// Method for polyline extension private bool ExtendPolyLine(ICurve lineCurve, ICurve boundary, bool nearStart) { LinearPath line = secondSelectedEntity as LinearPath; Point3D[] tempVertices = line.Vertices; // create temp line with proper direction Line tempLine = new Line(line.StartPoint, line.StartPoint); Vector3D direction = new Vector3D(line.Vertices[1], line.StartPoint); if (!nearStart) { tempLine = new Line(line.EndPoint, line.EndPoint); direction = new Vector3D(line.Vertices[line.Vertices.Length - 2], line.EndPoint); } direction.Normalize(); tempLine.EndPoint = tempLine.EndPoint + direction * extensionLength; #if NURBS Point3D[] intersetionPoints = Curve.Intersection(boundary, tempLine); if (intersetionPoints.Length == 0) { intersetionPoints = Curve.Intersection(GetExtendedBoundary(boundary), tempLine); } if (intersetionPoints.Length > 0) { if (nearStart) { tempVertices[0] = GetClosestPoint(line.StartPoint, intersetionPoints); } else { tempVertices[tempVertices.Length - 1] = GetClosestPoint(line.EndPoint, intersetionPoints); } line.Vertices = tempVertices; AddAndRefresh((Entity)line.Clone(), ((Entity)lineCurve).LayerName); return(true); } #endif return(false); }