I have just started creating my own pyRevit tools and hit a little snag trying to grab rooms from a linked model. I am using a FilteredElementCollector on the linked document,
roomCollector = DB.FilteredElementCollector(linkDoc).OfCategory(DB.BuiltInCategory.OST_Rooms).ToElements()
but when I print the result, it’s an empty list:
Just as a check I ran the same code in dynamo, and it worked.
The file I’m testing on is in Revit 2023. I am stumped. Any help would be greatly appreciated!
@DennisGoff Can you show the whole code? The piece you are showing looks fine.
I am guessing you are not passing the link document
once you grab you
RevitLinkInstance elements of the Class, you can use
GetLinkDocument() method and pass it as
linkDoc in your code
That’s what I was missing! Previously, I was using something like this:
linkDoc = linkInst.Document
but I did what you suggested and used GetLinkDocument() and it’s working now. Thanks!