External data extraction

External data extraction

Anonymous
Not applicable
1,323 Views
2 Replies
Message 1 of 3

External data extraction

Anonymous
Not applicable

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 🙂

0 Likes
Accepted solutions (1)
1,324 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk
Accepted solution

No, it is not possible to access the Revit API or RVT file contents without opening Revit, with one exception:

 

You can make use of the Forge platform:

 

https://autodesk-forge.github.io/

 

It includes a translator for RVT files which make all the geometry and properties available via Forge.

 

Here is more information on both Forge and Revit I/O:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.28b

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 3

Anonymous
Not applicable

Thanks Jeremy! 

 

Also, for anyone interested I also found this function:

app.OpenDocumentFile(file);

 

rather than using:

uiapp.OpenAndActivateDocument(file)

 

The forge platform may be ideal (as long as I can get data such as rooms, areas etc. However, using app.OpenDocumentFile seems like a quick and dirty fix for me at this time. When using OpenAndActivateDocument, I would sometimes get pop up windows / error messages which need clicked which defeats the point of automation, and I am pretty sure this problem is fixed. 

 

 

0 Likes