ricaun.Revit.FileInfo
library allows to check the version of an Autodesk Revit file (.rvt, .rfa, .rte, .rft)
without opening.
<PackageReference Include="ricaun.Revit.FileInfo" Version="*" />
using ricaun.Revit.FileInfo;
RevitVersion revitVersion = RevitFileInfo.GetRevitVersion(filePath);
or
RevitFileInfo revitFileInfo = new RevitFileInfo(filePath);
bool isValid = revitFileInfo.IsValid;
RevitVersion revitVersion = revitFileInfo.Version;
IsValid
: Check if the file is a valid Revit file extension.(.rvt, .rfa, .rte, .rft)
Version
: Get theRevitVersion
of the file.RevitVersion
is anint
with the default value zero orRevitVersion.Unknown
.
To find the version of the Revit file the BasicFileInfoUtils
is used, and a regex is used to find the version in te Revit Build:
or Format:
info.
- Revit 2018 and below:
Revit Build: Autodesk Revit 2018 (Build: 20170106_1515(x64))
. - Revit 2019 and above:
Format: 2019
.
A Unit test is used to check if the regex is working correctly between the different Revit file versions (2014-2024)
.
This project was inspired by the following projects:
This project is licensed under the MIT Licence.
Do you like this project? Please star this project on GitHub!