discuss@lists.openscad.org

OpenSCAD general discussion

View all threads

Re: text output

AM
Adrian Mariano
Tue, Sep 21, 2021 10:58 PM

I thought one of the reasons generic output didn't exist is that it's
a malware enabler.  If OpenSCAD can write arbitrary files it becomes
much more dangerous to run random code that you run across.

On Tue, Sep 21, 2021 at 6:54 PM William F. Adams via Discuss
discuss@lists.openscad.org wrote:

---------- Forwarded message ----------
From: "William F. Adams" willadams@aol.com
To: "discuss@lists.openscad.org" discuss@lists.openscad.org
Cc:
Bcc:
Date: Tue, 21 Sep 2021 22:53:51 +0000 (UTC)
Subject: [OpenSCAD] Re: text output
Yes, but one still has to do that, for each file, for each time it's run, and set it up for each project. That's a lot of duplicated effort.

I don't want to use OpenSCAD as a word-processor --- I want to use it as a programmatic system for generating geometry and associated files:

  • bill of material
  • assembly instructions
  • G-Code for cutting out parts
  • SVGs w/ curves as opposed to polylines

Lots of folks have had this need, and lots of folks have solved it in a number of ways (and I appreciate the right-click menu entries which make working w/ the Log easier), but it would help a lot of folks work much more comfortably and efficiently to have a way to write out text files which are directly usable and with the ability to control the file extension.

What would be involved in creating a Bounty for this?

How should it be worded?

Anyone able to estimate how much would be needed to attract the attention of a developer?

William

---------- Forwarded message ----------
From: "William F. Adams via Discuss" discuss@lists.openscad.org
To: "discuss@lists.openscad.org" discuss@lists.openscad.org
Cc: "William F. Adams" willadams@aol.com
Bcc:
Date: Tue, 21 Sep 2021 22:53:51 +0000 (UTC)
Subject: [OpenSCAD] Re: text output


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

I thought one of the reasons generic output didn't exist is that it's a malware enabler. If OpenSCAD can write arbitrary files it becomes much more dangerous to run random code that you run across. On Tue, Sep 21, 2021 at 6:54 PM William F. Adams via Discuss <discuss@lists.openscad.org> wrote: > > > > > ---------- Forwarded message ---------- > From: "William F. Adams" <willadams@aol.com> > To: "discuss@lists.openscad.org" <discuss@lists.openscad.org> > Cc: > Bcc: > Date: Tue, 21 Sep 2021 22:53:51 +0000 (UTC) > Subject: [OpenSCAD] Re: text output > Yes, but one still has to do that, for each file, for each time it's run, and set it up for each project. That's a lot of duplicated effort. > > I don't want to use OpenSCAD as a word-processor --- I want to use it as a programmatic system for generating geometry and associated files: > > - bill of material > - assembly instructions > - G-Code for cutting out parts > - SVGs w/ curves as opposed to polylines > > Lots of folks have had this need, and lots of folks have solved it in a number of ways (and I appreciate the right-click menu entries which make working w/ the Log easier), but it would help a lot of folks work much more comfortably and efficiently to have a way to write out text files which are directly usable and with the ability to control the file extension. > > What would be involved in creating a Bounty for this? > > How should it be worded? > > Anyone able to estimate how much would be needed to attract the attention of a developer? > > William > > > > ---------- Forwarded message ---------- > From: "William F. Adams via Discuss" <discuss@lists.openscad.org> > To: "discuss@lists.openscad.org" <discuss@lists.openscad.org> > Cc: "William F. Adams" <willadams@aol.com> > Bcc: > Date: Tue, 21 Sep 2021 22:53:51 +0000 (UTC) > Subject: [OpenSCAD] Re: text output > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
WF
William F. Adams
Tue, Sep 21, 2021 11:54 PM

Adrian Mariano wrote:

I thought one of the reasons generic output didn't exist is that it's
a malware enabler.  If OpenSCAD can write arbitrary files it becomes
much more dangerous to run random code that you run across.

That's why it would be an option only enabled by the user if they wished.
It could be paired w/ a security check at install, so it would only be activated if folks chose to enable it when installing when suitably informed.
William

Adrian Mariano wrote: >I thought one of the reasons generic output didn't exist is that it's >a malware enabler.  If OpenSCAD can write arbitrary files it becomes >much more dangerous to run random code that you run across. That's why it would be an option only enabled by the user if they wished. It could be paired w/ a security check at install, so it would only be activated if folks chose to enable it when installing when suitably informed. William
JB
Jordan Brown
Wed, Sep 22, 2021 12:18 AM

On 9/21/2021 3:58 PM, Adrian Mariano wrote:

I thought one of the reasons generic output didn't exist is that it's
a malware enabler.  If OpenSCAD can write arbitrary files it becomes
much more dangerous to run random code that you run across.

Yeah, reading and, especially, writing arbitrary files is terrifying.


I don't think it would be difficult at all to add a feature, one way or
another, that would let you emit unadorned text to the "echo" output
stream, or to create a new kind of output that consists only of this
unadorned text.

But at the same time it is hard to get excited about the need for it,
when trivial post-processing has the same effect.

In your OpenSCAD program, echo your data, with each line as one string. 
Have a script run your OpenSCAD program.  Capture the output, perhaps
explicitly into the "echo" output type or perhaps as a side effect of
generating STLs.  Strip off the echo noise and any other noise with a
trivial sed invocation:

