Numbering Elements starting from left to right top to bottom

So I got through filtering out elements, and applying a sequential number to a specified parameter, but whAt I’m finding difficult is making that order of numbering start in the upper left corner and go left to right, and top to bottom.

It seemed like default the script liked bottom left start, left to right, bottom to top…
Then when I deleted a pile in the middle and copied on in its place, that number came up last, so apparently placement order comes into play at some point.

I tried extracting Xs and Ys and parsing the data around, but I struggled with that. And I also thought there could be situations with Shared Coords that could lead to a failure. Unless I base my Coords off of PBP. But I digress….

Anyone have any suggestions for this task?

Erik fritz did a door number video based on a drawn spile line which might be applicable to you here.

Try google that and see where you get to

Hello, here are 2 methods to achieve


import sys
import clr

clr.AddReference("RevitAPI")
import Autodesk 
from Autodesk.Revit.DB import *

Elts=UnwrapElement(IN[0])

b=sorted(Elts,key=lambda x:(-x.Location.Point.Y,x.Location.Point.X))
OUT = b

Sincerely
christian.stan

3 Likes

@christian.stan
Can you pls explain what are you achieving with List.GroupByKey?

Hi, here is an explanation From Mr. Daan

cordially
christian.stan

Thanks. What this does Elts=UnwrapElement(IN[0])
?

1 Like

hello
good reading
cordially
christian.stan