diff --git a/Cad/FeatureDrivenDrawer.cs b/Cad/FeatureDrivenDrawer.cs index e5da4be..d1cea44 100644 --- a/Cad/FeatureDrivenDrawer.cs +++ b/Cad/FeatureDrivenDrawer.cs @@ -71,8 +71,8 @@ namespace CadParamPluging.Cad public const string KeyBoxSize2Prime = "BoxSize2Prime"; // 方体零件尺寸2 public const string KeyBoxSize3Prime = "BoxSize3Prime"; // 方体零件尺寸3 - // 其他参数 public const string KeyHardness = "Hardness"; // 硬度 + public const string KeyMarkingContent = "MarkingContent"; // 标刻内容 #endregion @@ -598,8 +598,13 @@ namespace CadParamPluging.Cad // 标注依然需要 // 用户反馈:下边的标注线在竖直方向上不要闭合(保持在底边水平),不要高于白色底部边框 - // 所以这里恢复 offset 为 0 - DrawInnerDiameterDimensionHalf(ctx, ox, xInnerRight.Value, oy, H, innerDia.Value, innerTolPlus, innerTolMinus, innerDiaPrime, 0.0); + // 修正:用户最新反馈(2026-01-21)要求“在竖直方向上,再向上闭合”,即连接到剖面的左下和右下角(圆角切点) + var dimExtensionOffset = 0.0; + if (r > 0.01) dimExtensionOffset = r; + + DrawInnerDiameterDimensionHalf(ctx, ox, xInnerRight.Value, oy, H, innerDia.Value, innerTolPlus, innerTolMinus, innerDiaPrime, dimExtensionOffset); + + // 剖面填充 // 剖面填充 DrawRingSectionHatchWithFillet(ctx, xInnerRight.Value, ox + visualOuterR, oy, H, unspecifiedFillet.Value); @@ -645,8 +650,21 @@ namespace CadParamPluging.Cad var minWallThickness = bag.GetDoubleOrNull(KeyMinWallThickness); if (minWallThickness.HasValue && minWallThickness.Value > 0 && xInnerRight.HasValue) { - // 用户反馈:下边标注线不要偏移,恢复为0 - DrawMinWallThicknessNote(ctx, xInnerRight.Value, ox + visualOuterR, oy, minWallThickness.Value, 0.0); + + // 同样应用闭合逻辑 + var dimExtensionOffset = 0.0; + // 注意这里需要重新获取一次r,或者复用上面的逻辑。 + // 简单起见,如果 applyUnspecifiedFillet 为真,则计算 r + if (applyUnspecifiedFillet && unspecifiedFillet.HasValue) + { + // Recalculate r + var sWidth = Math.Abs((ox + visualOuterR) - (xInnerRight.Value)); + var maxR = Math.Min(sWidth * 0.5, H * 0.5); + var rCalc = Math.Min(unspecifiedFillet.Value, maxR); + if (rCalc > 0.01) dimExtensionOffset = rCalc; + } + + DrawMinWallThicknessNote(ctx, xInnerRight.Value, ox + visualOuterR, oy, minWallThickness.Value, dimExtensionOffset); } // === 特征8: 零件轮廓(车加工态,右半边) === @@ -692,7 +710,16 @@ namespace CadParamPluging.Cad var xTarget = (xLoopInner + xLoopOuter) / 2.0; var yTarget = oy + H; - DrawSpecialHBLeaderToTop(ctx, xTarget, yTarget); + + + // 获取标刻内容 + var markingText = bag.GetString(KeyMarkingContent); + if (string.IsNullOrWhiteSpace(markingText)) + { + markingText = "HB5936-13"; // 默认值 + } + + DrawSpecialHBLeaderToTop(ctx, xTarget, yTarget, markingText); } else { @@ -2740,7 +2767,7 @@ namespace CadParamPluging.Cad } } - private static void DrawSpecialHBLeaderToTop(DrawingContext ctx, double xTarget, double yTarget) + private static void DrawSpecialHBLeaderToTop(DrawingContext ctx, double xTarget, double yTarget, string textContent) { try { @@ -2751,7 +2778,12 @@ namespace CadParamPluging.Cad var p2 = new Point3d(xTarget - 10, yTarget + 10, 0); // 终点:水平向左 - var p3 = new Point3d(p2.X - 35, p2.Y, 0); + // 长度根据文字长度适配,大致估算 + // 假设每个字符宽 2.5 (Height 3.5 * 0.7 roughly) + double textLen = (string.IsNullOrEmpty(textContent) ? 10 : textContent.Length) * 2.5; + if (textLen < 20) textLen = 20; // min length + + var p3 = new Point3d(p2.X - textLen, p2.Y, 0); var leader = new Leader(); leader.SetDatabaseDefaults(); @@ -2767,14 +2799,14 @@ namespace CadParamPluging.Cad // 绘制文字 var text = new DBText(); - text.TextString = "HB5936-13"; + text.TextString = textContent; text.Height = 3.5; text.ColorIndex = 7; // 白色 text.Layer = "0"; text.HorizontalMode = TextHorizontalMode.TextLeft; text.VerticalMode = TextVerticalMode.TextBottom; - text.AlignmentPoint = new Point3d(p3.X, p3.Y + 1.0, 0); + text.AlignmentPoint = new Point3d(p3.X, p3.Y + 1.0, 0); // 文字在横线上方 text.Position = text.AlignmentPoint; ctx.Btr.AppendEntity(text);