discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Fwd: Re: start a module from a variabel

RW
Ray West
Mon, Oct 11, 2021 7:06 PM

If it is for my own use and i can't bother with typing a list of if's, I
just rem out what's not needed - e.g. like

 // body();
 // translate([0,0,-2.5])flor();
   translate([0,-0.5,-12-thickness]) underframe();

On 11/10/2021 18:44, Matthieu Hendriks wrote:

Yes I do the same, it's still a workaround for the extra coding effort :)

Groet Matthieu

Jan Wieck schreef op 2021-10-11 19:34:

On 10/11/21 11:59 AM, Matthieu Hendriks wrote:

Is it possible to execute a module depending on a variable name. Example:

When I have "assemblies" I usually create a drop-down list and then
create modules depending on the value. Like:

part = "body"; // [body, arm, leg, head, all]

if (part == "body") { body(); }
if (part == "arm") { arm(); }
...
if (part == "all") {
    body();
    arm();
    leg();
    head();
}

That way I can select individual parts to work on, render and export
for printing, but I can also see the entire assembly together. The
"all" selection often has some rotate() and translate() for the
actual parts to put them at the right position within the assembly.

Regards, Jan

module_to_start = "create_plate"

sys(module_to_start) or &module_to_start

module create_plate () { ...}

module create_head () { ...}

Groet Matthieu



OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
mailto:discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org

If it is for my own use and i can't bother with typing a list of if's, I just rem out what's not needed - e.g. like  // body();  // translate([0,0,-2.5])flor();    translate([0,-0.5,-12-thickness]) underframe(); On 11/10/2021 18:44, Matthieu Hendriks wrote: > > Yes I do the same, it's still a workaround for the extra coding effort :) > > Groet Matthieu > > > Jan Wieck schreef op 2021-10-11 19:34: > >> On 10/11/21 11:59 AM, Matthieu Hendriks wrote: >>> Is it possible to execute a module depending on a variable name. Example: >> >> When I have "assemblies" I usually create a drop-down list and then >> create modules depending on the value. Like: >> >> part = "body"; // [body, arm, leg, head, all] >> >> if (part == "body") { body(); } >> if (part == "arm") { arm(); } >> ... >> if (part == "all") { >>     body(); >>     arm(); >>     leg(); >>     head(); >> } >> >> That way I can select individual parts to work on, render and export >> for printing, but I can also see the entire assembly together. The >> "all" selection often has some rotate() and translate() for the >> actual parts to put them at the right position within the assembly. >> >> >> Regards, Jan >> >> >>> >>> module_to_start = "create_plate" >>> >>> sys(module_to_start) or &module_to_start >>> >>> module create_plate () { ...} >>> >>> module create_head () { ...} >>> >>> >>> >>> Groet Matthieu >>> ------------------------------------------------------------------------ >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> <mailto:discuss-leave@lists.openscad.org> >>> > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
PC
Patrick Callahan
Thu, Oct 21, 2021 3:55 PM

I'll want to arrange the data for parts and assemblies in an organized way.

Today, my measurements for a project are in a single .scad file. I import
this file in each part file. But it's becoming unwieldy.
So, I'm looking for advice and examples of ways folks have dealt with the
structure of data in OpenScad projects.'

-Pat

As for scripting, language does not matter to me.
Ideally, I'd like to see the features addressed by scripting handled by
extending the OpenSCAD language, but that's a bit beyond my skills for now.

Data Usage

  • absolute measurements for single or multiple sizes
  • relative measurements between parts
  • clearances
  • calculated measures
  • re-use of a measurement in multiple parts
  • location and orientation data
  • movement
  • part selection

Goals:

  • exploded views
  • animated movement showing the assembly process and movement within the
    final assembly
  • 2d Drawings with labels and measures
  • 3d print compatible files with one or more parts
  • parts lists (with pictures)
  • assembly instructions (with pictures)

On Mon, Oct 11, 2021 at 3:07 PM Ray West raywest@raywest.com wrote:

If it is for my own use and i can't bother with typing a list of if's, I
just rem out what's not needed - e.g. like

// body();
// translate([0,0,-2.5])flor();
translate([0,-0.5,-12-thickness]) underframe();

On 11/10/2021 18:44, Matthieu Hendriks wrote:

Yes I do the same, it's still a workaround for the extra coding effort :)
Groet Matthieu

Jan Wieck schreef op 2021-10-11 19:34:

On 10/11/21 11:59 AM, Matthieu Hendriks wrote:

Is it possible to execute a module depending on a variable name. Example:

When I have "assemblies" I usually create a drop-down list and then create
modules depending on the value. Like:

part = "body"; // [body, arm, leg, head, all]

if (part == "body") { body(); }
if (part == "arm") { arm(); }
...
if (part == "all") {
body();
arm();
leg();
head();
}

That way I can select individual parts to work on, render and export for
printing, but I can also see the entire assembly together. The "all"
selection often has some rotate() and translate() for the actual parts to
put them at the right position within the assembly.

Regards, Jan

module_to_start = "create_plate"

sys(module_to_start) or &module_to_start

module create_plate () { ...}

module create_head () { ...}

Groet Matthieu



OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I'll want to arrange the data for parts and assemblies in an organized way. Today, my measurements for a project are in a single .scad file. I import this file in each part file. But it's becoming unwieldy. So, I'm looking for advice and examples of ways folks have dealt with the structure of data in OpenScad projects.' -Pat As for scripting, language does not matter to me. Ideally, I'd like to see the features addressed by scripting handled by extending the OpenSCAD language, but that's a bit beyond my skills for now. Data Usage - absolute measurements for single or multiple sizes - relative measurements between parts - clearances - calculated measures - re-use of a measurement in multiple parts - location and orientation data - movement - part selection Goals: - exploded views - animated movement showing the assembly process and movement within the final assembly - 2d Drawings with labels and measures - 3d print compatible files with one or more parts - parts lists (with pictures) - assembly instructions (with pictures) On Mon, Oct 11, 2021 at 3:07 PM Ray West <raywest@raywest.com> wrote: > If it is for my own use and i can't bother with typing a list of if's, I > just rem out what's not needed - e.g. like > > // body(); > // translate([0,0,-2.5])flor(); > translate([0,-0.5,-12-thickness]) underframe(); > > > On 11/10/2021 18:44, Matthieu Hendriks wrote: > > Yes I do the same, it's still a workaround for the extra coding effort :) > Groet Matthieu > > > Jan Wieck schreef op 2021-10-11 19:34: > > On 10/11/21 11:59 AM, Matthieu Hendriks wrote: > > Is it possible to execute a module depending on a variable name. Example: > > > When I have "assemblies" I usually create a drop-down list and then create > modules depending on the value. Like: > > part = "body"; // [body, arm, leg, head, all] > > if (part == "body") { body(); } > if (part == "arm") { arm(); } > ... > if (part == "all") { > body(); > arm(); > leg(); > head(); > } > > That way I can select individual parts to work on, render and export for > printing, but I can also see the entire assembly together. The "all" > selection often has some rotate() and translate() for the actual parts to > put them at the right position within the assembly. > > > Regards, Jan > > > > module_to_start = "create_plate" > > sys(module_to_start) or &module_to_start > > module create_plate () { ...} > > module create_head () { ...} > > > > Groet Matthieu > ------------------------------------------------------------------------ > ------------------------------------------------------------------------ > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
NH
nop head
Thu, Oct 21, 2021 4:31 PM

My library does pretty much all of those goals apart from

  • 2d Drawings with labels and measures

I make my 2D parts with a CNC mill, so I don't need dimensioned drawings.
Just DXF files.

  • animated movement showing the assembly process and movement within the
    final assembly

I have exploded views defined by a variable that can be between 0 and 1, so
setting it to 1 - $t would show parts coming together although I haven't
done that. I have lines between the exploded position and the final
position as in a conventional exploded view.

[image: dock_assembly.png]

I have also made animations of parts of a machine moving by making the axis
position a function of $t.

https://www.youtube.com/watch?v=aO12JR44Ets&t=8s

On Thu, 21 Oct 2021 at 16:55, Patrick Callahan pat.callahan1@gmail.com
wrote:

I'll want to arrange the data for parts and assemblies in an organized way.

Today, my measurements for a project are in a single .scad file. I import
this file in each part file. But it's becoming unwieldy.
So, I'm looking for advice and examples of ways folks have dealt with the
structure of data in OpenScad projects.'

-Pat

As for scripting, language does not matter to me.
Ideally, I'd like to see the features addressed by scripting handled by
extending the OpenSCAD language, but that's a bit beyond my skills for now.

Data Usage

- absolute measurements for single or multiple sizes
- relative measurements between parts
- clearances
- calculated measures
- re-use of a measurement in multiple parts
- location and orientation data
- movement
- part selection

Goals:

- exploded views
- animated movement showing the assembly process and movement within
the final assembly
- 2d Drawings with labels and measures
- 3d print compatible files with one or more parts
- parts lists (with pictures)
- assembly instructions (with pictures)

On Mon, Oct 11, 2021 at 3:07 PM Ray West raywest@raywest.com wrote:

If it is for my own use and i can't bother with typing a list of if's, I
just rem out what's not needed - e.g. like

// body();
// translate([0,0,-2.5])flor();
translate([0,-0.5,-12-thickness]) underframe();

On 11/10/2021 18:44, Matthieu Hendriks wrote:

Yes I do the same, it's still a workaround for the extra coding effort :)
Groet Matthieu

Jan Wieck schreef op 2021-10-11 19:34:

On 10/11/21 11:59 AM, Matthieu Hendriks wrote:

Is it possible to execute a module depending on a variable name. Example:

When I have "assemblies" I usually create a drop-down list and then
create modules depending on the value. Like:

part = "body"; // [body, arm, leg, head, all]

if (part == "body") { body(); }
if (part == "arm") { arm(); }
...
if (part == "all") {
body();
arm();
leg();
head();
}

That way I can select individual parts to work on, render and export for
printing, but I can also see the entire assembly together. The "all"
selection often has some rotate() and translate() for the actual parts to
put them at the right position within the assembly.

Regards, Jan

module_to_start = "create_plate"

sys(module_to_start) or &module_to_start

module create_plate () { ...}

module create_head () { ...}

Groet Matthieu



OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

My library does pretty much all of those goals apart from - 2d Drawings with labels and measures I make my 2D parts with a CNC mill, so I don't need dimensioned drawings. Just DXF files. - animated movement showing the assembly process and movement within the final assembly I have exploded views defined by a variable that can be between 0 and 1, so setting it to 1 - $t would show parts coming together although I haven't done that. I have lines between the exploded position and the final position as in a conventional exploded view. [image: dock_assembly.png] I have also made animations of parts of a machine moving by making the axis position a function of $t. https://www.youtube.com/watch?v=aO12JR44Ets&t=8s On Thu, 21 Oct 2021 at 16:55, Patrick Callahan <pat.callahan1@gmail.com> wrote: > I'll want to arrange the data for parts and assemblies in an organized way. > > Today, my measurements for a project are in a single .scad file. I import > this file in each part file. But it's becoming unwieldy. > So, I'm looking for advice and examples of ways folks have dealt with the > structure of data in OpenScad projects.' > > -Pat > > > As for scripting, language does not matter to me. > Ideally, I'd like to see the features addressed by scripting handled by > extending the OpenSCAD language, but that's a bit beyond my skills for now. > > Data Usage > > - absolute measurements for single or multiple sizes > - relative measurements between parts > - clearances > - calculated measures > - re-use of a measurement in multiple parts > - location and orientation data > - movement > - part selection > > Goals: > > - exploded views > - animated movement showing the assembly process and movement within > the final assembly > - 2d Drawings with labels and measures > - 3d print compatible files with one or more parts > - parts lists (with pictures) > - assembly instructions (with pictures) > > > On Mon, Oct 11, 2021 at 3:07 PM Ray West <raywest@raywest.com> wrote: > >> If it is for my own use and i can't bother with typing a list of if's, I >> just rem out what's not needed - e.g. like >> >> // body(); >> // translate([0,0,-2.5])flor(); >> translate([0,-0.5,-12-thickness]) underframe(); >> >> >> On 11/10/2021 18:44, Matthieu Hendriks wrote: >> >> Yes I do the same, it's still a workaround for the extra coding effort :) >> Groet Matthieu >> >> >> Jan Wieck schreef op 2021-10-11 19:34: >> >> On 10/11/21 11:59 AM, Matthieu Hendriks wrote: >> >> Is it possible to execute a module depending on a variable name. Example: >> >> >> When I have "assemblies" I usually create a drop-down list and then >> create modules depending on the value. Like: >> >> part = "body"; // [body, arm, leg, head, all] >> >> if (part == "body") { body(); } >> if (part == "arm") { arm(); } >> ... >> if (part == "all") { >> body(); >> arm(); >> leg(); >> head(); >> } >> >> That way I can select individual parts to work on, render and export for >> printing, but I can also see the entire assembly together. The "all" >> selection often has some rotate() and translate() for the actual parts to >> put them at the right position within the assembly. >> >> >> Regards, Jan >> >> >> >> module_to_start = "create_plate" >> >> sys(module_to_start) or &module_to_start >> >> module create_plate () { ...} >> >> module create_head () { ...} >> >> >> >> Groet Matthieu >> ------------------------------------------------------------------------ >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
RW
Ray West
Thu, Oct 21, 2021 6:08 PM

