running PythonSCAD from the command line

11 views
Skip to first unread message

John David

unread,
Mar 15, 2026, 12:37:37 PM (7 days ago) Mar 15
to PythonSCAD
I have run OpenSCAD from the command line a few times in the past.  When I tried it again (after reading a discussion on the OpenSCAD list), I found that the "-i <file>" argument is not implemented in PythonSCAD.  Is there a reason this was not pulled in from upstream?  Just checking.

  EBo --

Matthieu Hendriks

unread,
Mar 16, 2026, 3:26:35 AM (7 days ago) Mar 16
to John David, PythonSCAD
Hey John,

This weekend I run pythonscad from a (linux) script to generate some 3mf files and it was running fine. Maybe the commandline options changed.

Op zo 15 mrt 2026 om 17:37 schreef John David <ebo....@gmail.com>:
I have run OpenSCAD from the command line a few times in the past.  When I tried it again (after reading a discussion on the OpenSCAD list), I found that the "-i <file>" argument is not implemented in PythonSCAD.  Is there a reason this was not pulled in from upstream?  Just checking.

  EBo --

--
You received this message because you are subscribed to the Google Groups "PythonSCAD" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pythonscad+...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/pythonscad/CAAF3RYt%2B%3DAsAch-jW465GXRxswmL67j%3Dt5zXvBC0mVHLBhAVMQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Guenther Sohler

unread,
Mar 16, 2026, 5:24:51 AM (7 days ago) Mar 16
to John David, PythonSCAD
Hi John,

I also tested in latest compiled master of openscad,

./openscad -i /path/t/file.scad

doesn't work there either. Did it work there before ?

in contrast: if i is meant to be an abbreviation:

./pythonscad --info
./pythonscad --imagesize=1024,768


both work



On Sun, Mar 15, 2026 at 5:37 PM John David <ebo....@gmail.com> wrote:
I have run OpenSCAD from the command line a few times in the past.  When I tried it again (after reading a discussion on the OpenSCAD list), I found that the "-i <file>" argument is not implemented in PythonSCAD.  Is there a reason this was not pulled in from upstream?  Just checking.

  EBo --

--

John David

unread,
Mar 16, 2026, 7:15:43 AM (6 days ago) Mar 16
to Guenther Sohler, PythonSCAD
Yea, I had some simple SVG's created (for a previous run at the gcode toolchain), and it would create them.  I think it was a year or more ago that I tried this.  Others on the list are using this and thought I would ask.

Guenther Sohler

unread,
Mar 16, 2026, 7:34:31 AM (6 days ago) Mar 16
to John David, PythonSCAD
maybe you can add a sample command line, which worked before ?


Matthieu Hendriks

unread,
Mar 16, 2026, 7:37:23 AM (6 days ago) Mar 16
to John David, Guenther Sohler, PythonSCAD
params_str="{\\\"run\\\":\\\""$run"\\\",\\\"label\\\":\\\""$label"\\\"}"
pythonscad --trust-python -D'params_str="'"$params_str"'"' planklabel.py -o "dummy.3mf"

So you have to trust python, no -i needed,and a output file.

Op ma 16 mrt 2026 om 12:15 schreef John David <ebo....@gmail.com>:

John David

unread,
Mar 16, 2026, 4:03:42 PM (6 days ago) Mar 16
to Matthieu Hendriks, Guenther Sohler, PythonSCAD
Interesting.  That worked.  Well kinda...

My GCode color examples do not output any images, but directly exports the gcode fro the model.  I was able to get it to work by giving it a dummy -o <outfile> parameter, but it never output any image.  Not sure the best way to fix this, but I now know how to make it "just do the thing".

Thanks!

  EBo --

Matthieu Hendriks

unread,
Mar 17, 2026, 3:17:27 AM (6 days ago) Mar 17
to John David, Guenther Sohler, PythonSCAD
I do the export in the program itself. Thats where the params_str is used for to pass the parameters to my design.

params_str="{\\\"run\\\":\\\""$run"\\\",\\\"label\\\":\\\""$label"\\\"}"
pythonscad --trust-python -D'params_str="'"$params_str"'"' planklabel.py -o "dummy.3mf"

In the start of the program I load the params, set variables and  create the export.
If you need directions I can dig up the code for this, but I'm not at home now.
It's also available in the crashing issue I mentioned earlier where I included the code mecano.py and mhlib.py 



Op ma 16 mrt 2026 om 21:03 schreef John David <ebo....@gmail.com>:

Guenther Sohler

unread,
Mar 17, 2026, 3:46:44 AM (6 days ago) Mar 17
to Matthieu Hendriks, John David, PythonSCAD
you don't have to specify such a complicated param_str.
instead you can pass several -D parameters.
Last but not least. With python there are so many more options. you could open a file and get the information from there.


cheers

Matthieu Hendriks

unread,
Mar 17, 2026, 4:42:49 AM (6 days ago) Mar 17
to Guenther Sohler, John David, PythonSCAD
Sure, for me using a json string as one parameter is more flexible. :) 