sed -n 's/^ECHO: "\(.*\)"$/\1/p' $file

Here's the snippet that I use to do something similar:

    openscad -D "\$content_inventory=\"$2\"" -o junk.stl "$1" 2>&1 |
	tr -d '\r' |
	sed -n -e 's/^ECHO: "PART", "\(.*\)"$/\1/p' |
	sed 's/", "/ /g'

The corresponding OpenSCAD snippets look like:

            echo("PART", name, camera);
On 9/21/2021 3:58 PM, Adrian Mariano wrote: > I thought one of the reasons generic output didn't exist is that it's > a malware enabler. If OpenSCAD can write arbitrary files it becomes > much more dangerous to run random code that you run across. Yeah, reading and, especially, writing arbitrary files is terrifying. --- I don't think it would be difficult at all to add a feature, one way or another, that would let you emit unadorned text to the "echo" output stream, or to create a new kind of output that consists only of this unadorned text. But at the same time it is hard to get excited about the need for it, when trivial post-processing has the same effect. In your OpenSCAD program, echo your data, with each line as one string.  Have a script run your OpenSCAD program.  Capture the output, perhaps explicitly into the "echo" output type or perhaps as a side effect of generating STLs.  Strip off the echo noise and any other noise with a trivial sed invocation: sed -n 's/^ECHO: "\(.*\)"$/\1/p' $file Here's the snippet that I use to do something similar: openscad -D "\$content_inventory=\"$2\"" -o junk.stl "$1" 2>&1 | tr -d '\r' | sed -n -e 's/^ECHO: "PART", "\(.*\)"$/\1/p' | sed 's/", "/ /g' The corresponding OpenSCAD snippets look like: echo("PART", name, camera);
L
larry
Wed, Sep 22, 2021 1:56 AM

On Tue, 2021-09-21 at 18:58 -0400, Adrian Mariano wrote:

I thought one of the reasons generic output didn't exist is that it's
a malware enabler.  If OpenSCAD can write arbitrary files it becomes
much more dangerous to run random code that you run across.

Wouldn't it reduce the likelihood of a security breach if you could
call it with a command line option, something like

openscad -e >filepah/name blah blah

On Tue, 2021-09-21 at 18:58 -0400, Adrian Mariano wrote: > I thought one of the reasons generic output didn't exist is that it's > a malware enabler. If OpenSCAD can write arbitrary files it becomes > much more dangerous to run random code that you run across. Wouldn't it reduce the likelihood of a security breach if you could call it with a command line option, something like openscad -e >filepah/name blah blah
JB
Jordan Brown
Wed, Sep 22, 2021 2:05 AM

On 9/21/2021 6:56 PM, larry wrote:

Wouldn't it reduce the likelihood of a security breach if you could
call it with a command line option, something like
openscad -e >filepah/name blah blah

That already works, give or take the fact that the output is noisy.

What some people are asking for is the ability to have the OpenSCAD
program say "write <this text> into a file named <this>".

On 9/21/2021 6:56 PM, larry wrote: > Wouldn't it reduce the likelihood of a security breach if you could > call it with a command line option, something like > openscad -e >filepah/name blah blah That already works, give or take the fact that the output is noisy. What some people are asking for is the ability to have the OpenSCAD program say "write <this text> into a file named <this>".
NH
nop head
Wed, Sep 22, 2021 6:47 AM

I already make Bills of materials and assembly instructions using echo()
and Python and $variables to enable it. So I set $bom=2 on the command line
and produce a .echo file and then parse the result. I also scrape Markdown
comments from the code. I set $explode to 1 to make exploded assembly views
to go into the assembly instructions. It is all OpenSource, an example
here:
https://github.com/nophead/NopSCADlib/tree/master/examples/MainsBreakOutBox.

If I wanted to output g-code or SVG I would just add another $variable that
enabled some different echos and write a simple Python script to set that
on the command line and process the echos into the format I want.

On Wed, 22 Sept 2021 at 03:05, Jordan Brown openscad@jordan.maileater.net
wrote:

On 9/21/2021 6:56 PM, larry wrote:

Wouldn't it reduce the likelihood of a security breach if you could call
it with a command line option, something like

openscad -e >filepah/name blah blah

That already works, give or take the fact that the output is noisy.

What some people are asking for is the ability to have the OpenSCAD
program say "write <this text> into a file named <this>".


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

I already make Bills of materials and assembly instructions using echo() and Python and $variables to enable it. So I set $bom=2 on the command line and produce a .echo file and then parse the result. I also scrape Markdown comments from the code. I set $explode to 1 to make exploded assembly views to go into the assembly instructions. It is all OpenSource, an example here: https://github.com/nophead/NopSCADlib/tree/master/examples/MainsBreakOutBox. If I wanted to output g-code or SVG I would just add another $variable that enabled some different echos and write a simple Python script to set that on the command line and process the echos into the format I want. On Wed, 22 Sept 2021 at 03:05, Jordan Brown <openscad@jordan.maileater.net> wrote: > On 9/21/2021 6:56 PM, larry wrote: > > Wouldn't it reduce the likelihood of a security breach if you could call > it with a command line option, something like > > openscad -e >filepah/name blah blah > > > That already works, give or take the fact that the output is noisy. > > What some people are asking for is the ability to have the OpenSCAD > program say "write <this text> into a file named <this>". > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >