diff --git a/src/Mod/Part/App/TopoShapePy.xml b/src/Mod/Part/App/TopoShapePy.xml index 6f3d24b02..22a1d31e5 100644 --- a/src/Mod/Part/App/TopoShapePy.xml +++ b/src/Mod/Part/App/TopoShapePy.xml @@ -305,7 +305,56 @@ the hollowed solid, their thickness defined at the time of construction. - Offset a given shape + makeOffsetShape(offset, tolerance, inter = False, self_inter = False, +offsetMode = 0, join = 0, fill = False): makes an offset shape (3d offsetting). +The function supports keyword arguments. + +* offset: distance to expand the shape by. Negative value will shrink the +shape. + +* tolerance: precision of approximation. + +* inter: (parameter to OCC routine; not implemented) + +* self_inter: (parameter to OCC routine; not implemented) + +* offsetMode: 0 = skin; 1 = pipe; 2 = recto-verso + +* join: method of offsetting non-tangent joints. 0 = arcs, 1 = tangent, 2 = +intersection + +* fill: if true, offsetting a shell is to yeild a solid + +Returns: result of offsetting. + + + + + makeOffset2D(offset, join = 0, fill = False, openResult = false, intersection = +false): makes an offset shape (2d offsetting). The function supports keyword +arguments. Input shape (self) can be edge, wire, face, or a compound of those. + +* offset: distance to expand the shape by. Negative value will shrink the +shape. + +* join: method of offsetting non-tangent joints. 0 = arcs, 1 = tangent, 2 = +intersection + +* fill: if true, the output is a face filling the space covered by offset. If +false, the output is a wire. + +* openResult: affects the way open wires are processed. If False, an open wire +is made. If True, a closed wire is made from a double-sided offset, with rounds +around open vertices. + +* intersection: affects the way compounds are processed. If False, all children +are offset independently. If True, and children are edges/wires, the children +are offset in a collective manner. If compounding is nested, collectiveness +does not spread across compounds (only direct children of a compound are taken +collectively). + +Returns: result of offsetting (wire or face or compound of those). Compounding +structure follows that of source shape. diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index 87bc2e84b..e489a2654 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -1453,6 +1453,32 @@ PyObject* TopoShapePy::makeOffsetShape(PyObject *args, PyObject *keywds) } } +PyObject* TopoShapePy::makeOffset2D(PyObject *args, PyObject *keywds) +{ + static char *kwlist[] = {"offset", "join", "fill", "openResult", "intersection", NULL}; + double offset; + PyObject* fill = Py_False; + PyObject* openResult = Py_False; + PyObject* inter = Py_False; + short join = 0; + if (!PyArg_ParseTupleAndKeywords(args, keywds, "d|hO!O!O!", kwlist, + &offset, + &join, + &(PyBool_Type), &fill, + &(PyBool_Type), &openResult, + &(PyBool_Type), &inter)) + return 0; + + try { + TopoDS_Shape resultShape = this->getTopoShapePtr()->makeOffset2D(offset, join, + PyObject_IsTrue(fill) ? true : false, + PyObject_IsTrue(openResult) ? true : false, + PyObject_IsTrue(inter) ? true : false); + return new_reference_to(shape2pyshape(resultShape)); + } + PY_CATCH_OCC; +} + PyObject* TopoShapePy::reverse(PyObject *args) { if (!PyArg_ParseTuple(args, ""))