Numbering pile foundation based on X/Y and starts a new count for every house block

Hi all,

I have a python script for sorting by x,y location of pile foundations. Now this is working perfectly fine for a entire project. But when I have a project with multiple house blocks, in one revit file, I want to start the count with 1 for every house block. So I thought lets use group by key node and give that as input for the python script and I wanted to use ‘use levels’ option, but that is not possible with a python script.

Has anyone an idea how to deal with this? Python script is below.

image

image

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

list_el = IN[0]
orientation = IN[1]
output =

if orientation == True:
output = sorted(list_el, key=lambda list_el:(list_el[1], list_el[2]), reverse=True)
else:
output = sorted(list_el, key=lambda list_el:(list_el[2], list_el[1]), reverse=False)

#Assign your output to the OUT variable.
OUT = zip(*output)[0]

Hi @mvanleeuwen,

I can understand your graph a little bit (new in dynamo), but i understand what you want to achieve.

I saw in your Graph you have a parameter called “Bouwdeel”.

So based on this you can make different “groups” / lists and then based on the location you can start you numbering by set a value?

So i dont get it so far why you need the Python script?

I would filter out for each “Bouwdeel” and then with each list start with 1 and add up.

Kind regards,
F Verwoert

1 and 3 have the same X value, so first sorted by Y value, then by X value, you get this. I don’t know how to do this in dynamo with nodes. If I first sort by X, then by Y everything is just sorted by Y and X has no influence

I understand now what you mean.

I cant give you a solution, because what you basicly want is to first sort them by your Y-coordinate and over those results you want to filter by X-coordinates but leave the Y-coordinates as is.

I could suggest to you by using Excel make an export of all your piles and then use the sort by function of excel.
You can then select first Sort by Y and then sort by X

Maybe someone else know how to achieve this in Dynamo

@mvanleeuwen i did some more research on this forum and i found something useful from @Vikram_Subbaiah called SortTwice.

I changed it more towards your situation.
And you want from Y-coordanites and then X-coordanites, so you have to do the process reversed (so first X and then Y)

I used roundup because revert converts it wrong and this way i had te result i wanted.

In my case i used Structural Foundation, you can change that obviosly. And the last thing you need to do is add the “bouwdeel” parameter in it, you should put that first before the rest.

If you have any question feel free to ask. And thanks @Vikram_Subbaiah for sharing SortTwice, credits for you!

SortTwice.dyn (22.7 KB)

*Edited it made the capture before saving the first List.GetItemAtIndex the index was 1 should be 2 (i uploaded a new .dyn file)

1 Like

hi Fabian, sorry for the late reply, had a deadline dropped on my desk for friday. But thanks for the research, I appreciate that very much!

Probably coming week I’ve some time to get this thing working, so I will let you know!

1 Like

I still can’t get my head around it… This is my desired situation:

  • First I want my elements grouped by parameter parts, then grouped by point.Y.
  • Point.Y is in index 2 and parts in index 3.

at the end I want for every part, that the numbering starts all over again, beginning with one.

at @L2 i’ve grouped my list by keys (parts), so for so good. But now I want to create at @L3 the sublist based on point.Y.

So I thought to do the same trick as I did before.

I also tried to use ‘use levels’, but I didn’t get it working.

@mvanleeuwen you got an error by List.GetItemAtIndex called Function, you have to attacht the a list to it. (Your last screenshot)

Try fix that first then it might work, if not let me know what the error message contains.

Kind regards,
F Verwoert

no, thats how a list map works. And the error is not with the ‘getitematindex’, but by ‘groupbykey’.

@mvanleeuwen Use List.GroupByFunction instead of List.GroupByKey. You’ll need to remove your list input from the List.Map node.

Just thinking out loud here… but it might be easier to group them by house block afterwards, rather than dealing with a so many sublists.

If you sort them all by x and y first they’d be ordered by coordinates regardless of house block. Since they’d already be sorted, grouping them by house block after the fact would keep the sorting intact. Then all you’d have left to do is number each group sequentially.

2 Likes

thanks you all @Nick_Boyts, @awilliams. Sort afterwards did the trick. Still I found it frustrating that I can’t get it done by managing the sublists… Group by function did not work for me Amy, at least not the way I did it…