Assembly: Fix crash 20614 (#22844)

* Assembly: Fix crash 20614 (#22538)

(cherry picked from commit facfbeb47e)

* adapt to `getMovingPartFromRef` from 1.0 branch

* fix `Console().Warning` has PascalCase name in 1.0

---------

Co-authored-by: PaddleStroke <[email protected]>
Co-authored-by: Adrian Insaurralde Avalos <[email protected]>
This commit is contained in:
github-actions[bot]
2025-08-01 09:28:01 -03:00
committed by GitHub
co-authored by PaddleStroke Adrian Insaurralde Avalos
parent 1bcf27e1aa
commit 34b70663d1
2 changed files with 25 additions and 1 deletions
+23 -1
View File
@@ -1273,7 +1273,7 @@ AssemblyObject::makeMbdJoint(App::DocumentObject* joint)
JointType jointType = getJointType(joint);
std::shared_ptr<ASMTJoint> mbdJoint = makeMbdJointOfType(joint, jointType);
if (!mbdJoint) {
if (!mbdJoint || !isMbDJointValid(joint)) {
return {};
}
@@ -1581,6 +1581,28 @@ int AssemblyObject::slidingPartIndex(App::DocumentObject* joint)
return slidingFound;
}
bool AssemblyObject::isMbDJointValid(App::DocumentObject* joint)
{
// When dragging a part, we are bundling fixed parts together.
// This may lead to a conflicting joint that is self referencing a MbD part.
// The solver crash when fed such a bad joint. So we make sure it does not happen.
App::DocumentObject* part1 = getMovingPartFromRef(joint, "Reference1");
App::DocumentObject* part2 = getMovingPartFromRef(joint, "Reference2");
if (!part1 || !part2) {
return false;
}
// If this joint is self-referential it must be ignored.
if (getMbDPart(part1) == getMbDPart(part2)) {
Base::Console().Warning(
"Assembly: Ignoring joint (%s) because its parts are connected by a fixed "
"joint bundle. This joint is a conflicting or redundant constraint.\n",
joint->getFullLabel());
return false;
}
return true;
}
AssemblyObject::MbDPartData AssemblyObject::getMbDData(App::DocumentObject* part)
{
auto it = objectPartMap.find(part);
+2
View File
@@ -245,6 +245,8 @@ public:
std::vector<AssemblyLink*> getSubAssemblies();
void updateGroundedJointsPlacements();
bool isMbDJointValid(App::DocumentObject* joint);
private:
std::shared_ptr<MbD::ASMTAssembly> mbdAssembly;