/// <summary> /// 绘制直线 /// </summary> /// <param name="startPoint3d">指定起点</param> /// <returns></returns> public static (PromptResult result, Line line) DrawLine(Point3d startPoint3d) { var ed = DataBaseTools.DocumentEditor(); var lineJig = new LineJig(startPoint3d); //lineJig.Line.LineWeight = LineWeight.LineWeight200; //lineJig.Line.Color = Color.FromColor(); var res = ed.Drag(lineJig); Line line = null; if (res.Status == PromptStatus.OK) { lineJig.Line.AddToModelSpace(DataBaseTools.DocumentDatabase()); line = lineJig.Line; } return(res, line); }
/// <summary> /// 绘制直线 /// </summary> /// <returns></returns> public static (PromptResult result, Line line) DrawLine() { var ed = DataBaseTools.DocumentEditor(); var lineJig = new LineJig(); var res = ed.Drag(lineJig); Line line = null; if (res.Status == PromptStatus.OK) { lineJig.SetCounter(1); res = ed.Drag(lineJig); if (res.Status == PromptStatus.OK) { lineJig.Line.AddToModelSpace(DataBaseTools.DocumentDatabase()); line = lineJig.Line; } } return(res, line); }
/// <summary> /// 连续绘制直线 /// </summary> /// <returns></returns> public static IEnumerable <Line> DrawLineContinue() { var lines = new List <Line>(); var res = DrawLine(); if (res.result.Status != PromptStatus.OK) { return(lines); } lines.Add(res.line); var nextStartPoint = res.line.EndPoint; while (true) { res = DrawLine(nextStartPoint); if (res.result.Status == PromptStatus.OK) { lines.Add(res.line); nextStartPoint = res.line.EndPoint; } else if (res.result.Status == PromptStatus.Keyword && res.result.StringResult == "U") { var last = lines.LastOrDefault(); if (last != null) { lines.Remove(last); DataBaseTools.Remove(last); nextStartPoint = last.StartPoint; } else { break; } } else { break; } } return(lines); }