Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

ovo-Tim/pyOCCT2

 
 

Repository files navigation

pyOCCT — Python bindings for OpenCASCADE

Anaconda-Server Badge Anaconda-Server Badge Anaconda-Server Badge Anaconda-Server Badge

The pyOCCT2 project provides Python bindings to the OpenCASCADE geometry kernel via pybind11. Together, this technology stack enables rapid CAD/CAE/CAM application development in the popular Python programming language.

Why pyOCCT2 exists?

pyOCCT has been discontinued support, but it's still meaningful. We want to countinue supporting it. Thanks to frmdstryr, he is still keeping pyOCCT up to date.(His repo is here, it's also our upstream.)

pyOCCT2 added some new features, it's more close to pythonOCC. And it shoulds be compatible with pythonocc.

What is the difference between pyOCCT and pythonOCC?

pyOCCT provide interface that closer to native and support more module. Because of pyBind11, it's more convenient to maintenance. But pythonocc has a larger user base so you will likely find more people to collaborate with.

Enabling technology

The pyOCCT core technology stack includes:

  • OpenCASCADE: Open CASCADE Technology (OCCT) is an object-oriented C++ class library designed for rapid production of sophisticated domain-specific CAD/CAM/CAE applications.

  • pybind11: A lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code.

Getting started using conda

Conda packages are available for a number of platforms and Python versions. It only provides Linux conda packages, that's because I'm too lazy tired to fix up windows and MacOS building CI.(If anyone is willing to fix them up, I'm glad to help.) But you still build by yourself.

Get started with:

conda create -n pyocct python
activate pyocct
conda install ovo-tim::pyocct

This will create an environment named "pyocct" and install pyOCCT and all necessary dependencies. You can replace the "pyocct" environment name with anything you'd like.

Navigate to the examples/ folder and run from the active environment:

python import_step_qt.py

and you should see the following image in the viewing tool if all the requirements are correctly installed.

compressor

Installation files can be cleaned up by:

conda clean -a

Building from sources

To build from sources, you must generate the binding source code locally. This can be done using the pyOCCT_binder project which is available as a git submodule in this repository within the binder/ folder.

Clone this repository and use the --recurse-submodules command to initialize and download the external pyOCCT_binder project:

git clone --recurse-submodules https://github.com/ovo-Tim/pyOCCT2.git

The binder uses clang to parse the C++ header files of the libraries and generate the source code. If you are familiar with conda, an environment can be created for this task by:

conda env create -f binder/environment.yml

If all the necessary dependencies are available, the binder can be run to generate the binding sources:

python binder/run.py -c binder/config.txt -o src

Be sure and check the output from the binding generation process in the command prompt in case there are missing header files or other errors.

After the binding sources are generated:

mkdir build
cd build
cmake ..

Updating for new version

When updating to a new version of OCCT please ensure the occt version is updated in the following files:

  • ci/conda/meta.yaml
  • binder/environment.yml
  • CMakeLists.txt (project version, settings, and OCCT required version)
  • OCCT/init.py
  • Ensure cmake/OCCT_Modules.cmake is up to date

About

Python bindings for OpenCASCADE via pybind11

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 79.9%
  • C++ 13.8%
  • CMake 5.2%
  • Other 1.1%