discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

dxf files

RW
Raymond West
Fri, May 19, 2023 3:13 PM

example to demonstrate my problem.

The slightly modified  code

///////////////////////////////////////

module solid(){
  cube(200);
   cube ([150,100,300]);
   cylinder(h=400,d=100);
}
//solid();

   translate ([100,300,0])
       projection(cut=true) translate([0,0,-50])solid();
  translate ([100,600,0])
      projection (cut=true)translate([0,0,-250])solid();
  translate ([100,900,0])
     projection (cut=true)translate([0,0,-350])solid();

/////////////////////////////////////////////////

produces the following  dxf image

Whereas what I need is the shapes 'stacked' on top of each other, like this.

In openscad the 2d shapes are 'filled in', so you do not get the
separate outlines, and this stacked result is not possible within
openscad itself, afaik. I have to manually move the components in the
translated dxf file to align them, using another cad program.

Is it possible in openscad, perhaps using some command line
options/whatever, to export the dxf file, with each projection located
in the correct position, superimposed on top of each other, without
having to translate and rearrange in an external program? It becomes
tedious for more than a few projections.

example to demonstrate my problem. The slightly modified  code /////////////////////////////////////// module solid(){   cube(200);    cube ([150,100,300]);    cylinder(h=400,d=100); } //solid();    translate ([100,300,0])        projection(cut=true) translate([0,0,-50])solid();   translate ([100,600,0])       projection (cut=true)translate([0,0,-250])solid();   translate ([100,900,0])      projection (cut=true)translate([0,0,-350])solid(); ///////////////////////////////////////////////// produces the following  dxf image Whereas what I need is the shapes 'stacked' on top of each other, like this. In openscad the 2d shapes are 'filled in', so you do not get the separate outlines, and this stacked result is not possible within openscad itself, afaik. I have to manually move the components in the translated dxf file to align them, using another cad program. Is it possible in openscad, perhaps using some command line options/whatever, to export the dxf file, with each projection located in the correct position, superimposed on top of each other, without having to translate and rearrange in an external program? It becomes tedious for more than a few projections.
RW
Raymond West
Fri, May 19, 2023 6:15 PM

As an alternative to my wanting stacked projections saved as a single
dxf, Is it possible to save as separate dxf's, programmatically?

//////////////////////////////////
module solid(){
  cube(200);
   cube ([150,100,300]);
   cylinder(h=400,d=100);
}
//solid();

module cut(z){
 projection(cut=true) translate([0,0,-z])solid();
}

//cut(150);
//cut(250);
//cut(350);

///////////////////////////

along the lines that the files would be exported as, say,
'projection150.dxf', 'projection250.dxf',  and 'projection350.dxf' based
on the above example code.

Hoping that once the scad was written, is it possible to use a command
line to automate it, by something like   ' whatever needed (150,250,350)
etc.' ?

If not, I think it would be quicker to manually export separate dxf's at
the various offsets , compared to moving them  around in another
program. There are about a dozen offsets, not equally spaced, in my real
world problem types.

Thanks.

On 19/05/2023 16:13, Raymond West wrote:

example to demonstrate my problem.

The slightly modified  code

///////////////////////////////////////

module solid(){
  cube(200);
   cube ([150,100,300]);
   cylinder(h=400,d=100);
}
//solid();

   translate ([100,300,0])
       projection(cut=true) translate([0,0,-50])solid();
  translate ([100,600,0])
      projection (cut=true)translate([0,0,-250])solid();
  translate ([100,900,0])
     projection (cut=true)translate([0,0,-350])solid();

/////////////////////////////////////////////////

produces the following  dxf image

Whereas what I need is the shapes 'stacked' on top of each other, like
this.

In openscad the 2d shapes are 'filled in', so you do not get the
separate outlines, and this stacked result is not possible within
openscad itself, afaik. I have to manually move the components in the
translated dxf file to align them, using another cad program.

Is it possible in openscad, perhaps using some command line
options/whatever, to export the dxf file, with each projection located
in the correct position, superimposed on top of each other, without
having to translate and rearrange in an external program? It becomes
tedious for more than a few projections.


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

