From bb4e338b4aeac037e1d92f3c7af2c866b67bbe63 Mon Sep 17 00:00:00 2001 From: sladro Date: Sun, 4 Jan 2026 10:35:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=BE=E5=BD=A2=E6=A0=87?= =?UTF-8?q?=E5=BF=97=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cad/FeatureDrivenDrawer.cs | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/Cad/FeatureDrivenDrawer.cs b/Cad/FeatureDrivenDrawer.cs index 4eae711..3898905 100644 --- a/Cad/FeatureDrivenDrawer.cs +++ b/Cad/FeatureDrivenDrawer.cs @@ -437,6 +437,14 @@ namespace CadParamPluging.Cad DrawPartContourHalf(ctx, ox, oy, H, outerDiaPrime.Value, innerDiaPrime, heightPrime.Value); } + // === 特征10: 轧制+车加工 特殊引线标注 (HB5936-13) === + // 需满足: 车加工 + 轧制(本方法即为轧制) + 有内孔 + if (ctx.IsMachined && innerDia.HasValue && innerDia.Value > 0) + { + // 指向锻件内孔右上角 + DrawSpecialInnerHoleLeader(ctx, ox, oy, H, innerDia.Value); + } + // === 特征9: 硬度符号 === TryDrawHardnessSymbol(ctx, ox + R, oy, H); } @@ -2238,5 +2246,57 @@ namespace CadParamPluging.Cad } #endregion + private static void DrawSpecialInnerHoleLeader(DrawingContext ctx, double ox, double oy, double height, double innerDia) + { + try + { + // 内孔右侧X坐标 (锻件) + double xInner = ox + innerDia / 2.0; + + // 目标Y坐标:锻件内孔右上角向下偏移一点 (引线不应直指角点,而是指在直线上) + double yTarget = oy + height - 5.0; + + // 箭头点 (指向内孔竖线) + var p1 = new Point3d(xInner, yTarget, 0); + // 转折点 (向左上) + var p2 = new Point3d(xInner - 12, yTarget + 12, 0); + // 终点 (水平向左, 长度约35适配文字宽度 "HB5936-13") + var p3 = new Point3d(p2.X - 35, p2.Y, 0); + + // 使用 Leader 实体绘制带箭头的引线 + var leader = new Leader(); + leader.SetDatabaseDefaults(); + leader.AppendVertex(p1); + leader.AppendVertex(p2); + leader.AppendVertex(p3); + leader.HasArrowHead = true; + leader.ColorIndex = 7; // 白色 + leader.Layer = "0"; + + ctx.Btr.AppendEntity(leader); + ctx.Tr.AddNewlyCreatedDBObject(leader, true); + + // 绘制文字 + var text = new DBText(); + text.TextString = "HB5936-13"; + text.Height = 3.5; + text.ColorIndex = 7; // 白色 + text.Layer = "0"; + + // 文字位置:左对齐,基点为 p3 (线段最左端) + // 位于线段上方 (VerticalMode = TextBottom) + text.HorizontalMode = TextHorizontalMode.TextLeft; + text.VerticalMode = TextVerticalMode.TextBottom; + text.AlignmentPoint = new Point3d(p3.X, p3.Y + 1.0, 0); + text.Position = text.AlignmentPoint; + + ctx.Btr.AppendEntity(text); + ctx.Tr.AddNewlyCreatedDBObject(text, true); + } + catch + { + // ignore + } + } } }