This model is linked into one or more open documents

This model is linked into one or more open documents

Rockit_for_Revit
Advocate Advocate
502 Views
3 Replies
Message 1 of 4

This model is linked into one or more open documents

Rockit_for_Revit
Advocate
Advocate

Hello,

I have a command to resave as central a group of models.

The problem I'm facing is that some of the models are not opening due to the message 'This model is linked into one or more open documents'.

Basically my code opens the file, saves it, then closes it. However if the proceding model has one of the the models linked in, then the command fails. I'm wondering if I need to put in a delay to wait for the previous model to close before the next model is opened?

 

Document = uiapp.Application.OpenDocumentFile(objModelPath, objOpenOptions)

..

Document.SaveAs(strFullFileName, objSaveAsOptions)

..

Document.Close()

 

0 Likes
Accepted solutions (1)
503 Views
3 Replies
Replies (3)
Message 2 of 4

jeremy_tammik
Alumni
Alumni

I guess it depends on exactly how it is failing. Are you surer that it works better if you wait for long enough? Do you receive a warning message or an error message? If it is an error, it needs to be fixed. If it is a warning, it can be ignored, but may require user interaction to do so. In the latter case, a warning swallower might help:

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 4

GaryOrrMBI
Collaborator
Collaborator
This is the same behavior as in the UI. Revit does not allow you to open a linked model while the host model has it open (which is how Revit sees a loaded link in many respects).
In the UI you will be asked if you want to unload the link to allow you to open it as a separate model (unless it's a cloud project).

So, yes, you need to wait until it has completely closed the Host document.

If an event handler is possible for you then subscribe to the DocumentClosed event:
Autodesk::Revit::ApplicationServices::Application::DocumentClosed event will be raised immediately after document is closed

otherwise you could do a try...catch in a loop with a timer in it and a bail-out provision if a certain number of loops and/or a given amount of time passes, but that starts feeling a little wonky.

-G
Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
0 Likes
Message 4 of 4

Rockit_for_Revit
Advocate
Advocate
Accepted solution

Thank you for the suggestions. I've added a short delay and haven't been able to reproduce the issue, so maybe that’s the fix.

0 Likes