CadQuery / cadquery

A python parametric CAD scripting framework based on OCCT
https://cadquery.readthedocs.io
Other
3.69k stars 327 forks source link

Interactive show #1784

Open adam-urbanczyk opened 2 months ago

adam-urbanczyk commented 2 months ago

Currently show is blocking, it would be great to be able to use it multiple times without blocking of the script execution. I see 3 options

  1. Use Qt or Tk, requires integration of the gui event loop with the interpreter (Check how IPython odes that)
  2. Run all the VTK stuff in a separate thread and periodically invoke vtkRenderWindowInteractor.ProcessEvents()
  3. Trame (+pywebview - optional)
adam-urbanczyk commented 2 months ago

Regarding 3, it is easy to get something quickly:

Image

Few observations:

lorenzncode commented 2 months ago

I had some interest in a VTK.js based viewer (maybe as a separate project not built-in to CadQuery). I suppose the viewer could be implemented in other frameworks so Trame is one option.

  1. VTK.js single page application (browser and/or webview) a. Trame b. from scratch (bring your own framework)
adam-urbanczyk commented 2 months ago

FYI: with the current implementation VTK.js based rendering seems to be rather quirky, less so with remote rendering. With VTK 9.4 where is also a WASM option if I understand correctly, but for now we are on 9.3.

More visuals

With Remote

Image

With local (vtk.js)

Image