Definition

The Definition object describes the data type, name, and other Parameter details.

There are two kinds of definition objects derived from this object.

You should write the code to use the Definition base class so that the code is applicable to both internal and external parameter Definitions. The following code sample shows how to find a specific parameter using the definition type.

Code Region 8-2: Finding a parameter based on definition type

//Find parameter using the Parameter's definition type.
public Parameter FindParameter(Element element)
{
        Parameter foundParameter = null;
        // This will find the first parameter that measures length
        foreach (Parameter parameter in element.Parameters)
        {
                if (parameter.Definition.ParameterType == ParameterType.Length)
                {
                        foundParameter = parameter;
                        break;
                }
        }
        return foundParameter;
}

ParameterType

This property returns parameter data type, which affects how the parameter is displayed in the Revit UI. Some of the ParameterType enumeration members include:

Member name

Description

Number

The parameter data should be interpreted as a real number, possibly including decimal points.

Moment

The data value will be represented as a moment.

AreaForce

The data value will be represented as an area force.

LinearForce

The data value will be represented as a linear force.

Force

The data value will be represented as a force.

YesNo

A boolean value that will be represented as Yes or No.

Material

The value of this property is considered to be a material.

URL

A text string that represents a web address.

Angle

The parameter data represents an angle. The internal representation will be in radians. The user visible representation will be in the units that the user has chosen.

Volume

The parameter data represents a volume. The internal representation will be in decimal cubic feet. The user visible representation will be in the units that the user has chosen.

Area

The parameter data represents an area. The internal representation will be in decimal square feet. The user visible representation will be in the units that the user has chosen.

Integer

The parameter data should be interpreted as a whole number, positive or negative.

Invalid

The parameter type is invalid. This value should not be used.

Length

The parameter data represents a length. The internal representation will be in decimal feet. The user visible representation will be in the units system that the user has chosen.

Text

The parameter data should be interpreted as a string of text.

MultilineText

The value of this parameter will be represented as multiline text.

FamilyType

A parameter used to control the type of a family nested within another family.

Image

The value of this parameter is the id of an image.

For more details about ParameterType.Material, see Material.

ParameterGroup

The Definition class ParameterGroup property returns the parameter definition group ID. The BuiltInParameterGroup is an enumerated type listing all built-in parameter groups supported by Revit. Parameter groups are used to sort parameters in the Element Properties dialog box.

InternalDefinition

Every Parameter object has an InternalDefinition, which can be obtained from the Definition property. The InternalDefinition represents the parameter definition in the Revit document. In addition to the properties it inherits from Definition, it also has some other key properties.

BuiltInParameter

This property tests whether this definition identifies a built-in parameter or not. For a build-in parameter, this property returns one of the BuiltInParameter enumerated values. For custom-defined parameters, such as shared, global, or family parameters the value will be BuiltInParameter.INVALID.

Id

This property returns the id for the associated ParameterElement if the parameter is not built-in.

VariesAcrossGroups

This property, and the corresponding SetAllowVaryBetweenGroups() method, determine whether the values of this parameter can vary across the related members of group instances. If False, the values will be consistent across the related members in group instances. This can only be set for non-built-in parameters.

Visible

The visible property indicates whether a shared parameter is hidden from the user. This is useful if you wish to add data to an element that is only meaningful to your application and not to the user. This value can only be set when the shared parameter definition is created.