Automatically renumber detail views by location (help)

Hi all,

I’m trying to create a graph to collect the viewport locations in a given sheet and then renumber the detail view according their location on sheet.

So far I can collect the viewports and their centroid location. However I’m struggling to obtain the left bottom corner of the viewport and I’ve no clue of how to -once the coordinates are sorted- sort the viewports list following the same order as the coordinates list (given 2 lists of the same number of elements make the sort order on one match the other).

The graph currently works fine when renumbering views in the selection order.

What I’m trying to figure out is the upper half of the graph, from the Viewport.LocationData node onwards.

Any help is welcome :slight_smile:


@franciscusm please post your file or a link to it


Sure, here it is.

Why are using the Springs.SelectElements(ordered) node?


If you want to use that node, you can manually pick the order your self.

Look at this post:


Yes, I’m using that node in a different approach and works fine (sorry, everything is included in the same graph so it may be confusing).

I’m using it because it’s a WIP file for me and everything is there (first I got it working with Spring.SelectElements(ordered) and now I want to try an automatic approach with Viewport.LocationData.

My question was about the upper half of the graph (please ignore the Spring.SelectElements(ordered) stuff). Starting from Viewport.LocationData.

The script below will sort the Viewports starting from top left. Then you can rename them accordingly using the other part of the script you already have.

import clr
from Autodesk.DesignScript.Geometry import *


Coordinates=[[pt.X, pt.Y,vp] for vp, pt in zip (Viewports,Pts)]

Coordinates.sort(key=lambda x: (-x[1], x[0]))

OUT=[Viewport[2] for Viewport in Coordinates]


Great! I’ll try it when I have time. Many thanks! :slight_smile:

Thanks. It works,

However not always sorts views as desired. I think it would work better by sorting the bottom left corner coordinate of the viewports instead of the center, as every viewport can be different in size.

I’ll try that.


Works much better sorting by the bounding box minimum point, still not perfect as sometimes requires the human factor to decide or the viewports are not perfectly aligned… Thanks @salvatoredragotta !