diff --git a/src/Mod/Part/App/Geometry.cpp b/src/Mod/Part/App/Geometry.cpp index 88a6774c01..9e4e5698c9 100644 --- a/src/Mod/Part/App/Geometry.cpp +++ b/src/Mod/Part/App/Geometry.cpp @@ -4566,7 +4566,7 @@ void GeomTrimmedSurface::Restore (Base::XMLReader &/*reader*/) {as PyObject *GeomTrimmedSurface::getPyObject(void) { - return 0; + return new RectangularTrimmedSurfacePy(static_cast(this->clone())); } // ------------------------------------------------- diff --git a/src/Mod/Part/App/RectangularTrimmedSurfacePy.xml b/src/Mod/Part/App/RectangularTrimmedSurfacePy.xml index 0ce372acf5..79fbe99e1a 100644 --- a/src/Mod/Part/App/RectangularTrimmedSurfacePy.xml +++ b/src/Mod/Part/App/RectangularTrimmedSurfacePy.xml @@ -25,5 +25,16 @@ The trimmed surface is built from a copy of the basis surface. Therefore, when t is modified the trimmed surface is not changed. Consequently, the trimmed surface does not necessarily have the same orientation as the basis surface. - + + + Modifies this patch by changing the trim values applied to the original surface + + + + + + + + + diff --git a/src/Mod/Part/App/RectangularTrimmedSurfacePyImp.cpp b/src/Mod/Part/App/RectangularTrimmedSurfacePyImp.cpp index 07e80c8f2d..fba1d6a7ec 100644 --- a/src/Mod/Part/App/RectangularTrimmedSurfacePyImp.cpp +++ b/src/Mod/Part/App/RectangularTrimmedSurfacePyImp.cpp @@ -86,6 +86,41 @@ int RectangularTrimmedSurfacePy::PyInit(PyObject* args, PyObject* /*kwd*/) return -1; } +PyObject* RectangularTrimmedSurfacePy::setTrim(PyObject *args) +{ + double u1, u2, v1, v2; + if (!PyArg_ParseTuple(args, "dddd", &u1, &u2, &v1, &v2)) + return nullptr; + + try { + Handle(Geom_RectangularTrimmedSurface) surf = Handle(Geom_RectangularTrimmedSurface)::DownCast + (getGeometryPtr()->handle()); + if (surf.IsNull()) { + PyErr_SetString(PyExc_TypeError, "geometry is not a surface"); + return nullptr; + } + + surf->SetTrim(u1, u2, v1, v2); + Py_Return; + } + catch (const Standard_Failure& e) { + PyErr_SetString(PyExc_RuntimeError, e.GetMessageString()); + return nullptr; + } +} + +Py::Object RectangularTrimmedSurfacePy::getBasisSurface() const +{ + Handle(Geom_RectangularTrimmedSurface) surf = Handle(Geom_RectangularTrimmedSurface)::DownCast + (getGeometryPtr()->handle()); + if (surf.IsNull()) { + throw Py::TypeError("geometry is not a surface"); + } + + std::unique_ptr geo(makeFromSurface(surf->BasisSurface())); + return Py::asObject(geo->getPyObject()); +} + PyObject *RectangularTrimmedSurfacePy::getCustomAttributes(const char* /*attr*/) const { return 0;