feat: 新增环形自由锻中心冲孔CAD绘图器。
This commit is contained in:
parent
004a6a6e28
commit
11dd4b0568
@ -145,11 +145,25 @@ namespace CadParamPluging.Cad.Drawers
|
||||
// Right Side of Left Section is Inner -> innerFilletR
|
||||
DrawSectionWithAsymmetricFillets(ctx, ox, xInnerLeftVal, oy, H, outerFilletR, innerFilletR);
|
||||
|
||||
if (innerFilletR > 0)
|
||||
{
|
||||
double cxLeft = xInnerLeftVal - innerFilletR;
|
||||
double cyLeft = oy + H - innerFilletR;
|
||||
DrawInnerRadiusLeader(ctx, cxLeft, cyLeft, innerFilletR, true);
|
||||
}
|
||||
|
||||
// Draw Right Section Contour (Inner Edge: xInnerRightVal, Outer Edge: ox + W)
|
||||
// Left Side of Right Section is Inner -> innerFilletR
|
||||
// Right Side of Right Section is Outer -> outerFilletR
|
||||
DrawSectionWithAsymmetricFillets(ctx, xInnerRightVal, ox + W, oy, H, innerFilletR, outerFilletR);
|
||||
|
||||
if (innerFilletR > 0)
|
||||
{
|
||||
double cxRight = xInnerRightVal + innerFilletR;
|
||||
double cyRight = oy + H - innerFilletR;
|
||||
DrawInnerRadiusLeader(ctx, cxRight, cyRight, innerFilletR, false);
|
||||
}
|
||||
|
||||
// Draw Connecting Lines (Hole Back View) - Top and Bottom
|
||||
// Extend into the inner fillet radius
|
||||
|
||||
@ -357,6 +371,77 @@ namespace CadParamPluging.Cad.Drawers
|
||||
CreateHatchForPolyline(ctx, poly);
|
||||
}
|
||||
|
||||
private static void DrawInnerRadiusLeader(FeatureDrivenDrawer.DrawingContext ctx, double cx, double cy, double r, bool isLeftSection)
|
||||
{
|
||||
try
|
||||
{
|
||||
var val = ctx.OriginalBag?.GetDoubleOrNull(FeatureDrivenDrawer.KeyInnerRadiusMax);
|
||||
if (!val.HasValue || val.Value <= 0) return;
|
||||
|
||||
double angleDeg = isLeftSection ? 45 : 135;
|
||||
double angleRad = angleDeg * Math.PI / 180.0;
|
||||
|
||||
// 起点(指向圆弧:圆心延角度方向在圆弧上的点)
|
||||
double px = cx + r * Math.Cos(angleRad);
|
||||
double py = cy + r * Math.Sin(angleRad);
|
||||
|
||||
// 终点(沿着同一角度延伸出去一定长度作为引出线,比如长 25)
|
||||
double ex = px + 25 * Math.Cos(angleRad);
|
||||
double ey = py + 25 * Math.Sin(angleRad);
|
||||
|
||||
var leader = new Leader();
|
||||
leader.SetDatabaseDefaults();
|
||||
leader.AppendVertex(new Point3d(px, py, 0));
|
||||
leader.AppendVertex(new Point3d(ex, ey, 0));
|
||||
leader.HasArrowHead = true;
|
||||
ctx.Style?.Apply(leader, DrawingStyleManager.Role.Dimension);
|
||||
leader.ColorIndex = 4; // Cyan
|
||||
|
||||
ctx.Btr.AppendEntity(leader);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(leader, true);
|
||||
|
||||
// 文字(与线对齐同角度)
|
||||
var textStr = $"R\\U+2264{val.Value}";
|
||||
var text = new DBText();
|
||||
text.TextString = textStr;
|
||||
text.Height = 3.5;
|
||||
text.ColorIndex = 4;
|
||||
|
||||
// 倾斜文字角度
|
||||
double textRotation = angleRad;
|
||||
if (!isLeftSection)
|
||||
{
|
||||
// For the right side (135 degrees), we want the text to read left-to-right
|
||||
// So we subtract 180 degrees (PI) from the angle, which makes it -45 degrees
|
||||
textRotation = angleRad - Math.PI;
|
||||
}
|
||||
text.Rotation = textRotation;
|
||||
|
||||
// 对齐设置
|
||||
text.HorizontalMode = TextHorizontalMode.TextCenter;
|
||||
text.VerticalMode = TextVerticalMode.TextBottom;
|
||||
|
||||
// 计算文字放置点,紧贴在结束点上方
|
||||
// 为了让文字准确地骑在线上,基于文字的旋转角度计算偏移
|
||||
double offsetX = 2.0 * Math.Cos(textRotation + Math.PI / 2);
|
||||
double offsetY = 2.0 * Math.Sin(textRotation + Math.PI / 2);
|
||||
|
||||
var tp = new Point3d(ex + offsetX, ey + offsetY, 0);
|
||||
text.AlignmentPoint = tp;
|
||||
text.Position = tp;
|
||||
|
||||
ctx.Style?.Apply(text, DrawingStyleManager.Role.Text);
|
||||
text.ColorIndex = 4;
|
||||
|
||||
ctx.Btr.AppendEntity(text);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(text, true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateHatchForPolyline(FeatureDrivenDrawer.DrawingContext ctx, Polyline boundary)
|
||||
{
|
||||
try
|
||||
|
||||
Loading…
Reference in New Issue
Block a user