diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index cd446ba8..ffdc1387 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -1545,16 +1545,23 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) return curve->Value(curve->LastParameter()); }) .def("Edge", [](Handle(Geom2d_Curve) curve) { - // Geom_Plane surf{gp_Ax3()}; - auto surf = new Geom_Plane{gp_Ax3()}; + // static Geom_Plane surf{gp_Ax3()}; // crashes in nbconvert ??? + static auto surf = new Geom_Plane{gp_Ax3()}; auto edge = BRepBuilderAPI_MakeEdge(curve, surf).Edge(); BRepLib::BuildCurves3d(edge); return edge; }) + .def("Wire", [](Handle(Geom2d_Curve) curve) { + // static Geom_Plane surf{gp_Ax3()}; // crashes in nbconvert ??? + static auto surf = new Geom_Plane{gp_Ax3()}; + auto edge = BRepBuilderAPI_MakeEdge(curve, surf).Edge(); + BRepLib::BuildCurves3d(edge); + return BRepBuilderAPI_MakeWire(edge).Wire(); + }) .def("Face", [](Handle(Geom2d_Curve) curve) { - // static surf = new Geom_Plane{gp_Ax3()}; - static Geom_Plane surf{gp_Ax3()}; - auto edge = BRepBuilderAPI_MakeEdge(curve, &surf).Edge(); + // static Geom_Plane surf{gp_Ax3()}; // crashes in nbconvert ??? + static auto surf = new Geom_Plane{gp_Ax3()}; + auto edge = BRepBuilderAPI_MakeEdge(curve, surf).Edge(); BRepLib::BuildCurves3d(edge); auto wire = BRepBuilderAPI_MakeWire(edge).Wire(); return BRepBuilderAPI_MakeFace(wire).Face(); @@ -1878,7 +1885,8 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) .def("Reverse", &WorkPlane::Reverse, "revert orientation of current wire") .def("Close", &WorkPlane::Close, "draw line to start point of wire, and finish wire") .def("Finish", &WorkPlane::Finish, "finish current wire without closing") - .def("Last", &WorkPlane::Last, "returns current wire") + .def("Last", &WorkPlane::Last, "(deprecated) returns current wire") + .def("Wire", &WorkPlane::Last, "returns current wire") .def("Face", &WorkPlane::Face, "generate and return face of all wires, resets list of wires") .def("Wires", &WorkPlane::Wires, "returns all wires") ; diff --git a/python/occ.py b/python/occ.py index d53410c2..8cdb39e3 100644 --- a/python/occ.py +++ b/python/occ.py @@ -21,8 +21,7 @@ Rotation = gp_Trsf.Rotation Mirror = gp_Trsf.Mirror -wp2d = WorkPlane() -def Rectangle(l,w): return wp2d.Rectangle(l,w) -def MoveTo(x,y): return wp2d.MoveTo(x,y) -def LineTo(x,y): return wp2d.LineTo(x,y) -def Line(l): return wp2d.Line(l) +def Rectangle(l,w): return WorkPlane().Rectangle(l,w) +def MoveTo(x,y): return WorkPlane().MoveTo(x,y) +def LineTo(x,y): return WorkPlane().LineTo(x,y) +def Line(l): return WorkPlane().Line(l)