diff --git a/Cad/FeatureDrivenDrawer.cs b/Cad/FeatureDrivenDrawer.cs index 94ae317..1012f36 100644 --- a/Cad/FeatureDrivenDrawer.cs +++ b/Cad/FeatureDrivenDrawer.cs @@ -663,7 +663,7 @@ namespace CadParamPluging.Cad ctx, new Point3d(ox, oy, 0), new Point3d(ox + radius, oy, 0), - new Point3d(ox + radius / 2, oy - 23, 0), + new Point3d(ox + radius / 2, oy - 25, 0), 0, dimText, ApplyHalfSideDimStyle); @@ -957,8 +957,30 @@ namespace CadParamPluging.Cad // 在图纸右上角添加文字说明 try { + // Try to get original value to avoid scaling + var val = filletR; + if (ctx.OriginalBag != null) + { + // Check likely keys (could be Ring, Disk, Shaft, Box) + // We don't strictly know which one triggered this call without passing key, + // but we can check the context or just check all if they are mutually exclusive or consistent. + // Or better, just check the one that corresponds to current feature type. + + double? original = null; + if (FeatureDrivenDrawer.IsRing(ctx.StructuralFeature)) + original = ctx.OriginalBag.GetDoubleOrNull(KeyUnspecifiedFilletRadiusMax); + else if (FeatureDrivenDrawer.IsDisk(ctx.StructuralFeature)) + original = ctx.OriginalBag.GetDoubleOrNull(KeyDiskFilletRadiusMax); + else if (FeatureDrivenDrawer.IsShaft(ctx.StructuralFeature)) + original = ctx.OriginalBag.GetDoubleOrNull(KeyShaftFilletRadiusMax); + else if (FeatureDrivenDrawer.IsBlock(ctx.StructuralFeature)) + original = ctx.OriginalBag.GetDoubleOrNull(KeyBoxFilletRadiusMax); + + if (original.HasValue) val = original.Value; + } + var text = new DBText(); - text.TextString = $"未注圆角半径R≤{filletR}"; + text.TextString = $"未注圆角半径R≤{val}"; text.Position = new Point3d(ox + height + 10, oy + R + 15, 0); text.Height = 5; ctx.Style?.Apply(text, DrawingStyleManager.Role.Text); @@ -973,7 +995,8 @@ namespace CadParamPluging.Cad private static void DrawMinWallThicknessNote(DrawingContext ctx, double xInnerRight, double xOuterRight, double yBottom, double thickness) { - var dimText = $"{FormatDimNumber(thickness)}min"; + var val = ctx.OriginalBag?.GetDoubleOrNull(KeyMinWallThickness) ?? thickness; + var dimText = $"{FormatDimNumber(val)}min"; AddLinearDim( ctx, new Point3d(xInnerRight, yBottom, 0), @@ -1762,39 +1785,30 @@ namespace CadParamPluging.Cad // Lower deviation is usually displayed as negative number. double vm = tolMinus.Value; - // Use FormatDimNumber with raw string to respect input precision (e.g. "0.00" or "0") + // Use FormatDimNumber with raw string to respect input precision string formattedVal = FormatDimNumber(Math.Abs(vm), tolMinusStr); if (Math.Abs(vm) < 0.000001) { - // If it's zero. - // If raw string was "0", formatted is "0". - // If raw string was "0.00", formatted is "0.00". - // We just use the formatted value. minusStr = formattedVal; - - // Exception: if it's 0, we usually don't want a negative sign. - // Unless user explicitly wrote "-0"? Unlikely. } else { - // Force negative sign for lower deviation if it's not already negative in the formatted string? - // FormatDimNumber returns the number. If vm is positive in bag (abs deviation), we need minus. - minusStr = vm <= 0 - ? formattedVal - : $"-{formattedVal}"; + // Always display lower tolerance with negative sign + minusStr = $"-{formattedVal}"; } } // If we have both, stack them if (tolPlus.HasValue && tolMinus.HasValue) { - return $"{baseText}{{\\H{tolScale}x;\\S{plusStr}^{minusStr};}}"; + // Add a space between base text and tolerance stack to prevent crowding + return $"{baseText} {{\\H{tolScale}x;\\S{plusStr}^{minusStr};}}"; } // If only one side is present var single = tolPlus.HasValue ? plusStr : minusStr; - return $"{baseText}{{\\H{tolScale}x;{single}}}"; + return $"{baseText} {{\\H{tolScale}x;{single}}}"; } private static void ApplyHalfSideDimStyle(Dimension dim, DrawingContext ctx)