Join Paul F. Aubin for an in-depth discussion in this video Upgrade a folder full of files with Dynamo, part of Revit: Tips, Tricks, and Troubleshooting.
- [Instructor] Whenever a new release of Revit comes out, you're always faced with the prospect of having to upgrade existing files. Now if you only need to upgrade a few files, then you can just do them on the fly as needed, and when you simply open that file in the new release, Revit will upgrade it and when you save it will make the process permanent. But what if you have lots of files to upgrade? Maybe you have a whole folder full of previous files and you want to upgrade them all to the newest release. Well you can wait for the third part app developers to update their applications. There are lots of plugins available for Revit that perform this task.
Some are free, some cost money. So you could certainly do that. But if you need to upgrade files right away or if you'd rather not install one of these plugins, then you have an alternative and it's in using Dynamo. So Dynamo is installed with Revit automatically and you can build a graph that allows you to go through folder full of files and open up each one and save it and close the file. So that's what we're going to build right here. So to get started you need a collection of files. Now you can use any folder full of files from any previous release of Revit.
In my case, what I've done is, here in my Exercise Files folder I have this zip file called Files to Upgrade. And I've just gone and grabbed a sample of files from Revit essential training. So you could do the same, you could download exercise files from any of our other previous Revit courses here. But I've grabbed them from essential training here and I'm just simply going to right-click this and choose Extract All. Now, I'm going to remove this part of the path right there and just extract it right into Exercise Files and I'll click Extract.
And then it creates this folder here called Files to Upgrade. And as you can see I have a chapter five folder here which contains some Revit files but it also contains some DWGs and some text files. So I wanted you to see what would happen when you had a folder that had mixed file types in it. We're going to be able to tell it to just focus on the Revit files and then I've also got this links folder here. And I wanted you to see that as well because some of these Revit files are host files that point to those other files as Revit links. So it's going to be important that you upgrade the Revit links as well because otherwise next time you open the host file, it'll see that the link is still in the previous format and it'll have to upgrade it anyway and that will kind of defeat the purpose of what we're doing here.
So anyway, there's a little sample collection of files. It should process fairly quickly and it'll give us a sense for how this technique works. So meanwhile back here in Revit, I'll click the Manage tab and open up Dynamo. So when Dynamo launches, I'll click the New icon here to create a brand new graph. Now in order to build this graph, I'm going to use both out of the box nodes, ones that are provided directly natively with Dynamo and a couple nodes that are included with some packages that you have to download and install. Those packages are Clockwork and Rhythm.
So if you don't have Clockwork and Rhythm installed, it's very easy to install them. You just go to packages, you say Search for a Package, and then when this window opens up here you can click in the search field here and type in Clockwork for example. Make sure you're downloading the latest version. So Clockwork for Dynamo 1.x. And you click this little download here and that will install the latest version. Then we repeat that for Rhythm and you'll have all the nodes that you need. So to get started, I'll expand Core.
I'll go to Input. And I want a Directory Path. This browse button here is going to let us point to the folder where our files live. So let me click on that. I'll scroll down here. And under Exercise Files I'll choose Files to Upgrade and click OK. So that writes that path for us right there. Now next, natively, it's only going to look in one folder. So I want it to look at all the subfolders. So that's where I'm going to turn to Clockwork. So I go to Clockwork, I go to Core and under Clockwork, and then directory, and I've got this Directory Contents plus.
So this node allows us to see all the subfolders as well. So I'll take my directory here and I'll link it up to the Directory Path right there. Now this input allows us to limit the output to just Revit files. If I expand this little pushpin icon right here, what you're going to see is at the moment, it is actually seeing everything. The DWGs the Revit files, the Revit ini files. Everything that's contained in those folders.
We only want the Revit files. So I'll close down Clockwork here. I'll expand Core, back to Input, and I'll bring in a text string. And I'll type in that text string *.rvt. Now at the moment you can see the output here is 17 items. When I feed this text string in, that's going to drop down to nine items like so. Now you could expand it here to see those items but I like to use a Watch Node for this.
So I'm going to go down to view and bring in a Watch and I'll just take that and feed it in right there. And there are my nine items. And let's just scroll over here to see them. And notice they're all Revit files. Now, notice at the bottom of the list are the two files that are contained in the links folder. Now what'll happen is, it'll go down the list in order. So it's going to start at the top, work its way down, and that means that some of those host files are going to have to temporarily upgrade those linked files. So wouldn't it be better if we started with the linked files and then worked our way down.
This way we could speed the process up a little bit. So to do that, I just need to reverse this list. So you can come back over here to your library. Go to List and look for List.Reverse. Or if you prefer you can just simply search for it by typing in reverse in the search field right there. And then I'll bring that one in. And you could go from the watch right into the list, okay. And that will work just fine, or what you can do is actually go back to your original list of files and do it that way.
And then I'm going to copy this and paste it with Ctrl + C and Ctrl + V and then feed that in here. So now I have two Watch Nodes, but you can see that it just reorganized the order of that list. So now I have my links at the top. Now at this point I want to turn off automatic execution. By default Dynamo graph will execute automatically, so the minute you hook up a node it runs it. What I want to do is change this to manual because the next node that I place is going to start opening the files. And I don't want to sit here and wait for it to open up all of those files while I'm still building the graph.
I want to build the graph and then run it, okay. So make sure you switch to manual execution, that's very important, and then let me clear the search here by clicking the little X and then next one that I want to bring in is called Document.BackgroundOpen and that's part of the Rhythm package. So I'm just typing the word background to access that or you could certainly go in the library and browse for it manually in the Rhythm branch. So I'll take my list here and I'll feed that into file path.
So that will open up all of those files that are on that list. Then what do I want to do with those files? Well, once I open them, I just want to close them. But before we close them, I want to save them. Well both of those things will be achieved with a single node. And that's going to be Document.Close. So if I type the word close, you might have to scroll a little bit to find it or you could type Document.Close because that's the full name of the node. It's also part of Rhythm. Let's put that one over here.
Feed in the list of documents and then this is the most important input right here. If you want to save the files, you have to put a Boolean in there and set it to true. So let me clear this and again you could search for Boolean or it's under Input and Boolean and then just toggle that to true and hook that up to save. Now at this point, we could run the graph and it will complete everything. But I'm going to borrow this Watch Node right here, copy it and paste it with Ctrl + C, Ctrl + V, and I'm going to put that at the end because I like it to report to me how many files it saved once it's done.
So at this point it's a good idea to save this graph. So let me go ahead and save it. And I'll call this Batch Upgrade. And save it. And now we're ready to run it. So just click run here and sit back and watch it update. You might want to go grab a cup of coffee or do something else while it's doing the process and then when you come back, your Watch Node will tell you when it's completed. So you could see here in the Watch Node that it says that nine files were closed. That's kind of my confirmation that the process is complete.
So I could go ahead and close Dynamo. And if we go back to our desktop and open up the Exercise Files folder and take a look, you can see the backup files next to each of the Revit files and that kind of is another indication that the process is complete and all your files have been upgraded.
NOTE: The exercise files for this course can only be opened in the most recent version of Revit (Revit 2017).
Skill Level Appropriate for all
Q: Why can't I earn a Certificate of Completion for this course?
A: We publish a new tutorial or tutorials for this course on a regular basis. We are unable to offer a Certificate of Completion because it is an ever-evolving course that is not designed to be completed. Check back often for new movies.