Skip to content

Commit 076ab2d

Browse files
Accept IncludedOpenSCADObject for all arguments to OpenSCADObjects. This allows us to accept calculations made in imported OpenSCAD as well as native Python ones
1 parent 126a072 commit 076ab2d

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

solid/solidpython.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,11 @@ def _find_include_strings(obj: Union[IncludedOpenSCADObject, OpenSCADObject]) ->
398398
include_strings.add(obj.include_string)
399399
for child in obj.children:
400400
include_strings.update(_find_include_strings(child))
401+
# We also accept IncludedOpenSCADObject instances as parameters to functions,
402+
# so search in obj.params as well
403+
for param in obj.params.values():
404+
if isinstance(param, OpenSCADObject):
405+
include_strings.update(_find_include_strings(param))
401406
return include_strings
402407

403408
def scad_render(scad_object: OpenSCADObject, file_header: str = '') -> str:
@@ -757,6 +762,8 @@ def py2openscad(o: Union[bool, float, str, Iterable]) -> str:
757762
if type(o).__name__ == "ndarray":
758763
import numpy # type: ignore
759764
return numpy.array2string(o, separator=",", threshold=1000000000)
765+
if isinstance(o, IncludedOpenSCADObject):
766+
return o._render()[1:-1]
760767
if hasattr(o, "__iter__"):
761768
s = "["
762769
first = True

0 commit comments

Comments
 (0)