diff --git a/src/Mod/PartDesign/App/Body.cpp b/src/Mod/PartDesign/App/Body.cpp index 6b5c98802c..9bde93a67a 100644 --- a/src/Mod/PartDesign/App/Body.cpp +++ b/src/Mod/PartDesign/App/Body.cpp @@ -206,8 +206,17 @@ bool Body::isMemberOfMultiTransform(const App::DocumentObject* f) if (f == NULL) return false; + // ORIGINAL COMMENT: // This can be recognized because the Originals property is empty (it is contained // in the MultiTransform instead) + // COMMENT ON THE COMMENT: + // This is wrong because at the creation (addObject) and before assigning the originals, that + // is when this code is executed, the originals property is indeed empty. + // + // However, for the purpose of setting the base feature, the transform feature has been modified + // to auto set it when the originals are not null. See: + // App::DocumentObjectExecReturn *Transformed::execute(void) + // return (f->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()) && static_cast(f)->Originals.getValues().empty()); } @@ -320,12 +329,18 @@ void Body::insertObject(App::DocumentObject* feature, App::DocumentObject* targe Group.setValues (model); // Set the BaseFeature property + setBaseProperty(feature); + +} + +void Body::setBaseProperty(App::DocumentObject* feature) +{ if (Body::isSolidFeature(feature)) { // Set BaseFeature property to previous feature (this might be the Tip feature) App::DocumentObject* prevSolidFeature = getPrevSolidFeature(feature); // NULL is ok here, it just means we made the current one fiature the base solid static_cast(feature)->BaseFeature.setValue(prevSolidFeature); - + // Reroute the next solid feature's BaseFeature property to this feature App::DocumentObject* nextSolidFeature = getNextSolidFeature(feature); if (nextSolidFeature) { @@ -333,10 +348,8 @@ void Body::insertObject(App::DocumentObject* feature, App::DocumentObject* targe static_cast(nextSolidFeature)->BaseFeature.setValue(feature); } } - } - std::vector Body::removeObject(App::DocumentObject* feature) { App::DocumentObject* nextSolidFeature = getNextSolidFeature(feature); diff --git a/src/Mod/PartDesign/App/Body.h b/src/Mod/PartDesign/App/Body.h index f623bce196..aec97be57f 100644 --- a/src/Mod/PartDesign/App/Body.h +++ b/src/Mod/PartDesign/App/Body.h @@ -84,6 +84,8 @@ public: */ void insertObject(App::DocumentObject* feature, App::DocumentObject* target, bool after=false); + void setBaseProperty(App::DocumentObject* feature); + /// Remove the feature from the body virtual std::vector removeObject(DocumentObject* obj) override; diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index a0c3ef113a..c3ff4dcd04 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -44,6 +44,7 @@ #include "FeatureLinearPattern.h" #include "FeaturePolarPattern.h" #include "FeatureSketchBased.h" +#include "Body.h" #include #include @@ -200,8 +201,18 @@ App::DocumentObjectExecReturn *Transformed::execute(void) rejected.clear(); std::vector originals = Originals.getValues(); - if (originals.empty()) // typically InsideMultiTransform + if (originals.empty()) {// typically InsideMultiTransform return App::DocumentObject::StdReturn; + } + else { + if(!this->BaseFeature.getValue()) { + auto body = getFeatureBody(); + + if(body) { + body->setBaseProperty(this); + } + } + } this->positionBySupport();