FD
Fergal Daly
Sat, Jun 20, 2020 9:50 AM
I've recently started using OpenSCAD, I'm very impressed, thanks to all the
people who made it real.
I think this is a feature request but I'm curious if there's something like
it that I am missing or if this is a possibility in the future.
One thing I find is that I want to export calculations or measurements from
inside a module to outside. E.g. the module builds a shape with a certain
height, that height was computed based on parameters to the module. I'd
like to be able to refer to that height outside, e.g. to pass a parameter
for another module. I don't see a way to do this at the moment. It seems
like it would also require being able to assign instances of modules to
variables.
E.g. I want to drill a cylindrical hole that is wide enough to fit a
countersunk bolt head and I'm using BOSL. So I use the exported function
from BOSL get_metric_socket_cap_diam() but the programmer in me wants to
encapsulate this in the bolt itself. E.g.
use <lib/BOSL/metric_screws.scad>
my_bolt = metric_bolt(size=5, l=30, headtype="countersunk"); // renders
nothing
cylinder(r=bolt.head_diam); // renders a compatible cylinder
Also being able to access some positional information for an instance of a
module e.g. the module's "origin" and alignment-vector would be really
helpful for correctly positioning things relative to each other.
Is there already something I'm missing that would do this? If not, is there
any chance of such features?
F
I've recently started using OpenSCAD, I'm very impressed, thanks to all the
people who made it real.
I think this is a feature request but I'm curious if there's something like
it that I am missing or if this is a possibility in the future.
One thing I find is that I want to export calculations or measurements from
inside a module to outside. E.g. the module builds a shape with a certain
height, that height was computed based on parameters to the module. I'd
like to be able to refer to that height outside, e.g. to pass a parameter
for another module. I don't see a way to do this at the moment. It seems
like it would also require being able to assign instances of modules to
variables.
E.g. I want to drill a cylindrical hole that is wide enough to fit a
countersunk bolt head and I'm using BOSL. So I use the exported function
from BOSL get_metric_socket_cap_diam() but the programmer in me wants to
encapsulate this in the bolt itself. E.g.
use <lib/BOSL/metric_screws.scad>
my_bolt = metric_bolt(size=5, l=30, headtype="countersunk"); // renders
nothing
cylinder(r=bolt.head_diam); // renders a compatible cylinder
Also being able to access some positional information for an instance of a
module e.g. the module's "origin" and alignment-vector would be really
helpful for correctly positioning things relative to each other.
Is there already something I'm missing that would do this? If not, is there
any chance of such features?
F
NH
nop head
Sat, Jun 20, 2020 11:32 AM
There isn't a way to do that currently but I use a different way to
represent objects in my library. I describe everything with a list and pass
that as the first parameter to all functions and modules that operate on it.
Your example then becomes
include <NopSCADlib/screws.scad>
my_bolt = M5_cs_cap_screw; // assigns object description list to my_bolt
cylinder(r = screw_head_radius(my_bolt), h = screw_head_height(my_bolt));
// Draws a compatible cylinder
screw(my_bolt, 30); // Draw a 30mm screw
My screws always have their origin at the part of the head that mates with
the surface and they always point down. So for a countersunk screw it would
be the top of the head, for a cap head screw it would be the top of the
stem. So they are always translated and rotated to the top of the screw
hole. No need for origin information or alignment vectors as all objects
have the most convenient origin by convention.
On Sat, 20 Jun 2020 at 10:51, Fergal Daly fergald@gmail.com wrote:
I've recently started using OpenSCAD, I'm very impressed, thanks to all
the people who made it real.
I think this is a feature request but I'm curious if there's something
like it that I am missing or if this is a possibility in the future.
One thing I find is that I want to export calculations or measurements
from inside a module to outside. E.g. the module builds a shape with a
certain height, that height was computed based on parameters to the module.
I'd like to be able to refer to that height outside, e.g. to pass a
parameter for another module. I don't see a way to do this at the moment.
It seems like it would also require being able to assign instances of
modules to variables.
E.g. I want to drill a cylindrical hole that is wide enough to fit a
countersunk bolt head and I'm using BOSL. So I use the exported function
from BOSL get_metric_socket_cap_diam() but the programmer in me wants to
encapsulate this in the bolt itself. E.g.
use <lib/BOSL/metric_screws.scad>
my_bolt = metric_bolt(size=5, l=30, headtype="countersunk"); // renders
nothing
cylinder(r=bolt.head_diam); // renders a compatible cylinder
Also being able to access some positional information for an instance of a
module e.g. the module's "origin" and alignment-vector would be really
helpful for correctly positioning things relative to each other.
Is there already something I'm missing that would do this? If not, is
there any chance of such features?
F
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
There isn't a way to do that currently but I use a different way to
represent objects in my library. I describe everything with a list and pass
that as the first parameter to all functions and modules that operate on it.
Your example then becomes
include <NopSCADlib/screws.scad>
my_bolt = M5_cs_cap_screw; // assigns object description list to my_bolt
cylinder(r = screw_head_radius(my_bolt), h = screw_head_height(my_bolt));
// Draws a compatible cylinder
screw(my_bolt, 30); // Draw a 30mm screw
My screws always have their origin at the part of the head that mates with
the surface and they always point down. So for a countersunk screw it would
be the top of the head, for a cap head screw it would be the top of the
stem. So they are always translated and rotated to the top of the screw
hole. No need for origin information or alignment vectors as all objects
have the most convenient origin by convention.
On Sat, 20 Jun 2020 at 10:51, Fergal Daly <fergald@gmail.com> wrote:
> I've recently started using OpenSCAD, I'm very impressed, thanks to all
> the people who made it real.
>
> I think this is a feature request but I'm curious if there's something
> like it that I am missing or if this is a possibility in the future.
>
> One thing I find is that I want to export calculations or measurements
> from inside a module to outside. E.g. the module builds a shape with a
> certain height, that height was computed based on parameters to the module.
> I'd like to be able to refer to that height outside, e.g. to pass a
> parameter for another module. I don't see a way to do this at the moment.
> It seems like it would also require being able to assign instances of
> modules to variables.
>
> E.g. I want to drill a cylindrical hole that is wide enough to fit a
> countersunk bolt head and I'm using BOSL. So I use the exported function
> from BOSL get_metric_socket_cap_diam() but the programmer in me wants to
> encapsulate this in the bolt itself. E.g.
>
> use <lib/BOSL/metric_screws.scad>
> my_bolt = metric_bolt(size=5, l=30, headtype="countersunk"); // renders
> nothing
> cylinder(r=bolt.head_diam); // renders a compatible cylinder
>
> Also being able to access some positional information for an instance of a
> module e.g. the module's "origin" and alignment-vector would be really
> helpful for correctly positioning things relative to each other.
>
> Is there already something I'm missing that would do this? If not, is
> there any chance of such features?
>
> F
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
A
arnholm@arnholm.org
Sat, Jun 20, 2020 11:53 AM
On 2020-06-20 11:50, Fergal Daly wrote:
One thing I find is that I want to export calculations or measurements
from inside a module to outside. E.g. the module builds a shape with a
certain height, that height was computed based on parameters to the
module. I'd like to be able to refer to that height outside, e.g. to
pass a parameter for another module. I don't see a way to do this at
the moment. It seems like it would also require being able to assign
instances of modules to variables.
You cannot do that in OpenSCAD, the language does not offer/allow
retrieval of parameters. The typical way to do it would be to let each
cube, cylinder etc, be instances of classes with member functions to
retrieve the construction parameters. AngelCAD does exactly that, but
OpenSCAD does not.
E.g. I want to drill a cylindrical hole that is wide enough to fit a
countersunk bolt head and I'm using BOSL. So I use the exported
function from BOSL get_metric_socket_cap_diam() but the programmer in
me wants to encapsulate this in the bolt itself. E.g.
You want the ability to create user defined classes in addition to
built-in ones. You can do that in AngelCAD.
Also being able to access some positional information for an instance
of a module e.g. the module's "origin" and alignment-vector would be
really helpful for correctly positioning things relative to each
other.
One (partial) solution to this is to offer computation of bounding
boxes, which AngelCAD has.
Is there already something I'm missing that would do this? If not, is
there any chance of such features?
The OpenSCAD language is said to be a 'functional language', i.e. a
declarative style which by design does not allow retrieval of the kind
of information you are asking for. So I think there is a very low
probability that such features will appear in OpeSCAD.
Carsten Anrholm
On 2020-06-20 11:50, Fergal Daly wrote:
> One thing I find is that I want to export calculations or measurements
> from inside a module to outside. E.g. the module builds a shape with a
> certain height, that height was computed based on parameters to the
> module. I'd like to be able to refer to that height outside, e.g. to
> pass a parameter for another module. I don't see a way to do this at
> the moment. It seems like it would also require being able to assign
> instances of modules to variables.
You cannot do that in OpenSCAD, the language does not offer/allow
retrieval of parameters. The typical way to do it would be to let each
cube, cylinder etc, be instances of classes with member functions to
retrieve the construction parameters. AngelCAD does exactly that, but
OpenSCAD does not.
> E.g. I want to drill a cylindrical hole that is wide enough to fit a
> countersunk bolt head and I'm using BOSL. So I use the exported
> function from BOSL get_metric_socket_cap_diam() but the programmer in
> me wants to encapsulate this in the bolt itself. E.g.
You want the ability to create user defined classes in addition to
built-in ones. You can do that in AngelCAD.
> Also being able to access some positional information for an instance
> of a module e.g. the module's "origin" and alignment-vector would be
> really helpful for correctly positioning things relative to each
> other.
One (partial) solution to this is to offer computation of bounding
boxes, which AngelCAD has.
> Is there already something I'm missing that would do this? If not, is
> there any chance of such features?
The OpenSCAD language is said to be a 'functional language', i.e. a
declarative style which by design does not allow retrieval of the kind
of information you are asking for. So I think there is a very low
probability that such features will appear in OpeSCAD.
Carsten Anrholm
WF
William F. Adams
Sat, Jun 20, 2020 1:52 PM
My work-around for this sort of thing is to have a second/parallel program which imports all the parameters from the JSON file which the Customizer saves which then calculates the list of parts:
http://tug.org/TUGboat/tb40-2/tb125adams-3d.pdf
William
-----Original Message-----
From: Fergal Daly fergald@gmail.com
To: discuss@lists.openscad.org
Sent: Sat, Jun 20, 2020 5:50 am
Subject: [OpenSCAD] exporting information from a module?
I've recently started using OpenSCAD, I'm very impressed, thanks to all the people who made it real.
I think this is a feature request but I'm curious if there's something like it that I am missing or if this is a possibility in the future.
One thing I find is that I want to export calculations or measurements from inside a module to outside. E.g. the module builds a shape with a certain height, that height was computed based on parameters to the module. I'd like to be able to refer to that height outside, e.g. to pass a parameter for another module. I don't see a way to do this at the moment. It seems like it would also require being able to assign instances of modules to variables.
E.g. I want to drill a cylindrical hole that is wide enough to fit a countersunk bolt head and I'm using BOSL. So I use the exported function from BOSL get_metric_socket_cap_diam() but the programmer in me wants to encapsulate this in the bolt itself. E.g.
use <lib/BOSL/metric_screws.scad>
my_bolt = metric_bolt(size=5, l=30, headtype="countersunk"); // renders nothingcylinder(r=bolt.head_diam); // renders a compatible cylinder
Also being able to access some positional information for an instance of a module e.g. the module's "origin" and alignment-vector would be really helpful for correctly positioning things relative to each other.
Is there already something I'm missing that would do this? If not, is there any chance of such features?
F
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
My work-around for this sort of thing is to have a second/parallel program which imports all the parameters from the JSON file which the Customizer saves which then calculates the list of parts:
http://tug.org/TUGboat/tb40-2/tb125adams-3d.pdf
William
-----Original Message-----
From: Fergal Daly <fergald@gmail.com>
To: discuss@lists.openscad.org
Sent: Sat, Jun 20, 2020 5:50 am
Subject: [OpenSCAD] exporting information from a module?
I've recently started using OpenSCAD, I'm very impressed, thanks to all the people who made it real.
I think this is a feature request but I'm curious if there's something like it that I am missing or if this is a possibility in the future.
One thing I find is that I want to export calculations or measurements from inside a module to outside. E.g. the module builds a shape with a certain height, that height was computed based on parameters to the module. I'd like to be able to refer to that height outside, e.g. to pass a parameter for another module. I don't see a way to do this at the moment. It seems like it would also require being able to assign instances of modules to variables.
E.g. I want to drill a cylindrical hole that is wide enough to fit a countersunk bolt head and I'm using BOSL. So I use the exported function from BOSL get_metric_socket_cap_diam() but the programmer in me wants to encapsulate this in the bolt itself. E.g.
use <lib/BOSL/metric_screws.scad>
my_bolt = metric_bolt(size=5, l=30, headtype="countersunk"); // renders nothingcylinder(r=bolt.head_diam); // renders a compatible cylinder
Also being able to access some positional information for an instance of a module e.g. the module's "origin" and alignment-vector would be really helpful for correctly positioning things relative to each other.
Is there already something I'm missing that would do this? If not, is there any chance of such features?
F
_______________________________________________
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
F
fergald@gmail.com
Sun, Jun 21, 2020 6:08 AM
Thanks. Yeah, I was thinking about something like that. You could also have
your own translate and rotate that you can apply to these lists and manage
all of that but that's just all getting very clunky,
F
nophead wrote
There isn't a way to do that currently but I use a different way to
represent objects in my library. I describe everything with a list and
pass
that as the first parameter to all functions and modules that operate on
it.
Your example then becomes
include <NopSCADlib/screws.scad>
my_bolt = M5_cs_cap_screw; // assigns object description list to my_bolt
cylinder(r = screw_head_radius(my_bolt), h = screw_head_height(my_bolt));
// Draws a compatible cylinder
screw(my_bolt, 30); // Draw a 30mm screw
My screws always have their origin at the part of the head that mates with
the surface and they always point down. So for a countersunk screw it
would
be the top of the head, for a cap head screw it would be the top of the
stem. So they are always translated and rotated to the top of the screw
hole. No need for origin information or alignment vectors as all objects
have the most convenient origin by convention.
On Sat, 20 Jun 2020 at 10:51, Fergal Daly <
I've recently started using OpenSCAD, I'm very impressed, thanks to all
the people who made it real.
I think this is a feature request but I'm curious if there's something
like it that I am missing or if this is a possibility in the future.
One thing I find is that I want to export calculations or measurements
from inside a module to outside. E.g. the module builds a shape with a
certain height, that height was computed based on parameters to the
module.
I'd like to be able to refer to that height outside, e.g. to pass a
parameter for another module. I don't see a way to do this at the moment.
It seems like it would also require being able to assign instances of
modules to variables.
E.g. I want to drill a cylindrical hole that is wide enough to fit a
countersunk bolt head and I'm using BOSL. So I use the exported function
from BOSL get_metric_socket_cap_diam() but the programmer in me wants to
encapsulate this in the bolt itself. E.g.
use <lib/BOSL/metric_screws.scad>
my_bolt = metric_bolt(size=5, l=30, headtype="countersunk"); // renders
nothing
cylinder(r=bolt.head_diam); // renders a compatible cylinder
Also being able to access some positional information for an instance of
a
module e.g. the module's "origin" and alignment-vector would be really
helpful for correctly positioning things relative to each other.
Is there already something I'm missing that would do this? If not, is
there any chance of such features?
F
OpenSCAD mailing list
Thanks. Yeah, I was thinking about something like that. You could also have
your own translate and rotate that you can apply to these lists and manage
all of that but that's just all getting very clunky,
F
nophead wrote
> There isn't a way to do that currently but I use a different way to
> represent objects in my library. I describe everything with a list and
> pass
> that as the first parameter to all functions and modules that operate on
> it.
>
> Your example then becomes
>
> include <NopSCADlib/screws.scad>
> my_bolt = M5_cs_cap_screw; // assigns object description list to my_bolt
>
> cylinder(r = screw_head_radius(my_bolt), h = screw_head_height(my_bolt));
> // Draws a compatible cylinder
>
> screw(my_bolt, 30); // Draw a 30mm screw
>
> My screws always have their origin at the part of the head that mates with
> the surface and they always point down. So for a countersunk screw it
> would
> be the top of the head, for a cap head screw it would be the top of the
> stem. So they are always translated and rotated to the top of the screw
> hole. No need for origin information or alignment vectors as all objects
> have the most convenient origin by convention.
>
> On Sat, 20 Jun 2020 at 10:51, Fergal Daly <
> fergald@
> > wrote:
>
>> I've recently started using OpenSCAD, I'm very impressed, thanks to all
>> the people who made it real.
>>
>> I think this is a feature request but I'm curious if there's something
>> like it that I am missing or if this is a possibility in the future.
>>
>> One thing I find is that I want to export calculations or measurements
>> from inside a module to outside. E.g. the module builds a shape with a
>> certain height, that height was computed based on parameters to the
>> module.
>> I'd like to be able to refer to that height outside, e.g. to pass a
>> parameter for another module. I don't see a way to do this at the moment.
>> It seems like it would also require being able to assign instances of
>> modules to variables.
>>
>> E.g. I want to drill a cylindrical hole that is wide enough to fit a
>> countersunk bolt head and I'm using BOSL. So I use the exported function
>> from BOSL get_metric_socket_cap_diam() but the programmer in me wants to
>> encapsulate this in the bolt itself. E.g.
>>
>> use <lib/BOSL/metric_screws.scad>
>> my_bolt = metric_bolt(size=5, l=30, headtype="countersunk"); // renders
>> nothing
>> cylinder(r=bolt.head_diam); // renders a compatible cylinder
>>
>> Also being able to access some positional information for an instance of
>> a
>> module e.g. the module's "origin" and alignment-vector would be really
>> helpful for correctly positioning things relative to each other.
>>
>> Is there already something I'm missing that would do this? If not, is
>> there any chance of such features?
>>
>> F
>> _______________________________________________
>> OpenSCAD mailing list
>>
> Discuss@.openscad
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@.openscad
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
Sent from: http://forum.openscad.org/
F
fergald@gmail.com
Sun, Jun 21, 2020 6:25 AM
On 2020-06-20 11:50, Fergal Daly wrote:
One thing I find is that I want to export calculations or measurements
from inside a module to outside. E.g. the module builds a shape with a
certain height, that height was computed based on parameters to the
module. I'd like to be able to refer to that height outside, e.g. to
pass a parameter for another module. I don't see a way to do this at
the moment. It seems like it would also require being able to assign
instances of modules to variables.
You cannot do that in OpenSCAD, the language does not offer/allow
retrieval of parameters. The typical way to do it would be to let each
cube, cylinder etc, be instances of classes with member functions to
retrieve the construction parameters. AngelCAD does exactly that, but
OpenSCAD does not.
E.g. I want to drill a cylindrical hole that is wide enough to fit a
countersunk bolt head and I'm using BOSL. So I use the exported
function from BOSL get_metric_socket_cap_diam() but the programmer in
me wants to encapsulate this in the bolt itself. E.g.
You want the ability to create user defined classes in addition to
built-in ones. You can do that in AngelCAD.
Well not exactly, since you can't query the built-in ones either because you
cannot refer to them. Missing piece #1 is the ability to refer to a
constructed object, not just immediately add it to the tree. Then ideally
you would be able to query any of it's input parameters any of the
calculated parameters it chooses to expose and some standard parameters like
origin and orientation.
cacb wrote
Also being able to access some positional information for an instance
of a module e.g. the module's "origin" and alignment-vector would be
really helpful for correctly positioning things relative to each
other.
One (partial) solution to this is to offer computation of bounding
boxes, which AngelCAD has.
Is there already something I'm missing that would do this? If not, is
there any chance of such features?
The OpenSCAD language is said to be a 'functional language', i.e. a
declarative style which by design does not allow retrieval of the kind
of information you are asking for. So I think there is a very low
probability that such features will appear in OpeSCAD.
There's nothing fundamentally non-declarative about adding structure and
extra information, it's common in pure functional languages.
Anyway, I'll take a look at AngelCAD, looks like it does some or all of what
I'm talking about.
Thanks,
F
cacb wrote
Carsten Anrholm
OpenSCAD mailing list
cacb wrote
> On 2020-06-20 11:50, Fergal Daly wrote:
>> One thing I find is that I want to export calculations or measurements
>> from inside a module to outside. E.g. the module builds a shape with a
>> certain height, that height was computed based on parameters to the
>> module. I'd like to be able to refer to that height outside, e.g. to
>> pass a parameter for another module. I don't see a way to do this at
>> the moment. It seems like it would also require being able to assign
>> instances of modules to variables.
>
> You cannot do that in OpenSCAD, the language does not offer/allow
> retrieval of parameters. The typical way to do it would be to let each
> cube, cylinder etc, be instances of classes with member functions to
> retrieve the construction parameters. AngelCAD does exactly that, but
> OpenSCAD does not.
>
>> E.g. I want to drill a cylindrical hole that is wide enough to fit a
>> countersunk bolt head and I'm using BOSL. So I use the exported
>> function from BOSL get_metric_socket_cap_diam() but the programmer in
>> me wants to encapsulate this in the bolt itself. E.g.
>
> You want the ability to create user defined classes in addition to
> built-in ones. You can do that in AngelCAD.
Well not exactly, since you can't query the built-in ones either because you
cannot refer to them. Missing piece #1 is the ability to refer to a
constructed object, not just immediately add it to the tree. Then ideally
you would be able to query any of it's input parameters any of the
calculated parameters it chooses to expose and some standard parameters like
origin and orientation.
cacb wrote
>> Also being able to access some positional information for an instance
>> of a module e.g. the module's "origin" and alignment-vector would be
>> really helpful for correctly positioning things relative to each
>> other.
>
> One (partial) solution to this is to offer computation of bounding
> boxes, which AngelCAD has.
>
>> Is there already something I'm missing that would do this? If not, is
>> there any chance of such features?
>
> The OpenSCAD language is said to be a 'functional language', i.e. a
> declarative style which by design does not allow retrieval of the kind
> of information you are asking for. So I think there is a very low
> probability that such features will appear in OpeSCAD.
There's nothing fundamentally non-declarative about adding structure and
extra information, it's common in pure functional languages.
Anyway, I'll take a look at AngelCAD, looks like it does some or all of what
I'm talking about.
Thanks,
F
cacb wrote
> Carsten Anrholm
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@.openscad
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
Sent from: http://forum.openscad.org/
NH
nop head
Sun, Jun 21, 2020 8:32 AM
My property lists describe objects, they have size information, but no
coordinates, so I can't apply transformations to them. To position
something I translate and rotate the module that draws it, possibly using
functions to get its size.
I have functions to get all the information from the list without
needing to know anything about its layout or contents. It is just a name I
pass to all the rated functions and modules. I can also put it in the
property lists of other objects. For example a fan has a screw property, a
screw has nut and washer properties.
If I have a new requirement for some information about an object I add a
function to calculate it, or expand the property list. It doesn't change
any client code because the property lists are all in the library and only
ever referenced by name in the client.
Since the list has all the information needed to draw the object, make
holes for it, etc, I always have all the information I need about an
object, without ever needing to ask OpenSCAD anything. I know the width and
height of a fan, what screws it takes, where the screw holes are, the shape
of the aperture needed in a panel and have modules to generate fan guards,
grills and gaskets.
It is just home rolled object orientation but it fits OpenSCAD because I
always specify geometry, I never need to ask questions about what gets
generated.
On Sun, 21 Jun 2020 at 07:25, fergald@gmail.com fergald@gmail.com wrote:
On 2020-06-20 11:50, Fergal Daly wrote:
One thing I find is that I want to export calculations or measurements
from inside a module to outside. E.g. the module builds a shape with a
certain height, that height was computed based on parameters to the
module. I'd like to be able to refer to that height outside, e.g. to
pass a parameter for another module. I don't see a way to do this at
the moment. It seems like it would also require being able to assign
instances of modules to variables.
You cannot do that in OpenSCAD, the language does not offer/allow
retrieval of parameters. The typical way to do it would be to let each
cube, cylinder etc, be instances of classes with member functions to
retrieve the construction parameters. AngelCAD does exactly that, but
OpenSCAD does not.
E.g. I want to drill a cylindrical hole that is wide enough to fit a
countersunk bolt head and I'm using BOSL. So I use the exported
function from BOSL get_metric_socket_cap_diam() but the programmer in
me wants to encapsulate this in the bolt itself. E.g.
You want the ability to create user defined classes in addition to
built-in ones. You can do that in AngelCAD.
Well not exactly, since you can't query the built-in ones either because
you
cannot refer to them. Missing piece #1 is the ability to refer to a
constructed object, not just immediately add it to the tree. Then ideally
you would be able to query any of it's input parameters any of the
calculated parameters it chooses to expose and some standard parameters
like
origin and orientation.
cacb wrote
Also being able to access some positional information for an instance
of a module e.g. the module's "origin" and alignment-vector would be
really helpful for correctly positioning things relative to each
other.
One (partial) solution to this is to offer computation of bounding
boxes, which AngelCAD has.
Is there already something I'm missing that would do this? If not, is
there any chance of such features?
The OpenSCAD language is said to be a 'functional language', i.e. a
declarative style which by design does not allow retrieval of the kind
of information you are asking for. So I think there is a very low
probability that such features will appear in OpeSCAD.
There's nothing fundamentally non-declarative about adding structure and
extra information, it's common in pure functional languages.
Anyway, I'll take a look at AngelCAD, looks like it does some or all of
what
I'm talking about.
Thanks,
F
cacb wrote
Carsten Anrholm
OpenSCAD mailing list
My property lists describe objects, they have size information, but no
coordinates, so I can't apply transformations to them. To position
something I translate and rotate the module that draws it, possibly using
functions to get its size.
I have functions to get all the information from the list without
needing to know anything about its layout or contents. It is just a name I
pass to all the rated functions and modules. I can also put it in the
property lists of other objects. For example a fan has a screw property, a
screw has nut and washer properties.
If I have a new requirement for some information about an object I add a
function to calculate it, or expand the property list. It doesn't change
any client code because the property lists are all in the library and only
ever referenced by name in the client.
Since the list has all the information needed to draw the object, make
holes for it, etc, I always have all the information I need about an
object, without ever needing to ask OpenSCAD anything. I know the width and
height of a fan, what screws it takes, where the screw holes are, the shape
of the aperture needed in a panel and have modules to generate fan guards,
grills and gaskets.
It is just home rolled object orientation but it fits OpenSCAD because I
always specify geometry, I never need to ask questions about what gets
generated.
On Sun, 21 Jun 2020 at 07:25, fergald@gmail.com <fergald@gmail.com> wrote:
> cacb wrote
> > On 2020-06-20 11:50, Fergal Daly wrote:
> >> One thing I find is that I want to export calculations or measurements
> >> from inside a module to outside. E.g. the module builds a shape with a
> >> certain height, that height was computed based on parameters to the
> >> module. I'd like to be able to refer to that height outside, e.g. to
> >> pass a parameter for another module. I don't see a way to do this at
> >> the moment. It seems like it would also require being able to assign
> >> instances of modules to variables.
> >
> > You cannot do that in OpenSCAD, the language does not offer/allow
> > retrieval of parameters. The typical way to do it would be to let each
> > cube, cylinder etc, be instances of classes with member functions to
> > retrieve the construction parameters. AngelCAD does exactly that, but
> > OpenSCAD does not.
> >
> >> E.g. I want to drill a cylindrical hole that is wide enough to fit a
> >> countersunk bolt head and I'm using BOSL. So I use the exported
> >> function from BOSL get_metric_socket_cap_diam() but the programmer in
> >> me wants to encapsulate this in the bolt itself. E.g.
> >
> > You want the ability to create user defined classes in addition to
> > built-in ones. You can do that in AngelCAD.
>
> Well not exactly, since you can't query the built-in ones either because
> you
> cannot refer to them. Missing piece #1 is the ability to refer to a
> constructed object, not just immediately add it to the tree. Then ideally
> you would be able to query any of it's input parameters any of the
> calculated parameters it chooses to expose and some standard parameters
> like
> origin and orientation.
>
>
> cacb wrote
> >> Also being able to access some positional information for an instance
> >> of a module e.g. the module's "origin" and alignment-vector would be
> >> really helpful for correctly positioning things relative to each
> >> other.
> >
> > One (partial) solution to this is to offer computation of bounding
> > boxes, which AngelCAD has.
> >
> >> Is there already something I'm missing that would do this? If not, is
> >> there any chance of such features?
> >
> > The OpenSCAD language is said to be a 'functional language', i.e. a
> > declarative style which by design does not allow retrieval of the kind
> > of information you are asking for. So I think there is a very low
> > probability that such features will appear in OpeSCAD.
>
> There's nothing fundamentally non-declarative about adding structure and
> extra information, it's common in pure functional languages.
>
> Anyway, I'll take a look at AngelCAD, looks like it does some or all of
> what
> I'm talking about.
>
> Thanks,
>
> F
>
>
> cacb wrote
> > Carsten Anrholm
> >
> > _______________________________________________
> > OpenSCAD mailing list
>
> > Discuss@.openscad
>
> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
P
pproj@posteo.de
Sun, Jun 21, 2020 4:25 PM
to me it looks pretty much like another use case for my "constructive"
library again. it will do that with nice concise syntax.all the
translate, rotate, cube,etc.. have been reimplemented for use of
vectors,more concise syntax and more features like alignment.. i am
using it for years now, almost never go back to plain vanilla openscad
syntax anymore.
i am still saving the effort of clening up and publishing, perhaps the
potential use of it to others will outweigh the price of effort to do
it. perhaps not.
it is just the question if anybody would actually be ready to learn and
get used to something something made by others, instead of comfortably
going his own ways and reimplementing parts he needs in every project.
that is the perpetual dilemma: what do you think folks?how are the chances?
for instance i personally never use MCAD, i do not know it well, so i
think i have reimplemented some parts of it in some projects for sure.
On 21.06.20 08:08, fergald@gmail.com wrote:
Thanks. Yeah, I was thinking about something like that. You could also have
your own translate and rotate that you can apply to these lists and manage
all of that but that's just all getting very clunky,
F
nophead wrote
There isn't a way to do that currently but I use a different way to
represent objects in my library. I describe everything with a list and
pass
that as the first parameter to all functions and modules that operate on
it.
Your example then becomes
include <NopSCADlib/screws.scad>
my_bolt = M5_cs_cap_screw; // assigns object description list to my_bolt
cylinder(r = screw_head_radius(my_bolt), h = screw_head_height(my_bolt));
// Draws a compatible cylinder
screw(my_bolt, 30); // Draw a 30mm screw
My screws always have their origin at the part of the head that mates with
the surface and they always point down. So for a countersunk screw it
would
be the top of the head, for a cap head screw it would be the top of the
stem. So they are always translated and rotated to the top of the screw
hole. No need for origin information or alignment vectors as all objects
have the most convenient origin by convention.
On Sat, 20 Jun 2020 at 10:51, Fergal Daly <
fergald@
> wrote:
I've recently started using OpenSCAD, I'm very impressed, thanks to all
the people who made it real.
I think this is a feature request but I'm curious if there's something
like it that I am missing or if this is a possibility in the future.
One thing I find is that I want to export calculations or measurements
from inside a module to outside. E.g. the module builds a shape with a
certain height, that height was computed based on parameters to the
module.
I'd like to be able to refer to that height outside, e.g. to pass a
parameter for another module. I don't see a way to do this at the moment.
It seems like it would also require being able to assign instances of
modules to variables.
E.g. I want to drill a cylindrical hole that is wide enough to fit a
countersunk bolt head and I'm using BOSL. So I use the exported function
from BOSL get_metric_socket_cap_diam() but the programmer in me wants to
encapsulate this in the bolt itself. E.g.
use <lib/BOSL/metric_screws.scad>
my_bolt = metric_bolt(size=5, l=30, headtype="countersunk"); // renders
nothing
cylinder(r=bolt.head_diam); // renders a compatible cylinder
Also being able to access some positional information for an instance of
a
module e.g. the module's "origin" and alignment-vector would be really
helpful for correctly positioning things relative to each other.
Is there already something I'm missing that would do this? If not, is
there any chance of such features?
F
OpenSCAD mailing list
to me it looks pretty much like another use case for my "constructive"
library again. it will do that with nice concise syntax.all the
translate, rotate, cube,etc.. have been reimplemented for use of
vectors,more concise syntax and more features like alignment.. i am
using it for years now, almost never go back to plain vanilla openscad
syntax anymore.
i am still saving the effort of clening up and publishing, perhaps the
potential use of it to others will outweigh the price of effort to do
it. perhaps not.
it is just the question if anybody would actually be ready to learn and
get used to something something made by others, instead of comfortably
going his own ways and reimplementing parts he needs in every project.
that is the perpetual dilemma: what do you think folks?how are the chances?
for instance i personally never use MCAD, i do not know it well, so i
think i have reimplemented some parts of it in some projects for sure.
On 21.06.20 08:08, fergald@gmail.com wrote:
> Thanks. Yeah, I was thinking about something like that. You could also have
> your own translate and rotate that you can apply to these lists and manage
> all of that but that's just all getting very clunky,
>
> F
>
>
> nophead wrote
>> There isn't a way to do that currently but I use a different way to
>> represent objects in my library. I describe everything with a list and
>> pass
>> that as the first parameter to all functions and modules that operate on
>> it.
>>
>> Your example then becomes
>>
>> include <NopSCADlib/screws.scad>
>> my_bolt = M5_cs_cap_screw; // assigns object description list to my_bolt
>>
>> cylinder(r = screw_head_radius(my_bolt), h = screw_head_height(my_bolt));
>> // Draws a compatible cylinder
>>
>> screw(my_bolt, 30); // Draw a 30mm screw
>>
>> My screws always have their origin at the part of the head that mates with
>> the surface and they always point down. So for a countersunk screw it
>> would
>> be the top of the head, for a cap head screw it would be the top of the
>> stem. So they are always translated and rotated to the top of the screw
>> hole. No need for origin information or alignment vectors as all objects
>> have the most convenient origin by convention.
>>
>> On Sat, 20 Jun 2020 at 10:51, Fergal Daly <
>> fergald@
>> > wrote:
>>
>>> I've recently started using OpenSCAD, I'm very impressed, thanks to all
>>> the people who made it real.
>>>
>>> I think this is a feature request but I'm curious if there's something
>>> like it that I am missing or if this is a possibility in the future.
>>>
>>> One thing I find is that I want to export calculations or measurements
>>> from inside a module to outside. E.g. the module builds a shape with a
>>> certain height, that height was computed based on parameters to the
>>> module.
>>> I'd like to be able to refer to that height outside, e.g. to pass a
>>> parameter for another module. I don't see a way to do this at the moment.
>>> It seems like it would also require being able to assign instances of
>>> modules to variables.
>>>
>>> E.g. I want to drill a cylindrical hole that is wide enough to fit a
>>> countersunk bolt head and I'm using BOSL. So I use the exported function
>>> from BOSL get_metric_socket_cap_diam() but the programmer in me wants to
>>> encapsulate this in the bolt itself. E.g.
>>>
>>> use <lib/BOSL/metric_screws.scad>
>>> my_bolt = metric_bolt(size=5, l=30, headtype="countersunk"); // renders
>>> nothing
>>> cylinder(r=bolt.head_diam); // renders a compatible cylinder
>>>
>>> Also being able to access some positional information for an instance of
>>> a
>>> module e.g. the module's "origin" and alignment-vector would be really
>>> helpful for correctly positioning things relative to each other.
>>>
>>> Is there already something I'm missing that would do this? If not, is
>>> there any chance of such features?
>>>
>>> F
>>> _______________________________________________
>>> OpenSCAD mailing list
>>>
>> Discuss@.openscad
>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>>
>> _______________________________________________
>> OpenSCAD mailing list
>> Discuss@.openscad
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
JB
Jordan Brown
Sun, Jun 21, 2020 4:28 PM
Well not exactly, since you can't query the built-in ones either
because you cannot refer to them. Missing piece #1 is the ability to
refer to a constructed object, not just immediately add it to the
tree. Then ideally you would be able to query any of it's input
parameters any of the calculated parameters it chooses to expose and
some standard parameters like origin and orientation.
Could you give an example of how it would be useful to query the origin
or orientation of an object?
I'm not even understanding what it would mean.
On 6/20/2020 11:25 PM, fergald@gmail.com wrote:
> Well not exactly, since you can't query the built-in ones either
> because you cannot refer to them. Missing piece #1 is the ability to
> refer to a constructed object, not just immediately add it to the
> tree. Then ideally you would be able to query any of it's input
> parameters any of the calculated parameters it chooses to expose and
> some standard parameters like origin and orientation.
Could you give an example of how it would be useful to query the origin
or orientation of an object?
I'm not even understanding what it would mean.
P
pproj@posteo.de
Sun, Jun 21, 2020 4:29 PM
On 2020-06-20 11:50, Fergal Daly wrote:
One thing I find is that I want to export calculations or measurements
from inside a module to outside. E.g. the module builds a shape with a
certain height, that height was computed based on parameters to the
module. I'd like to be able to refer to that height outside, e.g. to
pass a parameter for another module. I don't see a way to do this at
the moment. It seems like it would also require being able to assign
instances of modules to variables.
You cannot do that in OpenSCAD, the language does not offer/allow
retrieval of parameters. The typical way to do it would be to let each
cube, cylinder etc, be instances of classes with member functions to
retrieve the construction parameters. AngelCAD does exactly that, but
OpenSCAD does not.
E.g. I want to drill a cylindrical hole that is wide enough to fit a
countersunk bolt head and I'm using BOSL. So I use the exported
function from BOSL get_metric_socket_cap_diam() but the programmer in
me wants to encapsulate this in the bolt itself. E.g.
You want the ability to create user defined classes in addition to
built-in ones. You can do that in AngelCAD.
Also being able to access some positional information for an instance
of a module e.g. the module's "origin" and alignment-vector would be
really helpful for correctly positioning things relative to each
other.
One (partial) solution to this is to offer computation of bounding
boxes, which AngelCAD has.
Is there already something I'm missing that would do this? If not, is
there any chance of such features?
the angelcad thing looks very promising to me, thanks forit and
thedemvideo Arnholm!
https://www.youtube.com/watch?v=4JJDHR0ATBs
On 20.06.20 13:53, arnholm@arnholm.org wrote:
> On 2020-06-20 11:50, Fergal Daly wrote:
>> One thing I find is that I want to export calculations or measurements
>> from inside a module to outside. E.g. the module builds a shape with a
>> certain height, that height was computed based on parameters to the
>> module. I'd like to be able to refer to that height outside, e.g. to
>> pass a parameter for another module. I don't see a way to do this at
>> the moment. It seems like it would also require being able to assign
>> instances of modules to variables.
>
> You cannot do that in OpenSCAD, the language does not offer/allow
> retrieval of parameters. The typical way to do it would be to let each
> cube, cylinder etc, be instances of classes with member functions to
> retrieve the construction parameters. AngelCAD does exactly that, but
> OpenSCAD does not.
>
>> E.g. I want to drill a cylindrical hole that is wide enough to fit a
>> countersunk bolt head and I'm using BOSL. So I use the exported
>> function from BOSL get_metric_socket_cap_diam() but the programmer in
>> me wants to encapsulate this in the bolt itself. E.g.
>
> You want the ability to create user defined classes in addition to
> built-in ones. You can do that in AngelCAD.
>
>> Also being able to access some positional information for an instance
>> of a module e.g. the module's "origin" and alignment-vector would be
>> really helpful for correctly positioning things relative to each
>> other.
>
> One (partial) solution to this is to offer computation of bounding
> boxes, which AngelCAD has.
>
>> Is there already something I'm missing that would do this? If not, is
>> there any chance of such features?
>
> The OpenSCAD language is said to be a 'functional language', i.e. a
> declarative style which by design does not allow retrieval of the kind
> of information you are asking for. So I think there is a very low
> probability that such features will appear in OpeSCAD.
>
> Carsten Anrholm
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org