简体   繁体   中英

Autodesk Revit Architecture 2014 .NET API C# find room for Instance in link

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM