Selection.Pickobjects() , should returns selected element in selected sequence

Selection.Pickobjects() , should returns selected element in selected sequence

Anonymous
Not applicable
2,451 Views
6 Replies
Message 1 of 7

Selection.Pickobjects() , should returns selected element in selected sequence

Anonymous
Not applicable

Hi ,

 

I am facing issue with Revit . I want to get elements id in sequence that I select in case of pick object but pick objects return element is sorted order.

I think after getting element can be sorted but getting selection sequence is not easy one.

 

 

Example :

Lets say in Document four element 1, 2, 3, 4.

I select element in sequence like 1, 4, 3, 2.

Currently PickObjects() result= 1,2,3,4

 

Expected result : 1,4,3,2

 

 

Note: I am achieving through adding while loop and using PickObject() . But in this case color of element when selected is not working so user not understand properly. I change color to fix color but some user uses different color scheme. so again this is an issue.

 

If Like Vote for this idea :

https://forums.autodesk.com/t5/revit-ideas/pickobjects-should-returns-element-in-sequnce/idi-p/75197...

 

Accepted solutions (1)
2,452 Views
6 Replies
Replies (6)
Message 2 of 7

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Manish Singh,

 

Thank you very much for submitting to the Revit Idea Station!

 

I wish you many votes for this.

 

Meanwhile, congratulations on implementing a workaround, and good luck finding a way to improve the user feedback for that as well.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 7

Anonymous
Not applicable

Hi Jeremy,

 

Thank you.

0 Likes
Message 4 of 7

sgermanoZ2Y2F
Enthusiast
Enthusiast

This is also causing me an issue, would you be willing to share your code for your workaround? Thanks! I also voted on your idea.

0 Likes
Message 5 of 7

MvL_WAG
Contributor
Contributor

An idea that might mimick the "normal" user experience,

If you change the active selection in the while loop, the selected elements appear selected.

 

Pseudocode:

while (bool)

{

element = pickobject()

selectedelements.add(element)

uidoc.Selection.SetElementIds(selectedelements)

}

 

 

 

0 Likes
Message 6 of 7

RPTHOMAS108
Mentor
Mentor

I think it doesn't consider because the option of PickObjects also has window selection.

 

What order are the birds in the sky when you look out a window, I don't know (I'll sort them by XYZ perhaps).

Message 7 of 7

vasim.kh
Participant
Participant

I was able to do just that, as for the color i haven't figured it out yet.
i'll post the code, hopefully someone will find it usefull 

 IList<Reference> refrence = new List<Reference>();

            try
            {
                while (true)
                    refrence.Add(uidoc.Selection.PickObject(ObjectType.Element, "Select lement, esc when finished"));


            }
            catch { }
            List<ElementId> selectionelements = (from Reference r in refrence select r.ElementId).ToList();
            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("Transaction Name");
                StringBuilder sb = new StringBuilder();

                    foreach (ElementId eid in selectionelements)
                    {
                        Element e = doc.GetElement(eid);
                        sb.Append("\n" + e.Name);
                    }
                    TaskDialog.Show("title", sb.ToString());
                tx.Commit();
                

               
            }
0 Likes