diff --git a/Cad/FeatureDrivenDrawer.cs b/Cad/FeatureDrivenDrawer.cs index 6b7cd42..7bfbb07 100644 --- a/Cad/FeatureDrivenDrawer.cs +++ b/Cad/FeatureDrivenDrawer.cs @@ -595,9 +595,34 @@ namespace CadParamPluging.Cad /// private static void DrawRingSymmetryAxis(DrawingContext ctx, double ox, double oy, double height) { - // 直接使用“高度标注”的两端点(锻件外轮廓的上下边),不做上下延长,避免越过图框上边界。 - var y0 = oy; - var y1 = oy + height; + const double extend = 5.0; // 中心线在轮廓上下各延长一点(与其它中心线的延长量保持一致) + const double frameMargin = 5.0; // 避免越过图框边界 + + var y0 = oy - extend; + var y1 = oy + height + extend; + + // 若能检测到白色外框,则把中心线端点夹在图框内(留出少量安全边距)。 + try + { + var frameExtents = TemplateDrawingService.ComputeWhiteFrameExtents(ctx?.Ctx); + if (frameExtents.HasValue) + { + var frame = frameExtents.Value; + y0 = Math.Max(y0, frame.MinPoint.Y + frameMargin); + y1 = Math.Min(y1, frame.MaxPoint.Y - frameMargin); + } + } + catch + { + // ignore + } + + // 极端情况下(图框过小/检测异常导致端点反转)退回到原始高度。 + if (y1 <= y0) + { + y0 = oy; + y1 = oy + height; + } var line = new Line(new Point3d(ox, y0, 0), new Point3d(ox, y1, 0)); ctx.Style?.Apply(line, DrawingStyleManager.Role.Centerline);