本文整理汇总了C++中DocumentObject::getPyObject方法的典型用法代码示例。如果您正苦于以下问题:C++ DocumentObject::getPyObject方法的具体用法?C++ DocumentObject::getPyObject怎么用?C++ DocumentObject::getPyObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentObject
的用法示例。
在下文中一共展示了DocumentObject::getPyObject方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addObject
PyObject* DocumentPy::addObject(PyObject *args)
{
char *sType,*sName=0;
PyObject* obj=0;
PyObject* view=0;
if (!PyArg_ParseTuple(args, "s|sOO", &sType,&sName,&obj,&view)) // convert args: Python->C
return NULL; // NULL triggers exception
DocumentObject *pcFtr;
pcFtr = getDocumentPtr()->addObject(sType,sName);
if (pcFtr) {
// Allows to hide the handling with Proxy in client python code
if (obj) {
try {
// the python binding class to the document object
Py::Object pyftr = Py::asObject(pcFtr->getPyObject());
// 'pyobj' is the python class with the implementation for DocumentObject
Py::Object pyobj(obj);
if (pyobj.hasAttr("__object__")) {
pyobj.setAttr("__object__", pyftr);
}
pyftr.setAttr("Proxy", pyobj);
// if a document class is set we also need a view provider defined which must be
// something different to None
Py::Object pyvp;
if (view)
pyvp = Py::Object(view);
if (pyvp.isNone())
pyvp = Py::Int(1);
// 'pyvp' is the python class with the implementation for ViewProvider
if (pyvp.hasAttr("__vobject__")) {
pyvp.setAttr("__vobject__", pyftr.getAttr("ViewObject"));
}
pyftr.getAttr("ViewObject").setAttr("Proxy", pyvp);
return Py::new_reference_to(pyftr);
}
catch (Py::Exception& e) {
e.clear();
}
}
return pcFtr->getPyObject();
}
else {
std::stringstream str;
str << "No document object found of type '" << sType << "'" << std::ends;
throw Py::Exception(PyExc_Exception,str.str());
}
}
示例2: getActiveObject
Py::Object DocumentPy::getActiveObject(void) const
{
DocumentObject *pcFtr = getDocumentPtr()->getActiveObject();
if(pcFtr)
return Py::Object(pcFtr->getPyObject(), true);
return Py::None();
}
示例3: getObject
PyObject* DocumentPy::getObject(PyObject *args)
{
char *sName;
if (!PyArg_ParseTuple(args, "s",&sName)) // convert args: Python->C
return NULL; // NULL triggers exception
DocumentObject *pcFtr = getDocumentPtr()->getObject(sName);
if (pcFtr)
return pcFtr->getPyObject();
else
Py_Return;
}
示例4: getObject
PyObject* DocumentObjectGroupPy::getObject(PyObject *args)
{
char* pcName;
if (!PyArg_ParseTuple(args, "s", &pcName)) // convert args: Python->C
return NULL; // NULL triggers exception
DocumentObject* obj = getDocumentObjectGroupPtr()->getObject(pcName);
if ( obj ) {
return obj->getPyObject();
} else {
Py_Return;
}
}
示例5: newObject
PyObject* DocumentObjectGroupPy::newObject(PyObject *args)
{
char *sType,*sName=0;
if (!PyArg_ParseTuple(args, "s|s", &sType,&sName)) // convert args: Python->C
return NULL;
DocumentObject *object = getDocumentObjectGroupPtr()->addObject(sType, sName);
if ( object ) {
return object->getPyObject();
}
else {
PyErr_Format(Base::BaseExceptionFreeCADError, "Cannot create object of type '%s'", sType);
return NULL;
}
}
示例6: moveObject
PyObject* DocumentPy::moveObject(PyObject *args)
{
PyObject *obj, *rec=Py_False;
if (!PyArg_ParseTuple(args, "O!|O!",&(DocumentObjectPy::Type),&obj,&PyBool_Type,&rec))
return NULL; // NULL triggers exception
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(obj);
DocumentObject* move = getDocumentPtr()->moveObject(docObj->getDocumentObjectPtr(), PyObject_IsTrue(rec) ? true : false);
if (move) {
return move->getPyObject();
}
else {
std::string str("Failed to move the object");
throw Py::Exception(PyExc_Exception,str);
}
}
示例7: copyObject
PyObject* DocumentPy::copyObject(PyObject *args)
{
PyObject *obj, *rec=0;
if (!PyArg_ParseTuple(args, "O!|O!",&(DocumentObjectPy::Type),&obj,&PyBool_Type,&rec))
return NULL; // NULL triggers exception
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(obj);
DocumentObject* copy = getDocumentPtr()->copyObject(docObj->getDocumentObjectPtr(), rec==Py_True);
if (copy) {
return copy->getPyObject();
}
else {
std::string str("Failed to copy the object");
throw Py::Exception(PyExc_Exception,str);
}
}
示例8: getPropertyContainerPtr
PyObject *DocumentPy::getCustomAttributes(const char* attr) const
{
// Note: Here we want to return only a document object if its
// name matches 'attr'. However, it is possible to have an object
// with the same name as an attribute. If so, we return 0 as other-
// wise it wouldn't be possible to address this attribute any more.
// The object must then be addressed by the getObject() method directly.
App::Property* prop = getPropertyContainerPtr()->getPropertyByName(attr);
if (prop) return 0;
if (this->ob_type->tp_dict == NULL) {
if (PyType_Ready(this->ob_type) < 0)
return 0;
}
PyObject* item = PyDict_GetItemString(this->ob_type->tp_dict, attr);
if (item) return 0;
// search for an object with this name
DocumentObject* obj = getDocumentPtr()->getObject(attr);
return (obj ? obj->getPyObject() : 0);
}