The Revit 2013 Structure API

I migrated the ADN Revit Structure API training material to Revit 2013, which led me to put together the following summary of the structural API enhancements and some details of the migration steps:

Revit Structure 2013 API Enhancements

I mentioned a few structure specific enhancements in the Revit 2013 API. They are discussed in somewhat more detail in the DevDays Online presentation on What's New in Revit 2013 and the complementary Revit 2013 API webcast, of which the first half provides an introduction to the Revit API in general, and the second covers some new 2013 specific features in more depth.

Actually, it was the webcast preparation that prompted me to start performing the migration described below, which in turn prompted me to publish the result and summarise the changes.

To recap, the structural enhancements include:

Structural Product Related Enhancements

Before we get to the detailed API changes, here are some notes on the main product goals and features:

Reinforcement detailing to help extend the BIM lifecycle from design to construction through detailing and fabrication:

Structural analysis in BIM moving towards delivering structural analysis in the cloud and supporting partner ecosystem growth by

Structural analysis web service and visualisation to democratize analysis and make it more accessible, easy to both use and provide. Long term, we would like to deliver structural analysis in the cloud and thus support partner ecosystem growth. Support for modal and deformation analysis, enhanced results visualization.

Enhanced physical properties to centralize analysis workflows around BIM data and improve the efficiency of BIM-based analysis workflows.

Now let's look at how these changes affect the API:

Reinforcement

The Rebar class provides a number of new methods and properties:

The Rebar.GetCenterlineCurves method takes new arguments to control

The BarDescription class is now obsolete and replaced by the new RebarInSystem class representing a bar in an AreaReinforcement or PathReinforcement system, providing access to individual rebars in a system and the ability to switch back and forth between system and individual elements.

A new class ReinforcementSettings is provided. When ReinforcementSettings.HostStructuralRebar is true, area and path reinforcement elements create individual rebar elements that participate in views and schedules. The individual RebarInSystem elements have the same graphical representation and parameters as Rebar elements, and have the same API methods for inquiry. Since the RebarInSystem elements are almost entirely controlled by their area or path system element, they lack most of the modification methods of the Rebar class.

These two system classes now have types, and provide new members to retrieve system members, curve boundaries, remove an element and convert its bars into standard rebar via the new methods GetRebarInSystemIds, RemoveAreaReinforcementSystem, and RemovePathReinforcementSystem.

Welded Wire Mesh
Physical Properties
Structural Analytical Model
Analysis Visualization Framework
AVF support for deformation

Revit Structure Labs RstLabs Migration

As said, I migrated the Revit Structure API material from 2012 to 2013, starting with the labs RstLabs. The standard steps are getting to be a habit, after already completing the The Building Coder samples, ADN Revit API training labs, AdnRme Revit MEP API and extensible storage samples:

After that, no warnings remain.

There are four errors, though, which all are caused by the removal of the LOAD_USE_LOCAL_COORDINATE_SYSTEM_HOSTED built-in parameter.

Since the parameter value retrieved is not used anywhere and the call is just to demonstrate the retrieval of a parameter value in general, I simply commented out the offending statements.

New Revit Structure Labs NewRstLab Migration

Standard stuff, same as before: change the Revit API assembly references, .NET framework version, and replace the use of the Element property by calls to GetElement.

I also replaced the test for a concrete column by new code, since the MaterialConcrete class no longer exists in Revit 2013. Here is the old code I replaced:

  MaterialSet materials = column.Materials;
 
  MaterialConcrete matConcrete = null;
 
  foreach( Material mat in materials )
  {
    // cast it to concrete material
    matConcrete = mat as MaterialConcrete; 
    break;
  }
  if( null == matConcrete )
  {
    messages = "The selected column is not concrete";
    trans.RollBack();
    return Result.Failed;
  }

The new code is much clearer and simpler:

  if( StructuralMaterialType.Concrete 
    != column.StructuralMaterialType )
  {
    messages = "The selected column is not concrete";
    trans.RollBack();
    return Result.Failed;
  }

Revit Structure AVF and DMU Sample RstAvfDmu Migration

RstAvfDmu is a dual sample by Saikat Bhattacharya on using the analysis visualisation framework AVF and the dynamic model update DMU in the context of Revit Structure.

The only significant change required is due to the GetCenterlineCurves method taking some additional arguments in Revit 2013:

  // For this we first access 
  // the rebar line geometry
 
  //Line rebarLine = rebar.Curves.get_Item( 
  //  0 ) as Line; // 2011
 
  //Line rebarLine = rebar.GetCenterlineCurves( 
  //  false )[0] as Line; // 2012
 
  Line rebarLine = rebar.GetCenterlineCurves(
    false, true, true )[0] as Line; // 2013

Materials

Here is rst_2013_2012-06-12.zip containing the result of my efforts so far, the Revit Structure 2013 versions of RstLabs, NewRstLab and RstAvfDmu.

The Revit Structure link sample RstLink is not yet completed, nor have I yet updated the Revit Structure API slide deck.