Revit 2010 supports

OmniClass codes
.
The Revit Architecture help provides the following background information on these codes in the section on Preparing Content for Sharing with Autodesk Seek, which is currently only available in the English edition:

OmniClass is a new classification system for the construction industry. The Autodesk Seek website uses codes from OmniClass Table 23 to filter and identify shared content. A code consists of an OmniClass number and title.

If an OmniClass code is not already assigned to a family, you are prompted to assign one during the sharing process. However, you can continue to share with Autodesk Seek without defining one. All Revit families have parameters for assigning an OmniClass code, except for the System and Annotation families.

You can access the OmniClass Number and OmniClass Title parameters in the Family Category and Parameters dialog under Family Parameters. See Family Category and Parameters.

Question:
How can I retrieve all available OmniClass numbers and their descriptions from a model?
I also need to retrieve the OmniClass numbers from the elements in the model.

I am using the export to ODBC functionality in Revit Architecture to find relevant data.
The export process produces an OmniClassNumbers table.
You can see the OmniClass numbers in the Revit user interface by opening a family drawing and clicking on the Category and Parameters tool.
The OmniClass Number field is displayed in Family Parameters in the bottom section of that window.
The resulting dialog displays the same data as that exported to the OmniClassNumbers table by the built in tool.

I need to

  1. Acquire the data already exported to the OmniClassNumbers table by the built in tool.
  2. Determine what OmniClass an element or type belongs to

Answer:
The Revit API defines two built-in parameters for accessing the OmniClass data:

  • OMNICLASS_CODE
  • OMNICLASS_DESCRIPTION

We can extract these parameter values for the elements which are contained in the model.
Some of these elements may already be present as instances in the model, some may be part of the template that was used to create it, and some may have been loaded into it as families.

Below is a piece of code to filter out all the elements in the model which have OmniClass data available. First, we define two class variables for the built-in parameters of interest:


BuiltInParameter _bipCode
  = BuiltInParameter.OMNICLASS_CODE;
 
BuiltInParameter _bipDesc
  = BuiltInParameter.OMNICLASS_DESCRIPTION;

Then we can implement an external command class with the following code in its Execute method, which produces the same data as the Revit exported ODBC data from the user interface:


Application app = commandData.Application;
Document doc = app.ActiveDocument;
 
List<Element> set = new List<Element>();
 
ParameterFilter f
  = app.Create.Filter.NewParameterFilter(
    _bipCode,
    CriteriaFilterType.NotEqual,
    string.Empty );
 
ElementIterator it = doc.get_Elements( f );
 
using( StreamWriter sw
  = File.CreateText( "C:/omni.txt" ) )
{
  while( it.MoveNext() )
  {
    Element e = it.Current as Element;
    sw.WriteLine( string.Format(
      "{0} code {1} desc {2}",
      Util.ElementDescription( e ),
      e.get_Parameter( bipCode ).AsString(),
      e.get_Parameter( bipDesc ).AsString() ) );
  }
  sw.Close();
}
return IExternalCommand.Result.Failed;

We use a highly efficient Revit API filter to select only those elements which have a non-empty OmniClass code. For those elements, the code and description is extracted from the element parameters and logged to a text file.

This code also demonstrates how to extract the built-in OmniClass parameters from any given individual element.

Many thanks to Saikat Bhattacharya for handling this case!

Revit 2010 Product Feature Recordings

There are a number of YouTube recordings available discussing and demonstrating new Revit 2010 product features. Here is a list of some of them:

  • Revit Structure 2010

  • Comments

    10 responses to “Omni Class Numbers”

    1. Steve Kimling Avatar
      Steve Kimling

      While the above example extracts the “used” Omni Class numbers from the elements, it does not produce the same result as the built in tool. For example, if this process is used on a 2009 revit drawing that has been converted to 2010 it will find nothing, while for the same drawing, the export utility fills the OmniClassNumbers table with all available codes.
      I have asked how the built in tool does that, but have as yet not gotten a response.

    2. Dear Steve,
      Thank you for the update, and yes, I saw your query. Saikat is exploring this issue further.
      Cheers, Jeremy.

    3. Steve Germano Avatar
      Steve Germano

      Hi Jeremy,
      I see how your code queries the information, but is it possible to write/overwrite the Omniclass code and description to a family?

    4. Dear Steve,
      As far as I know you can specify any OmniClass code you like when you define your own family, so you should have complete control over it at that point.
      Have you looked at the file OmniClassTaxonomy.txt in the Program subdirectory of the Revit installation folder?
      Cheers, Jeremy.

    5. Dear Jeremy,
      I’ve looked the OmniClassTaxonomy.txt file in the subdirectory of Revit and I have two questions:
      The first, the numerical codes contained in this text file (in the Revit 2011) and the official ones (www.omniclass.org) do not match. Do you know why?
      The second one, if you change the values of the codes in this file then the relationship will turn into a non standarized one. Am I right?
      Regards, Gons.

    6. Dear Gons,
      Nope, I do not know why the codes used by Revit do not match the ones defined by http://www.omniclass.org.
      And yes, I assume you are right, but I am not a product usage expert, so you would be better advised to ask someone more knowledgeable than me.
      Cheers, Jeremy.

    7. Hi Gons, Jeremy,
      Revit 2011 seems to use the older OmniClass Table 23 from 28/3/2006, not the updated version from 24/6/2010 published on http://www.omniclass.org.
      http://www.omniclass.org/tables/OmniClass_23_2006-03-28.pdf
      Best Wishes
      Peter Walsham

    8. Dear Ericakoe,
      Thank you for the pointer to the Revit Genome Project. I cannot say much about it, being purely API focused. Looks commendable :-)
      Cheers, Jeremy.

    9. Hi Jeremy;
      i m trying to find omniclass number product table 23 List.
      because if i can find this *.txt file i will exchange with budget codes product of our company.. are there any path on the revit program files???

    Leave a Reply

    Discover more from Autodesk Developer Blog

    Subscribe now to keep reading and get access to the full archive.

    Continue reading