From e4ad21e48fecdda5fc8a4c7f3eea03c1e0a73ffa Mon Sep 17 00:00:00 2001 From: bgbsww Date: Tue, 17 Sep 2024 08:14:44 -0400 Subject: [PATCH] If we are creating a Sketch inside a Body that is in a link, use link position --- src/Mod/PartDesign/Gui/SketchWorkflow.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Mod/PartDesign/Gui/SketchWorkflow.cpp b/src/Mod/PartDesign/Gui/SketchWorkflow.cpp index 2901685df0..03ce5b52e0 100644 --- a/src/Mod/PartDesign/Gui/SketchWorkflow.cpp +++ b/src/Mod/PartDesign/Gui/SketchWorkflow.cpp @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -681,7 +682,13 @@ std::tuple SketchWorkflow::shouldCreateBody() // We need either an active Body, or for there to be no Body // objects (in which case, just make one) to make a new sketch. - PartDesign::Body* pdBody = PartDesignGui::getBody(/* messageIfNot = */ false); + // If we are inside a link, we need to use its placement. + App::DocumentObject *topParent; + PartDesign::Body *pdBody = PartDesignGui::getBody(/* messageIfNot = */ false, true, true, &topParent); + if (pdBody && topParent->isLink()) { + auto *xLink = dynamic_cast(topParent); + pdBody->Placement.setValue(xLink->Placement.getValue()); + } if (!pdBody) { if (appdocument->countObjectsOfType(PartDesign::Body::getClassTypeId()) == 0) { shouldMakeBody = true;