Toponaming: Support disabling hashing; getting element history
This commit is contained in:
@@ -37,6 +37,45 @@ std::string PartFeaturePy::representation() const
|
||||
return {"<Part::PartFeature>"};
|
||||
}
|
||||
|
||||
PyObject *PartFeaturePy::getElementHistory(PyObject *args, PyObject *kwds) {
|
||||
const char *name;
|
||||
PyObject *recursive = Py_True;
|
||||
PyObject *sameType = Py_False;
|
||||
PyObject *showName = Py_False;
|
||||
static char *kwlist[] = {"elementName", "recursive", "sameType", "showName", nullptr};
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|OOO", kwlist, &name, &recursive, &sameType, &showName))
|
||||
return {};
|
||||
|
||||
auto feature = getFeaturePtr();
|
||||
Py::List list;
|
||||
bool showObjName = PyObject_IsTrue(showName);
|
||||
PY_TRY {
|
||||
std::string tmp;
|
||||
for (auto &history: Feature::getElementHistory(feature, name,
|
||||
PyObject_IsTrue(recursive), PyObject_IsTrue(sameType))) {
|
||||
Py::Tuple ret(3);
|
||||
if (history.obj) {
|
||||
if (showObjName) {
|
||||
ret.setItem(0, Py::TupleN(Py::String(history.obj->getFullName()),
|
||||
Py::String(history.obj->Label.getValue())));
|
||||
} else
|
||||
ret.setItem(0, Py::Object(history.obj->getPyObject(), true));
|
||||
} else
|
||||
ret.setItem(0, Py::Int(history.tag));
|
||||
tmp.clear();
|
||||
ret.setItem(1, Py::String(history.element.appendToBuffer(tmp)));
|
||||
Py::List intermedates;
|
||||
for (auto &h: history.intermediates) {
|
||||
tmp.clear();
|
||||
intermedates.append(Py::String(h.appendToBuffer(tmp)));
|
||||
}
|
||||
ret.setItem(2, intermedates);
|
||||
list.append(ret);
|
||||
}
|
||||
return Py::new_reference_to(list);
|
||||
} PY_CATCH;
|
||||
}
|
||||
|
||||
PyObject *PartFeaturePy::getCustomAttributes(const char* ) const
|
||||
{
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user