47 lines
1.9 KiB
C#
47 lines
1.9 KiB
C#
using CadParamPluging.Common;
|
|
using CadParamPluging.Domain.Models;
|
|
using Autodesk.AutoCAD.Geometry;
|
|
|
|
namespace CadParamPluging.Cad
|
|
{
|
|
public sealed class ShaftRawFreeForgeSquareShaftGenerator : ITemplateDrawingGenerator
|
|
{
|
|
// 对应 TemplateSchemaDefaults.cs 中的定义
|
|
// ProjectType = "毛料态", DrawingType = "自由锻", SheetSize = "轴杆", Scale = "方轴"
|
|
public static readonly string Key = TemplateKeyBuilder.Build("毛料态", "自由锻", "轴杆", "方轴");
|
|
|
|
public string TemplateKey => Key;
|
|
|
|
public FeatureDrivenDrawer.ExpectedDrawingSize CalculateExpectedSize(ParamBag bag, TemplateParams templateParams)
|
|
{
|
|
var l = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize1) ?? 0;
|
|
var w = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize2) ?? 0;
|
|
var t = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeySquareShaftSize3) ?? 0; // if side view exists
|
|
|
|
var extraMargin = 40;
|
|
double totalWidth = l + extraMargin * 2;
|
|
|
|
if (t > 0)
|
|
{
|
|
double gap = 50.0;
|
|
totalWidth = (l + gap + t) + extraMargin * 2;
|
|
}
|
|
|
|
double activeHeight = w;
|
|
|
|
return new FeatureDrivenDrawer.ExpectedDrawingSize
|
|
{
|
|
Width = totalWidth,
|
|
Height = activeHeight + extraMargin * 2
|
|
};
|
|
}
|
|
|
|
public void Draw(CadContext ctx, ParamBag bag, TemplateParams templateParams, Point3d center, double scaleFactor)
|
|
{
|
|
System.Diagnostics.Debug.WriteLine($"[SquareShaftGenerator] Draw() 被调用,准备调用 Drawer");
|
|
ShaftRawFreeForgeSquareShaftDrawer.Draw(ctx, bag, center, scaleFactor);
|
|
System.Diagnostics.Debug.WriteLine($"[SquareShaftGenerator] Drawer 调用完成");
|
|
}
|
|
}
|
|
}
|