Is there a programmer here who could make a minor change in OpenSCAD?

Trying to get a design cut, but am stymied on the CAM end of things — if I could just write out a text file from OpenSCAD I’d have it I think.

All I need is for any text which is added to the Console via Echo() to be exported via a menu entry (yes, I know I could filter it out w/ a utility or fancy search/replace but I want this to be something that a naïve user could do). Asked for it in an Issue:

but got shot down.

There’s on-going discussion in a different issue as well as the mailing list — I think it’d be accepted if it came in over the transom as a code patch, at least I hope it would.

Simplest expression:

Just adding a parallel output where if one called echo() only that text was written out to a second file (with a user configurable file extension) would work — no added menu entry, just a pair of configuration options:

[ ] write out echo text in separate file
[ ] custom file extension, use ____ instead of .txt

that’s all that would be necessary to allow folks to experiment with directly creating G-Code for CAM. (EDIT: and doing lots of other things such as compiling a B.O.M.)

If anyone is able to look into this I’d be grateful.

Hey Will,

I’ve used OpenSCAD a fair amount. I had a look at the code and could add a writeln(“”,{}) type of function to their grammar that would do the sort of thing you are after.

If this was a personal build for you on a single platform, then that’s straightforward. But if you wanted it to be generic and available to others then the OpenSCAD team would need to accept a pull request, and they seem to be reluctant about the overall concept.

So the code changes are easy, but making, updating and distributing builds is more complicated… and, well, tedious :slight_smile:

1 Like

Thanks! I really want this in the available builds and agree the politics of it are the problem.

Turns out that the code is pretty much already in place, see:

All that is necessary would be:

  • a preference for writing out the file

  • a way to run OpenSCAD with the equivalent of the command-line option:

    -o file.echo

which only captures the echoes — ideally after stripping out the extraneous text, if not, a way to run sed or some other suitable tool.

  • a preference (or command) in the language for specifying the file extension

I’m hoping that not asking for a new menu command, and burying this in the preferences will make this palatable.

If you’re happy with that sort of solution, why not run the following:

$ cat file.echo | grep -e "^ECHO:" | cut -f2 -d'"' >

This will work on macOS or WSL on windows… put it into a script that takes the filename parameter and substitutes it, and you are done, no?

1 Like

Because I don’t want the headache of telling everyone who ever uses one of my projects to do that.

The suggestion is that people who run this run:

$ mybox.scad

and end up with the file ready to go.

1 Like

Thanks. I don’t want to have to distribute the script — the thing is, being able to write out the echoed text would also be useful folks using OpenSCAD more generally — generating a B.O.M. comes to mind.

If it won’t just work directly, I guess I’ll either switch to AngelCAD or FreeCAD.

Fair enough.

You could write out the commands in the first ECHO statement instead. Then to generate the NC file the person would just need to remove the first ECHO: and then run the output to generate the NC file.

For example, write this:

ECHO: (grep -e "^ECHO:" | cut -f2 -d'"') << 'ECHO: EOF'
ECHO: "G0 X0 Y0 Z8"
ECHO: "G1 Z-3.175 F150"
ECHO: "G1 X0 Y4.20625 F600"
ECHO: "G0 Z8"
ECHO: "G0 X6.89856 Y0 Z8"
ECHO: "G1 Z-3.175 F150"
ECHO: "G1 X6.89856 Y4.20625 F600"
ECHO: "G0 Z8"

Then all you need to do is remove the first ECHO: (ie: 5 characters) and then: bash file.echo

1 Like

Yeah, I miss the concept of Oberon and everything being a script one could run.

This topic was automatically closed after 30 days. New replies are no longer allowed.