After reading about using Revit journal files to upgrade and purge Revit families, I decided to have a go at applying the same thought to automate one of my most hated processes – converting imperial files to metric.
The original article posted at Revit Randoms gave a quick template to get me started. The original ZIP file is located here.
A post on Reddit actually prompted me to complete this post, because the question on Reddit was related to templates, I’ll use template files in this example but you could apply to family or project files.
Firstly, I started with the batch file changing it to create a list file of RTE files which now looks like so
cd . del /s /F *.0*.rte
dir /B /S *.rte > RTE_to_metric_list.txt
The next step was to modify the provided script text file to suit my needs. Firstly I needed to change the line of code that loads the list of files to be modified, so I change the line
to
Because in the instance I didn’t want to purge the files that I was converting to metric, the next step was to remove all the lines related to loading and purging family files.
So then I needed the code to convert my files to metric. To do this it is as simple as running through the process manually in Revit and then taking the code straight from the Revit Journal file itself. I went through the long and arduous process of converting a file from imperial to metric units, all going well it would be the very last time. At the end, I also saved the file to get the code to save the file as the relevant file type, in this case a template file.
The next step was to hunt down the Revit journal files. The location of the journal files are outlined in the Autodesk Knowledge Centre. In my case I was using Revit 2014 on Windows 7 so my journal files were located in %LOCALAPPDATA%\Autodesk\Revit\Autodesk Revit 2014\Journals
Using Notepad++ I scanned through the journal file looking for lines related to the changing of units. Finally I spotted repetitive lines that looked something like this
Jrn.Data “File Name” _
, “IDOK”, “.\PURGE.rfa”
Jrn.Data “FileExternalTypes” _
, “”
Jrn.Data “Transaction Successful” _
, “Load Family”
Jrn.RibbonEvent “TabActivated:Manage”
Jrn.Command “Internal” , “Purge (delete) unused families and types , ID_PURGE_UNUSED”
Jrn.PushButton “Modal , Purge unused , Dialog_Revit_PurgeUnusedTree” _
, “Check All, Control_Revit_CheckAll”
Jrn.PushButton “Modal , Purge unused , Dialog_Revit_PurgeUnusedTree” _
, “OK, IDOK”
Jrn.Data “Transaction Successful” _
, “Purge unused”
I selected everything in the journal related to changing of units and pasted them into the script.
Next, I needed to change the line that saves the files as a family to saving as a template, again digging through the journal file I found where I had saved my file and changed the line
to
Once done, I simply needed to drag and drop my script onto the Revit icon and watch the magic happen.
Hey Can you please share the modified scripts
Hi Raghu,
Thanks for letting me know that the link was broken. I’ve updated the link in the post.
I have provided an update to work with 2015 and 2016 here https://www.revit.com.au/?p=2476
Hi Ryan, thanks for sharing. It is a very handy tool and it opened my eyes into the world of the journal file. I modified it to convert a big library from mm to m but found the tool crashing eventually, which meant having to find out the last updated family and editing the list to restart the process from there. After a while I realised that your script was not closing the files after saving the changes, so it would eventually run out of RAM. I added one line of code (right before the last line) and now it works perfectly with any size library I throw at it:
Jrn.Command “Ribbon” , “Close the active project , ID_REVIT_FILE_CLOSE”
However, I can’t figure out how to make it stop crashing when it finds a file already set to m. Any ideas?
Hi Ryan,
Thanks for sharing.
I would be grateful if you could share for metric to imperial as well.
Thanks 🙂
Hi Wai,
It already batch converts to imperial 🙂