[occ] add name argument to arc in workplane

This commit is contained in:
Christopher Lackner 2023-11-21 11:38:01 +01:00
parent 69025e5ef4
commit 5692604ab6

View File

@ -424,7 +424,7 @@ public:
return shared_from_this(); return shared_from_this();
} }
auto ArcTo (double h, double v, const gp_Vec2d t) auto ArcTo (double h, double v, const gp_Vec2d t, optional<string> name=nullopt)
{ {
gp_Pnt2d P1 = localpos.Location(); gp_Pnt2d P1 = localpos.Location();
@ -489,6 +489,8 @@ public:
auto edge = BRepBuilderAPI_MakeEdge(curve2d, surf, lastvertex, endv).Edge(); auto edge = BRepBuilderAPI_MakeEdge(curve2d, surf, lastvertex, endv).Edge();
lastvertex = endv; lastvertex = endv;
BRepLib::BuildCurves3d(edge); BRepLib::BuildCurves3d(edge);
if(name.has_value())
OCCGeometry::GetProperties(edge).name = name;
wire_builder.Add(edge); wire_builder.Add(edge);
//compute angle of rotation //compute angle of rotation
@ -509,7 +511,7 @@ public:
return shared_from_this(); return shared_from_this();
} }
auto Arc(double radius, double angle) auto Arc(double radius, double angle, optional<string> name)
{ {
double newAngle = fmod(angle,360)*M_PI/180; double newAngle = fmod(angle,360)*M_PI/180;
@ -540,7 +542,7 @@ public:
cout << IM(6) << "t = (" << t.X() << ", " << t.Y() << ")" << endl; cout << IM(6) << "t = (" << t.X() << ", " << t.Y() << ")" << endl;
//add arc //add arc
return ArcTo (oldp.X(), oldp.Y(), t); return ArcTo (oldp.X(), oldp.Y(), t, name);
} }
auto Rectangle (double l, double w) auto Rectangle (double l, double w)
@ -2534,8 +2536,9 @@ degen_tol : double
// .def("LineTo", &WorkPlane::LineTo) // .def("LineTo", &WorkPlane::LineTo)
.def("LineTo", [](WorkPlane&wp, double x, double y, optional<string> name) { return wp.LineTo(x, y, name); }, .def("LineTo", [](WorkPlane&wp, double x, double y, optional<string> name) { return wp.LineTo(x, y, name); },
py::arg("h"), py::arg("v"), py::arg("name")=nullopt, "draw line to position (h,v)") py::arg("h"), py::arg("v"), py::arg("name")=nullopt, "draw line to position (h,v)")
.def("ArcTo", &WorkPlane::ArcTo) .def("ArcTo", &WorkPlane::ArcTo, py::arg("h"), py::arg("v"),
.def("Arc", &WorkPlane::Arc, py::arg("r"), py::arg("ang"), "draw arc tangential to current pos/dir, of radius 'r' and angle 'ang', draw to the left/right if ang is positive/negative") py::arg("t"), py::arg("name")=nullopt)
.def("Arc", &WorkPlane::Arc, py::arg("r"), py::arg("ang"), py::arg("name")=nullopt, "draw arc tangential to current pos/dir, of radius 'r' and angle 'ang', draw to the left/right if ang is positive/negative")
.def("Rotate", &WorkPlane::Rotate, py::arg("ang"), "rotate current direction by 'ang' degrees") .def("Rotate", &WorkPlane::Rotate, py::arg("ang"), "rotate current direction by 'ang' degrees")
.def("Line", [](WorkPlane&wp,double l, optional<string> name) { return wp.Line(l, name); }, .def("Line", [](WorkPlane&wp,double l, optional<string> name) { return wp.Line(l, name); },
py::arg("l"), py::arg("name")=nullopt) py::arg("l"), py::arg("name")=nullopt)