Create standard XY, XZ, YZ planes when running the PartDesign_Body command if they don't exist yet

This commit is contained in:
jrheinlaender
2013-03-31 17:43:37 +04:30
committed by Stefan Tröger
parent 13f3ff24c3
commit dde81fe8f5
3 changed files with 58 additions and 17 deletions

View File

@@ -153,17 +153,22 @@ void Workbench::activated()
// make the previously used active Body active again
PartDesign::Body* activeBody = NULL;
std::vector<App::DocumentObject*> bodies = App::GetApplication().getActiveDocument()->getObjectsOfType(PartDesign::Body::getClassTypeId());
for (std::vector<App::DocumentObject*>::const_iterator b = bodies.begin(); b != bodies.end(); b++) {
PartDesign::Body* body = static_cast<PartDesign::Body*>(*b);
if (body->IsActive.getValue()) {
activeBody = body;
break;
App::Document* activeDocument = App::GetApplication().getActiveDocument();
if (activeDocument != NULL) {
std::vector<App::DocumentObject*> bodies = activeDocument->getObjectsOfType(PartDesign::Body::getClassTypeId());
for (std::vector<App::DocumentObject*>::const_iterator b = bodies.begin(); b != bodies.end(); b++) {
PartDesign::Body* body = static_cast<PartDesign::Body*>(*b);
if (body->IsActive.getValue()) {
activeBody = body;
break;
}
}
// If there is only one body, make it active
if ((activeBody == NULL) && (bodies.size() == 1))
activeBody = static_cast<PartDesign::Body*>(bodies.front());
}
// If there is only one body, make it active
if ((activeBody == NULL) && (bodies.size() == 1))
activeBody = static_cast<PartDesign::Body*>(bodies.front());
if (activeBody != NULL) {
Gui::Command::doCommand(Gui::Command::Doc,"import PartDesignGui");