private Polyline3d GetRail(Point3d startPoint, Curve curve1, Curve curve2) { if (!curve1.StartPoint.IsEqualTo(startPoint)) { curve1.ReverseCurve(); } Polyline3d polyline = null; if (curve1 is Line line) { polyline = line.ToPolyline3d(); } else if (curve1 is Spline spline) { polyline = (Polyline3d)spline.ToPolyline(); } ObjectId objectId = ObjectId.Null; App.LockAndExecute(() => objectId = polyline.AddToCurrentSpace()); var ep = polyline.EndPoint; if (!curve2.StartPoint.IsEqualTo(ep)) { curve2.ReverseCurve(); } App.LockAndExecute(() => { objectId.QOpenForWrite <Polyline3d>(pl => { if (curve2 is Line line2) { var pt = line2.NextPoint(ep); pl.AppendVertex(new PolylineVertex3d(pt)); } else if (curve2 is Spline spline2) { foreach (var vertex in (Polyline3d)spline2.ToPolyline()) { if (!((PolylineVertex3d)vertex).Position.IsEqualTo(ep)) { var v = new PolylineVertex3d(((PolylineVertex3d)vertex).Position); pl.AppendVertex(v); } } } }); }); return(objectId.QOpenForRead <Polyline3d>()); }