DP
David Phillip Oster
Thu, Feb 13, 2025 11:38 PM
Example of how to run OpenSCAD from the command line and parsing the output
from stderr/stdout
Given the commandExample.scad file:
echo("## My first test line");
difference(){
cube(25,center=true);
cylinder(25,r=10+2*0.1,center=true);
}
cylinder(25,r=10,center=true);
echo("## My last test line");
The following command line, for me, on macOS, using bash as my shell:
$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD commandExample.scad -o
a.stl 2>&1 | grep 'ECHO: "##' | sed -e 's/ECHO: "## //' | sed -e 's/"$//'
prints:
My first test line
My last test line
Discussion:
The 2>&1 maps stderr to stdout. The grep filters out only my echo lines.
The two sed commands remove the guard boilerplate, extracting just the
content I want to continue processing. A sed expert could probably
coalesce the grep | sed | sed to a single sed command.
On Thu, Feb 13, 2025 at 3:00 PM John David via Discuss <
discuss@lists.openscad.org> wrote:
BTW, does anyone have an example of how to run OpenSCAD from the command
line and parsing the output from stderr/stdout? When trying to build
various version from source I broke some things and have not gotten it all
sorted out yet. So, in the interim...
EBo --
On Thu, Feb 13, 2025 at 11:34 AM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:
On 2/13/2025 6:41 AM, Raymond West via Discuss wrote:
You can write text to the screen/viewport, and save as pdf., or other
2d/3d formats, if you need to read the values. If you want to input that as
text to another program, then that will need other manipulation. Text is
not exported as text, but as an image of the text. One method would be to
display output as a qr code, plenty of software for handling that.
It's only exported as an image of the text if you take a screen shot.
Ordinary select/copy/paste works fine and transfers the text as text.
module outline(t) {
difference() {
offset(t/2) children();
offset(-t/2) children();
}
}
color("black") outline(0.3) text("Hello world!");
yields console output:
Parsing design (AST generation)...
Saved backup file:
C:/Users/Jordan/OneDrive/Documents/OpenSCAD/backups/unsaved-backup-cSChDmHh.scad
Compiling design (CSG Tree generation)...
Compiling design (CSG Products generation)...
Geometries in cache: 7
Geometry cache size in bytes: 59168
CGAL Polyhedrons in cache: 0
CGAL cache size in bytes: 0
Compiling design (CSG Products normalization)...
Normalized tree has 2 elements!
Compile and preview finished.
Total rendering time: 0:00:00.051
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Example of how to run OpenSCAD from the command line and parsing the output
from stderr/stdout
Given the commandExample.scad file:
echo("## My first test line");
difference(){
cube(25,center=true);
cylinder(25,r=10+2*0.1,center=true);
}
cylinder(25,r=10,center=true);
echo("## My last test line");
The following command line, for me, on macOS, using bash as my shell:
$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD commandExample.scad -o
a.stl 2>&1 | grep 'ECHO: \"##' | sed -e 's/ECHO: \"## //' | sed -e 's/"$//'
prints:
My first test line
My last test line
Discussion:
The 2>&1 maps stderr to stdout. The grep filters out only my echo lines.
The two sed commands remove the guard boilerplate, extracting just the
content I want to continue processing. A sed expert could probably
coalesce the grep | sed | sed to a single sed command.
On Thu, Feb 13, 2025 at 3:00 PM John David via Discuss <
discuss@lists.openscad.org> wrote:
> BTW, does anyone have an example of how to run OpenSCAD from the command
> line and parsing the output from stderr/stdout? When trying to build
> various version from source I broke some things and have not gotten it all
> sorted out yet. So, in the interim...
>
> EBo --
>
> On Thu, Feb 13, 2025 at 11:34 AM Jordan Brown via Discuss <
> discuss@lists.openscad.org> wrote:
>
>> On 2/13/2025 6:41 AM, Raymond West via Discuss wrote:
>>
>> You can write text to the screen/viewport, and save as pdf., or other
>> 2d/3d formats, if you need to read the values. If you want to input that as
>> text to another program, then that will need other manipulation. Text is
>> not exported as text, but as an image of the text. One method would be to
>> display output as a qr code, plenty of software for handling that.
>>
>>
>> It's only exported as an image of the text if you take a screen shot.
>> Ordinary select/copy/paste works fine and transfers the text as text.
>>
>> module outline(t) {
>> difference() {
>> offset(t/2) children();
>> offset(-t/2) children();
>> }
>> }
>>
>> color("black") outline(0.3) text("Hello world!");
>>
>> yields console output:
>>
>> Parsing design (AST generation)...
>> Saved backup file:
>> C:/Users/Jordan/OneDrive/Documents/OpenSCAD/backups/unsaved-backup-cSChDmHh.scad
>> Compiling design (CSG Tree generation)...
>> Compiling design (CSG Products generation)...
>> Geometries in cache: 7
>> Geometry cache size in bytes: 59168
>> CGAL Polyhedrons in cache: 0
>> CGAL cache size in bytes: 0
>> Compiling design (CSG Products normalization)...
>> Normalized tree has 2 elements!
>> Compile and preview finished.
>> Total rendering time: 0:00:00.051
>>
>> _______________________________________________
>> 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
>
DP
David Phillip Oster
Thu, Feb 13, 2025 11:48 PM
A sed expert could probably coalesce the grep | sed | sed to a single sed
command.
here it is:
$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD commandExample.scad
-o a.stl 2>&1 | sed -n 's/ECHO: "##(.*)"/\1/p'
the -n removes echo lines not matched. the p suffix causes the lines that
do match to be output, after the replacement.
On Thu, Feb 13, 2025 at 3:38 PM David Phillip Oster <
davidphilliposter@gmail.com> wrote:
Example of how to run OpenSCAD from the command line and parsing the
output from stderr/stdout
Given the commandExample.scad file:
echo("## My first test line");
difference(){
cube(25,center=true);
cylinder(25,r=10+2*0.1,center=true);
}
cylinder(25,r=10,center=true);
echo("## My last test line");
The following command line, for me, on macOS, using bash as my shell:
$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD commandExample.scad
-o a.stl 2>&1 | grep 'ECHO: "##' | sed -e 's/ECHO: "## //' | sed -e
's/"$//'
prints:
My first test line
My last test line
Discussion:
The 2>&1 maps stderr to stdout. The grep filters out only my echo lines.
The two sed commands remove the guard boilerplate, extracting just the
content I want to continue processing. A sed expert could probably
coalesce the grep | sed | sed to a single sed command.
On Thu, Feb 13, 2025 at 3:00 PM John David via Discuss <
discuss@lists.openscad.org> wrote:
BTW, does anyone have an example of how to run OpenSCAD from the command
line and parsing the output from stderr/stdout? When trying to build
various version from source I broke some things and have not gotten it all
sorted out yet. So, in the interim...
EBo --
On Thu, Feb 13, 2025 at 11:34 AM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:
On 2/13/2025 6:41 AM, Raymond West via Discuss wrote:
You can write text to the screen/viewport, and save as pdf., or other
2d/3d formats, if you need to read the values. If you want to input that as
text to another program, then that will need other manipulation. Text is
not exported as text, but as an image of the text. One method would be to
display output as a qr code, plenty of software for handling that.
It's only exported as an image of the text if you take a screen shot.
Ordinary select/copy/paste works fine and transfers the text as text.
module outline(t) {
difference() {
offset(t/2) children();
offset(-t/2) children();
}
}
color("black") outline(0.3) text("Hello world!");
yields console output:
Parsing design (AST generation)...
Saved backup file:
C:/Users/Jordan/OneDrive/Documents/OpenSCAD/backups/unsaved-backup-cSChDmHh.scad
Compiling design (CSG Tree generation)...
Compiling design (CSG Products generation)...
Geometries in cache: 7
Geometry cache size in bytes: 59168
CGAL Polyhedrons in cache: 0
CGAL cache size in bytes: 0
Compiling design (CSG Products normalization)...
Normalized tree has 2 elements!
Compile and preview finished.
Total rendering time: 0:00:00.051
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
I wrote:
> A sed expert could probably coalesce the grep | sed | sed to a single sed
> command.
here it is:
$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD commandExample.scad
-o a.stl 2>&1 | sed -n 's/ECHO: \"##\(.*\)\"/\1/p'
the -n removes echo lines not matched. the p suffix causes the lines that
do match to be output, after the replacement.
On Thu, Feb 13, 2025 at 3:38 PM David Phillip Oster <
davidphilliposter@gmail.com> wrote:
> Example of how to run OpenSCAD from the command line and parsing the
> output from stderr/stdout
>
> Given the commandExample.scad file:
>
> echo("## My first test line");
>
> difference(){
>
> cube(25,center=true);
>
> cylinder(25,r=10+2*0.1,center=true);
>
> }
>
>
> cylinder(25,r=10,center=true);
>
> echo("## My last test line");
>
> The following command line, for me, on macOS, using bash as my shell:
>
> $ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD commandExample.scad
> -o a.stl 2>&1 | grep 'ECHO: \"##' | sed -e 's/ECHO: \"## //' | sed -e
> 's/"$//'
>
>
> prints:
>
> My first test line
>
> My last test line
>
>
> Discussion:
>
>
> The 2>&1 maps stderr to stdout. The grep filters out only my echo lines.
> The two sed commands remove the guard boilerplate, extracting just the
> content I want to continue processing. A sed expert could probably
> coalesce the grep | sed | sed to a single sed command.
>
> On Thu, Feb 13, 2025 at 3:00 PM John David via Discuss <
> discuss@lists.openscad.org> wrote:
>
>> BTW, does anyone have an example of how to run OpenSCAD from the command
>> line and parsing the output from stderr/stdout? When trying to build
>> various version from source I broke some things and have not gotten it all
>> sorted out yet. So, in the interim...
>>
>> EBo --
>>
>> On Thu, Feb 13, 2025 at 11:34 AM Jordan Brown via Discuss <
>> discuss@lists.openscad.org> wrote:
>>
>>> On 2/13/2025 6:41 AM, Raymond West via Discuss wrote:
>>>
>>> You can write text to the screen/viewport, and save as pdf., or other
>>> 2d/3d formats, if you need to read the values. If you want to input that as
>>> text to another program, then that will need other manipulation. Text is
>>> not exported as text, but as an image of the text. One method would be to
>>> display output as a qr code, plenty of software for handling that.
>>>
>>>
>>> It's only exported as an image of the text if you take a screen shot.
>>> Ordinary select/copy/paste works fine and transfers the text as text.
>>>
>>> module outline(t) {
>>> difference() {
>>> offset(t/2) children();
>>> offset(-t/2) children();
>>> }
>>> }
>>>
>>> color("black") outline(0.3) text("Hello world!");
>>>
>>> yields console output:
>>>
>>> Parsing design (AST generation)...
>>> Saved backup file:
>>> C:/Users/Jordan/OneDrive/Documents/OpenSCAD/backups/unsaved-backup-cSChDmHh.scad
>>> Compiling design (CSG Tree generation)...
>>> Compiling design (CSG Products generation)...
>>> Geometries in cache: 7
>>> Geometry cache size in bytes: 59168
>>> CGAL Polyhedrons in cache: 0
>>> CGAL cache size in bytes: 0
>>> Compiling design (CSG Products normalization)...
>>> Normalized tree has 2 elements!
>>> Compile and preview finished.
>>> Total rendering time: 0:00:00.051
>>>
>>> _______________________________________________
>>> 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
>>
>
FH
Father Horton
Fri, Feb 14, 2025 12:05 AM
A sed expert could probably coalesce the grep | sed | sed to a single
sed command.
here it is:
$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD commandExample.scad
-o a.stl 2>&1 | sed -n 's/ECHO: "##(.*)"/\1/p'
the -n removes echo lines not matched. the p suffix causes the lines that
do match to be output, after the replacement.
On Thu, Feb 13, 2025 at 3:38 PM David Phillip Oster <
davidphilliposter@gmail.com> wrote:
Example of how to run OpenSCAD from the command line and parsing the
output from stderr/stdout
Given the commandExample.scad file:
echo("## My first test line");
difference(){
cube(25,center=true);
cylinder(25,r=10+2*0.1,center=true);
}
cylinder(25,r=10,center=true);
echo("## My last test line");
The following command line, for me, on macOS, using bash as my shell:
$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD commandExample.scad
-o a.stl 2>&1 | grep 'ECHO: "##' | sed -e 's/ECHO: "## //' | sed -e
's/"$//'
prints:
My first test line
My last test line
Discussion:
The 2>&1 maps stderr to stdout. The grep filters out only my echo lines.
The two sed commands remove the guard boilerplate, extracting just the
content I want to continue processing. A sed expert could probably
coalesce the grep | sed | sed to a single sed command.
On Thu, Feb 13, 2025 at 3:00 PM John David via Discuss <
discuss@lists.openscad.org> wrote:
BTW, does anyone have an example of how to run OpenSCAD from the command
line and parsing the output from stderr/stdout? When trying to build
various version from source I broke some things and have not gotten it all
sorted out yet. So, in the interim...
EBo --
On Thu, Feb 13, 2025 at 11:34 AM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:
On 2/13/2025 6:41 AM, Raymond West via Discuss wrote:
You can write text to the screen/viewport, and save as pdf., or other
2d/3d formats, if you need to read the values. If you want to input that as
text to another program, then that will need other manipulation. Text is
not exported as text, but as an image of the text. One method would be to
display output as a qr code, plenty of software for handling that.
It's only exported as an image of the text if you take a screen shot.
Ordinary select/copy/paste works fine and transfers the text as text.
module outline(t) {
difference() {
offset(t/2) children();
offset(-t/2) children();
}
}
color("black") outline(0.3) text("Hello world!");
yields console output:
Parsing design (AST generation)...
Saved backup file:
C:/Users/Jordan/OneDrive/Documents/OpenSCAD/backups/unsaved-backup-cSChDmHh.scad
Compiling design (CSG Tree generation)...
Compiling design (CSG Products generation)...
Geometries in cache: 7
Geometry cache size in bytes: 59168
CGAL Polyhedrons in cache: 0
CGAL cache size in bytes: 0
Compiling design (CSG Products normalization)...
Normalized tree has 2 elements!
Compile and preview finished.
Total rendering time: 0:00:00.051
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
I am in awe.
On Thu, Feb 13, 2025 at 5:49 PM David Phillip Oster via Discuss <
discuss@lists.openscad.org> wrote:
> I wrote:
>
>> A sed expert could probably coalesce the grep | sed | sed to a single
>> sed command.
>
>
> here it is:
> $ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD commandExample.scad
> -o a.stl 2>&1 | sed -n 's/ECHO: \"##\(.*\)\"/\1/p'
>
> the -n removes echo lines not matched. the p suffix causes the lines that
> do match to be output, after the replacement.
>
>
> On Thu, Feb 13, 2025 at 3:38 PM David Phillip Oster <
> davidphilliposter@gmail.com> wrote:
>
>> Example of how to run OpenSCAD from the command line and parsing the
>> output from stderr/stdout
>>
>> Given the commandExample.scad file:
>>
>> echo("## My first test line");
>>
>> difference(){
>>
>> cube(25,center=true);
>>
>> cylinder(25,r=10+2*0.1,center=true);
>>
>> }
>>
>>
>> cylinder(25,r=10,center=true);
>>
>> echo("## My last test line");
>>
>> The following command line, for me, on macOS, using bash as my shell:
>>
>> $ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD commandExample.scad
>> -o a.stl 2>&1 | grep 'ECHO: \"##' | sed -e 's/ECHO: \"## //' | sed -e
>> 's/"$//'
>>
>>
>> prints:
>>
>> My first test line
>>
>> My last test line
>>
>>
>> Discussion:
>>
>>
>> The 2>&1 maps stderr to stdout. The grep filters out only my echo lines.
>> The two sed commands remove the guard boilerplate, extracting just the
>> content I want to continue processing. A sed expert could probably
>> coalesce the grep | sed | sed to a single sed command.
>>
>> On Thu, Feb 13, 2025 at 3:00 PM John David via Discuss <
>> discuss@lists.openscad.org> wrote:
>>
>>> BTW, does anyone have an example of how to run OpenSCAD from the command
>>> line and parsing the output from stderr/stdout? When trying to build
>>> various version from source I broke some things and have not gotten it all
>>> sorted out yet. So, in the interim...
>>>
>>> EBo --
>>>
>>> On Thu, Feb 13, 2025 at 11:34 AM Jordan Brown via Discuss <
>>> discuss@lists.openscad.org> wrote:
>>>
>>>> On 2/13/2025 6:41 AM, Raymond West via Discuss wrote:
>>>>
>>>> You can write text to the screen/viewport, and save as pdf., or other
>>>> 2d/3d formats, if you need to read the values. If you want to input that as
>>>> text to another program, then that will need other manipulation. Text is
>>>> not exported as text, but as an image of the text. One method would be to
>>>> display output as a qr code, plenty of software for handling that.
>>>>
>>>>
>>>> It's only exported as an image of the text if you take a screen shot.
>>>> Ordinary select/copy/paste works fine and transfers the text as text.
>>>>
>>>> module outline(t) {
>>>> difference() {
>>>> offset(t/2) children();
>>>> offset(-t/2) children();
>>>> }
>>>> }
>>>>
>>>> color("black") outline(0.3) text("Hello world!");
>>>>
>>>> yields console output:
>>>>
>>>> Parsing design (AST generation)...
>>>> Saved backup file:
>>>> C:/Users/Jordan/OneDrive/Documents/OpenSCAD/backups/unsaved-backup-cSChDmHh.scad
>>>> Compiling design (CSG Tree generation)...
>>>> Compiling design (CSG Products generation)...
>>>> Geometries in cache: 7
>>>> Geometry cache size in bytes: 59168
>>>> CGAL Polyhedrons in cache: 0
>>>> CGAL cache size in bytes: 0
>>>> Compiling design (CSG Products normalization)...
>>>> Normalized tree has 2 elements!
>>>> Compile and preview finished.
>>>> Total rendering time: 0:00:00.051
>>>>
>>>> _______________________________________________
>>>> 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
>
JD
John David
Fri, Feb 14, 2025 12:50 AM
Thanks! I will have this for when I get my system fully working again...
On Thu, Feb 13, 2025 at 7:06 PM Father Horton via Discuss <
discuss@lists.openscad.org> wrote:
A sed expert could probably coalesce the grep | sed | sed to a single
sed command.
here it is:
$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD
commandExample.scad -o a.stl 2>&1 | sed -n 's/ECHO: "##(.*)"/\1/p'
the -n removes echo lines not matched. the p suffix causes the lines that
do match to be output, after the replacement.
On Thu, Feb 13, 2025 at 3:38 PM David Phillip Oster <
davidphilliposter@gmail.com> wrote:
Example of how to run OpenSCAD from the command line and parsing the
output from stderr/stdout
Given the commandExample.scad file:
echo("## My first test line");
difference(){
cube(25,center=true);
cylinder(25,r=10+2*0.1,center=true);
}
cylinder(25,r=10,center=true);
echo("## My last test line");
The following command line, for me, on macOS, using bash as my shell:
$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD
commandExample.scad -o a.stl 2>&1 | grep 'ECHO: "##' | sed -e 's/ECHO:
"## //' | sed -e 's/"$//'
prints:
My first test line
My last test line
Discussion:
The 2>&1 maps stderr to stdout. The grep filters out only my echo
lines. The two sed commands remove the guard boilerplate, extracting
just the content I want to continue processing. A sed expert could
probably coalesce the grep | sed | sed to a single sed command.
On Thu, Feb 13, 2025 at 3:00 PM John David via Discuss <
discuss@lists.openscad.org> wrote:
BTW, does anyone have an example of how to run OpenSCAD from the
command line and parsing the output from stderr/stdout? When trying to
build various version from source I broke some things and have not gotten
it all sorted out yet. So, in the interim...
EBo --
On Thu, Feb 13, 2025 at 11:34 AM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:
On 2/13/2025 6:41 AM, Raymond West via Discuss wrote:
You can write text to the screen/viewport, and save as pdf., or other
2d/3d formats, if you need to read the values. If you want to input that as
text to another program, then that will need other manipulation. Text is
not exported as text, but as an image of the text. One method would be to
display output as a qr code, plenty of software for handling that.
It's only exported as an image of the text if you take a screen shot.
Ordinary select/copy/paste works fine and transfers the text as text.
module outline(t) {
difference() {
offset(t/2) children();
offset(-t/2) children();
}
}
color("black") outline(0.3) text("Hello world!");
yields console output:
Parsing design (AST generation)...
Saved backup file:
C:/Users/Jordan/OneDrive/Documents/OpenSCAD/backups/unsaved-backup-cSChDmHh.scad
Compiling design (CSG Tree generation)...
Compiling design (CSG Products generation)...
Geometries in cache: 7
Geometry cache size in bytes: 59168
CGAL Polyhedrons in cache: 0
CGAL cache size in bytes: 0
Compiling design (CSG Products normalization)...
Normalized tree has 2 elements!
Compile and preview finished.
Total rendering time: 0:00:00.051
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Thanks! I will have this for when I get my system fully working again...
On Thu, Feb 13, 2025 at 7:06 PM Father Horton via Discuss <
discuss@lists.openscad.org> wrote:
> I am in awe.
>
> On Thu, Feb 13, 2025 at 5:49 PM David Phillip Oster via Discuss <
> discuss@lists.openscad.org> wrote:
>
>> I wrote:
>>
>>> A sed expert could probably coalesce the grep | sed | sed to a single
>>> sed command.
>>
>>
>> here it is:
>> $ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD
>> commandExample.scad -o a.stl 2>&1 | sed -n 's/ECHO: \"##\(.*\)\"/\1/p'
>>
>> the -n removes echo lines not matched. the p suffix causes the lines that
>> do match to be output, after the replacement.
>>
>>
>> On Thu, Feb 13, 2025 at 3:38 PM David Phillip Oster <
>> davidphilliposter@gmail.com> wrote:
>>
>>> Example of how to run OpenSCAD from the command line and parsing the
>>> output from stderr/stdout
>>>
>>> Given the commandExample.scad file:
>>>
>>> echo("## My first test line");
>>>
>>> difference(){
>>>
>>> cube(25,center=true);
>>>
>>> cylinder(25,r=10+2*0.1,center=true);
>>>
>>> }
>>>
>>>
>>> cylinder(25,r=10,center=true);
>>>
>>> echo("## My last test line");
>>>
>>> The following command line, for me, on macOS, using bash as my shell:
>>>
>>> $ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD
>>> commandExample.scad -o a.stl 2>&1 | grep 'ECHO: \"##' | sed -e 's/ECHO:
>>> \"## //' | sed -e 's/"$//'
>>>
>>>
>>> prints:
>>>
>>> My first test line
>>>
>>> My last test line
>>>
>>>
>>> Discussion:
>>>
>>>
>>> The 2>&1 maps stderr to stdout. The grep filters out only my echo
>>> lines. The two sed commands remove the guard boilerplate, extracting
>>> just the content I want to continue processing. A sed expert could
>>> probably coalesce the grep | sed | sed to a single sed command.
>>>
>>> On Thu, Feb 13, 2025 at 3:00 PM John David via Discuss <
>>> discuss@lists.openscad.org> wrote:
>>>
>>>> BTW, does anyone have an example of how to run OpenSCAD from the
>>>> command line and parsing the output from stderr/stdout? When trying to
>>>> build various version from source I broke some things and have not gotten
>>>> it all sorted out yet. So, in the interim...
>>>>
>>>> EBo --
>>>>
>>>> On Thu, Feb 13, 2025 at 11:34 AM Jordan Brown via Discuss <
>>>> discuss@lists.openscad.org> wrote:
>>>>
>>>>> On 2/13/2025 6:41 AM, Raymond West via Discuss wrote:
>>>>>
>>>>> You can write text to the screen/viewport, and save as pdf., or other
>>>>> 2d/3d formats, if you need to read the values. If you want to input that as
>>>>> text to another program, then that will need other manipulation. Text is
>>>>> not exported as text, but as an image of the text. One method would be to
>>>>> display output as a qr code, plenty of software for handling that.
>>>>>
>>>>>
>>>>> It's only exported as an image of the text if you take a screen shot.
>>>>> Ordinary select/copy/paste works fine and transfers the text as text.
>>>>>
>>>>> module outline(t) {
>>>>> difference() {
>>>>> offset(t/2) children();
>>>>> offset(-t/2) children();
>>>>> }
>>>>> }
>>>>>
>>>>> color("black") outline(0.3) text("Hello world!");
>>>>>
>>>>> yields console output:
>>>>>
>>>>> Parsing design (AST generation)...
>>>>> Saved backup file:
>>>>> C:/Users/Jordan/OneDrive/Documents/OpenSCAD/backups/unsaved-backup-cSChDmHh.scad
>>>>> Compiling design (CSG Tree generation)...
>>>>> Compiling design (CSG Products generation)...
>>>>> Geometries in cache: 7
>>>>> Geometry cache size in bytes: 59168
>>>>> CGAL Polyhedrons in cache: 0
>>>>> CGAL cache size in bytes: 0
>>>>> Compiling design (CSG Products normalization)...
>>>>> Normalized tree has 2 elements!
>>>>> Compile and preview finished.
>>>>> Total rendering time: 0:00:00.051
>>>>>
>>>>> _______________________________________________
>>>>> 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
>
MP
Marcus Poller
Fri, Feb 14, 2025 8:24 AM
David Phillip Oster via Discuss wrote:
$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD commandExample.scad -o
a.stl 2>&1 | grep 'ECHO: "##' | sed -e 's/ECHO: "## //' | sed -e 's/"$//'
David sparked my curiousity.
I would like to add a Makefile - do demonstrate rendering to STL as well as preview image generation
cmdswitch:=--render #--backend=Manifold
default:
openscad cmdline.scad -o cmdline.stl $(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25,0];' -o cmdline1.png $(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25+90,0];' -o cmdline2.png $(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25+180,0];' -o cmdline3.png $(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25+270,0];' -o cmdline3.png $(cmdswitch)
sources:
Happy Hacking!
Marcus
David Phillip Oster via Discuss wrote:
> $ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD commandExample.scad -o
> a.stl 2>&1 | grep 'ECHO: \"##' | sed -e 's/ECHO: \"## //' | sed -e 's/"$//'
David sparked my curiousity.
I would like to add a Makefile - do demonstrate rendering to STL as well as preview image generation
cmdswitch:=--render #--backend=Manifold
default:
openscad cmdline.scad -o cmdline.stl $(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25,0];' -o cmdline1.png $(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25+90,0];' -o cmdline2.png $(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25+180,0];' -o cmdline3.png $(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25+270,0];' -o cmdline3.png $(cmdswitch)
# sources:
# https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment
# https://openscad.org/cheatsheet/
Happy Hacking!
Marcus
JD
John David
Fri, Feb 14, 2025 11:59 PM
Nice! Thank you. I look forward when I get this going again.
On Fri, Feb 14, 2025 at 3:24 AM Marcus Poller via Discuss <
discuss@lists.openscad.org> wrote:
David Phillip Oster via Discuss wrote:
$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD commandExample.scad
a.stl 2>&1 | grep 'ECHO: "##' | sed -e 's/ECHO: "## //' | sed -e
's/"$//'
David sparked my curiousity.
I would like to add a Makefile - do demonstrate rendering to STL as well
as preview image generation
cmdswitch:=--render #--backend=Manifold
default:
openscad cmdline.scad -o cmdline.stl $(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25,0];' -o cmdline1.png
$(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25+90,0];' -o cmdline2.png
$(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25+180,0];' -o cmdline3.png
$(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25+270,0];' -o cmdline3.png
$(cmdswitch)
sources:
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment
Happy Hacking!
Marcus
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Nice! Thank you. I look forward when I get this going again.
On Fri, Feb 14, 2025 at 3:24 AM Marcus Poller via Discuss <
discuss@lists.openscad.org> wrote:
> David Phillip Oster via Discuss wrote:
> > $ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD commandExample.scad
> -o
> > a.stl 2>&1 | grep 'ECHO: \"##' | sed -e 's/ECHO: \"## //' | sed -e
> 's/"$//'
>
> David sparked my curiousity.
>
> I would like to add a Makefile - do demonstrate rendering to STL as well
> as preview image generation
>
> cmdswitch:=--render #--backend=Manifold
>
> default:
> openscad cmdline.scad -o cmdline.stl $(cmdswitch)
> openscad cmdline.scad -D'$$vpr=[-10,25,0];' -o cmdline1.png
> $(cmdswitch)
> openscad cmdline.scad -D'$$vpr=[-10,25+90,0];' -o cmdline2.png
> $(cmdswitch)
> openscad cmdline.scad -D'$$vpr=[-10,25+180,0];' -o cmdline3.png
> $(cmdswitch)
> openscad cmdline.scad -D'$$vpr=[-10,25+270,0];' -o cmdline3.png
> $(cmdswitch)
>
> # sources:
> #
> https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment
> # https://openscad.org/cheatsheet/
>
>
> Happy Hacking!
> Marcus
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
GB
Glenn Butcher
Sat, Feb 15, 2025 1:40 AM
I wrote a OpenSCAD-specific make, called aptly scadmake:
https://github.com/butcherg/SCADMake
It walks the include/use statements of the .scad scripts in a directory,
will re-run the specified OpenSCAD command when the output file is older
than the associated .scad file.
It'll alternatively generate a Makefile if you prefer to use that.
No releases, you have to compile it yourself. No dependencies. I've
compiled and used it successfully in AMD64 Ubuntu and Windows with MSYS2.
On 2/14/2025 4:59 PM, John David via Discuss wrote:
Nice! Thank you. I look forward when I get this going again.
On Fri, Feb 14, 2025 at 3:24 AM Marcus Poller via Discuss
discuss@lists.openscad.org wrote:
David Phillip Oster via Discuss wrote:
$ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD
a.stl 2>&1 | grep 'ECHO: "##' | sed -e 's/ECHO: "## //' | sed
-e 's/"$//'
David sparked my curiousity.
I would like to add a Makefile - do demonstrate rendering to STL
as well as preview image generation
cmdswitch:=--render #--backend=Manifold
default:
openscad cmdline.scad -o cmdline.stl $(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25,0];' -o
cmdline1.png $(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25+90,0];' -o
cmdline2.png $(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25+180,0];' -o
cmdline3.png $(cmdswitch)
openscad cmdline.scad -D'$$vpr=[-10,25+270,0];' -o
cmdline3.png $(cmdswitch)
# sources:
#
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment
# https://openscad.org/cheatsheet/
Happy Hacking!
Marcus
_______________________________________________
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
I wrote a OpenSCAD-specific make, called aptly scadmake:
https://github.com/butcherg/SCADMake
It walks the include/use statements of the .scad scripts in a directory,
will re-run the specified OpenSCAD command when the output file is older
than the associated .scad file.
It'll alternatively generate a Makefile if you prefer to use that.
No releases, you have to compile it yourself. No dependencies. I've
compiled and used it successfully in AMD64 Ubuntu and Windows with MSYS2.
On 2/14/2025 4:59 PM, John David via Discuss wrote:
> Nice! Thank you. I look forward when I get this going again.
>
> On Fri, Feb 14, 2025 at 3:24 AM Marcus Poller via Discuss
> <discuss@lists.openscad.org> wrote:
>
> David Phillip Oster via Discuss wrote:
> > $ /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD
> commandExample.scad -o
> > a.stl 2>&1 | grep 'ECHO: \"##' | sed -e 's/ECHO: \"## //' | sed
> -e 's/"$//'
>
> David sparked my curiousity.
>
> I would like to add a Makefile - do demonstrate rendering to STL
> as well as preview image generation
>
> cmdswitch:=--render #--backend=Manifold
>
> default:
> openscad cmdline.scad -o cmdline.stl $(cmdswitch)
> openscad cmdline.scad -D'$$vpr=[-10,25,0];' -o
> cmdline1.png $(cmdswitch)
> openscad cmdline.scad -D'$$vpr=[-10,25+90,0];' -o
> cmdline2.png $(cmdswitch)
> openscad cmdline.scad -D'$$vpr=[-10,25+180,0];' -o
> cmdline3.png $(cmdswitch)
> openscad cmdline.scad -D'$$vpr=[-10,25+270,0];' -o
> cmdline3.png $(cmdswitch)
>
> # sources:
> #
> https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment
> # https://openscad.org/cheatsheet/
>
>
> Happy Hacking!
> Marcus
> _______________________________________________
> 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, Feb 15, 2025 3:18 AM
On 2/14/2025 5:40 PM, Glenn Butcher via Discuss wrote:
It walks the include/use statements of the .scad scripts in a
directory, will re-run the specified OpenSCAD command when the output
file is older than the associated .scad file.
It looks like you can get this automatically using the -d <name>
option. This is discussed in the OpenSCAD manual
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment#Makefile_example.
Here's a slightly different pattern that I wrote more or less on my own
before looking at the manual. It seems to work. I haven't used it in
production; I just put it together today.
# Give a list of top-level SCAD files here.
SCAD = a.scad b.scad
# Rest is boilerplate.
# Given the list of SCAD files, generate the corresponding list of STL files.
STL = $(SCAD:%.scad=%.stl)
# This is the rule that creates an STL file from an SCAD file. Note the -d $*.d that generates
# a dependency file as a side effect.
%.stl: %.scad
openscad -o $@ -d $*.d $<
# By default (since this is the first rule in the file) build all of the STLs.
all: $(STL)
# Include any previously-generated dependency files. Ignore any errors so that this works on the
# first run.
-include $(SCAD:%.scad=%.d)
# Not directly part of the solution, but makes diagnosing Makefiles easier. "make print-NAME"
# to print the value of $(NAME).
print-% :
@echo $* = $($*)
I'm not sure what the "-m make" option is for in the manual's example.
Perhaps it is to automatically generate any included .scad files or
imported files that are missing. My gut reaction is that that's a rare
enough case that I don't mind explicitly representing it in the Makefile.
On 2/14/2025 5:40 PM, Glenn Butcher via Discuss wrote:
> It walks the include/use statements of the .scad scripts in a
> directory, will re-run the specified OpenSCAD command when the output
> file is older than the associated .scad file.
It looks like you can get this automatically using the -d <name>
option. This is discussed in the OpenSCAD manual
<https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment#Makefile_example>.
Here's a slightly different pattern that I wrote more or less on my own
before looking at the manual. It seems to work. I haven't used it in
production; I just put it together today.
# Give a list of top-level SCAD files here.
SCAD = a.scad b.scad
# Rest is boilerplate.
# Given the list of SCAD files, generate the corresponding list of STL files.
STL = $(SCAD:%.scad=%.stl)
# This is the rule that creates an STL file from an SCAD file. Note the -d $*.d that generates
# a dependency file as a side effect.
%.stl: %.scad
openscad -o $@ -d $*.d $<
# By default (since this is the first rule in the file) build all of the STLs.
all: $(STL)
# Include any previously-generated dependency files. Ignore any errors so that this works on the
# first run.
-include $(SCAD:%.scad=%.d)
# Not directly part of the solution, but makes diagnosing Makefiles easier. "make print-NAME"
# to print the value of $(NAME).
print-% :
@echo $* = $($*)
I'm not sure what the "-m make" option is for in the manual's example.
Perhaps it is to automatically generate any included .scad files or
imported files that are missing. My gut reaction is that that's a rare
enough case that I don't mind explicitly representing it in the Makefile.