70002448 Split Polyline with more than one points

Article 70002448
Type Wish
Product Engine
Version 1004
Date Added 11/30/2023 12:00:00 AM
Fixed 10.1005.0.4 (11/30/2023 12:00:00 AM)
Submitted by Daniele Scarabottolo

Summary

Split Polyline with more than one points

Solution

In version 1005.0.4 a new method SplitPolylineWithPoints of vdPolyline was added



Syntax:
public vdArray SplitPolylineWithPoints(gPoints pts)
Desctiption:
Culculate the segments that this polyline object is splitting by passed points
Parameters:
pts : Array of gPoint on the object boundary
Returns:
An array of Vertexes represent the segments that the object is splitting to.Null if the object is not splitting.
NOTE:only if SPlineFlag is VdConstSplineFlag.SFlagSTANDARD supports this method


Example:

                //split selected curve with one or more user select points
                //selected curve can be vdPolyline, vdLine vdArc vdCircle or vdRect
                vdFigure fig;
                gPoint pt;
                doc.Prompt("select curve to split");
                doc.ActionUtility.getUserEntity(out fig, out pt);
                doc.Prompt(null);
                vdPolyline curve = fig as vdPolyline;
                if (curve == null)
                {
                    if (fig is IvdAsPolyline)
                    {
                        curve = ((IvdAsPolyline)fig).AsPolyline();
                    }
                    if (curve == null) return;
                }
                gPoints pts = new gPoints();
                do
                {
                    doc.Prompt("select splitpoint ");
                    gPoint p1 = doc.ActionUtility.getUserPoint() as gPoint;
                    doc.Prompt(null);
                    if (p1 == null) break;
                    pts.Add(p1);

                } while (true);
                vdArray vertsarr = curve.SplitPolylineWithPoints(pts);
                if (vertsarr == null) return;
                short i = 0;
                foreach (Vertexes item in vertsarr)
                {
                    vdPolyline plnew = curve.Clone(null) as vdPolyline;
                    plnew.VertexList = item;
                    plnew.Flag = VdConstPlineFlag.PlFlagOPEN;
                    plnew.PenColor = new vdColor(vdColor.ColorType.ByColorIndex) { ColorIndex = i++ };
                    doc.Model.Entities.AddItem(plnew);
                }
                doc.Redraw(true);

Send comments on this topic.