A better way to organize XYZ imported via Excel

Hi everyone,


I’ve recently imported XYZ data via Excel, in a couple of ways, and I was just wondering whether any of you can think of other ways it can be imported/organized that are worth looking into.

I’ve attached two images. One shows a node-based approach, the other uses a code-based approach.

In both cases, the 4-point lists are then used with the AdaptiveComponent.ByPoints node, to place an adaptive component with 4 adaptive points.

There’s always many ways to do something, and I’m interesting in learning new ways you could come up with.


Here’s the code:

<span style=“color: #309130;”>// Obtain Excel data for the in-place points</span>
D1 = <span style=“color: #2e998f;”>Excel</span>.<span style=“color: #417693;”>ReadFromFile</span>(data, <span style=“color: #885d3b;”>“Sheet 1”</span>, <span style=“color: #8c5eaa;”>false</span>);
D2 = <span style=“color: #2e998f;”>Excel</span>.<span style=“color: #417693;”>ReadFromFile</span>(data, <span style=“color: #885d3b;”>“Sheet 2”</span>, <span style=“color: #8c5eaa;”>false</span>);
D3 = <span style=“color: #2e998f;”>Excel</span>.<span style=“color: #417693;”>ReadFromFile</span>(data, <span style=“color: #885d3b;”>“Sheet 3”</span>, <span style=“color: #8c5eaa;”>false</span>);
D4 = <span style=“color: #2e998f;”>Excel</span>.<span style=“color: #417693;”>ReadFromFile</span>(data, <span style=“color: #885d3b;”>“Sheet 4”</span>, <span style=“color: #8c5eaa;”>false</span>);

<span style=“color: #309130;”>// Obtain Excel data for the unfolded points</span>
D6 = <span style=“color: #2e998f;”>Excel</span>.<span style=“color: #417693;”>ReadFromFile</span>(data, <span style=“color: #885d3b;”>“Sheet 6”</span>, <span style=“color: #8c5eaa;”>false</span>);
D7 = <span style=“color: #2e998f;”>Excel</span>.<span style=“color: #417693;”>ReadFromFile</span>(data, <span style=“color: #885d3b;”>“Sheet 7”</span>, <span style=“color: #8c5eaa;”>false</span>);
D8 = <span style=“color: #2e998f;”>Excel</span>.<span style=“color: #417693;”>ReadFromFile</span>(data, <span style=“color: #885d3b;”>“Sheet 8”</span>, <span style=“color: #8c5eaa;”>false</span>);
D9 = <span style=“color: #2e998f;”>Excel</span>.<span style=“color: #417693;”>ReadFromFile</span>(data, <span style=“color: #885d3b;”>“Sheet 9”</span>, <span style=“color: #8c5eaa;”>false</span>);

<span style=“color: #309130;”>// Group the points for the placement of adaptive components</span>
PtGroup1 = groupPts(getPts(D1), getPts(D2), getPts(D3), getPts(D4));
PtGroup2 = groupPts(getPts(D6), getPts(D7), getPts(D8), getPts(D9));

<span style=“color: #309130;”>// Create Points from the Excel data</span>
<span style=“color: #8c5eaa;”>def</span> getPts(list:<span style=“color: #8c5eaa;”>var</span>)

xyz = <span style=“color: #2e998f;”>List</span>.<span style=“color: #417693;”>Transpose</span>(list);
Pt_X = <span style=“color: #2e998f;”>List</span>.<span style=“color: #417693;”>GetItemAtIndex</span>(xyz, <span style=“color: #2585e5;”>0</span>);
Pt_Y = <span style=“color: #2e998f;”>List</span>.<span style=“color: #417693;”>GetItemAtIndex</span>(xyz, <span style=“color: #2585e5;”>1</span>);
Pt_Z = <span style=“color: #2e998f;”>List</span>.<span style=“color: #417693;”>GetItemAtIndex</span>(xyz, <span style=“color: #2585e5;”>2</span>);
Pt = <span style=“color: #2e998f;”>Point</span>.<span style=“color: #417693;”>ByCoordinates</span>(Pt_X, Pt_Y, Pt_Z);

<span style=“color: #8c5eaa;”>return</span> = Pt;


<span style=“color: #309130;”>// Group Points by transposing lists</span>
<span style=“color: #8c5eaa;”>def</span> groupPts(a:<span style=“color: #2e998f;”>Point</span>, b:<span style=“color: #2e998f;”>Point</span>, c:<span style=“color: #2e998f;”>Point</span>, d:<span style=“color: #2e998f;”>Point</span>)

list = <span style=“color: #2e998f;”>List</span>.<span style=“color: #417693;”>Transpose</span>({b, c, d, a});

<span style=“color: #8c5eaa;”>return</span> = list;


Image 15 Image 16

I’m trying to edit my post, but it will not update…

Another possible difference is to use a different setup for the excel file. Check out the example in the DynamoTutorial package’s extra folder:

C:\Users\YOUR_NAME\Google Drive\Dynamo\Workshop Content\Intro Workshop Day 1\03 Working with tabular data


try logging out, closing browser window, then opening and logging back in

Here’s the code (again):



// Obtain Excel data for the in-place points
D1 = Excel.ReadFromFile(data, “Sheet 1”, false);
D2 = Excel.ReadFromFile(data, “Sheet 2”, false);
D3 = Excel.ReadFromFile(data, “Sheet 3”, false);
D4 = Excel.ReadFromFile(data, “Sheet 4”, false);

// Obtain Excel data for the unfolded points
D6 = Excel.ReadFromFile(data, “Sheet 6”, false);
D7 = Excel.ReadFromFile(data, “Sheet 7”, false);
D8 = Excel.ReadFromFile(data, “Sheet 8”, false);
D9 = Excel.ReadFromFile(data, “Sheet 9”, false);

// Group the points for the placement of adaptive components
PtGroup1 = groupPts(getPts(D1), getPts(D2), getPts(D3), getPts(D4));
PtGroup2 = groupPts(getPts(D6), getPts(D7), getPts(D8), getPts(D9));

// Create Points from the Excel data
def getPts(list:var[][])

xyz = List.Transpose(list);
Pt_X = List.GetItemAtIndex(xyz, 0);
Pt_Y = List.GetItemAtIndex(xyz, 1);
Pt_Z = List.GetItemAtIndex(xyz, 2);
Pt = Point.ByCoordinates(Pt_X, Pt_Y, Pt_Z);

return = Pt;


// Group Points by transposing lists
def groupPts(a:Point[], b:Point[], c:Point[], d:Point[])

list = List.Transpose({b, c, d, a});

return = list;


Thanks Colin,

Dynamo is reading each list as a row from Excel.

Considering this, how would you then group each triad of X, Y and Z coordinates to create points, and then group each group of 4 points into lists, in order to pass those point lists into the AdaptiveComponent.ByPoints node?

Santiago, that file I am referring to does all of that.

Ah! I wasn’t paying attention. I’ve included a capture of that tutorial example.

Yes, this is much cleaner than the node version I made, many thanks Colin.

Do you happen to have a code-block version of this approach?

If not, I’ll try to write one myself. Thanks again!

Image 17