毛料态、自由锻、环形、非中心冲孔模板图纸生成调整完成
This commit is contained in:
parent
1ab7899cdf
commit
cbc34e2d9c
@ -119,19 +119,76 @@ namespace CadParamPluging.Cad.Drawers
|
||||
double ox = ctx.Center.X - W / 2.0;
|
||||
double oy = ctx.Center.Y - H / 2.0;
|
||||
|
||||
// 车加工态 parameters
|
||||
double? outerDiaPrime = null;
|
||||
double? innerDiaPrime = null;
|
||||
double? heightPrime = null;
|
||||
// Unconditionally retrieve variables for Part Contour (Prime parameters)
|
||||
// This ensures the yellow part contour is drawn if parameters exist, regardless of status.
|
||||
var outerDiaPrime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyOuterDiameter1Prime);
|
||||
var innerDiaPrime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyInnerDiameter2Prime);
|
||||
var heightPrime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyHeight1Prime);
|
||||
|
||||
/*
|
||||
if (ctx.IsMachined)
|
||||
{
|
||||
outerDiaPrime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyOuterDiameter1Prime);
|
||||
innerDiaPrime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyInnerDiameter2Prime);
|
||||
heightPrime = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyHeight1Prime);
|
||||
// Previously, these were only loaded if IsMachined was true.
|
||||
}
|
||||
*/
|
||||
|
||||
// 1. Forging Outer Contour
|
||||
FeatureDrivenDrawer.DrawForgingOuterContour(ctx, ox, oy, W, H);
|
||||
// 1. Forging Section Contours (Replacing generic outer contour)
|
||||
var sectionFilletR = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyUnspecifiedFilletRadiusMax) ?? 0;
|
||||
|
||||
// Pre-calculate inner hole parameters
|
||||
var innerDia = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyInnerDiameter2);
|
||||
var innerTolPlus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyInnerDiameter2TolPlus);
|
||||
var innerTolMinus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyInnerDiameter2TolMinus);
|
||||
double? xInnerLeft = null;
|
||||
double? xInnerRight = null;
|
||||
|
||||
// Full Section: Draw Contour with Fillet for both sides
|
||||
if (innerDia.HasValue && innerDia.Value > 0 && innerDia.Value < W)
|
||||
{
|
||||
// Do NOT draw sharp ForgingOuterContour, as it conflicts with rounded fillets.
|
||||
// FeatureDrivenDrawer.DrawForgingOuterContour(ctx, ox, oy, W, H);
|
||||
|
||||
double xInnerLeftVal = ctx.Center.X - innerDia.Value / 2.0;
|
||||
double xInnerRightVal = ctx.Center.X + innerDia.Value / 2.0;
|
||||
|
||||
// Draw Left Section Contour
|
||||
FeatureDrivenDrawer.DrawRingSectionContourWithFillet(ctx, ox, xInnerLeftVal, oy, H, sectionFilletR);
|
||||
// Draw Left Hatch (with fillet)
|
||||
FeatureDrivenDrawer.DrawRingSectionHatchWithFillet(ctx, ox, xInnerLeftVal, oy, H, sectionFilletR);
|
||||
|
||||
// Draw Right Section Contour
|
||||
FeatureDrivenDrawer.DrawRingSectionContourWithFillet(ctx, xInnerRightVal, ox + W, oy, H, sectionFilletR);
|
||||
// Draw Right Hatch (with fillet)
|
||||
FeatureDrivenDrawer.DrawRingSectionHatchWithFillet(ctx, xInnerRightVal, ox + W, oy, H, sectionFilletR);
|
||||
|
||||
// Draw Connecting Lines (Hole Back View) - Top and Bottom
|
||||
// Extend into the fillet radius to connect with the flat top/bottom of the sections
|
||||
|
||||
double lineStart = xInnerLeftVal - sectionFilletR;
|
||||
double lineEnd = xInnerRightVal + sectionFilletR;
|
||||
|
||||
var connectingLineTop = new Line(new Point3d(lineStart, oy + H, 0), new Point3d(lineEnd, oy + H, 0));
|
||||
connectingLineTop.ColorIndex = 7; // White
|
||||
ctx.Btr.AppendEntity(connectingLineTop);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(connectingLineTop, true);
|
||||
|
||||
var connectingLineBottom = new Line(new Point3d(lineStart, oy, 0), new Point3d(lineEnd, oy, 0));
|
||||
connectingLineBottom.ColorIndex = 7; // White
|
||||
ctx.Btr.AppendEntity(connectingLineBottom);
|
||||
ctx.Tr.AddNewlyCreatedDBObject(connectingLineBottom, true);
|
||||
|
||||
// Adjust Inner Dim to attach to vertical wall (offset by r)
|
||||
FeatureDrivenDrawer.DrawInnerDiameterDimension(ctx, xInnerLeftVal, xInnerRightVal, oy + sectionFilletR, innerDia.Value, innerTolPlus, innerTolMinus, innerDiaPrime);
|
||||
|
||||
// Store values for later use in dimensions/notes
|
||||
xInnerRight = xInnerRightVal;
|
||||
xInnerLeft = xInnerLeftVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback if no inner hole (should not happen for a ring but safe to keep)
|
||||
// FeatureDrivenDrawer.DrawForgingOuterContour(ctx, ox, oy, W, H);
|
||||
}
|
||||
|
||||
// 1.1 Centerline
|
||||
FeatureDrivenDrawer.DrawRingCenterline(ctx, ox, oy, W, H);
|
||||
@ -139,44 +196,53 @@ namespace CadParamPluging.Cad.Drawers
|
||||
// 2. Outer Diameter Dimension
|
||||
var outerTolPlus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyOuterDiameter1TolPlus);
|
||||
var outerTolMinus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyOuterDiameter1TolMinus);
|
||||
FeatureDrivenDrawer.DrawOuterDiameterDimension(ctx, ox, oy, W, W, outerTolPlus, outerTolMinus, outerDiaPrime);
|
||||
// Adjust Y by fillet radius so dimension lines attach to the vertical wall, not the rounded corner gap
|
||||
FeatureDrivenDrawer.DrawOuterDiameterDimension(ctx, ox, oy + sectionFilletR, W, W, outerTolPlus, outerTolMinus, outerDiaPrime);
|
||||
|
||||
// 3. Inner Hole
|
||||
var innerDia = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyInnerDiameter2);
|
||||
double? xInnerLeft = null;
|
||||
double? xInnerRight = null;
|
||||
if (innerDia.HasValue && innerDia.Value > 0 && innerDia.Value < W)
|
||||
{
|
||||
xInnerLeft = ctx.Center.X - innerDia.Value / 2.0;
|
||||
xInnerRight = ctx.Center.X + innerDia.Value / 2.0;
|
||||
|
||||
var innerTolPlus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyInnerDiameter2TolPlus);
|
||||
var innerTolMinus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyInnerDiameter2TolMinus);
|
||||
|
||||
FeatureDrivenDrawer.DrawInnerHole(ctx, xInnerLeft.Value, xInnerRight.Value, oy, H);
|
||||
FeatureDrivenDrawer.DrawInnerDiameterDimension(ctx, xInnerLeft.Value, xInnerRight.Value, oy, innerDia.Value, innerTolPlus, innerTolMinus, innerDiaPrime);
|
||||
|
||||
// 4. Inner Fillets - ONLY if CenterPunched (which is false here), so SKIP.
|
||||
// But wait, the template is "NonCenterPunch", so we definitely SKIP DrawInnerFillets.
|
||||
|
||||
// 4.1 Section Hatch
|
||||
FeatureDrivenDrawer.DrawRingSectionHatch(ctx, xInnerRight.Value, ox + W, oy, H);
|
||||
|
||||
// Section Boundary Bold
|
||||
FeatureDrivenDrawer.DrawSectionInnerBoundaryBold(ctx, xInnerRight.Value, oy, H);
|
||||
}
|
||||
// 3. Inner Hole Block (REMOVED - now handled above)
|
||||
/*
|
||||
// declared and handled above
|
||||
*/
|
||||
|
||||
// 5. Height Dimension
|
||||
var heightVal = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyHeight1) ?? H;
|
||||
var heightStr = bag.GetString(FeatureDrivenDrawer.KeyHeight1);
|
||||
var heightTolPlus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyHeight1TolPlus);
|
||||
var heightTolMinus = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyHeight1TolMinus);
|
||||
FeatureDrivenDrawer.DrawHeightDimension(ctx, ox, oy, W, H, heightTolPlus, heightTolMinus, heightPrime);
|
||||
var heightTolPlusStr = bag.GetString(FeatureDrivenDrawer.KeyHeight1TolPlus);
|
||||
var heightTolMinusStr = bag.GetString(FeatureDrivenDrawer.KeyHeight1TolMinus);
|
||||
|
||||
// 6. Unspecified Fillet Note
|
||||
var heightBaseText = FeatureDrivenDrawer.BuildDimensionText(FeatureDrivenDrawer.FormatDimNumber(heightVal, heightStr), heightTolPlus, heightTolMinus, heightTolPlusStr, heightTolMinusStr);
|
||||
var heightDimText = heightPrime.HasValue && heightPrime.Value > 0
|
||||
? heightBaseText + $"\n({FeatureDrivenDrawer.FormatDimNumber(heightPrime.Value)})" // Use newline for alternate unit style if needed, or stick to \\X
|
||||
: heightBaseText;
|
||||
|
||||
// Fix: Use \\X for secondary text if using standard style
|
||||
if (heightPrime.HasValue && heightPrime.Value > 0)
|
||||
{
|
||||
heightDimText = heightBaseText + $"\\X({FeatureDrivenDrawer.FormatDimNumber(heightPrime.Value)})";
|
||||
}
|
||||
|
||||
// Custom Height Dimension Logic to ensure "Closed" look with fillets
|
||||
// Move X definition points inward by fillet radius so extension lines start from the flat face
|
||||
double dimX = ox + W - sectionFilletR;
|
||||
|
||||
FeatureDrivenDrawer.AddLinearDim(
|
||||
ctx,
|
||||
new Point3d(dimX, oy, 0),
|
||||
new Point3d(dimX, oy + H, 0),
|
||||
new Point3d(ox + W + 25, oy + H / 2, 0),
|
||||
90,
|
||||
heightDimText);
|
||||
|
||||
// 6. Unspecified Fillet Note - User requested to remove this
|
||||
/*
|
||||
var unspecifiedFillet = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyUnspecifiedFilletRadiusMax);
|
||||
if (unspecifiedFillet.HasValue && unspecifiedFillet.Value > 0)
|
||||
{
|
||||
FeatureDrivenDrawer.DrawUnspecifiedFilletNote(ctx, ox, oy, H, W, unspecifiedFillet.Value);
|
||||
}
|
||||
*/
|
||||
|
||||
// 7. Min Wall Thickness
|
||||
var minWallThickness = bag.GetDoubleOrNull(FeatureDrivenDrawer.KeyMinWallThickness);
|
||||
@ -185,8 +251,9 @@ namespace CadParamPluging.Cad.Drawers
|
||||
FeatureDrivenDrawer.DrawMinWallThicknessNote(ctx, xInnerRight.Value, ox + W, oy, minWallThickness.Value);
|
||||
}
|
||||
|
||||
// 8. Part Contour (Machined)
|
||||
if (ctx.IsMachined && outerDiaPrime.HasValue && outerDiaPrime.Value > 0 && heightPrime.HasValue && heightPrime.Value > 0)
|
||||
// 8. Part Contour (Machined Parameters present)
|
||||
// Even if status is "Raw", if parameters exist, we draw the part contour as requested.
|
||||
if (outerDiaPrime.HasValue && outerDiaPrime.Value > 0 && heightPrime.HasValue && heightPrime.Value > 0)
|
||||
{
|
||||
FeatureDrivenDrawer.DrawPartContour(ctx, ctx.Center, outerDiaPrime.Value, innerDiaPrime, heightPrime.Value);
|
||||
}
|
||||
|
||||
@ -1658,7 +1658,7 @@ namespace CadParamPluging.Cad
|
||||
}
|
||||
}
|
||||
|
||||
private static string FormatDimNumber(double value, string rawInput = null)
|
||||
public static string FormatDimNumber(double value, string rawInput = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -2203,7 +2203,7 @@ namespace CadParamPluging.Cad
|
||||
|
||||
#region 辅助方法
|
||||
|
||||
private static string BuildDimensionText(string baseText, double? tolPlus, double? tolMinus, string tolPlusStr = null, string tolMinusStr = null)
|
||||
public static string BuildDimensionText(string baseText, double? tolPlus, double? tolMinus, string tolPlusStr = null, string tolMinusStr = null)
|
||||
{
|
||||
if (!tolPlus.HasValue && !tolMinus.HasValue)
|
||||
{
|
||||
@ -2333,7 +2333,7 @@ namespace CadParamPluging.Cad
|
||||
catch { }
|
||||
}
|
||||
|
||||
private static void AddLinearDim(DrawingContext ctx, Point3d pt1, Point3d pt2, Point3d dimLinePt,
|
||||
public static void AddLinearDim(DrawingContext ctx, Point3d pt1, Point3d pt2, Point3d dimLinePt,
|
||||
double rotationDeg, string textOverride, Action<Dimension, DrawingContext> customizer = null)
|
||||
{
|
||||
try
|
||||
|
||||
Loading…
Reference in New Issue
Block a user