Assembly: Change Joint References to remove cyclic dependency. (#25513)
* Assembly: Change Joint References to remove cyclic dependency. * Update JointObject.py * Update TestCore.py * Update JointObject.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update AssemblyUtils.cpp * Update UtilsAssembly.py * Update JointObject.py * small fix for link groups --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -520,14 +520,19 @@ App::DocumentObject* getObjFromProp(const App::DocumentObject* joint, const char
|
||||
return propObj->getValue();
|
||||
}
|
||||
|
||||
App::DocumentObject* getObjFromRef(const App::DocumentObject* obj, const std::string& sub)
|
||||
App::DocumentObject* getObjFromRef(App::DocumentObject* comp, const std::string& sub)
|
||||
{
|
||||
if (!obj) {
|
||||
if (!comp) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const auto* doc = obj->getDocument();
|
||||
const auto names = Base::Tools::splitSubName(sub);
|
||||
const auto* doc = comp->getDocument();
|
||||
auto names = Base::Tools::splitSubName(sub);
|
||||
names.insert(names.begin(), comp->getNameInDocument());
|
||||
|
||||
if (names.size() <= 2) {
|
||||
return comp;
|
||||
}
|
||||
|
||||
// Lambda function to check if the typeId is a BodySubObject
|
||||
const auto isBodySubObject = [](App::DocumentObject* obj) -> bool {
|
||||
@@ -618,7 +623,7 @@ App::DocumentObject* getObjFromRef(const App::PropertyXLinkSub* prop)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const App::DocumentObject* obj = prop->getValue();
|
||||
App::DocumentObject* obj = prop->getValue();
|
||||
if (!obj) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -631,7 +636,7 @@ App::DocumentObject* getObjFromRef(const App::PropertyXLinkSub* prop)
|
||||
return getObjFromRef(obj, subs[0]);
|
||||
}
|
||||
|
||||
App::DocumentObject* getObjFromRef(const App::DocumentObject* joint, const char* pName)
|
||||
App::DocumentObject* getObjFromJointRef(const App::DocumentObject* joint, const char* pName)
|
||||
{
|
||||
if (!joint) {
|
||||
return nullptr;
|
||||
@@ -647,13 +652,13 @@ App::DocumentObject* getLinkedObjFromRef(const App::DocumentObject* joint, const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (const auto* obj = getObjFromRef(joint, pObj)) {
|
||||
if (const auto* obj = getObjFromJointRef(joint, pObj)) {
|
||||
return obj->getLinkedObject(true);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
App::DocumentObject* getMovingPartFromRef(
|
||||
App::DocumentObject* getMovingPartFromSel(
|
||||
const AssemblyObject* assemblyObject,
|
||||
App::DocumentObject* obj,
|
||||
const std::string& sub
|
||||
@@ -710,39 +715,23 @@ App::DocumentObject* getMovingPartFromRef(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
App::DocumentObject* getMovingPartFromRef(
|
||||
const AssemblyObject* assemblyObject,
|
||||
App::PropertyXLinkSub* prop
|
||||
)
|
||||
App::DocumentObject* getMovingPartFromRef(App::PropertyXLinkSub* prop)
|
||||
{
|
||||
if (!prop) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
App::DocumentObject* obj = prop->getValue();
|
||||
if (!obj) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::vector<std::string> subs = prop->getSubValues();
|
||||
if (subs.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
return getMovingPartFromRef(assemblyObject, obj, subs[0]);
|
||||
return prop->getValue();
|
||||
}
|
||||
|
||||
App::DocumentObject* getMovingPartFromRef(
|
||||
const AssemblyObject* assemblyObject,
|
||||
App::DocumentObject* joint,
|
||||
const char* pName
|
||||
)
|
||||
App::DocumentObject* getMovingPartFromRef(App::DocumentObject* joint, const char* pName)
|
||||
{
|
||||
if (!joint) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto* prop = joint->getPropertyByName<App::PropertyXLinkSub>(pName);
|
||||
return getMovingPartFromRef(assemblyObject, prop);
|
||||
return getMovingPartFromRef(prop);
|
||||
}
|
||||
|
||||
void syncPlacements(App::DocumentObject* src, App::DocumentObject* to)
|
||||
|
||||
Reference in New Issue
Block a user