diff --git a/src/Mod/Assembly/App/AssemblyObject.cpp b/src/Mod/Assembly/App/AssemblyObject.cpp index cf74c3f830..510b34e31f 100644 --- a/src/Mod/Assembly/App/AssemblyObject.cpp +++ b/src/Mod/Assembly/App/AssemblyObject.cpp @@ -194,12 +194,30 @@ void AssemblyObject::preDrag(std::vector dragParts) solve(); bundleFixed = false; - dragMbdParts.clear(); + draggedParts.clear(); for (auto part : dragParts) { - auto mbdPart = getMbDPart(part); - if (std::find(dragMbdParts.begin(), dragMbdParts.end(), mbdPart) == dragMbdParts.end()) { - dragMbdParts.push_back(mbdPart); + // make sure no duplicate + if (std::find(draggedParts.begin(), draggedParts.end(), part) != draggedParts.end()) { + continue; } + + // Some objects have been bundled, we don't want to add these to dragged parts + Base::Placement plc; + for (auto& pair : objectPartMap) { + App::DocumentObject* parti = pair.first; + if (parti != part) { + continue; + } + plc = pair.second.offsetPlc; + } + if (!plc.isIdentity()) { + // If not identity, then it's a bundled object. Some bundled objects may + // have identity placement if they have the same position as the main object of + // the bundle. But they're not going to be a problem. + continue; + } + + draggedParts.push_back(part); } mbdAssembly->runPreDrag(); @@ -208,21 +226,16 @@ void AssemblyObject::preDrag(std::vector dragParts) void AssemblyObject::doDragStep() { try { - for (auto& mbdPart : dragMbdParts) { - App::DocumentObject* part = nullptr; - - // Find the corresponding DocumentObject for the mbdPart - for (auto& pair : objectPartMap) { - if (pair.second.part == mbdPart) { - part = pair.first; - break; - } - } + std::vector> dragMbdParts; + for (auto& part : draggedParts) { if (!part) { continue; } + auto mbdPart = getMbDPart(part); + dragMbdParts.push_back(mbdPart); + // Update the MBD part's position Base::Placement plc = getPlacementFromProp(part, "Placement"); Base::Vector3d pos = plc.getPosition(); diff --git a/src/Mod/Assembly/App/AssemblyObject.h b/src/Mod/Assembly/App/AssemblyObject.h index b2a083767f..a51968058e 100644 --- a/src/Mod/Assembly/App/AssemblyObject.h +++ b/src/Mod/Assembly/App/AssemblyObject.h @@ -250,7 +250,7 @@ private: std::unordered_map objectPartMap; std::vector> objMasses; - std::vector> dragMbdParts; + std::vector draggedParts; std::vector> previousPositions;