@@ -43,7 +43,6 @@ def _find_include_strings(obj):
4343 include_strings .update (_find_include_strings (child ))
4444 return include_strings
4545
46-
4746def scad_render (scad_object , file_header = '' ):
4847 # Make this object the root of the tree
4948 root = scad_object
@@ -57,7 +56,6 @@ def scad_render(scad_object, file_header=''):
5756 scad_body = root ._render ()
5857 return file_header + includes + scad_body
5958
60-
6159def scad_render_animated (func_to_animate , steps = 20 , back_and_forth = True , filepath = None , file_header = '' ):
6260 # func_to_animate takes a single float argument, _time in [0, 1), and
6361 # returns an OpenSCADObject instance.
@@ -117,14 +115,12 @@ def scad_render_animated(func_to_animate, steps=20, back_and_forth=True, filepat
117115 "}\n " % vars ())
118116 return rendered_string
119117
120-
121118def scad_render_animated_file (func_to_animate , steps = 20 , back_and_forth = True ,
122119 filepath = None , file_header = '' , include_orig_code = True ):
123120 rendered_string = scad_render_animated (func_to_animate , steps ,
124121 back_and_forth , file_header )
125122 return _write_code_to_file (rendered_string , filepath , include_orig_code )
126123
127-
128124def scad_render_to_file (scad_object , filepath = None , file_header = '' , include_orig_code = True ):
129125
130126 header = "// Generated by SolidPython {version} on {date}\n " .format (
@@ -135,7 +131,6 @@ def scad_render_to_file(scad_object, filepath=None, file_header='', include_orig
135131 rendered_string = scad_render (scad_object , header )
136132 return _write_code_to_file (rendered_string , filepath , include_orig_code )
137133
138-
139134def _write_code_to_file (rendered_string , filepath = None , include_orig_code = True ):
140135 try :
141136 calling_file = Path (calling_module (stack_depth = 3 ).__file__ ).absolute ()
@@ -148,18 +143,16 @@ def _write_code_to_file(rendered_string, filepath=None, include_orig_code=True):
148143 # If filepath isn't supplied, place a .scad file with the same name
149144 # as the calling module next to it
150145 if not filepath :
151- filepath = filepath . with_ext ('.scad' )
146+ filepath = calling_file . with_suffix ('.scad' )
152147 except AttributeError as e :
153148 # If no calling_file was found, this is being called from the terminal.
154149 # We can't read original code from a file, so don't try,
155150 # and can't read filename from the calling file either, so just save to
156151 # solid.scad.
157152 if not filepath :
158153 filepath = Path ().absolute () / 'solid.scad'
159-
160154 Path (filepath ).write_text (rendered_string )
161- return True
162-
155+ return filepath
163156
164157def _get_version ():
165158 # Returns SolidPython version
@@ -181,7 +174,6 @@ def _get_version():
181174
182175 raise RuntimeError ("Unable to determine software version." )
183176
184-
185177def sp_code_in_scad_comment (calling_file ):
186178 # Once a SCAD file has been created, it's difficult to reconstruct
187179 # how it got there, since it has no variables, modules, etc. So, include
@@ -339,7 +331,6 @@ def _unsubbed_keyword(subbed_keyword):
339331 shortened = subbed_keyword [:- 1 ]
340332 return shortened if shortened in PYTHON_ONLY_RESERVED_WORDS else subbed_keyword
341333
342-
343334# =========================
344335# = Internal Utilities =
345336# =========================
@@ -711,6 +702,5 @@ def py2openscad(o):
711702 return s
712703 return str (o )
713704
714-
715705def indent (s ):
716706 return s .replace ("\n " , "\n \t " )
0 commit comments