SolidView is a Python package that provides seamless 3D visualization of objects created with SolidPython2 in Jupyter notebooks. It leverages OpenSCAD for rendering and JupyterSCAD for interactive visualization.
- ๐ฏ Easy Integration: Simple API for viewing SolidPython2 objects
- ๐ฅ๏ธ Cross-Platform: Automatic OpenSCAD detection on Windows, macOS, and Linux
- ๐ฑ Interactive Viewing: Powered by JupyterSCAD for smooth 3D interaction
- ๐พ STL Export: Built-in functionality to save objects as STL files
- ๐งน Smart Cleanup: Automatic temporary file management
- ๐จ Customizable: Configurable viewer dimensions and rendering options
- OpenSCAD: Download and install from https://openscad.org/
- Python 3.8+: Make sure you have Python 3.8 or higher installed
pip install solidviewOr install from source:
git clone https://github.com/mr-kam/solidview.git
cd solidview
pip install -e .For development, install with additional dependencies:
pip install -e ".[dev]"from solid2 import *
from solidview import view3d
# Create a simple object
cube_obj = cube([10, 10, 10])
sphere_obj = sphere(8)
combined = cube_obj + translate([15, 0, 0])(sphere_obj)
# View it in Jupyter
view3d(combined)For more control and better performance with multiple objects:
from solidview import SolidViewer
from solid2 import *
# Create a viewer instance
viewer = SolidViewer()
# Create and view multiple objects
for i in range(3):
obj = translate([i * 20, 0, 0])(cube([10, 10, 10]))
viewer.view(obj, width=800, height=600)
# Save an object as STL
viewer.save_stl(combined, "my_object.stl")If OpenSCAD is installed in a custom location:
from solidview import SolidViewer
viewer = SolidViewer(openscad_exec="/path/to/your/openscad")
viewer.view(your_object)Convenience function for quick 3D visualization.
Parameters:
obj: SolidPython2 object to renderwidth(int): Viewer width in pixels (default: 600)height(int): Viewer height in pixels (default: 600)openscad_exec(str, optional): Path to OpenSCAD executable
Returns: JupyterSCAD viewer widget
Initialize a SolidViewer instance.
Parameters:
openscad_exec(str, optional): Path to OpenSCAD executable
Render and display a 3D object.
Parameters:
obj: SolidPython2 object to renderwidth(int): Viewer width in pixelsheight(int): Viewer height in pixelscleanup(bool): Whether to clean up temporary files
Returns: JupyterSCAD viewer widget
Render an object and save as STL file.
Parameters:
obj: SolidPython2 object to renderoutput_path(str): Path for output STL fileoverwrite(bool): Whether to overwrite existing files
Returns: Path to saved STL file
from solid2 import *
from solidview import view3d
# Create a complex object
base = cube([30, 30, 5])
post = translate([15, 15, 5])(cylinder(r=3, h=20))
hole = translate([15, 15, -1])(cylinder(r=1, h=27))
final_object = base + post - hole
# View with custom dimensions
view3d(final_object, width=800, height=600)from solidview import SolidViewer
from solid2 import *
viewer = SolidViewer()
objects = []
for i in range(5):
obj = translate([i * 15, 0, 0])(
rotate([0, 0, i * 45])(
cube([10, 5, 8])
)
)
objects.append(obj)
# View each object
for i, obj in enumerate(objects):
print(f"Object {i+1}:")
viewer.view(obj)
# Optionally save each one
viewer.save_stl(obj, f"object_{i+1}.stl")If you get an error about OpenSCAD not being found:
- Check Installation: Make sure OpenSCAD is properly installed
- Path Issues: On Windows, ensure OpenSCAD is in one of these locations:
C:\\Program Files\\OpenSCAD\\openscad.exeC:\\Program Files (x86)\\OpenSCAD\\openscad.exe
- Manual Path: Specify the path manually:
viewer = SolidViewer(openscad_exec="C:\\path\\to\\openscad.exe")
If you encounter import errors:
pip install solidpython2 jupyterscad- Memory: Large objects may require more memory
- Complexity: Highly complex objects may take longer to render
- Temporary Files: If cleanup fails, manually delete temp files in your system's temp directory
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- SolidPython2 for the excellent Python โ OpenSCAD interface
- JupyterSCAD for Jupyter notebook integration
- OpenSCAD for the powerful 3D modeling capabilities
- Initial release
- Basic 3D visualization functionality
- Cross-platform OpenSCAD detection
- STL export capability
- Comprehensive documentation and examples