Last weekend I traveled to Medellin – Colombia, as one of my colleagues called it, “High tech capital of northern South America” and boy, he was right about it.
I arrived after a connection from JFK to Bogota, on Wednesday the 14th. The reason of my travel, well I was selected to be a Speaker and to give a work shop at the conference (happening for the 2nd time in Medellin, more details here JsConfCo). A weekend full of activities kicked off with DevFest on Thursday, and the Workshop day for the JSConf on Friday. I had the chance to share my knowledge using the View and Data API (WebGL and Three.js based) and demonstrate through a couple of steps how easy is to now add 3D content to your websites. After a 1 hour and a half workshop, the feedback started to be shown in, what is now one of my favorite social networks, Twitter. The comments were very encouraging to continue what I’ve been doing and Colombians reminded me of the people from my home country. So eager to learn, to achieve more and demonstrate what Colombia has to offer in the Technology field.
Medellin, it is a beautiful place in Colombia, Coffee is amazing and Technology definitely is overcoming their dark past, and trust me it looks pretty good. I’m very thankful to the organizers of jsconfco, and the attendees who gave me the opportunity of sharing a bit of my knowledge with 3D web, and looking forward to see them in the near future, once again Gracias Parses!
Ok, enough of my traveling, Let’s get back to Revit API. This week I’ve been helping a developer with a plugin to export to gbXML from the API. Also, there was another case with a very similar question.I will post both questions and both responses which target to the same code answer.
1st case Question:In Revit 2016, the gbXML export through the Document.Export function appears to generate a faulty XML file. In the attached example, an XML file with only one room is generated even though the project contains three rooms. Exporting through the Revit export menu generates the correct XML file with three rooms. In Revit 2015, the problem does not occur -- both XML files are identical. Here's the code used in our application to start the gbXML export in Revit 2016:
GBXMLExportOptions gbxmloptions = new GBXMLExportOptions();
// new in Revit 2016:
EnergyAnalysisDetailModelOptions energyOptions= new EnergyAnalysisDetailModelOptions();
bool exported = doc.Export(exportFolder, filename, gbxmloptions);
Why is the gbXML file created this way incomplete?
1st case Answer: After reaching out to our Revit Engineers, they have confirmed that your 2016 models are saved with a stale energy model (with only 1 analytical space in it). They suggested to as a best practice always regenerate the energy model before exporting it to gbXML. Here is a snippet of code they provided in order to do so. I have already tested and I can confirmed the fix on it.
public Result Execute(
ref string message,
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
GBXMLExportOptions gbxmloptions =
// regenerate energy model
EnergyAnalysisDetailModel eadm =
if (eadm != null)
// new in Revit 2016:
EnergyAnalysisDetailModelOptions energyOptions =
bool exported = doc.Export
("C:\\Desktop", "FixingModelSample2016", gbxmloptions);
Please try it and let me know.
1st case Response: That worked, thank you problem solved!
So 1 out of 2 cases done.
2nd case Question:I've had an gbXML export based on the 2015 SDK samples provided by Autodesk, these were located in the "ImportExport" project. And that worked fine in 2015, but when I now use my own export under 2016 it's doesn't work anymore and throws an error "There is no main EnergyAnalysisDetailModel in the document.". I've tried the gbXML export in the 2016 SDK and that throws the same error, so the sample doesn't work anymore either. I've looked at the API changes in 2016 and it say you have to create an EnergyAnalysisDetailModel if you want to export gbXML. So I've added the following code to my project, before calling the export function:
EnergyAnalysisDetailModelOptions energyAnalysisDetailModelOptions= new EnergyAnalysisDetailModelOptions();
EnergyAnalysisDetailModel energyAnalysisDetailModel= EnergyAnalysisDetailModel.Create(m_activeDoc,energyAnalysisDetailModelOptions);
Note that the GbXml get's exported but when I commit my transaction, I get the following warning:
"The energy analysis model does not contain any roof surfaces! If there are roofs in your model, please verify that they are space bounding, and make sure that the space offsets are high enough to include the roofs." What is the best way to create a simple function in Revit 2016 that exports my project to gbXML. I hope you'll have an answer.
2nd case Answer: Thank you for the RVT model you provided. At first sight I can see that you are missing very important things in your model in order to make it available to be Exported as gbXML, how do I know? Well you can try simply exporting it from the UI, and you will notice that there are many alert messages telling you what you are missing in order to be able to export.
When using the command Export > gbXML, there must be rooms or spaces placed in the project. In the Export gbXML dialog you can also choose which project phase to export (the selected phase needs to have rooms/spaces otherwise an error message displays).
In Revit we export the Revit model according to the gbXML schema.
Here you can read more about the process to create and export the right gbXML file.
After modifying your sample model, adding a Room and a Roof to it, and also making sure the Room Bounding is setup correctly, I'm able to export your model both from UI and the Code I provided you. Best practice will be, Do it first from the UI, so you can make sure there is a good chance it will work from your code. Other than that you tend to be shooting blind. I hope this helps you and please let me know how it goes.
I still haven’t heard back from the developer, I will update the post once I hear back, but for what I can see, everything is working as excepted even when I used the RVT project he provided.
Hope this helps you with your next gbXML exporter plugin. Cheers, until next time.