discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Multiple objects in a file

FH
Father Horton
Sat, Jan 29, 2022 5:39 PM

I have a project with three parts. They're all in the same file so that I
can be sure they fit properly. I defined a variable that's set to "ALL" if
all the parts are to be generated, or to the name of one part if only one
is to be generated. As far as I can tell, this is the most efficient way to
get three printable STLs.

But now I wonder ... is there a better way? This isn't awful, but I'd hate
to be missing something easy and obvious.

I have a project with three parts. They're all in the same file so that I can be sure they fit properly. I defined a variable that's set to "ALL" if all the parts are to be generated, or to the name of one part if only one is to be generated. As far as I can tell, this is the most efficient way to get three printable STLs. But now I wonder ... is there a better way? This isn't awful, but I'd hate to be missing something easy and obvious.
NH
nop head
Sat, Jan 29, 2022 5:53 PM

I use a Python framework to generate STLs, DXFs and a bill of materials and
assembly instructions. Over the top if you have one project with three
parts but I use it for all my projects and some have thousands of parts.
See https://github.com/nophead/NopSCADlib. It is aimed at projects where
all the parts are modelled, not just the printable STLs.

Any parts that make STLs are made with a module with _stl suffix to its
name. They also call an stl module announcing their name. That adds them to
the BOM and then the framework can generate all the STLs on the BOM.

On Sat, 29 Jan 2022 at 17:39, Father Horton fatherhorton@gmail.com wrote:

I have a project with three parts. They're all in the same file so that I
can be sure they fit properly. I defined a variable that's set to "ALL" if
all the parts are to be generated, or to the name of one part if only one
is to be generated. As far as I can tell, this is the most efficient way to
get three printable STLs.

But now I wonder ... is there a better way? This isn't awful, but I'd hate
to be missing something easy and obvious.


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

I use a Python framework to generate STLs, DXFs and a bill of materials and assembly instructions. Over the top if you have one project with three parts but I use it for all my projects and some have thousands of parts. See https://github.com/nophead/NopSCADlib. It is aimed at projects where all the parts are modelled, not just the printable STLs. Any parts that make STLs are made with a module with _stl suffix to its name. They also call an stl module announcing their name. That adds them to the BOM and then the framework can generate all the STLs on the BOM. On Sat, 29 Jan 2022 at 17:39, Father Horton <fatherhorton@gmail.com> wrote: > I have a project with three parts. They're all in the same file so that I > can be sure they fit properly. I defined a variable that's set to "ALL" if > all the parts are to be generated, or to the name of one part if only one > is to be generated. As far as I can tell, this is the most efficient way to > get three printable STLs. > > But now I wonder ... is there a better way? This isn't awful, but I'd hate > to be missing something easy and obvious. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
FH
Father Horton
Sat, Jan 29, 2022 6:19 PM

I will take a look. Thanks!

On Sat, Jan 29, 2022 at 11:54 AM nop head nop.head@gmail.com wrote:

I use a Python framework to generate STLs, DXFs and a bill of materials
and assembly instructions. Over the top if you have one project with three
parts but I use it for all my projects and some have thousands of parts.
See https://github.com/nophead/NopSCADlib. It is aimed at projects where
all the parts are modelled, not just the printable STLs.

Any parts that make STLs are made with a module with _stl suffix to its
name. They also call an stl module announcing their name. That adds them to
the BOM and then the framework can generate all the STLs on the BOM.

On Sat, 29 Jan 2022 at 17:39, Father Horton fatherhorton@gmail.com
wrote:

I have a project with three parts. They're all in the same file so that I
can be sure they fit properly. I defined a variable that's set to "ALL" if
all the parts are to be generated, or to the name of one part if only one
is to be generated. As far as I can tell, this is the most efficient way to
get three printable STLs.

