From 34d125f397a6cd50147dd03d44568dd4b1cbe0b3 Mon Sep 17 00:00:00 2001 From: sladro Date: Fri, 10 Apr 2026 10:39:06 +0800 Subject: [PATCH] feat: implement drawer classes for free-forged blocks with and without round heads --- Cad/BlockRawFreeForgeNoRoundHeadDrawer.cs | 38 +---------------------- Cad/BlockRawFreeForgeRoundHeadDrawer.cs | 38 +---------------------- package-lock.json | 6 ++++ 3 files changed, 8 insertions(+), 74 deletions(-) create mode 100644 package-lock.json diff --git a/Cad/BlockRawFreeForgeNoRoundHeadDrawer.cs b/Cad/BlockRawFreeForgeNoRoundHeadDrawer.cs index f8dbd87..f6555c4 100644 --- a/Cad/BlockRawFreeForgeNoRoundHeadDrawer.cs +++ b/Cad/BlockRawFreeForgeNoRoundHeadDrawer.cs @@ -294,7 +294,7 @@ namespace CadParamPluging.Cad { double xStart = xSectionRight; double yStart = oy + H * 0.25; - DrawHardnessSymbol(ctx, xStart, yStart, hardnessVal); + FeatureDrivenDrawer.DrawHardnessSymbol(ctx, xStart, yStart, hardnessVal); } // 10. 标刻内容引线 - 从剖面左侧引出 @@ -823,42 +823,6 @@ namespace CadParamPluging.Cad return $"{baseText} {{\\H{tolScale}x;{single}}}"; } - private static void DrawHardnessSymbol(FeatureDrivenDrawer.DrawingContext ctx, double xStart, double yStart, string hardnessVal = null) - { - try - { - var p1 = new Point3d(xStart, yStart, 0); - var p2 = new Point3d(xStart + 15, yStart - 15, 0); - var p3 = new Point3d(p2.X + 10, p2.Y, 0); - - var poly = new Polyline(); - poly.AddVertexAt(0, new Point2d(p1.X, p1.Y), 0, 0, 0); - poly.AddVertexAt(1, new Point2d(p2.X, p2.Y), 0, 0, 0); - poly.AddVertexAt(2, new Point2d(p3.X, p3.Y), 0, 0, 0); - - ctx.Style?.Apply(poly, DrawingStyleManager.Role.Dimension); - poly.ColorIndex = 3; - - ctx.Btr.AppendEntity(poly); - ctx.Tr.AddNewlyCreatedDBObject(poly, true); - - string displayTxt = string.IsNullOrWhiteSpace(hardnessVal) ? "HB" : hardnessVal; - var text = new DBText(); - text.TextString = displayTxt; - text.Height = 3.5; - text.ColorIndex = 3; - text.HorizontalMode = TextHorizontalMode.TextLeft; - text.VerticalMode = TextVerticalMode.TextVerticalMid; - var tp = new Point3d(p3.X + 2.0, p3.Y, 0); - text.AlignmentPoint = tp; - text.Position = tp; - - ctx.Btr.AppendEntity(text); - ctx.Tr.AddNewlyCreatedDBObject(text, true); - } - catch {} - } - private static void DrawSpecialHBLeaderToTop(FeatureDrivenDrawer.DrawingContext ctx, double xTarget, double yTarget, string textContent) { try diff --git a/Cad/BlockRawFreeForgeRoundHeadDrawer.cs b/Cad/BlockRawFreeForgeRoundHeadDrawer.cs index c60a458..9d51426 100644 --- a/Cad/BlockRawFreeForgeRoundHeadDrawer.cs +++ b/Cad/BlockRawFreeForgeRoundHeadDrawer.cs @@ -319,7 +319,7 @@ namespace CadParamPluging.Cad { double xStart = xSectionRight; double yStart = oy + H * 0.25; - DrawHardnessSymbol(ctx, xStart, yStart, hardnessVal); + FeatureDrivenDrawer.DrawHardnessSymbol(ctx, xStart, yStart, hardnessVal); } // 10. 标刻内容引线 - 从剖面左侧引出 @@ -669,42 +669,6 @@ namespace CadParamPluging.Cad catch { } } - private static void DrawHardnessSymbol(FeatureDrivenDrawer.DrawingContext ctx, double xStart, double yStart, string hardnessVal = null) - { - try - { - var p1 = new Point3d(xStart, yStart, 0); - var p2 = new Point3d(xStart + 15, yStart - 15, 0); - var p3 = new Point3d(p2.X + 10, p2.Y, 0); - - var poly = new Polyline(); - poly.AddVertexAt(0, new Point2d(p1.X, p1.Y), 0, 0, 0); - poly.AddVertexAt(1, new Point2d(p2.X, p2.Y), 0, 0, 0); - poly.AddVertexAt(2, new Point2d(p3.X, p3.Y), 0, 0, 0); - - ctx.Style?.Apply(poly, DrawingStyleManager.Role.Dimension); - poly.ColorIndex = 3; - - ctx.Btr.AppendEntity(poly); - ctx.Tr.AddNewlyCreatedDBObject(poly, true); - - string displayTxt = string.IsNullOrWhiteSpace(hardnessVal) ? "HB" : hardnessVal; - var text = new DBText(); - text.TextString = displayTxt; - text.Height = 3.5; - text.ColorIndex = 3; - text.HorizontalMode = TextHorizontalMode.TextLeft; - text.VerticalMode = TextVerticalMode.TextVerticalMid; - var tp = new Point3d(p3.X + 2.0, p3.Y, 0); - text.AlignmentPoint = tp; - text.Position = tp; - - ctx.Btr.AppendEntity(text); - ctx.Tr.AddNewlyCreatedDBObject(text, true); - } - catch { } - } - private static void DrawHeadFilletRadiusLeader(FeatureDrivenDrawer.DrawingContext ctx, double cx, double cy, double r, bool isLeftSection) { try diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..595f8e4 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "CadParamPluging", + "lockfileVersion": 3, + "requires": true, + "packages": {} +}