discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: Making modules first class without breaking existing Openscad code

RW
Rogier Wolff
Fri, Sep 2, 2022 6:22 AM

On Thu, Sep 01, 2022 at 09:07:33AM -0700, Jordan Brown wrote:

Also, as I think of it, I don't know what the arguments to such a call
would be. At least in my mental model, this is a data value, not a
module, so what would arguments mean?

You instantiate the module.

You can make complex "assemblies" of a named variable.

The simplest examples can also be done with the "children () "
construct but I'm pretty sure that you can do more complex stuff with
this. For example,

module hexsocketscrew (size, len) {...}
module hexheadscrew (size, len) {...}

my_3d_printer (screw=hexsocketscrew);
translate ([500,0,]) my_3d_printer (screw=hexheadscrew);

The 3D printer model will need to instantiate different sizes of the
screws, and having assigned an instantiatable module (with
parameters!) to a variable/parameter this becomes possible.

Roger. 

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

On Thu, Sep 01, 2022 at 09:07:33AM -0700, Jordan Brown wrote: > Also, as I think of it, I don't know what the arguments to such a call > would be. At least in my mental model, this is a data value, not a > module, so what would arguments mean? You instantiate the module. You can make complex "assemblies" of a named variable. The simplest examples can also be done with the "children () " construct but I'm pretty sure that you can do more complex stuff with this. For example, module hexsocketscrew (size, len) {...} module hexheadscrew (size, len) {...} my_3d_printer (screw=hexsocketscrew); translate ([500,0,]) my_3d_printer (screw=hexheadscrew); The 3D printer model will need to instantiate different sizes of the screws, and having assigned an instantiatable module (with parameters!) to a variable/parameter this becomes possible. Roger. -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** f equals m times a. When your f is steady, and your m is going down your a is going up. -- Chris Hadfield about flying up the space shuttle.