Skip to content

Re/Load and preview SolidPython (and .STL) models when they change on disk. Use your favorite IDE to write python code, and get previews in real time as if you were using OpenSCAD.

License

Notifications You must be signed in to change notification settings

dc740/real-time-mesh-viewer

Repository files navigation

SolidPython realtime model visualizer

tkinter UI screenshot

Use your favorite IDE to write python code, and get previews in real time as if you were using OpenSCAD (*).

This tkinter UI reloads and preview SolidPython (and .STL) models when they change on disk.

It has three modes:

  • STL viewer
  • SCAD viewer (file is auto-converted to STL)
  • .py file viewer (file auto-converted to SCAD and then to STL)

The model will be refreshed automatically in all cases when the original file gets updated. The only requirement in python is for the model to expose these two variables:

solidpython_model
solidpython_segments

The example "basic_geometry.py" (taken from SolidPython) shows how to expose these two variables for the viewer to pick them up and update the view.

The original viewer code came from this other project, and I added the main feature on top of it: https://github.com/precise-simulation/mesh-viewer/

(*) This was just a proof of concept. After all, it's easier to just start OpenSCAD, open the generated scad file (from SolidPython), and enable auto reload in Design -> _Automatic Reload and Preview.

If converting a file takes a lot of time in OpenSCAD, then it will also take a lot of time to load on this project, but since it will be shown much smoother since they are automatically converted to STL files. Try reducing the number of segments, since this speeds up the process.


To run it make sure you have OpenSCAD in your system PATH and start the script:

python meshviewer.py

If vispy refuses to start because of EGL, GL or similar errors, try setting the backend with PYOPENGL_PLATFORM environment variable:

PYOPENGL_PLATFORM=glx python meshviewer.py

Tested on Ubuntu. The typing module requires Python 3.12, but it could be removed to use older versions.

Licensed as AGPL, since this is the original license of the UI that this is based on.

About

Re/Load and preview SolidPython (and .STL) models when they change on disk. Use your favorite IDE to write python code, and get previews in real time as if you were using OpenSCAD.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published