using CadParamPluging.Common; using CadParamPluging.Domain.Models; namespace CadParamPluging.Cad { public sealed class BlockRawFreeForgeRoundHeadGenerator : TemplateDrawingGeneratorBase { public static readonly string Key = TemplateKeyBuilder.Build("毛料态", "自由锻", "方体", "有圆头"); public override string TemplateKey => Key; public override 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 的示意图模式计算 // 这里的模拟逻辑是直接复制 DrawRingFeaturesHalfCore 中的视觉比例逻辑 // 假设 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 override void Draw(CadContext ctx, ParamBag bag, TemplateParams templateParams, Autodesk.AutoCAD.Geometry.Point3d center, double scaleFactor) { // 调用独立的新绘制方法 BlockRawFreeForgeRoundHeadDrawer.Draw(ctx, bag, center, scaleFactor); } } }