Renumber views in specific order

Hi all, I know there have been a bunch of posts on here about renumbering views on sheets, but none quite get me there. My goal is to renumber a single sheet automatically, without picking the views in order. I need to start with #1 in the upper left, then work horizontally from there towards the lower right. I’m close, but it won’t consistently renumber in rows from top to bottom.
Here’s what I’ve got so far, thanks to others on this forum:

Thanks for any help!

Hi @Andrew-Watkins ,

Welcome to the Dynamo community :smiley:

I don’t exactly understand why you are remapping your X and Y values to sort your viewports, but see if this approach helps:

This approach first sorts all viewports by their X-location, and then if there are any which have the same X-location they are also sorted by their Y-location.

Uploading: 2022-06-20 Sort Viewport Numbers by their location.dyn…

If you have non-uniform view sizes or view placements, you may want to consider binning your X/Y values within ranges so that left-to-right top-to-bottom logic better aligns to what you see versus the coordinates themselves. Rounding the values to specific increments before applying your sort logic would also work.

1 Like

Hi Dan,
This is close. The missing piece is the viewports w/ the higher Y value needs to be renumbered first, like the image attached. I haven’t been able to correctly sort the resultant list to match that sequence yet!

^This.

If your view origins are not aligned then your numbering will likely be off. This is a common issue with non-uniform arrays. Round your values to a set increment to better “judge” the location of each view.

1 Like