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.
This commit is contained in:
wmayer
2024-11-03 00:16:26 +01:00
parent 400d5c49ab
commit 5ea04e70c5

View File

@@ -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