discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Auto-generate the STL.

JB
Jordan Brown
Thu, May 2, 2024 4:45 PM

On 5/2/2024 1:59 AM, Rogier Wolff via Discuss wrote:

But first I want to use manifold for the STL generation. It is not
good if I interactively look at one "interpretation" of the source and
then use a different "toolset" to actually process it further.

You want "--enable manifold".  E.g.:

$ openscad --enable manifold -o x.stl x.scad
On 5/2/2024 1:59 AM, Rogier Wolff via Discuss wrote: > But first I want to use manifold for the STL generation. It is not > good if I interactively look at one "interpretation" of the source and > then use a different "toolset" to actually process it further. You want "--enable manifold".  E.g.: $ openscad --enable manifold -o x.stl x.scad
RW
Rogier Wolff
Fri, May 3, 2024 1:04 PM

On Thu, May 02, 2024 at 04:45:26PM +0000, Jordan Brown via Discuss wrote:

On 5/2/2024 1:59 AM, Rogier Wolff via Discuss wrote:

But first I want to use manifold for the STL generation. It is not
good if I interactively look at one "interpretation" of the source and
then use a different "toolset" to actually process it further.

You want "--enable manifold".  E.g.:

 $ openscad --enable manifold -o x.stl x.scad

Thanks that's it!

Below is my mkstl script:


#!/bin/sh

mkstl (C) by REW (R.E.Wolff@BitWizard.nl)

scad=$1

outbn=basename $scad .scad

nrs=grep '// *output' $scad | awk '{print $3}'
for p in $nrs; do
ext=grep '// *output *'$p' ' $scad | awk '{print $4}'
openscad  --enable=manifold -o $outbn"_"$ext.stl -D view=0 -D output=$p $scad
done


use it with something like this in your scad:

view = 1;
output = 0;
if (view == 1) assembly ();

// Here are the outputs:
// output 1 top
// output 2 bot
if (output == 1) rotate ([180,0,0]) mypart_top (); // flip the top so it is printable.
if (output == 2) mypart_bot ();

The // output 1 top lines are what the script looks for.

Roger. 

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

On Thu, May 02, 2024 at 04:45:26PM +0000, Jordan Brown via Discuss wrote: > On 5/2/2024 1:59 AM, Rogier Wolff via Discuss wrote: > > But first I want to use manifold for the STL generation. It is not > > good if I interactively look at one "interpretation" of the source and > > then use a different "toolset" to actually process it further. > > You want "--enable manifold".  E.g.: > > $ openscad --enable manifold -o x.stl x.scad Thanks that's it! Below is my mkstl script: ----------------- #!/bin/sh # mkstl (C) by REW (R.E.Wolff@BitWizard.nl) scad=$1 outbn=`basename $scad .scad` nrs=`grep '// *output' $scad | awk '{print $3}'` for p in $nrs; do ext=`grep '// *output *'$p' ' $scad | awk '{print $4}'` openscad --enable=manifold -o $outbn"_"$ext.stl -D view=0 -D output=$p $scad done ------- use it with something like this in your scad: view = 1; output = 0; if (view == 1) assembly (); // Here are the outputs: // output 1 top // output 2 bot if (output == 1) rotate ([180,0,0]) mypart_top (); // flip the top so it is printable. if (output == 2) mypart_bot (); The // output 1 top lines are what the script looks for. Roger. -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** f equals m times a. When your f is steady, and your m is going down your a is going up. -- Chris Hadfield about flying up the space shuttle.
CM
Curt McDowell
Sat, May 4, 2024 2:29 AM

OpenSCAD has a -d option for generating dependency files for Make
(similar to makedepend or gcc -M).

    openscad -d model.deps -o model.stl model.scad

Here is a nice blog on using that
https://kevincuzner.com/2022/12/31/a-good-workflow-and-build-system-with-openscad-and-makefiles/#:~:text=When%20invoking%20openscad%20to%20build,according%20to%20the%20Makefile%20logic..

If generating many similar renderings (such as frames for an animation),
running openscad separately for each frame could be much slower than
necessary, as it wouldn't be taking full advantage of the geometry
cache, and that is in addition to the application startup overheads.

Multiple files could be generated using the builtin animation mode and
keying off $t for which part of the model to build, although the
numbered output files would have to be renamed afterward.

    part = 1 + floor($t * 4);
   ...
    if (part == 1) part1();
    else if (part == 2) part2();
    else if (part == 3) part3();
    else if (part == 4) part4();

    openscad --animate 4 -o model.stl model.scad

Regards,
-Curt

On 5/1/2024 9:59 AM, Rogier Wolff via Discuss wrote:

But when I run:

 time openscad -q -o esun-reel.stl -D view=2 esun-reel.scad

there is a significant delay.

OpenSCAD has a -d option for generating dependency files for Make (similar to makedepend or gcc -M).     openscad -d model.deps -o model.stl model.scad Here is a nice blog on using that <https://kevincuzner.com/2022/12/31/a-good-workflow-and-build-system-with-openscad-and-makefiles/#:~:text=When%20invoking%20openscad%20to%20build,according%20to%20the%20Makefile%20logic.>. If generating many similar renderings (such as frames for an animation), running openscad separately for each frame could be much slower than necessary, as it wouldn't be taking full advantage of the geometry cache, and that is in addition to the application startup overheads. Multiple files could be generated using the builtin animation mode and keying off $t for which part of the model to build, although the numbered output files would have to be renamed afterward.     part = 1 + floor($t * 4);    ...     if (part == 1) part1();     else if (part == 2) part2();     else if (part == 3) part3();     else if (part == 4) part4();     openscad --animate 4 -o model.stl model.scad Regards, -Curt On 5/1/2024 9:59 AM, Rogier Wolff via Discuss wrote: > But when I run: > > time openscad -q -o esun-reel.stl -D view=2 esun-reel.scad > > there is a significant delay.