feat: add RingMachinedRollingDrawer for independent ring rolling drawing logic
This commit is contained in:
parent
34d125f397
commit
3e5ea615b1
@ -266,24 +266,12 @@ namespace CadParamPluging.Cad
|
||||
DrawPartContourHalf(ctx, ox, oy, H, scaledOuterDiaPrime, scaledInnerDiaPrime, scaledHeightPrime);
|
||||
}
|
||||
|
||||
// === 特征10: 标刻内容 HB5936-13 ===
|
||||
// === 特征10: 轧制+车加工 特殊引线标注 (HB5936-13) ===
|
||||
// 需满足: 车加工 + 轧制(本方法即为轧制) + 有内孔
|
||||
if (ctx.IsMachined && innerDia.HasValue && innerDia.Value > 0)
|
||||
{
|
||||
var markingText = bag.GetString(KeyMarkingContent);
|
||||
// 哪怕没有标刻内容,在"车加工-轧制-环形"中也常常需要显示默认标准
|
||||
if (!string.IsNullOrWhiteSpace(markingText) || applyUnspecifiedFillet)
|
||||
{
|
||||
// 修改:接触线应该是左侧边(即内孔边界的垂直线)
|
||||
var xTarget = ox + visualInnerR;
|
||||
var yTargetTop = oy + H;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(markingText))
|
||||
{
|
||||
markingText = "HB5936-13";
|
||||
}
|
||||
|
||||
DrawMarkingLeaderToSide(ctx, xTarget, yTargetTop, markingText);
|
||||
}
|
||||
// 指向锻件内孔右上角
|
||||
DrawSpecialInnerHoleLeader(ctx, ox, oy, H, visualInnerR);
|
||||
}
|
||||
|
||||
// === 特征9: 硬度符号 (HB) ===
|
||||
@ -381,23 +369,24 @@ namespace CadParamPluging.Cad
|
||||
catch { }
|
||||
}
|
||||
|
||||
private static void DrawMarkingLeaderToSide(FeatureDrivenDrawer.DrawingContext ctx, double xTarget, double yTargetTop, string markingText)
|
||||
private static void DrawSpecialInnerHoleLeader(FeatureDrivenDrawer.DrawingContext ctx, double ox, double oy, double height, double visualInnerR)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 箭头起点:内孔左侧边的顶部向下5mm处 (接触线是左侧边)
|
||||
var p1 = new Point3d(xTarget, yTargetTop - 5.0, 0);
|
||||
// 内孔右侧X坐标 (锻件)
|
||||
double xInner = ox + visualInnerR;
|
||||
|
||||
// 转折点:向左上 (偏移角度随意,例如左10,上10)
|
||||
var p2 = new Point3d(xTarget - 10, yTargetTop + 5, 0);
|
||||
// 目标Y坐标:锻件内孔右上角向下偏移一点 (引线不应直指角点,而是指在直线上)
|
||||
double yTarget = oy + height - 5.0;
|
||||
|
||||
// 终点:水平向左
|
||||
// 长度根据文字适配
|
||||
double textLen = (string.IsNullOrEmpty(markingText) ? 10 : markingText.Length) * 2.5;
|
||||
if (textLen < 20) textLen = 20;
|
||||
|
||||
var p3 = new Point3d(p2.X - textLen, p2.Y, 0);
|
||||
// 箭头点 (指向内孔竖线)
|
||||
var p1 = new Point3d(xInner, yTarget, 0);
|
||||
// 转折点 (向左上)
|
||||
var p2 = new Point3d(xInner - 12, yTarget + 12, 0);
|
||||
// 终点 (水平向左, 长度约35适配文字宽度 "HB5936-13")
|
||||
var p3 = new Point3d(p2.X - 35, p2.Y, 0);
|
||||
|
||||
// 使用 Leader 实体绘制带箭头的引线
|
||||
var leader = new Leader();
|
||||
leader.SetDatabaseDefaults();
|
||||
leader.AppendVertex(p1);
|
||||
@ -405,14 +394,20 @@ namespace CadParamPluging.Cad
|
||||
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 = markingText;
|
||||
text.TextString = "HB5936-13";
|
||||
text.Height = 3.5;
|
||||
text.ColorIndex = 7;
|
||||
text.ColorIndex = 7; // 白色
|
||||
text.Layer = "0";
|
||||
|
||||
// 文字位置:左对齐,基点为 p3 (线段最左端)
|
||||
// 位于线段上方 (VerticalMode = TextBottom)
|
||||
text.HorizontalMode = TextHorizontalMode.TextLeft;
|
||||
text.VerticalMode = TextVerticalMode.TextBottom;
|
||||
text.AlignmentPoint = new Point3d(p3.X, p3.Y + 1.0, 0);
|
||||
@ -421,7 +416,10 @@ namespace CadParamPluging.Cad
|
||||
ctx.Btr.AppendEntity(text);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(text, true);
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
#region 私有辅助绘图方法
|
||||
|
||||
Loading…
Reference in New Issue
Block a user