solidview


Namesolidview JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/Mr-KAM/solidview
SummaryA Python package for 3D visualization of SolidPython2 objects
upload_time2025-10-11 11:48:51
maintainerNone
docs_urlNone
authorAnicet Cyrille KAMBOU
requires_python>=3.8
licenseMIT
keywords 3d visualization solidpython openscad jupyter cad
VCS
bugtrack_url
requirements solidpython2 jupyterscad
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SolidView

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)

**SolidView** is a Python package that provides seamless 3D visualization of objects created with [SolidPython2](https://github.com/jeff-dh/SolidPython) 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/](https://openscad.org/)
2. **Python 3.8+**: Make sure you have Python 3.8 or higher installed

### Install SolidView

```bash
pip install solidview
```

Or install from source:

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

### Development Installation

For development, install with additional dependencies:

```bash
pip install -e ".[dev]"
```

## Quick Start

### Basic Usage

```python
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:

```python
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:

```python
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

```python
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

```python
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:
   ```python
   viewer = SolidViewer(openscad_exec="C:\\path\\to\\openscad.exe")
   ```

### Import Errors

If you encounter import errors:

```bash
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](CONTRIBUTING.md) 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](LICENSE) file for details.

## Acknowledgments

- [SolidPython2](https://github.com/jeff-dh/SolidPython) for the excellent Python โ†’ OpenSCAD interface
- [JupyterSCAD](https://github.com/jreiberkyle/jupyterscad) for Jupyter notebook integration
- [OpenSCAD](https://openscad.org/) 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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Mr-KAM/solidview",
    "name": "solidview",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "3d, visualization, solidpython, openscad, jupyter, cad",
    "author": "Anicet Cyrille KAMBOU",
    "author_email": "Anicet Cyrille KAMBOU <kanicetcyrille@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/06/ef/0e10c2b6eac4bae314bbfc4e418058cbb7565fe61d69aa616d3262db3a4b/solidview-0.1.0.tar.gz",
    "platform": null,
    "description": "# SolidView\r\n\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)\r\n\r\n**SolidView** is a Python package that provides seamless 3D visualization of objects created with [SolidPython2](https://github.com/jeff-dh/SolidPython) in Jupyter notebooks. It leverages OpenSCAD for rendering and JupyterSCAD for interactive visualization.\r\n\r\n## Features\r\n\r\n- \ud83c\udfaf **Easy Integration**: Simple API for viewing SolidPython2 objects\r\n- \ud83d\udda5\ufe0f **Cross-Platform**: Automatic OpenSCAD detection on Windows, macOS, and Linux\r\n- \ud83d\udcf1 **Interactive Viewing**: Powered by JupyterSCAD for smooth 3D interaction\r\n- \ud83d\udcbe **STL Export**: Built-in functionality to save objects as STL files\r\n- \ud83e\uddf9 **Smart Cleanup**: Automatic temporary file management\r\n- \ud83c\udfa8 **Customizable**: Configurable viewer dimensions and rendering options\r\n\r\n## Installation\r\n\r\n### Prerequisites\r\n\r\n1. **OpenSCAD**: Download and install from [https://openscad.org/](https://openscad.org/)\r\n2. **Python 3.8+**: Make sure you have Python 3.8 or higher installed\r\n\r\n### Install SolidView\r\n\r\n```bash\r\npip install solidview\r\n```\r\n\r\nOr install from source:\r\n\r\n```bash\r\ngit clone https://github.com/mr-kam/solidview.git\r\ncd solidview\r\npip install -e .\r\n```\r\n\r\n### Development Installation\r\n\r\nFor development, install with additional dependencies:\r\n\r\n```bash\r\npip install -e \".[dev]\"\r\n```\r\n\r\n## Quick Start\r\n\r\n### Basic Usage\r\n\r\n```python\r\nfrom solid2 import *\r\nfrom solidview import view3d\r\n\r\n# Create a simple object\r\ncube_obj = cube([10, 10, 10])\r\nsphere_obj = sphere(8)\r\ncombined = cube_obj + translate([15, 0, 0])(sphere_obj)\r\n\r\n# View it in Jupyter\r\nview3d(combined)\r\n```\r\n\r\n### Using the SolidViewer Class\r\n\r\nFor more control and better performance with multiple objects:\r\n\r\n```python\r\nfrom solidview import SolidViewer\r\nfrom solid2 import *\r\n\r\n# Create a viewer instance\r\nviewer = SolidViewer()\r\n\r\n# Create and view multiple objects\r\nfor i in range(3):\r\n    obj = translate([i * 20, 0, 0])(cube([10, 10, 10]))\r\n    viewer.view(obj, width=800, height=600)\r\n\r\n# Save an object as STL\r\nviewer.save_stl(combined, \"my_object.stl\")\r\n```\r\n\r\n### Custom OpenSCAD Path\r\n\r\nIf OpenSCAD is installed in a custom location:\r\n\r\n```python\r\nfrom solidview import SolidViewer\r\n\r\nviewer = SolidViewer(openscad_exec=\"/path/to/your/openscad\")\r\nviewer.view(your_object)\r\n```\r\n\r\n## API Reference\r\n\r\n### `view3d(obj, width=600, height=600, openscad_exec=None)`\r\n\r\nConvenience function for quick 3D visualization.\r\n\r\n**Parameters:**\r\n\r\n- `obj`: SolidPython2 object to render\r\n- `width` (int): Viewer width in pixels (default: 600)\r\n- `height` (int): Viewer height in pixels (default: 600)\r\n- `openscad_exec` (str, optional): Path to OpenSCAD executable\r\n\r\n**Returns:** JupyterSCAD viewer widget\r\n\r\n### `SolidViewer` Class\r\n\r\n#### `__init__(openscad_exec=None)`\r\n\r\nInitialize a SolidViewer instance.\r\n\r\n**Parameters:**\r\n\r\n- `openscad_exec` (str, optional): Path to OpenSCAD executable\r\n\r\n#### `view(obj, width=600, height=600, cleanup=True)`\r\n\r\nRender and display a 3D object.\r\n\r\n**Parameters:**\r\n\r\n- `obj`: SolidPython2 object to render\r\n- `width` (int): Viewer width in pixels\r\n- `height` (int): Viewer height in pixels\r\n- `cleanup` (bool): Whether to clean up temporary files\r\n\r\n**Returns:** JupyterSCAD viewer widget\r\n\r\n#### `save_stl(obj, output_path, overwrite=False)`\r\n\r\nRender an object and save as STL file.\r\n\r\n**Parameters:**\r\n\r\n- `obj`: SolidPython2 object to render\r\n- `output_path` (str): Path for output STL file\r\n- `overwrite` (bool): Whether to overwrite existing files\r\n\r\n**Returns:** Path to saved STL file\r\n\r\n## Examples\r\n\r\n### Complex Object with Multiple Operations\r\n\r\n```python\r\nfrom solid2 import *\r\nfrom solidview import view3d\r\n\r\n# Create a complex object\r\nbase = cube([30, 30, 5])\r\npost = translate([15, 15, 5])(cylinder(r=3, h=20))\r\nhole = translate([15, 15, -1])(cylinder(r=1, h=27))\r\n\r\nfinal_object = base + post - hole\r\n\r\n# View with custom dimensions\r\nview3d(final_object, width=800, height=600)\r\n```\r\n\r\n### Batch Processing\r\n\r\n```python\r\nfrom solidview import SolidViewer\r\nfrom solid2 import *\r\n\r\nviewer = SolidViewer()\r\n\r\nobjects = []\r\nfor i in range(5):\r\n    obj = translate([i * 15, 0, 0])(\r\n        rotate([0, 0, i * 45])(\r\n            cube([10, 5, 8])\r\n        )\r\n    )\r\n    objects.append(obj)\r\n  \r\n# View each object\r\nfor i, obj in enumerate(objects):\r\n    print(f\"Object {i+1}:\")\r\n    viewer.view(obj)\r\n  \r\n    # Optionally save each one\r\n    viewer.save_stl(obj, f\"object_{i+1}.stl\")\r\n```\r\n\r\n## Troubleshooting\r\n\r\n### OpenSCAD Not Found\r\n\r\nIf you get an error about OpenSCAD not being found:\r\n\r\n1. **Check Installation**: Make sure OpenSCAD is properly installed\r\n2. **Path Issues**: On Windows, ensure OpenSCAD is in one of these locations:\r\n   - `C:\\\\Program Files\\\\OpenSCAD\\\\openscad.exe`\r\n   - `C:\\\\Program Files (x86)\\\\OpenSCAD\\\\openscad.exe`\r\n3. **Manual Path**: Specify the path manually:\r\n   ```python\r\n   viewer = SolidViewer(openscad_exec=\"C:\\\\path\\\\to\\\\openscad.exe\")\r\n   ```\r\n\r\n### Import Errors\r\n\r\nIf you encounter import errors:\r\n\r\n```bash\r\npip install solidpython2 jupyterscad\r\n```\r\n\r\n### Rendering Issues\r\n\r\n- **Memory**: Large objects may require more memory\r\n- **Complexity**: Highly complex objects may take longer to render\r\n- **Temporary Files**: If cleanup fails, manually delete temp files in your system's temp directory\r\n\r\n## Contributing\r\n\r\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\r\n\r\n1. Fork the repository\r\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\r\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\r\n4. Push to the branch (`git push origin feature/amazing-feature`)\r\n5. Open a Pull Request\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## Acknowledgments\r\n\r\n- [SolidPython2](https://github.com/jeff-dh/SolidPython) for the excellent Python \u2192 OpenSCAD interface\r\n- [JupyterSCAD](https://github.com/jreiberkyle/jupyterscad) for Jupyter notebook integration\r\n- [OpenSCAD](https://openscad.org/) for the powerful 3D modeling capabilities\r\n\r\n## Changelog\r\n\r\n### Version 0.1.0\r\n\r\n- Initial release\r\n- Basic 3D visualization functionality\r\n- Cross-platform OpenSCAD detection\r\n- STL export capability\r\n- Comprehensive documentation and examples\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python package for 3D visualization of SolidPython2 objects",
    "version": "0.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/Mr-KAM/solidview/issues",
        "Documentation": "https://mr-kam.github.io/solidview/",
        "Homepage": "https://github.com/Mr-KAM/solidview",
        "Repository": "https://github.com/Mr-KAM/solidview"
    },
    "split_keywords": [
        "3d",
        " visualization",
        " solidpython",
        " openscad",
        " jupyter",
        " cad"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "95da562b40bf436aa815512471bc40f46d39f7f08805acfc0b56765057102630",
                "md5": "44e7cd9ae4893bb239273141025ce321",
                "sha256": "7fb5b5b6836d35198579cdebbc60ffaa997a4e9acf6c3d0a7802044edd0a168a"
            },
            "downloads": -1,
            "filename": "solidview-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "44e7cd9ae4893bb239273141025ce321",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7433,
            "upload_time": "2025-10-11T11:48:49",
            "upload_time_iso_8601": "2025-10-11T11:48:49.797029Z",
            "url": "https://files.pythonhosted.org/packages/95/da/562b40bf436aa815512471bc40f46d39f7f08805acfc0b56765057102630/solidview-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "06ef0e10c2b6eac4bae314bbfc4e418058cbb7565fe61d69aa616d3262db3a4b",
                "md5": "9f657b2cb60176b8c40e235bcfef93b1",
                "sha256": "f408a46a27f86153f4f9246b32be1bcbf7cca649151b89a7ddd5e940339cc204"
            },
            "downloads": -1,
            "filename": "solidview-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9f657b2cb60176b8c40e235bcfef93b1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 21237,
            "upload_time": "2025-10-11T11:48:51",
            "upload_time_iso_8601": "2025-10-11T11:48:51.272543Z",
            "url": "https://files.pythonhosted.org/packages/06/ef/0e10c2b6eac4bae314bbfc4e418058cbb7565fe61d69aa616d3262db3a4b/solidview-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-11 11:48:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Mr-KAM",
    "github_project": "solidview",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "solidpython2",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "jupyterscad",
            "specs": [
                [
                    ">=",
                    "0.2.0"
                ]
            ]
        }
    ],
    "lcname": "solidview"
}
        
Elapsed time: 2.66511s