提交了毛料态/轧制/环形的硬度标注显示
This commit is contained in:
parent
d2c4be4226
commit
bef27c05fb
@ -70,6 +70,9 @@ namespace CadParamPluging.Cad
|
||||
public const string KeyBoxSize1Prime = "BoxSize1Prime"; // 方体零件尺寸1
|
||||
public const string KeyBoxSize2Prime = "BoxSize2Prime"; // 方体零件尺寸2
|
||||
public const string KeyBoxSize3Prime = "BoxSize3Prime"; // 方体零件尺寸3
|
||||
|
||||
// 其他参数
|
||||
public const string KeyHardness = "Hardness"; // 硬度
|
||||
|
||||
#endregion
|
||||
|
||||
@ -632,7 +635,8 @@ namespace CadParamPluging.Cad
|
||||
DrawHeightDimensionHalf(ctx, ox, oy, visualOuterR, H, heightTolPlus, heightTolMinus, heightPrime, heightDimIndentX);
|
||||
|
||||
// === 特征6: 未注圆角 ===
|
||||
if (unspecifiedFillet.HasValue && unspecifiedFillet.Value > 0)
|
||||
// 针对“毛料态-轧制-环形”模板(applyUnspecifiedFillet=true),不显示此文字
|
||||
if (!applyUnspecifiedFillet && unspecifiedFillet.HasValue && unspecifiedFillet.Value > 0)
|
||||
{
|
||||
DrawUnspecifiedFilletNote(ctx, ox, oy, H, visualOuterR, unspecifiedFillet.Value);
|
||||
}
|
||||
@ -677,12 +681,40 @@ namespace CadParamPluging.Cad
|
||||
// 需满足: 车加工 + 轧制(本方法即为轧制) + 有内孔
|
||||
if (ctx.IsMachined && innerDia.HasValue && innerDia.Value > 0)
|
||||
{
|
||||
// 指向锻件内孔右上角(白色线框)
|
||||
var scaledInnerDia = visualInnerR * 2.0;
|
||||
DrawSpecialInnerHoleLeader(ctx, ox, oy, H, scaledInnerDia);
|
||||
if (applyUnspecifiedFillet)
|
||||
{
|
||||
// [修改] 针对“毛料态-轧制-环形”模板
|
||||
// 指向锻件顶部白色边框的中间位置
|
||||
// 顶部中间 X = (xInnerRight + xOuterRight) / 2
|
||||
// Y = Top = oy + H
|
||||
var xLoopInner = ox + visualInnerR;
|
||||
var xLoopOuter = ox + visualOuterR;
|
||||
var xTarget = (xLoopInner + xLoopOuter) / 2.0;
|
||||
var yTarget = oy + H;
|
||||
|
||||
DrawSpecialHBLeaderToTop(ctx, xTarget, yTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 原有逻辑:指向锻件内孔右上角
|
||||
var scaledInnerDia = visualInnerR * 2.0;
|
||||
DrawSpecialInnerHoleLeader(ctx, ox, oy, H, scaledInnerDia);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// === 特征9: 硬度符号 ===
|
||||
var hardnessVal = bag.GetString(KeyHardness);
|
||||
if (!string.IsNullOrWhiteSpace(hardnessVal))
|
||||
{
|
||||
// 指向锻件剖面图的右下角 (白色边框)
|
||||
// 坐标: xOuterRight, yBottom
|
||||
double xCorner = ox + visualOuterR;
|
||||
double yCorner = oy;
|
||||
|
||||
DrawHardnessSymbol(ctx, xCorner, yCorner);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2701,5 +2733,110 @@ namespace CadParamPluging.Cad
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawSpecialHBLeaderToTop(DrawingContext ctx, double xTarget, double yTarget)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 箭头起点:顶部中间
|
||||
var p1 = new Point3d(xTarget, yTarget, 0);
|
||||
|
||||
// 转折点:向左上
|
||||
var p2 = new Point3d(xTarget - 10, yTarget + 10, 0);
|
||||
|
||||
// 终点:水平向左
|
||||
var p3 = new Point3d(p2.X - 35, p2.Y, 0);
|
||||
|
||||
var leader = new Leader();
|
||||
leader.SetDatabaseDefaults();
|
||||
leader.AppendVertex(p1);
|
||||
leader.AppendVertex(p2);
|
||||
leader.AppendVertex(p3);
|
||||
leader.HasArrowHead = true;
|
||||
leader.ColorIndex = 7; // 白色
|
||||
leader.Layer = "0";
|
||||
|
||||
ctx.Btr.AppendEntity(leader);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(leader, true);
|
||||
|
||||
// 绘制文字
|
||||
var text = new DBText();
|
||||
text.TextString = "HB5936-13";
|
||||
text.Height = 3.5;
|
||||
text.ColorIndex = 7; // 白色
|
||||
text.Layer = "0";
|
||||
|
||||
text.HorizontalMode = TextHorizontalMode.TextLeft;
|
||||
text.VerticalMode = TextVerticalMode.TextBottom;
|
||||
text.AlignmentPoint = new Point3d(p3.X, p3.Y + 1.0, 0);
|
||||
text.Position = text.AlignmentPoint;
|
||||
|
||||
ctx.Btr.AppendEntity(text);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(text, true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void DrawHardnessSymbol(DrawingContext ctx, double xStart, double yStart)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 1. 引线 (Diagonal Down-Right -> Horizontal)
|
||||
// 起点: (xStart, yStart)
|
||||
// 转折点: (xStart + 15, yStart - 15)
|
||||
// 终点(圆左侧): (xStart + 15 + 10, yStart - 15)
|
||||
|
||||
var p1 = new Point3d(xStart, yStart, 0);
|
||||
var p2 = new Point3d(xStart + 15, yStart - 15, 0);
|
||||
var p3 = new Point3d(p2.X + 10, p2.Y, 0); // 这里的p3是直线的终点,圆接在这里
|
||||
|
||||
// 绘制引线
|
||||
var poly = new Polyline();
|
||||
poly.AddVertexAt(0, new Point2d(p1.X, p1.Y), 0, 0, 0);
|
||||
poly.AddVertexAt(1, new Point2d(p2.X, p2.Y), 0, 0, 0);
|
||||
poly.AddVertexAt(2, new Point2d(p3.X, p3.Y), 0, 0, 0);
|
||||
|
||||
ctx.Style?.Apply(poly, DrawingStyleManager.Role.Dimension); // 使用 Dimension 角色
|
||||
// 确保此时是白色(颜色7) 或 按照标注颜色(青色 or Green?) 图片看起来像青色(Cyan)或白色
|
||||
// 用户截图看起来是青色/绿色(标注层颜色). Apply logic usually handles layer/color.
|
||||
// 我们显式设为青色(4)或者跟随标注层
|
||||
poly.ColorIndex = 4;
|
||||
|
||||
ctx.Btr.AppendEntity(poly);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(poly, true);
|
||||
|
||||
// 2. 圆圈 (HB)
|
||||
// 圆心 x = p3.X + R
|
||||
double radius = 4.0;
|
||||
var center = new Point3d(p3.X + radius, p3.Y, 0);
|
||||
var circle = new Circle(center, Vector3d.ZAxis, radius);
|
||||
circle.ColorIndex = 4;
|
||||
|
||||
ctx.Btr.AppendEntity(circle);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(circle, true);
|
||||
|
||||
// 3. 文字 (HB)
|
||||
var text = new DBText();
|
||||
text.TextString = "HB";
|
||||
text.Height = 3.5;
|
||||
text.ColorIndex = 4;
|
||||
text.HorizontalMode = TextHorizontalMode.TextCenter;
|
||||
text.VerticalMode = TextVerticalMode.TextVerticalMid;
|
||||
text.AlignmentPoint = center;
|
||||
text.Position = center;
|
||||
|
||||
ctx.Btr.AppendEntity(text);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(text, true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user