As an alternative to my wanting stacked projections saved as a single dxf, Is it possible to save as separate dxf's, programmatically? ////////////////////////////////// module solid(){   cube(200);    cube ([150,100,300]);    cylinder(h=400,d=100); } //solid(); module cut(z){  projection(cut=true) translate([0,0,-z])solid(); } //cut(150); //cut(250); //cut(350); /////////////////////////// along the lines that the files would be exported as, say, 'projection150.dxf', 'projection250.dxf',  and 'projection350.dxf' based on the above example code. Hoping that once the scad was written, is it possible to use a command line to automate it, by something like   ' whatever needed (150,250,350) etc.' ? If not, I think it would be quicker to manually export separate dxf's at the various offsets , compared to moving them  around in another program. There are about a dozen offsets, not equally spaced, in my real world problem types. Thanks. On 19/05/2023 16:13, Raymond West wrote: > > example to demonstrate my problem. > > > > The slightly modified  code > > /////////////////////////////////////// > > module solid(){ >   cube(200); >    cube ([150,100,300]); >    cylinder(h=400,d=100); > } > //solid(); > >    translate ([100,300,0]) >        projection(cut=true) translate([0,0,-50])solid(); >   translate ([100,600,0]) >       projection (cut=true)translate([0,0,-250])solid(); >   translate ([100,900,0]) >      projection (cut=true)translate([0,0,-350])solid(); > > ///////////////////////////////////////////////// > > produces the following  dxf image > > > Whereas what I need is the shapes 'stacked' on top of each other, like > this. > > > In openscad the 2d shapes are 'filled in', so you do not get the > separate outlines, and this stacked result is not possible within > openscad itself, afaik. I have to manually move the components in the > translated dxf file to align them, using another cad program. > > Is it possible in openscad, perhaps using some command line > options/whatever, to export the dxf file, with each projection located > in the correct position, superimposed on top of each other, without > having to translate and rearrange in an external program? It becomes > tedious for more than a few projections. > > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
FS
FF Systems
Fri, May 19, 2023 7:29 PM

Why are you translating the 2D cuts? Either don’t translate, or translate
them all to the same coord. The dxf should then be what you want, iwt.

On Fri, May 19, 2023 at 13:16 Raymond West raywest@raywest.com wrote:

As an alternative to my wanting stacked projections saved as a single dxf,
Is it possible to save as separate dxf's, programmatically?

//////////////////////////////////
module solid(){
cube(200);
cube ([150,100,300]);
cylinder(h=400,d=100);
}
//solid();

module cut(z){
projection(cut=true) translate([0,0,-z])solid();
}

//cut(150);
//cut(250);
//cut(350);

///////////////////////////

along the lines that the files would be exported as, say,
'projection150.dxf', 'projection250.dxf',  and 'projection350.dxf' based on
the above example code.

Hoping that once the scad was written, is it possible to use a command
line to automate it, by something like  ' whatever needed (150,250,350)
etc.' ?

If not, I think it would be quicker to manually export separate dxf's at
the various offsets , compared to moving them  around in another program.
There are about a dozen offsets, not equally spaced, in my real world
problem types.

Thanks.

On 19/05/2023 16:13, Raymond West wrote:

example to demonstrate my problem.

The slightly modified  code

///////////////////////////////////////

module solid(){
cube(200);
cube ([150,100,300]);
cylinder(h=400,d=100);
}
//solid();

translate ([100,300,0])
    projection(cut=true) translate([0,0,-50])solid();

translate ([100,600,0])
projection (cut=true)translate([0,0,-250])solid();
translate ([100,900,0])
projection (cut=true)translate([0,0,-350])solid();

/////////////////////////////////////////////////

produces the following  dxf image

Whereas what I need is the shapes 'stacked' on top of each other, like
this.

In openscad the 2d shapes are 'filled in', so you do not get the separate
outlines, and this stacked result is not possible within openscad itself,
afaik. I have to manually move the components in the translated dxf file to
align them, using another cad program.

Is it possible in openscad, perhaps using some command line
options/whatever, to export the dxf file, with each projection located in
the correct position, superimposed on top of each other, without having to
translate and rearrange in an external program? It becomes tedious for more
than a few projections.


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

