Message 1 of 17
Selection of linked elements does not look correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm using the new Selection.SetReferences Method from 2023 that now allows you to select elements in linked files. The selecting is working, according to the filter count, but the elements do not look highlighted correctly or even at all. Here is a macro to test in the 2024 Snowdon HVAC file, L2 view (turn on Rooms/turn off Spaces in view template):
public void SelectLinkedRooms()
{
UIDocument uiDoc = this.ActiveUIDocument;
Document doc = uiDoc.Document;
var linkedRoomList = new List<Reference>();
var revitLinkList = new FilteredElementCollector(doc).OfClass(typeof(RevitLinkInstance)).ToElements().Cast<RevitLinkInstance>().ToList();
foreach (var linkInstance in revitLinkList)
{
// Skip linked doc if not loaded
var linkedDoc = linkInstance.GetLinkDocument();
if (linkedDoc == null) continue;
// Get all rooms in linked document instance filtered by level id
var linkedInstanceRoomList = new FilteredElementCollector(linkedDoc).WherePasses(new RoomFilter()).ToElements().Where(q => q.LevelId.IntegerValue == 593177).ToList();
linkedRoomList.AddRange(linkedInstanceRoomList.Select(q => new Reference(q).CreateLinkReference(linkInstance)));
}
uiDoc.Selection.SetReferences(linkedRoomList);
}
It gets the rooms from every link file, creates references from them and then sends that into Selection.SetReferences. The rooms should be show as shaded as if you had manually picked them. Am I doing something wrong or is this a bug?