Get Element Type

In the Revit 2011 API, the Symbol class was been renamed to ElementType and some other changes were made to clarify the usage of element types in Revit, which were previously referred to as both types and symbols. Some remnants of the previous naming conventions still exists, such as the FamilySymbol class and the FamilyInstance.Symbol property, but the long-term intention is to move toward calling these things element types instead of symbols.

This renaming and restructuring has causes some confusion here and there in porting existing applications, giving rise to questions such as the following:

Question: I have been updating my Revit 2010 API code to the 2011 version and realized that the Element.ObjectType property no longer exists.

I want to retrieve the AssemblyCode value from the element type properties in the Revit project. Here is the old code for the Revit 2010 API:

  string assembly_code
    = e.ObjectType.get_Parameter(
      BuiltInParameter.UNIFORMAT_CODE )

How can I rewrite this code for Revit 2011?

Answer: The first place to look in cases like this is the What's New section of the Revit API help file RevitAPI.chm, which includes the following section:

Replacement for Symbol and properties that access types

The Symbol class has been renamed to ElementType.

The properties that access types from Elements have been replaced:

So you can simply use GetTypeId and then open the associated ElementType object to access the parameter.

Some samples of using these new methods are given in the discussions on

The code that you show above can thus be rewritten as follows for the Revit 2011 API:

  ElementId id = e.GetTypeId();
  ElementType type = m_doc.get_Element( id )
    as ElementType;
  string AssemblyCode = type.get_Parameter(
    BuiltInParameter.UNIFORMAT_CODE )