Reputation: 406
I have the following setup: File A is my architectural model with walls, rooms, furniture, .. File B is my electro mechanical file with Lightning fixtures, Sockets, ... File A links to file B, so that file B is a linked File.
I'm currently creating an addin in Revit which generates a list of elements that is inside a given room. Now, generating this list for elements that are in the HOST file (file A) is not that hard, just iterate all elements, check if it's an Instance
and get the .Room
property of that Instance
.
However, for the Instances in the linked Document (file B), the .Room
property always returns null.
I was hoping if somebody already stumbled against a solution for this problem. Right now the only solution I see is to BIND the linked document, so that it is converted to a group. But, 1: I can't see a possibility to BIND a link trough the API, and 2: converting in to a group throws away all the advantages of a linked document.
Upvotes: 1
Views: 1395
Reputation: 601
What I've done is use the Document.GetRoomAtPoint(XYZ point) method, and pass the origin points of the elements in the host file.
You'll need some logic to convert the coordinates between your host and linked document - see this post by Jeremy Tammik for more information: http://thebuildingcoder.typepad.com/blog/2013/11/determining-host-document-location-of-a-linked-element.html
You can access the linked document through the Application.Documents property. You'll need some logic to identify which of the loaded documents are linked documents for your host model. You could use the TransmissionData.GetAllExternalFileReferenceIds() and TransmissionData.transmissionData.GetLastSavedReferenceData(elId) to retrieve the ExternalFileReference object and compare that with all currently loaded documents.
Upvotes: 1