From 1ab7899cdf725d09aa811cbf14d51829d71c13a3 Mon Sep 17 00:00:00 2001 From: sladro Date: Wed, 28 Jan 2026 15:29:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=AF=9B=E6=96=99?= =?UTF-8?q?=E6=80=81=E3=80=81=E8=87=AA=E7=94=B1=E9=94=BB=E3=80=81=E7=8E=AF?= =?UTF-8?q?=E5=BD=A2=E3=80=81=E9=9D=9E=E4=B8=AD=E5=BF=83=E5=86=B2=E5=AD=94?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=EF=BC=8C=E8=BF=98=E6=B2=A1=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E7=94=9F=E6=88=90=EF=BC=8C=E7=94=9F=E6=88=90=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=98=AF=E7=8B=AC=E7=AB=8B=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RingRawFreeForgeNonCenterPunchDrawer.cs | 227 ++++++++++++++++++ ...RingRawFreeForgeNonCenterPunchGenerator.cs | 22 ++ Cad/Drawers/TemplateDrawingRegistry.cs | 1 + Cad/FeatureDrivenDrawer.cs | 118 +++++---- CadParamPluging.csproj | 2 + Common/DropdownOptions.cs | 8 +- Common/TemplateSchemaDefaults.cs | 35 +++ 7 files changed, 364 insertions(+), 49 deletions(-) create mode 100644 Cad/Drawers/RingRawFreeForgeNonCenterPunchDrawer.cs create mode 100644 Cad/Drawers/RingRawFreeForgeNonCenterPunchGenerator.cs diff --git a/Cad/Drawers/RingRawFreeForgeNonCenterPunchDrawer.cs b/Cad/Drawers/RingRawFreeForgeNonCenterPunchDrawer.cs new file mode 100644 index 0000000..231eceb --- /dev/null +++ b/Cad/Drawers/RingRawFreeForgeNonCenterPunchDrawer.cs @@ -0,0 +1,227 @@ +using System; +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.Geometry; +using CadParamPluging.Common; + +namespace CadParamPluging.Cad.Drawers +{ + public static class RingRawFreeForgeNonCenterPunchDrawer + { + public static void Draw(CadContext ctx, ParamBag bag, Point3d center, double scaleFactor = 1.0) + { + if (ctx == null) throw new ArgumentNullException(nameof(ctx)); + if (bag == null) throw new ArgumentNullException(nameof(bag)); + + // Apply scaling + var effectiveBag = scaleFactor < 1.0 ? ScaleParamBag(bag, scaleFactor) : bag; + + var db = ctx.Database; + var tr = ctx.Transaction; + + var prevDb = HostApplicationServices.WorkingDatabase; + HostApplicationServices.WorkingDatabase = db; + BlockTableRecord btr; + try + { + var bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); + btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); + } + finally + { + HostApplicationServices.WorkingDatabase = prevDb; + } + + // Construct DrawingContext + // Note: SpecialCondition needs to NOT contain "中心冲孔" + var context = new FeatureDrivenDrawer.DrawingContext + { + Ctx = ctx, + Bag = effectiveBag, + OriginalBag = bag, + Center = center, + DeliveryStatus = "毛料态", + StructuralFeature = "环形", + SpecialCondition = "非中心冲孔", + ProcessMethod = "自由锻", + Btr = btr, + // We need to instantiate DrawingStyleManager. Accessing internal constructor via reflection or if it's internal to assembly we are fine. + // Assuming same assembly. + Style = new DrawingStyleManager(db, tr) + }; + + DrawCore(context); + } + + private static ParamBag ScaleParamBag(ParamBag original, double scaleFactor) + { + if (original == null || scaleFactor <= 0 || (Math.Abs(scaleFactor - 1.0) < 1e-6)) + { + return original; + } + + var scaled = new ParamBag(); + + // 需要缩放的尺寸参数Key列表 + var sizeKeys = new System.Collections.Generic.HashSet(StringComparer.OrdinalIgnoreCase) + { + // 环形参数 + FeatureDrivenDrawer.KeyOuterDiameter1, FeatureDrivenDrawer.KeyInnerDiameter2, FeatureDrivenDrawer.KeyHeight1, + FeatureDrivenDrawer.KeyOuterDiameter1Prime, FeatureDrivenDrawer.KeyInnerDiameter2Prime, FeatureDrivenDrawer.KeyHeight1Prime, + FeatureDrivenDrawer.KeyMinWallThickness, + // 圆角参数 + FeatureDrivenDrawer.KeyUnspecifiedFilletRadiusMax, FeatureDrivenDrawer.KeyInnerRadiusMax, + + // 包含公差参数以保持一致性 + FeatureDrivenDrawer.KeyOuterDiameter1TolPlus, FeatureDrivenDrawer.KeyOuterDiameter1TolMinus, + FeatureDrivenDrawer.KeyInnerDiameter2TolPlus, FeatureDrivenDrawer.KeyInnerDiameter2TolMinus, + FeatureDrivenDrawer.KeyHeight1TolPlus, FeatureDrivenDrawer.KeyHeight1TolMinus + }; + + foreach (var key in original.GetKeys()) + { + var value = original.GetString(key); + + if (sizeKeys.Contains(key)) + { + // 尝试解析为数值并缩放 + if (double.TryParse(value, out var numValue)) + { + var scaledValue = numValue * scaleFactor; + // 保留适当的小数位数,避免精度问题 + scaled.Set(key, scaledValue.ToString("F4")); + } + else + { + scaled.Set(key, value); + } + } + else + { + // 非尺寸参数直接复制 + scaled.Set(key, value); + } + } + + return scaled; + } + + private static void DrawCore(FeatureDrivenDrawer.DrawingContext ctx) + { + // Logic copied from FeatureDrivenDrawer.DrawRingFeaturesFull but tailored for NonCenterPunch + var bag = ctx.Bag; + var outerDia = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyOuterDiameter1); + var height = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyHeight1); + + if (!outerDia.HasValue || !height.HasValue) return; + + double W = outerDia.Value; + double H = height.Value; + double ox = ctx.Center.X - W / 2.0; + double oy = ctx.Center.Y - H / 2.0; + + // 车加工态 parameters + double? outerDiaPrime = null; + double? innerDiaPrime = null; + double? heightPrime = null; + if (ctx.IsMachined) + { + outerDiaPrime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyOuterDiameter1Prime); + innerDiaPrime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyInnerDiameter2Prime); + heightPrime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyHeight1Prime); + } + + // 1. Forging Outer Contour + FeatureDrivenDrawer.DrawForgingOuterContour(ctx, ox, oy, W, H); + + // 1.1 Centerline + FeatureDrivenDrawer.DrawRingCenterline(ctx, ox, oy, W, H); + + // 2. Outer Diameter Dimension + var outerTolPlus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyOuterDiameter1TolPlus); + var outerTolMinus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyOuterDiameter1TolMinus); + FeatureDrivenDrawer.DrawOuterDiameterDimension(ctx, ox, oy, W, W, outerTolPlus, outerTolMinus, outerDiaPrime); + + // 3. Inner Hole + var innerDia = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyInnerDiameter2); + double? xInnerLeft = null; + double? xInnerRight = null; + if (innerDia.HasValue && innerDia.Value > 0 && innerDia.Value < W) + { + xInnerLeft = ctx.Center.X - innerDia.Value / 2.0; + xInnerRight = ctx.Center.X + innerDia.Value / 2.0; + + var innerTolPlus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyInnerDiameter2TolPlus); + var innerTolMinus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyInnerDiameter2TolMinus); + + FeatureDrivenDrawer.DrawInnerHole(ctx, xInnerLeft.Value, xInnerRight.Value, oy, H); + FeatureDrivenDrawer.DrawInnerDiameterDimension(ctx, xInnerLeft.Value, xInnerRight.Value, oy, innerDia.Value, innerTolPlus, innerTolMinus, innerDiaPrime); + + // 4. Inner Fillets - ONLY if CenterPunched (which is false here), so SKIP. + // But wait, the template is "NonCenterPunch", so we definitely SKIP DrawInnerFillets. + + // 4.1 Section Hatch + FeatureDrivenDrawer.DrawRingSectionHatch(ctx, xInnerRight.Value, ox + W, oy, H); + + // Section Boundary Bold + FeatureDrivenDrawer.DrawSectionInnerBoundaryBold(ctx, xInnerRight.Value, oy, H); + } + + // 5. Height Dimension + var heightTolPlus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyHeight1TolPlus); + var heightTolMinus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyHeight1TolMinus); + FeatureDrivenDrawer.DrawHeightDimension(ctx, ox, oy, W, H, heightTolPlus, heightTolMinus, heightPrime); + + // 6. Unspecified Fillet Note + var unspecifiedFillet = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyUnspecifiedFilletRadiusMax); + if (unspecifiedFillet.HasValue && unspecifiedFillet.Value > 0) + { + FeatureDrivenDrawer.DrawUnspecifiedFilletNote(ctx, ox, oy, H, W, unspecifiedFillet.Value); + } + + // 7. Min Wall Thickness + var minWallThickness = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyMinWallThickness); + if (minWallThickness.HasValue && minWallThickness.Value > 0 && xInnerRight.HasValue) + { + FeatureDrivenDrawer.DrawMinWallThicknessNote(ctx, xInnerRight.Value, ox + W, oy, minWallThickness.Value); + } + + // 8. Part Contour (Machined) + if (ctx.IsMachined && outerDiaPrime.HasValue && outerDiaPrime.Value > 0 && heightPrime.HasValue && heightPrime.Value > 0) + { + FeatureDrivenDrawer.DrawPartContour(ctx, ctx.Center, outerDiaPrime.Value, innerDiaPrime, heightPrime.Value); + } + + // 9. Hardness Symbol + var hardnessVal = bag.GetString(FeatureDrivenDrawer.KeyHardness); + if (!string.IsNullOrWhiteSpace(hardnessVal)) + { + if (xInnerRight.HasValue) + { + double xStart = (xInnerRight.Value + ox + W) / 2.0; + double yStart = oy; + FeatureDrivenDrawer.DrawHardnessSymbol(ctx, xStart, yStart); + } + else + { + FeatureDrivenDrawer.DrawHardnessSymbol(ctx, ox + W / 2.0, oy); + } + } + + // 10. Marking Content + var markingText = bag.GetString(FeatureDrivenDrawer.KeyMarkingContent); + if (!string.IsNullOrWhiteSpace(markingText)) + { + if (xInnerRight.HasValue) + { + double xTarget = (xInnerRight.Value + ox + W) / 2.0; + double yTarget = oy + H; + FeatureDrivenDrawer.DrawSpecialHBLeaderToTop(ctx, xTarget, yTarget, markingText); + } + else + { + FeatureDrivenDrawer.DrawSpecialHBLeaderToTop(ctx, ox + W / 2.0, oy + H, markingText); + } + } + } + } +} diff --git a/Cad/Drawers/RingRawFreeForgeNonCenterPunchGenerator.cs b/Cad/Drawers/RingRawFreeForgeNonCenterPunchGenerator.cs new file mode 100644 index 0000000..ab3ee73 --- /dev/null +++ b/Cad/Drawers/RingRawFreeForgeNonCenterPunchGenerator.cs @@ -0,0 +1,22 @@ +using Autodesk.AutoCAD.Geometry; +using CadParamPluging.Common; +using CadParamPluging.Domain.Models; +using CadParamPluging.Cad.Drawers; + +namespace CadParamPluging.Cad +{ + public class RingRawFreeForgeNonCenterPunchGenerator : ITemplateDrawingGenerator + { + public string TemplateKey => TemplateKeyBuilder.Build("毛料态", "自由锻", "环形", "非中心冲孔"); + + public FeatureDrivenDrawer.ExpectedDrawingSize CalculateExpectedSize(ParamBag bag, TemplateParams templateParams) + { + return FeatureDrivenDrawer.CalculateExpectedSize(bag, "环形"); + } + + public void Draw(CadContext ctx, ParamBag bag, TemplateParams templateParams, Point3d center, double scaleFactor) + { + RingRawFreeForgeNonCenterPunchDrawer.Draw(ctx, bag, center, scaleFactor); + } + } +} diff --git a/Cad/Drawers/TemplateDrawingRegistry.cs b/Cad/Drawers/TemplateDrawingRegistry.cs index da44b72..08e22ad 100644 --- a/Cad/Drawers/TemplateDrawingRegistry.cs +++ b/Cad/Drawers/TemplateDrawingRegistry.cs @@ -13,6 +13,7 @@ namespace CadParamPluging.Cad Register(new RingMachinedRollingGenerator()); Register(new RingRawRollingGenerator()); Register(new BlockRawFreeForgeRoundHeadGenerator()); + Register(new RingRawFreeForgeNonCenterPunchGenerator()); } public static bool TryResolve(string templateKey, out ITemplateDrawingGenerator generator) diff --git a/Cad/FeatureDrivenDrawer.cs b/Cad/FeatureDrivenDrawer.cs index 2741a27..8048f3b 100644 --- a/Cad/FeatureDrivenDrawer.cs +++ b/Cad/FeatureDrivenDrawer.cs @@ -99,7 +99,8 @@ namespace CadParamPluging.Cad && DeliveryStatus.IndexOf("车加工", StringComparison.OrdinalIgnoreCase) >= 0; public bool IsCenterPunched => !string.IsNullOrWhiteSpace(SpecialCondition) - && SpecialCondition.IndexOf("中心冲孔", StringComparison.OrdinalIgnoreCase) >= 0; + && SpecialCondition.IndexOf("中心冲孔", StringComparison.OrdinalIgnoreCase) >= 0 + && SpecialCondition.IndexOf("非中心冲孔", StringComparison.OrdinalIgnoreCase) < 0; public bool HasRoundHead => !string.IsNullOrWhiteSpace(SpecialCondition) && SpecialCondition.IndexOf("有圆头", StringComparison.OrdinalIgnoreCase) >= 0; @@ -699,9 +700,12 @@ namespace CadParamPluging.Cad // 需满足: 车加工 + 轧制(本方法即为轧制) + 有内孔 if (ctx.IsMachined && innerDia.HasValue && innerDia.Value > 0) { - if (applyUnspecifiedFillet) + // 获取标刻内容 + var markingText = bag.GetString(KeyMarkingContent); + // 只要有标刻内容,或者处于"毛料态-轧制-环形"模式,都画 + if (!string.IsNullOrWhiteSpace(markingText) || applyUnspecifiedFillet) { - // [修改] 针对“毛料态-轧制-环形”模板 + // [修改] // 指向锻件顶部白色边框的中间位置 // 顶部中间 X = (xInnerRight + xOuterRight) / 2 // Y = Top = oy + H @@ -710,10 +714,6 @@ namespace CadParamPluging.Cad var xTarget = (xLoopInner + xLoopOuter) / 2.0; var yTarget = oy + H; - - - // 获取标刻内容 - var markingText = bag.GetString(KeyMarkingContent); if (string.IsNullOrWhiteSpace(markingText)) { markingText = "HB5936-13"; // 默认值 @@ -729,26 +729,20 @@ namespace CadParamPluging.Cad } } - - // === 特征9: 硬度符号 === - // 仅在“毛料态-轧制-环形”模板(applyUnspecifiedFillet=true)中显示 - if (applyUnspecifiedFillet) + // 只要有硬度参数就画,不再局限于"毛料态-轧制-环形" + var hardnessVal = bag.GetString(KeyHardness); + if (!string.IsNullOrWhiteSpace(hardnessVal)) { - var hardnessVal = bag.GetString(KeyHardness); - if (!string.IsNullOrWhiteSpace(hardnessVal)) - { - // 指向锻件剖面图的底部边框的中间位置 - // 坐标: mid X, yBottom - double xLoopInner = ox + visualInnerR; - double xLoopOuter = ox + visualOuterR; - double xStart = (xLoopInner + xLoopOuter) / 2.0; - double yStart = oy; + // 指向锻件剖面图的底部边框的中间位置 + // 坐标: mid X, yBottom + double xLoopInner = ox + visualInnerR; + double xLoopOuter = ox + visualOuterR; + double xStart = (xLoopInner + xLoopOuter) / 2.0; + double yStart = oy; - DrawHardnessSymbol(ctx, xStart, yStart); - } + DrawHardnessSymbol(ctx, xStart, yStart); } - } @@ -756,7 +750,7 @@ namespace CadParamPluging.Cad /// 轧制:绘制带圆角的实体闭合轮廓(圆角多段线) /// 替代原来分散的外轮廓线和内孔边界线 /// - private static void DrawRingSectionContourWithFillet(DrawingContext ctx, double xLeft, double xRight, double yBottom, double height, double filletR) + public static void DrawRingSectionContourWithFillet(DrawingContext ctx, double xLeft, double xRight, double yBottom, double height, double filletR) { var yTop = yBottom + height; var width = xRight - xLeft; @@ -823,7 +817,7 @@ namespace CadParamPluging.Cad ctx.Tr.AddNewlyCreatedDBObject(polyFillet, true); } - private static void DrawHoleHorizontalLines(DrawingContext ctx, double xAxis, double xSectionLeft, double yBottom, double height, double filletR) + public static void DrawHoleHorizontalLines(DrawingContext ctx, double xAxis, double xSectionLeft, double yBottom, double height, double filletR) { var yTop = yBottom + height; @@ -860,7 +854,10 @@ namespace CadParamPluging.Cad /// /// 自由锻工艺 - 画全图 /// - private static void DrawRingFeaturesFull(DrawingContext ctx, double outerDia, double height) + /// + /// 自由锻工艺 - 画全图 + /// + public static void DrawRingFeaturesFull(DrawingContext ctx, double outerDia, double height) { var bag = ctx.Bag; double W = outerDia; @@ -945,11 +942,42 @@ namespace CadParamPluging.Cad DrawPartContour(ctx, ctx.Center, outerDiaPrime.Value, innerDiaPrime, heightPrime.Value); } - // === 特征9: 硬度符号(有要求才画) === - + // === 特征9: 硬度符号 === + var hardnessVal = bag.GetString(KeyHardness); + if (!string.IsNullOrWhiteSpace(hardnessVal)) + { + // 指向剖面图的底部边框的中间位置 + if (xInnerRight.HasValue) + { + double xStart = (xInnerRight.Value + ox + W) / 2.0; + double yStart = oy; + DrawHardnessSymbol(ctx, xStart, yStart); + } + else + { + // 若无内孔(理论上环形应有),可指向整体中间 + DrawHardnessSymbol(ctx, ox + W / 2.0, oy); + } + } + + // === 特征10: 标刻内容 === + var markingText = bag.GetString(KeyMarkingContent); + if (!string.IsNullOrWhiteSpace(markingText)) + { + if (xInnerRight.HasValue) + { + double xTarget = (xInnerRight.Value + ox + W) / 2.0; + double yTarget = oy + H; + DrawSpecialHBLeaderToTop(ctx, xTarget, yTarget, markingText); + } + else + { + DrawSpecialHBLeaderToTop(ctx, ox + W / 2.0, oy + H, markingText); + } + } } - private static void DrawSectionInnerBoundaryBold(DrawingContext ctx, double x, double yBottom, double height) + public static void DrawSectionInnerBoundaryBold(DrawingContext ctx, double x, double yBottom, double height) { try { @@ -964,7 +992,7 @@ namespace CadParamPluging.Cad } } - private static void DrawForgingOuterContour(DrawingContext ctx, double ox, double oy, double width, double height) + public static void DrawForgingOuterContour(DrawingContext ctx, double ox, double oy, double width, double height) { var poly = new Polyline(); poly.AddVertexAt(0, new Point2d(ox, oy), 0, 0, 0); @@ -979,7 +1007,7 @@ namespace CadParamPluging.Cad ctx.Tr.AddNewlyCreatedDBObject(poly, true); } - private static void DrawRingCenterline(DrawingContext ctx, double ox, double oy, double width, double height) + public static void DrawRingCenterline(DrawingContext ctx, double ox, double oy, double width, double height) { var cy = oy + height / 2.0; var line = new Line(new Point3d(ox - 10, cy, 0), new Point3d(ox + width + 10, cy, 0)); @@ -1275,7 +1303,7 @@ namespace CadParamPluging.Cad #endregion - private static void DrawInnerHole(DrawingContext ctx, double xInnerLeft, double xInnerRight, double yBottom, double height) + public static void DrawInnerHole(DrawingContext ctx, double xInnerLeft, double xInnerRight, double yBottom, double height) { var yTop = yBottom + height; @@ -1290,7 +1318,7 @@ namespace CadParamPluging.Cad ctx.Tr.AddNewlyCreatedDBObject(lineRight, true); } - private static void DrawInnerFillets(DrawingContext ctx, double xInnerLeft, double xInnerRight, double yBottom, double height, double filletR) + public static void DrawInnerFillets(DrawingContext ctx, double xInnerLeft, double xInnerRight, double yBottom, double height, double filletR) { // 在内径四角绘制圆角示意 var yTop = yBottom + height; @@ -1305,7 +1333,7 @@ namespace CadParamPluging.Cad DrawFilletArc(ctx, xInnerRight - filletR, yBottom + filletR, filletR, Math.PI * 1.5, Math.PI * 2); } - private static void DrawFilletArc(DrawingContext ctx, double cx, double cy, double r, double startAngle, double endAngle) + public static void DrawFilletArc(DrawingContext ctx, double cx, double cy, double r, double startAngle, double endAngle) { try { @@ -1320,7 +1348,7 @@ namespace CadParamPluging.Cad } } - private static void DrawOuterDiameterDimension(DrawingContext ctx, double ox, double oy, double width, + public static void DrawOuterDiameterDimension(DrawingContext ctx, double ox, double oy, double width, double diameter, double? tolPlus, double? tolMinus, double? diameterPrime) { // Use OriginalBag for text display to avoid scaled values @@ -1352,7 +1380,7 @@ namespace CadParamPluging.Cad dimText); } - private static void DrawInnerDiameterDimension(DrawingContext ctx, double xInnerLeft, double xInnerRight, double yBottom, + public static void DrawInnerDiameterDimension(DrawingContext ctx, double xInnerLeft, double xInnerRight, double yBottom, double diameter, double? tolPlus, double? tolMinus, double? diameterPrime) { // Use OriginalBag for text display @@ -1384,7 +1412,7 @@ namespace CadParamPluging.Cad dimText); } - private static void DrawHeightDimension(DrawingContext ctx, double ox, double oy, double width, + public static void DrawHeightDimension(DrawingContext ctx, double ox, double oy, double width, double height, double? tolPlus, double? tolMinus, double? heightPrime) { // Use OriginalBag for text display @@ -1416,7 +1444,7 @@ namespace CadParamPluging.Cad dimText); } - private static void DrawUnspecifiedFilletNote(DrawingContext ctx, double ox, double oy, double R, double height, double filletR) + public static void DrawUnspecifiedFilletNote(DrawingContext ctx, double ox, double oy, double R, double height, double filletR) { // 在图纸右上角添加文字说明 try @@ -1457,7 +1485,7 @@ namespace CadParamPluging.Cad } } - private static void DrawMinWallThicknessNote(DrawingContext ctx, double xInnerRight, double xOuterRight, double yBottom, double thickness, double offsetY = 0) + public static void DrawMinWallThicknessNote(DrawingContext ctx, double xInnerRight, double xOuterRight, double yBottom, double thickness, double offsetY = 0) { var val = ctx.OriginalBag?.GetDoubleOrNull(KeyMinWallThickness) ?? thickness; var dimText = $"{FormatDimNumber(val)}min"; @@ -1470,7 +1498,7 @@ namespace CadParamPluging.Cad dimText); } - private static void DrawPartContour(DrawingContext ctx, Point3d center, + public static void DrawPartContour(DrawingContext ctx, Point3d center, double outerDiaPrime, double? innerDiaPrime, double heightPrime) { var w = outerDiaPrime; @@ -1508,7 +1536,7 @@ namespace CadParamPluging.Cad } } - private static void DrawRingSectionHatch(DrawingContext ctx, double xInnerRight, double xOuterRight, double yBottom, double height) + public static void DrawRingSectionHatch(DrawingContext ctx, double xInnerRight, double xOuterRight, double yBottom, double height) { if (xOuterRight <= xInnerRight) { @@ -1561,7 +1589,7 @@ namespace CadParamPluging.Cad } } - private static void DrawRingSectionHatchWithFillet(DrawingContext ctx, double xInnerRight, double xOuterRight, double yBottom, double height, double filletR) + public static void DrawRingSectionHatchWithFillet(DrawingContext ctx, double xInnerRight, double xOuterRight, double yBottom, double height, double filletR) { if (xOuterRight <= xInnerRight) { @@ -2714,7 +2742,7 @@ namespace CadParamPluging.Cad } #endregion - private static void DrawSpecialInnerHoleLeader(DrawingContext ctx, double ox, double oy, double height, double innerDia) + public static void DrawSpecialInnerHoleLeader(DrawingContext ctx, double ox, double oy, double height, double innerDia) { try { @@ -2767,7 +2795,7 @@ namespace CadParamPluging.Cad } } - private static void DrawSpecialHBLeaderToTop(DrawingContext ctx, double xTarget, double yTarget, string textContent) + public static void DrawSpecialHBLeaderToTop(DrawingContext ctx, double xTarget, double yTarget, string textContent) { try { @@ -2819,7 +2847,7 @@ namespace CadParamPluging.Cad } - private static void DrawHardnessSymbol(DrawingContext ctx, double xStart, double yStart) + public static void DrawHardnessSymbol(DrawingContext ctx, double xStart, double yStart) { try { diff --git a/CadParamPluging.csproj b/CadParamPluging.csproj index 1414ef7..2cbede4 100644 --- a/CadParamPluging.csproj +++ b/CadParamPluging.csproj @@ -86,6 +86,8 @@ + + diff --git a/Common/DropdownOptions.cs b/Common/DropdownOptions.cs index bb8cb4d..71e7551 100644 --- a/Common/DropdownOptions.cs +++ b/Common/DropdownOptions.cs @@ -23,10 +23,10 @@ namespace CadParamPluging.Common { return new DropdownOptions { - DeliveryStatuses = new List { "结构", "示例" }, - ProcessMethods = new List { "基础平面", "示例图" }, - StructuralFeatures = new List { "A1", "A3" }, - SpecialConditions = new List { "无" } + DeliveryStatuses = new List { "毛料态", "车加工" }, + ProcessMethods = new List { "轧制", "自由锻" }, + StructuralFeatures = new List { "环形", "方体" }, + SpecialConditions = new List { "无", "中心冲孔", "非中心冲孔", "有圆头" } }; } diff --git a/Common/TemplateSchemaDefaults.cs b/Common/TemplateSchemaDefaults.cs index 9d6fc56..d178c0e 100644 --- a/Common/TemplateSchemaDefaults.cs +++ b/Common/TemplateSchemaDefaults.cs @@ -113,6 +113,41 @@ namespace CadParamPluging.Common PartOwnershipConfigured = true }); + // 模板七:交付状态=毛料态, 工艺方法=自由锻, 结构特征=环形, 特殊条件=非中心冲孔 + schemas.Items.Add(new TemplateSchemaDefinition + { + ProjectType = "毛料态", + DrawingType = "自由锻", + SheetSize = "环形", + Scale = "非中心冲孔", + DisplayName = "环形(毛料态/自由锻/非中心冲孔)", + SelectedParamKeys = new List + { + "OuterDiameter1", + "OuterDiameter1TolPlus", + "OuterDiameter1TolMinus", + "InnerDiameter2", + "InnerDiameter2TolPlus", + "InnerDiameter2TolMinus", + "Height1", + "Height1TolPlus", + "Height1TolMinus", + "MinWallThickness", + "UnspecifiedFilletRadiusMax", + // 可选:车加工态参数 + "OuterDiameter1Prime", + "InnerDiameter2Prime", + "Height1Prime" + }, + SelectedPartParamKeys = new List + { + "OuterDiameter1Prime", + "InnerDiameter2Prime", + "Height1Prime" + }, + PartOwnershipConfigured = true + }); + schemas.Normalize(); return schemas; }