Is there any way to order elements by their position within the XY-plane? (From top left to bottom right)

I’m trying to sort/order my elements in a list according to their placement in the XY coordinate system from top left to bottom right (so regardless of there ID or the order they were created/placed in). They are placed along a multi-segment grid and should be in the order as displayed:

I have tried looking at the solution of this very old post but I just can’t seem to get the ordering by X and Y to work like I need it to…
Rename elements (beams,columns etc.) by X and Y direction - Revit - Dynamo

Any suggestions are welcome, I’ve also attached a rvt-file with some elements to test with, the grids are not multi-segmented though… Also attached is the start of a script…
I used 2 different approaches for finding the center point of my elements, by creating a center point between the 2 adaptive points and by using Element.Location. Both seem to give different results…
I’m writing the order value to the Mark-Parameter as an easy way to check if the list has the correct order…

OrderElementsXY.dyn (92.6 KB)

Order elements XY.rvt (7.9 MB)

The first part of the process for building an automation is to write down the sequence of operations you have to perform. So if you had a pen and paper in front of you with the grids and objects drawn, what would your steps be?

From there you’ll have a map showing you what you need to do and the order you need to do it in, which makes building the graph MUCH easier. Give it a shot and see where you get.

1 Like

Have a look here or here.

@bvs1982

I’ve tried implementing those solutions but I can’t seem to get it working for my elements.
I think it’s because my elements are not perpendicular/orthogonal…

I’ve tried this but it’s not getting me anywhere.

Maybe numbering by using a Spline works better in your case. There is also a ‘Pick in Order’ node
(i don’t know which Package). You get a List with the Element in the order you picked.

What were your steps?

Hi @Laura_BIMChick you could try something here maybe :wink:

@bvs1982 can you elaborate on the Spline?
The ‘Pick in order’ will not be an option for me, since my actual model consists of more than 100 of these elements…

So…

My steps would be:

  1. Get the location of each element.
  2. Sort the grids by their sequence.
  3. Get the grid curves (now in sequence).
  4. Group the elements by the nearest grid curve.
  5. For each group:
    A. Get the location of the element
    B. Get the closest point on the associated grid.
    C. Get the parameter of the grid at that point.
    D. Sort the elements in the group by the parameters
  6. Flatten the lists of sorted groups
  7. Build a range of mark values as long as the flat list of groups
  8. Set the mark values of the flattened list by the range of values

I can, but maybe @jacob.small has a better idea where you can still use the xy approach :innocent:.

Your solution almost works, only a couple are in the wrong order…

guees its becourse you use the family location instead geometry location

@jacob.small Sounds very promising but unfortunately I don’t have the time or brainpower left to attempt this right now. That’s why I posted on here with everything I was able to do.
Right now the suggestion of @sovitek kinda works for the most part and I will probably just fix those couple that aren’t right, manually for now. But I’ll have to take a look tomorrow if it also would work on my actual model/project.

Is there a way to get the element geometry by using regular nodes? I saw you used a custom node from your own package but’ I’m very limited in what packages I can use (company policy).

yes i can send the python tomorrow,but you will need iron python 3…which revit version are you in?

2024.3 Currently

try with this one here, just place it into a costum dyf so you can control the levels

forum geometry.dyn (13.7 KB)

EDIT seems better with just a boundingbox…

2 Likes

@sovitek The bounding box solution worked perfectly!


I’ll test it out on my actual model this afternoon!
Thanks!

@sovitek Could you please still share your script? I’m trying to replicate but can’t see where all the lines are going exactly…

1 Like