fix part and body search for invalid objects
This commit is contained in:
parent
3aae4ce011
commit
20d551bc88
|
@ -201,6 +201,8 @@ App::DocumentObject* TaskSketchBasedParameters::getPartPlanes(const char* str) c
|
|||
//TODO: Adjust to GRAPH handling when available
|
||||
App::DocumentObject* obj = vp->getObject();
|
||||
App::Part* part = getPartFor(obj, true);
|
||||
if(!part)
|
||||
return nullptr;
|
||||
|
||||
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(origs.size()<1)
|
||||
|
@ -223,6 +225,8 @@ App::DocumentObject* TaskSketchBasedParameters::getPartLines(const char* str) co
|
|||
//TODO: Adjust to GRAPH handling when available
|
||||
App::DocumentObject* obj = vp->getObject();
|
||||
App::Part* part = getPartFor(obj, true);
|
||||
if(!part)
|
||||
return nullptr;
|
||||
|
||||
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(origs.size()<1)
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace PartDesignGui {
|
|||
|
||||
PartDesign::Body *getBody(bool messageIfNot)
|
||||
{
|
||||
PartDesign::Body * activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
PartDesign::Body * activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
|
||||
if (!activeBody && messageIfNot){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No active Body"),
|
||||
|
@ -85,13 +85,13 @@ PartDesign::Body *getBody(bool messageIfNot)
|
|||
"PartDesign to put them into a Body."
|
||||
));
|
||||
}
|
||||
return activeBody;
|
||||
return activeBody;
|
||||
|
||||
}
|
||||
|
||||
PartDesign::Body *getBodyFor(App::DocumentObject* obj, bool messageIfNot)
|
||||
{
|
||||
if(!obj || !obj->isValid())
|
||||
if(!obj)
|
||||
return nullptr;
|
||||
|
||||
PartDesign::Body * activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
|
@ -115,7 +115,7 @@ PartDesign::Body *getBodyFor(App::DocumentObject* obj, bool messageIfNot)
|
|||
|
||||
App::Part* getPartFor(App::DocumentObject* obj, bool messageIfNot) {
|
||||
|
||||
if(!obj || !obj->isValid())
|
||||
if(!obj)
|
||||
return nullptr;
|
||||
|
||||
PartDesign::Body* body = getBodyFor(obj, false);
|
||||
|
|
Loading…
Reference in New Issue
Block a user