From 9109ea2610ace2cc37d37ad0ab042de51362e124 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 7 Jul 2022 13:17:34 +0200 Subject: [PATCH] TechDraw: Allow DraftView command on any object Currently the TechDraw DraftView command only accepts Draft objects as selected objects. However, the Draft SVG rendering works with almost anything (or at least it should :) ). This commit raises the restrictions amd allow the DraftView tool to work with any kind of selected object. --- src/Mod/TechDraw/Gui/Command.cpp | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index 732b820f2f..815b3637f5 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -1201,27 +1201,19 @@ void CmdTechDrawDraftView::activated(int iMsg) } std::pair dirs = DrawGuiUtil::get3DDirAndRot(); - int draftItemsFound = 0; for (std::vector::iterator it = objects.begin(); it != objects.end(); ++it) { - if (DrawGuiUtil::isDraftObject((*it))) { - draftItemsFound++; - std::string FeatName = getUniqueObjectName("DraftView"); - std::string SourceName = (*it)->getNameInDocument(); - openCommand(QT_TRANSLATE_NOOP("Command", "Create DraftView")); - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewDraft','%s')", FeatName.c_str()); - doCommand(Doc, "App.activeDocument().%s.Source = App.activeDocument().%s", - FeatName.c_str(), SourceName.c_str()); - doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", - PageName.c_str(), FeatName.c_str()); - doCommand(Doc, "App.activeDocument().%s.Direction = FreeCAD.Vector(%.3f,%.3f,%.3f)", - FeatName.c_str(), dirs.first.x, dirs.first.y, dirs.first.z); - updateActive(); - commitCommand(); - } - } - if (draftItemsFound == 0) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("There were no DraftWB objects in the selection.")); + std::string FeatName = getUniqueObjectName("DraftView"); + std::string SourceName = (*it)->getNameInDocument(); + openCommand(QT_TRANSLATE_NOOP("Command", "Create DraftView")); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewDraft','%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Source = App.activeDocument().%s", + FeatName.c_str(), SourceName.c_str()); + doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", + PageName.c_str(), FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Direction = FreeCAD.Vector(%.3f,%.3f,%.3f)", + FeatName.c_str(), dirs.first.x, dirs.first.y, dirs.first.z); + updateActive(); + commitCommand(); } }