Why are you translating the 2D cuts? Either don’t translate, or translate them all to the same coord. The dxf should then be what you want, iwt. On Fri, May 19, 2023 at 13:16 Raymond West <raywest@raywest.com> wrote: > As an alternative to my wanting stacked projections saved as a single dxf, > Is it possible to save as separate dxf's, programmatically? > > ////////////////////////////////// > module solid(){ > cube(200); > cube ([150,100,300]); > cylinder(h=400,d=100); > } > //solid(); > > module cut(z){ > projection(cut=true) translate([0,0,-z])solid(); > } > > //cut(150); > //cut(250); > //cut(350); > > /////////////////////////// > > along the lines that the files would be exported as, say, > 'projection150.dxf', 'projection250.dxf', and 'projection350.dxf' based on > the above example code. > > Hoping that once the scad was written, is it possible to use a command > line to automate it, by something like ' whatever needed (150,250,350) > etc.' ? > > If not, I think it would be quicker to manually export separate dxf's at > the various offsets , compared to moving them around in another program. > There are about a dozen offsets, not equally spaced, in my real world > problem types. > > Thanks. > > > On 19/05/2023 16:13, Raymond West wrote: > > example to demonstrate my problem. > > > > The slightly modified code > > /////////////////////////////////////// > > module solid(){ > cube(200); > cube ([150,100,300]); > cylinder(h=400,d=100); > } > //solid(); > > translate ([100,300,0]) > projection(cut=true) translate([0,0,-50])solid(); > translate ([100,600,0]) > projection (cut=true)translate([0,0,-250])solid(); > translate ([100,900,0]) > projection (cut=true)translate([0,0,-350])solid(); > > ///////////////////////////////////////////////// > > produces the following dxf image > > > > > > Whereas what I need is the shapes 'stacked' on top of each other, like > this. > > > In openscad the 2d shapes are 'filled in', so you do not get the separate > outlines, and this stacked result is not possible within openscad itself, > afaik. I have to manually move the components in the translated dxf file to > align them, using another cad program. > > Is it possible in openscad, perhaps using some command line > options/whatever, to export the dxf file, with each projection located in > the correct position, superimposed on top of each other, without having to > translate and rearrange in an external program? It becomes tedious for more > than a few projections. > > > > _______________________________________________ > 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
Fri, May 19, 2023 9:27 PM

Nope.  But you could more or less straightforwardly wrap a shell script
around a command line, passing -D settings in to tell the OpenSCAD
program which shape to generate and storing the results in separate DXF
files.

Just as in 3D, the shapes are unioned and their original identity is lost.

Nope.  But you could more or less straightforwardly wrap a shell script around a command line, passing -D settings in to tell the OpenSCAD program which shape to generate and storing the results in separate DXF files. Just as in 3D, the shapes are unioned and their original identity is lost.
BL
Bryan Lee
Fri, May 19, 2023 10:31 PM

One method I have used in several models is to build in a "mode" that is
manually set for each run.

