SketchObjectPy.cpp

Go to the documentation of this file.
00001 
00002 // This file is generated by src/Tools/generateTemaplates/templateClassPyExport.py out of the .XML file
00003 // Every change you make here get lost at the next full rebuild!
00004 // This File is normaly build as an include in SketchObjectPyImp.cpp! Its not intended to be in a project!
00005 
00006 #include <boost/filesystem/path.hpp>
00007 #include <boost/filesystem/operations.hpp>
00008 #include <boost/filesystem/exception.hpp>
00009 #include <Base/PyObjectBase.h>
00010 #include <Base/Console.h>
00011 #include <Base/Exception.h>
00012 #include <CXX/Objects.hxx>
00013 
00014 #define new DEBUG_CLIENTBLOCK
00015 
00016 using Base::streq;
00017 using namespace Sketcher;
00018 
00020 PyTypeObject SketchObjectPy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Sketcher.SketchObject",     /*tp_name*/
00024     sizeof(SketchObjectPy),                       /*tp_basicsize*/
00025     0,                                                /*tp_itemsize*/
00026     /* methods */
00027     PyDestructor,                                     /*tp_dealloc*/
00028     0,                                                /*tp_print*/
00029     __getattr,                                        /*tp_getattr*/
00030     __setattr,                                        /*tp_setattr*/
00031     0,                                                /*tp_compare*/
00032     __repr,                                           /*tp_repr*/
00033     0,                                                /*tp_as_number*/
00034     0,                                                /*tp_as_sequence*/
00035     0,                                                /*tp_as_mapping*/
00036     0,                                                /*tp_hash*/
00037     0,                                                /*tp_call */
00038     0,                                                /*tp_str  */
00039     0,                                                /*tp_getattro*/
00040     0,                                                /*tp_setattro*/
00041     /* --- Functions to access object as input/output buffer ---------*/
00042     0,                                                /* tp_as_buffer */
00043     /* --- Flags to define presence of optional/expanded features */
00044     Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_CLASS,        /*tp_flags */
00045     "With this objects you can handle sketches",           /*tp_doc */
00046     0,                                                /*tp_traverse */
00047     0,                                                /*tp_clear */
00048     0,                                                /*tp_richcompare */
00049     0,                                                /*tp_weaklistoffset */
00050     0,                                                /*tp_iter */
00051     0,                                                /*tp_iternext */
00052     Sketcher::SketchObjectPy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     Sketcher::SketchObjectPy::GetterSetter,                     /*tp_getset */
00055     &Part::Part2DObjectPy::Type,                        /*tp_base */
00056     0,                                                /*tp_dict */
00057     0,                                                /*tp_descr_get */
00058     0,                                                /*tp_descr_set */
00059     0,                                                /*tp_dictoffset */
00060     __PyInit,                                         /*tp_init */
00061     0,                                                /*tp_alloc */
00062     Sketcher::SketchObjectPy::PyMake,/*tp_new */
00063     0,                                                /*tp_free   Low-level free-memory routine */
00064     0,                                                /*tp_is_gc  For PyObject_IS_GC */
00065     0,                                                /*tp_bases */
00066     0,                                                /*tp_mro    method resolution order */
00067     0,                                                /*tp_cache */
00068     0,                                                /*tp_subclasses */
00069     0,                                                /*tp_weaklist */
00070     0                                                 /*tp_del */
00071 };
00072 
00074 PyMethodDef SketchObjectPy::Methods[] = {
00075     {"solve",
00076         (PyCFunction) staticCallback_solve,
00077         METH_VARARGS,
00078         "solve the actual set of geometry and constraints"
00079     },
00080     {"addGeometry",
00081         (PyCFunction) staticCallback_addGeometry,
00082         METH_VARARGS,
00083         "add a geometric object to the sketch"
00084     },
00085     {"delGeometry",
00086         (PyCFunction) staticCallback_delGeometry,
00087         METH_VARARGS,
00088         "delete a geometric object from the sketch"
00089     },
00090     {"toggleConstruction",
00091         (PyCFunction) staticCallback_toggleConstruction,
00092         METH_VARARGS,
00093         "switch a geometry to a construcion line"
00094     },
00095     {"addConstraint",
00096         (PyCFunction) staticCallback_addConstraint,
00097         METH_VARARGS,
00098         "add a constraint to the sketch"
00099     },
00100     {"delConstraint",
00101         (PyCFunction) staticCallback_delConstraint,
00102         METH_VARARGS,
00103         "delete a constraint from the sketch"
00104     },
00105     {"addExternal",
00106         (PyCFunction) staticCallback_addExternal,
00107         METH_VARARGS,
00108         "add a link to a external geometry to use them in a constraint"
00109     },
00110     {"delExternal",
00111         (PyCFunction) staticCallback_delExternal,
00112         METH_VARARGS,
00113         "delete a external geometry link from the sketch"
00114     },
00115     {"delConstraintOnPoint",
00116         (PyCFunction) staticCallback_delConstraintOnPoint,
00117         METH_VARARGS,
00118         "delete coincident constraints associated with a sketch point"
00119     },
00120     {"setDatum",
00121         (PyCFunction) staticCallback_setDatum,
00122         METH_VARARGS,
00123         "set the Datum of a Distance or Angle constraint"
00124     },
00125     {"movePoint",
00126         (PyCFunction) staticCallback_movePoint,
00127         METH_VARARGS,
00128         "\n          movePoint(GeoIndex,PointPos,Vector,[relative]) - move a given point (or curve)\n          to another location.\n          It moves the specified point (or curve) to the given location by adding some\n          temporary weak constraints and solve the sketch.\n          This method is mostly used to allow the user to drag some portions of the sketch\n          in real time by e.g. the mouse and it works only for underconstrained portions of\n          the sketch.\n          The argument 'relative', if present, states if the new location is given\n          relatively to the current one.\n        "
00129     },
00130     {"fillet",
00131         (PyCFunction) staticCallback_fillet,
00132         METH_VARARGS,
00133         "create fillet between two edges or at a point"
00134     },
00135     {"trim",
00136         (PyCFunction) staticCallback_trim,
00137         METH_VARARGS,
00138         "trim a curve with a given id at a given reference point"
00139     },
00140     {NULL, NULL, 0, NULL}               /* Sentinel */
00141 };
00142 
00143 
00144 
00146 PyGetSetDef SketchObjectPy::GetterSetter[] = {
00147     {"ConstraintCount",
00148         (getter) staticCallback_getConstraintCount,
00149         (setter) staticCallback_setConstraintCount, 
00150         "Number of Constraints in this sketch",
00151         NULL
00152     },
00153     {"GeometryCount",
00154         (getter) staticCallback_getGeometryCount,
00155         (setter) staticCallback_setGeometryCount, 
00156         "Number of geometric objects in this sketch",
00157         NULL
00158     },
00159     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00160 };
00161 
00162 // solve() callback and implementer
00163 // PyObject*  SketchObjectPy::solve(PyObject *args){};
00164 // has to be implemented in SketchObjectPyImp.cpp
00165 PyObject * SketchObjectPy::staticCallback_solve (PyObject *self, PyObject *args)
00166 {
00167     // test if twin object not allready deleted
00168     if (!((PyObjectBase*) self)->isValid()){
00169         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00170         return NULL;
00171     }
00172 
00173     // test if object is set Const
00174     if (((PyObjectBase*) self)->isConst()){
00175         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00176         return NULL;
00177     }
00178 
00179     try { // catches all exceptions coming up from c++ and generate a python exception
00180         PyObject* ret = ((SketchObjectPy*)self)->solve(args);
00181         if (ret != 0)
00182             ((SketchObjectPy*)self)->startNotify();
00183         return ret;
00184     }
00185     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00186     {
00187         std::string str;
00188         str += "FreeCAD exception thrown (";
00189         str += e.what();
00190         str += ")";
00191         e.ReportException();
00192         PyErr_SetString(PyExc_Exception,str.c_str());
00193         return NULL;
00194     }
00195     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00196     {
00197         std::string str;
00198         str += "File system exception thrown (";
00199         //str += e.who();
00200         //str += ", ";
00201         str += e.what();
00202         str += ")\n";
00203         Base::Console().Error(str.c_str());
00204         PyErr_SetString(PyExc_Exception,str.c_str());
00205         return NULL;
00206     }
00207     catch(const Py::Exception&)
00208     {
00209         // The exception text is already set
00210         return NULL;
00211     }
00212     catch(const char* e) // catch simple string exceptions
00213     {
00214         Base::Console().Error(e);
00215         PyErr_SetString(PyExc_Exception,e);
00216         return NULL;
00217     }
00218     // in debug not all exceptions will be catched to get the attention of the developer!
00219 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00220     catch(const std::exception& e) // catch other c++ exceptions
00221     {
00222         std::string str;
00223         str += "FC++ exception thrown (";
00224         str += e.what();
00225         str += ")";
00226         Base::Console().Error(str.c_str());
00227         PyErr_SetString(PyExc_Exception,str.c_str());
00228         return NULL;
00229     }
00230     catch(...)  // catch the rest!
00231     {
00232         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00233         return NULL;
00234     }
00235 #endif
00236 }
00237 
00238 // addGeometry() callback and implementer
00239 // PyObject*  SketchObjectPy::addGeometry(PyObject *args){};
00240 // has to be implemented in SketchObjectPyImp.cpp
00241 PyObject * SketchObjectPy::staticCallback_addGeometry (PyObject *self, PyObject *args)
00242 {
00243     // test if twin object not allready deleted
00244     if (!((PyObjectBase*) self)->isValid()){
00245         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00246         return NULL;
00247     }
00248 
00249     // test if object is set Const
00250     if (((PyObjectBase*) self)->isConst()){
00251         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00252         return NULL;
00253     }
00254 
00255     try { // catches all exceptions coming up from c++ and generate a python exception
00256         PyObject* ret = ((SketchObjectPy*)self)->addGeometry(args);
00257         if (ret != 0)
00258             ((SketchObjectPy*)self)->startNotify();
00259         return ret;
00260     }
00261     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00262     {
00263         std::string str;
00264         str += "FreeCAD exception thrown (";
00265         str += e.what();
00266         str += ")";
00267         e.ReportException();
00268         PyErr_SetString(PyExc_Exception,str.c_str());
00269         return NULL;
00270     }
00271     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00272     {
00273         std::string str;
00274         str += "File system exception thrown (";
00275         //str += e.who();
00276         //str += ", ";
00277         str += e.what();
00278         str += ")\n";
00279         Base::Console().Error(str.c_str());
00280         PyErr_SetString(PyExc_Exception,str.c_str());
00281         return NULL;
00282     }
00283     catch(const Py::Exception&)
00284     {
00285         // The exception text is already set
00286         return NULL;
00287     }
00288     catch(const char* e) // catch simple string exceptions
00289     {
00290         Base::Console().Error(e);
00291         PyErr_SetString(PyExc_Exception,e);
00292         return NULL;
00293     }
00294     // in debug not all exceptions will be catched to get the attention of the developer!
00295 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00296     catch(const std::exception& e) // catch other c++ exceptions
00297     {
00298         std::string str;
00299         str += "FC++ exception thrown (";
00300         str += e.what();
00301         str += ")";
00302         Base::Console().Error(str.c_str());
00303         PyErr_SetString(PyExc_Exception,str.c_str());
00304         return NULL;
00305     }
00306     catch(...)  // catch the rest!
00307     {
00308         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00309         return NULL;
00310     }
00311 #endif
00312 }
00313 
00314 // delGeometry() callback and implementer
00315 // PyObject*  SketchObjectPy::delGeometry(PyObject *args){};
00316 // has to be implemented in SketchObjectPyImp.cpp
00317 PyObject * SketchObjectPy::staticCallback_delGeometry (PyObject *self, PyObject *args)
00318 {
00319     // test if twin object not allready deleted
00320     if (!((PyObjectBase*) self)->isValid()){
00321         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00322         return NULL;
00323     }
00324 
00325     // test if object is set Const
00326     if (((PyObjectBase*) self)->isConst()){
00327         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00328         return NULL;
00329     }
00330 
00331     try { // catches all exceptions coming up from c++ and generate a python exception
00332         PyObject* ret = ((SketchObjectPy*)self)->delGeometry(args);
00333         if (ret != 0)
00334             ((SketchObjectPy*)self)->startNotify();
00335         return ret;
00336     }
00337     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00338     {
00339         std::string str;
00340         str += "FreeCAD exception thrown (";
00341         str += e.what();
00342         str += ")";
00343         e.ReportException();
00344         PyErr_SetString(PyExc_Exception,str.c_str());
00345         return NULL;
00346     }
00347     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00348     {
00349         std::string str;
00350         str += "File system exception thrown (";
00351         //str += e.who();
00352         //str += ", ";
00353         str += e.what();
00354         str += ")\n";
00355         Base::Console().Error(str.c_str());
00356         PyErr_SetString(PyExc_Exception,str.c_str());
00357         return NULL;
00358     }
00359     catch(const Py::Exception&)
00360     {
00361         // The exception text is already set
00362         return NULL;
00363     }
00364     catch(const char* e) // catch simple string exceptions
00365     {
00366         Base::Console().Error(e);
00367         PyErr_SetString(PyExc_Exception,e);
00368         return NULL;
00369     }
00370     // in debug not all exceptions will be catched to get the attention of the developer!
00371 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00372     catch(const std::exception& e) // catch other c++ exceptions
00373     {
00374         std::string str;
00375         str += "FC++ exception thrown (";
00376         str += e.what();
00377         str += ")";
00378         Base::Console().Error(str.c_str());
00379         PyErr_SetString(PyExc_Exception,str.c_str());
00380         return NULL;
00381     }
00382     catch(...)  // catch the rest!
00383     {
00384         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00385         return NULL;
00386     }
00387 #endif
00388 }
00389 
00390 // toggleConstruction() callback and implementer
00391 // PyObject*  SketchObjectPy::toggleConstruction(PyObject *args){};
00392 // has to be implemented in SketchObjectPyImp.cpp
00393 PyObject * SketchObjectPy::staticCallback_toggleConstruction (PyObject *self, PyObject *args)
00394 {
00395     // test if twin object not allready deleted
00396     if (!((PyObjectBase*) self)->isValid()){
00397         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00398         return NULL;
00399     }
00400 
00401     // test if object is set Const
00402     if (((PyObjectBase*) self)->isConst()){
00403         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00404         return NULL;
00405     }
00406 
00407     try { // catches all exceptions coming up from c++ and generate a python exception
00408         PyObject* ret = ((SketchObjectPy*)self)->toggleConstruction(args);
00409         if (ret != 0)
00410             ((SketchObjectPy*)self)->startNotify();
00411         return ret;
00412     }
00413     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00414     {
00415         std::string str;
00416         str += "FreeCAD exception thrown (";
00417         str += e.what();
00418         str += ")";
00419         e.ReportException();
00420         PyErr_SetString(PyExc_Exception,str.c_str());
00421         return NULL;
00422     }
00423     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00424     {
00425         std::string str;
00426         str += "File system exception thrown (";
00427         //str += e.who();
00428         //str += ", ";
00429         str += e.what();
00430         str += ")\n";
00431         Base::Console().Error(str.c_str());
00432         PyErr_SetString(PyExc_Exception,str.c_str());
00433         return NULL;
00434     }
00435     catch(const Py::Exception&)
00436     {
00437         // The exception text is already set
00438         return NULL;
00439     }
00440     catch(const char* e) // catch simple string exceptions
00441     {
00442         Base::Console().Error(e);
00443         PyErr_SetString(PyExc_Exception,e);
00444         return NULL;
00445     }
00446     // in debug not all exceptions will be catched to get the attention of the developer!
00447 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00448     catch(const std::exception& e) // catch other c++ exceptions
00449     {
00450         std::string str;
00451         str += "FC++ exception thrown (";
00452         str += e.what();
00453         str += ")";
00454         Base::Console().Error(str.c_str());
00455         PyErr_SetString(PyExc_Exception,str.c_str());
00456         return NULL;
00457     }
00458     catch(...)  // catch the rest!
00459     {
00460         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00461         return NULL;
00462     }
00463 #endif
00464 }
00465 
00466 // addConstraint() callback and implementer
00467 // PyObject*  SketchObjectPy::addConstraint(PyObject *args){};
00468 // has to be implemented in SketchObjectPyImp.cpp
00469 PyObject * SketchObjectPy::staticCallback_addConstraint (PyObject *self, PyObject *args)
00470 {
00471     // test if twin object not allready deleted
00472     if (!((PyObjectBase*) self)->isValid()){
00473         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00474         return NULL;
00475     }
00476 
00477     // test if object is set Const
00478     if (((PyObjectBase*) self)->isConst()){
00479         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00480         return NULL;
00481     }
00482 
00483     try { // catches all exceptions coming up from c++ and generate a python exception
00484         PyObject* ret = ((SketchObjectPy*)self)->addConstraint(args);
00485         if (ret != 0)
00486             ((SketchObjectPy*)self)->startNotify();
00487         return ret;
00488     }
00489     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00490     {
00491         std::string str;
00492         str += "FreeCAD exception thrown (";
00493         str += e.what();
00494         str += ")";
00495         e.ReportException();
00496         PyErr_SetString(PyExc_Exception,str.c_str());
00497         return NULL;
00498     }
00499     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00500     {
00501         std::string str;
00502         str += "File system exception thrown (";
00503         //str += e.who();
00504         //str += ", ";
00505         str += e.what();
00506         str += ")\n";
00507         Base::Console().Error(str.c_str());
00508         PyErr_SetString(PyExc_Exception,str.c_str());
00509         return NULL;
00510     }
00511     catch(const Py::Exception&)
00512     {
00513         // The exception text is already set
00514         return NULL;
00515     }
00516     catch(const char* e) // catch simple string exceptions
00517     {
00518         Base::Console().Error(e);
00519         PyErr_SetString(PyExc_Exception,e);
00520         return NULL;
00521     }
00522     // in debug not all exceptions will be catched to get the attention of the developer!
00523 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00524     catch(const std::exception& e) // catch other c++ exceptions
00525     {
00526         std::string str;
00527         str += "FC++ exception thrown (";
00528         str += e.what();
00529         str += ")";
00530         Base::Console().Error(str.c_str());
00531         PyErr_SetString(PyExc_Exception,str.c_str());
00532         return NULL;
00533     }
00534     catch(...)  // catch the rest!
00535     {
00536         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00537         return NULL;
00538     }
00539 #endif
00540 }
00541 
00542 // delConstraint() callback and implementer
00543 // PyObject*  SketchObjectPy::delConstraint(PyObject *args){};
00544 // has to be implemented in SketchObjectPyImp.cpp
00545 PyObject * SketchObjectPy::staticCallback_delConstraint (PyObject *self, PyObject *args)
00546 {
00547     // test if twin object not allready deleted
00548     if (!((PyObjectBase*) self)->isValid()){
00549         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00550         return NULL;
00551     }
00552 
00553     // test if object is set Const
00554     if (((PyObjectBase*) self)->isConst()){
00555         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00556         return NULL;
00557     }
00558 
00559     try { // catches all exceptions coming up from c++ and generate a python exception
00560         PyObject* ret = ((SketchObjectPy*)self)->delConstraint(args);
00561         if (ret != 0)
00562             ((SketchObjectPy*)self)->startNotify();
00563         return ret;
00564     }
00565     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00566     {
00567         std::string str;
00568         str += "FreeCAD exception thrown (";
00569         str += e.what();
00570         str += ")";
00571         e.ReportException();
00572         PyErr_SetString(PyExc_Exception,str.c_str());
00573         return NULL;
00574     }
00575     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00576     {
00577         std::string str;
00578         str += "File system exception thrown (";
00579         //str += e.who();
00580         //str += ", ";
00581         str += e.what();
00582         str += ")\n";
00583         Base::Console().Error(str.c_str());
00584         PyErr_SetString(PyExc_Exception,str.c_str());
00585         return NULL;
00586     }
00587     catch(const Py::Exception&)
00588     {
00589         // The exception text is already set
00590         return NULL;
00591     }
00592     catch(const char* e) // catch simple string exceptions
00593     {
00594         Base::Console().Error(e);
00595         PyErr_SetString(PyExc_Exception,e);
00596         return NULL;
00597     }
00598     // in debug not all exceptions will be catched to get the attention of the developer!
00599 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00600     catch(const std::exception& e) // catch other c++ exceptions
00601     {
00602         std::string str;
00603         str += "FC++ exception thrown (";
00604         str += e.what();
00605         str += ")";
00606         Base::Console().Error(str.c_str());
00607         PyErr_SetString(PyExc_Exception,str.c_str());
00608         return NULL;
00609     }
00610     catch(...)  // catch the rest!
00611     {
00612         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00613         return NULL;
00614     }
00615 #endif
00616 }
00617 
00618 // addExternal() callback and implementer
00619 // PyObject*  SketchObjectPy::addExternal(PyObject *args){};
00620 // has to be implemented in SketchObjectPyImp.cpp
00621 PyObject * SketchObjectPy::staticCallback_addExternal (PyObject *self, PyObject *args)
00622 {
00623     // test if twin object not allready deleted
00624     if (!((PyObjectBase*) self)->isValid()){
00625         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00626         return NULL;
00627     }
00628 
00629     // test if object is set Const
00630     if (((PyObjectBase*) self)->isConst()){
00631         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00632         return NULL;
00633     }
00634 
00635     try { // catches all exceptions coming up from c++ and generate a python exception
00636         PyObject* ret = ((SketchObjectPy*)self)->addExternal(args);
00637         if (ret != 0)
00638             ((SketchObjectPy*)self)->startNotify();
00639         return ret;
00640     }
00641     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00642     {
00643         std::string str;
00644         str += "FreeCAD exception thrown (";
00645         str += e.what();
00646         str += ")";
00647         e.ReportException();
00648         PyErr_SetString(PyExc_Exception,str.c_str());
00649         return NULL;
00650     }
00651     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00652     {
00653         std::string str;
00654         str += "File system exception thrown (";
00655         //str += e.who();
00656         //str += ", ";
00657         str += e.what();
00658         str += ")\n";
00659         Base::Console().Error(str.c_str());
00660         PyErr_SetString(PyExc_Exception,str.c_str());
00661         return NULL;
00662     }
00663     catch(const Py::Exception&)
00664     {
00665         // The exception text is already set
00666         return NULL;
00667     }
00668     catch(const char* e) // catch simple string exceptions
00669     {
00670         Base::Console().Error(e);
00671         PyErr_SetString(PyExc_Exception,e);
00672         return NULL;
00673     }
00674     // in debug not all exceptions will be catched to get the attention of the developer!
00675 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00676     catch(const std::exception& e) // catch other c++ exceptions
00677     {
00678         std::string str;
00679         str += "FC++ exception thrown (";
00680         str += e.what();
00681         str += ")";
00682         Base::Console().Error(str.c_str());
00683         PyErr_SetString(PyExc_Exception,str.c_str());
00684         return NULL;
00685     }
00686     catch(...)  // catch the rest!
00687     {
00688         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00689         return NULL;
00690     }
00691 #endif
00692 }
00693 
00694 // delExternal() callback and implementer
00695 // PyObject*  SketchObjectPy::delExternal(PyObject *args){};
00696 // has to be implemented in SketchObjectPyImp.cpp
00697 PyObject * SketchObjectPy::staticCallback_delExternal (PyObject *self, PyObject *args)
00698 {
00699     // test if twin object not allready deleted
00700     if (!((PyObjectBase*) self)->isValid()){
00701         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00702         return NULL;
00703     }
00704 
00705     // test if object is set Const
00706     if (((PyObjectBase*) self)->isConst()){
00707         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00708         return NULL;
00709     }
00710 
00711     try { // catches all exceptions coming up from c++ and generate a python exception
00712         PyObject* ret = ((SketchObjectPy*)self)->delExternal(args);
00713         if (ret != 0)
00714             ((SketchObjectPy*)self)->startNotify();
00715         return ret;
00716     }
00717     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00718     {
00719         std::string str;
00720         str += "FreeCAD exception thrown (";
00721         str += e.what();
00722         str += ")";
00723         e.ReportException();
00724         PyErr_SetString(PyExc_Exception,str.c_str());
00725         return NULL;
00726     }
00727     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00728     {
00729         std::string str;
00730         str += "File system exception thrown (";
00731         //str += e.who();
00732         //str += ", ";
00733         str += e.what();
00734         str += ")\n";
00735         Base::Console().Error(str.c_str());
00736         PyErr_SetString(PyExc_Exception,str.c_str());
00737         return NULL;
00738     }
00739     catch(const Py::Exception&)
00740     {
00741         // The exception text is already set
00742         return NULL;
00743     }
00744     catch(const char* e) // catch simple string exceptions
00745     {
00746         Base::Console().Error(e);
00747         PyErr_SetString(PyExc_Exception,e);
00748         return NULL;
00749     }
00750     // in debug not all exceptions will be catched to get the attention of the developer!
00751 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00752     catch(const std::exception& e) // catch other c++ exceptions
00753     {
00754         std::string str;
00755         str += "FC++ exception thrown (";
00756         str += e.what();
00757         str += ")";
00758         Base::Console().Error(str.c_str());
00759         PyErr_SetString(PyExc_Exception,str.c_str());
00760         return NULL;
00761     }
00762     catch(...)  // catch the rest!
00763     {
00764         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00765         return NULL;
00766     }
00767 #endif
00768 }
00769 
00770 // delConstraintOnPoint() callback and implementer
00771 // PyObject*  SketchObjectPy::delConstraintOnPoint(PyObject *args){};
00772 // has to be implemented in SketchObjectPyImp.cpp
00773 PyObject * SketchObjectPy::staticCallback_delConstraintOnPoint (PyObject *self, PyObject *args)
00774 {
00775     // test if twin object not allready deleted
00776     if (!((PyObjectBase*) self)->isValid()){
00777         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00778         return NULL;
00779     }
00780 
00781     // test if object is set Const
00782     if (((PyObjectBase*) self)->isConst()){
00783         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00784         return NULL;
00785     }
00786 
00787     try { // catches all exceptions coming up from c++ and generate a python exception
00788         PyObject* ret = ((SketchObjectPy*)self)->delConstraintOnPoint(args);
00789         if (ret != 0)
00790             ((SketchObjectPy*)self)->startNotify();
00791         return ret;
00792     }
00793     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00794     {
00795         std::string str;
00796         str += "FreeCAD exception thrown (";
00797         str += e.what();
00798         str += ")";
00799         e.ReportException();
00800         PyErr_SetString(PyExc_Exception,str.c_str());
00801         return NULL;
00802     }
00803     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00804     {
00805         std::string str;
00806         str += "File system exception thrown (";
00807         //str += e.who();
00808         //str += ", ";
00809         str += e.what();
00810         str += ")\n";
00811         Base::Console().Error(str.c_str());
00812         PyErr_SetString(PyExc_Exception,str.c_str());
00813         return NULL;
00814     }
00815     catch(const Py::Exception&)
00816     {
00817         // The exception text is already set
00818         return NULL;
00819     }
00820     catch(const char* e) // catch simple string exceptions
00821     {
00822         Base::Console().Error(e);
00823         PyErr_SetString(PyExc_Exception,e);
00824         return NULL;
00825     }
00826     // in debug not all exceptions will be catched to get the attention of the developer!
00827 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00828     catch(const std::exception& e) // catch other c++ exceptions
00829     {
00830         std::string str;
00831         str += "FC++ exception thrown (";
00832         str += e.what();
00833         str += ")";
00834         Base::Console().Error(str.c_str());
00835         PyErr_SetString(PyExc_Exception,str.c_str());
00836         return NULL;
00837     }
00838     catch(...)  // catch the rest!
00839     {
00840         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00841         return NULL;
00842     }
00843 #endif
00844 }
00845 
00846 // setDatum() callback and implementer
00847 // PyObject*  SketchObjectPy::setDatum(PyObject *args){};
00848 // has to be implemented in SketchObjectPyImp.cpp
00849 PyObject * SketchObjectPy::staticCallback_setDatum (PyObject *self, PyObject *args)
00850 {
00851     // test if twin object not allready deleted
00852     if (!((PyObjectBase*) self)->isValid()){
00853         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00854         return NULL;
00855     }
00856 
00857     // test if object is set Const
00858     if (((PyObjectBase*) self)->isConst()){
00859         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00860         return NULL;
00861     }
00862 
00863     try { // catches all exceptions coming up from c++ and generate a python exception
00864         PyObject* ret = ((SketchObjectPy*)self)->setDatum(args);
00865         if (ret != 0)
00866             ((SketchObjectPy*)self)->startNotify();
00867         return ret;
00868     }
00869     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00870     {
00871         std::string str;
00872         str += "FreeCAD exception thrown (";
00873         str += e.what();
00874         str += ")";
00875         e.ReportException();
00876         PyErr_SetString(PyExc_Exception,str.c_str());
00877         return NULL;
00878     }
00879     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00880     {
00881         std::string str;
00882         str += "File system exception thrown (";
00883         //str += e.who();
00884         //str += ", ";
00885         str += e.what();
00886         str += ")\n";
00887         Base::Console().Error(str.c_str());
00888         PyErr_SetString(PyExc_Exception,str.c_str());
00889         return NULL;
00890     }
00891     catch(const Py::Exception&)
00892     {
00893         // The exception text is already set
00894         return NULL;
00895     }
00896     catch(const char* e) // catch simple string exceptions
00897     {
00898         Base::Console().Error(e);
00899         PyErr_SetString(PyExc_Exception,e);
00900         return NULL;
00901     }
00902     // in debug not all exceptions will be catched to get the attention of the developer!
00903 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00904     catch(const std::exception& e) // catch other c++ exceptions
00905     {
00906         std::string str;
00907         str += "FC++ exception thrown (";
00908         str += e.what();
00909         str += ")";
00910         Base::Console().Error(str.c_str());
00911         PyErr_SetString(PyExc_Exception,str.c_str());
00912         return NULL;
00913     }
00914     catch(...)  // catch the rest!
00915     {
00916         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00917         return NULL;
00918     }
00919 #endif
00920 }
00921 
00922 // movePoint() callback and implementer
00923 // PyObject*  SketchObjectPy::movePoint(PyObject *args){};
00924 // has to be implemented in SketchObjectPyImp.cpp
00925 PyObject * SketchObjectPy::staticCallback_movePoint (PyObject *self, PyObject *args)
00926 {
00927     // test if twin object not allready deleted
00928     if (!((PyObjectBase*) self)->isValid()){
00929         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00930         return NULL;
00931     }
00932 
00933     // test if object is set Const
00934     if (((PyObjectBase*) self)->isConst()){
00935         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00936         return NULL;
00937     }
00938 
00939     try { // catches all exceptions coming up from c++ and generate a python exception
00940         PyObject* ret = ((SketchObjectPy*)self)->movePoint(args);
00941         if (ret != 0)
00942             ((SketchObjectPy*)self)->startNotify();
00943         return ret;
00944     }
00945     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00946     {
00947         std::string str;
00948         str += "FreeCAD exception thrown (";
00949         str += e.what();
00950         str += ")";
00951         e.ReportException();
00952         PyErr_SetString(PyExc_Exception,str.c_str());
00953         return NULL;
00954     }
00955     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00956     {
00957         std::string str;
00958         str += "File system exception thrown (";
00959         //str += e.who();
00960         //str += ", ";
00961         str += e.what();
00962         str += ")\n";
00963         Base::Console().Error(str.c_str());
00964         PyErr_SetString(PyExc_Exception,str.c_str());
00965         return NULL;
00966     }
00967     catch(const Py::Exception&)
00968     {
00969         // The exception text is already set
00970         return NULL;
00971     }
00972     catch(const char* e) // catch simple string exceptions
00973     {
00974         Base::Console().Error(e);
00975         PyErr_SetString(PyExc_Exception,e);
00976         return NULL;
00977     }
00978     // in debug not all exceptions will be catched to get the attention of the developer!
00979 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00980     catch(const std::exception& e) // catch other c++ exceptions
00981     {
00982         std::string str;
00983         str += "FC++ exception thrown (";
00984         str += e.what();
00985         str += ")";
00986         Base::Console().Error(str.c_str());
00987         PyErr_SetString(PyExc_Exception,str.c_str());
00988         return NULL;
00989     }
00990     catch(...)  // catch the rest!
00991     {
00992         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00993         return NULL;
00994     }
00995 #endif
00996 }
00997 
00998 // fillet() callback and implementer
00999 // PyObject*  SketchObjectPy::fillet(PyObject *args){};
01000 // has to be implemented in SketchObjectPyImp.cpp
01001 PyObject * SketchObjectPy::staticCallback_fillet (PyObject *self, PyObject *args)
01002 {
01003     // test if twin object not allready deleted
01004     if (!((PyObjectBase*) self)->isValid()){
01005         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01006         return NULL;
01007     }
01008 
01009     // test if object is set Const
01010     if (((PyObjectBase*) self)->isConst()){
01011         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
01012         return NULL;
01013     }
01014 
01015     try { // catches all exceptions coming up from c++ and generate a python exception
01016         PyObject* ret = ((SketchObjectPy*)self)->fillet(args);
01017         if (ret != 0)
01018             ((SketchObjectPy*)self)->startNotify();
01019         return ret;
01020     }
01021     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01022     {
01023         std::string str;
01024         str += "FreeCAD exception thrown (";
01025         str += e.what();
01026         str += ")";
01027         e.ReportException();
01028         PyErr_SetString(PyExc_Exception,str.c_str());
01029         return NULL;
01030     }
01031     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
01032     {
01033         std::string str;
01034         str += "File system exception thrown (";
01035         //str += e.who();
01036         //str += ", ";
01037         str += e.what();
01038         str += ")\n";
01039         Base::Console().Error(str.c_str());
01040         PyErr_SetString(PyExc_Exception,str.c_str());
01041         return NULL;
01042     }
01043     catch(const Py::Exception&)
01044     {
01045         // The exception text is already set
01046         return NULL;
01047     }
01048     catch(const char* e) // catch simple string exceptions
01049     {
01050         Base::Console().Error(e);
01051         PyErr_SetString(PyExc_Exception,e);
01052         return NULL;
01053     }
01054     // in debug not all exceptions will be catched to get the attention of the developer!
01055 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01056     catch(const std::exception& e) // catch other c++ exceptions
01057     {
01058         std::string str;
01059         str += "FC++ exception thrown (";
01060         str += e.what();
01061         str += ")";
01062         Base::Console().Error(str.c_str());
01063         PyErr_SetString(PyExc_Exception,str.c_str());
01064         return NULL;
01065     }
01066     catch(...)  // catch the rest!
01067     {
01068         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01069         return NULL;
01070     }
01071 #endif
01072 }
01073 
01074 // trim() callback and implementer
01075 // PyObject*  SketchObjectPy::trim(PyObject *args){};
01076 // has to be implemented in SketchObjectPyImp.cpp
01077 PyObject * SketchObjectPy::staticCallback_trim (PyObject *self, PyObject *args)
01078 {
01079     // test if twin object not allready deleted
01080     if (!((PyObjectBase*) self)->isValid()){
01081         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01082         return NULL;
01083     }
01084 
01085     // test if object is set Const
01086     if (((PyObjectBase*) self)->isConst()){
01087         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
01088         return NULL;
01089     }
01090 
01091     try { // catches all exceptions coming up from c++ and generate a python exception
01092         PyObject* ret = ((SketchObjectPy*)self)->trim(args);
01093         if (ret != 0)
01094             ((SketchObjectPy*)self)->startNotify();
01095         return ret;
01096     }
01097     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01098     {
01099         std::string str;
01100         str += "FreeCAD exception thrown (";
01101         str += e.what();
01102         str += ")";
01103         e.ReportException();
01104         PyErr_SetString(PyExc_Exception,str.c_str());
01105         return NULL;
01106     }
01107     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
01108     {
01109         std::string str;
01110         str += "File system exception thrown (";
01111         //str += e.who();
01112         //str += ", ";
01113         str += e.what();
01114         str += ")\n";
01115         Base::Console().Error(str.c_str());
01116         PyErr_SetString(PyExc_Exception,str.c_str());
01117         return NULL;
01118     }
01119     catch(const Py::Exception&)
01120     {
01121         // The exception text is already set
01122         return NULL;
01123     }
01124     catch(const char* e) // catch simple string exceptions
01125     {
01126         Base::Console().Error(e);
01127         PyErr_SetString(PyExc_Exception,e);
01128         return NULL;
01129     }
01130     // in debug not all exceptions will be catched to get the attention of the developer!
01131 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01132     catch(const std::exception& e) // catch other c++ exceptions
01133     {
01134         std::string str;
01135         str += "FC++ exception thrown (";
01136         str += e.what();
01137         str += ")";
01138         Base::Console().Error(str.c_str());
01139         PyErr_SetString(PyExc_Exception,str.c_str());
01140         return NULL;
01141     }
01142     catch(...)  // catch the rest!
01143     {
01144         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01145         return NULL;
01146     }
01147 #endif
01148 }
01149 
01150 // ConstraintCount() callback and implementer
01151 // PyObject*  SketchObjectPy::ConstraintCount(PyObject *args){};
01152 // has to be implemented in SketchObjectPyImp.cpp
01153 PyObject * SketchObjectPy::staticCallback_getConstraintCount (PyObject *self, void * /*closure*/)
01154 {
01155     if (!((PyObjectBase*) self)->isValid()){
01156         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01157         return NULL;
01158     }
01159 
01160     try {
01161         return Py::new_reference_to(((SketchObjectPy*)self)->getConstraintCount());
01162     } catch (const Py::Exception&) {
01163         // The exception text is already set
01164         return NULL;
01165     } catch (...) {
01166         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'ConstraintCount' of object 'SketchObject'");
01167         return NULL;
01168     }
01169 }
01170 
01171 int SketchObjectPy::staticCallback_setConstraintCount (PyObject *self, PyObject * /*value*/, void * /*closure*/)
01172 {
01173     if (!((PyObjectBase*) self)->isValid()){
01174         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01175         return -1;
01176     }
01177 
01178     PyErr_SetString(PyExc_AttributeError, "Attribute 'ConstraintCount' of object 'SketchObject' is read-only");
01179     return -1;
01180 }
01181 
01182 // GeometryCount() callback and implementer
01183 // PyObject*  SketchObjectPy::GeometryCount(PyObject *args){};
01184 // has to be implemented in SketchObjectPyImp.cpp
01185 PyObject * SketchObjectPy::staticCallback_getGeometryCount (PyObject *self, void * /*closure*/)
01186 {
01187     if (!((PyObjectBase*) self)->isValid()){
01188         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01189         return NULL;
01190     }
01191 
01192     try {
01193         return Py::new_reference_to(((SketchObjectPy*)self)->getGeometryCount());
01194     } catch (const Py::Exception&) {
01195         // The exception text is already set
01196         return NULL;
01197     } catch (...) {
01198         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'GeometryCount' of object 'SketchObject'");
01199         return NULL;
01200     }
01201 }
01202 
01203 int SketchObjectPy::staticCallback_setGeometryCount (PyObject *self, PyObject * /*value*/, void * /*closure*/)
01204 {
01205     if (!((PyObjectBase*) self)->isValid()){
01206         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01207         return -1;
01208     }
01209 
01210     PyErr_SetString(PyExc_AttributeError, "Attribute 'GeometryCount' of object 'SketchObject' is read-only");
01211     return -1;
01212 }
01213 
01214 
01215 
01216 //--------------------------------------------------------------------------
01217 // Parents structure
01218 //--------------------------------------------------------------------------
01219 PyParentObject SketchObjectPy::Parents[] = { PARENTSSketcherSketchObjectPy };
01220 
01221 //--------------------------------------------------------------------------
01222 // Constructor
01223 //--------------------------------------------------------------------------
01224 SketchObjectPy::SketchObjectPy(SketchObject *pcObject, PyTypeObject *T)
01225     : Part2DObjectPy(reinterpret_cast<Part2DObjectPy::PointerType>(pcObject), T)
01226 {
01227 }
01228 
01229 PyObject *SketchObjectPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
01230 {
01231     // never create such objects with the constructor
01232     PyErr_SetString(PyExc_RuntimeError, "You cannot create directly an instance of 'SketchObjectPy'.");
01233  
01234     return 0;
01235 }
01236 
01237 int SketchObjectPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
01238 {
01239     return 0;
01240 }
01241 
01242 //--------------------------------------------------------------------------
01243 // destructor
01244 //--------------------------------------------------------------------------
01245 SketchObjectPy::~SketchObjectPy()                                // Everything handled in parent
01246 {
01247 }
01248 
01249 //--------------------------------------------------------------------------
01250 // SketchObjectPy representation
01251 //--------------------------------------------------------------------------
01252 PyObject *SketchObjectPy::_repr(void)
01253 {
01254     return Py_BuildValue("s", representation().c_str());
01255 }
01256 
01257 //--------------------------------------------------------------------------
01258 // SketchObjectPy Attributes
01259 //--------------------------------------------------------------------------
01260 PyObject *SketchObjectPy::_getattr(char *attr)                          // __getattr__ function: note only need to handle new state
01261 {
01262     try {
01263         // getter method for special Attributes (e.g. dynamic ones)
01264         PyObject *r = getCustomAttributes(attr);
01265         if(r) return r;
01266     }
01267 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01268     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01269     {
01270         std::string str;
01271         str += "FreeCAD exception thrown (";
01272         str += e.what();
01273         str += ")";
01274         e.ReportException();
01275         PyErr_SetString(PyExc_Exception,str.c_str());
01276         return NULL;
01277     }
01278     catch(const std::exception& e) // catch other c++ exceptions
01279     {
01280         std::string str;
01281         str += "FC++ exception thrown (";
01282         str += e.what();
01283         str += ")";
01284         Base::Console().Error(str.c_str());
01285         PyErr_SetString(PyExc_Exception,str.c_str());
01286         return NULL;
01287     }
01288     catch(const Py::Exception&)
01289     {
01290         // The exception text is already set
01291         return NULL;
01292     }
01293     catch(...)  // catch the rest!
01294     {
01295         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01296         return NULL;
01297     }
01298 #else  // DONT_CATCH_CXX_EXCEPTIONS  
01299     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01300     {
01301         std::string str;
01302         str += "FreeCAD exception thrown (";
01303         str += e.what();
01304         str += ")";
01305         e.ReportException();
01306         PyErr_SetString(PyExc_Exception,str.c_str());
01307         return NULL;
01308     }
01309     catch(const Py::Exception&)
01310     {
01311         // The exception text is already set
01312         return NULL;
01313     }
01314 #endif  // DONT_CATCH_CXX_EXCEPTIONS
01315 
01316     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
01317     if (rvalue == NULL)
01318     {
01319         PyErr_Clear();
01320         return Part2DObjectPy::_getattr(attr);
01321     }
01322     else
01323     {
01324         return rvalue;
01325     }
01326 }
01327 
01328 int SketchObjectPy::_setattr(char *attr, PyObject *value)       // __setattr__ function: note only need to handle new state
01329 {
01330     try {
01331         // setter for  special Attributes (e.g. dynamic ones)
01332         int r = setCustomAttributes(attr, value);
01333         if(r==1) return 0;
01334     }
01335 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01336     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01337     {
01338         std::string str;
01339         str += "FreeCAD exception thrown (";
01340         str += e.what();
01341         str += ")";
01342         e.ReportException();
01343         PyErr_SetString(PyExc_Exception,str.c_str());
01344         return -1;
01345     }
01346     catch(const std::exception& e) // catch other c++ exceptions
01347     {
01348         std::string str;
01349         str += "FC++ exception thrown (";
01350         str += e.what();
01351         str += ")";
01352         Base::Console().Error(str.c_str());
01353         PyErr_SetString(PyExc_Exception,str.c_str());
01354         return -1;
01355     }
01356     catch(const Py::Exception&)
01357     {
01358         // The exception text is already set
01359         return -1;
01360     }
01361     catch(...)  // catch the rest!
01362     {
01363         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01364         return -1;
01365     }
01366 #else  // DONT_CATCH_CXX_EXCEPTIONS  
01367     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01368     {
01369         std::string str;
01370         str += "FreeCAD exception thrown (";
01371         str += e.what();
01372         str += ")";
01373         e.ReportException();
01374         PyErr_SetString(PyExc_Exception,str.c_str());
01375         return -1;
01376     }
01377     catch(const Py::Exception&)
01378     {
01379         // The exception text is already set
01380         return -1;
01381     }
01382 #endif  // DONT_CATCH_CXX_EXCEPTIONS
01383 
01384     return Part2DObjectPy::_setattr(attr, value);
01385 }
01386 
01387 SketchObject *SketchObjectPy::getSketchObjectPtr(void) const
01388 {
01389     return static_cast<SketchObject *>(_pcTwinPointer);
01390 }
01391 
01392 #if 0
01393 /* From here on come the methods you have to implement, but NOT in this module. Implement in SketchObjectPyImp.cpp! This prototypes 
01394  * are just for convenience when you add a new method.
01395  */
01396 
01397 
01398 // returns a string which represents the object e.g. when printed in python
01399 std::string SketchObjectPy::representation(void) const
01400 {
01401     return std::string("<SketchObject object>");
01402 }
01403 
01404 PyObject* SketchObjectPy::solve(PyObject *args)
01405 {
01406     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01407     return 0;
01408 }
01409 
01410 PyObject* SketchObjectPy::addGeometry(PyObject *args)
01411 {
01412     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01413     return 0;
01414 }
01415 
01416 PyObject* SketchObjectPy::delGeometry(PyObject *args)
01417 {
01418     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01419     return 0;
01420 }
01421 
01422 PyObject* SketchObjectPy::toggleConstruction(PyObject *args)
01423 {
01424     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01425     return 0;
01426 }
01427 
01428 PyObject* SketchObjectPy::addConstraint(PyObject *args)
01429 {
01430     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01431     return 0;
01432 }
01433 
01434 PyObject* SketchObjectPy::delConstraint(PyObject *args)
01435 {
01436     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01437     return 0;
01438 }
01439 
01440 PyObject* SketchObjectPy::addExternal(PyObject *args)
01441 {
01442     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01443     return 0;
01444 }
01445 
01446 PyObject* SketchObjectPy::delExternal(PyObject *args)
01447 {
01448     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01449     return 0;
01450 }
01451 
01452 PyObject* SketchObjectPy::delConstraintOnPoint(PyObject *args)
01453 {
01454     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01455     return 0;
01456 }
01457 
01458 PyObject* SketchObjectPy::setDatum(PyObject *args)
01459 {
01460     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01461     return 0;
01462 }
01463 
01464 PyObject* SketchObjectPy::movePoint(PyObject *args)
01465 {
01466     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01467     return 0;
01468 }
01469 
01470 PyObject* SketchObjectPy::fillet(PyObject *args)
01471 {
01472     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01473     return 0;
01474 }
01475 
01476 PyObject* SketchObjectPy::trim(PyObject *args)
01477 {
01478     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01479     return 0;
01480 }
01481 
01482 
01483 
01484 Py::Int SketchObjectPy::getConstraintCount(void) const
01485 {
01486     //return Py::Int();
01487     throw Py::AttributeError("Not yet implemented");
01488 }
01489 
01490 Py::Int SketchObjectPy::getGeometryCount(void) const
01491 {
01492     //return Py::Int();
01493     throw Py::AttributeError("Not yet implemented");
01494 }
01495 
01496 PyObject *SketchObjectPy::getCustomAttributes(const char* attr) const
01497 {
01498     return 0;
01499 }
01500 
01501 int SketchObjectPy::setCustomAttributes(const char* attr, PyObject *obj)
01502 {
01503     return 0; 
01504 }
01505 #endif
01506 
01507 
01508 

Generated on Wed Nov 23 19:00:38 2011 for FreeCAD by  doxygen 1.6.1