diff --git a/src/Mod/PartDesign/App/FeatureHole.cpp b/src/Mod/PartDesign/App/FeatureHole.cpp index 120ab5bfd1..679359e2bb 100644 --- a/src/Mod/PartDesign/App/FeatureHole.cpp +++ b/src/Mod/PartDesign/App/FeatureHole.cpp @@ -864,9 +864,7 @@ void Hole::updateHoleCutParams() HoleCutDepth.setValue(dimen.depth); } else { - // valid values for visual feedback - HoleCutDiameter.setValue(Diameter.getValue() + 0.1); - HoleCutDepth.setValue(0.1); + calculateAndSetCounterbore(); } } if (HoleCutDepth.getValue() == 0.0) @@ -880,13 +878,13 @@ void Hole::updateHoleCutParams() const CutDimensionSet& counter = find_cutDimensionSet(threadTypeStr, "ISO 10642"); if (HoleCutDiameter.getValue() == 0.0 || HoleCutDiameter.getValue() <= diameterVal) { const CounterSinkDimension& dimen = counter.get_sink(threadSizeStr); + HoleCutCountersinkAngle.setValue(counter.angle); if (dimen.diameter != 0.0) { HoleCutDiameter.setValue(dimen.diameter); } else { - HoleCutDiameter.setValue(Diameter.getValue() + 0.1); + calculateAndSetCountersink(); } - HoleCutCountersinkAngle.setValue(counter.angle); } if (HoleCutCountersinkAngle.getValue() == 0.0) { HoleCutCountersinkAngle.setValue(counter.angle); @@ -947,9 +945,7 @@ void Hole::updateHoleCutParams() HoleCutCountersinkAngle.setReadOnly(true); const CounterBoreDimension& dimen = counter.get_bore(threadSizeStr); if (dimen.thread == "None") { - // valid values for visual feedback - HoleCutDiameter.setValue(Diameter.getValue() + 0.1); - HoleCutDepth.setValue(0.1); + calculateAndSetCounterbore(); // we force custom values since there are no normed ones HoleCutCustomValues.setReadOnly(true); // important to set only if not already true, to avoid loop call of updateHoleCutParams() @@ -981,12 +977,11 @@ void Hole::updateHoleCutParams() else if (counter.cut_type == CutDimensionSet::Countersink) { const CounterSinkDimension& dimen = counter.get_sink(threadSizeStr); if (dimen.thread == "None") { - // valid values for visual feedback - HoleCutDiameter.setValue(Diameter.getValue() + 0.1); // there might be an angle of zero (if no norm exists for the size) if (HoleCutCountersinkAngle.getValue() == 0.0) { HoleCutCountersinkAngle.setValue(counter.angle); } + calculateAndSetCountersink(); // we force custom values since there are no normed ones HoleCutCustomValues.setReadOnly(true); // important to set only if not already true, to avoid loop call of updateHoleCutParams() @@ -2525,6 +2520,29 @@ bool Hole::isDynamicCountersink(const std::string& thread, const Hole::CounterBoreDimension Hole::CounterBoreDimension::nothing{ "None", 0.0, 0.0 }; const Hole::CounterSinkDimension Hole::CounterSinkDimension::nothing{ "None", 0.0 }; +void Hole::calculateAndSetCounterbore() +{ + // estimate a reasonable value since it's not on the standard + double threadDiameter = Diameter.getValue(); + double dk = (1.5 * threadDiameter) + 1.0; + double k = threadDiameter; + + HoleCutDiameter.setValue(dk); + HoleCutDepth.setValue(k); +} + +void Hole::calculateAndSetCountersink() +{ + // estimate a reasonable value since it's not on the standard + double threadDiameter = Diameter.getValue(); + double dk = 2.24 * threadDiameter; + double k = 0.62 * threadDiameter; + + HoleCutDiameter.setValue(dk); + HoleCutDepth.setValue(k); +} + + Hole::CutDimensionKey::CutDimensionKey(const std::string& t, const std::string& c) : thread_type{ t }, cut_name{ c } { diff --git a/src/Mod/PartDesign/App/FeatureHole.h b/src/Mod/PartDesign/App/FeatureHole.h index 956da4411b..96b8a91d34 100644 --- a/src/Mod/PartDesign/App/FeatureHole.h +++ b/src/Mod/PartDesign/App/FeatureHole.h @@ -239,6 +239,8 @@ private: void addCutType(const CutDimensionSet& dimensions); void updateHoleCutParams(); + void calculateAndSetCounterbore(); + void calculateAndSetCountersink(); std::optional determineDiameter() const; void updateDiameterParam(); void updateThreadDepthParam();