But now I wonder ... is there a better way? This isn't awful, but I'd
hate to be missing something easy and obvious.


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 will take a look. Thanks! On Sat, Jan 29, 2022 at 11:54 AM nop head <nop.head@gmail.com> wrote: > I use a Python framework to generate STLs, DXFs and a bill of materials > and assembly instructions. Over the top if you have one project with three > parts but I use it for all my projects and some have thousands of parts. > See https://github.com/nophead/NopSCADlib. It is aimed at projects where > all the parts are modelled, not just the printable STLs. > > Any parts that make STLs are made with a module with _stl suffix to its > name. They also call an stl module announcing their name. That adds them to > the BOM and then the framework can generate all the STLs on the BOM. > > On Sat, 29 Jan 2022 at 17:39, Father Horton <fatherhorton@gmail.com> > wrote: > >> I have a project with three parts. They're all in the same file so that I >> can be sure they fit properly. I defined a variable that's set to "ALL" if >> all the parts are to be generated, or to the name of one part if only one >> is to be generated. As far as I can tell, this is the most efficient way to >> get three printable STLs. >> >> But now I wonder ... is there a better way? This isn't awful, but I'd >> hate to be missing something easy and obvious. >> _______________________________________________ >> 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 >
KT
Kevin Toppenberg
Sat, Jan 29, 2022 9:05 PM

I usually use this pattern, similar to what you are doing....

show_top_part  = 1;
show_front_part = 0;
show_base        = 1;

I then set the relevant variable for which part I want to display.

Kevin

On Sat, Jan 29, 2022 at 12:39 PM Father Horton fatherhorton@gmail.com
wrote:

I have a project with three parts. They're all in the same file so that I
can be sure they fit properly. I defined a variable that's set to "ALL" if
all the parts are to be generated, or to the name of one part if only one
is to be generated. As far as I can tell, this is the most efficient way to
get three printable STLs.

But now I wonder ... is there a better way? This isn't awful, but I'd hate
to be missing something easy and obvious.


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

I usually use this pattern, similar to what you are doing.... show_top_part = 1; show_front_part = 0; show_base = 1; I then set the relevant variable for which part I want to display. Kevin On Sat, Jan 29, 2022 at 12:39 PM Father Horton <fatherhorton@gmail.com> wrote: > I have a project with three parts. They're all in the same file so that I > can be sure they fit properly. I defined a variable that's set to "ALL" if > all the parts are to be generated, or to the name of one part if only one > is to be generated. As far as I can tell, this is the most efficient way to > get three printable STLs. > > But now I wonder ... is there a better way? This isn't awful, but I'd hate > to be missing something easy and obvious. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
J
jon
Sat, Jan 29, 2022 9:28 PM

Similarly:

TopPart();

!FrontPart();

BasePart();

Jon

On 1/29/2022 4:05 PM, Kevin Toppenberg wrote:

I usually use this pattern, similar to what you are doing....

show_top_part  = 1;
show_front_part = 0;
show_base        = 1;

I then set the relevant variable for which part I want to display.

Kevin

On Sat, Jan 29, 2022 at 12:39 PM Father Horton
fatherhorton@gmail.com wrote:

 I have a project with three parts. They're all in the same file so
 that I can be sure they fit properly. I defined a variable that's
 set to "ALL" if all the parts are to be generated, or to the name
 of one part if only one is to be generated. As far as I can tell,
 this is the most efficient way to get three printable STLs.

 But now I wonder ... is there a better way? This isn't awful, but
 I'd hate to be missing something easy and obvious.
 _______________________________________________
 OpenSCAD mailing list
 To unsubscribe send an email to discuss-leave@lists.openscad.org

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

