Skip to main content

SolidView

License: MIT Python 3.8+

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.

Features

  • 🎯 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

Installation

Prerequisites

  1. OpenSCAD: Download and install from https://openscad.org/
  2. Python 3.8+: Make sure you have Python 3.8 or higher installed

Install SolidView

pip install solidview

Or install from source:

git clone https://github.com/mr-kam/solidview.git
cd solidview
pip install -e .

Development Installation

For development, install with additional dependencies:

pip install -e ".[dev]"

Quick Start

Basic Usage

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)

Using the SolidViewer Class

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")

Custom OpenSCAD Path

If OpenSCAD is installed in a custom location:

from solidview import SolidViewer

viewer = SolidViewer(openscad_exec="/path/to/your/openscad")
viewer.view(your_object)

API Reference

view3d(obj, width=600, height=600, openscad_exec=None)

Convenience function for quick 3D visualization.

Parameters:

  • obj: SolidPython2 object to render
  • width (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

SolidViewer Class

__init__(openscad_exec=None)

Initialize a SolidViewer instance.

Parameters:

  • openscad_exec (str, optional): Path to OpenSCAD executable

view(obj, width=600, height=600, cleanup=True)

Render and display a 3D object.

Parameters:

  • obj: SolidPython2 object to render
  • width (int): Viewer width in pixels
  • height (int): Viewer height in pixels
  • cleanup (bool): Whether to clean up temporary files

Returns: JupyterSCAD viewer widget

save_stl(obj, output_path, overwrite=False)

Render an object and save as STL file.

Parameters:

  • obj: SolidPython2 object to render
  • output_path (str): Path for output STL file
  • overwrite (bool): Whether to overwrite existing files

Returns: Path to saved STL file

Examples

Complex Object with Multiple Operations

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)

Batch Processing

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")

Troubleshooting

OpenSCAD Not Found

If you get an error about OpenSCAD not being found:

  1. Check Installation: Make sure OpenSCAD is properly installed
  2. Path Issues: On Windows, ensure OpenSCAD is in one of these locations:
    • C:\\Program Files\\OpenSCAD\\openscad.exe
    • C:\\Program Files (x86)\\OpenSCAD\\openscad.exe
  3. Manual Path: Specify the path manually:
    viewer = SolidViewer(openscad_exec="C:\\path\\to\\openscad.exe")
    

Import Errors

If you encounter import errors:

pip install solidpython2 jupyterscad

Rendering Issues

  • 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

Contributing

We welcome contributions! Please see our Contributing Guide for details.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • SolidPython2 for the excellent Python → OpenSCAD interface
  • JupyterSCAD for Jupyter notebook integration
  • OpenSCAD for the powerful 3D modeling capabilities

Changelog

Version 0.1.0

  • Initial release
  • Basic 3D visualization functionality
  • Cross-platform OpenSCAD detection
  • STL export capability
  • Comprehensive documentation and examples

Metadata

Release files for solidview 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for solidview 0.1.0
File Size Uploaded Provenance
solidview-0.1.0.tar.gz 21.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for solidview 0.1.0
File Interpreter ABI Platform
solidview-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.7 kB

Release files / solidview-0.1.0.tar.gz

Download URL solidview-0.1.0.tar.gz
Size 21.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f408a46a27f86153f4f9246b32be1bcbf7cca649151b89a7ddd5e940339cc204
BLAKE2b-256 checksum
How to use checksums
06ef0e10c2b6eac4bae314bbfc4e418058cbb7565fe61d69aa616d3262db3a4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / solidview-0.1.0-py3-none-any.whl

Download URL solidview-0.1.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7fb5b5b6836d35198579cdebbc60ffaa997a4e9acf6c3d0a7802044edd0a168a
BLAKE2b-256 checksum
How to use checksums
95da562b40bf436aa815512471bc40f46d39f7f08805acfc0b56765057102630
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Security for solidview 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page