From 896e774c41f6b785f3d8263b0b3fe8f3c21ac838 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Thu, 26 Mar 2020 18:39:06 +0800 Subject: [PATCH] PartDesign: fix DressUp SupportTransform Skip multiple consequtive DressUp features when SupportTransform is enabled. --- src/Mod/PartDesign/App/FeatureDressUp.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureDressUp.cpp b/src/Mod/PartDesign/App/FeatureDressUp.cpp index 7c24ba95d8..1d957363c5 100644 --- a/src/Mod/PartDesign/App/FeatureDressUp.cpp +++ b/src/Mod/PartDesign/App/FeatureDressUp.cpp @@ -203,13 +203,25 @@ void DressUp::getAddSubShape(Part::TopoShape &addShape, Part::TopoShape &subShap shape.setPlacement(Base::Placement()); FeatureAddSub *base = nullptr; - if(SupportTransform.getValue()) - base = Base::freecad_dynamic_cast(getBaseObject(true)); + if(SupportTransform.getValue()) { + // SupportTransform means transform the support together with + // the dressing. So we need to find the previous support + // feature (which must be of type FeatureAddSub), and skipping + // any consequtive DressUp in-between. + for(Feature *current=this; ;current=static_cast(base)) { + base = Base::freecad_dynamic_cast(current->getBaseObject(true)); + if(!base) + FC_THROWM(Base::CADKernelError, + "Cannot find additive or subtractive support for " << getFullName()); + if(!base->isDerivedFrom(DressUp::getClassTypeId())) + break; + } + } Part::TopoShape baseShape; if(base) { baseShape = base->getBaseTopoShape(true); - baseShape.setPlacement(Base::Placement()); + baseShape.move(base->getLocation().Inverted()); if (base->getAddSubType() == Additive) { if(!baseShape.isNull() && baseShape.hasSubShape(TopAbs_SOLID)) shapes.push_back(shape.cut(baseShape.getShape())); @@ -228,7 +240,7 @@ void DressUp::getAddSubShape(Part::TopoShape &addShape, Part::TopoShape &subShap } } else { baseShape = getBaseTopoShape(); - baseShape.setPlacement(Base::Placement()); + baseShape.move(getLocation().Inverted()); shapes.push_back(shape.cut(baseShape.getShape())); shapes.push_back(baseShape.cut(shape.getShape())); }