feat: introduce new CAD drawing functionalities for raw forged blocks, rings, shafts, and disks.
This commit is contained in:
parent
2c816847f4
commit
f8e6443d04
@ -290,11 +290,11 @@ namespace CadParamPluging.Cad
|
|||||||
|
|
||||||
// 9. 硬度符号 - 从剖面右侧引出
|
// 9. 硬度符号 - 从剖面右侧引出
|
||||||
var hardnessVal = bag.GetString(FeatureDrivenDrawer.KeyHardness);
|
var hardnessVal = bag.GetString(FeatureDrivenDrawer.KeyHardness);
|
||||||
if (!string.IsNullOrWhiteSpace(hardnessVal))
|
if (!string.IsNullOrWhiteSpace(hardnessVal) && hardnessVal != "空")
|
||||||
{
|
{
|
||||||
double xStart = xSectionRight;
|
double xStart = xSectionRight;
|
||||||
double yStart = oy + H * 0.25;
|
double yStart = oy + H * 0.25;
|
||||||
DrawHardnessSymbol(ctx, xStart, yStart);
|
DrawHardnessSymbol(ctx, xStart, yStart, hardnessVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10. 标刻内容引线 - 从剖面左侧引出
|
// 10. 标刻内容引线 - 从剖面左侧引出
|
||||||
@ -823,7 +823,7 @@ namespace CadParamPluging.Cad
|
|||||||
return $"{baseText} {{\\H{tolScale}x;{single}}}";
|
return $"{baseText} {{\\H{tolScale}x;{single}}}";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DrawHardnessSymbol(FeatureDrivenDrawer.DrawingContext ctx, double xStart, double yStart)
|
private static void DrawHardnessSymbol(FeatureDrivenDrawer.DrawingContext ctx, double xStart, double yStart, string hardnessVal = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -842,22 +842,16 @@ namespace CadParamPluging.Cad
|
|||||||
ctx.Btr.AppendEntity(poly);
|
ctx.Btr.AppendEntity(poly);
|
||||||
ctx.Tr.AddNewlyCreatedDBObject(poly, true);
|
ctx.Tr.AddNewlyCreatedDBObject(poly, true);
|
||||||
|
|
||||||
double radius = 4.0;
|
string displayTxt = string.IsNullOrWhiteSpace(hardnessVal) ? "HB" : hardnessVal;
|
||||||
var center = new Point3d(p3.X + radius, p3.Y, 0);
|
|
||||||
var circle = new Circle(center, Vector3d.ZAxis, radius);
|
|
||||||
circle.ColorIndex = 3;
|
|
||||||
|
|
||||||
ctx.Btr.AppendEntity(circle);
|
|
||||||
ctx.Tr.AddNewlyCreatedDBObject(circle, true);
|
|
||||||
|
|
||||||
var text = new DBText();
|
var text = new DBText();
|
||||||
text.TextString = "HB";
|
text.TextString = displayTxt;
|
||||||
text.Height = 3.5;
|
text.Height = 3.5;
|
||||||
text.ColorIndex = 3;
|
text.ColorIndex = 3;
|
||||||
text.HorizontalMode = TextHorizontalMode.TextCenter;
|
text.HorizontalMode = TextHorizontalMode.TextLeft;
|
||||||
text.VerticalMode = TextVerticalMode.TextVerticalMid;
|
text.VerticalMode = TextVerticalMode.TextVerticalMid;
|
||||||
text.AlignmentPoint = center;
|
var tp = new Point3d(p3.X + 2.0, p3.Y, 0);
|
||||||
text.Position = center;
|
text.AlignmentPoint = tp;
|
||||||
|
text.Position = tp;
|
||||||
|
|
||||||
ctx.Btr.AppendEntity(text);
|
ctx.Btr.AppendEntity(text);
|
||||||
ctx.Tr.AddNewlyCreatedDBObject(text, true);
|
ctx.Tr.AddNewlyCreatedDBObject(text, true);
|
||||||
|
|||||||
@ -315,11 +315,11 @@ namespace CadParamPluging.Cad
|
|||||||
|
|
||||||
// 9. 硬度符号 - 从剖面右侧引出
|
// 9. 硬度符号 - 从剖面右侧引出
|
||||||
var hardnessVal = bag.GetString(FeatureDrivenDrawer.KeyHardness);
|
var hardnessVal = bag.GetString(FeatureDrivenDrawer.KeyHardness);
|
||||||
if (!string.IsNullOrWhiteSpace(hardnessVal))
|
if (!string.IsNullOrWhiteSpace(hardnessVal) && hardnessVal != "空")
|
||||||
{
|
{
|
||||||
double xStart = xSectionRight;
|
double xStart = xSectionRight;
|
||||||
double yStart = oy + H * 0.25;
|
double yStart = oy + H * 0.25;
|
||||||
DrawHardnessSymbol(ctx, xStart, yStart);
|
DrawHardnessSymbol(ctx, xStart, yStart, hardnessVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10. 标刻内容引线 - 从剖面左侧引出
|
// 10. 标刻内容引线 - 从剖面左侧引出
|
||||||
@ -669,7 +669,7 @@ namespace CadParamPluging.Cad
|
|||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DrawHardnessSymbol(FeatureDrivenDrawer.DrawingContext ctx, double xStart, double yStart)
|
private static void DrawHardnessSymbol(FeatureDrivenDrawer.DrawingContext ctx, double xStart, double yStart, string hardnessVal = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -688,22 +688,16 @@ namespace CadParamPluging.Cad
|
|||||||
ctx.Btr.AppendEntity(poly);
|
ctx.Btr.AppendEntity(poly);
|
||||||
ctx.Tr.AddNewlyCreatedDBObject(poly, true);
|
ctx.Tr.AddNewlyCreatedDBObject(poly, true);
|
||||||
|
|
||||||
double radius = 4.0;
|
string displayTxt = string.IsNullOrWhiteSpace(hardnessVal) ? "HB" : hardnessVal;
|
||||||
var center = new Point3d(p3.X + radius, p3.Y, 0);
|
|
||||||
var circle = new Circle(center, Vector3d.ZAxis, radius);
|
|
||||||
circle.ColorIndex = 3;
|
|
||||||
|
|
||||||
ctx.Btr.AppendEntity(circle);
|
|
||||||
ctx.Tr.AddNewlyCreatedDBObject(circle, true);
|
|
||||||
|
|
||||||
var text = new DBText();
|
var text = new DBText();
|
||||||
text.TextString = "HB";
|
text.TextString = displayTxt;
|
||||||
text.Height = 3.5;
|
text.Height = 3.5;
|
||||||
text.ColorIndex = 3;
|
text.ColorIndex = 3;
|
||||||
text.HorizontalMode = TextHorizontalMode.TextCenter;
|
text.HorizontalMode = TextHorizontalMode.TextLeft;
|
||||||
text.VerticalMode = TextVerticalMode.TextVerticalMid;
|
text.VerticalMode = TextVerticalMode.TextVerticalMid;
|
||||||
text.AlignmentPoint = center;
|
var tp = new Point3d(p3.X + 2.0, p3.Y, 0);
|
||||||
text.Position = center;
|
text.AlignmentPoint = tp;
|
||||||
|
text.Position = tp;
|
||||||
|
|
||||||
ctx.Btr.AppendEntity(text);
|
ctx.Btr.AppendEntity(text);
|
||||||
ctx.Tr.AddNewlyCreatedDBObject(text, true);
|
ctx.Tr.AddNewlyCreatedDBObject(text, true);
|
||||||
|
|||||||
@ -178,6 +178,24 @@ namespace CadParamPluging.Cad
|
|||||||
{
|
{
|
||||||
DrawDiskPartContour(ctx, ox, oy, diameter.Value, H, diaPrime.Value, heightPrime.Value);
|
DrawDiskPartContour(ctx, ox, oy, diameter.Value, H, diaPrime.Value, heightPrime.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 标刻内容
|
||||||
|
var markingText = bag.GetString(FeatureDrivenDrawer.KeyMarkingContent);
|
||||||
|
if (!string.IsNullOrWhiteSpace(markingText))
|
||||||
|
{
|
||||||
|
double xTarget = ctx.Center.X;
|
||||||
|
double yTarget = oy + H;
|
||||||
|
FeatureDrivenDrawer.DrawSpecialHBLeaderToTop(ctx, xTarget, yTarget, markingText);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 硬度符号
|
||||||
|
var hardnessVal = bag.GetString(FeatureDrivenDrawer.KeyHardness);
|
||||||
|
if (!string.IsNullOrWhiteSpace(hardnessVal) && hardnessVal != "空")
|
||||||
|
{
|
||||||
|
double xHardness = ctx.Center.X;
|
||||||
|
double yHardness = oy;
|
||||||
|
FeatureDrivenDrawer.DrawHardnessSymbol(ctx, xHardness, yHardness, hardnessVal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DrawDiskPartContour(FeatureDrivenDrawer.DrawingContext ctx, double ox, double oy,
|
private static void DrawDiskPartContour(FeatureDrivenDrawer.DrawingContext ctx, double ox, double oy,
|
||||||
|
|||||||
@ -165,12 +165,12 @@ namespace CadParamPluging.Cad.Drawers
|
|||||||
double lineEnd = xInnerRightVal + innerFilletR;
|
double lineEnd = xInnerRightVal + innerFilletR;
|
||||||
|
|
||||||
var connectingLineTop = new Line(new Point3d(lineStart, oy + H, 0), new Point3d(lineEnd, oy + H, 0));
|
var connectingLineTop = new Line(new Point3d(lineStart, oy + H, 0), new Point3d(lineEnd, oy + H, 0));
|
||||||
connectingLineTop.ColorIndex = 7; // White
|
ctx.Style?.Apply(connectingLineTop, DrawingStyleManager.Role.OutlineBold);
|
||||||
ctx.Btr.AppendEntity(connectingLineTop);
|
ctx.Btr.AppendEntity(connectingLineTop);
|
||||||
ctx.Tr.AddNewlyCreatedDBObject(connectingLineTop, true);
|
ctx.Tr.AddNewlyCreatedDBObject(connectingLineTop, true);
|
||||||
|
|
||||||
var connectingLineBottom = new Line(new Point3d(lineStart, oy, 0), new Point3d(lineEnd, oy, 0));
|
var connectingLineBottom = new Line(new Point3d(lineStart, oy, 0), new Point3d(lineEnd, oy, 0));
|
||||||
connectingLineBottom.ColorIndex = 7; // White
|
ctx.Style?.Apply(connectingLineBottom, DrawingStyleManager.Role.OutlineBold);
|
||||||
ctx.Btr.AppendEntity(connectingLineBottom);
|
ctx.Btr.AppendEntity(connectingLineBottom);
|
||||||
ctx.Tr.AddNewlyCreatedDBObject(connectingLineBottom, true);
|
ctx.Tr.AddNewlyCreatedDBObject(connectingLineBottom, true);
|
||||||
|
|
||||||
@ -260,17 +260,17 @@ namespace CadParamPluging.Cad.Drawers
|
|||||||
|
|
||||||
// 9. Hardness Symbol
|
// 9. Hardness Symbol
|
||||||
var hardnessVal = bag.GetString(FeatureDrivenDrawer.KeyHardness);
|
var hardnessVal = bag.GetString(FeatureDrivenDrawer.KeyHardness);
|
||||||
if (!string.IsNullOrWhiteSpace(hardnessVal))
|
if (!string.IsNullOrWhiteSpace(hardnessVal) && hardnessVal != "空")
|
||||||
{
|
{
|
||||||
if (xInnerRight.HasValue)
|
if (xInnerRight.HasValue)
|
||||||
{
|
{
|
||||||
double xStart = (xInnerRight.Value + ox + W) / 2.0;
|
double xStart = (xInnerRight.Value + ox + W) / 2.0;
|
||||||
double yStart = oy;
|
double yStart = oy;
|
||||||
FeatureDrivenDrawer.DrawHardnessSymbol(ctx, xStart, yStart);
|
FeatureDrivenDrawer.DrawHardnessSymbol(ctx, xStart, yStart, hardnessVal);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FeatureDrivenDrawer.DrawHardnessSymbol(ctx, ox + W / 2.0, oy);
|
FeatureDrivenDrawer.DrawHardnessSymbol(ctx, ox + W / 2.0, oy, hardnessVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -168,12 +168,12 @@ namespace CadParamPluging.Cad.Drawers
|
|||||||
double lineEnd = xInnerRightVal + sectionFilletR;
|
double lineEnd = xInnerRightVal + sectionFilletR;
|
||||||
|
|
||||||
var connectingLineTop = new Line(new Point3d(lineStart, oy + H, 0), new Point3d(lineEnd, oy + H, 0));
|
var connectingLineTop = new Line(new Point3d(lineStart, oy + H, 0), new Point3d(lineEnd, oy + H, 0));
|
||||||
connectingLineTop.ColorIndex = 7; // White
|
ctx.Style?.Apply(connectingLineTop, DrawingStyleManager.Role.OutlineBold);
|
||||||
ctx.Btr.AppendEntity(connectingLineTop);
|
ctx.Btr.AppendEntity(connectingLineTop);
|
||||||
ctx.Tr.AddNewlyCreatedDBObject(connectingLineTop, true);
|
ctx.Tr.AddNewlyCreatedDBObject(connectingLineTop, true);
|
||||||
|
|
||||||
var connectingLineBottom = new Line(new Point3d(lineStart, oy, 0), new Point3d(lineEnd, oy, 0));
|
var connectingLineBottom = new Line(new Point3d(lineStart, oy, 0), new Point3d(lineEnd, oy, 0));
|
||||||
connectingLineBottom.ColorIndex = 7; // White
|
ctx.Style?.Apply(connectingLineBottom, DrawingStyleManager.Role.OutlineBold);
|
||||||
ctx.Btr.AppendEntity(connectingLineBottom);
|
ctx.Btr.AppendEntity(connectingLineBottom);
|
||||||
ctx.Tr.AddNewlyCreatedDBObject(connectingLineBottom, true);
|
ctx.Tr.AddNewlyCreatedDBObject(connectingLineBottom, true);
|
||||||
|
|
||||||
@ -286,17 +286,17 @@ namespace CadParamPluging.Cad.Drawers
|
|||||||
|
|
||||||
// 9. Hardness Symbol
|
// 9. Hardness Symbol
|
||||||
var hardnessVal = bag.GetString(FeatureDrivenDrawer.KeyHardness);
|
var hardnessVal = bag.GetString(FeatureDrivenDrawer.KeyHardness);
|
||||||
if (!string.IsNullOrWhiteSpace(hardnessVal))
|
if (!string.IsNullOrWhiteSpace(hardnessVal) && hardnessVal != "空")
|
||||||
{
|
{
|
||||||
if (xInnerRight.HasValue)
|
if (xInnerRight.HasValue)
|
||||||
{
|
{
|
||||||
double xStart = (xInnerRight.Value + ox + W) / 2.0;
|
double xStart = (xInnerRight.Value + ox + W) / 2.0;
|
||||||
double yStart = oy;
|
double yStart = oy;
|
||||||
FeatureDrivenDrawer.DrawHardnessSymbol(ctx, xStart, yStart);
|
FeatureDrivenDrawer.DrawHardnessSymbol(ctx, xStart, yStart, hardnessVal);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FeatureDrivenDrawer.DrawHardnessSymbol(ctx, ox + W / 2.0, oy);
|
FeatureDrivenDrawer.DrawHardnessSymbol(ctx, ox + W / 2.0, oy, hardnessVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -770,7 +770,7 @@ namespace CadParamPluging.Cad
|
|||||||
// === 特征9: 硬度符号 ===
|
// === 特征9: 硬度符号 ===
|
||||||
// 只要有硬度参数就画,不再局限于"毛料态-轧制-环形"
|
// 只要有硬度参数就画,不再局限于"毛料态-轧制-环形"
|
||||||
var hardnessVal = bag.GetString(KeyHardness);
|
var hardnessVal = bag.GetString(KeyHardness);
|
||||||
if (!string.IsNullOrWhiteSpace(hardnessVal))
|
if (!string.IsNullOrWhiteSpace(hardnessVal) && hardnessVal != "空")
|
||||||
{
|
{
|
||||||
// 指向锻件剖面图的底部边框的中间位置
|
// 指向锻件剖面图的底部边框的中间位置
|
||||||
// 坐标: mid X, yBottom
|
// 坐标: mid X, yBottom
|
||||||
@ -779,7 +779,7 @@ namespace CadParamPluging.Cad
|
|||||||
double xStart = (xLoopInner + xLoopOuter) / 2.0;
|
double xStart = (xLoopInner + xLoopOuter) / 2.0;
|
||||||
double yStart = oy;
|
double yStart = oy;
|
||||||
|
|
||||||
DrawHardnessSymbol(ctx, xStart, yStart);
|
DrawHardnessSymbol(ctx, xStart, yStart, hardnessVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -982,19 +982,19 @@ namespace CadParamPluging.Cad
|
|||||||
|
|
||||||
// === 特征9: 硬度符号 ===
|
// === 特征9: 硬度符号 ===
|
||||||
var hardnessVal = bag.GetString(KeyHardness);
|
var hardnessVal = bag.GetString(KeyHardness);
|
||||||
if (!string.IsNullOrWhiteSpace(hardnessVal))
|
if (!string.IsNullOrWhiteSpace(hardnessVal) && hardnessVal != "空")
|
||||||
{
|
{
|
||||||
// 指向剖面图的底部边框的中间位置
|
// 指向剖面图的底部边框的中间位置
|
||||||
if (xInnerRight.HasValue)
|
if (xInnerRight.HasValue)
|
||||||
{
|
{
|
||||||
double xStart = (xInnerRight.Value + ox + W) / 2.0;
|
double xStart = (xInnerRight.Value + ox + W) / 2.0;
|
||||||
double yStart = oy;
|
double yStart = oy;
|
||||||
DrawHardnessSymbol(ctx, xStart, yStart);
|
DrawHardnessSymbol(ctx, xStart, yStart, hardnessVal);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 若无内孔(理论上环形应有),可指向整体中间
|
// 若无内孔(理论上环形应有),可指向整体中间
|
||||||
DrawHardnessSymbol(ctx, ox + W / 2.0, oy);
|
DrawHardnessSymbol(ctx, ox + W / 2.0, oy, hardnessVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2885,7 +2885,7 @@ namespace CadParamPluging.Cad
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void DrawHardnessSymbol(DrawingContext ctx, double xStart, double yStart)
|
public static void DrawHardnessSymbol(DrawingContext ctx, double xStart, double yStart, string hardnessVal = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -2896,7 +2896,7 @@ namespace CadParamPluging.Cad
|
|||||||
|
|
||||||
var p1 = new Point3d(xStart, yStart, 0);
|
var p1 = new Point3d(xStart, yStart, 0);
|
||||||
var p2 = new Point3d(xStart + 15, yStart - 15, 0);
|
var p2 = new Point3d(xStart + 15, yStart - 15, 0);
|
||||||
var p3 = new Point3d(p2.X + 10, p2.Y, 0); // 这里的p3是直线的终点,圆接在这里
|
var p3 = new Point3d(p2.X + 10, p2.Y, 0); // 这里的p3是直线的终点,短线接在这里
|
||||||
|
|
||||||
// 绘制引线
|
// 绘制引线
|
||||||
var poly = new Polyline();
|
var poly = new Polyline();
|
||||||
@ -2911,25 +2911,17 @@ namespace CadParamPluging.Cad
|
|||||||
ctx.Btr.AppendEntity(poly);
|
ctx.Btr.AppendEntity(poly);
|
||||||
ctx.Tr.AddNewlyCreatedDBObject(poly, true);
|
ctx.Tr.AddNewlyCreatedDBObject(poly, true);
|
||||||
|
|
||||||
// 2. 圆圈 (HB)
|
// 2. 文字 (硬度的具体值)
|
||||||
// 圆心 x = p3.X + R
|
string displayTxt = string.IsNullOrWhiteSpace(hardnessVal) ? "HB" : hardnessVal;
|
||||||
double radius = 4.0;
|
|
||||||
var center = new Point3d(p3.X + radius, p3.Y, 0);
|
|
||||||
var circle = new Circle(center, Vector3d.ZAxis, radius);
|
|
||||||
circle.ColorIndex = 3;
|
|
||||||
|
|
||||||
ctx.Btr.AppendEntity(circle);
|
|
||||||
ctx.Tr.AddNewlyCreatedDBObject(circle, true);
|
|
||||||
|
|
||||||
// 3. 文字 (HB)
|
|
||||||
var text = new DBText();
|
var text = new DBText();
|
||||||
text.TextString = "HB";
|
text.TextString = displayTxt;
|
||||||
text.Height = 3.5;
|
text.Height = 3.5;
|
||||||
text.ColorIndex = 3;
|
text.ColorIndex = 3;
|
||||||
text.HorizontalMode = TextHorizontalMode.TextCenter;
|
text.HorizontalMode = TextHorizontalMode.TextLeft;
|
||||||
text.VerticalMode = TextVerticalMode.TextVerticalMid;
|
text.VerticalMode = TextVerticalMode.TextVerticalMid;
|
||||||
text.AlignmentPoint = center;
|
var tp = new Point3d(p3.X + 2.0, p3.Y, 0);
|
||||||
text.Position = center;
|
text.AlignmentPoint = tp;
|
||||||
|
text.Position = tp;
|
||||||
|
|
||||||
ctx.Btr.AppendEntity(text);
|
ctx.Btr.AppendEntity(text);
|
||||||
ctx.Tr.AddNewlyCreatedDBObject(text, true);
|
ctx.Tr.AddNewlyCreatedDBObject(text, true);
|
||||||
@ -3220,11 +3212,11 @@ namespace CadParamPluging.Cad
|
|||||||
|
|
||||||
// 9. 硬度符号 - 从剖面底部引出
|
// 9. 硬度符号 - 从剖面底部引出
|
||||||
var hardnessVal = bag.GetString(KeyHardness);
|
var hardnessVal = bag.GetString(KeyHardness);
|
||||||
if (!string.IsNullOrWhiteSpace(hardnessVal))
|
if (!string.IsNullOrWhiteSpace(hardnessVal) && hardnessVal != "空")
|
||||||
{
|
{
|
||||||
double xStart = (xSectionLeft + xSectionRight) / 2.0;
|
double xStart = (xSectionLeft + xSectionRight) / 2.0;
|
||||||
double yStart = oy;
|
double yStart = oy;
|
||||||
DrawHardnessSymbol(ctx, xStart, yStart);
|
DrawHardnessSymbol(ctx, xStart, yStart, hardnessVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10. 标刻内容引线 - 从剖面顶部引出
|
// 10. 标刻内容引线 - 从剖面顶部引出
|
||||||
|
|||||||
@ -288,6 +288,97 @@ namespace CadParamPluging.Cad
|
|||||||
|
|
||||||
// === 特征9: 硬度符号 (HB) ===
|
// === 特征9: 硬度符号 (HB) ===
|
||||||
// 【已移除】按用户需求,此模板不绘制红色方框中的硬度符号
|
// 【已移除】按用户需求,此模板不绘制红色方框中的硬度符号
|
||||||
|
|
||||||
|
// === 特征11: 粗糙度符号 (右上角) ===
|
||||||
|
var roughnessVal = bag.GetString("SurfaceRoughness");
|
||||||
|
if (!string.IsNullOrWhiteSpace(roughnessVal) && roughnessVal != "空")
|
||||||
|
{
|
||||||
|
DrawAllRoughnessSymbol(ctx, roughnessVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DrawAllRoughnessSymbol(FeatureDrivenDrawer.DrawingContext ctx, string value)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 获取整个模板右上方坐标
|
||||||
|
double maxX = 0;
|
||||||
|
double maxY = 0;
|
||||||
|
|
||||||
|
var frameExtents = TemplateDrawingService.ComputeWhiteFrameExtents(ctx?.Ctx);
|
||||||
|
if (frameExtents.HasValue)
|
||||||
|
{
|
||||||
|
maxX = frameExtents.Value.MaxPoint.X;
|
||||||
|
maxY = frameExtents.Value.MaxPoint.Y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Fallback, 以中心+200估算
|
||||||
|
maxX = ctx.Center.X + 200;
|
||||||
|
maxY = ctx.Center.Y + 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定位:距离右上角内缩一定边距,调整为更靠近右上角 (5.0)
|
||||||
|
double pRightX = maxX - 5.0;
|
||||||
|
double pTopY = maxY - 5.0;
|
||||||
|
|
||||||
|
double hTotal = 11.0;
|
||||||
|
double hTriangle = 5.5;
|
||||||
|
|
||||||
|
double dxTotal = hTotal * Math.Tan(30.0 * Math.PI / 180.0);
|
||||||
|
double originX = pRightX - dxTotal;
|
||||||
|
double originY = pTopY - hTotal;
|
||||||
|
|
||||||
|
var p0 = new Point3d(originX, originY, 0);
|
||||||
|
|
||||||
|
double dxTriangle = hTriangle * Math.Tan(30.0 * Math.PI / 180.0);
|
||||||
|
var p1 = new Point3d(originX - dxTriangle, originY + hTriangle, 0);
|
||||||
|
var p2 = new Point3d(originX + dxTriangle, originY + hTriangle, 0);
|
||||||
|
var p3 = new Point3d(pRightX, pTopY, 0);
|
||||||
|
|
||||||
|
var line1 = new Line(p1, p0);
|
||||||
|
var line2 = new Line(p0, p3);
|
||||||
|
var line3 = new Line(p1, p2);
|
||||||
|
|
||||||
|
line1.ColorIndex = 7; // White
|
||||||
|
line2.ColorIndex = 7;
|
||||||
|
line3.ColorIndex = 7;
|
||||||
|
|
||||||
|
ctx.Btr.AppendEntity(line1);
|
||||||
|
ctx.Tr.AddNewlyCreatedDBObject(line1, true);
|
||||||
|
|
||||||
|
ctx.Btr.AppendEntity(line2);
|
||||||
|
ctx.Tr.AddNewlyCreatedDBObject(line2, true);
|
||||||
|
|
||||||
|
ctx.Btr.AppendEntity(line3);
|
||||||
|
ctx.Tr.AddNewlyCreatedDBObject(line3, true);
|
||||||
|
|
||||||
|
// 粗糙度数值 (如1.6)
|
||||||
|
var textVal = new DBText();
|
||||||
|
textVal.TextString = value;
|
||||||
|
textVal.Height = 3.5;
|
||||||
|
textVal.ColorIndex = 7;
|
||||||
|
textVal.HorizontalMode = TextHorizontalMode.TextCenter;
|
||||||
|
textVal.VerticalMode = TextVerticalMode.TextBottom;
|
||||||
|
textVal.AlignmentPoint = new Point3d(originX, originY + hTriangle + 1.0, 0);
|
||||||
|
textVal.Position = textVal.AlignmentPoint;
|
||||||
|
ctx.Btr.AppendEntity(textVal);
|
||||||
|
ctx.Tr.AddNewlyCreatedDBObject(textVal, true);
|
||||||
|
|
||||||
|
// “所有”文本
|
||||||
|
var textAll = new DBText();
|
||||||
|
textAll.TextString = "所有";
|
||||||
|
textAll.Height = 3.5;
|
||||||
|
textAll.ColorIndex = 7;
|
||||||
|
textAll.HorizontalMode = TextHorizontalMode.TextRight;
|
||||||
|
textAll.VerticalMode = TextVerticalMode.TextVerticalMid;
|
||||||
|
// 向左偏移一点,中心对齐三角线高度
|
||||||
|
textAll.AlignmentPoint = new Point3d(p1.X - 2.0, originY + hTriangle, 0);
|
||||||
|
textAll.Position = textAll.AlignmentPoint;
|
||||||
|
ctx.Btr.AppendEntity(textAll);
|
||||||
|
ctx.Tr.AddNewlyCreatedDBObject(textAll, true);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DrawMarkingLeaderToSide(FeatureDrivenDrawer.DrawingContext ctx, double xTarget, double yTargetTop, string markingText)
|
private static void DrawMarkingLeaderToSide(FeatureDrivenDrawer.DrawingContext ctx, double xTarget, double yTargetTop, string markingText)
|
||||||
|
|||||||
@ -297,9 +297,20 @@ namespace CadParamPluging.Cad
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === 特征9: 硬度符号 ===
|
// === 特征9: 硬度符号 ===
|
||||||
// 【移除】 按用户需求,“毛料态-轧制-环形”模板不应显示硬度符号?
|
var hardnessVal = bag.GetString(KeyHardness);
|
||||||
// "将料态/轧制/环形先改为独立",且之前提到“去掉该模板的硬度标志”,
|
if (!string.IsNullOrWhiteSpace(hardnessVal) && hardnessVal != "空")
|
||||||
// 所以这里移除 FeatureDrivenDrawer.DrawHardnessSymbol 的调用。
|
{
|
||||||
|
if (xInnerRight.HasValue)
|
||||||
|
{
|
||||||
|
double xStart = (xInnerRight.Value + ox + visualOuterR) / 2.0;
|
||||||
|
double yStart = oy;
|
||||||
|
FeatureDrivenDrawer.DrawHardnessSymbol(ctx, xStart, yStart, hardnessVal);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FeatureDrivenDrawer.DrawHardnessSymbol(ctx, ox + visualOuterR / 2.0, oy, hardnessVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 私有辅助绘图方法
|
#region 私有辅助绘图方法
|
||||||
|
|||||||
@ -179,12 +179,12 @@ namespace CadParamPluging.Cad
|
|||||||
|
|
||||||
// 4. 硬度和标刻
|
// 4. 硬度和标刻
|
||||||
var hardnessVal = bag.GetString(FeatureDrivenDrawer.KeyHardness);
|
var hardnessVal = bag.GetString(FeatureDrivenDrawer.KeyHardness);
|
||||||
if (!string.IsNullOrWhiteSpace(hardnessVal))
|
if (!string.IsNullOrWhiteSpace(hardnessVal) && hardnessVal != "空")
|
||||||
{
|
{
|
||||||
// 硬度放在底部中心位置
|
// 硬度放在底部中心位置
|
||||||
double xStart = ctx.Center.X;
|
double xStart = ctx.Center.X;
|
||||||
double yStart = oy;
|
double yStart = oy;
|
||||||
FeatureDrivenDrawer.DrawHardnessSymbol(ctx, xStart, yStart);
|
FeatureDrivenDrawer.DrawHardnessSymbol(ctx, xStart, yStart, hardnessVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
var markingText = bag.GetString(FeatureDrivenDrawer.KeyMarkingContent);
|
var markingText = bag.GetString(FeatureDrivenDrawer.KeyMarkingContent);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Autodesk.AutoCAD.DatabaseServices;
|
using Autodesk.AutoCAD.DatabaseServices;
|
||||||
using Autodesk.AutoCAD.Geometry;
|
using Autodesk.AutoCAD.Geometry;
|
||||||
@ -63,10 +63,13 @@ namespace CadParamPluging.Cad
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double S1 = size1.Value;
|
// Swap Size1 and Size2 so Size2 is horizontal and Size1 is vertical
|
||||||
double S2 = size2.Value;
|
double S1 = size2.Value;
|
||||||
|
double S2 = size1.Value;
|
||||||
double S3 = size3.HasValue && size3.Value > 0 ? size3.Value : 0;
|
double S3 = size3.HasValue && size3.Value > 0 ? size3.Value : 0;
|
||||||
double originalS1 = originalSize1.HasValue ? originalSize1.Value : S1;
|
|
||||||
|
var originalSize2 = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize2);
|
||||||
|
double originalS1 = originalSize2.HasValue ? originalSize2.Value : S1;
|
||||||
|
|
||||||
double ox = ctx.Center.X - S1 / 2.0;
|
double ox = ctx.Center.X - S1 / 2.0;
|
||||||
double oy = ctx.Center.Y - S2 / 2.0;
|
double oy = ctx.Center.Y - S2 / 2.0;
|
||||||
@ -145,16 +148,16 @@ namespace CadParamPluging.Cad
|
|||||||
|
|
||||||
// 4. Dimensions
|
// 4. Dimensions
|
||||||
{
|
{
|
||||||
var val = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize1) ?? S1;
|
var val = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize2) ?? S1;
|
||||||
var str = ctx.OriginalBag?.GetString(FeatureDrivenDrawer.KeySquareShaftSize1);
|
var str = ctx.OriginalBag?.GetString(FeatureDrivenDrawer.KeySquareShaftSize2);
|
||||||
var tolPlus = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize1TolPlus);
|
var tolPlus = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize2TolPlus);
|
||||||
var tolMinus = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize1TolMinus);
|
var tolMinus = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize2TolMinus);
|
||||||
var tolPlusStr = ctx.OriginalBag?.GetString(FeatureDrivenDrawer.KeySquareShaftSize1TolPlus);
|
var tolPlusStr = ctx.OriginalBag?.GetString(FeatureDrivenDrawer.KeySquareShaftSize2TolPlus);
|
||||||
var tolMinusStr = ctx.OriginalBag?.GetString(FeatureDrivenDrawer.KeySquareShaftSize1TolMinus);
|
var tolMinusStr = ctx.OriginalBag?.GetString(FeatureDrivenDrawer.KeySquareShaftSize2TolMinus);
|
||||||
|
|
||||||
var dimText = FeatureDrivenDrawer.BuildDimensionText(FeatureDrivenDrawer.FormatDimNumber(val, str), tolPlus, tolMinus, tolPlusStr, tolMinusStr);
|
var dimText = FeatureDrivenDrawer.BuildDimensionText(FeatureDrivenDrawer.FormatDimNumber(val, str), tolPlus, tolMinus, tolPlusStr, tolMinusStr);
|
||||||
|
|
||||||
var valPrime = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize1Prime);
|
var valPrime = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize2Prime);
|
||||||
if (valPrime.HasValue && valPrime.Value > 0)
|
if (valPrime.HasValue && valPrime.Value > 0)
|
||||||
{
|
{
|
||||||
dimText += @"\X(" + FeatureDrivenDrawer.FormatDimNumber(valPrime.Value) + ")";
|
dimText += @"\X(" + FeatureDrivenDrawer.FormatDimNumber(valPrime.Value) + ")";
|
||||||
@ -166,16 +169,16 @@ namespace CadParamPluging.Cad
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var val = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize2) ?? S2;
|
var val = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize1) ?? S2;
|
||||||
var str = ctx.OriginalBag?.GetString(FeatureDrivenDrawer.KeySquareShaftSize2);
|
var str = ctx.OriginalBag?.GetString(FeatureDrivenDrawer.KeySquareShaftSize1);
|
||||||
var tolPlus = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize2TolPlus);
|
var tolPlus = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize1TolPlus);
|
||||||
var tolMinus = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize2TolMinus);
|
var tolMinus = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize1TolMinus);
|
||||||
var tolPlusStr = ctx.OriginalBag?.GetString(FeatureDrivenDrawer.KeySquareShaftSize2TolPlus);
|
var tolPlusStr = ctx.OriginalBag?.GetString(FeatureDrivenDrawer.KeySquareShaftSize1TolPlus);
|
||||||
var tolMinusStr = ctx.OriginalBag?.GetString(FeatureDrivenDrawer.KeySquareShaftSize2TolMinus);
|
var tolMinusStr = ctx.OriginalBag?.GetString(FeatureDrivenDrawer.KeySquareShaftSize1TolMinus);
|
||||||
|
|
||||||
var dimText = FeatureDrivenDrawer.BuildDimensionText(FeatureDrivenDrawer.FormatDimNumber(val, str), tolPlus, tolMinus, tolPlusStr, tolMinusStr);
|
var dimText = FeatureDrivenDrawer.BuildDimensionText(FeatureDrivenDrawer.FormatDimNumber(val, str), tolPlus, tolMinus, tolPlusStr, tolMinusStr);
|
||||||
|
|
||||||
var valPrime = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize2Prime);
|
var valPrime = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize1Prime);
|
||||||
if (valPrime.HasValue && valPrime.Value > 0)
|
if (valPrime.HasValue && valPrime.Value > 0)
|
||||||
{
|
{
|
||||||
dimText += @"\X(" + FeatureDrivenDrawer.FormatDimNumber(valPrime.Value) + ")";
|
dimText += @"\X(" + FeatureDrivenDrawer.FormatDimNumber(valPrime.Value) + ")";
|
||||||
@ -219,11 +222,11 @@ namespace CadParamPluging.Cad
|
|||||||
}
|
}
|
||||||
|
|
||||||
var hardnessVal = bag.GetString(FeatureDrivenDrawer.KeyHardness);
|
var hardnessVal = bag.GetString(FeatureDrivenDrawer.KeyHardness);
|
||||||
if (!string.IsNullOrWhiteSpace(hardnessVal))
|
if (!string.IsNullOrWhiteSpace(hardnessVal) && hardnessVal != "空")
|
||||||
{
|
{
|
||||||
double xStart = (S3 > 0) ? ctx.Center.X : (ox + S1 / 2.0);
|
double xStart = (S3 > 0) ? ctx.Center.X : (ox + S1 / 2.0);
|
||||||
double yStart = oy;
|
double yStart = oy;
|
||||||
FeatureDrivenDrawer.DrawHardnessSymbol(ctx, xStart, yStart);
|
FeatureDrivenDrawer.DrawHardnessSymbol(ctx, xStart, yStart, hardnessVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
var markingText = bag.GetString(FeatureDrivenDrawer.KeyMarkingContent);
|
var markingText = bag.GetString(FeatureDrivenDrawer.KeyMarkingContent);
|
||||||
@ -238,14 +241,14 @@ namespace CadParamPluging.Cad
|
|||||||
var s2Prime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize2Prime);
|
var s2Prime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize2Prime);
|
||||||
if (s1Prime.HasValue && s1Prime.Value > 0 && s2Prime.HasValue && s2Prime.Value > 0)
|
if (s1Prime.HasValue && s1Prime.Value > 0 && s2Prime.HasValue && s2Prime.Value > 0)
|
||||||
{
|
{
|
||||||
double pL = s1Prime.Value;
|
// Size2 is horizontal (width), Size1 is vertical (height)
|
||||||
double pH = s2Prime.Value;
|
double pL = s2Prime.Value;
|
||||||
|
double pH = s1Prime.Value;
|
||||||
double pOx = ctx.Center.X - pL / 2.0;
|
double pOx = ctx.Center.X - pL / 2.0;
|
||||||
double pOy = ctx.Center.Y - pH / 2.0;
|
double pOy = ctx.Center.Y - pH / 2.0;
|
||||||
|
|
||||||
if (needBreakLines)
|
if (needBreakLines)
|
||||||
{
|
{
|
||||||
// double xBreak = ox + S1 / 4.0; // variable is already declared in outer scope
|
|
||||||
DrawRectOutlineWithBreak(ctx, pOx, pOy, pL, pH, xBreak, lineSpacing, DrawingStyleManager.Role.PartContour);
|
DrawRectOutlineWithBreak(ctx, pOx, pOy, pL, pH, xBreak, lineSpacing, DrawingStyleManager.Role.PartContour);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -306,6 +306,22 @@ namespace CadParamPluging.Common
|
|||||||
if (key != null && (key.StartsWith("MarkingContent", StringComparison.OrdinalIgnoreCase) || key.StartsWith("Hardness", StringComparison.OrdinalIgnoreCase)))
|
if (key != null && (key.StartsWith("MarkingContent", StringComparison.OrdinalIgnoreCase) || key.StartsWith("Hardness", StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
// MarkingContent / Hardness -> render empty string
|
// MarkingContent / Hardness -> render empty string
|
||||||
|
if (key.StartsWith("Hardness", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
int rIdx = sb.Length - 1;
|
||||||
|
while (rIdx >= 0 && char.IsWhiteSpace(sb[rIdx]))
|
||||||
|
{
|
||||||
|
rIdx--;
|
||||||
|
}
|
||||||
|
if (rIdx >= 0)
|
||||||
|
{
|
||||||
|
char lc = sb[rIdx];
|
||||||
|
if (lc == ',' || lc == ',' || lc == '.' || lc == '。' || lc == ';' || lc == ';' || lc == '、')
|
||||||
|
{
|
||||||
|
sb.Length = rIdx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// (Separators will be cleaned up later)
|
// (Separators will be cleaned up later)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user