Speaking generally, in an example where you have a number of component
items, and a layout/collection file.

if you write each component/part/group of parts as separate modules, and
if you extract all the values that you want to change as variables, you
can test each part individually. then you can comment out the variables
that you want to change in the 'layout file' and save it as a component
file. Then in the layout file, you can include each component file
inside a module, and set the variables inside the module, or outside, if
you want. That allows you to use simple variable names  like length,
width, whatever for each component, and to have the values individually
adjustable in the layout file, without having to alter values in the
component files.

On 21/10/2021 16:55, Patrick Callahan wrote:

I'll want to arrange the data for parts and assemblies in an organized
way.

Today, my measurements for a project are in a single .scad file. I
import this file in each part file. But it's becoming unwieldy.
So, I'm looking for advice and examples of ways folks have dealt with
the structure of data in OpenScad projects.'

-Pat

As for scripting, language does not matter to me.
Ideally, I'd like to see the features addressed by scripting handled
by extending the OpenSCAD language, but that's a bit beyond my skills
for now.
Data Usage

  • absolute measurements for single or multiple sizes
  • relative measurements between parts
  • clearances
  • calculated measures
  • re-use of a measurement in multiple parts
  • location and orientation data
  • movement
  • part selection

Goals:

  • exploded views
  • animated movement showing the assembly process and movement within
    the final assembly
  • 2d Drawings with labels and measures
  • 3d print compatible files with one or more parts
  • parts lists (with pictures)
  • assembly instructions (with pictures)

On Mon, Oct 11, 2021 at 3:07 PM Ray West <raywest@raywest.com
mailto:raywest@raywest.com> wrote:

 If it is for my own use and i can't bother with typing a list of
 if's, I just rem out what's not needed - e.g. like

  // body();
  // translate([0,0,-2.5])flor();
    translate([0,-0.5,-12-thickness]) underframe();


 On 11/10/2021 18:44, Matthieu Hendriks wrote:
 Yes I do the same, it's still a workaround for the extra coding
 effort :)

 Groet Matthieu


 Jan Wieck schreef op 2021-10-11 19:34:
 On 10/11/21 11:59 AM, Matthieu Hendriks wrote:
 Is it possible to execute a module depending on a variable name. Example:
 When I have "assemblies" I usually create a drop-down list and
 then create modules depending on the value. Like:

 part = "body"; // [body, arm, leg, head, all]

 if (part == "body") { body(); }
 if (part == "arm") { arm(); }
 ...
 if (part == "all") {
     body();
     arm();
     leg();
     head();
 }

 That way I can select individual parts to work on, render and
 export for printing, but I can also see the entire assembly
 together. The "all" selection often has some rotate() and
 translate() for the actual parts to put them at the right
 position within the assembly.


 Regards, Jan
 module_to_start = "create_plate"

 sys(module_to_start) or &module_to_start

 module create_plate () { ...}

 module create_head () { ...}



 Groet Matthieu
 ------------------------------------------------------------------------
 ------------------------------------------------------------------------

 _______________________________________________
 OpenSCAD mailing list
 To unsubscribe send an email to
 discuss-leave@lists.openscad.org
 <mailto:discuss-leave@lists.openscad.org>
 _______________________________________________
 OpenSCAD mailing list
 To unsubscribe send an email todiscuss-leave@lists.openscad.org  <mailto:discuss-leave@lists.openscad.org>
 _______________________________________________
 OpenSCAD mailing list
 To unsubscribe send an email to discuss-leave@lists.openscad.org
 <mailto:discuss-leave@lists.openscad.org>

OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Speaking generally, in an example where you have a number of component items, and a layout/collection file. if you write each component/part/group of parts as separate modules, and if you extract all the values that you want to change as variables, you can test each part individually. then you can comment out the variables that you want to change in the 'layout file' and save it as a component file. Then in the layout file, you can include each component file inside a module, and set the variables inside the module, or outside, if you want. That allows you to use simple variable names  like length, width, whatever for each component, and to have the values individually adjustable in the layout file, without having to alter values in the component files. On 21/10/2021 16:55, Patrick Callahan wrote: > I'll want to arrange the data for parts and assemblies in an organized > way. > > Today, my measurements for a project are in a single .scad file. I > import this file in each part file. But it's becoming unwieldy. > So, I'm looking for advice and examples of ways folks have dealt with > the structure of data in OpenScad projects.' > > -Pat > > > As for scripting, language does not matter to me. > Ideally, I'd like to see the features addressed by scripting handled > by extending the OpenSCAD language, but that's a bit beyond my skills > for now. > Data Usage > > * absolute measurements for single or multiple sizes > * relative measurements between parts > * clearances > * calculated measures > * re-use of a measurement in multiple parts > * location and orientation data > * movement > * part selection > > Goals: > > * exploded views > * animated movement showing the assembly process and movement within > the final assembly > * 2d Drawings with labels and measures > * 3d print compatible files with one or more parts > * parts lists (with pictures) > * assembly instructions (with pictures) > > > On Mon, Oct 11, 2021 at 3:07 PM Ray West <raywest@raywest.com > <mailto:raywest@raywest.com>> wrote: > > If it is for my own use and i can't bother with typing a list of > if's, I just rem out what's not needed - e.g. like > >  // body(); >  // translate([0,0,-2.5])flor(); >    translate([0,-0.5,-12-thickness]) underframe(); > > > On 11/10/2021 18:44, Matthieu Hendriks wrote: >> >> Yes I do the same, it's still a workaround for the extra coding >> effort :) >> >> Groet Matthieu >> >> >> Jan Wieck schreef op 2021-10-11 19:34: >> >>> On 10/11/21 11:59 AM, Matthieu Hendriks wrote: >>>> Is it possible to execute a module depending on a variable name. Example: >>> >>> When I have "assemblies" I usually create a drop-down list and >>> then create modules depending on the value. Like: >>> >>> part = "body"; // [body, arm, leg, head, all] >>> >>> if (part == "body") { body(); } >>> if (part == "arm") { arm(); } >>> ... >>> if (part == "all") { >>>     body(); >>>     arm(); >>>     leg(); >>>     head(); >>> } >>> >>> That way I can select individual parts to work on, render and >>> export for printing, but I can also see the entire assembly >>> together. The "all" selection often has some rotate() and >>> translate() for the actual parts to put them at the right >>> position within the assembly. >>> >>> >>> Regards, Jan >>> >>> >>>> >>>> module_to_start = "create_plate" >>>> >>>> sys(module_to_start) or &module_to_start >>>> >>>> module create_plate () { ...} >>>> >>>> module create_head () { ...} >>>> >>>> >>>> >>>> Groet Matthieu >>>> ------------------------------------------------------------------------ >>>> ------------------------------------------------------------------------ >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to >>>> discuss-leave@lists.openscad.org >>>> <mailto:discuss-leave@lists.openscad.org> >>>> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email todiscuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > <mailto:discuss-leave@lists.openscad.org> > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
PC
Patrick Callahan
Fri, Oct 22, 2021 2:18 AM

Some very good ideas in your work.  I'll take a close look at your library
as something to base my designs in.

On Thu, Oct 21, 2021 at 12:32 PM nop head nop.head@gmail.com wrote:

My library does pretty much all of those goals apart from

- 2d Drawings with labels and measures

I make my 2D parts with a CNC mill, so I don't need dimensioned drawings.
Just DXF files.

- animated movement showing the assembly process and movement within
the final assembly

I have exploded views defined by a variable that can be between 0 and 1,
so setting it to 1 - $t would show parts coming together although I haven't
done that. I have lines between the exploded position and the final
position as in a conventional exploded view.

[image: dock_assembly.png]

I have also made animations of parts of a machine moving by making
the axis position a function of $t.

https://www.youtube.com/watch?v=aO12JR44Ets&t=8s

On Thu, 21 Oct 2021 at 16:55, Patrick Callahan pat.callahan1@gmail.com
wrote:

I'll want to arrange the data for parts and assemblies in an organized
way.

Today, my measurements for a project are in a single .scad file. I import
this file in each part file. But it's becoming unwieldy.
So, I'm looking for advice and examples of ways folks have dealt with the
structure of data in OpenScad projects.'

-Pat

As for scripting, language does not matter to me.
Ideally, I'd like to see the features addressed by scripting handled by
extending the OpenSCAD language, but that's a bit beyond my skills for now.

Data Usage

- absolute measurements for single or multiple sizes
- relative measurements between parts
- clearances
- calculated measures
- re-use of a measurement in multiple parts
- location and orientation data
- movement
- part selection

Goals:

- exploded views
- animated movement showing the assembly process and movement within
the final assembly
- 2d Drawings with labels and measures
- 3d print compatible files with one or more parts
- parts lists (with pictures)
- assembly instructions (with pictures)

On Mon, Oct 11, 2021 at 3:07 PM Ray West raywest@raywest.com wrote:

If it is for my own use and i can't bother with typing a list of if's, I
just rem out what's not needed - e.g. like

// body();
// translate([0,0,-2.5])flor();
translate([0,-0.5,-12-thickness]) underframe();

On 11/10/2021 18:44, Matthieu Hendriks wrote:

Yes I do the same, it's still a workaround for the extra coding effort
:)
Groet Matthieu

Jan Wieck schreef op 2021-10-11 19:34:

On 10/11/21 11:59 AM, Matthieu Hendriks wrote:

Is it possible to execute a module depending on a variable name. Example:

When I have "assemblies" I usually create a drop-down list and then
create modules depending on the value. Like:

part = "body"; // [body, arm, leg, head, all]

if (part == "body") { body(); }
if (part == "arm") { arm(); }
...
if (part == "all") {
body();
arm();
leg();
head();
}

That way I can select individual parts to work on, render and export for
printing, but I can also see the entire assembly together. The "all"
selection often has some rotate() and translate() for the actual parts to
put them at the right position within the assembly.

Regards, Jan

module_to_start = "create_plate"

sys(module_to_start) or &module_to_start

module create_plate () { ...}

module create_head () { ...}

Groet Matthieu



OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Some very good ideas in your work. I'll take a close look at your library as something to base my designs in. On Thu, Oct 21, 2021 at 12:32 PM nop head <nop.head@gmail.com> wrote: > My library does pretty much all of those goals apart from > > - 2d Drawings with labels and measures > > I make my 2D parts with a CNC mill, so I don't need dimensioned drawings. > Just DXF files. > > - animated movement showing the assembly process and movement within > the final assembly > > I have exploded views defined by a variable that can be between 0 and 1, > so setting it to 1 - $t would show parts coming together although I haven't > done that. I have lines between the exploded position and the final > position as in a conventional exploded view. > > [image: dock_assembly.png] > > I have also made animations of parts of a machine moving by making > the axis position a function of $t. > > https://www.youtube.com/watch?v=aO12JR44Ets&t=8s > > > On Thu, 21 Oct 2021 at 16:55, Patrick Callahan <pat.callahan1@gmail.com> > wrote: > >> I'll want to arrange the data for parts and assemblies in an organized >> way. >> >> Today, my measurements for a project are in a single .scad file. I import >> this file in each part file. But it's becoming unwieldy. >> So, I'm looking for advice and examples of ways folks have dealt with the >> structure of data in OpenScad projects.' >> >> -Pat >> >> >> As for scripting, language does not matter to me. >> Ideally, I'd like to see the features addressed by scripting handled by >> extending the OpenSCAD language, but that's a bit beyond my skills for now. >> >> Data Usage >> >> - absolute measurements for single or multiple sizes >> - relative measurements between parts >> - clearances >> - calculated measures >> - re-use of a measurement in multiple parts >> - location and orientation data >> - movement >> - part selection >> >> Goals: >> >> - exploded views >> - animated movement showing the assembly process and movement within >> the final assembly >> - 2d Drawings with labels and measures >> - 3d print compatible files with one or more parts >> - parts lists (with pictures) >> - assembly instructions (with pictures) >> >> >> On Mon, Oct 11, 2021 at 3:07 PM Ray West <raywest@raywest.com> wrote: >> >>> If it is for my own use and i can't bother with typing a list of if's, I >>> just rem out what's not needed - e.g. like >>> >>> // body(); >>> // translate([0,0,-2.5])flor(); >>> translate([0,-0.5,-12-thickness]) underframe(); >>> >>> >>> On 11/10/2021 18:44, Matthieu Hendriks wrote: >>> >>> Yes I do the same, it's still a workaround for the extra coding effort >>> :) >>> Groet Matthieu >>> >>> >>> Jan Wieck schreef op 2021-10-11 19:34: >>> >>> On 10/11/21 11:59 AM, Matthieu Hendriks wrote: >>> >>> Is it possible to execute a module depending on a variable name. Example: >>> >>> >>> When I have "assemblies" I usually create a drop-down list and then >>> create modules depending on the value. Like: >>> >>> part = "body"; // [body, arm, leg, head, all] >>> >>> if (part == "body") { body(); } >>> if (part == "arm") { arm(); } >>> ... >>> if (part == "all") { >>> body(); >>> arm(); >>> leg(); >>> head(); >>> } >>> >>> That way I can select individual parts to work on, render and export for >>> printing, but I can also see the entire assembly together. The "all" >>> selection often has some rotate() and translate() for the actual parts to >>> put them at the right position within the assembly. >>> >>> >>> Regards, Jan >>> >>> >>> >>> module_to_start = "create_plate" >>> >>> sys(module_to_start) or &module_to_start >>> >>> module create_plate () { ...} >>> >>> module create_head () { ...} >>> >>> >>> >>> Groet Matthieu >>> ------------------------------------------------------------------------ >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
PC
Patrick Callahan
Fri, Oct 22, 2021 12:13 PM

Ray,

I think I'm trying to get to some rules for code and interface organization
specific to OpenSCAD.

Your comments on the separation of components as modules and the treatment
of variables exemplify the kind of structural thinking I want to clarify.

I think everyone who uses openSCAD will eventually find that they are
solving this kind of problem whether they think about it directly or not.
I'm hoping to avoid duplicating work others have already done as I organize
my work.

Certain "kinds" of OpenSCAD code would be in each of those "types" of
files.  The question is, what specific kind of code

I've got my first project written as individual modules, one module per
part usually and sometimes one per feature. But some interfaces have many
parameters. That's not a good sign.

I'm thinking of files with names like:
*.measurements.scad
*.feature.scad
*.part.scad
*.layout.scad
*.animation.scad
*.component.scad
etc.

On Thu, Oct 21, 2021 at 2:08 PM Ray West raywest@raywest.com wrote:

Speaking generally, in an example where you have a number of component
items, and a layout/collection file.

if you write each component/part/group of parts as separate modules, and
if you extract all the values that you want to change as variables, you can
test each part individually. then you can comment out the variables that
you want to change in the 'layout file' and save it as a component file.
Then in the layout file,  you can include each component file inside a
module, and set the variables inside the module, or outside, if you want.
That allows you to use simple variable names  like length, width, whatever
for each component, and to have the values individually adjustable in the
layout file, without having to alter values in the component files.
On 21/10/2021 16:55, Patrick Callahan wrote:

I'll want to arrange the data for parts and assemblies in an organized way.

Today, my measurements for a project are in a single .scad file. I import
this file in each part file. But it's becoming unwieldy.
So, I'm looking for advice and examples of ways folks have dealt with the
structure of data in OpenScad projects.'

-Pat

As for scripting, language does not matter to me.
Ideally, I'd like to see the features addressed by scripting handled by
extending the OpenSCAD language, but that's a bit beyond my skills for now.

Data Usage

- absolute measurements for single or multiple sizes
- relative measurements between parts
- clearances
- calculated measures
- re-use of a measurement in multiple parts
- location and orientation data
- movement
- part selection

Goals:

- exploded views
- animated movement showing the assembly process and movement within
the final assembly
- 2d Drawings with labels and measures
- 3d print compatible files with one or more parts
- parts lists (with pictures)
- assembly instructions (with pictures)

On Mon, Oct 11, 2021 at 3:07 PM Ray West raywest@raywest.com wrote:

If it is for my own use and i can't bother with typing a list of if's, I
just rem out what's not needed - e.g. like

// body();
// translate([0,0,-2.5])flor();
translate([0,-0.5,-12-thickness]) underframe();

On 11/10/2021 18:44, Matthieu Hendriks wrote:

Yes I do the same, it's still a workaround for the extra coding effort :)
Groet Matthieu

Jan Wieck schreef op 2021-10-11 19:34:

On 10/11/21 11:59 AM, Matthieu Hendriks wrote:

Is it possible to execute a module depending on a variable name. Example:

When I have "assemblies" I usually create a drop-down list and then
create modules depending on the value. Like:

part = "body"; // [body, arm, leg, head, all]

if (part == "body") { body(); }
if (part == "arm") { arm(); }
...
if (part == "all") {
body();
arm();
leg();
head();
}

That way I can select individual parts to work on, render and export for
printing, but I can also see the entire assembly together. The "all"
selection often has some rotate() and translate() for the actual parts to
put them at the right position within the assembly.

Regards, Jan

module_to_start = "create_plate"

sys(module_to_start) or &module_to_start

module create_plate () { ...}

module create_head () { ...}

Groet Matthieu



OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Ray, I think I'm trying to get to some rules for code and interface organization specific to OpenSCAD. Your comments on the separation of components as modules and the treatment of variables exemplify the kind of structural thinking I want to clarify. I think everyone who uses openSCAD will eventually find that they are solving this kind of problem whether they think about it directly or not. I'm hoping to avoid duplicating work others have already done as I organize my work. Certain "kinds" of OpenSCAD code would be in each of those "types" of files. The question is, what specific kind of code I've got my first project written as individual modules, one module per part usually and sometimes one per feature. But some interfaces have many parameters. That's not a good sign. I'm thinking of files with names like: *.measurements.scad *.feature.scad *.part.scad *.layout.scad *.animation.scad *.component.scad etc. On Thu, Oct 21, 2021 at 2:08 PM Ray West <raywest@raywest.com> wrote: > Speaking generally, in an example where you have a number of component > items, and a layout/collection file. > > if you write each component/part/group of parts as separate modules, and > if you extract all the values that you want to change as variables, you can > test each part individually. then you can comment out the variables that > you want to change in the 'layout file' and save it as a component file. > Then in the layout file, you can include each component file inside a > module, and set the variables inside the module, or outside, if you want. > That allows you to use simple variable names like length, width, whatever > for each component, and to have the values individually adjustable in the > layout file, without having to alter values in the component files. > On 21/10/2021 16:55, Patrick Callahan wrote: > > I'll want to arrange the data for parts and assemblies in an organized way. > > Today, my measurements for a project are in a single .scad file. I import > this file in each part file. But it's becoming unwieldy. > So, I'm looking for advice and examples of ways folks have dealt with the > structure of data in OpenScad projects.' > > -Pat > > > As for scripting, language does not matter to me. > Ideally, I'd like to see the features addressed by scripting handled by > extending the OpenSCAD language, but that's a bit beyond my skills for now. > > Data Usage > > - absolute measurements for single or multiple sizes > - relative measurements between parts > - clearances > - calculated measures > - re-use of a measurement in multiple parts > - location and orientation data > - movement > - part selection > > Goals: > > - exploded views > - animated movement showing the assembly process and movement within > the final assembly > - 2d Drawings with labels and measures > - 3d print compatible files with one or more parts > - parts lists (with pictures) > - assembly instructions (with pictures) > > > On Mon, Oct 11, 2021 at 3:07 PM Ray West <raywest@raywest.com> wrote: > >> If it is for my own use and i can't bother with typing a list of if's, I >> just rem out what's not needed - e.g. like >> >> // body(); >> // translate([0,0,-2.5])flor(); >> translate([0,-0.5,-12-thickness]) underframe(); >> >> >> On 11/10/2021 18:44, Matthieu Hendriks wrote: >> >> Yes I do the same, it's still a workaround for the extra coding effort :) >> Groet Matthieu >> >> >> Jan Wieck schreef op 2021-10-11 19:34: >> >> On 10/11/21 11:59 AM, Matthieu Hendriks wrote: >> >> Is it possible to execute a module depending on a variable name. Example: >> >> >> When I have "assemblies" I usually create a drop-down list and then >> create modules depending on the value. Like: >> >> part = "body"; // [body, arm, leg, head, all] >> >> if (part == "body") { body(); } >> if (part == "arm") { arm(); } >> ... >> if (part == "all") { >> body(); >> arm(); >> leg(); >> head(); >> } >> >> That way I can select individual parts to work on, render and export for >> printing, but I can also see the entire assembly together. The "all" >> selection often has some rotate() and translate() for the actual parts to >> put them at the right position within the assembly. >> >> >> Regards, Jan >> >> >> >> module_to_start = "create_plate" >> >> sys(module_to_start) or &module_to_start >> >> module create_plate () { ...} >> >> module create_head () { ...} >> >> >> >> Groet Matthieu >> ------------------------------------------------------------------------ >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > >
PC
Patrick Callahan
Fri, Oct 22, 2021 7:25 PM

I am thinking about where to put various kinds of data in an OpenSCAD
project.

  1. Encoded in File Names
  2. Scalar and Vector Variable values included* from a .scad file
  3. Python or Bash script variables
  4. Spreadsheets
  5. Flat Files read by a bash or python script
  6. Visual Studio Code configuration?

I'm closely examining  https://github.com/nophead/NopSCADlib to see how
Chris Palmer approaches this.

*To get variable values, I found that I had to use "include" rather than
"use."

Did I mention the case where a 3d print features need scaling to print
accurately?  How do we handle that as data?

On Fri, Oct 22, 2021 at 8:13 AM Patrick Callahan pat.callahan1@gmail.com
wrote:

Ray,

I think I'm trying to get to some rules for code and interface
organization specific to OpenSCAD.

Your comments on the separation of components as modules and the treatment
of variables exemplify the kind of structural thinking I want to clarify.

I think everyone who uses openSCAD will eventually find that they are
solving this kind of problem whether they think about it directly or not.
I'm hoping to avoid duplicating work others have already done as I organize
my work.

Certain "kinds" of OpenSCAD code would be in each of those "types" of
files.  The question is, what specific kind of code

I've got my first project written as individual modules, one module per
part usually and sometimes one per feature. But some interfaces have many
parameters. That's not a good sign.

I'm thinking of files with names like:
*.measurements.scad
*.feature.scad
*.part.scad
*.layout.scad
*.animation.scad
*.component.scad
etc.

On Thu, Oct 21, 2021 at 2:08 PM Ray West raywest@raywest.com wrote:

Speaking generally, in an example where you have a number of component
items, and a layout/collection file.

if you write each component/part/group of parts as separate modules, and
if you extract all the values that you want to change as variables, you can
test each part individually. then you can comment out the variables that
you want to change in the 'layout file' and save it as a component file.
Then in the layout file,  you can include each component file inside a
module, and set the variables inside the module, or outside, if you want.
That allows you to use simple variable names  like length, width, whatever
for each component, and to have the values individually adjustable in the
layout file, without having to alter values in the component files.
On 21/10/2021 16:55, Patrick Callahan wrote:

I'll want to arrange the data for parts and assemblies in an organized
way.

Today, my measurements for a project are in a single .scad file. I import
this file in each part file. But it's becoming unwieldy.
So, I'm looking for advice and examples of ways folks have dealt with the
structure of data in OpenScad projects.'

-Pat

As for scripting, language does not matter to me.
Ideally, I'd like to see the features addressed by scripting handled by
extending the OpenSCAD language, but that's a bit beyond my skills for now.

Data Usage

- absolute measurements for single or multiple sizes
- relative measurements between parts
- clearances
- calculated measures
- re-use of a measurement in multiple parts
- location and orientation data
- movement
- part selection

Goals:

- exploded views
- animated movement showing the assembly process and movement within
the final assembly
- 2d Drawings with labels and measures
- 3d print compatible files with one or more parts
- parts lists (with pictures)
- assembly instructions (with pictures)

On Mon, Oct 11, 2021 at 3:07 PM Ray West raywest@raywest.com wrote:

