Skip to content

Porting from 0.18.x to 7.4.0

Thomas Paviot edited this page Feb 27, 2020 · 4 revisions

From releases 0.18.x to 7.4.0, pythonocc moved up from open cascade technology (OCCT) 6.9 to 7.4.0. This new release comes with two major changes:

  1. API changes related to the C++ API itself. There has been new classes, deprecated classes removed, new methods, deprecated methods remove etc. OCCT also made major changes to its smart pointers (known as Handles). This wiki page cannot gives the exhaustive list of changes. To trace these changes, refer to:
  1. Changes to the python wrapper itself:
  • transparent handles: under pythonocc 0.18.x and before, OCCT smart pointers were wrapped using GetObjet() and GetHandle() methods and you had to care about using Handles or the base class. With pythonocc 7.4 and above, this difference is not visible anymore thanks to "transparent handles". You don't have to worry about those handles, everything is performed by the wrapper. To port your old code, just remove all the calls to GetHandle and GetObject. For example, the commit related to the occ classical example port is available here: https://github.com/tpaviot/pythonocc-demos/commit/e59acdce5720d84ce76134789b48c268e36446d6#diff-68b70730ce65eb74e098809766ab3d0d
# Build edges and wires for threading
# Old code (pythonocc 0.18.x)
anEdge1OnSurf1 = BRepBuilderAPI_MakeEdge(Handle_Geom2d_Curve(anArc1), Handle_Geom_Surface(aCyl1))

# New Code (pythonocc 7.4.0)
anEdge1OnSurf1 = BRepBuilderAPI_MakeEdge(Geom2d_Curve(anArc1), Geom_Surface(aCyl1))
  • new package structure: move all from OCC.xxx imports to from OCC.Core.xxx, for instance:
# Old Code (pythonocc 0.18.x)
from OCC.gp import gp_Pnt, gp_OX, gp_Vec, gp_Trsf

# New Code (pythonocc 7.4.0)
from OCC.Core.gp import gp_Pnt, gp_OX, gp_Vec, gp_Trsf
  • smart inheritance*: no need to DownCast anything anymore. Base classes are automatically identified by the wrapper. This result in the following change, for example:
# Old Code (pythonocc 0.18.x)
geom_plane = Geom_Plane(some_gp_pln)
h_surface = Handle_Geom_Surface(geom_plane)
e1 = BRepBuilderAPI_MakeEdge(seg1.Value(), h_surface)

# New Code (pythonocc 7.4.0)
geom_plane = Geom_Plane(some_gp_pln)
e1 = BRepBuilderAPI_MakeEdge(seg1.Value(), geom_plane)
Clone this wiki locally