Linked doc of background doc

Hello everyone,

Quick question, does anyone know how to get elements in a file linked to another document, not the one we are working in?

I have opened a doc in the background and got data from it, but some other data are in a file linked to this file. The nodes I am using for the first step obviously don’t work with the link file of a background opened doc. I have tried to copy the python scripts from custom nodes and change doc=DocumentManager.Instance.CurrentDBDocument wit doc=IN[0] with my background opened document as IN[0] but it doesn’t seem to work.

Does anyone have some ideas?

I tried to get the linked document like that:
Looks like the GetLinkDocument() method doesnt work here, I dont know why because link_docs give a RevitLinkInstance … (see also https://forums.autodesk.com/t5/revit-api-forum/getlinkdocument-method-for-nested-revit-link-returns-null/td-p/9263128)

And then used this node:

Hope you have any ideas ! Thanks !

Hey Baud,

The Orchid package has a node that will grab the Revit links from a background opened file.

I have not tried what you are asking but I think it will work with the nodes from BIMorph Package. I have used them quite extensively for getting linked elements just not for a link within a link.

Hi Baudouin,

The easiest way is to set your nested link to Attachment :

For Overlay, it’s more complicated, you have to open in background the nested link :

1 Like

You have to get the Link document from the Link type, not Link instance. That’s what is throwing the null in the first image.

Thank guys ! Your solutions work fine ! Thanks for your support !

Hi Sean,

Can you explain your comment? I get the nested document with the LinkInstance. I don’t understand the benefit of using the RevitLinkType.

1 Like

Thank you for the answer although I still do not understand.
GetLinkDocument () is a method for LinkInstances not for LinkTypes.
I thought I could learn something new :wink:

1 Like

@Alban_de_Chasteigner thanks for correcting me! I suppose I may have gotten a little too reliant on autocomplete in Visual Studio! But hey, still solved the question right! :rofl:

2 Likes