- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
Does anyone know if it is possible to access the revit api / .rvt files outside of opening revit? Here is some sample code of what I am trying to do:
public void getRooms()
{
Document doc = this.ActiveUIDocument.Document;
showCount(doc);
Autodesk.Revit.ApplicationServices.Application app = this.Application;
UIApplication uiapp = new UIApplication(app);
doc = uiapp.OpenAndActivateDocument("C:/myRevitProject.rvt").Document;
showCount(doc);
}
public void showCount(Document doc)
{
FilteredElementCollector roomCollector = new FilteredElementCollector(doc);
roomCollector = roomCollector.OfCategory(BuiltInCategory.OST_Rooms);
int count = 0;
foreach(Element room in roomCollector)
{
count ++;
}
TaskDialog.Show("count", count.ToString());
}This code simply shows how many rooms in the current active document, then also shows how many rooms are in a file of your choice. I wanted to expand this so that you could run the plugin from a file, and it would crawl through my company's file system and post data to either an excel sheet or a mysql database.
However I came across certain files where an error dialog or warning pops up, which would require a user to click out of it for the plugin to continue its work. This is where I thought it would be ideal to not even 'open and activate' each file, but rather get the data out without opening the revit file. However, this doesn't seem possible. Please tell me it is 🙂
Solved! Go to Solution.