Skip to content

Commit

Permalink
Sketch: new fillet Python support
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelobrien authored and abdullahtahiriyo committed Feb 4, 2021
1 parent f6f43b6 commit 46feeb1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/Mod/Sketcher/App/SketchObjectPyImp.cpp
Expand Up @@ -1043,16 +1043,21 @@ PyObject* SketchObjectPy::getAxis(PyObject *args)
PyObject* SketchObjectPy::fillet(PyObject *args)
{
PyObject *pcObj1, *pcObj2;
int geoId1, geoId2, posId1, trim=1;
int geoId1, geoId2, posId1;
int trim=true;
PyObject* createCorner = Py_False;
double radius;

// Two Lines, radius
if (PyArg_ParseTuple(args, "iiO!O!d|i", &geoId1, &geoId2, &(Base::VectorPy::Type), &pcObj1, &(Base::VectorPy::Type), &pcObj2, &radius, &trim)) {
if (PyArg_ParseTuple(args, "iiO!O!d|iO!", &geoId1, &geoId2, &(Base::VectorPy::Type), &pcObj1, &(Base::VectorPy::Type), &pcObj2,
&radius, &trim, &PyBool_Type, &createCorner)) {
// The i for &trim should probably have been a bool like &createCorner, but we'll leave it an int for backward
// compatibility (and because python will accept a bool there anyway)

Base::Vector3d v1 = static_cast<Base::VectorPy*>(pcObj1)->value();
Base::Vector3d v2 = static_cast<Base::VectorPy*>(pcObj2)->value();

if (this->getSketchObjectPtr()->fillet(geoId1, geoId2, v1, v2, radius, trim?true:false)) {
if (this->getSketchObjectPtr()->fillet(geoId1, geoId2, v1, v2, radius, trim, PyObject_IsTrue(createCorner))) {
std::stringstream str;
str << "Not able to fillet curves with ids : (" << geoId1 << ", " << geoId2 << ") and points (" << v1.x << ", " << v1.y << ", " << v1.z << ") & "
<< "(" << v2.x << ", " << v2.y << ", " << v2.z << ")";
Expand All @@ -1064,8 +1069,9 @@ PyObject* SketchObjectPy::fillet(PyObject *args)

PyErr_Clear();
// Point, radius
if (PyArg_ParseTuple(args, "iid|i", &geoId1, &posId1, &radius, &trim)) {
if (this->getSketchObjectPtr()->fillet(geoId1, (Sketcher::PointPos) posId1, radius, trim?true:false)) {
if (PyArg_ParseTuple(args, "iid|iO!", &geoId1, &posId1, &radius, &trim, &PyBool_Type, &createCorner)) {
if (this->getSketchObjectPtr()->fillet(geoId1, (Sketcher::PointPos) posId1, radius, trim,
PyObject_IsTrue(createCorner))) {
std::stringstream str;
str << "Not able to fillet point with ( geoId: " << geoId1 << ", PointPos: " << posId1 << " )";
PyErr_SetString(PyExc_ValueError, str.str().c_str());
Expand All @@ -1075,8 +1081,8 @@ PyObject* SketchObjectPy::fillet(PyObject *args)
}

PyErr_SetString(PyExc_TypeError, "fillet() method accepts:\n"
"-- int,int,Vector,Vector,float,[int]\n"
"-- int,int,float,[int]\n");
"-- int,int,Vector,Vector,float,[bool],[bool]\n"
"-- int,int,float,[bool],[bool]\n");
return 0;
}

Expand Down

0 comments on commit 46feeb1

Please sign in to comment.