Make Part working
This commit is contained in:
parent
1f1f6f81ce
commit
e9744c842d
|
@ -95,6 +95,7 @@
|
|||
#include "MeasureDistance.h"
|
||||
#include "Placement.h"
|
||||
#include "Plane.h"
|
||||
#include "Part.h"
|
||||
#include "MaterialObject.h"
|
||||
#include "Expression.h"
|
||||
|
||||
|
@ -1129,6 +1130,7 @@ void Application::initTypes(void)
|
|||
App ::MaterialObjectPython ::init();
|
||||
App ::Placement ::init();
|
||||
App ::Plane ::init();
|
||||
App ::Part ::init();
|
||||
|
||||
// Expression classes
|
||||
App ::Expression ::init();
|
||||
|
|
|
@ -104,6 +104,7 @@
|
|||
#include "ViewProviderMeasureDistance.h"
|
||||
#include "ViewProviderPlacement.h"
|
||||
#include "ViewProviderPlane.h"
|
||||
#include "ViewProviderPart.h"
|
||||
#include "ViewProviderMaterialObject.h"
|
||||
|
||||
#include "Language/Translator.h"
|
||||
|
@ -1530,6 +1531,7 @@ void Application::initTypes(void)
|
|||
Gui::ViewProviderPythonGeometry ::init();
|
||||
Gui::ViewProviderPlacement ::init();
|
||||
Gui::ViewProviderPlane ::init();
|
||||
Gui::ViewProviderPart ::init();
|
||||
Gui::ViewProviderMaterialObject ::init();
|
||||
Gui::ViewProviderMaterialObjectPython ::init();
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_VIEWPROVIDER_DOCUMENTOBJECTGROUP_H
|
||||
#define GUI_VIEWPROVIDER_DOCUMENTOBJECTGROUP_H
|
||||
#ifndef GUI_VIEWPROVIDER_ViewProviderPart_H
|
||||
#define GUI_VIEWPROVIDER_ViewProviderPart_H
|
||||
|
||||
|
||||
#include "ViewProviderGeometryObject.h"
|
||||
|
|
|
@ -108,22 +108,25 @@ void CmdPartDesignBody::activated(int iMsg)
|
|||
|
||||
// first check if Part is already created:
|
||||
App::Part *actPart = getDocument()->Tip.getValue<App::Part *>();
|
||||
|
||||
std::string PartName;
|
||||
if(!actPart){
|
||||
std::string PartName = getUniqueObjectName("Part");
|
||||
doCommand(Doc,"App.activeDocument().addObject('App::Part','%s')",PartName.c_str());
|
||||
// if not, creating a part and set it up by calling the appropiated function in Workbench
|
||||
PartName = getUniqueObjectName("Part");
|
||||
doCommand(Doc,"App.activeDocument().Tip = App.activeDocument().addObject('App::Part','%s')",PartName.c_str());
|
||||
PartDesignGui::Workbench::setUpPart(dynamic_cast<App::Part *>(getDocument()->getObject(PartName.c_str())));
|
||||
}
|
||||
}else
|
||||
PartName = actPart->getNameInDocument();
|
||||
|
||||
// add the Body feature itself, and make it active
|
||||
doCommand(Doc,"App.activeDocument().addObject('PartDesign::Body','%s')",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Model = []",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Tip = None",FeatName.c_str());
|
||||
doCommand(Doc,"import PartDesignGui");
|
||||
//doCommand(Doc,"App.activeDocument().%s.Model = []",FeatName.c_str());
|
||||
//doCommand(Doc,"App.activeDocument().%s.Tip = None",FeatName.c_str());
|
||||
addModule(Gui,"PartDesignGui"); // import the Gui module only once a session
|
||||
doCommand(Gui,"PartDesignGui.setActivePart(App.ActiveDocument.%s)", FeatName.c_str());
|
||||
// Make the "Create sketch" prompt appear in the task panel
|
||||
doCommand(Gui,"Gui.Selection.clearSelection()");
|
||||
doCommand(Gui,"Gui.Selection.addSelection(App.ActiveDocument.%s)", FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.addObject(App.ActiveDocument.%s)",PartName.c_str(),FeatName.c_str());
|
||||
|
||||
updateActive();
|
||||
}
|
||||
|
|
|
@ -115,19 +115,25 @@ PartDesign::Body *Workbench::setUpPart(const App::Part *part)
|
|||
}
|
||||
|
||||
if (!found) {
|
||||
// Add the planes ...
|
||||
Gui::Command::doCommand( Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", PartDesignGui::BaseplaneNames[0]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("XY-Plane").toStdString().c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", PartDesignGui::BaseplaneNames[1]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(1,0,0),-90))");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("XZ-Plane").toStdString().c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", PartDesignGui::BaseplaneNames[2]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(0,1,0),90))");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("YZ-Plane").toStdString().c_str());
|
||||
// ... and put them in the 'Origin' group
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::DocumentObjectGroup','%s')", QObject::tr("Origin").toStdString().c_str());
|
||||
for (unsigned i = 0; i < 3; i++)
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().Origin.addObject(App.activeDocument().getObject('%s'))", PartDesignGui::BaseplaneNames[i]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"OGroup = App.activeDocument().addObject('App::DocumentObjectGroup','%s')", "Origin");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"OGroup.Label = '%s'", QObject::tr("Origin").toStdString().c_str());
|
||||
// Add the planes ...
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", PartDesignGui::BaseplaneNames[0]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("XY-Plane").toStdString().c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"OGroup.addObject(App.activeDocument().ActiveObject)");
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", PartDesignGui::BaseplaneNames[1]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(1,0,0),-90))");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("XZ-Plane").toStdString().c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"OGroup.addObject(App.activeDocument().ActiveObject)");
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", PartDesignGui::BaseplaneNames[2]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(0,1,0),90))");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("YZ-Plane").toStdString().c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"OGroup.addObject(App.activeDocument().ActiveObject)");
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(OGroup)", part->getNameInDocument());
|
||||
// TODO: Fold the group (is that possible through the Python interface?)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user