LWN: Comments on "The programmer's CAD: OpenSCAD" https://lwn.net/Articles/829489/ This is a special feed containing comments posted to the individual LWN article titled "The programmer's CAD: OpenSCAD". en-us Fri, 29 Aug 2025 09:43:20 +0000 Fri, 29 Aug 2025 09:43:20 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Why $ in variable names? https://lwn.net/Articles/830552/ https://lwn.net/Articles/830552/ michaelkjohnson <div class="FormattedComment"> TIL!<br> <p> It surprises me not at all that nophead (of NopSCADlib) provides an example taking advantage of the dynamic scope:<br> <p> <a href="http://forum.openscad.org/Special-variable-scoping-rules-tp20305p20366.html">http://forum.openscad.org/Special-variable-scoping-rules-...</a><br> </div> Thu, 03 Sep 2020 19:28:17 +0000 Why $ in variable names? https://lwn.net/Articles/830537/ https://lwn.net/Articles/830537/ t-paul <div class="FormattedComment"> There is also a difference in scoping. The &quot;$&quot; variables are dynamically scoped so using them for everything could cause unexpected results.<br> </div> Thu, 03 Sep 2020 16:55:46 +0000 MCAD and NopSCADlib https://lwn.net/Articles/829715/ https://lwn.net/Articles/829715/ coogle <div class="FormattedComment"> Oh wow, I wasn&#x27;t familiar with NopSCADlib, that&#x27;s a great package of components. Thanks for the tip!<br> </div> Thu, 27 Aug 2020 18:13:40 +0000 Implicit union https://lwn.net/Articles/829712/ https://lwn.net/Articles/829712/ coogle <div class="FormattedComment"> 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. <br> </div> Thu, 27 Aug 2020 18:10:56 +0000 Why $ in variable names? https://lwn.net/Articles/829711/ https://lwn.net/Articles/829711/ coogle <div class="FormattedComment"> There isn&#x27;t a technical reason why I prefaced variables with $, other than perhaps force of habit from other languages. It is a habit I should break for OpenSCAD code, because you are correct that things like $fa and $fs carry special meaning and I wouldn&#x27;t want to accidentally create a problem there.<br> </div> Thu, 27 Aug 2020 18:05:37 +0000 MCAD and NopSCADlib https://lwn.net/Articles/829704/ https://lwn.net/Articles/829704/ gerdesj <div class="FormattedComment"> Thanks for that. The quality of the documentation for NopSCADlib is awesome.<br> <p> My printer is going to be very busy soon.<br> </div> Thu, 27 Aug 2020 16:07:05 +0000 SolidPython and ViewSCAD https://lwn.net/Articles/829662/ https://lwn.net/Articles/829662/ esemwy <div class="FormattedComment"> I’m partial to SolidPython and ViewSCAD in a Jupyter notebook. I find it less clunky than the Qt app, and, of course, python. <br> <p> <a href="https://solidpython.readthedocs.io/en/latest/">https://solidpython.readthedocs.io/en/latest/</a><br> <a href="https://github.com/nickc92/ViewSCAD">https://github.com/nickc92/ViewSCAD</a><br> </div> Thu, 27 Aug 2020 12:08:49 +0000 Why $ in variable names? https://lwn.net/Articles/829657/ https://lwn.net/Articles/829657/ smurf <div class="FormattedComment"> Some people code like everything is Perl ...?<br> </div> Thu, 27 Aug 2020 06:37:55 +0000 MCAD and NopSCADlib https://lwn.net/Articles/829646/ https://lwn.net/Articles/829646/ michaelkjohnson It is reasonably common to have MCAD packaged with OpenSCAD; for example, Fedora packages both openscad and openscad-MCAD.</p> If you are designing anything that uses components similar to those used in 3D printing, you might find <a href="https://github.com/nophead/NopSCADlib">NopSCADlib</a> worth looking though. It has an amazing variety of carefully-modeled components. Wed, 26 Aug 2020 23:27:23 +0000 Why $ in variable names? https://lwn.net/Articles/829645/ https://lwn.net/Articles/829645/ michaelkjohnson In my OpenSCAD experience, <tt>$</tt> is used for reserved variables such as <tt>$fn</tt>, and normal variables are not commonly prefixed with a <tt>$</tt>. I see that you used both a <tt>$</tt> and a <tt>$_</tt> convention that I don't recognize from other OpenSCAD exemplars. Is there a reason beyond personal convention for this form in your example? Wed, 26 Aug 2020 23:20:18 +0000 Implicit union https://lwn.net/Articles/829644/ https://lwn.net/Articles/829644/ michaelkjohnson A minor clarification that might help those just learning OpenSCAD: <blockquote> 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. </blockquote> That's potentially misleading, depending on how it is read. The <tt>union</tt> 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 <i>geometrically</i> sufficient. The <tt>union</tt> operator is useful in the context of other operators that interpret their child objects depending on position, primarily <tt>difference</tt>, as in the case that you used it. It's used to organize the object tree <i>before rendering</i>, and doesn't add semantics to the rendering process itself. Put another way, you are grouping <i>operations</i> not <i>solids</i>.</p> From the manual's documentation of union: <blockquote> Remark: union is implicit when not used. But it is mandatory, for example, in difference to group first child nodes into one. </blockquote></p> I've seen plenty of OpenSCAD code that overuses <tt>union</tt> and in fact especially in my first OpenSCAD code overused it a lot before I understood that point. Wed, 26 Aug 2020 23:15:30 +0000