Assembly: Make pre-solve and reverse move all the downstream parts (#24193)

This commit is contained in:
PaddleStroke
2025-10-07 18:44:11 +02:00
committed by GitHub
parent c64f06c3ad
commit 6282dd48bb
3 changed files with 105 additions and 61 deletions

View File

@@ -198,3 +198,36 @@ Py::List AssemblyObjectPy::getJoints() const
return ret;
}
PyObject* AssemblyObjectPy::getDownstreamParts(PyObject* args) const
{
PyObject* pyPart;
PyObject* pyJoint;
// Parse the two arguments: a part object and a joint object
if (!PyArg_ParseTuple(args,
"O!O!",
&(App::DocumentObjectPy::Type),
&pyPart,
&(App::DocumentObjectPy::Type),
&pyJoint)) {
return nullptr;
}
auto* part = static_cast<App::DocumentObjectPy*>(pyPart)->getDocumentObjectPtr();
auto* joint = static_cast<App::DocumentObjectPy*>(pyJoint)->getDocumentObjectPtr();
// Call the C++ method
std::vector<Assembly::ObjRef> downstreamParts =
this->getAssemblyObjectPtr()->getDownstreamParts(part, joint);
// Convert the result into a Python list of DocumentObjects
Py::List ret;
for (const auto& objRef : downstreamParts) {
if (objRef.obj) {
ret.append(Py::Object(objRef.obj->getPyObject(), true));
}
}
return Py::new_reference_to(ret);
}