diff --git a/src/Mod/Part/App/GeometryCurvePy.xml b/src/Mod/Part/App/GeometryCurvePy.xml
index e4308eb72d..925686b51f 100644
--- a/src/Mod/Part/App/GeometryCurvePy.xml
+++ b/src/Mod/Part/App/GeometryCurvePy.xml
@@ -58,6 +58,14 @@ length([uMin,uMax,Tol]) -> Float
of the nearest orthogonal projection of the point.
+
+
+
+ Converts a curve of any type (only part from First to Last)
+ toBSpline([Float=First, Float=Last]) -> B-Spline curve
+
+
+
diff --git a/src/Mod/Part/App/GeometryCurvePyImp.cpp b/src/Mod/Part/App/GeometryCurvePyImp.cpp
index 45b35f1daf..b52b2a1ee7 100644
--- a/src/Mod/Part/App/GeometryCurvePyImp.cpp
+++ b/src/Mod/Part/App/GeometryCurvePyImp.cpp
@@ -43,6 +43,7 @@
# include
# include
# include
+# include
#endif
#include
@@ -54,6 +55,7 @@
#include "RectangularTrimmedSurfacePy.h"
#include "BSplineSurfacePy.h"
#include "PlanePy.h"
+#include "BSplineCurvePy.h"
#include "TopoShape.h"
#include "TopoShapePy.h"
@@ -339,6 +341,32 @@ PyObject* GeometryCurvePy::intersect2d(PyObject *args)
}
}
+PyObject* GeometryCurvePy::toBSpline(PyObject * args)
+{
+ Handle_Geom_Geometry g = getGeometryPtr()->handle();
+ Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
+ try {
+ if (!c.IsNull()) {
+ double u,v;
+ u=c->FirstParameter();
+ v=c->LastParameter();
+ if (!PyArg_ParseTuple(args, "|dd", &u,&v))
+ return 0;
+ ShapeConstruct_Curve scc;
+ Handle_Geom_BSplineCurve spline = scc.ConvertToBSpline(c, u, v, Precision::Confusion());
+ return new BSplineCurvePy(new GeomBSplineCurve(spline));
+ }
+ }
+ catch (Standard_Failure) {
+ Handle_Standard_Failure e = Standard_Failure::Caught();
+ PyErr_SetString(PyExc_Exception, e->GetMessageString());
+ return 0;
+ }
+
+ PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
+ return 0;
+}
+
Py::Float GeometryCurvePy::getFirstParameter(void) const
{
return Py::Float(Handle_Geom_Curve::DownCast