If it is for my own use and i can't bother with typing a list of if's, I
just rem out what's not needed - e.g. like

// body();
// translate([0,0,-2.5])flor();
translate([0,-0.5,-12-thickness]) underframe();

On 11/10/2021 18:44, Matthieu Hendriks wrote:

Yes I do the same, it's still a workaround for the extra coding effort
:)
Groet Matthieu

Jan Wieck schreef op 2021-10-11 19:34:

On 10/11/21 11:59 AM, Matthieu Hendriks wrote:

Is it possible to execute a module depending on a variable name. Example:

When I have "assemblies" I usually create a drop-down list and then
create modules depending on the value. Like:

part = "body"; // [body, arm, leg, head, all]

if (part == "body") { body(); }
if (part == "arm") { arm(); }
...
if (part == "all") {
body();
arm();
leg();
head();
}

That way I can select individual parts to work on, render and export for
printing, but I can also see the entire assembly together. The "all"
selection often has some rotate() and translate() for the actual parts to
put them at the right position within the assembly.

Regards, Jan

module_to_start = "create_plate"

sys(module_to_start) or &module_to_start

module create_plate () { ...}

module create_head () { ...}

Groet Matthieu



OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I am thinking about where to put various kinds of data in an OpenSCAD project. 1. Encoded in File Names 2. Scalar and Vector Variable values included* from a .scad file 3. Python or Bash script variables 4. Spreadsheets 5. Flat Files read by a bash or python script 6. Visual Studio Code configuration? I'm closely examining https://github.com/nophead/NopSCADlib to see how Chris Palmer approaches this. *To get variable values, I found that I had to use "include" rather than "use." Did I mention the case where a 3d print features need scaling to print accurately? How do we handle that as data? On Fri, Oct 22, 2021 at 8:13 AM Patrick Callahan <pat.callahan1@gmail.com> wrote: > Ray, > > I think I'm trying to get to some rules for code and interface > organization specific to OpenSCAD. > > Your comments on the separation of components as modules and the treatment > of variables exemplify the kind of structural thinking I want to clarify. > > I think everyone who uses openSCAD will eventually find that they are > solving this kind of problem whether they think about it directly or not. > I'm hoping to avoid duplicating work others have already done as I organize > my work. > > Certain "kinds" of OpenSCAD code would be in each of those "types" of > files. The question is, what specific kind of code > > I've got my first project written as individual modules, one module per > part usually and sometimes one per feature. But some interfaces have many > parameters. That's not a good sign. > > I'm thinking of files with names like: > *.measurements.scad > *.feature.scad > *.part.scad > *.layout.scad > *.animation.scad > *.component.scad > etc. > > > On Thu, Oct 21, 2021 at 2:08 PM Ray West <raywest@raywest.com> wrote: > >> Speaking generally, in an example where you have a number of component >> items, and a layout/collection file. >> >> if you write each component/part/group of parts as separate modules, and >> if you extract all the values that you want to change as variables, you can >> test each part individually. then you can comment out the variables that >> you want to change in the 'layout file' and save it as a component file. >> Then in the layout file, you can include each component file inside a >> module, and set the variables inside the module, or outside, if you want. >> That allows you to use simple variable names like length, width, whatever >> for each component, and to have the values individually adjustable in the >> layout file, without having to alter values in the component files. >> On 21/10/2021 16:55, Patrick Callahan wrote: >> >> I'll want to arrange the data for parts and assemblies in an organized >> way. >> >> Today, my measurements for a project are in a single .scad file. I import >> this file in each part file. But it's becoming unwieldy. >> So, I'm looking for advice and examples of ways folks have dealt with the >> structure of data in OpenScad projects.' >> >> -Pat >> >> >> As for scripting, language does not matter to me. >> Ideally, I'd like to see the features addressed by scripting handled by >> extending the OpenSCAD language, but that's a bit beyond my skills for now. >> >> Data Usage >> >> - absolute measurements for single or multiple sizes >> - relative measurements between parts >> - clearances >> - calculated measures >> - re-use of a measurement in multiple parts >> - location and orientation data >> - movement >> - part selection >> >> Goals: >> >> - exploded views >> - animated movement showing the assembly process and movement within >> the final assembly >> - 2d Drawings with labels and measures >> - 3d print compatible files with one or more parts >> - parts lists (with pictures) >> - assembly instructions (with pictures) >> >> >> On Mon, Oct 11, 2021 at 3:07 PM Ray West <raywest@raywest.com> wrote: >> >>> If it is for my own use and i can't bother with typing a list of if's, I >>> just rem out what's not needed - e.g. like >>> >>> // body(); >>> // translate([0,0,-2.5])flor(); >>> translate([0,-0.5,-12-thickness]) underframe(); >>> >>> >>> On 11/10/2021 18:44, Matthieu Hendriks wrote: >>> >>> Yes I do the same, it's still a workaround for the extra coding effort >>> :) >>> Groet Matthieu >>> >>> >>> Jan Wieck schreef op 2021-10-11 19:34: >>> >>> On 10/11/21 11:59 AM, Matthieu Hendriks wrote: >>> >>> Is it possible to execute a module depending on a variable name. Example: >>> >>> >>> When I have "assemblies" I usually create a drop-down list and then >>> create modules depending on the value. Like: >>> >>> part = "body"; // [body, arm, leg, head, all] >>> >>> if (part == "body") { body(); } >>> if (part == "arm") { arm(); } >>> ... >>> if (part == "all") { >>> body(); >>> arm(); >>> leg(); >>> head(); >>> } >>> >>> That way I can select individual parts to work on, render and export for >>> printing, but I can also see the entire assembly together. The "all" >>> selection often has some rotate() and translate() for the actual parts to >>> put them at the right position within the assembly. >>> >>> >>> Regards, Jan >>> >>> >>> >>> module_to_start = "create_plate" >>> >>> sys(module_to_start) or &module_to_start >>> >>> module create_plate () { ...} >>> >>> module create_head () { ...} >>> >>> >>> >>> Groet Matthieu >>> ------------------------------------------------------------------------ >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >>
WF
William F. Adams
Fri, Oct 22, 2021 7:36 PM

Is there a reason you left out using parameters from the JSON file for them using the Customizer?
William

-----Original Message-----
From: Patrick Callahan pat.callahan1@gmail.com
To: OpenSCAD general discussion discuss@lists.openscad.org
Sent: Fri, Oct 22, 2021 3:25 pm
Subject: [OpenSCAD] Re: Fwd: Re: start a module from a variabel

I am thinking about where to put various kinds of data in an OpenSCAD project.

  • Encoded in File Names
  • Scalar and Vector Variable values included* from a .scad file 
  • Python or Bash script variables
  • Spreadsheets
  • Flat Files read by a bash or python script
  • Visual Studio Code configuration?
    I'm closely examining  https://github.com/nophead/NopSCADlib to see how Chris Palmer approaches this.
    *To get variable values, I found that I had to use "include" rather than "use."
    Did I mention the case where a 3d print features need scaling to print accurately?  How do we handle that as data?
    On Fri, Oct 22, 2021 at 8:13 AM Patrick Callahan pat.callahan1@gmail.com wrote:

Ray,
I think I'm trying to get to some rules for code and interface organization specific to OpenSCAD.
Your comments on the separation of components as modules and the treatment of variables exemplify the kind of structural thinking I want to clarify.
I think everyone who uses openSCAD will eventually find that they are solving this kind of problem whether they think about it directly or not.  I'm hoping to avoid duplicating work others have already done as I organize my work.
Certain "kinds" of OpenSCAD code would be in each of those "types" of files.  The question is, what specific kind of code 
I've got my first project written as individual modules, one module per part usually and sometimes one per feature. But some interfaces have many parameters. That's not a good sign.
I'm thinking of files with names like:
.measurements.scad.feature.scad*.part.scad*.layout.scad*.animation.scad*.component.scadetc. 
On Thu, Oct 21, 2021 at 2:08 PM Ray West raywest@raywest.com wrote:

Speaking generally, in an example where you have a number of component items, and a layout/collection file. if you write each component/part/group of parts as separate modules, and if you extract all the values that you want to change as variables, you can test each part individually. then you can comment out the variables that you want to change in the 'layout file' and save it as a component file. Then in the layout file,  you can include each component file inside a module, and set the variables inside the module, or outside, if you want. That allows you to use simple variable names  like length, width, whatever for each component, and to have the values individually adjustable in the layout file, without having to alter values in the component files. 
On 21/10/2021 16:55, Patrick Callahan wrote:

I'll want to arrange the data for parts and assemblies in an organized way.

Today, my measurements for a project are in a single .scad file. I import this file in each part file. But it's becoming unwieldy.  So, I'm looking for advice and examples of ways folks have dealt with the structure of data in OpenScad projects.'

-Pat

As for scripting, language does not matter to me.   Ideally, I'd like to see the features addressed by scripting handled by extending the OpenSCAD language, but that's a bit beyond my skills for now.     Data Usage 

  • absolute measurements for single or multiple sizes
  • relative measurements between parts
  • clearances
  • calculated measures
  • re-use of a measurement in multiple parts
  • location and orientation data
  • movement 
  • part selection
    Goals:
  • exploded views
  • animated movement showing the assembly process and movement within the final assembly
  • 2d Drawings with labels and measures
  • 3d print compatible files with one or more parts
  • parts lists (with pictures)
  • assembly instructions (with pictures)

On Mon, Oct 11, 2021 at 3:07 PM Ray West raywest@raywest.com wrote:

If it is for my own use and i can't bother with typing a list of if's, I just rem out what's not needed - e.g. like   // body();
 // translate([0,0,-2.5])flor();
   translate([0,-0.5,-12-thickness]) underframe();
On 11/10/2021 18:44, Matthieu Hendriks wrote:

Yes I do the same, it's still a workaround for the extra coding effort :)   Groet Matthieu
Jan Wieck schreef op 2021-10-11 19:34:
On 10/11/21 11:59 AM, Matthieu Hendriks wrote:
Is it possible to execute a module depending on a variable name. Example:

When I have "assemblies" I usually create a drop-down list and then create modules depending on the value. Like:

part = "body"; // [body, arm, leg, head, all]

if (part == "body") { body(); }
if (part == "arm") { arm(); }
...
if (part == "all") {
    body();
    arm();
    leg();
    head();
}

That way I can select individual parts to work on, render and export for printing, but I can also see the entire assembly together. The "all" selection often has some rotate() and translate() for the actual parts to put them at the right position within the assembly.

Regards, Jan

module_to_start = "create_plate"

sys(module_to_start) or &module_to_start

module create_plate () { ...}

module create_head () { ...}

Groet Matthieu



OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Is there a reason you left out using parameters from the JSON file for them using the Customizer? William -----Original Message----- From: Patrick Callahan <pat.callahan1@gmail.com> To: OpenSCAD general discussion <discuss@lists.openscad.org> Sent: Fri, Oct 22, 2021 3:25 pm Subject: [OpenSCAD] Re: Fwd: Re: start a module from a variabel I am thinking about where to put various kinds of data in an OpenSCAD project. - Encoded in File Names - Scalar and Vector Variable values included* from a .scad file  - Python or Bash script variables - Spreadsheets - Flat Files read by a bash or python script - Visual Studio Code configuration? I'm closely examining  https://github.com/nophead/NopSCADlib to see how Chris Palmer approaches this. *To get variable values, I found that I had to use "include" rather than "use." Did I mention the case where a 3d print features need scaling to print accurately?  How do we handle that as data? On Fri, Oct 22, 2021 at 8:13 AM Patrick Callahan <pat.callahan1@gmail.com> wrote: Ray, I think I'm trying to get to some rules for code and interface organization specific to OpenSCAD. Your comments on the separation of components as modules and the treatment of variables exemplify the kind of structural thinking I want to clarify. I think everyone who uses openSCAD will eventually find that they are solving this kind of problem whether they think about it directly or not.  I'm hoping to avoid duplicating work others have already done as I organize my work. Certain "kinds" of OpenSCAD code would be in each of those "types" of files.  The question is, what specific kind of code  I've got my first project written as individual modules, one module per part usually and sometimes one per feature. But some interfaces have many parameters. That's not a good sign. I'm thinking of files with names like: *.measurements.scad*.feature.scad*.part.scad*.layout.scad*.animation.scad*.component.scadetc.  On Thu, Oct 21, 2021 at 2:08 PM Ray West <raywest@raywest.com> wrote: Speaking generally, in an example where you have a number of component items, and a layout/collection file. if you write each component/part/group of parts as separate modules, and if you extract all the values that you want to change as variables, you can test each part individually. then you can comment out the variables that you want to change in the 'layout file' and save it as a component file. Then in the layout file,  you can include each component file inside a module, and set the variables inside the module, or outside, if you want. That allows you to use simple variable names  like length, width, whatever for each component, and to have the values individually adjustable in the layout file, without having to alter values in the component files.  On 21/10/2021 16:55, Patrick Callahan wrote: I'll want to arrange the data for parts and assemblies in an organized way. Today, my measurements for a project are in a single .scad file. I import this file in each part file. But it's becoming unwieldy. So, I'm looking for advice and examples of ways folks have dealt with the structure of data in OpenScad projects.' -Pat As for scripting, language does not matter to me.   Ideally, I'd like to see the features addressed by scripting handled by extending the OpenSCAD language, but that's a bit beyond my skills for now.    Data Usage  - absolute measurements for single or multiple sizes - relative measurements between parts - clearances - calculated measures - re-use of a measurement in multiple parts - location and orientation data - movement  - part selection Goals: - exploded views - animated movement showing the assembly process and movement within the final assembly - 2d Drawings with labels and measures - 3d print compatible files with one or more parts - parts lists (with pictures) - assembly instructions (with pictures) On Mon, Oct 11, 2021 at 3:07 PM Ray West <raywest@raywest.com> wrote: If it is for my own use and i can't bother with typing a list of if's, I just rem out what's not needed - e.g. like  // body();  // translate([0,0,-2.5])flor();    translate([0,-0.5,-12-thickness]) underframe(); On 11/10/2021 18:44, Matthieu Hendriks wrote: Yes I do the same, it's still a workaround for the extra coding effort :)  Groet Matthieu Jan Wieck schreef op 2021-10-11 19:34: On 10/11/21 11:59 AM, Matthieu Hendriks wrote: Is it possible to execute a module depending on a variable name. Example: When I have "assemblies" I usually create a drop-down list and then create modules depending on the value. Like: part = "body"; // [body, arm, leg, head, all] if (part == "body") { body(); } if (part == "arm") { arm(); } ... if (part == "all") {     body();     arm();     leg();     head(); } That way I can select individual parts to work on, render and export for printing, but I can also see the entire assembly together. The "all" selection often has some rotate() and translate() for the actual parts to put them at the right position within the assembly. Regards, Jan module_to_start = "create_plate" sys(module_to_start) or &module_to_start module create_plate () { ...} module create_head () { ...} Groet Matthieu ------------------------------------------------------------------------ ------------------------------------------------------------------------ _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org
NH
nop head
Fri, Oct 22, 2021 9:45 PM

I never put scaling factors in my OpenSCAD code. I just calibrate my
printers and slicer setting to print things the correct size. I recently
checked my Mendel90 printer that was last calibrated around 10 years ago.

[image: IMG_20210323_212659826.jpg][image: IMG_20210323_212544674.jpg]

Most of my project dimensions are expressions that involve the size of its
components. If it has more than one file then yes I put them in a common
file that is included.

A simple example I am working on at the moment has lines like these:

psu = ATX300;

box_type = box(screw = M4_dome_screw, wall = 2, sheets = DiBond, top_sheet
= DiBond, base_sheet = DiBond, size = []);

clearance = 2;
front_depth = 50;

box = concat(box_type, [psu_length(psu) + 2 * (clearance +
box_wall(box_type)),
psu_height(psu) + 2 * (clearance +
box_intrusion(box_type)),
psu_width(psu) + front_depth]);

meter = DSN_VC288;
meter_spacing = 2.5;

function meter_pos(i) = let(s = pmeter_bezel(meter)) [(i % 2 ? -1 : 1) *
(s.x / 2 + meter_spacing), (i < 2 ? -1 : 1) * (s.y / 2 + meter_spacing)];

module meter_positions()
for(i = [0 : 3])
translate(meter_pos(i))
children();

module output_positions()
for(i = [0 : 3])
let($colours = [["blue", "royalblue"], [ "green", "springgreen"],
["red", "red"], ["yellow", "yellow"]][i],
$value = ["120","330","500","120"][i]
)
translate(meter_pos(i) + [(i % 2 ? -1 : 1) * (pmeter_bezel(meter).x
/ 2 + jack_4mm_flange_radius() + meter_spacing), 0])
children();

jack_pitch = 15;
led = LED5mm;
led_x = 0;
led_y = -35;

When I do F5 OpenSCAD tells me my box is 133 x 89 x 150, so I know it will
be printable.

This project has only two files at the moment. lab_atx2.scad and shunt.scad.

[image: image.png]

[image: image.png]

For big mult-project files like a 3D printer I might include a
positions.scad to place the internal assemblies but most of my projects are
only one or two files.

On Fri, 22 Oct 2021 at 20:28, Patrick Callahan pat.callahan1@gmail.com
wrote:

I am thinking about where to put various kinds of data in an OpenSCAD
project.

1. Encoded in File Names
2. Scalar and Vector Variable values included* from a .scad file
3. Python or Bash script variables
4. Spreadsheets
5. Flat Files read by a bash or python script
6. Visual Studio Code configuration?

I'm closely examining  https://github.com/nophead/NopSCADlib to see how
Chris Palmer approaches this.

*To get variable values, I found that I had to use "include" rather than
"use."

Did I mention the case where a 3d print features need scaling to print
accurately?  How do we handle that as data?

On Fri, Oct 22, 2021 at 8:13 AM Patrick Callahan pat.callahan1@gmail.com
wrote:

Ray,

I think I'm trying to get to some rules for code and interface
organization specific to OpenSCAD.

Your comments on the separation of components as modules and the
treatment of variables exemplify the kind of structural thinking I want to
clarify.

I think everyone who uses openSCAD will eventually find that they are
solving this kind of problem whether they think about it directly or not.
I'm hoping to avoid duplicating work others have already done as I organize
my work.

Certain "kinds" of OpenSCAD code would be in each of those "types" of
files.  The question is, what specific kind of code

I've got my first project written as individual modules, one module per
part usually and sometimes one per feature. But some interfaces have many
parameters. That's not a good sign.

I'm thinking of files with names like:
*.measurements.scad
*.feature.scad
*.part.scad
*.layout.scad
*.animation.scad
*.component.scad
etc.

On Thu, Oct 21, 2021 at 2:08 PM Ray West raywest@raywest.com wrote:

Speaking generally, in an example where you have a number of component
items, and a layout/collection file.

if you write each component/part/group of parts as separate modules, and
if you extract all the values that you want to change as variables, you can
test each part individually. then you can comment out the variables that
you want to change in the 'layout file' and save it as a component file.
Then in the layout file,  you can include each component file inside a
module, and set the variables inside the module, or outside, if you want.
That allows you to use simple variable names  like length, width, whatever
for each component, and to have the values individually adjustable in the
layout file, without having to alter values in the component files.
On 21/10/2021 16:55, Patrick Callahan wrote:

I'll want to arrange the data for parts and assemblies in an organized
way.

Today, my measurements for a project are in a single .scad file. I
import this file in each part file. But it's becoming unwieldy.
So, I'm looking for advice and examples of ways folks have dealt with
the structure of data in OpenScad projects.'

-Pat

As for scripting, language does not matter to me.
Ideally, I'd like to see the features addressed by scripting handled by
extending the OpenSCAD language, but that's a bit beyond my skills for now.

Data Usage

- absolute measurements for single or multiple sizes
- relative measurements between parts
- clearances
- calculated measures
- re-use of a measurement in multiple parts
- location and orientation data
- movement
- part selection

Goals:

- exploded views
- animated movement showing the assembly process and movement within
the final assembly
- 2d Drawings with labels and measures
- 3d print compatible files with one or more parts
- parts lists (with pictures)
- assembly instructions (with pictures)

On Mon, Oct 11, 2021 at 3:07 PM Ray West raywest@raywest.com wrote:

If it is for my own use and i can't bother with typing a list of if's,
I just rem out what's not needed - e.g. like

// body();
// translate([0,0,-2.5])flor();
translate([0,-0.5,-12-thickness]) underframe();

On 11/10/2021 18:44, Matthieu Hendriks wrote:

Yes I do the same, it's still a workaround for the extra coding effort
:)
Groet Matthieu

Jan Wieck schreef op 2021-10-11 19:34:

On 10/11/21 11:59 AM, Matthieu Hendriks wrote:

Is it possible to execute a module depending on a variable name. Example:

When I have "assemblies" I usually create a drop-down list and then
create modules depending on the value. Like:

part = "body"; // [body, arm, leg, head, all]

if (part == "body") { body(); }
if (part == "arm") { arm(); }
...
if (part == "all") {
body();
arm();
leg();
head();
}

That way I can select individual parts to work on, render and export
for printing, but I can also see the entire assembly together. The "all"
selection often has some rotate() and translate() for the actual parts to
put them at the right position within the assembly.

Regards, Jan

module_to_start = "create_plate"

sys(module_to_start) or &module_to_start

module create_plate () { ...}

module create_head () { ...}

Groet Matthieu



OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I never put scaling factors in my OpenSCAD code. I just calibrate my printers and slicer setting to print things the correct size. I recently checked my Mendel90 printer that was last calibrated around 10 years ago. [image: IMG_20210323_212659826.jpg][image: IMG_20210323_212544674.jpg] Most of my project dimensions are expressions that involve the size of its components. If it has more than one file then yes I put them in a common file that is included. A simple example I am working on at the moment has lines like these: psu = ATX300; box_type = box(screw = M4_dome_screw, wall = 2, sheets = DiBond, top_sheet = DiBond, base_sheet = DiBond, size = []); clearance = 2; front_depth = 50; box = concat(box_type, [psu_length(psu) + 2 * (clearance + box_wall(box_type)), psu_height(psu) + 2 * (clearance + box_intrusion(box_type)), psu_width(psu) + front_depth]); meter = DSN_VC288; meter_spacing = 2.5; function meter_pos(i) = let(s = pmeter_bezel(meter)) [(i % 2 ? -1 : 1) * (s.x / 2 + meter_spacing), (i < 2 ? -1 : 1) * (s.y / 2 + meter_spacing)]; module meter_positions() for(i = [0 : 3]) translate(meter_pos(i)) children(); module output_positions() for(i = [0 : 3]) let($colours = [["blue", "royalblue"], [ "green", "springgreen"], ["red", "red"], ["yellow", "yellow"]][i], $value = ["120","330","500","120"][i] ) translate(meter_pos(i) + [(i % 2 ? -1 : 1) * (pmeter_bezel(meter).x / 2 + jack_4mm_flange_radius() + meter_spacing), 0]) children(); jack_pitch = 15; led = LED5mm; led_x = 0; led_y = -35; When I do F5 OpenSCAD tells me my box is 133 x 89 x 150, so I know it will be printable. This project has only two files at the moment. lab_atx2.scad and shunt.scad. [image: image.png] [image: image.png] For big mult-project files like a 3D printer I might include a positions.scad to place the internal assemblies but most of my projects are only one or two files. On Fri, 22 Oct 2021 at 20:28, Patrick Callahan <pat.callahan1@gmail.com> wrote: > I am thinking about where to put various kinds of data in an OpenSCAD > project. > > 1. Encoded in File Names > 2. Scalar and Vector Variable values included* from a .scad file > 3. Python or Bash script variables > 4. Spreadsheets > 5. Flat Files read by a bash or python script > 6. Visual Studio Code configuration? > > I'm closely examining https://github.com/nophead/NopSCADlib to see how > Chris Palmer approaches this. > > *To get variable values, I found that I had to use "include" rather than > "use." > > Did I mention the case where a 3d print features need scaling to print > accurately? How do we handle that as data? > > On Fri, Oct 22, 2021 at 8:13 AM Patrick Callahan <pat.callahan1@gmail.com> > wrote: > >> Ray, >> >> I think I'm trying to get to some rules for code and interface >> organization specific to OpenSCAD. >> >> Your comments on the separation of components as modules and the >> treatment of variables exemplify the kind of structural thinking I want to >> clarify. >> >> I think everyone who uses openSCAD will eventually find that they are >> solving this kind of problem whether they think about it directly or not. >> I'm hoping to avoid duplicating work others have already done as I organize >> my work. >> >> Certain "kinds" of OpenSCAD code would be in each of those "types" of >> files. The question is, what specific kind of code >> >> I've got my first project written as individual modules, one module per >> part usually and sometimes one per feature. But some interfaces have many >> parameters. That's not a good sign. >> >> I'm thinking of files with names like: >> *.measurements.scad >> *.feature.scad >> *.part.scad >> *.layout.scad >> *.animation.scad >> *.component.scad >> etc. >> >> >> On Thu, Oct 21, 2021 at 2:08 PM Ray West <raywest@raywest.com> wrote: >> >>> Speaking generally, in an example where you have a number of component >>> items, and a layout/collection file. >>> >>> if you write each component/part/group of parts as separate modules, and >>> if you extract all the values that you want to change as variables, you can >>> test each part individually. then you can comment out the variables that >>> you want to change in the 'layout file' and save it as a component file. >>> Then in the layout file, you can include each component file inside a >>> module, and set the variables inside the module, or outside, if you want. >>> That allows you to use simple variable names like length, width, whatever >>> for each component, and to have the values individually adjustable in the >>> layout file, without having to alter values in the component files. >>> On 21/10/2021 16:55, Patrick Callahan wrote: >>> >>> I'll want to arrange the data for parts and assemblies in an organized >>> way. >>> >>> Today, my measurements for a project are in a single .scad file. I >>> import this file in each part file. But it's becoming unwieldy. >>> So, I'm looking for advice and examples of ways folks have dealt with >>> the structure of data in OpenScad projects.' >>> >>> -Pat >>> >>> >>> As for scripting, language does not matter to me. >>> Ideally, I'd like to see the features addressed by scripting handled by >>> extending the OpenSCAD language, but that's a bit beyond my skills for now. >>> >>> Data Usage >>> >>> - absolute measurements for single or multiple sizes >>> - relative measurements between parts >>> - clearances >>> - calculated measures >>> - re-use of a measurement in multiple parts >>> - location and orientation data >>> - movement >>> - part selection >>> >>> Goals: >>> >>> - exploded views >>> - animated movement showing the assembly process and movement within >>> the final assembly >>> - 2d Drawings with labels and measures >>> - 3d print compatible files with one or more parts >>> - parts lists (with pictures) >>> - assembly instructions (with pictures) >>> >>> >>> On Mon, Oct 11, 2021 at 3:07 PM Ray West <raywest@raywest.com> wrote: >>> >>>> If it is for my own use and i can't bother with typing a list of if's, >>>> I just rem out what's not needed - e.g. like >>>> >>>> // body(); >>>> // translate([0,0,-2.5])flor(); >>>> translate([0,-0.5,-12-thickness]) underframe(); >>>> >>>> >>>> On 11/10/2021 18:44, Matthieu Hendriks wrote: >>>> >>>> Yes I do the same, it's still a workaround for the extra coding effort >>>> :) >>>> Groet Matthieu >>>> >>>> >>>> Jan Wieck schreef op 2021-10-11 19:34: >>>> >>>> On 10/11/21 11:59 AM, Matthieu Hendriks wrote: >>>> >>>> >>>> Is it possible to execute a module depending on a variable name. Example: >>>> >>>> >>>> When I have "assemblies" I usually create a drop-down list and then >>>> create modules depending on the value. Like: >>>> >>>> part = "body"; // [body, arm, leg, head, all] >>>> >>>> if (part == "body") { body(); } >>>> if (part == "arm") { arm(); } >>>> ... >>>> if (part == "all") { >>>> body(); >>>> arm(); >>>> leg(); >>>> head(); >>>> } >>>> >>>> That way I can select individual parts to work on, render and export >>>> for printing, but I can also see the entire assembly together. The "all" >>>> selection often has some rotate() and translate() for the actual parts to >>>> put them at the right position within the assembly. >>>> >>>> >>>> Regards, Jan >>>> >>>> >>>> >>>> module_to_start = "create_plate" >>>> >>>> sys(module_to_start) or &module_to_start >>>> >>>> module create_plate () { ...} >>>> >>>> module create_head () { ...} >>>> >>>> >>>> >>>> Groet Matthieu >>>> ------------------------------------------------------------------------ >>>> ------------------------------------------------------------------------ >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >>> _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
T
terrypingm@gmail.com
Sat, Oct 23, 2021 7:57 AM

“ When I do F5 OpenSCAD tells me my box is 133 x 89 x 150“

Please excuse this elementary side question:
Do you mean that’s what you visually measure from the axes markers? Or is it something more explicit?
Terry

--
Terry

On 22 Oct 2021, at 22:52, nop head nop.head@gmail.com wrote:

When I do F5 OpenSCAD tells me my box is 133 x 89 x 150

“ When I do F5 OpenSCAD tells me my box is 133 x 89 x 150“ Please excuse this elementary side question: Do you mean that’s what you visually measure from the axes markers? Or is it something more explicit? Terry -- Terry > On 22 Oct 2021, at 22:52, nop head <nop.head@gmail.com> wrote: > > When I do F5 OpenSCAD tells me my box is 133 x 89 x 150
NH
nop head
Sat, Oct 23, 2021 9:03 AM

The module that makes the box has an echo statement that shows the internal
dimensions.

ECHO: "Box:", 133, 89, 150

This is because they are usually complicated expressions to fit the
internal components, so it is not obvious what they are. When the box is
small enough I use 3D printed panels. When it is too big for my printer I
use CNC cut DiBond panels with printed bezels and corner profiles. They can
be printed in arbitrarily many pieces and solvent welded together. So I can
make enclosures up to the capacity of my CNC milling machine. I also have a
simpler box in my library that is just sheets and brackets.
[image: image.png]

That module also echos its internal volume because I made a double walled
filament dryer and needed to estimate the volume of insulations that I
needed. So I subtracted the volume of the inner box. I stuff the gap with
cotton wool, which is a nice to handle insulator.
[image: bbox_assembly.png]

On Sat, 23 Oct 2021 at 08:57, terrypingm@gmail.com terrypingm@gmail.com
wrote:

“ When I do F5 OpenSCAD tells me my box is 133 x 89 x 150“

Please excuse this elementary side question:
Do you mean that’s what you visually measure from the axes markers? Or is
it something more explicit?
Terry

--
Terry

On 22 Oct 2021, at 22:52, nop head nop.head@gmail.com wrote:

When I do F5 OpenSCAD tells me my box is 133 x 89 x 150


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

The module that makes the box has an echo statement that shows the internal dimensions. ECHO: "Box:", 133, 89, 150 This is because they are usually complicated expressions to fit the internal components, so it is not obvious what they are. When the box is small enough I use 3D printed panels. When it is too big for my printer I use CNC cut DiBond panels with printed bezels and corner profiles. They can be printed in arbitrarily many pieces and solvent welded together. So I can make enclosures up to the capacity of my CNC milling machine. I also have a simpler box in my library that is just sheets and brackets. [image: image.png] That module also echos its internal volume because I made a double walled filament dryer and needed to estimate the volume of insulations that I needed. So I subtracted the volume of the inner box. I stuff the gap with cotton wool, which is a nice to handle insulator. [image: bbox_assembly.png] On Sat, 23 Oct 2021 at 08:57, terrypingm@gmail.com <terrypingm@gmail.com> wrote: > “ When I do F5 OpenSCAD tells me my box is 133 x 89 x 150“ > > Please excuse this elementary side question: > Do you mean that’s what you visually measure from the axes markers? Or is > it something more explicit? > Terry > > -- > Terry > > > On 22 Oct 2021, at 22:52, nop head <nop.head@gmail.com> wrote: > > > > When I do F5 OpenSCAD tells me my box is 133 x 89 x 150 > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
TP
Torsten Paul
Sat, Oct 23, 2021 6:01 PM

On 22.10.21 21:25, Patrick Callahan wrote:

I am thinking about where to put various kinds of data
in an OpenSCAD project.

It also should soon(-ish) be possible to import data via
JSON files.

See https://github.com/openscad/openscad/pull/3891

Example with JSON file:

{
"number": 2,
"float": 3.5e-10,
"bool": true,
"string": "hallo world!",
"array_number": [ 0, 1, 2, 3, 5 ],
"array-string": [ "one", "two", "three" ],
"array-mixed": [ "one", 1, false ],
"object": {
"name": "The object name",
"nested": {
"value": 42
},
"number": 4
}
}

Usage:

j = import("scad-data.json");

echo(j.string); // ECHO: "hallo world!"
echo(j.array_number); // ECHO: [0, 1, 2, 3, 5]
echo(j["array-string"]); // ECHO: ["one", "two", "three"]
echo(j.object.name); // ECHO: "The object name"
echo(j.object.nested.value); // ECHO: 42

ciao,
Torsten.

On 22.10.21 21:25, Patrick Callahan wrote: > I am thinking about where to put various kinds of data > in an OpenSCAD project. It also should soon(-ish) be possible to import data via JSON files. See https://github.com/openscad/openscad/pull/3891 Example with JSON file: { "number": 2, "float": 3.5e-10, "bool": true, "string": "hallo world!", "array_number": [ 0, 1, 2, 3, 5 ], "array-string": [ "one", "two", "three" ], "array-mixed": [ "one", 1, false ], "object": { "name": "The object name", "nested": { "value": 42 }, "number": 4 } } Usage: j = import("scad-data.json"); echo(j.string); // ECHO: "hallo world!" echo(j.array_number); // ECHO: [0, 1, 2, 3, 5] echo(j["array-string"]); // ECHO: ["one", "two", "three"] echo(j.object.name); // ECHO: "The object name" echo(j.object.nested.value); // ECHO: 42 ciao, Torsten.
LM
Leonard Martin Struttmann
Sat, Oct 23, 2021 9:45 PM

As for avoiding frameworks becoming more onerous than the problem, that's
something I'd prefer to avoid.  I know from experience that it's easy to
let the tail wag the dog.

*I'm not so much looking for a library or method that solves all problems,
as seeking a small set of strategies or guidelines for creating modules,
functions, and variables, then putting them in separate files that play
nicely together across a larger project. *

Patrick,

I, too, felt this way when I first started more complex projects. I didn't
want to learn someone else's framework which would probably be much more
complicated than I needed.

In the end, I came up with a set of coding practices with a small number of
helper utilities that help me keep things organized.

My most important practices are:

1, Each part is in its own file.
2. Part files are never accessed with include<>.  They are accessed with
use<>.  This avoids polluting my namespace.
3. If I need data from a part, I publish that data by defining a function
in the part file.  This function usually has the same name as the part
module.
4. If multiple data items need to be published, the part function uses a
text-based table lookup to return the correct data item.

Example:

In my main assembly I can create a part and query properties of that part:

use <stepper_motor_bracket.scad>

stepper_motor_bracket( parameters... );
bracket_height = stepper_motor_bracket( "height" );
bracket_width = stepper_motor_bracket( "width" );

On Sat, Oct 23, 2021 at 1:02 PM Torsten Paul Torsten.Paul@gmx.de wrote:

On 22.10.21 21:25, Patrick Callahan wrote:

I am thinking about where to put various kinds of data
in an OpenSCAD project.

It also should soon(-ish) be possible to import data via
JSON files.

See https://github.com/openscad/openscad/pull/3891

Example with JSON file:

{
"number": 2,
"float": 3.5e-10,
"bool": true,
"string": "hallo world!",
"array_number": [ 0, 1, 2, 3, 5 ],
"array-string": [ "one", "two", "three" ],
"array-mixed": [ "one", 1, false ],
"object": {
"name": "The object name",
"nested": {
"value": 42
},
"number": 4
}
}

Usage:

j = import("scad-data.json");

echo(j.string); // ECHO: "hallo world!"
echo(j.array_number); // ECHO: [0, 1, 2, 3, 5]
echo(j["array-string"]); // ECHO: ["one", "two", "three"]
echo(j.object.name); // ECHO: "The object name"
echo(j.object.nested.value); // ECHO: 42

ciao,
Torsten.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

*As for avoiding frameworks becoming more onerous than the problem, that's something I'd prefer to avoid. I know from experience that it's easy to let the tail wag the dog.* *I'm not so much looking for a library or method that solves all problems, as seeking a small set of strategies or guidelines for creating modules, functions, and variables, then putting them in separate files that play nicely together across a larger project. * Patrick, I, too, felt this way when I first started more complex projects. I didn't want to learn someone else's framework which would probably be much more complicated than I needed. In the end, I came up with a set of coding practices with a small number of helper utilities that help me keep things organized. My most important practices are: 1, Each part is in its own file. 2. Part files are never accessed with include<>. They are accessed with use<>. This avoids polluting my namespace. 3. If I need data from a part, I publish that data by defining a function in the part file. This function usually has the same name as the part module. 4. If multiple data items need to be published, the part function uses a text-based table lookup to return the correct data item. Example: In my main assembly I can create a part and query properties of that part: use <stepper_motor_bracket.scad> stepper_motor_bracket( parameters... ); bracket_height = stepper_motor_bracket( "height" ); bracket_width = stepper_motor_bracket( "width" ); On Sat, Oct 23, 2021 at 1:02 PM Torsten Paul <Torsten.Paul@gmx.de> wrote: > On 22.10.21 21:25, Patrick Callahan wrote: > > I am thinking about where to put various kinds of data > > in an OpenSCAD project. > > It also should soon(-ish) be possible to import data via > JSON files. > > See https://github.com/openscad/openscad/pull/3891 > > Example with JSON file: > > { > "number": 2, > "float": 3.5e-10, > "bool": true, > "string": "hallo world!", > "array_number": [ 0, 1, 2, 3, 5 ], > "array-string": [ "one", "two", "three" ], > "array-mixed": [ "one", 1, false ], > "object": { > "name": "The object name", > "nested": { > "value": 42 > }, > "number": 4 > } > } > > Usage: > > j = import("scad-data.json"); > > echo(j.string); // ECHO: "hallo world!" > echo(j.array_number); // ECHO: [0, 1, 2, 3, 5] > echo(j["array-string"]); // ECHO: ["one", "two", "three"] > echo(j.object.name); // ECHO: "The object name" > echo(j.object.nested.value); // ECHO: 42 > > ciao, > Torsten. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
RW
Ray West
Sat, Oct 23, 2021 11:59 PM

On 23/10/2021 22:45, Leonard Martin Struttmann wrote:

  1. Part files are never accessed with include<>.  They are accessed
    with use<>.  This avoids polluting my namespace.

I don't think you can put a 'use' inside a module, but you can use an
'include'.  It may be a bug.

e.g. Module fred(){

include<alibfile.scad>;

}

is ok, but

module fred(){

use<alibfile.scad>;

}

is not

Putting libraries of parts inside modules in the layout main file, say,
prevents anything in the part files polluting the layout file space, or
other part files,  but allows part values to be set, either globally, or
individually.

On 23/10/2021 22:45, Leonard Martin Struttmann wrote: > 2. Part files are never accessed with include<>.  They are accessed > with use<>.  This avoids polluting my namespace. I don't think you can put a 'use' inside a module, but you can use an 'include'.  It may be a bug. e.g. Module fred(){ include<alibfile.scad>; } is ok, but module fred(){ use<alibfile.scad>; } is not Putting libraries of parts inside modules in the layout main file, say, prevents anything in the part files polluting the layout file space, or other part files,  but allows part values to be set, either globally, or individually.
GH
Gene Heskett
Sun, Oct 24, 2021 12:18 AM

On Saturday 23 October 2021 19:59:43 Ray West wrote:

On 23/10/2021 22:45, Leonard Martin Struttmann wrote:

  1. Part files are never accessed with include<>.  They are accessed
    with use<>.  This avoids polluting my namespace.

I don't think you can put a 'use' inside a module, but you can use an
'include'.  It may be a bug.

e.g. Module fred(){

include<alibfile.scad>;

}

is ok, but

module fred(){

use<alibfile.scad>;

}

is not

Putting libraries of parts inside modules in the layout main file,
say, prevents anything in the part files polluting the layout file
space, or other part files,  but allows part values to be set, either
globally, or individually.

Let me see if I have the correct concept of the difference here.

The first example above does not execute it until you include it in s
statement such as
"translate([,0,0,0]) "modulename in alibfile(args)"

but if its a "use<alibfile.scad" you are telling it to execute it but
there's no syntax to pass the "args" so it fails. right, wrong, or so
far out its not even wrong as W. Pauli once wrote?

Cheers, Gene Heskett.

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.

On Saturday 23 October 2021 19:59:43 Ray West wrote: > On 23/10/2021 22:45, Leonard Martin Struttmann wrote: > > 2. Part files are never accessed with include<>.  They are accessed > > with use<>.  This avoids polluting my namespace. > > I don't think you can put a 'use' inside a module, but you can use an > 'include'.  It may be a bug. > > e.g. Module fred(){ > > include<alibfile.scad>; > > } > > is ok, but > > module fred(){ > > use<alibfile.scad>; > > } > > is not > > Putting libraries of parts inside modules in the layout main file, > say, prevents anything in the part files polluting the layout file > space, or other part files,  but allows part values to be set, either > globally, or individually. > Let me see if I have the correct concept of the difference here. The first example above does not execute it until you include it in s statement such as "translate([,0,0,0]) "modulename in alibfile(args)" but if its a "use<alibfile.scad" you are telling it to execute it but there's no syntax to pass the "args" so it fails. right, wrong, or so far out its not even wrong as W. Pauli once wrote? Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page <http://geneslinuxbox.net:6309/gene>
LM
Leonard Martin Struttmann
Sun, Oct 24, 2021 12:38 AM

Ray,  here's a simple working example:

File: stepper_motor_bracket.scad

height = 10;
width = 100;
length = 100;

constants =
[
["height",  height ],
["width",  width  ],
["length",  length ],
];

function stepper_motor_bracket( name ) =
let ( row = search( [name], constants )[0] )
row!=[]? constants[row][1] : 0;

module stepper_motor_bracket()
{
cube( [ length, width, height ] );
}

File: Assembly.scad

use <stepper_motor_bracket.scad>;

stepper_height = stepper_motor_bracket( "height" );
echo( "stepper_height", stepper_height );

stepper_motor_bracket();

On Sat, Oct 23, 2021 at 7:19 PM Gene Heskett gheskett@shentel.net wrote:

On Saturday 23 October 2021 19:59:43 Ray West wrote:

On 23/10/2021 22:45, Leonard Martin Struttmann wrote:

  1. Part files are never accessed with include<>.  They are accessed
    with use<>.  This avoids polluting my namespace.

I don't think you can put a 'use' inside a module, but you can use an
'include'.  It may be a bug.

e.g. Module fred(){

include<alibfile.scad>;

}

is ok, but

module fred(){

use<alibfile.scad>;

}

is not

Putting libraries of parts inside modules in the layout main file,
say, prevents anything in the part files polluting the layout file
space, or other part files,  but allows part values to be set, either
globally, or individually.

Let me see if I have the correct concept of the difference here.

The first example above does not execute it until you include it in s
statement such as
"translate([,0,0,0]) "modulename in alibfile(args)"

but if its a "use<alibfile.scad" you are telling it to execute it but
there's no syntax to pass the "args" so it fails. right, wrong, or so
far out its not even wrong as W. Pauli once wrote?

Cheers, Gene Heskett.

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Ray, here's a simple working example: File: stepper_motor_bracket.scad ------------------------------------------------- height = 10; width = 100; length = 100; constants = [ ["height", height ], ["width", width ], ["length", length ], ]; function stepper_motor_bracket( name ) = let ( row = search( [name], constants )[0] ) row!=[]? constants[row][1] : 0; module stepper_motor_bracket() { cube( [ length, width, height ] ); } ------------------------------------------------- File: Assembly.scad ------------------------------------------------- use <stepper_motor_bracket.scad>; stepper_height = stepper_motor_bracket( "height" ); echo( "stepper_height", stepper_height ); stepper_motor_bracket(); ------------------------------------------------- On Sat, Oct 23, 2021 at 7:19 PM Gene Heskett <gheskett@shentel.net> wrote: > On Saturday 23 October 2021 19:59:43 Ray West wrote: > > > On 23/10/2021 22:45, Leonard Martin Struttmann wrote: > > > 2. Part files are never accessed with include<>. They are accessed > > > with use<>. This avoids polluting my namespace. > > > > I don't think you can put a 'use' inside a module, but you can use an > > 'include'. It may be a bug. > > > > e.g. Module fred(){ > > > > include<alibfile.scad>; > > > > } > > > > is ok, but > > > > module fred(){ > > > > use<alibfile.scad>; > > > > } > > > > is not > > > > Putting libraries of parts inside modules in the layout main file, > > say, prevents anything in the part files polluting the layout file > > space, or other part files, but allows part values to be set, either > > globally, or individually. > > > Let me see if I have the correct concept of the difference here. > > The first example above does not execute it until you include it in s > statement such as > "translate([,0,0,0]) "modulename in alibfile(args)" > > but if its a "use<alibfile.scad" you are telling it to execute it but > there's no syntax to pass the "args" so it fails. right, wrong, or so > far out its not even wrong as W. Pauli once wrote? > > Cheers, Gene Heskett. > -- > "There are four boxes to be used in defense of liberty: > soap, ballot, jury, and ammo. Please use in that order." > -Ed Howdershelt (Author, 1940) > If we desire respect for the law, we must first make the law respectable. > - Louis D. Brandeis > Genes Web page <http://geneslinuxbox.net:6309/gene> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jordan Brown
Sun, Oct 24, 2021 2:15 PM

On 10/23/2021 5:18 PM, Gene Heskett wrote:

On Saturday 23 October 2021 19:59:43 Ray West wrote:

I don't think you can put a 'use' inside a module, but you can use an
'include'.  It may be a bug.

e.g. Module fred(){

include<alibfile.scad>;

}

is ok, but

module fred(){

use<alibfile.scad>;

}

is not

Let me see if I have the correct concept of the difference here.

The first example above does not execute it until you include it in s
statement such as
"translate([,0,0,0]) "modulename in alibfile(args)"

but if its a "use<alibfile.scad" you are telling it to execute it but
there's no syntax to pass the "args" so it fails. right, wrong, or so
far out its not even wrong as W. Pauli once wrote?

An "include" is straight textual inclusion.  When it encounters the
"include" line, it reads in the file as if the two files were merged
together, without regard to the structure of the program.  Not that it
would be useful, but it appears that you can put the include at any
point, even (say) in the middle of an expression.

That is, you could have

// foo.scad
x = 2 +
include <bar.scad>

and

// bar.scad
2;

echo(x);

and it would work and print 4.

"use", on the other hand, is part of the structure of the program.  It
loads module and function definitions from the file, but does not
execute any module invocations.  Top-level assignments are executed at
the time of each call into the file.  (It is controversial whether this
is a bug or a feature and I don't want to get into that discussion here,
but it means that if the "used" file has many assignments or they do
complex work it can be a serious performance drag.)  Module and function
definitions are visible to the calling file, but top-level variable
assignments are not; this can help with namespace management.

A "use" in the middle of a module might in theory be meaningful, but is
not allowed.

On 10/23/2021 5:18 PM, Gene Heskett wrote: > On Saturday 23 October 2021 19:59:43 Ray West wrote: >> I don't think you can put a 'use' inside a module, but you can use an >> 'include'.  It may be a bug. >> >> e.g. Module fred(){ >> >> include<alibfile.scad>; >> >> } >> >> is ok, but >> >> module fred(){ >> >> use<alibfile.scad>; >> >> } >> >> is not > Let me see if I have the correct concept of the difference here. > > The first example above does not execute it until you include it in s > statement such as > "translate([,0,0,0]) "modulename in alibfile(args)" > > but if its a "use<alibfile.scad" you are telling it to execute it but > there's no syntax to pass the "args" so it fails. right, wrong, or so > far out its not even wrong as W. Pauli once wrote? > An "include" is straight textual inclusion.  When it encounters the "include" line, it reads in the file as if the two files were merged together, without regard to the structure of the program.  Not that it would be useful, but it appears that you can put the include at any point, even (say) in the middle of an expression. That is, you could have // foo.scad x = 2 + include <bar.scad> and // bar.scad 2; echo(x); and it would work and print 4. "use", on the other hand, is part of the structure of the program.  It loads module and function definitions from the file, but does not execute any module invocations.  Top-level assignments are executed at the time of each call into the file.  (It is controversial whether this is a bug or a feature and I don't want to get into that discussion here, but it means that if the "used" file has many assignments or they do complex work it can be a serious performance drag.)  Module and function definitions are visible to the calling file, but top-level variable assignments are not; this can help with namespace management. A "use" in the middle of a module might in theory be meaningful, but is not allowed.
GH
Gene Heskett
Sun, Oct 24, 2021 2:28 PM

On Sunday 24 October 2021 10:15:47 Jordan Brown wrote:

On 10/23/2021 5:18 PM, Gene Heskett wrote:

On Saturday 23 October 2021 19:59:43 Ray West wrote:

I don't think you can put a 'use' inside a module, but you can use
an 'include'.  It may be a bug.

e.g. Module fred(){

include<alibfile.scad>;

}

is ok, but

module fred(){

use<alibfile.scad>;

}

is not

Let me see if I have the correct concept of the difference here.

