FeaturePython objects include the Python class's __repr__ it their __repr__ (#24462)
This commit is contained in:
@@ -33,7 +33,25 @@ using namespace Part;
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string AttachExtensionPy::representation() const
|
||||
{
|
||||
return {"<Part::AttachableObject>"};
|
||||
auto* P = getAttachExtensionPtr()->getExtendedObject()->getPropertyByName("Proxy");
|
||||
if (P) {
|
||||
PyObject* Featclass = static_cast<App::PropertyPythonObject*>(P)->getValue().ptr();
|
||||
PyObject* repstr = PyObject_Repr(Featclass);
|
||||
if (repstr) {
|
||||
Py_ssize_t len;
|
||||
std::string ret = fmt::format(
|
||||
"<Attachable {} ({})>\n",
|
||||
getAttachExtensionPtr()->getExtendedObject()->getTypeId().getName(),
|
||||
PyUnicode_AsUTF8AndSize(repstr, &len)
|
||||
);
|
||||
Py_DECREF(repstr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return fmt::format(
|
||||
"<Attachable {}>",
|
||||
getAttachExtensionPtr()->getExtendedObject()->getTypeId().getName()
|
||||
);
|
||||
}
|
||||
|
||||
PyObject* AttachExtensionPy::positionBySupport(PyObject* args)
|
||||
|
||||
@@ -37,6 +37,22 @@ using namespace Part;
|
||||
// returns a string which represent the object e.g. when printed in python
|
||||
std::string PartFeaturePy::representation() const
|
||||
{
|
||||
auto* P = getFeaturePtr()->getPropertyByName("Proxy");
|
||||
if (P) {
|
||||
PyObject* Featclass = static_cast<App::PropertyPythonObject*>(P)->getValue().ptr();
|
||||
PyObject* repstr = PyObject_Repr(Featclass);
|
||||
if (repstr) {
|
||||
Py_ssize_t len;
|
||||
std::string ret = fmt::format(
|
||||
"<{} ({})>\n",
|
||||
static_cast<std::string>(getTypeId()),
|
||||
PyUnicode_AsUTF8AndSize(repstr, &len)
|
||||
);
|
||||
Py_DECREF(repstr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return fmt::format("<{}>", static_cast<std::string>(getTypeId()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user