//MODE=3;            // Mode 3:  Generate 3d model for visualization
//MODE=2;        // Mode 2:  Generate 2d pattern for cutting
//MODE=0;        // Mode 0:  Generate 2d joined pattern for cutting
MODE=-1;
if ( MODE == 3) {  // 3d visualization
// code here
} else if ( MODE >= 0) {  //  Generate 2d layout for lasercutting
// more code here
} else {  // Generate 2d layout tops connected
// echo (str("MODE is negative"));
//MORE code HERE

You can build in a MODE or other flag that's either a number or true/false,
and based on that generate a specific part.  Then you manually run your
code, changing the mode each time, and saving each as a DXF with a
different filename.

Thus Raymond West hast written on Fri, May 19, 2023 at 04:13:55PM +0100, and, according to prophecy, it shall come to pass that:

example to demonstrate my problem.

The slightly modified  code

///////////////////////////////////////

module solid(){
  cube(200);
   cube ([150,100,300]);
   cylinder(h=400,d=100);
}
//solid();

   translate ([100,300,0])
       projection(cut=true) translate([0,0,-50])solid();
  translate ([100,600,0])
      projection (cut=true)translate([0,0,-250])solid();
  translate ([100,900,0])
     projection (cut=true)translate([0,0,-350])solid();

/////////////////////////////////////////////////

produces the following  dxf image

Whereas what I need is the shapes 'stacked' on top of each other, like this.

In openscad the 2d shapes are 'filled in', so you do not get the separate
outlines, and this stacked result is not possible within openscad itself,
afaik. I have to manually move the components in the translated dxf file to
align them, using another cad program.

Is it possible in openscad, perhaps using some command line
options/whatever, to export the dxf file, with each projection located in
the correct position, superimposed on top of each other, without having to
translate and rearrange in an external program? It becomes tedious for more
than a few projections.


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

One method I have used in several models is to build in a "mode" that is manually set for each run. //MODE=3; // Mode 3: Generate 3d model for visualization //MODE=2; // Mode 2: Generate 2d pattern for cutting //MODE=0; // Mode 0: Generate 2d joined pattern for cutting MODE=-1; if ( MODE == 3) { // 3d visualization // code here } else if ( MODE >= 0) { // Generate 2d layout for lasercutting // more code here } else { // Generate 2d layout tops connected // echo (str("MODE is negative")); //MORE code HERE You can build in a MODE or other flag that's either a number or true/false, and based on that generate a specific part. Then you manually run your code, changing the mode each time, and saving each as a DXF with a different filename. Thus Raymond West hast written on Fri, May 19, 2023 at 04:13:55PM +0100, and, according to prophecy, it shall come to pass that: > example to demonstrate my problem. > > > > The slightly modified  code > > /////////////////////////////////////// > > module solid(){ >   cube(200); >    cube ([150,100,300]); >    cylinder(h=400,d=100); > } > //solid(); > >    translate ([100,300,0]) >        projection(cut=true) translate([0,0,-50])solid(); >   translate ([100,600,0]) >       projection (cut=true)translate([0,0,-250])solid(); >   translate ([100,900,0]) >      projection (cut=true)translate([0,0,-350])solid(); > > ///////////////////////////////////////////////// > > produces the following  dxf image > > > Whereas what I need is the shapes 'stacked' on top of each other, like this. > > > In openscad the 2d shapes are 'filled in', so you do not get the separate > outlines, and this stacked result is not possible within openscad itself, > afaik. I have to manually move the components in the translated dxf file to > align them, using another cad program. > > Is it possible in openscad, perhaps using some command line > options/whatever, to export the dxf file, with each projection located in > the correct position, superimposed on top of each other, without having to > translate and rearrange in an external program? It becomes tedious for more > than a few projections. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
JB
Jordan Brown
Fri, May 19, 2023 11:32 PM

On 5/19/2023 3:31 PM, Bryan Lee wrote:

One method I have used in several models is to build in a "mode" that is
manually set for each run.

Right, you do that, but then you wrap it in a shell script that uses the
CLI and -D to set the mode and control the output name.

On 5/19/2023 3:31 PM, Bryan Lee wrote: > One method I have used in several models is to build in a "mode" that is > manually set for each run. > Right, you do that, but then you wrap it in a shell script that uses the CLI and -D to set the mode and control the output name.
RW
Raymond West
Sat, May 20, 2023 10:52 AM

 Initially I translated in x/y so that the dxf's were separated (since
openscad treats them as planes, not lines, and if you 'stack them' in
openscad, you lose the individual boundaries). I then thought that
separate files would be better, with no x/y translation. My 2.5d cnc
software will mill the boundaries, or pocket, to fixed depths for
selected 2d dxf lines, I have to manually select the lines, set the
depth, etc. It is probably easier/quicker to combine the g-code files
from individual dxf files, compared to offsetting the dxf's to the
origin within the cnc software.

On 19/05/2023 20:29, FF Systems wrote:

Why are you translating the 2D cuts? Either don’t translate, or
translate them all to the same coord. The dxf should then be what you
want, iwt.

