Close Background Revit Files

While trying to solve THIS PROBLEM, I discovered my graph was incapable of being re-run due to a bunch of .rfa files being left open in the background. I need to figure out a way to close all of them, without having to completely shut down Revit.

Between Rhythm’s Application.OpenDocumentFile node & its Application.CloseDocument node, i feel like there should be a way to do this - but I am not sure how i can get those to play well with my graph

Currently, the files are all being opened in the background by the Bimorph Node CAD.ReportInstances, so i can’t easily bracket the graph between the two Rhythm nodes.

Help?

Sounds like we need a node to report open documents then. To then allow you to close them?

a node that reports open background documents… we wouldn’t want to close the active document, as that would also shut down dynamo…

That said… i am going to see if i simultaneously open the documents with your Application.Open Document node at the same point in the graph where the files are being opened by the CAD.ReportInstances node… it may allow both to work, and then use a passthrough to get the Application.CloseDocument node to work at the end of the graph.

Still - a node that reports all open background documents would probably be really helpful.
Thanks John!

yep! I would make the node report other documents that are not the current document. :grin:

Bakery had a node for Get List of Open Revit Documents (though it’s marked as BETA, and warns of possible crashing) and archilab had one for Current Document
Between those two, i was able to get the index of the current document, and remove it from the list of open docs… but when i sent the revised list to the Application.CloseDocument (both the version from Beaker and from Rhythm), it didn’t seem to actually close them, because when i ran the graph again, all the files were still showing up as open.

beaker is no longer supported. And for Rhythm it is reporting as function? Did you try inputting a boolean into the save?

1 Like

Did you try inputting a boolean into the save?

I’m an idiot. I am so used to those bool inputs on nodes having a default value of false, i just assumed this one did as well.

That seems to have fixed the problem, as now the files are reporting as closed… now to see if the approach works on the big graph. Thanks again @john_pierson

1 Like

Yeah, I think I avoided the default value as i did not want to make that decision for the end user. lol I will still look at making a query node for “background opened docs”

That would still be really helpful. Since the workaround i made would still close any other revit files a user may intentionally have had open (besides the “current” file).

Hi @nharburger,

I wanted to provide an update on this request.

Recently I released a version of Rhythm that included the following node to accommodate this,
image

However, the node was only halfway reliable because of some stability issues demonstrated in the following thread in relation to other background open operations from other packages.
https://forum.dynamobim.com/t/copy-views-to-document-on-file/33448

In short, with background opening scripts Dynamo gets placed in a fairly “uneasy” state as we are interactively switching the Revit document. This means that if the document was lost (background closed), then Dynamo would crash. This was demonstrated in the thread above but here is a GIF of that in action as well.

20190318-BackgroundOpenCrashing

As a package developer, this is not something I was proud of as it could lead to a pretty crummy user experience and be perceived as unreliable.

So, I went ahead and implemented a fix that will not crash like previously demonstrated. This new method returns the title of the document and stores the Autodesk.Revit.DB.Document within the nodes themselves. Here is how this now functions.
20190318-BackgroundOpenWorking

As you can see the node can be run automatically and have the values changed on the fly in regards to Rhythm background document workflows.

With all of those changes came the addition of the Applications.GetDocuments nodes.

Here is a GIF of that node in action as well.
20190318-BackgroundOpenedCloseDocs

I plan on pushing a release on Tuesday of this week after I go ahead and take a look at a few other things. As always, the latest package will be on the package manager and be compatible with Dynamo 1.3.4 and 2.0.x, and Revit 2017+.

Thanks again for your comments and I hope the update will help!
-John

6 Likes

Hey - I’ve been tucked away in all sorts of non-dynamo BIM Management lands, and only just saw this response/update post. Thanks so much for doing this - its super helpful. My users like it when their graphs don’t return error messages (even if the desired task successfully completes itself)

1 Like