40 lines
1.5 KiB
C#
40 lines
1.5 KiB
C#
using CadParamPluging.Common;
|
|
using CadParamPluging.Domain.Models;
|
|
|
|
namespace CadParamPluging.Cad
|
|
{
|
|
public sealed class DiskRawFreeForgeGenerator : TemplateDrawingGeneratorBase
|
|
{
|
|
public static readonly string Key = TemplateKeyBuilder.Build("毛料态", "自由锻", "饼盘", "");
|
|
|
|
public override string TemplateKey => Key;
|
|
|
|
public override FeatureDrivenDrawer.ExpectedDrawingSize CalculateExpectedSize(ParamBag bag, TemplateParams templateParams)
|
|
{
|
|
var diameter = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyDiameter) ?? 0;
|
|
var height = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyHeight1) ?? 0;
|
|
|
|
// Visual size estimation
|
|
// Disk drawing is roughly:
|
|
// Top view (Circle) + Side view (Rectangle)?
|
|
// Wait, FeatureDrivenDrawer.DrawDiskFeatures only draws the Side View (Rectangle).
|
|
// "这里绘制侧视图" (Lines 1762-1763 of FeatureDrivenDrawer.cs)
|
|
// So width = Diameter, Height = Height.
|
|
|
|
// Margins
|
|
var extraMargin = 60.0;
|
|
|
|
return new FeatureDrivenDrawer.ExpectedDrawingSize
|
|
{
|
|
Width = diameter + extraMargin * 2,
|
|
Height = height + extraMargin * 2
|
|
};
|
|
}
|
|
|
|
public override void Draw(CadContext ctx, ParamBag bag, TemplateParams templateParams, Autodesk.AutoCAD.Geometry.Point3d center, double scaleFactor)
|
|
{
|
|
DiskRawFreeForgeDrawer.Draw(ctx, bag, center, scaleFactor);
|
|
}
|
|
}
|
|
}
|