Tuesday, January 11, 2011

Retrieving a wall's Function Parameter (BuiltInParameter.FUNCTION_PARAM)

For part of a large Revit material-gathering project I'm working on, I need to retrieve a wall's function. Walls can be assigned six functions from within their type properties:

  • Interior
  • Exterior
  • Foundation
  • Retaining
  • Soffit
  • Core-Shaft

At first I thought it would be fairly straight-forward, and I'd just do this grab the valuestring of the 'FUNCTION_PARAM' like so:


But that gave me a NULL value and crashed Revit. The approach that worked for me was this:

static public string IsExterior(Element e, Document doc)
    ElementId id = e.GetTypeId();
    ElementType wallType = doc.get_Element(id) as ElementType;

    Parameter wallFunction = wallType.get_Parameter
    WallFunction value  = (WallFunction)wallFunction.AsInteger();

    return value.ToString();
Thanks to Jeremy Tammik's SDK example for setting me straight.

No comments:

Post a Comment