discuss@lists.openscad.org

OpenSCAD general discussion

View all threads

start a module from a variabel

MH
Matthieu Hendriks
Sat, Oct 16, 2021 8:31 AM

I've included some files I use for standard use:

  1. skelet.scad is used as a template for creating new openscad projects.

It's start with some comments, a section for including standard
libraries, and constants. Important is here to have run="all";  // you
can change this later on for any other module name you want to use

than a section for all modules.

a module starting with "print_" is used for automatic creating an stl
file and png files for documentation

the module all() is used for generating a series off png files with
combined give an mp4 movie. (using of module all() is mandatory.)

  1. scad4include. Is a bash script wich automatically generates an
    standard include section in your code :

/* runstart */

if (part == "bottom") bottom();
 if (part == "top") top();

/* runeind */

The used module names from your main scad file are used for this.

  1. scad2gif, is a bash script which scans your project.scad file,
    generates stl and png files for all modules starting with print_ and a
    series of png from all() for the mp4 file.

Temporary png files are cleanud up afterwards.

The bash scripts are for linux user.

You need ffmpeg installed for the mp4 file.

If you want a animated gif uncomment gifski and have this program
installed.

STL files and PNG files are created parallel for speed , the number of
parallel processes is defined in maxproc.

the scripts are straight forward.

How to use:

  1. Create you scad project based on skelet.scad

  2. create you code, use modules as much as possible

  3. run the scad4include with your newly project (from the commandpromt)

  4. test individual module by run="module1"  and so on.

  5. run the scad2gif over your project.

Have fun.

Groet Matthieu


Jan Wieck schreef op 2021-10-15 19:54:

On 10/15/21 12:24 PM, Patrick Callahan wrote:

I'm interested in a technique to create multiple output files
automatically. Let's discuss the approach and any code you have that
does this.

It works pretty straight forward using the CLI in a batch/shell script
or with a Makefile. The Makefile approach offers to only render those
output files that would change based on the modified source (.scad,
.json and other) files.

This requires to organize the work a bit and have the customizable and
global variables in a main source and an include file for each module
that defines a part of the overall project. There can be additional
files shared by parts.

As an example I will use a configurable toolbox I am working on. The
boxes would hold things like socket wrench sets or impact driver bits.
A box type becomes a named configurator parameter set. The parameter
set controls the dimensions of the box, number of hinges and the
artwork on top. A drop down string variable controls which part is to
be rendered and the toplevel .scad file makes that happen with code
like

if (part == "bottom") ToolBoxBottom();
if (part == "top") ToolBoxTop();

The Makefile defines the dependencies and the commands to run. So if I
only modify the source code for ToolBoxBottom, it will only create a
new bottom.stl file. If I modify the toplevel ToolBox.scad file, it
will recreate all stl files. The command for (re)creating the needed
stl files for my DEMO box (attached) is

DESIGN=DEMO make

I would need to do some code cleanup before sharing the source code.


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

I've included some files I use for standard use: 1. skelet.scad is used as a template for creating new openscad projects. It's start with some comments, a section for including standard libraries, and constants. Important is here to have run="all"; // you can change this later on for any other module name you want to use than a section for all modules. a module starting with "print_" is used for automatic creating an stl file and png files for documentation the module all() is used for generating a series off png files with combined give an mp4 movie. (using of module all() is mandatory.) 2. scad4include. Is a bash script wich automatically generates an standard include section in your code : /* runstart */ if (part == "bottom") bottom(); if (part == "top") top(); /* runeind */ The used module names from your main scad file are used for this. 3. scad2gif, is a bash script which scans your project.scad file, generates stl and png files for all modules starting with print_ and a series of png from all() for the mp4 file. Temporary png files are cleanud up afterwards. The bash scripts are for linux user. You need ffmpeg installed for the mp4 file. If you want a animated gif uncomment gifski and have this program installed. STL files and PNG files are created parallel for speed , the number of parallel processes is defined in maxproc. the scripts are straight forward. How to use: 1. Create you scad project based on skelet.scad 2. create you code, use modules as much as possible 3. run the scad4include with your newly project (from the commandpromt) 4. test individual module by run="module1" and so on. 5. run the scad2gif over your project. Have fun. Groet Matthieu ------------------------- Jan Wieck schreef op 2021-10-15 19:54: > On 10/15/21 12:24 PM, Patrick Callahan wrote: > >> I'm interested in a technique to create multiple output files >> automatically. Let's discuss the approach and any code you have that >> does this. > > It works pretty straight forward using the CLI in a batch/shell script > or with a Makefile. The Makefile approach offers to only render those > output files that would change based on the modified source (.scad, > .json and other) files. > > This requires to organize the work a bit and have the customizable and > global variables in a main source and an include file for each module > that defines a part of the overall project. There can be additional > files shared by parts. > > As an example I will use a configurable toolbox I am working on. The > boxes would hold things like socket wrench sets or impact driver bits. > A box type becomes a named configurator parameter set. The parameter > set controls the dimensions of the box, number of hinges and the > artwork on top. A drop down string variable controls which part is to > be rendered and the toplevel .scad file makes that happen with code > like > > if (part == "bottom") ToolBoxBottom(); > if (part == "top") ToolBoxTop(); > > The Makefile defines the dependencies and the commands to run. So if I > only modify the source code for ToolBoxBottom, it will only create a > new bottom.stl file. If I modify the toplevel ToolBox.scad file, it > will recreate all stl files. The command for (re)creating the needed > stl files for my DEMO box (attached) is > > DESIGN=DEMO make > > I would need to do some code cleanup before sharing the source code. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org