From 6a6a98dceade8395ad5e47f2c00940233be0e9a7 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Thu, 9 Sep 2021 14:12:06 +0200 Subject: [PATCH] 2d drawing --- libsrc/occ/python_occ_shapes.cpp | 15 +++++++++++++++ python/occ.py | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index 059b555f..cd446ba8 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -1544,6 +1544,21 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) .def_property_readonly("end", [](Handle(Geom2d_Curve) curve) { return curve->Value(curve->LastParameter()); }) + .def("Edge", [](Handle(Geom2d_Curve) curve) { + // Geom_Plane surf{gp_Ax3()}; + auto surf = new Geom_Plane{gp_Ax3()}; + auto edge = BRepBuilderAPI_MakeEdge(curve, surf).Edge(); + BRepLib::BuildCurves3d(edge); + return edge; + }) + .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(); + BRepLib::BuildCurves3d(edge); + auto wire = BRepBuilderAPI_MakeWire(edge).Wire(); + return BRepBuilderAPI_MakeFace(wire).Face(); + }) ; diff --git a/python/occ.py b/python/occ.py index 0e94898e..d53410c2 100644 --- a/python/occ.py +++ b/python/occ.py @@ -19,3 +19,10 @@ gp_Ax1 = Axis Translation = gp_Trsf.Translation 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)