When switching to the PartDesign workbench, activate the Body feature that was active when the document was last saved,
and move the selection to its Tip feature so that the user can start creating new features right away
This commit is contained in:
parent
1b809f305e
commit
acd88878af
|
@ -55,6 +55,7 @@ static PyObject * setActivePart(PyObject *self, PyObject *args)
|
|||
break;
|
||||
}
|
||||
|
||||
ActivePartObject->IsActive.setValue(false);
|
||||
ActivePartObject = 0;
|
||||
ActiveGuiDoc =0;
|
||||
ActiveAppDoc =0;
|
||||
|
@ -67,6 +68,7 @@ static PyObject * setActivePart(PyObject *self, PyObject *args)
|
|||
// Should be set!
|
||||
assert(Item);
|
||||
|
||||
Item->IsActive.setValue(true);
|
||||
ActivePartObject = Item;
|
||||
ActiveAppDoc = Item->getDocument();
|
||||
ActiveGuiDoc = Gui::Application::Instance->getDocument(ActiveAppDoc);
|
||||
|
|
|
@ -43,7 +43,7 @@ PROPERTY_SOURCE(PartDesign::Body, Part::BodyBase)
|
|||
|
||||
Body::Body()
|
||||
{
|
||||
|
||||
ADD_PROPERTY(IsActive,(0));
|
||||
}
|
||||
|
||||
short Body::mustExecute() const
|
||||
|
|
|
@ -38,6 +38,10 @@ class Body : public Part::BodyBase
|
|||
PROPERTY_HEADER(PartDesign::Body);
|
||||
|
||||
public:
|
||||
|
||||
/// True if this body feature is active or was active when the document was last closed
|
||||
App::PropertyBool IsActive;
|
||||
|
||||
Body();
|
||||
|
||||
/** @name methods override feature */
|
||||
|
|
|
@ -96,7 +96,7 @@ App::DocumentObjectExecReturn *Pad::execute(void)
|
|||
return new App::DocumentObjectExecReturn(e.what());
|
||||
}
|
||||
|
||||
// Find active Body feature and get the shape of the feature preceding this one for fusing
|
||||
// Find Body feature which owns this Pad and get the shape of the feature preceding this one for fusing
|
||||
PartDesign::Body* body = getBody();
|
||||
if (body == NULL) {
|
||||
return new App::DocumentObjectExecReturn(
|
||||
|
|
|
@ -151,9 +151,26 @@ void Workbench::activated()
|
|||
"PartDesign_MultiTransform"
|
||||
));
|
||||
|
||||
// set the previous used active Body
|
||||
if(oldActive != "")
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"PartDesignGui.setActivePart(App.activeDocument().%s)",oldActive.c_str());
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
// 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");
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"PartDesignGui.setActivePart(App.activeDocument().%s)", activeBody->getNameInDocument());
|
||||
// Move selection to the Tip feature so that the user can start creating new features right away
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.Selection.addSelection(App.ActiveDocument.%s.Tip)", activeBody->getNameInDocument());
|
||||
}
|
||||
|
||||
addTaskWatcher(Watcher);
|
||||
Gui::Control().showTaskView();
|
||||
|
@ -165,6 +182,7 @@ void Workbench::deactivated()
|
|||
{
|
||||
removeTaskWatcher();
|
||||
// remember the body for later activation
|
||||
// TODO: Remove this if the IsActive Property of Body works OK
|
||||
if(ActivePartObject)
|
||||
oldActive = ActivePartObject->getNameInDocument();
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue
Block a user