34 lines
1.3 KiB
C#
34 lines
1.3 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 = "圆轴"
|
|
public static readonly string Key = TemplateKeyBuilder.Build("毛料态", "自由锻", "轴杆", "圆轴");
|
|
|
|
public string TemplateKey => Key;
|
|
|
|
public FeatureDrivenDrawer.ExpectedDrawingSize CalculateExpectedSize(ParamBag bag, TemplateParams templateParams)
|
|
{
|
|
var diameter = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyDiameter) ?? 0;
|
|
var length = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyLength) ?? 0;
|
|
|
|
var extraMargin = 40;
|
|
return new FeatureDrivenDrawer.ExpectedDrawingSize
|
|
{
|
|
Width = length + extraMargin * 2,
|
|
Height = diameter + extraMargin * 2
|
|
};
|
|
}
|
|
|
|
public void Draw(CadContext ctx, ParamBag bag, TemplateParams templateParams, Point3d center, double scaleFactor)
|
|
{
|
|
ShaftRawFreeForgeRoundShaftDrawer.Draw(ctx, bag, center, scaleFactor);
|
|
}
|
|
}
|
|
}
|