In this how-to guide, we see how a polyline can be tweaked by adjusting specific points. If you need to rebuild or smooth a polyline based on a general characteristic, take a look the how-to Lines and polylines.
Find a specific vertex in a polyline
We can use different methods to find specific vertices in a polyline. In this
example, we use a location based search, in which we have an existing point and
find the vertex closest to it: After deconstructing the polyline, we find the
Closest PointInputs Point (P) Point to search from Cloud (C) Cloud of points to search Outputs Closest Point (P) Point in [C] closest to [P] CP Index (i) Index of closest point Distance (D) Distance between [P] and [C](i) Inputs List (L) Base list Index (i) Item index Wrap (W) Wrap index to list bounds Outputs Item (i) Item at {i'}
Remove vertices from a polyline
To remove a vertex from a polyline, we can deconstruct it with either DiscontinuityInputs Curve (C) Curve to analyze Level (L) Level of discontinuity to test for (1=C1, 2=C2, 3=Cinfinite) Outputs Points (P) Points at discontinuities Parameters (t) Curve parameters at discontinuities Inputs Curve (C) Curve to explode Recursive (R) Recursive decomposition until all segments are atomic Outputs Segments (S) Exploded segments that make up the base curve Vertices (V) Vertices of the exploded segments Inputs List (L) List to cull Indices (I) Culling indices Wrap (W) Wrap indices to list range Outputs List (L) Culled list Inputs Vertices (V) Polyline vertex points Closed (C) Close polyline Outputs Polyline (Pl) Resulting polyline
Add vertices to a polyline
To add a vertex to a polyline, we deconstruct it first and create a list with
the new and existing vertices. Then, Sort Along CurveInputs Points (P) Points to sort Curve (C) Curve to sort along Outputs Points (P) Sorted points Indices (I) Point index map Inputs Vertices (V) Polyline vertex points Closed (C) Close polyline Outputs Polyline (Pl) Resulting polyline
Another possibility, to add new vertices, is using the curve parameters of the existing polyline.
Note that this approach is only possible, when the new vertices are on the
existing polyline. DiscontinuityInputs Curve (C) Curve to analyze Level (L) Level of discontinuity to test for (1=C1, 2=C2, 3=Cinfinite) Outputs Points (P) Points at discontinuities Parameters (t) Curve parameters at discontinuities Inputs Keys (K) List of sortable keys Values A (A) Optional list of values to sort synchronously Outputs Keys (K) Sorted keys Values A (A) Synchronous values in A Inputs Curve (C) Curve to evaluate Parameter (t) Parameter on curve domain to evaluate Outputs Point (P) Point on the curve at {t} Tangent (T) Tangent vector at {t} Angle (A) Angle (in Radians) of incoming vs. outgoing curve at {t} Inputs Vertices (V) Polyline vertex points Closed (C) Close polyline Outputs Polyline (Pl) Resulting polyline
Replace vertices in a polyline
To replace a vertex, we deconstruct the polyline and use Replace ItemsInputs List (L) List to modify Item (I) Items to replace with. If no items are supplied, nulls will be inserted. Indices (i) Replacement index for each item Wrap (W) If true, indices will be wrapped Outputs List (L) List with replaced values Inputs Vertices (V) Polyline vertex points Closed (C) Close polyline Outputs Polyline (Pl) Resulting polyline
For advanced, yet specific, modifications, we can also make use of the full set of methods that are described in the how-to Filter lists.