Skip to content

Commit

Permalink
TechDraw: Allow DraftView command on any object
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yorikvanhavre committed Jul 7, 2022
1 parent 1f4e6ad commit c38e88c
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions src/Mod/TechDraw/Gui/Command.cpp
Expand Up @@ -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();
}
}

Expand Down

0 comments on commit c38e88c

Please sign in to comment.