CadParamPluging/Cad/Drawers/BlockRawFreeForgeNoRoundHeadGenerator.cs

39 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using CadParamPluging.Common;
using CadParamPluging.Domain.Models;
namespace CadParamPluging.Cad
{
public sealed class BlockRawFreeForgeNoRoundHeadGenerator : ITemplateDrawingGenerator
{
public static readonly string Key = TemplateKeyBuilder.Build("毛料态", "自由锻", "方体", "无圆头");
public string TemplateKey => Key;
public FeatureDrivenDrawer.ExpectedDrawingSize CalculateExpectedSize(ParamBag bag, TemplateParams templateParams)
{
// 复用环形逻辑的尺寸计算,因为接下来的绘图逻辑是完全复制环形的
// 映射参数BoxSize1 -> OuterDiameter1, BoxSize2 -> Height1
var width = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyBoxSize1) ?? 0;
var height = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyBoxSize2) ?? 0;
// 模拟 Machined + Rolling 的示意图模式计算
// 假设 Height * 3.0 作为视觉宽度
double activeWidth = height * 3.0;
double activeHeight = height;
var extraMargin = 60.0;
return new FeatureDrivenDrawer.ExpectedDrawingSize
{
Width = activeWidth + extraMargin * 2,
Height = activeHeight + extraMargin * 2
};
}
public void Draw(CadContext ctx, ParamBag bag, TemplateParams templateParams, Autodesk.AutoCAD.Geometry.Point3d center, double scaleFactor)
{
// 调用独立的新绘制方法
BlockRawFreeForgeNoRoundHeadDrawer.Draw(ctx, bag, center, scaleFactor);
}
}
}