On Fri, May 19, 2023 at 13:16 Raymond West raywest@raywest.com wrote:

 As an alternative to my wanting stacked projections saved as a
 single dxf, Is it possible to save as separate dxf's,
 programmatically?

 //////////////////////////////////
 module solid(){
   cube(200);
    cube ([150,100,300]);
    cylinder(h=400,d=100);
 }
 //solid();

 module cut(z){
  projection(cut=true) translate([0,0,-z])solid();
 }

 //cut(150);
 //cut(250);
 //cut(350);

 ///////////////////////////

 along the lines that the files would be exported as, say,
 'projection150.dxf', 'projection250.dxf',  and 'projection350.dxf'
 based on the above example code.

 Hoping that once the scad was written, is it possible to use a
 command line to automate it, by something like   ' whatever needed
 (150,250,350) etc.' ?

 If not, I think it would be quicker to manually export separate
 dxf's at the various offsets , compared to moving them  around in
 another program. There are about a dozen offsets, not equally
 spaced, in my real world problem types.

 Thanks.


 On 19/05/2023 16:13, Raymond West wrote:
 example to demonstrate my problem.



 The slightly modified  code

 ///////////////////////////////////////

 module solid(){
   cube(200);
    cube ([150,100,300]);
    cylinder(h=400,d=100);
 }
 //solid();

    translate ([100,300,0])
        projection(cut=true) translate([0,0,-50])solid();
   translate ([100,600,0])
       projection (cut=true)translate([0,0,-250])solid();
   translate ([100,900,0])
      projection (cut=true)translate([0,0,-350])solid();

 /////////////////////////////////////////////////

 produces the following  dxf image


 Whereas what I need is the shapes 'stacked' on top of each other,
 like this.


 In openscad the 2d shapes are 'filled in', so you do not get the
 separate outlines, and this stacked result is not possible within
 openscad itself, afaik. I have to manually move the components in
 the translated dxf file to align them, using another cad program.

 Is it possible in openscad, perhaps using some command line
 options/whatever, to export the dxf file, with each projection
 located in the correct position, superimposed on top of each
 other, without having to translate and rearrange in an external
 program? It becomes tedious for more than a few projections.



 _______________________________________________
 OpenSCAD mailing list
 To unsubscribe send an email todiscuss-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 todiscuss-leave@lists.openscad.org

 Initially I translated in x/y so that the dxf's were separated (since openscad treats them as planes, not lines, and if you 'stack them' in openscad, you lose the individual boundaries). I then thought that separate files would be better, with no x/y translation. My 2.5d cnc software will mill the boundaries, or pocket, to fixed depths for selected 2d dxf lines, I have to manually select the lines, set the depth, etc. It is probably easier/quicker to combine the g-code files from individual dxf files, compared to offsetting the dxf's to the origin within the cnc software. On 19/05/2023 20:29, FF Systems wrote: > Why are you translating the 2D cuts? Either don’t translate, or > translate them all to the same coord. The dxf should then be what you > want, iwt. > > On Fri, May 19, 2023 at 13:16 Raymond West <raywest@raywest.com> wrote: > > As an alternative to my wanting stacked projections saved as a > single dxf, Is it possible to save as separate dxf's, > programmatically? > > ////////////////////////////////// > module solid(){ >   cube(200); >    cube ([150,100,300]); >    cylinder(h=400,d=100); > } > //solid(); > > module cut(z){ >  projection(cut=true) translate([0,0,-z])solid(); > } > > //cut(150); > //cut(250); > //cut(350); > > /////////////////////////// > > along the lines that the files would be exported as, say, > 'projection150.dxf', 'projection250.dxf',  and 'projection350.dxf' > based on the above example code. > > Hoping that once the scad was written, is it possible to use a > command line to automate it, by something like   ' whatever needed > (150,250,350) etc.' ? > > If not, I think it would be quicker to manually export separate > dxf's at the various offsets , compared to moving them  around in > another program. There are about a dozen offsets, not equally > spaced, in my real world problem types. > > Thanks. > > > On 19/05/2023 16:13, Raymond West wrote: >> >> example to demonstrate my problem. >> >> >> >> The slightly modified  code >> >> /////////////////////////////////////// >> >> module solid(){ >>   cube(200); >>    cube ([150,100,300]); >>    cylinder(h=400,d=100); >> } >> //solid(); >> >>    translate ([100,300,0]) >>        projection(cut=true) translate([0,0,-50])solid(); >>   translate ([100,600,0]) >>       projection (cut=true)translate([0,0,-250])solid(); >>   translate ([100,900,0]) >>      projection (cut=true)translate([0,0,-350])solid(); >> >> ///////////////////////////////////////////////// >> >> produces the following  dxf image >> >> >> Whereas what I need is the shapes 'stacked' on top of each other, >> like this. >> >> >> In openscad the 2d shapes are 'filled in', so you do not get the >> separate outlines, and this stacked result is not possible within >> openscad itself, afaik. I have to manually move the components in >> the translated dxf file to align them, using another cad program. >> >> Is it possible in openscad, perhaps using some command line >> options/whatever, to export the dxf file, with each projection >> located in the correct position, superimposed on top of each >> other, without having to translate and rearrange in an external >> program? It becomes tedious for more than a few projections. >> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email todiscuss-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 todiscuss-leave@lists.openscad.org