Similarly: TopPart(); !FrontPart(); BasePart(); Jon On 1/29/2022 4:05 PM, Kevin Toppenberg wrote: > I usually use this pattern, similar to what you are doing.... > > > show_top_part  = 1; > show_front_part = 0; > show_base        = 1; > > I then set the relevant variable for which part I want to display. > > Kevin > > > On Sat, Jan 29, 2022 at 12:39 PM Father Horton > <fatherhorton@gmail.com> wrote: > > I have a project with three parts. They're all in the same file so > that I can be sure they fit properly. I defined a variable that's > set to "ALL" if all the parts are to be generated, or to the name > of one part if only one is to be generated. As far as I can tell, > this is the most efficient way to get three printable STLs. > > But now I wonder ... is there a better way? This isn't awful, but > I'd hate to be missing something easy and obvious. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
M
MichaelAtOz
Sat, Jan 29, 2022 10:24 PM

I haven't done this yet, but with customizer you could have checkboxes to click which part you want, e.g.

part1=false;

part2=false;

if (part1) cube();

if (part2) sphere();


From: jon [mailto:jon@jonbondy.com]
Sent: Sun, 30 Jan 2022 08:29
To: OpenSCAD general discussion; Kevin Toppenberg
Subject: [OpenSCAD] Re: Multiple objects in a file

Similarly:

TopPart();

!FrontPart();

BasePart();

Jon

On 1/29/2022 4:05 PM, Kevin Toppenberg wrote:

I usually use this pattern, similar to what you are doing....

show_top_part  = 1;

show_front_part = 0;

show_base        = 1;

I then set the relevant variable for which part I want to display.

Kevin

On Sat, Jan 29, 2022 at 12:39 PM Father Horton fatherhorton@gmail.com wrote:

I have a project with three parts. They're all in the same file so that I can be sure they fit properly. I defined a variable that's set to "ALL" if all the parts are to be generated, or to the name of one part if only one is to be generated. As far as I can tell, this is the most efficient way to get three printable STLs.

But now I wonder ... is there a better way? This isn't awful, but I'd hate to be missing something easy and obvious.


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

--
This email has been checked for viruses by AVG.
https://www.avg.com

I haven't done this yet, but with customizer you could have checkboxes to click which part you want, e.g. part1=false; part2=false; if (part1) cube(); if (part2) sphere(); _____ From: jon [mailto:jon@jonbondy.com] Sent: Sun, 30 Jan 2022 08:29 To: OpenSCAD general discussion; Kevin Toppenberg Subject: [OpenSCAD] Re: Multiple objects in a file Similarly: TopPart(); !FrontPart(); BasePart(); Jon On 1/29/2022 4:05 PM, Kevin Toppenberg wrote: I usually use this pattern, similar to what you are doing.... show_top_part = 1; show_front_part = 0; show_base = 1; I then set the relevant variable for which part I want to display. Kevin On Sat, Jan 29, 2022 at 12:39 PM Father Horton <fatherhorton@gmail.com> wrote: I have a project with three parts. They're all in the same file so that I can be sure they fit properly. I defined a variable that's set to "ALL" if all the parts are to be generated, or to the name of one part if only one is to be generated. As far as I can tell, this is the most efficient way to get three printable STLs. But now I wonder ... is there a better way? This isn't awful, but I'd hate to be missing something easy and obvious. _______________________________________________ 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 -- This email has been checked for viruses by AVG. https://www.avg.com
DS
David Schooley
Sat, Jan 29, 2022 10:24 PM

By default, my parts are all in modules named draw_something, as in:

module draw_something(…) {..}

module draw_sub_part_of_something(…) {…}

At the end of the script, there is a call to draw_something(), with whatever parameters I want.

Depending on what I am doing, there might be small scripts that import the original script and do nothing more than call draw_something() or one of the draw_sub_part_of_something() modules with the correct parameters. This makes it easy to get the stl, 3mf, or svg files that I want.

This also works for assemblies. I only put one part for file, so a file for an assembly includes the individual part files and calls the correct draw_something modules while translating and/or rotating them to put everything together.

On Jan 29, 2022, at 11:39 AM, Father Horton fatherhorton@gmail.com wrote:

