$ show tpaviot/pythonocc-core
pythonocc-core is a Python binding for the OpenCASCADE Technology (OCCT) 3D CAD kernel, providing full access to OCCT's geometry, topology, visualization, and data exchange capabilities. It is a library, not a standalone application, designed for engineers and developers building CAD/CAE/PLM tools in Python. The architecture is a C++ extension module generated via SWIG, with a thin Python layer that adds convenience utilities, multiple display backends (Qt, wxPython, Tkinter, WebGL/Jupyter), and high-level helpers for shape creation, topology traversal, and file I/O (STEP, IGES, STL, glTF, OBJ, PLY). The core API mirrors OCCT's class hierarchy, while the `OCC.Extend` and `OCC.Display` packages provide Pythonic wrappers and interactive 3D viewers. The repository is actively maintained, with recent releases (7.9.3) and CI pipelines for conda packages across platforms. It includes extensive type stubs for IDE support, a comprehensive test suite, and support for offscreen rendering and Jupyter notebooks. Key entry points include `OCC.Display.SimpleGui.init_display()` for interactive viewers, `OCC.Extend.DataExchange.read_step_file()` for CAD file import, and `OCC.Core.Tesselator.ShapeTesselator` for mesh generation. The codebase demonstrates strong engineering practices with reusable patterns like the topology explorer, shape factory utilities, and a generic proxy pattern for OCCT objects. However, the SWIG-generated wrapper layer is large and fragile, requiring careful version alignment with OCCT, and some OCCT classes remain unwrapped.
The LLM identified 5 files worth highlighting for reuse:
Provides `TopologyExplorer` and `WireExplorer` classes that wrap OCCT's `TopExp_Explorer` with a clean Pythonic interface. Supports filtering by orientation, ancestor mapping, and discretization of edges/wires into point sequences. This module is self-contained (only depends on OCC.Core) and can be extracted for any project needing to traverse or analyze BRep topology.
A collection of static methods for common shape operations: bounding boxes (AABB, OBB), face recognition, shape transformation, mass/volume computation, and compound creation. It abstracts OCCT's verbose APIs into simple function calls. Reusable across any CAD workflow requiring shape manipulation.
Implements `Viewer3d` and `OffscreenRenderer` classes that encapsulate OCCT's 3D viewer and rendering context. Provides methods for adding/removing shapes, setting display modes, camera control, selection, and image export. The `OffscreenRenderer` enables headless rendering for batch processing or testing. This module is a reusable abstraction for embedding OCCT visualization in any Python application.
High-level functions for reading and writing CAD files in STEP, IGES, STL, glTF, OBJ, and PLY formats. Handles color/material import/export via OCAF. Each function is a thin wrapper around OCCT's reader/writer classes, with sensible defaults and error handling. This module can be reused as a standalone file I/O utility for any project needing CAD format conversion.
Contains utility functions and decorators for the SWIG wrapper layer: `@deprecated` for marking old APIs, `@methodnotwrapped` for stubs, and a generic proxy class that delegates attribute access to underlying OCCT objects. The proxy pattern is a clean solution for wrapping C++ objects with Pythonic behavior and can be extracted for any SWIG-based binding project.