JB
Jordan Brown
Sat, May 20, 2023 4:52 PM

I was asked for a concrete example.  The shell script  here is a little
odd because I don't have a shell environment with an OpenSCAD in the
path, but it should be obvious enough to anybody who knows shell
programming.

--- demo.scad ---

mode=1;

if (mode == 1) {
    text("one");
}

if (mode == 2) {
    text("two");
}

--- demo.sh ---

#! /bin/sh

openscad='C:/Program Files/OpenSCAD-2021.01/openscad'
"$openscad" -Dmode=1 -o demo-1.dxf demo.scad
"$openscad" -Dmode=2 -o demo-2.dxf demo.scad

I was asked for a concrete example.  The shell script  here is a little odd because I don't have a shell environment with an OpenSCAD in the path, but it should be obvious enough to anybody who knows shell programming. --- demo.scad --- mode=1; if (mode == 1) {     text("one"); } if (mode == 2) {     text("two"); } --- demo.sh --- #! /bin/sh openscad='C:/Program Files/OpenSCAD-2021.01/openscad' "$openscad" -Dmode=1 -o demo-1.dxf demo.scad "$openscad" -Dmode=2 -o demo-2.dxf demo.scad
RW
Raymond West
Sat, May 20, 2023 10:07 PM

I've done it in a windows batch file (saved in my openscad folder with
the rest of my scad scripts. simple enough to copy/paste, small edit, to
get extra sections

C:"Program Files"\OpenSCAD\openscad.exe -o projection250.dxf -D z=250
"projection test.scad"
C:"Program Files"\OpenSCAD\openscad.exe -o projection350.dxf -D z=350
"projection test.scad"
C:"Program Files"\OpenSCAD\openscad.exe -o projection50.dxf -D z=50
"projection test.scad"

for the scad file named "projection test.scad"

module solid(){
  cube(200);
   cube ([150,100,300]);
   cylinder(h=400,d=100);
}
//solid();
module doit(z){
   projection(cut=true) translate([0,0,-z])solid();
}

doit(z);

//doit (250);
//doit(350);
//doit(50);

Now to see if it is better in practice, compared to the original
translated single file.

On 20/05/2023 17:52, Jordan Brown wrote:

I was asked for a concrete example.  The shell script  here is a
little odd because I don't have a shell environment with an OpenSCAD
in the path, but it should be obvious enough to anybody who knows
shell programming.

--- demo.scad ---
mode=1;

if (mode == 1) {
    text("one");
}

if (mode == 2) {
    text("two");
}

--- demo.sh ---
#! /bin/sh

openscad='C:/Program Files/OpenSCAD-2021.01/openscad'
"$openscad" -Dmode=1 -o demo-1.dxf demo.scad
"$openscad" -Dmode=2 -o demo-2.dxf demo.scad


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

I've done it in a windows batch file (saved in my openscad folder with the rest of my scad scripts. simple enough to copy/paste, small edit, to get extra sections C:\"Program Files"\OpenSCAD\openscad.exe -o projection250.dxf -D z=250 "projection test.scad" C:\"Program Files"\OpenSCAD\openscad.exe -o projection350.dxf -D z=350 "projection test.scad" C:\"Program Files"\OpenSCAD\openscad.exe -o projection50.dxf -D z=50 "projection test.scad" for the scad file named "projection test.scad" module solid(){   cube(200);    cube ([150,100,300]);    cylinder(h=400,d=100); } //solid(); module doit(z){    projection(cut=true) translate([0,0,-z])solid(); } doit(z); //doit (250); //doit(350); //doit(50); Now to see if it is better in practice, compared to the original translated single file. On 20/05/2023 17:52, Jordan Brown wrote: > I was asked for a concrete example.  The shell script  here is a > little odd because I don't have a shell environment with an OpenSCAD > in the path, but it should be obvious enough to anybody who knows > shell programming. > > --- demo.scad --- > mode=1; > > if (mode == 1) { >     text("one"); > } > > if (mode == 2) { >     text("two"); > } > > --- demo.sh --- > #! /bin/sh > > openscad='C:/Program Files/OpenSCAD-2021.01/openscad' > "$openscad" -Dmode=1 -o demo-1.dxf demo.scad > "$openscad" -Dmode=2 -o demo-2.dxf demo.scad > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
RW
Ray West
Sun, May 21, 2023 11:05 AM

