SolidCode / SolidPython

A python frontend for solid modelling that compiles to OpenSCAD
1.11k stars 173 forks source link

Add support for using custom iterables as parameters #108

Closed Michael0x2a closed 5 years ago

Michael0x2a commented 5 years ago

This pull request adjusts the way SolidPython converts Python parameters into OpenSCAD parameters by converting any iterable object into a vector, not just list, tuples, and numpy ndarrays.

This means it's now possible to write Python code that looks like this:

from euclid3 import Vector3
from solidpython import *

model = cube(size=Vector3(1, 2, 3))
scad_render_to_file(model, 'cube.scad')

This program previously used to generate invalid OpenSCAD code -- the py2openscad(...) would fall back to calling str(...) on the Vector3, producing cube(size = Vector3(1, 2, 3)) as output.

nickc92 commented 5 years ago

Hi Michael, thanks for the contribution. Seems like a good idea; I can't think of any downsides. Any thoughts, Evan?

etjones commented 5 years ago

Looks good. Also, thanks for including the unit test; that's rare in pull requests, and appreciated!