增加了毛料态、自由锻、环形、非中心冲孔模板,还没完善生成,生成代码是独立文件

This commit is contained in:
sladro 2026-01-28 15:29:45 +08:00
parent 6b71730057
commit 1ab7899cdf
7 changed files with 364 additions and 49 deletions

View File

@ -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<string>(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);
}
}
}
}
}

View File

@ -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);
}
}
}

View File

@ -13,6 +13,7 @@ namespace CadParamPluging.Cad
Register(new RingMachinedRollingGenerator()); Register(new RingMachinedRollingGenerator());
Register(new RingRawRollingGenerator()); Register(new RingRawRollingGenerator());
Register(new BlockRawFreeForgeRoundHeadGenerator()); Register(new BlockRawFreeForgeRoundHeadGenerator());
Register(new RingRawFreeForgeNonCenterPunchGenerator());
} }
public static bool TryResolve(string templateKey, out ITemplateDrawingGenerator generator) public static bool TryResolve(string templateKey, out ITemplateDrawingGenerator generator)

View File

@ -99,7 +99,8 @@ namespace CadParamPluging.Cad
&& DeliveryStatus.IndexOf("车加工", StringComparison.OrdinalIgnoreCase) >= 0; && DeliveryStatus.IndexOf("车加工", StringComparison.OrdinalIgnoreCase) >= 0;
public bool IsCenterPunched => !string.IsNullOrWhiteSpace(SpecialCondition) 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) public bool HasRoundHead => !string.IsNullOrWhiteSpace(SpecialCondition)
&& SpecialCondition.IndexOf("有圆头", StringComparison.OrdinalIgnoreCase) >= 0; && SpecialCondition.IndexOf("有圆头", StringComparison.OrdinalIgnoreCase) >= 0;
@ -699,9 +700,12 @@ namespace CadParamPluging.Cad
// 需满足: 车加工 + 轧制(本方法即为轧制) + 有内孔 // 需满足: 车加工 + 轧制(本方法即为轧制) + 有内孔
if (ctx.IsMachined && innerDia.HasValue && innerDia.Value > 0) if (ctx.IsMachined && innerDia.HasValue && innerDia.Value > 0)
{ {
if (applyUnspecifiedFillet) // 获取标刻内容
var markingText = bag.GetString(KeyMarkingContent);
// 只要有标刻内容,或者处于"毛料态-轧制-环形"模式,都画
if (!string.IsNullOrWhiteSpace(markingText) || applyUnspecifiedFillet)
{ {
// [修改] 针对“毛料态-轧制-环形”模板 // [修改]
// 指向锻件顶部白色边框的中间位置 // 指向锻件顶部白色边框的中间位置
// 顶部中间 X = (xInnerRight + xOuterRight) / 2 // 顶部中间 X = (xInnerRight + xOuterRight) / 2
// Y = Top = oy + H // Y = Top = oy + H
@ -710,10 +714,6 @@ namespace CadParamPluging.Cad
var xTarget = (xLoopInner + xLoopOuter) / 2.0; var xTarget = (xLoopInner + xLoopOuter) / 2.0;
var yTarget = oy + H; var yTarget = oy + H;
// 获取标刻内容
var markingText = bag.GetString(KeyMarkingContent);
if (string.IsNullOrWhiteSpace(markingText)) if (string.IsNullOrWhiteSpace(markingText))
{ {
markingText = "HB5936-13"; // 默认值 markingText = "HB5936-13"; // 默认值
@ -729,26 +729,20 @@ namespace CadParamPluging.Cad
} }
} }
// === 特征9: 硬度符号 === // === 特征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;
// 坐标: mid X, yBottom double xStart = (xLoopInner + xLoopOuter) / 2.0;
double xLoopInner = ox + visualInnerR; double yStart = oy;
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
/// 轧制:绘制带圆角的实体闭合轮廓(圆角多段线) /// 轧制:绘制带圆角的实体闭合轮廓(圆角多段线)
/// 替代原来分散的外轮廓线和内孔边界线 /// 替代原来分散的外轮廓线和内孔边界线
/// </summary> /// </summary>
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 yTop = yBottom + height;
var width = xRight - xLeft; var width = xRight - xLeft;
@ -823,7 +817,7 @@ namespace CadParamPluging.Cad
ctx.Tr.AddNewlyCreatedDBObject(polyFillet, true); 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; var yTop = yBottom + height;
@ -860,7 +854,10 @@ namespace CadParamPluging.Cad
/// <summary> /// <summary>
/// 自由锻工艺 - 画全图 /// 自由锻工艺 - 画全图
/// </summary> /// </summary>
private static void DrawRingFeaturesFull(DrawingContext ctx, double outerDia, double height) /// <summary>
/// 自由锻工艺 - 画全图
/// </summary>
public static void DrawRingFeaturesFull(DrawingContext ctx, double outerDia, double height)
{ {
var bag = ctx.Bag; var bag = ctx.Bag;
double W = outerDia; double W = outerDia;
@ -945,11 +942,42 @@ namespace CadParamPluging.Cad
DrawPartContour(ctx, ctx.Center, outerDiaPrime.Value, innerDiaPrime, heightPrime.Value); 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 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(); var poly = new Polyline();
poly.AddVertexAt(0, new Point2d(ox, oy), 0, 0, 0); poly.AddVertexAt(0, new Point2d(ox, oy), 0, 0, 0);
@ -979,7 +1007,7 @@ namespace CadParamPluging.Cad
ctx.Tr.AddNewlyCreatedDBObject(poly, true); 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 cy = oy + height / 2.0;
var line = new Line(new Point3d(ox - 10, cy, 0), new Point3d(ox + width + 10, cy, 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 #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; var yTop = yBottom + height;
@ -1290,7 +1318,7 @@ namespace CadParamPluging.Cad
ctx.Tr.AddNewlyCreatedDBObject(lineRight, true); 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; 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); 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 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) double diameter, double? tolPlus, double? tolMinus, double? diameterPrime)
{ {
// Use OriginalBag for text display to avoid scaled values // Use OriginalBag for text display to avoid scaled values
@ -1352,7 +1380,7 @@ namespace CadParamPluging.Cad
dimText); 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) double diameter, double? tolPlus, double? tolMinus, double? diameterPrime)
{ {
// Use OriginalBag for text display // Use OriginalBag for text display
@ -1384,7 +1412,7 @@ namespace CadParamPluging.Cad
dimText); 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) double height, double? tolPlus, double? tolMinus, double? heightPrime)
{ {
// Use OriginalBag for text display // Use OriginalBag for text display
@ -1416,7 +1444,7 @@ namespace CadParamPluging.Cad
dimText); 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 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 val = ctx.OriginalBag?.GetDoubleOrNull(KeyMinWallThickness) ?? thickness;
var dimText = $"{FormatDimNumber(val)}min"; var dimText = $"{FormatDimNumber(val)}min";
@ -1470,7 +1498,7 @@ namespace CadParamPluging.Cad
dimText); dimText);
} }
private static void DrawPartContour(DrawingContext ctx, Point3d center, public static void DrawPartContour(DrawingContext ctx, Point3d center,
double outerDiaPrime, double? innerDiaPrime, double heightPrime) double outerDiaPrime, double? innerDiaPrime, double heightPrime)
{ {
var w = outerDiaPrime; 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) 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) if (xOuterRight <= xInnerRight)
{ {
@ -2714,7 +2742,7 @@ namespace CadParamPluging.Cad
} }
#endregion #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 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 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 try
{ {

View File

@ -86,6 +86,8 @@
<Compile Include="Cad\Drawers\RingMachinedRollingGenerator.cs" /> <Compile Include="Cad\Drawers\RingMachinedRollingGenerator.cs" />
<Compile Include="Cad\Drawers\RingRawRollingGenerator.cs" /> <Compile Include="Cad\Drawers\RingRawRollingGenerator.cs" />
<Compile Include="Cad\Drawers\BlockRawFreeForgeRoundHeadGenerator.cs" /> <Compile Include="Cad\Drawers\BlockRawFreeForgeRoundHeadGenerator.cs" />
<Compile Include="Cad\Drawers\RingRawFreeForgeNonCenterPunchGenerator.cs" />
<Compile Include="Cad\Drawers\RingRawFreeForgeNonCenterPunchDrawer.cs" />
<Compile Include="Cad\Drawers\TemplateDrawingRegistry.cs" /> <Compile Include="Cad\Drawers\TemplateDrawingRegistry.cs" />
<Compile Include="Cad\TemplateAnnotationOptionsExtractor.cs" /> <Compile Include="Cad\TemplateAnnotationOptionsExtractor.cs" />
<Compile Include="Cad\TemplateLayoutAnnotationExtractor.cs" /> <Compile Include="Cad\TemplateLayoutAnnotationExtractor.cs" />

View File

@ -23,10 +23,10 @@ namespace CadParamPluging.Common
{ {
return new DropdownOptions return new DropdownOptions
{ {
DeliveryStatuses = new List<string> { "结构", "示例" }, DeliveryStatuses = new List<string> { "毛料态", "车加工" },
ProcessMethods = new List<string> { "基础平面", "示例图" }, ProcessMethods = new List<string> { "轧制", "自由锻" },
StructuralFeatures = new List<string> { "A1", "A3" }, StructuralFeatures = new List<string> { "环形", "方体" },
SpecialConditions = new List<string> { "无" } SpecialConditions = new List<string> { "无", "中心冲孔", "非中心冲孔", "有圆头" }
}; };
} }

View File

@ -113,6 +113,41 @@ namespace CadParamPluging.Common
PartOwnershipConfigured = true PartOwnershipConfigured = true
}); });
// 模板七:交付状态=毛料态, 工艺方法=自由锻, 结构特征=环形, 特殊条件=非中心冲孔
schemas.Items.Add(new TemplateSchemaDefinition
{
ProjectType = "毛料态",
DrawingType = "自由锻",
SheetSize = "环形",
Scale = "非中心冲孔",
DisplayName = "环形(毛料态/自由锻/非中心冲孔)",
SelectedParamKeys = new List<string>
{
"OuterDiameter1",
"OuterDiameter1TolPlus",
"OuterDiameter1TolMinus",
"InnerDiameter2",
"InnerDiameter2TolPlus",
"InnerDiameter2TolMinus",
"Height1",
"Height1TolPlus",
"Height1TolMinus",
"MinWallThickness",
"UnspecifiedFilletRadiusMax",
// 可选:车加工态参数
"OuterDiameter1Prime",
"InnerDiameter2Prime",
"Height1Prime"
},
SelectedPartParamKeys = new List<string>
{
"OuterDiameter1Prime",
"InnerDiameter2Prime",
"Height1Prime"
},
PartOwnershipConfigured = true
});
schemas.Normalize(); schemas.Normalize();
return schemas; return schemas;
} }