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.
This commit is contained in:
Yorik van Havre
2022-07-07 13:17:34 +02:00
parent f958e1a215
commit 9109ea2610

View File

@@ -1201,27 +1201,19 @@ void CmdTechDrawDraftView::activated(int iMsg)
}
std::pair<Base::Vector3d, Base::Vector3d> dirs = DrawGuiUtil::get3DDirAndRot();
int draftItemsFound = 0;
for (std::vector<App::DocumentObject*>::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();
}
}