[OpenSCAD] Using children with let

John Savage john at jegsav.com
Wed Sep 12 13:30:41 EDT 2018

Hi Nop Head(?) Thanks for your reply. I get it now. John


From: nop head [mailto:nop.head at gmail.com] 
Sent: 12 Sep 2018 04:05
To: john at jegsav.com; OpenSCAD general discussion
Subject: Re: [OpenSCAD] Using children with let


OpenSCAD variables have lexical scope by default, so they can only be seen in the block they are defined in. So you could do children(a) to access the 23rd child but a is not visible outside leta() and more specifically only under the let().

However, if you use $a it will have dynamic scope and be accessible in all the modules and functions called from the block it is defined in.


On 12 September 2018 at 15:06, John Savage <john at jegsav.com> wrote:

I would like to be able to write a single let() statement and use it on multiple modules. A simple example is


module leta(){





leta() cylinder(h=a, d=a); // Doesn't work, a is unknown here.


However this does work:


module move(x){





module cone_rod(){





move(0) cone_rod();      // Works as expected

move(20) cone_rod();     // Works as expected


What’s the difference and why doesn’t the first example work?



Image removed by sender.

OpenSCAD mailing list
Discuss at lists.openscad.org


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20180912/b42ec8a2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ~WRD000.jpg
Type: image/jpeg
Size: 823 bytes
Desc: not available
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20180912/b42ec8a2/attachment.jpg>

More information about the Discuss mailing list