The first example above does not execute it until you include it in
s statement such as
"translate([,0,0,0]) "modulename in alibfile(args)"

but if its a "use<alibfile.scad" you are telling it to execute it
but there's no syntax to pass the "args" so it fails. right, wrong,
or so far out its not even wrong as W. Pauli once wrote?

An "include" is straight textual inclusion.  When it encounters the
"include" line, it reads in the file as if the two files were merged
together, without regard to the structure of the program.  Not that it
would be useful, but it appears that you can put the include at any
point, even (say) in the middle of an expression.

That is, you could have

 // foo.scad
 x = 2 +
 include <bar.scad>

and

 // bar.scad
 2;

 echo(x);

and it would work and print 4.

"use", on the other hand, is part of the structure of the program.  It
loads module and function definitions from the file, but does not
execute any module invocations.  Top-level assignments are executed at
the time of each call into the file.  (It is controversial whether
this is a bug or a feature and I don't want to get into that
discussion here, but it means that if the "used" file has many
assignments or they do complex work it can be a serious performance
drag.)  Module and function definitions are visible to the calling
file, but top-level variable assignments are not; this can help with
namespace management.

A "use" in the middle of a module might in theory be meaningful, but
is not allowed.

No need to Cc: me, I am subscribed, and many thanks for the
clarification,  Jordan.

Take care and stay well.

Cheers, Gene Heskett.

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.

On Sunday 24 October 2021 10:15:47 Jordan Brown wrote: > On 10/23/2021 5:18 PM, Gene Heskett wrote: > > On Saturday 23 October 2021 19:59:43 Ray West wrote: > >> I don't think you can put a 'use' inside a module, but you can use > >> an 'include'.  It may be a bug. > >> > >> e.g. Module fred(){ > >> > >> include<alibfile.scad>; > >> > >> } > >> > >> is ok, but > >> > >> module fred(){ > >> > >> use<alibfile.scad>; > >> > >> } > >> > >> is not > > > > Let me see if I have the correct concept of the difference here. > > > > The first example above does not execute it until you include it in > > s statement such as > > "translate([,0,0,0]) "modulename in alibfile(args)" > > > > but if its a "use<alibfile.scad" you are telling it to execute it > > but there's no syntax to pass the "args" so it fails. right, wrong, > > or so far out its not even wrong as W. Pauli once wrote? > > An "include" is straight textual inclusion.  When it encounters the > "include" line, it reads in the file as if the two files were merged > together, without regard to the structure of the program.  Not that it > would be useful, but it appears that you can put the include at any > point, even (say) in the middle of an expression. > > That is, you could have > > // foo.scad > x = 2 + > include <bar.scad> > > and > > // bar.scad > 2; > > echo(x); > > and it would work and print 4. > > > "use", on the other hand, is part of the structure of the program.  It > loads module and function definitions from the file, but does not > execute any module invocations.  Top-level assignments are executed at > the time of each call into the file.  (It is controversial whether > this is a bug or a feature and I don't want to get into that > discussion here, but it means that if the "used" file has many > assignments or they do complex work it can be a serious performance > drag.)  Module and function definitions are visible to the calling > file, but top-level variable assignments are not; this can help with > namespace management. > > A "use" in the middle of a module might in theory be meaningful, but > is not allowed. No need to Cc: me, I am subscribed, and many thanks for the clarification, Jordan. Take care and stay well. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page <http://geneslinuxbox.net:6309/gene>
PC
Patrick Callahan
Sun, Oct 24, 2021 3:34 PM

Leonard,

That's an excellent way to encapsulate basic measures, and I think a
library of different-sized parts could work the same way with two
parameters.

My beginner work just had a module with all the parts' data as scalar
variables in one file called "measurements.scad."  It was fast becoming
less comfortable as the project grew.

I am a long-time procedural programmer, so using functions as a data store
is not second nature.

-Pat

On Sat, Oct 23, 2021 at 8:38 PM Leonard Martin Struttmann <
lenstruttmann@gmail.com> wrote:

Ray,  here's a simple working example:

File: stepper_motor_bracket.scad

height = 10;
width = 100;
length = 100;

constants =
[
["height",  height ],
["width",  width  ],
["length",  length ],
];

function stepper_motor_bracket( name ) =
let ( row = search( [name], constants )[0] )
row!=[]? constants[row][1] : 0;

module stepper_motor_bracket()
{
cube( [ length, width, height ] );
}

File: Assembly.scad

use <stepper_motor_bracket.scad>;

stepper_height = stepper_motor_bracket( "height" );
echo( "stepper_height", stepper_height );

stepper_motor_bracket();

On Sat, Oct 23, 2021 at 7:19 PM Gene Heskett gheskett@shentel.net wrote:

On Saturday 23 October 2021 19:59:43 Ray West wrote:

On 23/10/2021 22:45, Leonard Martin Struttmann wrote:

  1. Part files are never accessed with include<>.  They are accessed
    with use<>.  This avoids polluting my namespace.

I don't think you can put a 'use' inside a module, but you can use an
'include'.  It may be a bug.

e.g. Module fred(){

include<alibfile.scad>;

}

is ok, but

module fred(){

use<alibfile.scad>;

}

is not

Putting libraries of parts inside modules in the layout main file,
say, prevents anything in the part files polluting the layout file
space, or other part files,  but allows part values to be set, either
globally, or individually.

Let me see if I have the correct concept of the difference here.

The first example above does not execute it until you include it in s
statement such as
"translate([,0,0,0]) "modulename in alibfile(args)"

but if its a "use<alibfile.scad" you are telling it to execute it but
there's no syntax to pass the "args" so it fails. right, wrong, or so
far out its not even wrong as W. Pauli once wrote?

Cheers, Gene Heskett.

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Leonard, That's an excellent way to encapsulate basic measures, and I think a library of different-sized parts could work the same way with two parameters. My beginner work just had a module with all the parts' data as scalar variables in one file called "measurements.scad." It was fast becoming less comfortable as the project grew. I am a long-time procedural programmer, so using functions as a data store is not second nature. -Pat On Sat, Oct 23, 2021 at 8:38 PM Leonard Martin Struttmann < lenstruttmann@gmail.com> wrote: > Ray, here's a simple working example: > > File: stepper_motor_bracket.scad > ------------------------------------------------- > height = 10; > width = 100; > length = 100; > > constants = > [ > ["height", height ], > ["width", width ], > ["length", length ], > ]; > > function stepper_motor_bracket( name ) = > let ( row = search( [name], constants )[0] ) > row!=[]? constants[row][1] : 0; > > module stepper_motor_bracket() > { > cube( [ length, width, height ] ); > } > ------------------------------------------------- > > > > > File: Assembly.scad > ------------------------------------------------- > use <stepper_motor_bracket.scad>; > > stepper_height = stepper_motor_bracket( "height" ); > echo( "stepper_height", stepper_height ); > > stepper_motor_bracket(); > ------------------------------------------------- > > > On Sat, Oct 23, 2021 at 7:19 PM Gene Heskett <gheskett@shentel.net> wrote: > >> On Saturday 23 October 2021 19:59:43 Ray West wrote: >> >> > On 23/10/2021 22:45, Leonard Martin Struttmann wrote: >> > > 2. Part files are never accessed with include<>. They are accessed >> > > with use<>. This avoids polluting my namespace. >> > >> > I don't think you can put a 'use' inside a module, but you can use an >> > 'include'. It may be a bug. >> > >> > e.g. Module fred(){ >> > >> > include<alibfile.scad>; >> > >> > } >> > >> > is ok, but >> > >> > module fred(){ >> > >> > use<alibfile.scad>; >> > >> > } >> > >> > is not >> > >> > Putting libraries of parts inside modules in the layout main file, >> > say, prevents anything in the part files polluting the layout file >> > space, or other part files, but allows part values to be set, either >> > globally, or individually. >> > >> Let me see if I have the correct concept of the difference here. >> >> The first example above does not execute it until you include it in s >> statement such as >> "translate([,0,0,0]) "modulename in alibfile(args)" >> >> but if its a "use<alibfile.scad" you are telling it to execute it but >> there's no syntax to pass the "args" so it fails. right, wrong, or so >> far out its not even wrong as W. Pauli once wrote? >> >> Cheers, Gene Heskett. >> -- >> "There are four boxes to be used in defense of liberty: >> soap, ballot, jury, and ammo. Please use in that order." >> -Ed Howdershelt (Author, 1940) >> If we desire respect for the law, we must first make the law respectable. >> - Louis D. Brandeis >> Genes Web page <http://geneslinuxbox.net:6309/gene> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
RW
Ray West
Sun, Oct 24, 2021 8:47 PM

On 24/10/2021 15:15, Jordan Brown wrote:

On 10/23/2021 5:18 PM, Gene Heskett wrote:

On Saturday 23 October 2021 19:59:43 Ray West wrote:

I don't think you can put a 'use' inside a module, but you can use an
'include'.  It may be a bug.

e.g. Module fred(){

include<alibfile.scad>;

}

is ok, but

module fred(){

use<alibfile.scad>;

}

is not

Let me see if I have the correct concept of the difference here.

The first example above does not execute it until you include it in s
statement such as
"translate([,0,0,0]) "modulename in alibfile(args)"

but if its a "use<alibfile.scad" you are telling it to execute it but
there's no syntax to pass the "args" so it fails. right, wrong, or so
far out its not even wrong as W. Pauli once wrote?

An "include" is straight textual inclusion.  When it encounters the
"include" line, it reads in the file as if the two files were merged
together, without regard to the structure of the program. Not that it
would be useful, but it appears that you can put the include at any
point, even (say) in the middle of an expression.

That is, you could have

 // foo.scad
 x = 2 +
 include <bar.scad>

and

 // bar.scad
 2;

 echo(x);

and it would work and print 4.

"use", on the other hand, is part of the structure of the program.  It
loads module and function definitions from the file, but does not
execute any module invocations.  Top-level assignments are executed at
the time of each call into the file. (It is controversial whether this
is a bug or a feature and I don't want to get into that discussion
here, but it means that if the "used" file has many assignments or
they do complex work it can be a serious performance drag.)  Module
and function definitions are visible to the calling file, but
top-level variable assignments are not; this can help with namespace
management.

A "use" in the middle of a module might in theory be meaningful, but
is not allowed.

Hi Jordan, thanks for the explanation, it is a bug then 😉  . For me,
tthe differance between use and include, its that if using an include
I have to comment out 'test code' in the file that I am including.  No
big deal.

Best wishes,

Ray

On 24/10/2021 15:15, Jordan Brown wrote: > On 10/23/2021 5:18 PM, Gene Heskett wrote: >> On Saturday 23 October 2021 19:59:43 Ray West wrote: >>> I don't think you can put a 'use' inside a module, but you can use an >>> 'include'.  It may be a bug. >>> >>> e.g. Module fred(){ >>> >>> include<alibfile.scad>; >>> >>> } >>> >>> is ok, but >>> >>> module fred(){ >>> >>> use<alibfile.scad>; >>> >>> } >>> >>> is not >> Let me see if I have the correct concept of the difference here. >> >> The first example above does not execute it until you include it in s >> statement such as >> "translate([,0,0,0]) "modulename in alibfile(args)" >> >> but if its a "use<alibfile.scad" you are telling it to execute it but >> there's no syntax to pass the "args" so it fails. right, wrong, or so >> far out its not even wrong as W. Pauli once wrote? >> > > An "include" is straight textual inclusion.  When it encounters the > "include" line, it reads in the file as if the two files were merged > together, without regard to the structure of the program. Not that it > would be useful, but it appears that you can put the include at any > point, even (say) in the middle of an expression. > > That is, you could have > > // foo.scad > x = 2 + > include <bar.scad> > > and > > // bar.scad > 2; > > echo(x); > > and it would work and print 4. > > > "use", on the other hand, is part of the structure of the program.  It > loads module and function definitions from the file, but does not > execute any module invocations.  Top-level assignments are executed at > the time of each call into the file. (It is controversial whether this > is a bug or a feature and I don't want to get into that discussion > here, but it means that if the "used" file has many assignments or > they do complex work it can be a serious performance drag.)  Module > and function definitions are visible to the calling file, but > top-level variable assignments are not; this can help with namespace > management. > > A "use" in the middle of a module might in theory be meaningful, but > is not allowed. > > > Hi Jordan, thanks for the explanation, it is a bug then 😉  . For me, > tthe differance between use and include, its that if using an include > I have to comment out 'test code' in the file that I am including.  No > big deal. Best wishes, Ray