I have a project with three parts. They're all in the same file so that I can be sure they fit properly. I defined a variable that's set to "ALL" if all the parts are to be generated, or to the name of one part if only one is to be generated. As far as I can tell, this is the most efficient way to get three printable STLs.

But now I wonder ... is there a better way? This isn't awful, but I'd hate to be missing something easy and obvious.


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

By default, my parts are all in modules named draw_something, as in: module draw_something(…) {..} module draw_sub_part_of_something(…) {…} At the end of the script, there is a call to draw_something(), with whatever parameters I want. Depending on what I am doing, there might be small scripts that import the original script and do nothing more than call draw_something() or one of the draw_sub_part_of_something() modules with the correct parameters. This makes it easy to get the stl, 3mf, or svg files that I want. This also works for assemblies. I only put one part for file, so a file for an assembly includes the individual part files and calls the correct draw_something modules while translating and/or rotating them to put everything together. > On Jan 29, 2022, at 11:39 AM, Father Horton <fatherhorton@gmail.com> wrote: > > I have a project with three parts. They're all in the same file so that I can be sure they fit properly. I defined a variable that's set to "ALL" if all the parts are to be generated, or to the name of one part if only one is to be generated. As far as I can tell, this is the most efficient way to get three printable STLs. > > But now I wonder ... is there a better way? This isn't awful, but I'd hate to be missing something easy and obvious. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
LM
Leonard Martin Struttmann
Sat, Jan 29, 2022 10:29 PM

I set up a list of parts that I want to see:

parts = ["all"];

...or...

parts = ["base", "supports", "stepper"];

... and then put my calls to the appropriate modules within if clauses:

if (len(strSearch( [ "base", "all"], parts)) > 0)

{

base();

}

function strSearch( str, list ) =
let ( searchStrings = is_string(str)? [str]:str )
[ for (i=[0:len(list)-1], j=[0:len(searchStrings)-1])
if (searchStrings[j]==list[i]) i
];

On Sat, Jan 29, 2022 at 4:25 PM David Schooley dcschooley@gmail.com wrote:

By default, my parts are all in modules named draw_something, as in:

module draw_something(…) {..}

module draw_sub_part_of_something(…) {…}

At the end of the script, there is a call to draw_something(), with
whatever parameters I want.

Depending on what I am doing, there might be small scripts that import the
original script and do nothing more than call draw_something() or one of
the draw_sub_part_of_something() modules with the correct parameters. This
makes it easy to get the stl, 3mf, or svg files that I want.

This also works for assemblies. I only put one part for file, so a file
for an assembly includes the individual part files and calls the correct
draw_something modules while translating and/or rotating them to put
everything together.

On Jan 29, 2022, at 11:39 AM, Father Horton fatherhorton@gmail.com
wrote:

I have a project with three parts. They're all in the same file so that I
can be sure they fit properly. I defined a variable that's set to "ALL" if
all the parts are to be generated, or to the name of one part if only one
is to be generated. As far as I can tell, this is the most efficient way to
get three printable STLs.

