Journal File Magic & Exporting Groups to File (the grand finale)

The previous two posts have talked about cleaning up a journal file to remove extraneous data and looking at the Revit UI and journal file output to make educated guesses about how the journal file can be modified to become a more dynamic VBScript file that can do more than the journal file that was created in the initial Revit session.

To wrap this up, first we can remove some more of the unneeded lines from the journal file in this post. Also worth noting that the underscore character (_) is the line continuation character in VBScript. You can remove these and put the multiple lines on a single line of text if that makes it more readable for you. We don’t need these:

  • 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.LButtonUp
  • Jrn.Data _
    “DroppedMouseAction” , “no active editor”

Next, we want to create a For loop around the portion of the journal file that does the group export.

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”

Finally, I wanted to create some variables to store a few key pieces of information that would be changed for different RVT files, just so that it is easier to make these changes without messing up something else in the file

Dim fileName, exportFolder, numberOfGroupsInFile
fileName = "C:\Program Files\Autodesk\Revit 2024\Samples\Snowdon Towers Sample Architectural.rvt"
exportFolder = "C:\Users\harry\Documents\GroupExport\"'
numberOfGroupsInFile = 11

Here’s the finished file!

'
Dim Jrn
Set Jrn = CrsJournalScript
Dim fileName, exportFolder, numberOfGroupsInFile

' DO NOT CHANGE ANYTHING ABOVE THIS LINE ------------

fileName = "C:\Program Files\Autodesk\Revit 2024\Samples\Snowdon Towers Sample Architectural.rvt"
exportFolder = "C:\Users\harry\Documents\GroupExport\"'
numberOfGroupsInFile = 11

' DO NOT CHANGE ANYTHING BELOW THIS LINE ------------

  Jrn.Command "Ribbon"  , "Open an existing project , ID_REVIT_FILE_OPEN" 
  Jrn.Data "File Name"  , "IDOK" , fileName
		  
For i = 0 to numberOfGroupsInFile - 1
  Jrn.Command "Ribbon"  , "Save a loaded group , ID_SAVE_GROUP" 
  Jrn.Data  "Save Group File Name"  , exportFolder & "Same as group name.rvt" 
  Jrn.Data  "Save Group Index"  , i 
  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" 
Next

  Jrn.Command "Internal"  , "Quit the application; prompts to save projects , ID_APP_EXIT" 

Drag and drop that onto your Revit shortcut and get this beautiful result!

One thought on “Journal File Magic & Exporting Groups to File (the grand finale)

Leave a comment