Note: you must have Python installed to use the Python script node. See Installation and Getting Started.
Goal: Learn how to pass lists and data structures into the Python scripting node. Connect the dots between to sub-divided curves by passing in two collections of points and having a Python script create new line between each pair of points.
> (Open). Using a python script to make lines between two collections of points
So what is happening here? Dynamo nodes are creating two collections of points, one list per selected curve. The List node then takes those two lists and creates a new list around them, a list of lists. This List is then passed into the IN port in the Python node. The python script then unpacks the lists and iterates through the elements to create new lines. A line is created between pairs of points. Here is the Python script:
| import math
doc = __revit__.ActiveUIDocument.Document app = __revit__.Application
RefPointList1 = IN[0] RefPointList2 = IN[1] count = IN[2]
max = int(count)
#use for loop to connect two series of points #if count > len(RefPointList1): max = len(RefPointList1)
for i in range(0,max): pt1 = RefPointList1[i] pt2 = RefPointList2[i] refptarr = ReferencePointArray() refptarr.Append(pt1) refptarr.Append(pt2) crv = doc.FamilyCreate.NewCurveByPoints(refptarr)
|
Python script to connect two lists of points