From 5ea04e70c50171586099a1ab92c7752abae2cb64 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 3 Nov 2024 00:16:26 +0100 Subject: [PATCH] PD: If needed open another transaction for sketch creation When creating a sketch in PartDesign a dialog is opened that gives the user the possibility to perform another action that may close the active transaction. To make sure the creation of the sketch can be undone a new transaction must be opened. --- src/Mod/PartDesign/Gui/SketchWorkflow.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mod/PartDesign/Gui/SketchWorkflow.cpp b/src/Mod/PartDesign/Gui/SketchWorkflow.cpp index 25aa9f0cd9..2c623678e8 100644 --- a/src/Mod/PartDesign/Gui/SketchWorkflow.cpp +++ b/src/Mod/PartDesign/Gui/SketchWorkflow.cpp @@ -618,8 +618,13 @@ private: std::string FeatName = documentOfBody->getUniqueObjectName("Sketch"); std::string supportString = Gui::Command::getObjectCmd(plane,"(",",[''])"); + App::Document* doc = partDesignBody->getDocument(); + if (!doc->hasPendingTransaction()) { + doc->openTransaction(QT_TRANSLATE_NOOP("Command", "Create a new Sketch")); + } + FCMD_OBJ_CMD(partDesignBody,"newObject('Sketcher::SketchObject','" << FeatName << "')"); - auto Feat = partDesignBody->getDocument()->getObject(FeatName.c_str()); + auto Feat = doc->getObject(FeatName.c_str()); FCMD_OBJ_CMD(Feat,"AttachmentSupport = " << supportString); FCMD_OBJ_CMD(Feat,"MapMode = '" << Attacher::AttachEngine::getModeName(Attacher::mmFlatFace)<<"'"); Gui::Command::updateActive(); // Make sure the AttachmentSupport's Placement property is updated