[OpenSCAD] sumUp() to Replace Difference() (in most cases)
pproj at posteo.de
Fri Oct 7 09:56:29 EDT 2016
Everyone: i think this a very important point of the lib (it should be
be placed somewhere in the docs): you can now group things by their
semantic meaning and not by weather you are going to add or remove them.
On 07.10.2016 00:34, Ronaldo Persiano wrote:
> From one point of view, it is interesting that it is possible to add()
> and remove() parts in any order inside sumUp(). But this may also make
> codes harder to understand. I cannot judge it without trying it
i actually think that is the very thing which makes the sumUp()
attractive - the code shorter and easier, because you can now group
things by their semantic meaning and not by weather you are going to add
or remove them.
say you want to make holes and add screws at some area of your model.
with difference() you would have to translate and rotate each of them
with reference to some third "zero-coordinate":
first for the subtracted part(holes) and then duplicating the same
translation and rotation for the screws.
it is impossible to say to openscad to "simply put screws just where you
have made holes" because the screws are positive and holes are made
inside the difference()
that is code redundancy something everybody is trying to avoid for good
with sumup() you could just group stuff by their meaning and do
you could even move added part() in relation to the subtracted part not
some third "zero-coordinates", which is practically impossible with
difference() you have to hide your transformation by putting them into
transforming modules, and a lot of them! sometimes you have to manually
calculate the reverse transformation if you want to do something
relative to the part which is subtracted. quite terrible stuff.
but with sumUp () it is easy
translate([0,0,2]) //move the bolts 2 mm out of the hole
the same goes for "FOR" which can multiply holes and bolts in one step.
beside this now you can now put all this inside of a module, and even
add stuff which you want to be added before your remove()(and thus -
subtracted from) by using add()
> Although I have not fully grasped the technique you developed I guess
> it may be helpful in other contexts.
> 2016-10-06 19:13 GMT-03:00 pproj <pproj at posteo.de>:
>> hmm.. there must be a misunderstanding.
>> i have stated that sumUp() is slower than difference() in complex
>> projects (thats its main drawback) and asked if it can be hardcoded
>> to make it faster...
>> i think we are of the same opinion on that. i believe the
>> cleanliness of code, reduction of nesting and thus redundancy by far
>> outweigh the very unpleasant fact that i have to wait for several
>> minutes for a complex model to render, and this would have been
>> times faster with the messier difference()-using code
> OpenSCAD mailing list
> Discuss at lists.openscad.org
More information about the Discuss