I have recently been looking into obtaining file size for a Revit project. It’s one of these file size tracking dashboards that everyone seems to have handy these days that I was working on, and realized that I am not getting proper reports from a BIM 360 model. Lo and behold, it turns out there is no API for that sucker, and according to this post: Dynamo BIM Forum, we can obtain that info from two sources: Jurnal Files and Local Cache for Collaboration For Revit. Yeah, I am lazy so I went ahead and used the answer provided in the before mentioned post, but in C#. I also combined that with two other methods that I already had for tracking Revit Server file sizes, and regular Central Models:
Now that we have a file size we could post it to a database, or toss it into some dashboard tool of your choice. One thing worth noting here is the REST API call to Revit Server to get the file size. Here’s the code:
I am using RestSharp to create that call so make sure to have that referenced.
One more thing worth noting, is that the file size that we are getting is in bytes, so we must convert that value to something human readable: KiB, MiB, GiB etc. Here’s a utility for that, and something to remember: file sizes are actually represented in powers of 1024 bytes and not 1000. Just an FYI.
All right I hope this was helpful to someone.
Per comment below from Dale Bartlett:
Hi Konrad, Interesting article, but I am not sure to what RsFileInfo refers in fileInfo.cs. Are you able to clarify? Regards.
I am indeed guilty of not mentioning what happens in that call. So, we make a call to Revit Server and ask it to give us information about the file. It will return that information in a specific format, that then can be parsed from JSON into a class with bunch of properties. Such class looks like this: