discuss@lists.openscad.org

OpenSCAD general discussion

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