Journal File Magic & Exporting Groups to File (part 2)

The first thing to do, is take the cleaned journal file created in the previous post and see if it will run in Revit. So drag the .txt file onto the Revit shortcut on your desktop and see what happens.

Hmmm. That’s not great. So open up the newly created journal file and search for “journal file playback”

“Data missing from file follows” means that when the journal was being replayed, something happened that was not found in the journal file. In this case, it is the task dialog informing us that there is an existing file and asking if it should be replaced.

Which is correct, that didn’t occur when I first recorded the journal file and now it does occur because that file does exist. This is an important lesson about the brittleness of journal file replay. If something happens (or doesn’t happen) that doesn’t match up with what the journal file says should happen, then the journal replay will stop. With the API, we can much more flexibly handle situations like this, but not with journal replay.

So delete the existing group RVT file and try the replay again. This time it works! Revit launches, opens the RVT, saves the group RVT, and the Revit session exits.

The next thing to do is figure out what we are going to modify in the journal to select different groups to save. Because while in the UI there is a “Group to Save” dropdown list that lists the groups by name, the journal file does not name the group in the same way, it instead has a numeric index that represents the group to save.

The next important thing to know is that Revit will run VBScript as part of journal file replay! So read a good article about looping structures in VBScript (like https://www.w3schools.com/asp/asp_looping.asp) and come back for the next post in the series to see what to do next.

Journal File Magic & Exporting Groups to File (part 1)

The Revit API does not provide access to the “Save As – Group” command, but maybe you have a lot of groups that you want to export. One approach to consider it modifying a journal file to automate the process. This is a somewhat brittle approach that can’t always be used when the API comes up short, but it is nice when it works.

To get started, I opened an RVT, exported a group, and exited from Revit. This creates a journal file in C:\Users\harry\AppData\Local\Autodesk\Revit\Autodesk Revit 2024\Journals

But that journal file has a ton of stuff (it is a 294KB file!) So the first step is to remove all the comments (the lines that start with a single quote ‘ character or some spaces then a ‘) and also lines that start with Jrn.Directive and some other entries that we don’t care about.

Here is a tool to cleanup that journal file and get rid of a lot of stuff that isn’t helpful for this exercise

https://bitbucket.org/BoostYourBIM/journalcleaner/src/master/JournalCleaner/bin/Release/net6.0/publish/win-x86/ – click on “view raw” to download the file

Put JournalCleaner.exe in the same folder as one or more journal files, run the command, and for each journal file it will create a “cleaned” version of the journal. In this case, we gone from a 2,500 line journal file, to one with only a couple dozen lines!


Dim Jrn
Set Jrn = CrsJournalScript
Jrn.Data _
“JournalDefaultTemplate” , “Imperial Multi-discipline=$AllUsersAppData\Templates\English-Imperial\Default-Multi-discipline.rte, Metric Multi-discipline=$AllUsersAppData\Templates\English\Default-Multi-Discipline_Metric.rte”
Jrn.Data _
“JournalDefaultViewDiscipline” , “Coordination”
Jrn.Command “Internal” , “Display Profile Dialog , ID_DISPLAY_PROFILE_DIALOG”
Jrn.Command “Internal” , ” , ID_REVIT_MODEL_BROWSER_OPEN”
Jrn.Command “Ribbon” , “Model Browser , ID_REVIT_MODEL_BROWSER”
Jrn.Command “Ribbon” , “Open an existing project , ID_REVIT_FILE_OPEN”
Jrn.Data _
“File Name” , “IDOK” , “..\..\..\..\..\..\Documents\groups.rvt”
Jrn.Data _
“WorksetConfig” , “Custom” , 0
Jrn.LButtonUp 0 , 453 , 206
Jrn.Data _
“DroppedMouseAction” , “no active editor”
Jrn.Command “Ribbon” , “Save a loaded group , ID_SAVE_GROUP”
Jrn.Data _
“Save Group File Name” , “..\..\..\..\..\..\Documents\Same as group name.rvt”
Jrn.Data _
“Save Group Index” , “0”
Jrn.Data _
“Save Group Include Attached” , “1”
Jrn.Data _
“Transaction Successful” , “Create Type Previews”
Jrn.Data _
“Transaction Successful” , “Save a loaded group”
Jrn.Data _
“Transaction Successful” , “Save a loaded group”
Jrn.Command “Internal” , “Quit the application; prompts to save projects , ID_APP_EXIT”
Jrn.Command “Internal” , ” , ID_REVIT_MODEL_BROWSER_OPEN”

In the next post, we will talk about a bit more manual cleanup to this journal file, and then how to read data from external file and more magic.