taxpon / openpyscad

Python library to generate OpenSCAD source code. This library provides intuitive interface when you handle 3D data.
https://pypi.org/project/openpyscad/
MIT License
119 stars 21 forks source link

Translation doesn't work on existing objects #28

Open edmundsj opened 4 years ago

edmundsj commented 4 years ago

It looks like if I create a cube and then attempt to translate it, it doesn't do anything (I still have the same cube):

my_cube = ops.Cube([10, 10, 10])
my_cube.translate([0, 0, 50])

But if I do it in one step, then it renders correctly:

my_cube = ops.Cube([10, 10, 10]).tranlate([0, 0, 50])

Is there a reason for this behavior? Is it dramatically easier to implement? This seems to break my intuition about how to use OOP. It also just leads to ugly-long lines of code.

edmundsj commented 4 years ago

Nope, it doesn't break my intuition, because this works just fine:

my_cube = ops.Cube([10, 10, 10])
my_cube = my_cube.translate([0, 0, 50])

Can you state somewhere that the transformations return the modified object, but do not modify it in place? This wasn't clear from the README. Additional API documentation would be very helpful. It's a neat module!