PythonOCC

From FreeCAD Documentation
Revision as of 17:32, 20 February 2021 by David69 (talk | contribs)

Description

PythonOCC est un projet qui vise à fournir toute la gamme des fonctions OpenCASCADE Technology (OCCT) via le module Python OCC. C'est une approche différente de celle de FreeCAD, où seuls certains composants d'OCCT sont exposés via l'atelier Part.

PythonOCC, d'autre part, donne accès à toutes les classes et fonctions OCCT, ce qui est complexe mais aussi très puissant. Par conséquent, lorsque vous êtes limité par la fonctionnalité OCCT de FreeCAD, l'utilisation de pythonOCC est une bonne alternative.

Usage

Actuellement dans l'Atelier Part, nous avons les méthodes Part.__toPythonOCC__() et Part.__fromPythonOCC__() pour échanger TopoDS_Shape (Part TopoShape) entités vers et depuis pythonOCC. Cela nous permet d'utiliser toute la puissance d'OCTT en Python puis de remettre les formes résultantes dans FreeCAD.

PythonOCC is internally used by the IFC viewer included with the IfcOpenShell libraries. IfcOpenShell is used to read and write IFC documents with FreeCAD. PythonOCC is only needed to launch IfcOpenShell's integrated viewer, otherwise it is not necessary.

Installation

PythonOCC must be compiled from source. For this you need to get the corresponding development files for OpenCASCADE Technology (OCCT) and SWIG. The older version of PythonOCC was intended to wrap around OCE 0.18, the community edition of OCCT 6.9.x, which is now unmaintained. The newest version of PythonOCC is now intended to work with the recent, official OCCT 7.4 version.

Together with OCCT 7.4, PythonOCC requires fairly recent dependencies like Python 3.7, CMake 3.12, and SWIG 3.0.11. Python 2 is no longer supported.

It is also possible to install pre-compiled PythonOCC libraries using Conda. For more information and compilation instructions, see the main project's repository, tpaviot/pythonocc-core.

More information