From 9370378ec7cf5b5fedfe8b6768ec2f618a0d97ce Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 9 Sep 2016 13:02:15 +0200 Subject: [PATCH] allow to pass parameter range when creating a line from a line --- src/Mod/Part/App/LinePyImp.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Mod/Part/App/LinePyImp.cpp b/src/Mod/Part/App/LinePyImp.cpp index c47afd01e..ee714a6f3 100644 --- a/src/Mod/Part/App/LinePyImp.cpp +++ b/src/Mod/Part/App/LinePyImp.cpp @@ -101,6 +101,30 @@ int LinePy::PyInit(PyObject* args, PyObject* /*kwd*/) return 0; } + PyErr_Clear(); + double first, last; + if (PyArg_ParseTuple(args, "O!dd", &(LinePy::Type), &pLine, &first, &last)) { + // Copy line + LinePy* pcLine = static_cast(pLine); + // get Geom_Line of line segment + Handle_Geom_TrimmedCurve that_curv = Handle_Geom_TrimmedCurve::DownCast + (pcLine->getGeomLineSegmentPtr()->handle()); + Handle_Geom_Line that_line = Handle_Geom_Line::DownCast + (that_curv->BasisCurve()); + // get Geom_Line of line segment + Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast + (this->getGeomLineSegmentPtr()->handle()); + Handle_Geom_Line this_line = Handle_Geom_Line::DownCast + (this_curv->BasisCurve()); + + Infinite = pcLine->Infinite; + + // Assign the lines + this_line->SetLin(that_line->Lin()); + this_curv->SetTrim(first, last); + return 0; + } + PyErr_Clear(); PyObject *pV1, *pV2; if (PyArg_ParseTuple(args, "O!O!", &(Base::VectorPy::Type), &pV1,