From 01b8f1930b9801096d8c9c39a5bf45bec4997cb8 Mon Sep 17 00:00:00 2001 From: sladro Date: Tue, 3 Feb 2026 18:58:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B9=E8=BD=B4=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ShaftRawFreeForgeRoundShaftGenerator.cs | 33 ++ .../ShaftRawFreeForgeSquareShaftGenerator.cs | 44 +++ Cad/Drawers/TemplateDrawingRegistry.cs | 2 + Cad/FeatureDrivenDrawer.cs | 40 +- Cad/ShaftRawFreeForgeRoundShaftDrawer.cs | 369 ++++++++++++++++++ Cad/ShaftRawFreeForgeSquareShaftDrawer.cs | Bin 0 -> 32398 bytes CadParamPluging.csproj | 4 + Common/ParamCatalog.cs | 146 +++++++ Common/TemplateSchemaDefaults.cs | 61 +++ 9 files changed, 698 insertions(+), 1 deletion(-) create mode 100644 Cad/Drawers/ShaftRawFreeForgeRoundShaftGenerator.cs create mode 100644 Cad/Drawers/ShaftRawFreeForgeSquareShaftGenerator.cs create mode 100644 Cad/ShaftRawFreeForgeRoundShaftDrawer.cs create mode 100644 Cad/ShaftRawFreeForgeSquareShaftDrawer.cs diff --git a/Cad/Drawers/ShaftRawFreeForgeRoundShaftGenerator.cs b/Cad/Drawers/ShaftRawFreeForgeRoundShaftGenerator.cs new file mode 100644 index 0000000..efce132 --- /dev/null +++ b/Cad/Drawers/ShaftRawFreeForgeRoundShaftGenerator.cs @@ -0,0 +1,33 @@ +using CadParamPluging.Common; +using CadParamPluging.Domain.Models; +using Autodesk.AutoCAD.Geometry; + +namespace CadParamPluging.Cad +{ + public sealed class ShaftRawFreeForgeRoundShaftGenerator : ITemplateDrawingGenerator + { + // 对应 TemplateSchemaDefaults.cs 中的定义 + // ProjectType = "毛料态", DrawingType = "自由锻", SheetSize = "轴杆", Scale = "圆轴" + public static readonly string Key = TemplateKeyBuilder.Build("毛料态", "自由锻", "轴杆", "圆轴"); + + public string TemplateKey => Key; + + public FeatureDrivenDrawer.ExpectedDrawingSize CalculateExpectedSize(ParamBag bag, TemplateParams templateParams) + { + var diameter = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyDiameter) ?? 0; + var length = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyLength) ?? 0; + + var extraMargin = 40; + return new FeatureDrivenDrawer.ExpectedDrawingSize + { + Width = length + extraMargin * 2, + Height = diameter + extraMargin * 2 + }; + } + + public void Draw(CadContext ctx, ParamBag bag, TemplateParams templateParams, Point3d center, double scaleFactor) + { + ShaftRawFreeForgeRoundShaftDrawer.Draw(ctx, bag, center, scaleFactor); + } + } +} diff --git a/Cad/Drawers/ShaftRawFreeForgeSquareShaftGenerator.cs b/Cad/Drawers/ShaftRawFreeForgeSquareShaftGenerator.cs new file mode 100644 index 0000000..165fade --- /dev/null +++ b/Cad/Drawers/ShaftRawFreeForgeSquareShaftGenerator.cs @@ -0,0 +1,44 @@ +using CadParamPluging.Common; +using CadParamPluging.Domain.Models; +using Autodesk.AutoCAD.Geometry; + +namespace CadParamPluging.Cad +{ + public sealed class ShaftRawFreeForgeSquareShaftGenerator : ITemplateDrawingGenerator + { + // 对应 TemplateSchemaDefaults.cs 中的定义 + // ProjectType = "毛料态", DrawingType = "自由锻", SheetSize = "轴杆", Scale = "方轴" + public static readonly string Key = TemplateKeyBuilder.Build("毛料态", "自由锻", "轴杆", "方轴"); + + public string TemplateKey => Key; + + public FeatureDrivenDrawer.ExpectedDrawingSize CalculateExpectedSize(ParamBag bag, TemplateParams templateParams) + { + var l = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize1) ?? 0; + var w = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize2) ?? 0; + var t = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize3) ?? 0; // if side view exists + + var extraMargin = 40; + double totalWidth = l + extraMargin * 2; + + if (t > 0) + { + double gap = 50.0; + totalWidth = (l + gap + t) + extraMargin * 2; + } + + double activeHeight = w; + + return new FeatureDrivenDrawer.ExpectedDrawingSize + { + Width = totalWidth, + Height = activeHeight + extraMargin * 2 + }; + } + + public void Draw(CadContext ctx, ParamBag bag, TemplateParams templateParams, Point3d center, double scaleFactor) + { + ShaftRawFreeForgeSquareShaftDrawer.Draw(ctx, bag, center, scaleFactor); + } + } +} diff --git a/Cad/Drawers/TemplateDrawingRegistry.cs b/Cad/Drawers/TemplateDrawingRegistry.cs index b2f379b..bf2b078 100644 --- a/Cad/Drawers/TemplateDrawingRegistry.cs +++ b/Cad/Drawers/TemplateDrawingRegistry.cs @@ -18,6 +18,8 @@ namespace CadParamPluging.Cad Register(new RingRawFreeForgeNonCenterPunchGenerator()); Register(new BlockRawFreeForgeNoRoundHeadGenerator()); Register(new RingRawFreeForgeCenterPunchGenerator()); + Register(new ShaftRawFreeForgeRoundShaftGenerator()); + Register(new ShaftRawFreeForgeSquareShaftGenerator()); } public static bool TryResolve(string templateKey, out ITemplateDrawingGenerator generator) diff --git a/Cad/FeatureDrivenDrawer.cs b/Cad/FeatureDrivenDrawer.cs index 291186e..6d045d4 100644 --- a/Cad/FeatureDrivenDrawer.cs +++ b/Cad/FeatureDrivenDrawer.cs @@ -55,6 +55,21 @@ namespace CadParamPluging.Cad public const string KeyDiameterPrime = "DiameterPrime"; // 轴杆零件直径 public const string KeyLengthPrime = "LengthPrime"; // 轴杆零件长度 + // 轴杆参数(方轴) + public const string KeySquareShaftSize1 = "SquareShaftSize1"; + public const string KeySquareShaftSize1TolPlus = "SquareShaftSize1TolPlus"; + public const string KeySquareShaftSize1TolMinus = "SquareShaftSize1TolMinus"; + public const string KeySquareShaftSize2 = "SquareShaftSize2"; + public const string KeySquareShaftSize2TolPlus = "SquareShaftSize2TolPlus"; + public const string KeySquareShaftSize2TolMinus = "SquareShaftSize2TolMinus"; + public const string KeySquareShaftSize3 = "SquareShaftSize3"; + public const string KeySquareShaftSize3TolPlus = "SquareShaftSize3TolPlus"; + public const string KeySquareShaftSize3TolMinus = "SquareShaftSize3TolMinus"; + public const string KeySquareShaftFilletRadiusMax = "SquareShaftFilletRadiusMax"; // 未注圆角半径R≤ + public const string KeySquareShaftSize1Prime = "SquareShaftSize1Prime"; + public const string KeySquareShaftSize2Prime = "SquareShaftSize2Prime"; + public const string KeySquareShaftSize3Prime = "SquareShaftSize3Prime"; + // 方体参数 public const string KeyBoxSize1 = "BoxSize1"; public const string KeyBoxSize1TolPlus = "BoxSize1TolPlus"; @@ -218,6 +233,18 @@ namespace CadParamPluging.Cad private static ExpectedDrawingSize CalculateShaftSize(ParamBag bag) { + var l = bag.GetDoubleOrNull(KeySquareShaftSize1); + if (l.HasValue) + { + var w = bag.GetDoubleOrNull(KeySquareShaftSize2) ?? 0; + var extraMarginSq = 40; + return new ExpectedDrawingSize + { + Width = l.Value + extraMarginSq * 2, + Height = w + extraMarginSq * 2 + }; + } + var diameter = bag.GetDoubleOrNull(KeyDiameter) ?? 0; var length = bag.GetDoubleOrNull(KeyLength) ?? 0; @@ -308,7 +335,18 @@ namespace CadParamPluging.Cad } else if (IsShaft(structuralFeature)) { - DrawShaftFeatures(context); + if (deliveryStatus == "毛料态" && processMethod == "自由锻" && specialCondition == "圆轴") + { + ShaftRawFreeForgeRoundShaftDrawer.Draw(context.Ctx, context.OriginalBag ?? context.Bag, context.Center, scaleFactor); + } + else if (deliveryStatus == "毛料态" && processMethod == "自由锻" && specialCondition == "方轴") + { + ShaftRawFreeForgeSquareShaftDrawer.Draw(context.Ctx, context.OriginalBag ?? context.Bag, context.Center, scaleFactor); + } + else + { + DrawShaftFeatures(context); + } } else if (IsBlock(structuralFeature)) { diff --git a/Cad/ShaftRawFreeForgeRoundShaftDrawer.cs b/Cad/ShaftRawFreeForgeRoundShaftDrawer.cs new file mode 100644 index 0000000..a0c52a7 --- /dev/null +++ b/Cad/ShaftRawFreeForgeRoundShaftDrawer.cs @@ -0,0 +1,369 @@ +using System; +using System.Collections.Generic; +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.Geometry; +using CadParamPluging.Common; + +namespace CadParamPluging.Cad +{ + public static class ShaftRawFreeForgeRoundShaftDrawer + { + 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)); + + 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; + } + + var context = new FeatureDrivenDrawer.DrawingContext + { + Ctx = ctx, + Bag = effectiveBag, + OriginalBag = bag, + Center = center, + DeliveryStatus = "毛料态", + StructuralFeature = "轴杆", + SpecialCondition = "圆轴", + ProcessMethod = "自由锻", + Btr = btr, + Style = new DrawingStyleManager(db, tr) // Reusing existing StyleManager + }; + + DrawCore(context); + } + + private static void DrawCore(FeatureDrivenDrawer.DrawingContext ctx) + { + var bag = ctx.Bag; + + // Parameters + var diameter = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyDiameter); + var length = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyLength); + + if (!diameter.HasValue || diameter.Value <= 0 || !length.HasValue || length.Value <= 0) + { + return; + } + + double D = diameter.Value; + double L = length.Value; + + // Visual Size Calculation + // Keep aspect ratio but maybe limit if too extreme? + // For now, draw 1:1 visually unless scaled by scaleFactor (which is handled in bag). + + // Calculate coordinates (Center is geometric center) + double ox = ctx.Center.X - L / 2.0; + double oy = ctx.Center.Y - D / 2.0; + + // 1. Draw Shaft Outline (Rectangle with optional fillets) + var filletRParam = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyShaftFilletRadiusMax); + double filletR = filletRParam.HasValue && filletRParam.Value > 0 ? filletRParam.Value : 0; + + // Limit fillet radius + double maxR = Math.Min(D / 2.0, L / 2.0); + if (filletR > maxR) filletR = maxR; + + DrawShaftOutline(ctx, ox, oy, L, D, filletR); + + // 2. Draw Symmetry Axis + DrawSymmetryAxis(ctx, ox, oy, L, D); + + // 3. Draw Part Contour (Yellow dashed) + var diameterPrime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyDiameterPrime); + var lengthPrime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyLengthPrime); + + if (diameterPrime.HasValue && diameterPrime.Value > 0 && lengthPrime.HasValue && lengthPrime.Value > 0) + { + double partD = diameterPrime.Value; + double partL = lengthPrime.Value; + + // Center part contour + double partOx = ctx.Center.X - partL / 2.0; + double partOy = ctx.Center.Y - partD / 2.0; + + DrawPartContour(ctx, partOx, partOy, partL, partD); + } + + // 4. Dimensions + + // Length Dimension (Bottom) + { + var val = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeyLength) ?? L; + var str = ctx.OriginalBag?.GetString(FeatureDrivenDrawer.KeyLength); + var tolPlus = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeyLengthTolPlus); + var tolMinus = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeyLengthTolMinus); + + var dimText = BuildDimensionText(FormatDimNumber(val, str), tolPlus, tolMinus); + + // Add Part Length (Prime) below + var valPrime = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeyLengthPrime); + if (valPrime.HasValue && valPrime.Value > 0) + { + dimText += $"\\X({FormatDimNumber(valPrime.Value)})"; + } + + // Place below + double dimY = oy - 20; // Offset downwards? Usually dependent on margin + // Let's use a standard offset. If D is small, 20 is fine. + + AddLinearDim( + ctx, + new Point3d(ox, oy, 0), + new Point3d(ox + L, oy, 0), + new Point3d(ctx.Center.X, dimY, 0), + 0, + dimText); + } + + // Diameter Dimension (Right side usually for shafts, or put on side) + // Vertical dimension for Diameter + { + var val = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeyDiameter) ?? D; + var str = ctx.OriginalBag?.GetString(FeatureDrivenDrawer.KeyDiameter); + var tolPlus = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeyDiameterTolPlus); + var tolMinus = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeyDiameterTolMinus); + + // Prefix with %%c for diameter + var dimText = BuildDimensionText("%%c" + FormatDimNumber(val, str), tolPlus, tolMinus); + + // Add Part Diameter (Prime) below + var valPrime = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeyDiameterPrime); + if (valPrime.HasValue && valPrime.Value > 0) + { + dimText += $"\\X(%%c{FormatDimNumber(valPrime.Value)})"; + } + + double dimX = ox + L + 20; + + AddLinearDim( + ctx, + new Point3d(ox + L, oy, 0), + new Point3d(ox + L, oy + D, 0), + new Point3d(dimX, ctx.Center.Y, 0), + 90, + dimText); + } + + // Unspecified Fillet Note + if (filletR > 0) + { + // Usually text near the drawing or a general note. + // Ring template puts it at bottom left/right. + // Let's place it at top left. + // "未注圆角 R<=..." + + // Construct text + string note = $"未注圆角 R≤{FormatDimNumber(filletR)}"; + + // Position: Top Left, slightly above + DrawSimpleText(ctx, new Point3d(ox, oy + D + 10, 0), note, 3.5); + } + } + + private static void DrawShaftOutline(FeatureDrivenDrawer.DrawingContext ctx, double x, double y, double w, double h, double r) + { + var poly = new Polyline(); + + if (r < 0.01) + { + poly.AddVertexAt(0, new Point2d(x, y), 0, 0, 0); + poly.AddVertexAt(1, new Point2d(x + w, y), 0, 0, 0); + poly.AddVertexAt(2, new Point2d(x + w, y + h), 0, 0, 0); + poly.AddVertexAt(3, new Point2d(x, y + h), 0, 0, 0); + } + else + { + var bulge = Math.Tan(Math.PI / 8.0); + + // Bottom-Left corner + poly.AddVertexAt(0, new Point2d(x + r, y), 0, 0, 0); // Start of bottom line + + // Bottom-Right corner + poly.AddVertexAt(1, new Point2d(x + w - r, y), bulge, 0, 0); // Arc start + poly.AddVertexAt(2, new Point2d(x + w, y + r), 0, 0, 0); // Right line start + + // Top-Right corner + poly.AddVertexAt(3, new Point2d(x + w, y + h - r), bulge, 0, 0); + poly.AddVertexAt(4, new Point2d(x + w - r, y + h), 0, 0, 0); + + // Top-Left corner + poly.AddVertexAt(5, new Point2d(x + r, y + h), bulge, 0, 0); + poly.AddVertexAt(6, new Point2d(x, y + h - r), 0, 0, 0); + + // Back to bottom-left arc + poly.AddVertexAt(7, new Point2d(x, y + r), bulge, 0, 0); + } + + poly.Closed = true; + ctx.Style?.Apply(poly, DrawingStyleManager.Role.OutlineBold); + ctx.Btr.AppendEntity(poly); + ctx.Tr.AddNewlyCreatedDBObject(poly, true); + + // Hatching? Shafts are usually not hatched unless sectioned. + // "Raw State Free Forging" might be just the outline. + // Ring templates hatch because they are sections. Shaft is usually full view. + // But if user wants a "template", maybe it mimics others? + // Ring Free Forge has hatching. Block has hatching in section. + // If this is a SECTION of a shaft (which is just a circle?), no. + // Should be side view. No hatching typically. + } + + private static void DrawSymmetryAxis(FeatureDrivenDrawer.DrawingContext ctx, double x, double y, double w, double h) + { + // Horizontal axis? Shafts are usually horizontal. + // Center Y = y + h/2 + double midY = y + h / 2.0; + double extend = w * 0.1; + if (extend > 15) extend = 15; + + var line = new Line(new Point3d(x - extend, midY, 0), new Point3d(x + w + extend, midY, 0)); + ctx.Style?.Apply(line, DrawingStyleManager.Role.Centerline); + ctx.Btr.AppendEntity(line); + ctx.Tr.AddNewlyCreatedDBObject(line, true); + } + + private static void DrawPartContour(FeatureDrivenDrawer.DrawingContext ctx, double x, double y, double w, double h) + { + var poly = new Polyline(); + poly.AddVertexAt(0, new Point2d(x, y), 0, 0, 0); + poly.AddVertexAt(1, new Point2d(x + w, y), 0, 0, 0); + poly.AddVertexAt(2, new Point2d(x + w, y + h), 0, 0, 0); + poly.AddVertexAt(3, new Point2d(x, y + h), 0, 0, 0); + poly.Closed = true; + + ctx.Style?.Apply(poly, DrawingStyleManager.Role.PartContour); // Yellow Dashed + ctx.Btr.AppendEntity(poly); + ctx.Tr.AddNewlyCreatedDBObject(poly, true); + } + + // --- Helpers copied/adapted to ensure isolation --- + + private static ParamBag ScaleParamBag(ParamBag original, double scaleFactor) + { + if (original == null) return null; + if (Math.Abs(scaleFactor - 1.0) < 0.000001) return original; + // Simplified copy for specific keys + var newBag = new ParamBag(); + foreach(var k in original.GetKeys()) + { + var v = original.GetString(k); + if (IsScaleableKey(k) && double.TryParse(v, out var d)) + { + newBag.Set(k, (d * scaleFactor).ToString("0.###")); + } + else + { + newBag.Set(k, v); + } + } + return newBag; + } + + private static bool IsScaleableKey(string key) + { + // List relevant keys for this template + return key.StartsWith("Diameter") || key.StartsWith("Length") || key.EndsWith("Prime") || key.Contains("Radius"); + } + + private static void AddLinearDim(FeatureDrivenDrawer.DrawingContext ctx, Point3d p1, Point3d p2, Point3d ptDim, double rot, string text) + { + try + { + var dim = new RotatedDimension(); + dim.SetDatabaseDefaults(); + dim.XLine1Point = p1; + dim.XLine2Point = p2; + dim.DimLinePoint = ptDim; + dim.Rotation = rot * Math.PI / 180.0; + dim.DimensionStyle = ctx.Db.Dimstyle; + dim.DimensionText = text; + + // Force Green + dim.ColorIndex = 3; + + // Basic overrides if possible + // Using reflection setup similar to other files + SetDimColor(dim, "Dimclrd", 3); + SetDimColor(dim, "Dimclre", 3); + SetDimColor(dim, "Dimclrt", 3); + SetDimBool(dim, "Dimtofl", true); + + ctx.Style?.Apply(dim, DrawingStyleManager.Role.Dimension); + dim.ColorIndex = 3; + + ctx.Btr.AppendEntity(dim); + ctx.Tr.AddNewlyCreatedDBObject(dim, true); + } + catch {} + } + + private static void DrawSimpleText(FeatureDrivenDrawer.DrawingContext ctx, Point3d pos, string text, double height) + { + try + { + var mtxt = new MText(); + mtxt.SetDatabaseDefaults(); + mtxt.Location = pos; + mtxt.Contents = text; + mtxt.TextHeight = height; + mtxt.Attachment = AttachmentPoint.BottomLeft; + + ctx.Style?.Apply(mtxt, DrawingStyleManager.Role.Text); + ctx.Btr.AppendEntity(mtxt); + ctx.Tr.AddNewlyCreatedDBObject(mtxt, true); + } + catch {} + } + + private static string FormatDimNumber(double value, string rawInput = null) + { + // Simplified formatter + return value.ToString("0.###"); + } + + private static string BuildDimensionText(string baseText, double? tolPlus, double? tolMinus) + { + if (!tolPlus.HasValue && !tolMinus.HasValue) return baseText; + + if (tolPlus.HasValue && tolMinus.HasValue && Math.Abs(Math.Abs(tolPlus.Value) - Math.Abs(tolMinus.Value)) < 0.00001) + { + return $"{baseText}%%p{Math.Abs(tolPlus.Value):0.###}"; + } + + string p = tolPlus.HasValue ? (tolPlus.Value >= 0 ? "+" : "") + tolPlus.Value.ToString("0.###") : "0"; + string m = tolMinus.HasValue ? tolMinus.Value.ToString("0.###") : "0"; + + return $"{baseText}\\S{p}^{m};"; + } + + // Reflection helpers + private static void SetDimColor(Dimension dim, string prop, int colorIndex) + { + try { + var p = dim.GetType().GetProperty(prop); + if (p != null) p.SetValue(dim, Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci, (short)colorIndex)); + } catch {} + } + private static void SetDimBool(Dimension dim, string prop, bool val) + { + try { dim.GetType().GetProperty(prop)?.SetValue(dim, val); } catch {} + } + } +} diff --git a/Cad/ShaftRawFreeForgeSquareShaftDrawer.cs b/Cad/ShaftRawFreeForgeSquareShaftDrawer.cs new file mode 100644 index 0000000000000000000000000000000000000000..f67a5f891e22a44669f3579ee8c11a10355194ff GIT binary patch literal 32398 zcmeI5%W@q_TE~kG3nF-j(*g#0E^1qv<}y9d;merrz-~J%hr1`Z1hyrsg)Lb~8o7<} zf+ee2vEWg74Ys@h!9xK5Uw!&3E9+EcIH`~o#^J(+j&2KehSJ#@`&Fkisezu$EdSX}q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Yhlb4yehfW^VSdNorYyRZRF)tI^}gj z)|3-jFmr3Rg{Zzfr}bF97`{)B?wZdrF9Y_m19GeYjx)8njD0R+el#~bdZ3Yl%Sr3H zU4ZFt$WGNU-{PJAPuVXD+A8UK(UENOomt{5knP?`ra89<2Hb=I~94PvHKHa2)Q_?Fe Qf%$p*ddu-Uyi5H3A02TnG5`Po literal 0 HcmV?d00001 diff --git a/CadParamPluging.csproj b/CadParamPluging.csproj index 62f66f3..184e196 100644 --- a/CadParamPluging.csproj +++ b/CadParamPluging.csproj @@ -91,7 +91,11 @@ + + + + diff --git a/Common/ParamCatalog.cs b/Common/ParamCatalog.cs index 14e38c2..387b1dc 100644 --- a/Common/ParamCatalog.cs +++ b/Common/ParamCatalog.cs @@ -796,6 +796,152 @@ namespace CadParamPluging.Common Order = 930, Group = "尺寸-饼盘" }, + + // --- Dimensions: square shaft (方轴) --- + new ParamDefinition + { + Key = "SquareShaftSize1", + Label = "尺寸1", + Type = ParamValueType.Double, + Required = false, + DefaultValue = "", + Hint = "手动编辑(长度)", + Order = 781, + Group = "尺寸-轴杆(方轴)" + }, + new ParamDefinition + { + Key = "SquareShaftSize1TolPlus", + Label = "尺寸1上差a1", + Type = ParamValueType.Double, + Required = false, + DefaultValue = "", + Hint = "下拉列表(+2~+7),可手动编辑", + Order = 782, + Group = "尺寸-轴杆(方轴)" + }, + new ParamDefinition + { + Key = "SquareShaftSize1TolMinus", + Label = "尺寸1下差b1", + Type = ParamValueType.Double, + Required = false, + DefaultValue = "", + Hint = "下拉列表(-2~-7),可手动编辑", + Order = 783, + Group = "尺寸-轴杆(方轴)" + }, + new ParamDefinition + { + Key = "SquareShaftSize2", + Label = "尺寸2", + Type = ParamValueType.Double, + Required = false, + DefaultValue = "", + Hint = "手动编辑", + Order = 784, + Group = "尺寸-轴杆(方轴)" + }, + new ParamDefinition + { + Key = "SquareShaftSize2TolPlus", + Label = "尺寸2上差a2", + Type = ParamValueType.Double, + Required = false, + DefaultValue = "", + Hint = "下拉列表(+2~+7),可手动编辑", + Order = 785, + Group = "尺寸-轴杆(方轴)" + }, + new ParamDefinition + { + Key = "SquareShaftSize2TolMinus", + Label = "尺寸2下差b2", + Type = ParamValueType.Double, + Required = false, + DefaultValue = "", + Hint = "下拉列表(-2~-7),可手动编辑", + Order = 786, + Group = "尺寸-轴杆(方轴)" + }, + new ParamDefinition + { + Key = "SquareShaftSize3", + Label = "尺寸3", + Type = ParamValueType.Double, + Required = false, + DefaultValue = "", + Hint = "手动编辑", + Order = 787, + Group = "尺寸-轴杆(方轴)" + }, + new ParamDefinition + { + Key = "SquareShaftSize3TolPlus", + Label = "尺寸3上差a3", + Type = ParamValueType.Double, + Required = false, + DefaultValue = "", + Hint = "下拉列表(+2~+7),可手动编辑", + Order = 788, + Group = "尺寸-轴杆(方轴)" + }, + new ParamDefinition + { + Key = "SquareShaftSize3TolMinus", + Label = "尺寸3下差b3", + Type = ParamValueType.Double, + Required = false, + DefaultValue = "", + Hint = "下拉列表(-2~-7),可手动编辑", + Order = 789, + Group = "尺寸-轴杆(方轴)" + }, + new ParamDefinition + { + Key = "SquareShaftFilletRadiusMax", + Label = "未注圆角半径R≤", + Type = ParamValueType.Enum, + Required = false, + DefaultValue = "", + EnumOptions = new List { "6", "5", "4" }, + Hint = "下拉列表(6/5/4),可手动编辑", + Order = 790, + Group = "尺寸-轴杆(方轴)" + }, + new ParamDefinition + { + Key = "SquareShaftSize1Prime", + Label = "尺寸1'", + Type = ParamValueType.Double, + Required = false, + DefaultValue = "", + Hint = "零件尺寸", + Order = 791, + Group = "尺寸-轴杆(方轴)" + }, + new ParamDefinition + { + Key = "SquareShaftSize2Prime", + Label = "尺寸2'", + Type = ParamValueType.Double, + Required = false, + DefaultValue = "", + Hint = "零件尺寸", + Order = 792, + Group = "尺寸-轴杆(方轴)" + }, + new ParamDefinition + { + Key = "SquareShaftSize3Prime", + Label = "尺寸3'", + Type = ParamValueType.Double, + Required = false, + DefaultValue = "", + Hint = "零件尺寸", + Order = 793, + Group = "尺寸-轴杆(方轴)" + }, new ParamDefinition { Key = "DiskHeightTolPlus", diff --git a/Common/TemplateSchemaDefaults.cs b/Common/TemplateSchemaDefaults.cs index 8286793..7b8f134 100644 --- a/Common/TemplateSchemaDefaults.cs +++ b/Common/TemplateSchemaDefaults.cs @@ -218,6 +218,67 @@ namespace CadParamPluging.Common PartOwnershipConfigured = true }); + // 模板:交付状态=毛料态, 工艺方法=自由锻, 结构特征=轴杆, 特殊条件=圆轴 + schemas.Items.Add(new TemplateSchemaDefinition + { + ProjectType = "毛料态", + DrawingType = "自由锻", + SheetSize = "轴杆", + Scale = "圆轴", // Special Condition + DisplayName = "轴杆(毛料态/自由锻/圆轴)", + SelectedParamKeys = new List + { + "Diameter", + "DiameterTolPlus", + "DiameterTolMinus", + "Length", + "LengthTolPlus", + "LengthTolMinus", + "ShaftFilletRadiusMax", // 未注圆角半径R≤ + "DiameterPrime", + "LengthPrime" + }, + SelectedPartParamKeys = new List + { + "DiameterPrime", + "LengthPrime" + }, + PartOwnershipConfigured = true + }); + + // 模板:交付状态=毛料态, 工艺方法=自由锻, 结构特征=轴杆, 特殊条件=方轴 + schemas.Items.Add(new TemplateSchemaDefinition + { + ProjectType = "毛料态", + DrawingType = "自由锻", + SheetSize = "轴杆", + Scale = "方轴", + DisplayName = "轴杆(毛料态/自由锻/方轴)", + SelectedParamKeys = new List + { + "SquareShaftSize1", + "SquareShaftSize1TolPlus", + "SquareShaftSize1TolMinus", + "SquareShaftSize2", + "SquareShaftSize2TolPlus", + "SquareShaftSize2TolMinus", + "SquareShaftSize3", + "SquareShaftSize3TolPlus", + "SquareShaftSize3TolMinus", + "SquareShaftFilletRadiusMax", // 未注圆角半径R≤ + "SquareShaftSize1Prime", + "SquareShaftSize2Prime", + "SquareShaftSize3Prime" + }, + SelectedPartParamKeys = new List + { + "SquareShaftSize1Prime", + "SquareShaftSize2Prime", + "SquareShaftSize3Prime" + }, + PartOwnershipConfigured = true + }); + schemas.Normalize(); return schemas; }