From 9774d8a0b9c62e8b0a70f21b63e14e307b95650e Mon Sep 17 00:00:00 2001 From: sladro Date: Mon, 12 Jan 2026 17:32:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E7=94=BB=E7=BA=BF=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cad/DrawingStyleManager.cs | 5 ++++- Cad/FeatureDrivenDrawer.cs | 41 ++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Cad/DrawingStyleManager.cs b/Cad/DrawingStyleManager.cs index 28f3aa3..2cb271b 100644 --- a/Cad/DrawingStyleManager.cs +++ b/Cad/DrawingStyleManager.cs @@ -10,6 +10,7 @@ namespace CadParamPluging.Cad OutlineBold, OutlineThin, PartContour, + BreakLine, // 截断线(白色双点划线) Centerline, Hidden, Hatch, @@ -57,7 +58,9 @@ namespace CadParamPluging.Cad case Role.OutlineBold: return new LayerSpec { LayerName = "粗实线", DefaultLinetypeName = "Continuous", DefaultLineWeight = LineWeight.LineWeight050, DefaultColorIndex = 7 }; case Role.PartContour: - return new LayerSpec { LayerName = "双点划线", DefaultLinetypeName = "PHANTOM", DefaultLineWeight = LineWeight.LineWeight015, DefaultColorIndex = 7 }; + return new LayerSpec { LayerName = "双点划线", DefaultLinetypeName = "PHANTOM", DefaultLineWeight = LineWeight.LineWeight015, DefaultColorIndex = 2 }; + case Role.BreakLine: + return new LayerSpec { LayerName = "截断线", DefaultLinetypeName = "PHANTOM", DefaultLineWeight = LineWeight.LineWeight015, DefaultColorIndex = 7 }; case Role.Centerline: return new LayerSpec { LayerName = "中心线", DefaultLinetypeName = "CENTER", DefaultLineWeight = LineWeight.LineWeight015, DefaultColorIndex = 7 }; case Role.Hidden: diff --git a/Cad/FeatureDrivenDrawer.cs b/Cad/FeatureDrivenDrawer.cs index eaa3f3f..7df0b46 100644 --- a/Cad/FeatureDrivenDrawer.cs +++ b/Cad/FeatureDrivenDrawer.cs @@ -601,17 +601,18 @@ namespace CadParamPluging.Cad } /// - /// 轧制:绘制对称轴(垂直中心线) + /// 轧制:绘制截断线(两根双点划线,间距5mm) /// private static void DrawRingSymmetryAxis(DrawingContext ctx, double ox, double oy, double height) { - const double extend = 5.0; // 中心线在轮廓上下各延长一点(与其它中心线的延长量保持一致) + const double extend = 5.0; // 截断线在轮廓上下各延长一点 const double frameMargin = 5.0; // 避免越过图框边界 + const double lineSpacing = 5.0; // 两根截断线间距5mm var y0 = oy - extend; var y1 = oy + height + extend; - // 若能检测到白色外框,则把中心线端点夹在图框内(留出少量安全边距)。 + // 若能检测到白色外框,则把截断线端点夹在图框内(留出少量安全边距)。 try { var frameExtents = TemplateDrawingService.ComputeWhiteFrameExtents(ctx?.Ctx); @@ -634,10 +635,18 @@ namespace CadParamPluging.Cad y1 = oy + height; } - var line = new Line(new Point3d(ox, y0, 0), new Point3d(ox, y1, 0)); - ctx.Style?.Apply(line, DrawingStyleManager.Role.Centerline); - ctx.Btr.AppendEntity(line); - ctx.Tr.AddNewlyCreatedDBObject(line, true); + // 绘制两根双点划线,间距 lineSpacing + // 第一根在 ox 位置 + var line1 = new Line(new Point3d(ox, y0, 0), new Point3d(ox, y1, 0)); + ctx.Style?.Apply(line1, DrawingStyleManager.Role.BreakLine); // 使用截断线样式(白色双点划线) + ctx.Btr.AppendEntity(line1); + ctx.Tr.AddNewlyCreatedDBObject(line1, true); + + // 第二根在 ox - lineSpacing 位置 + var line2 = new Line(new Point3d(ox - lineSpacing, y0, 0), new Point3d(ox - lineSpacing, y1, 0)); + ctx.Style?.Apply(line2, DrawingStyleManager.Role.BreakLine); // 使用截断线样式(白色双点划线) + ctx.Btr.AppendEntity(line2); + ctx.Tr.AddNewlyCreatedDBObject(line2, true); } /// @@ -781,7 +790,7 @@ namespace CadParamPluging.Cad } /// - /// 轧制:零件轮廓(右半边) + /// 轧制:零件轮廓(闭合方框,双点划线黄色) /// private static void DrawPartContourHalf(DrawingContext ctx, double ox, double oy, double forgingHeight, double outerDiaPrime, double? innerDiaPrime, double heightPrime) @@ -793,28 +802,16 @@ namespace CadParamPluging.Cad var offsetY = (forgingHeight - h) / 2.0; var y0 = oy + offsetY; - // 右半边零件轮廓(开口) + // 绘制闭合方框(仅画外轮廓,不画内径线) var polyPart = new Polyline(); polyPart.AddVertexAt(0, new Point2d(ox, y0), 0, 0, 0); polyPart.AddVertexAt(1, new Point2d(ox + Rp, y0), 0, 0, 0); polyPart.AddVertexAt(2, new Point2d(ox + Rp, y0 + h), 0, 0, 0); polyPart.AddVertexAt(3, new Point2d(ox, y0 + h), 0, 0, 0); - polyPart.Closed = false; // 不闭合 + polyPart.Closed = true; // 闭合方框 ctx.Style?.Apply(polyPart, DrawingStyleManager.Role.PartContour); ctx.Btr.AppendEntity(polyPart); ctx.Tr.AddNewlyCreatedDBObject(polyPart, true); - - // 右侧内径轮廓 - if (innerDiaPrime.HasValue && innerDiaPrime.Value > 0 && innerDiaPrime.Value < outerDiaPrime) - { - var xiR = ox + innerDiaPrime.Value / 2.0; - var yTop = y0 + h; - - var lineInner = new Line(new Point3d(xiR, y0, 0), new Point3d(xiR, yTop, 0)); - ctx.Style?.Apply(lineInner, DrawingStyleManager.Role.PartContour); - ctx.Btr.AppendEntity(lineInner); - ctx.Tr.AddNewlyCreatedDBObject(lineInner, true); - } } #endregion