feat: implement DiskRawFreeForgeDrawer for drawing disk-shaped raw free forgings with dimensions and fillets.
This commit is contained in:
parent
fe695947ca
commit
ed86f19c48
@ -102,6 +102,38 @@ namespace CadParamPluging.Cad
|
||||
ctx.Btr.AppendEntity(poly);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(poly, true);
|
||||
|
||||
// 绘制中心线 (点划线)
|
||||
const double extendLine = 5.0;
|
||||
const double frameMargin = 5.0;
|
||||
var y0 = oy - extendLine;
|
||||
var y1 = oy + H + extendLine;
|
||||
|
||||
try
|
||||
{
|
||||
var frameExtents = TemplateDrawingService.ComputeWhiteFrameExtents(ctx?.Ctx);
|
||||
if (frameExtents.HasValue)
|
||||
{
|
||||
var frame = frameExtents.Value;
|
||||
y0 = Math.Max(y0, frame.MinPoint.Y + frameMargin);
|
||||
y1 = Math.Min(y1, frame.MaxPoint.Y - frameMargin);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
if (y1 <= y0)
|
||||
{
|
||||
y0 = oy;
|
||||
y1 = oy + H;
|
||||
}
|
||||
|
||||
var centerLine = new Line(new Point3d(ctx.Center.X, y0, 0), new Point3d(ctx.Center.X, y1, 0));
|
||||
ctx.Style?.Apply(centerLine, DrawingStyleManager.Role.Centerline);
|
||||
ctx.Btr.AppendEntity(centerLine);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(centerLine, true);
|
||||
|
||||
var diaPrime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyDiameterPrime);
|
||||
var heightPrime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyHeight1Prime);
|
||||
|
||||
// 直径标注
|
||||
var diaTolPlus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyDiameterTolPlus);
|
||||
var diaTolMinus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyDiameterTolMinus);
|
||||
@ -110,6 +142,11 @@ namespace CadParamPluging.Cad
|
||||
var diaTolMinusStr = bag.GetString(FeatureDrivenDrawer.KeyDiameterTolMinus);
|
||||
|
||||
var diaDimText = BuildDimensionText($"%%c{FormatDimNumber(diameter.Value, diameterStr)}", diaTolPlus, diaTolMinus, diaTolPlusStr, diaTolMinusStr);
|
||||
if (diaPrime.HasValue && diaPrime.Value > 0)
|
||||
{
|
||||
diaDimText += $"\\X(%%c{FormatDimNumber(diaPrime.Value)})";
|
||||
}
|
||||
|
||||
// 为避免标注界线悬空,根据 r 的存在小幅调整起点
|
||||
AddLinearDim(ctx, new Point3d(ox, oy + r, 0), new Point3d(ox + diameter.Value, oy + r, 0),
|
||||
new Point3d(ctx.Center.X, oy - 20, 0), 0, diaDimText);
|
||||
@ -122,6 +159,11 @@ namespace CadParamPluging.Cad
|
||||
var htTolMinusStr = bag.GetString(FeatureDrivenDrawer.KeyHeight1TolMinus);
|
||||
|
||||
var htDimText = BuildDimensionText(FormatDimNumber(H, heightStr), htTolPlus, htTolMinus, htTolPlusStr, htTolMinusStr);
|
||||
if (heightPrime.HasValue && heightPrime.Value > 0)
|
||||
{
|
||||
htDimText += $"\\X({FormatDimNumber(heightPrime.Value)})";
|
||||
}
|
||||
|
||||
AddLinearDim(ctx, new Point3d(ox + diameter.Value - r, oy, 0), new Point3d(ox + diameter.Value - r, oy + H, 0),
|
||||
new Point3d(ox + diameter.Value + 20, ctx.Center.Y, 0), 90, htDimText);
|
||||
|
||||
@ -131,9 +173,7 @@ namespace CadParamPluging.Cad
|
||||
DrawUnspecifiedFilletNote(ctx, ox, oy + H, R, diameter.Value, unspecifiedFillet.Value);
|
||||
}
|
||||
|
||||
// 零件尺寸(如果有)
|
||||
var diaPrime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyDiameterPrime);
|
||||
var heightPrime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyHeight1Prime);
|
||||
// 零件轮廓(如果有)
|
||||
if (diaPrime.HasValue && diaPrime.Value > 0 && heightPrime.HasValue && heightPrime.Value > 0)
|
||||
{
|
||||
DrawDiskPartContour(ctx, ox, oy, diameter.Value, H, diaPrime.Value, heightPrime.Value);
|
||||
@ -156,16 +196,6 @@ namespace CadParamPluging.Cad
|
||||
|
||||
ctx.Btr.AppendEntity(polyPart);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(polyPart, true);
|
||||
|
||||
// 零件直径标注
|
||||
AddLinearDim(ctx, new Point3d(ox + offsetX, oy + offsetY, 0),
|
||||
new Point3d(ox + offsetX + partDia, oy + offsetY, 0),
|
||||
new Point3d(ox + offsetX + partDia / 2, oy + offsetY - 10, 0), 0, $"%%c{partDia}");
|
||||
|
||||
// 零件高度标注
|
||||
AddLinearDim(ctx, new Point3d(ox + offsetX + partDia, oy + offsetY, 0),
|
||||
new Point3d(ox + offsetX + partDia, oy + offsetY + partH, 0),
|
||||
new Point3d(ox + offsetX + partDia + 10, oy + offsetY + partH / 2, 0), 90, $"{partH}");
|
||||
}
|
||||
|
||||
private static void DrawUnspecifiedFilletNote(FeatureDrivenDrawer.DrawingContext ctx, double ox, double oy, double R, double height, double filletR)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user