|
|
Subscribe / Log in / New account

Implicit union

Implicit union

Posted Aug 26, 2020 23:15 UTC (Wed) by michaelkjohnson (subscriber, #41438)
Parent article: The programmer's CAD: OpenSCAD

A minor clarification that might help those just learning OpenSCAD:

At this point in the process, the cylinder and cube are independent, overlapping solids to OpenSCAD. To join them together, we wrap the code with a union operation, which takes all of the solids defined within it and combines them into a single solid in the model.
That's potentially misleading, depending on how it is read. The union operator is not needed to merely fuse geometrical elements. OpenSCAD doesn't have a concept of physically-conjoint independent objects, and mere concatenation of objects is geometrically sufficient. The union operator is useful in the context of other operators that interpret their child objects depending on position, primarily difference, as in the case that you used it. It's used to organize the object tree before rendering, and doesn't add semantics to the rendering process itself. Put another way, you are grouping operations not solids.

From the manual's documentation of union:
Remark: union is implicit when not used. But it is mandatory, for example, in difference to group first child nodes into one.

I've seen plenty of OpenSCAD code that overuses union and in fact especially in my first OpenSCAD code overused it a lot before I understood that point.


to post comments

Implicit union

Posted Aug 27, 2020 18:10 UTC (Thu) by coogle (guest, #138507) [Link]

Thank you for pointing that out, I can see how that sentence might accidentally send people down the wrong road -- I was not explicit on using union() use in conjunction with difference() there.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds