diff --git a/src/Mod/PartDesign/App/FeatureDressUp.cpp b/src/Mod/PartDesign/App/FeatureDressUp.cpp index dae0a17cb..fba49cc21 100644 --- a/src/Mod/PartDesign/App/FeatureDressUp.cpp +++ b/src/Mod/PartDesign/App/FeatureDressUp.cpp @@ -64,20 +64,18 @@ void DressUp::positionByBaseFeature(void) this->Placement.setValue(base->Placement.getValue()); } -Part::TopoShape DressUp::getBaseShape() +Part::Feature *DressUp::getBaseObject() const { - App::DocumentObject* link = BaseFeature.getValue(); - if (!link) - link = this->Base.getValue(); // For legacy features - if (!link) - throw Base::Exception("No object linked"); - if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) - throw Base::Exception("Linked object is not a Part object"); - Part::Feature* base = static_cast(link); - const Part::TopoShape& shape = base->Shape.getShape(); - if (shape._Shape.IsNull()) - throw Base::Exception("Cannot draft invalid shape"); - return shape; + try { + return Feature::getBaseObject(); + } catch (const Base::Exception &) { + App::DocumentObject* base = Base.getValue(); + if(!base) + throw Base::Exception("No Base object linked"); + if(!base->isDerivedFrom(Part::Feature::getClassTypeId())) + throw Base::Exception("Linked object is not a Part object"); + return static_cast(base); + } } void DressUp::getContiniusEdges(Part::TopoShape TopShape, std::vector< std::string >& SubNames) { @@ -142,20 +140,21 @@ void DressUp::getContiniusEdges(Part::TopoShape TopShape, std::vector< std::stri else { SubNames.erase(SubNames.begin()+i); } - } + } } void DressUp::onChanged(const App::Property* prop) { - // the BaseFeature property should always link to the same feature as the Base + // the BaseFeature property should track the Base and vice-versa as long as + // the feature is inside a body (aka BaseFeature is nonzero) if (prop == &BaseFeature) { - if (Base.getValue() != BaseFeature.getValue()) { + if (BaseFeature.getValue() && Base.getValue() != BaseFeature.getValue()) { Base.setValue (BaseFeature.getValue()); } } else if (prop == &Base) { // track the vice-versa changes - if (Base.getValue() != BaseFeature.getValue()) { + if (BaseFeature.getValue() && Base.getValue() != BaseFeature.getValue()) { BaseFeature.setValue (Base.getValue()); } } diff --git a/src/Mod/PartDesign/App/FeatureDressUp.h b/src/Mod/PartDesign/App/FeatureDressUp.h index 4a9e42ade..35a0155c3 100644 --- a/src/Mod/PartDesign/App/FeatureDressUp.h +++ b/src/Mod/PartDesign/App/FeatureDressUp.h @@ -39,15 +39,19 @@ public: /** * Base feature and it's subelements to which dressup operation will be aplied to. - * It always refers to the same feature Feature::BaseFeature does, but unlike it - * the Base property also includes SubLinks. + * Unlike Feature::BaseFeature it includes Sublinks and set not only inside a body. + * But for consistancy if BaseFeature is nonzero this links to the same body as it. */ App::PropertyLinkSub Base; short mustExecute() const; /// updates the Placement property from the Placement of the BaseFeature void positionByBaseFeature(void); - Part::TopoShape getBaseShape(); + /** + * Returns the BaseFeature property's object if it's set othervice returns Base's + * feature property object otherviceeature property's object (if any) + */ + virtual Part::Feature* getBaseObject() const; /// extracts all edges from the subshapes (inkluding face edges) and furthermore adds /// all C0 continius edges to the vector void getContiniusEdges(Part::TopoShape, std::vector< std::string >&);