Steps to reproduce:Feature is not in a part
In order to use this feature it needs to belong to a part object in the document.
- Create a PartDesign Body with an Additive Box
- Switch to the Sketcher workbench (<--- obviously the wrong work flow, I'm trying to prove a point...)
- Select the top face of the Box
- Create a sketch, select FlatFace attachment mode
- Sketch a circle then close
- Switch back to the PartDesign workbench
- With the sketch selected, try to create any sketch-based PartDesign feature
- You get the aforementioned popup error.
https://github.com/FreeCAD/FreeCAD/blob ... s.cpp#L175
Code: Select all
App::Part* getPartFor(const App::DocumentObject* obj, bool messageIfNot) {
if(!obj)
return nullptr;
PartDesign::Body* body = getBodyFor(obj, false);
if(body)
obj = body;
//get the part
for(App::Part* p : obj->getDocument()->getObjectsOfType<App::Part>()) {
if(p->hasObject(obj)) {
return p;
}
}
if (messageIfNot){
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Feature is not in a part"),
QObject::tr("In order to use this feature it needs to belong to a part object in the document."));
}
return nullptr;
}
https://github.com/FreeCAD/FreeCAD/blob ... s.cpp#L142
Code: Select all
PartDesign::Body *getBodyFor(const App::DocumentObject* obj, bool messageIfNot,
bool autoActivate, bool assertModern)
{
if(!obj)
return nullptr;
PartDesign::Body * rv = getBody(/*messageIfNot =*/false, autoActivate, assertModern);
if (rv && rv->hasObject(obj))
return rv;
rv = PartDesign::Body::findBodyOf(obj);
if (rv) {
return rv;
}
if (messageIfNot){
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Feature is not in a body"),
QObject::tr("In order to use this feature it needs to belong to a body object in the document."));
}
return nullptr;
}
In my opinion, the bit of code starting with L158 should be removed. It is problematic, because it seems to supersede the proper error message that starts at L126, and misleads the end user about the nature of the error.
As far as I know, App:Part has no relevance to PartDesign.