40 lines
1.5 KiB
C#
40 lines
1.5 KiB
C#
using CadParamPluging.Common;
|
|
using CadParamPluging.Domain.Models;
|
|
using Autodesk.AutoCAD.Geometry;
|
|
|
|
namespace CadParamPluging.Cad
|
|
{
|
|
public sealed class ShaftRawFreeForgeRoundShaftGenerator : ITemplateDrawingGenerator
|
|
{
|
|
// 对应 TemplateSchemaDefaults.cs 中的定义
|
|
// ProjectType = "毛料态", DrawingType = "自由锻", SheetSize = "轴杆", Scale = "圆轴"
|
|
// 这里的 Scale 对应 SpecialCondition
|
|
public static readonly string Key = TemplateKeyBuilder.Build("毛料态", "自由锻", "轴杆", "圆轴");
|
|
|
|
public string TemplateKey => Key;
|
|
|
|
public FeatureDrivenDrawer.ExpectedDrawingSize CalculateExpectedSize(ParamBag bag, TemplateParams templateParams)
|
|
{
|
|
var d = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyDiameter) ?? 0;
|
|
var l = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyLength) ?? 0;
|
|
|
|
// 根据用户要求:直径是图纸宽度,长度是图纸高度
|
|
double activeWidth = d;
|
|
double activeHeight = l;
|
|
|
|
var extraMargin = 40;
|
|
|
|
return new FeatureDrivenDrawer.ExpectedDrawingSize
|
|
{
|
|
Width = activeWidth + extraMargin * 2,
|
|
Height = activeHeight + extraMargin * 2
|
|
};
|
|
}
|
|
|
|
public void Draw(CadContext ctx, ParamBag bag, TemplateParams templateParams, Point3d center, double scaleFactor)
|
|
{
|
|
ShaftRawFreeForgeRoundShaftDrawer.Draw(ctx, bag, center, scaleFactor);
|
|
}
|
|
}
|
|
}
|