Polyline vertices incl. start and end vertices?

I just started using Dynamo today, so bear with me if I am babbeling.

I have a list of polylines,

list
[0] list
[0]Polycurve (NumberOfCurves = 3)
[1]Polycurve (NumberOfCurves = 2)
etc…

And I need to extract a list of all of the vertices - including start and end vertex.

So I made a PolyCurve.Curves and got a nice list with all the vertices.

list
[0] list
[0] list
[0]Curve(StartPoint = Point(x,y,z), EndPoint = Point(x,y,z)
[1]Curve(StartPoint = Point(x,y,z), EndPoint = Point(x,y,z)
[2]Curve(StartPoint = Point(x,y,z), EndPoint = Point(x,y,z)
[3]Curve(StartPoint = Point(x,y,z), EndPoint = Point(x,y,z)
[1] list
[0]Curve(StartPoint = Point(x,y,z), EndPoint = Point(x,y,z)
[1]Curve(StartPoint = Point(x,y,z), EndPoint = Point(x,y,z)
[2]Curve(StartPoint = Point(x,y,z), EndPoint = Point(x,y,z)

How can I transform this list into a list of lists of all the vertices once?

list
[0] list
[0] Point(xyz) - this is the startpoints
[1] Point(xyz) - this is the startpoints
[2] Point(xyz) - this is the startpoints
[3] Point(xyz) - this is the startpoints
[4] Point(xyz) - this is the Endpoint of last line
[1] list
[0] Point(xyz) - this is the startpoints
[1] Point(xyz) - this is the startpoints
[2] Point(xyz) - this is the startpoints
[3] Point(xyz) - this is the Endpoint of last line

I expect this needs some Python, and while I do code C++, the Python syntax eludes me.

You will find a lot of information that helps to get started with Dynamo in the Primer:
http://dynamoprimer.com/en/05_Geometry-for-Computational-Design/5-1_geometry-overview.html
As well as in the Dictionary:
http://dictionary.dynamobim.com/#/Geometry/Curve/Query/StartPoint

I figured it out - I was not deep enough into the lists.

"
import clr
clr.AddReference
#from Autodesk.DesignScript.Geometry import *

def BuildLines(pLine):
layerList=[]
for i in range(len(pLine)):
curveList=[]
for j in range(len(pLine[i])):
lineList=[]
for k in range(len(pLine[i][j])):
lineList.append(pLine[i][j][k].StartPoint)
lineList.append(pLine[i][j][k].EndPoint)
curveList.append(lineList)
layerList.append(curveList)

return layerList

OUT=BuildLines(IN[0]);
";

Please cite your sources so that everyone can understand the point of this thread

hi, I need the exact same thing - the list of start, all vertices, end vertex.

but my polycurve is already made out of 3 joined detail lines. - because i need the vertices in the correct order since i want to draw a wire. (this is why i need all the vertices)

image

it doesn’t seem like i can extract much out of this node.
I have the detail lines selected in a “select model elements” node, but the order there is random…

Maybe a little bit of Python could help.

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

# Place your code below this line
pCrv = IN[0]

crvs = pCrv.Curves()
verts = []
verts.extend(c.StartPoint for c in crvs)
verts.append(pCrv.EndPoint)
# Assign your output to the OUT variable.
OUT = verts

a part from that I think maybe there exists a node for this in the Wombat package. Unsure if it is still maintained.

3 Likes

thank you for the code :slight_smile: always nice to study it.

found these in Dynamo:

now the vertices are taken in the correct order :slight_smile:

This is nice. Thank you for this.
Though it fails for list of polycurves.

Regards,
Atharva Purohit