Having forgotten about the details of batch files, and never getting
into power shell, I got Bing in Edge (OpenAI chat-gpt v 4, afaik) to
generate a more succinct batch file. took a bit of tooing and froing (I
changed the z values from b4)

@echo off
setlocal enabledelayedexpansion
set z_values=355 245 5
for %%z in (%z_values%) do (
    echo Running OpenSCAD with z=%%z
    C:"Program Files"\OpenSCAD\openscad.exe -o projection%%z.dxf -D
z=%%z "projection test.scad"
)
endlocal

On 20/05/2023 23:07, Raymond West wrote:

I've done it in a windows batch file (saved in my openscad folder with
the rest of my scad scripts. simple enough to copy/paste, small edit,
to get extra sections

C:"Program Files"\OpenSCAD\openscad.exe -o projection250.dxf -D z=250
"projection test.scad"
C:"Program Files"\OpenSCAD\openscad.exe -o projection350.dxf -D z=350
"projection test.scad"
C:"Program Files"\OpenSCAD\openscad.exe -o projection50.dxf -D z=50
"projection test.scad"

for the scad file named "projection test.scad"

module solid(){
  cube(200);
   cube ([150,100,300]);
   cylinder(h=400,d=100);
}
//solid();
module doit(z){
   projection(cut=true) translate([0,0,-z])solid();
}

doit(z);

//doit (250);
//doit(350);
//doit(50);

Now to see if it is better in practice, compared to the original
translated single file.

On 20/05/2023 17:52, Jordan Brown wrote:

I was asked for a concrete example.  The shell script  here is a
little odd because I don't have a shell environment with an OpenSCAD
in the path, but it should be obvious enough to anybody who knows
shell programming.

--- demo.scad ---
mode=1;

if (mode == 1) {
    text("one");
}

if (mode == 2) {
    text("two");
}

--- demo.sh ---
#! /bin/sh

openscad='C:/Program Files/OpenSCAD-2021.01/openscad'
"$openscad" -Dmode=1 -o demo-1.dxf demo.scad
"$openscad" -Dmode=2 -o demo-2.dxf demo.scad


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


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

Having forgotten about the details of batch files, and never getting into power shell, I got Bing in Edge (OpenAI chat-gpt v 4, afaik) to generate a more succinct batch file. took a bit of tooing and froing (I changed the z values from b4) @echo off setlocal enabledelayedexpansion set z_values=355 245 5 for %%z in (%z_values%) do (     echo Running OpenSCAD with z=%%z     C:\"Program Files"\OpenSCAD\openscad.exe -o projection%%z.dxf -D z=%%z "projection test.scad" ) endlocal On 20/05/2023 23:07, Raymond West wrote: > > I've done it in a windows batch file (saved in my openscad folder with > the rest of my scad scripts. simple enough to copy/paste, small edit, > to get extra sections > > C:\"Program Files"\OpenSCAD\openscad.exe -o projection250.dxf -D z=250 > "projection test.scad" > C:\"Program Files"\OpenSCAD\openscad.exe -o projection350.dxf -D z=350 > "projection test.scad" > C:\"Program Files"\OpenSCAD\openscad.exe -o projection50.dxf -D z=50 > "projection test.scad" > > for the scad file named "projection test.scad" > > module solid(){ >   cube(200); >    cube ([150,100,300]); >    cylinder(h=400,d=100); > } > //solid(); > module doit(z){ >    projection(cut=true) translate([0,0,-z])solid(); > } > > doit(z); > > > //doit (250); > //doit(350); > //doit(50); > > Now to see if it is better in practice, compared to the original > translated single file. > > On 20/05/2023 17:52, Jordan Brown wrote: >> I was asked for a concrete example.  The shell script  here is a >> little odd because I don't have a shell environment with an OpenSCAD >> in the path, but it should be obvious enough to anybody who knows >> shell programming. >> >> --- demo.scad --- >> mode=1; >> >> if (mode == 1) { >>     text("one"); >> } >> >> if (mode == 2) { >>     text("two"); >> } >> >> --- demo.sh --- >> #! /bin/sh >> >> openscad='C:/Program Files/OpenSCAD-2021.01/openscad' >> "$openscad" -Dmode=1 -o demo-1.dxf demo.scad >> "$openscad" -Dmode=2 -o demo-2.dxf demo.scad >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email todiscuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org