<aside> <img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/0226f9a5-e9a4-486c-9d59-df73c9759e47/arrows-se.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/0226f9a5-e9a4-486c-9d59-df73c9759e47/arrows-se.png" width="40px" /> The pyRevit CLI can easily extract this information from Revit models, see Extract Model Metadata
</aside>
If you are writing your own applications, you can also use the pyRevitLabs API to get the model info using the RevitModelFile class.
// add reference to pyRevitLabs.TargetApps.Revit.dll
using pyRevitLabs.TargetApps.Revit;
try {
var model = new RevitModelFile(rvtFilePath);
// print model info in pyrevit cli tool
Console.WriteLine(string.Format("Workshared: {0}", model.IsWorkshared ? "Yes" : "No"));
Console.WriteLine(string.Format("Central Model Path: {0}", model.CentralModelPath));
Console.WriteLine(string.Format("Last Saved Path: {0}", model.LastSavedPath));
Console.WriteLine(string.Format("Document Id: {0}", model.UniqueId));
Console.WriteLine(string.Format("Open Workset Settings: {0}", model.OpenWorksetConfig));
Console.WriteLine(string.Format("Document Increment: {0}", model.DocumentIncrement));
if (model.IsFamily) {
Console.WriteLine("Model is a Revit Family!");
Console.WriteLine(string.Format("Category Name: {0}", model.CategoryName));
Console.WriteLine(string.Format("Host Category Name: {0}", model.HostCategoryName));
}
} catch {
// not a revit file
}
You can use the same services in python (with .NET bingings e.g. IronPython, CPython with pythonnet)
# add reference to pyRevitLabs.TargetApps.Revit.dll
import clr
clr.AddReference('pyRevitLabs.TargetApps.Revit')
import pyRevitLabs.TargetApps.Revit as revit
try:
model = revit.RevitModelFile(rvtFilePath)
# print model info in pyrevit cli tool
print("Workshared: %s" % "Yes" if model.IsWorkshared else "No")
print("Central Model Path: %s" % model.CentralModelPath)
print("Last Saved Path: %s" % model.LastSavedPath)
print("Document Id: %s" % model.UniqueId)
print("Open Workset Settings: %s" % model.OpenWorksetConfig)
print("Document Increment: %s" % model.DocumentIncrement)
if model.IsFamily:
print("Model is a Revit Family!")
print("Category Name: %s" % model.CategoryName)
print("Host Category Name: %s" % model.HostCategoryName)
except:
# not a revit file
# raise exception? log error?