PartDesign: do not include transform for sub-object in Feature

This commit is contained in:
Zheng, Lei
2023-03-06 19:59:57 +08:00
committed by Uwe
parent 4ed6150231
commit fac0a1740f
2 changed files with 43 additions and 0 deletions

View File

@@ -234,6 +234,44 @@ Body* Feature::getFeatureBody() const {
return nullptr;
}
App::DocumentObject *Feature::getSubObject(const char *subname,
PyObject **pyObj, Base::Matrix4D *pmat, bool transform, int depth) const
{
if (subname && subname != Data::ComplexGeoData::findElementName(subname)) {
const char * dot = strchr(subname,'.');
if (dot) {
auto body = PartDesign::Body::findBodyOf(this);
if (body) {
auto feat = body->Group.find(std::string(subname, dot));
if (feat) {
Base::Matrix4D _mat;
if (!transform) {
// Normally the parent object is supposed to transform
// the sub-object using its own placement. So, if no
// transform is requested, (i.e. no parent
// transformation), we just need to NOT apply the
// transformation.
//
// But PartDesign features (including sketch) are
// supposed to be contained inside a body. It makes
// little sense to transform its sub-object. So if 'no
// transform' is requested, we need to actively apply
// an inverse trasnform.
_mat = Placement.getValue().inverse().toMatrix();
if (pmat)
*pmat *= _mat;
else
pmat = &_mat;
}
return feat->getSubObject(dot+1, pyObj, pmat, true, depth+1);
}
}
}
}
return Part::Feature::getSubObject(subname, pyObj, pmat, transform, depth);
}
}//namespace PartDesign
namespace App {

View File

@@ -81,6 +81,11 @@ public:
return "PartDesignGui::ViewProvider";
}
App::DocumentObject *getSubObject(const char *subname,
PyObject **pyObj, Base::Matrix4D *pmat, bool transform, int depth) const override;
protected:
/**