Op di 17 mrt 2026 om 08:46 schreef Guenther Sohler <guenthe...@gmail.com>:

John David

unread,
Mar 17, 2026, 5:38:49 PM (5 days ago) Mar 17
to Matthieu Hendriks, Guenther Sohler, PythonSCAD
Maybe we should add the ability to pass in a non-output file, like "-o -", or trigger the run some other way like "--run-script" or "--cli"

Guenther Sohler

unread,
Mar 18, 2026, 3:24:31 AM (5 days ago) Mar 18
to John David, Matthieu Hendriks, PythonSCAD
That would definitely be very easy. just replacing - with /dev/stdout
Not sure if it makes so much sense in windows ...

John David

unread,
Mar 18, 2026, 9:06:56 AM (4 days ago) Mar 18
to Guenther Sohler, Matthieu Hendriks, PythonSCAD
The trick will be to come up with something that makes sense across systems, and works with both the GUI and CLI.  The trick will be to figure out what all the "run in place" requires to trigger.

I'll give it some thought.

  EBo --

nomike Postmann

unread,
Mar 19, 2026, 10:34:50 PM (3 days ago) Mar 19
to PythonSCAD
I just read this conversation, but I'm a bit at a loss what `-i <file>` is supposed to do?

If you want to open a design in the GUI, just specify it as a parameter (e.g. `pythonscad foo.py`).
To render the design directly and output the result to a file instead of launching the GUI, you can use the `--o` and `--export-format` parameters.

And as per documentation (`man pythonscad`) you can use `-o -` to specify that the result should be written to stdout, where you can then pipe it to another command for example.
This is similar to most other command line tools.

nomike

Guenther Sohler

unread,
Mar 20, 2026, 4:06:40 AM (3 days ago) Mar 20
to nomike Postmann, PythonSCAD
The option -i does not do anything, not even for OpenSCAD in any version

John just tried that similar to other programs

-i ... input file to program
-o output file from program

suppose the issue is resolved already


John David

unread,
Mar 20, 2026, 7:38:02 AM (2 days ago) Mar 20
to Guenther Sohler, nomike Postmann, PythonSCAD
If the -i does not do anything, then it should be removed upstream, but if memory serves, it was requited in OpenSCAD.  Requiring an extra CLI (eg. '-o dummy.out') that does nothing but is suggestive of actually doing something, AND is required to trigger a different run style violates the principle of least surprise.  It would make more sense to add an argument that forces the run path to be GUI-less (maybe --no-gui, --background, ... with short arguments of -B or /B on Win* machines).  Just need to know what to call it.  What are your thoughts for a consensus?  It would be nice to have folks chime in that run on Win* or Macs.

  EBo --

nomike Postmann

unread,
Mar 20, 2026, 5:39:41 PM (2 days ago) Mar 20
to PythonSCAD
From both OpenSCAD and PythhonSCAD I'm getting an "unrecognized option" error for "-i". It's also neither mentioned on the "--help" page nor on the man-page.

At both OpenSCAD and PythonSCAD it is mentioned on the `--help` and on the manpage, that you could use the "-o | --o" to render a design directly without engaging the GUI.

So there is already a flag and it's clearly documented.

And the documentation also mentions that you could specify "-" as a filename to have the rendering be printed to the terminal instead of it being written to a file.

So that's also covered.

Or am I missing something?

nomike

John David

unread,
Mar 21, 2026, 12:30:57 AM (yesterday) Mar 21
to nomike Postmann, PythonSCAD
Specifying "-" for a filename triggers an error...  Just say'n.

Matthieu Hendriks

unread,
Mar 21, 2026, 6:00:57 AM (yesterday) Mar 21
to nomike Postmann, PythonSCAD
Don't fix it if it aint broke :)

the -i normaly stands for include something you are not including a file you are running a file.
same for:
python example.py
pythonscad design.py --trust-python -D ... -o "dummy.3f"  

@gunther: if running from cli the preview variabele is not set, should be nice if this is set default  False. 

Op vr 20 mrt 2026 om 22:39 schreef nomike Postmann <michael....@gmail.com>:

Matthieu Hendriks

unread,
Mar 21, 2026, 6:05:31 AM (yesterday) Mar 21
to Guenther Sohler, John David, PythonSCAD
You got me thinking: I changed the json param_str to something more simple.

params_str="run=$run&label=$label&batch=1"

If you are adding a lot of parameters from a bash script a simple string is easier to build

and then in linux bash script:

pythonscad --trust-python -D'params_str="'"$params_str"'"' planklabel.py -o "dummy.3mf

def loadParams(params_str=None, verbose=False):
    global _params  
    from urllib.parse import parse_qsl
    _params = dict(parse_qsl(params_str))
    return _params



Op di 17 mrt 2026 om 08:46 schreef Guenther Sohler <guenthe...@gmail.com>:
you don't have to specify such a complicated param_str.
Reply all
Reply to author
Forward
0 new messages