Reputation: 113
Is there a method Revit API 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.
Upvotes: 0
Views: 855
Reputation: 13
The easiest way you can fix your problem is by using the following method.
public List<Element> GetElementsBySelection(UIDocument uiDoc)
{
bool flag = true;
List<Element> listElem = new List<Element>();
do
{
try
{
Reference referencia = uiDoc.Selection.PickObject(ObjectType.Element);
Element elem = uiDoc.Document.GetElement(referencia);
listElem.Add(elem);
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException e)
{
flag = false;
}
} while (flag);
return listElem;
}
This method ends when you press the "Esc" key. Other more elegant ways to detect when the key is pressed were discussed in the following forums: Monitoring keyboard and Detect key press.
I hope that it serves as a guide so that you can continue advancing in the development. Best regards. Thanks to Jeremy Tammik for the general idea to solve the problem.
Upvotes: 0
Reputation: 8294
It is exactly as you say. No, the Revit API does not provide a built-in method providing the functionality you require. You can implement it yourself by calling PickObject
repeatedly in a loop and collecting the selected elements in your own sorted list.
Upvotes: 0