Selection, Sorting and Highlighting Elements in the selected order using PickObjects() method

Is there a method/way in Dynamo/Revit API using Python where I can select elements in order, highlighting the elements selection.

Please note, Selection.PickObjects() does the selection & highlighting but does not save the elements in the order of Selection.

Springs, Rhythm, and Data-Shapes all have nodes for selecting ordered elements.

I agree they do and I had a look at the package nodes, but they fail to highlight the selection. The method they use is Select.PickObject(), which does the selection, saves the selection, but doesn’t keep the selection highlighted, which is the case of Select.PickObjects() method, the only issues with it is it doesn’t save the selection in order of selection/picking.

The three that I mentioned are python nodes, so you can see what they’re doing in the code to select and maintain object order. You should be able to combine that with Selection.PickObjects() to get what you want.

Exactly, I have done the same using Python, they have implemented the Selection.PickObject() method to select elements in correct order and save it, but it fails to highlight the selection, which is my requirement for selecting multiple elements.
Here is the implementation in Python,

sel1 = uidoc.Selection
obt1 = Selection.ObjectType.Element
msg1 = 'Pick elements in the desired order, hit ESC to stop picking.'
getDetailElements = []
get_rvt_Crvs = []


if(IN[0] == True):

    flag = True
    TaskDialog.Show("Detail Curves Selection", msg1)
    while flag:
        try:
            el1 = doc.GetElement(sel1.PickObject(obt1, msg1).ElementId)
            getDetailElements.append(el1)
            
        except : flag = False

If any of the methods, or any other method, can do the job, it would really help.

It may be a difference in PickObject() and PickObjects(). The ordered nodes use PickObject() to iteratively pick multiple singular objects vs picking many objects at once. This allows them to build a custom list in the order the elements are selected but probably doesn’t highlight elements because it wouldn’t be necessary for a single object. Selecting multiple elements with PickObjects() would highlight the elements but likely returns a sorted list.

You can try to work around this but it may not be possible.

Hello,
this post may help you

1 Like

Thank you so much, this is exactly what I needed.
:smiley: :smiley: