Skip to content

Commit 46cc89f

Browse files
Fixes #20, so that OpenSCAD’s use() and include() functions still work, even if you don’t import SolidPython as ‘form solid import *’
1 parent b03143c commit 46cc89f

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎solid/solidpython.py‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -615,20 +615,23 @@ def new_openscad_class_str( class_name, args=[], kwargs=[], include_file_path=No
615615
for kwarg in kwargs:
616616
args_str += ', %(kwarg)s=None'%vars()
617617
args_pairs += "'%(kwarg)s':%(kwarg)s, "%vars()
618-
618+
619619
if include_file_path:
620-
result = ("class %(class_name)s( included_openscad_object):\n"
620+
# NOTE the explicit import of 'solid' below. This is a fix for:
621+
# https://github.com/SolidCode/SolidPython/issues/20 -ETJ 16 Jan 2014
622+
result = ("import solid\n"
623+
"class %(class_name)s( solid.included_openscad_object):\n"
621624
" def __init__(self%(args_str)s):\n"
622-
" included_openscad_object.__init__(self, '%(class_name)s', {%(args_pairs)s }, include_file_path='%(include_file_path)s', use_not_include=%(use_not_include)s )\n"
625+
" solid.included_openscad_object.__init__(self, '%(class_name)s', {%(args_pairs)s }, include_file_path='%(include_file_path)s', use_not_include=%(use_not_include)s )\n"
623626
" \n"
624627
"\n"%vars())
625628
else:
626-
result = ('class %(class_name)s( openscad_object):\n'
629+
result = ("class %(class_name)s( openscad_object):\n"
627630
" def __init__(self%(args_str)s):\n"
628631
" openscad_object.__init__(self, '%(class_name)s', {%(args_pairs)s })\n"
629632
" \n"
630633
"\n"%vars())
631-
634+
632635
return result
633636

634637
def py2openscad(o):

0 commit comments

Comments
 (0)