But now I wonder ... is there a better way? This isn't awful, but I'd hate
to be missing something easy and obvious.


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 set up a list of parts that I want to see: parts = ["all"]; ...or... parts = ["base", "supports", "stepper"]; ... and then put my calls to the appropriate modules within if clauses: if (len(strSearch( [ "base", "all"], parts)) > 0) { base(); } function strSearch( str, list ) = let ( searchStrings = is_string(str)? [str]:str ) [ for (i=[0:len(list)-1], j=[0:len(searchStrings)-1]) if (searchStrings[j]==list[i]) i ]; On Sat, Jan 29, 2022 at 4:25 PM David Schooley <dcschooley@gmail.com> wrote: > By default, my parts are all in modules named draw_something, as in: > > module draw_something(…) {..} > > module draw_sub_part_of_something(…) {…} > > At the end of the script, there is a call to draw_something(), with > whatever parameters I want. > > Depending on what I am doing, there might be small scripts that import the > original script and do nothing more than call draw_something() or one of > the draw_sub_part_of_something() modules with the correct parameters. This > makes it easy to get the stl, 3mf, or svg files that I want. > > This also works for assemblies. I only put one part for file, so a file > for an assembly includes the individual part files and calls the correct > draw_something modules while translating and/or rotating them to put > everything together. > > > On Jan 29, 2022, at 11:39 AM, Father Horton <fatherhorton@gmail.com> > wrote: > > I have a project with three parts. They're all in the same file so that I > can be sure they fit properly. I defined a variable that's set to "ALL" if > all the parts are to be generated, or to the name of one part if only one > is to be generated. As far as I can tell, this is the most efficient way to > get three printable STLs. > > But now I wonder ... is there a better way? This isn't awful, but I'd hate > to be missing something easy and obvious. > _______________________________________________ > 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 >
JB
Jordan Brown
Sun, Jan 30, 2022 4:27 PM

I have a mechanism that is more formal than many, though not as formal
as nophead's.

The top of a file will look something like so:

$content_selected = "all";  // [ all, chair1, chair2,
silverwarechest, table, table_frame, table_center, table_top,
table_leaves ]

contents() {
    item("chair1") drchair();
    item("chair2") drchair2();
    item("silverwarechest", distance=120) silverwarechest();
    item("table") drtable();
    item("table_frame", png=false) drtable($part="frame");
    item("table_center", png=false) drtable($part="center");
    item("table_top", png=false) drtable($part="top");
    item("table_leaves", png=false) drtable_leaves();
}

This gets used in two ways:

  • From the Customizer, I can pick which component I want.  "all" lays
    them all out on a grid.
  • From an external shell script (run under Cygwin on Windows), I can
    list all of the components in the file and generate STLs and PNGs
    for each of them, as modified by the options.  "png=false" means
    that a PNG doesn't get generated for that item.  Similarly
    "stl=false".  There's a couple of camera-control options for the PNG
    generation.  Thus the block above generates eight STLs and four
    PNGs.  (The STL of the table isn't actually useful, except for 3D
    visualization.)

At another layer, $part controls which part of an object gets generated.

I've enclosed the OpenSCAD components and the shell script.

I have a mechanism that is more formal than many, though not as formal as nophead's. The top of a file will look something like so: $content_selected = "all";  // [ all, chair1, chair2, silverwarechest, table, table_frame, table_center, table_top, table_leaves ] contents() {     item("chair1") drchair();     item("chair2") drchair2();     item("silverwarechest", distance=120) silverwarechest();     item("table") drtable();     item("table_frame", png=false) drtable($part="frame");     item("table_center", png=false) drtable($part="center");     item("table_top", png=false) drtable($part="top");     item("table_leaves", png=false) drtable_leaves(); } This gets used in two ways: * From the Customizer, I can pick which component I want.  "all" lays them all out on a grid. * From an external shell script (run under Cygwin on Windows), I can list all of the components in the file and generate STLs and PNGs for each of them, as modified by the options.  "png=false" means that a PNG doesn't get generated for that item.  Similarly "stl=false".  There's a couple of camera-control options for the PNG generation.  Thus the block above generates eight STLs and four PNGs.  (The STL of the table isn't actually useful, except for 3D visualization.) At another layer, $part controls which part of an object gets generated. I've enclosed the OpenSCAD components and the shell script.
JB
Jordan Brown
Sun, Jan 30, 2022 4:29 PM

I keep thinking about multi-color / multi-material support.  It seems
like such support will want to operate in a couple of modes, either
exporting to a multi-object format like 3MF or exporting multiple STLs
in one shot.  Now if only I had the free time...

I keep thinking about multi-color / multi-material support.  It seems like such support will want to operate in a couple of modes, either exporting to a multi-object format like 3MF or exporting multiple STLs in one shot.  Now if only I had the free time...