PythonOCC

From FreeCAD Documentation
Revision as of 19:10, 29 August 2020 by FuzzyBot (talk | contribs) (Updating to match new version of source page)

Description

PythonOCC est un projet qui vise à lier l'ensemble des fonctions de la technologie OpenCASCADE (OCCT) dans un module Python. Il s'agit d'une approche différente de FreeCAD, où seuls certains composants de l'OCCT sont utilisés, résultant en une structure beaucoup plus simple. La page du projet est pythonocc.org.

PythonOCC, d'autre part, il vous donne accès à toutes les classes et fonctions OCC, est très complexe mais aussi très puissant. C'est donc un très bel ajout à FreeCAD. Lorsque vous êtes limité par la fonctionnalité OCCT disponible de FreeCAD dans vos scripts Python, il est temps de charger pythonOCC.

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