diff --git a/solid/core/object_base.py b/solid/core/object_base.py index 2e6ca4c0..4e7d109a 100644 --- a/solid/core/object_base.py +++ b/solid/core/object_base.py @@ -37,13 +37,16 @@ def __call__(self, *args): def __repr__(self): return self.as_scad() - def as_scad(self, _fn=None): + def as_scad(self, scad_interface=None): from .scad_render import scad_render - return scad_render(self, _fn=_fn)[:-1] + return scad_render(self, scad_interface=scad_interface)[:-1] - def save_as_scad(self, filename='', outdir='', _fn=None): + def save_as_scad(self, filename='', outdir='', scad_interface=None): from .scad_render import scad_render_to_file - return scad_render_to_file(self, filename, outdir, _fn=_fn) + return scad_render_to_file(self, + filename, + outdir, + scad_interface=scad_interface) class OpenSCADObject(ObjectBase): def __init__(self, name, params): diff --git a/solid/core/scad_render.py b/solid/core/scad_render.py index f17b1595..6f90d097 100644 --- a/solid/core/scad_render.py +++ b/solid/core/scad_render.py @@ -8,7 +8,7 @@ # ========================================= # = Rendering Python code to OpenSCAD code= # ========================================= -def scad_render(root, file_header = '', _fn=None, scad_interface=None): +def scad_render(root, file_header = '', scad_interface=None): #get a list of all used and included files includes = get_include_string() @@ -26,9 +26,6 @@ def scad_render(root, file_header = '', _fn=None, scad_interface=None): extensions_footer_str = default_extension_manager.call_post_render(root) extensions_footer_str += "\n" if extensions_footer_str else '' - if _fn: - file_header += f'$fn = {_fn};\n\n' - if scad_interface != None: file_header += scad_interface.get_header_str() @@ -36,14 +33,14 @@ def scad_render(root, file_header = '', _fn=None, scad_interface=None): + extensions_footer_str def scad_render_to_file(scad_object, filename=None, out_dir='', - file_header='', include_orig_code=True, _fn=None, + file_header='', include_orig_code=True, scad_interface = None): if out_dir == None: out_dir = '' header = f"// Generated by ExpSolidPython\n" + file_header + "\n" - rendered_string = scad_render(scad_object, header, _fn, scad_interface) + rendered_string = scad_render(scad_object, header, scad_interface) return _write_to_file(rendered_string, filename, out_dir) diff --git a/solid/examples/11-fonts.py b/solid/examples/11-fonts.py index ee94bdb7..3d5b3f55 100644 --- a/solid/examples/11-fonts.py +++ b/solid/examples/11-fonts.py @@ -12,6 +12,5 @@ scad = ScadInterface() scad.register_font("11-font/RichEatin.otf") -t = text(font="Rich Eatin'", text="blablub") -scad_render_to_file(t, scad_interface=scad) +text(font="Rich Eatin'", text="blablub").save_as_scad(scad_interface=scad)