Show model in interactive cli session.

69 views
Skip to first unread message

Khoroshyy Petro

unread,
Apr 9, 2023, 12:10:33 PM4/9/23
to CadQuery
Hi.
Is there any way to show a model from the interactive Python session in a terminal?
Thanks.
Petro.

--
______________________________
Petro Khoroshyy

Lorenz Neureuter

unread,
Apr 9, 2023, 12:37:01 PM4/9/23
to Khoroshyy Petro, CadQuery
The closest I know of is to run in JupyterLab.

Install with conda:
$ conda install -c conda-forge jupyterlab

or install with pip:
$ pip install jupyterlab


Start JupyterLab:

$ jupyter lab

JupyterLab will open automatically in your browser. Create a Notebook to interactively edit/view CadQuery models.

Call display to show the model.:

display(<Workplane, Shape, or Assembly object>)


--
cadquery home: https://github.com/CadQuery/cadquery
post issues at https://github.com/CadQuery/cadquery/issues
run it at home at : https://github.com/CadQuery/CQ-editor
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/CAEoO5zqDBEGbB4ShPs%2B_O%3D-n-wB-R1JnwLGN%2B5WKQH02x69W1g%40mail.gmail.com.

Khoroshyy Petro

unread,
Apr 9, 2023, 12:42:33 PM4/9/23
to Lorenz Neureuter, CadQuery
Thanks.
That's the way I am running now :)
I was hoping to use vim for Python editing and run it in a way that you can run Matplotlib, for example. But I guess I will need to tame my desires and use it as all normal people do.
Best.
Petro.

Lorenz Neureuter

unread,
Apr 9, 2023, 12:48:05 PM4/9/23
to Khoroshyy Petro, CadQuery
In that case why not try cq-editor?  You can use any text editor with it and use cq-editor only as the viewer.

You can also launch it from the terminal pointing to your script:
$ cq-editor myfile.py

Adam Urbanczyk

unread,
Apr 11, 2023, 3:49:23 PM4/11/23
to CadQuery
BTW: if there is enough interest such functionality could be added (PRs welcome) via VTK which is already a dependency of CQ.

Steve Work

unread,
Apr 11, 2023, 6:13:26 PM4/11/23
to CadQuery
Huh: I have one, incomplete but I've found it useful. Violates CQGI, imposing its own convention on model modules, but maybe a starting point?

github.com:swork/cqmodels.git

I set it up in a venv in the workspace dir, "venv/bin/python -m pip install -e .", and run it against a model like "venv/bin/cqmodel show nethercott_ic/nethercott_ic.py". instances() in the model lists individual .stls, generated in the same dir as the model file and regenerated each time the .py changes. Viewers for each .stl are spawned as subprocesses, and they in turn reload their .stl on each change.

Plenty of bugs, some understood and just not yet squashed (example: things freeze up on syntax trouble with the module, forcing you to kill and restart cqmodel - a dumb consequence of importlib.reload() working only after a successful previous load/reload, and me neglecting to respond to a failure there). I'm short of time to maintain it but will do the best I can - good to have a reason to get it right instead of continuing to work around problems.

My models vary in parameter conventions as I figure out what works. Most likely I threw out a baby by not working within CQGI, but I didn't immediately see a path to module composition there. So feedback is most welcome!

Reply all
Reply to author
Forward
0 new messages