Dynamo Lacing, Levels and Data Structure

During all the dynamo trainings that I have given, people seem to struggle most with lists, or as I often call it: Dealing with the data structure.
The trickiest part is lacing. Lacing is well explained on the DynamoPrimer. Except, so far, the workings of the Auto lacing.
Below you see a typical example of the shortest vs Auto Lacing.
The node Line.ByStartPointEndPoint (in the shortest group) gets an item and a list of multiple items, since the node is set to Lacing shortest it stops creating lines as soon as the input with the least items runs out. Therefore this node only produces one red line.
The node Line.ByStartPointEndPoint (in the Auto group) gets an item, and a list and since the node is set to Lacing Auto it creates lines for every point in the longest list with the single point provided from the input: startPoint. Therefore this node produces four  blue lines. You could say that the Auto lacing behaves, in this situation, like what the longest lacing does.

To understand the Auto Lacing a bit better, I have updated the graph like this. Notice the List Chop node.
The node Line.ByStartPointEndPoint (in the shortest group) gets one item into its startPoint input port and a list with three items in its endPoint input port. Since the items in the list happen to be list themselves, the node  Line.ByStartPointEndPoint creates 3 red lines. Basically it takes the first item from the two input ports and does its magic.

But as soon as you provide a list of points (Notice that I am creating a range of startpoints) for the startPoint input of the node Line.ByStartPointEndPoint you get a different result, both the nodes Line.ByStartPointEndPoint produces the same amount of lines.

Let’s add list levels into the mix.
Notice that both the nodes Line.ByStartPointEndPoint have a list level set to @L2 for the startPoint input port.
The node Line.ByStartPointEndPoint (in the shortest group) takes the two points from the list from the startPoint input port and connects these with the first two points of the first list from the endPoint input port.
Whereas the node Line.ByStartPointEndPoint (in the auto group) takes the two points from the list from the startPoint input port and connects these to all the points in the two lists from the endPoint input port. Sort of mimicing lacing longest behaviour.

Let’s change the lacing of the input port startPoint of the nodes Line.ByStartPointEndPoint to @L1.
The node Line.ByStartPointEndPoint (in the shortest group) takes all the points regardless of the place in the data structure and combines this with what comes into the endPoint port. So the first item from the startPoint input port gets connected with points in the first list of the endPoint input port, the second point from the startPoint input port gets connected with points in the second list of the endPoint input port and so on. The Auto group seems to be doing a cross-product lacing.
When you look at the data structure notice in the node Line.ByStartPointEndPoint you get two lists for each point you provided in the endPoint input port.
But notice when you expand these two lists you get a data structure in both list that is the same as the data structure that is coming into the startPoint input port.
The Auto lacing produces the same result as if you wouldn’t use any levels but set the lacing to cross product.

Cross Product vs Auto Lacing at different levels.

Notice the differences in results once you add levels into the mix.

Both startPoint input port without levels

Both startPoint input port @L1

Both startPoint input port @L2

Both startPoint input port @L3

Dynamo Lacing, Levels and Data Structure
Tagged on:         

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: