|
28 | 28 | {'name': 'union', 'args': [], 'kwargs': []} , |
29 | 29 | {'name': 'intersection', 'args': [], 'kwargs': []} , |
30 | 30 | {'name': 'difference', 'args': [], 'kwargs': []} , |
31 | | - {'name': 'hole', 'args': [], 'kwargs': []} , |
32 | | - {'name': 'part', 'args': [], 'kwargs': []} , |
| 31 | + {'name': 'hole', 'args': [], 'kwargs': []} , |
| 32 | + {'name': 'part', 'args': [], 'kwargs': []} , |
33 | 33 |
|
34 | 34 | # Transforms |
35 | 35 | {'name': 'translate', 'args': [], 'kwargs': ['v']} , |
|
43 | 43 | {'name': 'render', 'args': [], 'kwargs': ['convexity']}, |
44 | 44 |
|
45 | 45 | # 2D to 3D transitions |
| 46 | + # FIXME: linear_extrude now has a scale parameter as of OpenSCAD 13.06 -ETJ 20 Jan 2014 |
| 47 | + # Also: Check release notes for any other changes to the language, here: |
| 48 | + # https://github.com/openscad/openscad/blob/master/RELEASE_NOTES |
| 49 | + # Add Colors as here: http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations |
46 | 50 | {'name': 'linear_extrude', 'args': [], 'kwargs': ['height', 'center', 'convexity', 'twist','slices']} , |
47 | 51 | {'name': 'rotate_extrude', 'args': [], 'kwargs': ['convexity', 'segments']} , |
48 | | - {'name': 'dxf_linear_extrude', 'args': ['file'], 'kwargs': ['layer', 'height', 'center', 'convexity', 'twist', 'slices']} , |
| 52 | + {'name': 'dxf_linear_extrude', 'args': ['file'],'kwargs': ['layer', 'height', 'center', 'convexity', 'twist', 'slices']} , |
49 | 53 | {'name': 'projection', 'args': [], 'kwargs': ['cut']} , |
50 | 54 | {'name': 'surface', 'args': ['file'], 'kwargs': ['center','convexity']} , |
51 | 55 |
|
| 56 | + #Child/ren |
| 57 | + {'name': 'child', 'args': [], 'kwargs': ['index', 'vector', 'range']} , |
| 58 | + {'name': 'children', 'args': [], 'kwargs': ['index', 'vector', 'range']} , |
| 59 | + |
| 60 | + # FIXME: support 'resize' as well -ETJ 20 Jan 2014 |
| 61 | + |
52 | 62 | # Import/export |
53 | | - {'name': 'import_stl', 'args': ['filename'], 'kwargs': ['convexity']} , |
| 63 | + {'name': 'import_stl', 'args': ['file'], 'kwargs': ['layer', 'origin']} , |
| 64 | + {'name': 'import_dxf', 'args': ['file'], 'kwargs': ['layer', 'origin']}, |
| 65 | + {'name': 'import_', 'args': ['file'], 'kwargs': ['layer', 'origin']}, |
| 66 | + |
54 | 67 |
|
55 | 68 | # Modifiers; These are implemented by calling e.g. |
56 | 69 | # obj.set_modifier( '*') or |
@@ -87,6 +100,19 @@ def __init__( self): |
87 | 100 | def __init__( self): |
88 | 101 | openscad_object.__init__(self, 'part', {}) |
89 | 102 | self.set_part_root( True) |
| 103 | + ''', |
| 104 | + # Import, import_dxf, and import_stl all resolve to the same OpenSCAD keyword, 'import' |
| 105 | + 'import_':'''class import_( openscad_object): |
| 106 | + def __init__( self, file, origin=(0,0), layer=None): |
| 107 | + openscad_object.__init__(self, 'import', {'file':file, 'origin':origin, 'layer':layer}) |
| 108 | + ''', |
| 109 | + 'import_dxf':'''class import_dxf( openscad_object): |
| 110 | + def __init__( self, file, origin=(0,0), layer=None): |
| 111 | + openscad_object.__init__(self, 'import', {'file':file, 'origin':origin, 'layer':layer}) |
| 112 | + ''', |
| 113 | + 'import_stl':'''class import_stl( openscad_object): |
| 114 | + def __init__( self, file, origin=(0,0), layer=None): |
| 115 | + openscad_object.__init__(self, 'import', {'file':file, 'origin':origin, 'layer':layer}) |
90 | 116 | ''' |
91 | 117 |
|
92 | 118 | } |
@@ -259,18 +285,26 @@ def scad_render_animated_file( func_to_animate, steps=20, back_and_forth=True, f |
259 | 285 | def scad_render_to_file( scad_object, filepath=None, file_header='', include_orig_code=True): |
260 | 286 | rendered_string = scad_render( scad_object, file_header) |
261 | 287 |
|
262 | | - calling_file = os.path.abspath( calling_module().__file__) |
263 | | - |
264 | | - if include_orig_code: |
265 | | - rendered_string += sp_code_in_scad_comment( calling_file) |
266 | | - |
267 | | - # This write is destructive, and ought to do some checks that the write |
268 | | - # was successful. |
269 | | - # If filepath isn't supplied, place a .scad file with the same name |
270 | | - # as the calling module next to it |
271 | | - if not filepath: |
272 | | - filepath = os.path.splitext( calling_file)[0] + '.scad' |
273 | | - |
| 288 | + try: |
| 289 | + calling_file = os.path.abspath( calling_module().__file__) |
| 290 | + |
| 291 | + if include_orig_code: |
| 292 | + rendered_string += sp_code_in_scad_comment( calling_file) |
| 293 | + |
| 294 | + # This write is destructive, and ought to do some checks that the write |
| 295 | + # was successful. |
| 296 | + # If filepath isn't supplied, place a .scad file with the same name |
| 297 | + # as the calling module next to it |
| 298 | + if not filepath: |
| 299 | + filepath = os.path.splitext( calling_file)[0] + '.scad' |
| 300 | + except AttributeError, e: |
| 301 | + # If no calling_file was found, this is being called from the terminal. |
| 302 | + # We can't read original code from a file, so don't try, |
| 303 | + # and can't read filename from the calling file either, so just save to |
| 304 | + # solid.scad. |
| 305 | + if not filepath: |
| 306 | + filepath = os.path.abspath('.') + "/solid.scad" |
| 307 | + |
274 | 308 | f = open( filepath,"w") |
275 | 309 | f.write( rendered_string) |
276 | 310 | f.close() |
|
0 commit comments