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:
# 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