StorageType

StorageType

StorageType describes the type of parameter values stored internally.

Based on the property value, use the corresponding get and set methods to retrieve and set the parameter data value.

The StorageType is an enumerated type that lists all internal parameter data storage types supported by Revit:

Table 16: Storage Type

Member Name

Description

String

Internal data is stored as a string of characters.

ElementId

Data type represents an element and is stored as an Element ID.

Double

Data is stored internally as an 8-byte floating point number.

Integer

Internal data is stored as a signed 32-bit integer.

None

None represents an invalid storage type. For internal use only.

In most cases, the ElementId value is a positive number. However, it can be a negative number. When the ElementId value is negative, it does not represent an Element but has another meaning. For example, the storage type parameter for a beam's Vertical Projection is ElementId. When the parameter value is Level 1 or Level 2, the ElementId value is positive and corresponds to the ElementId of that level. However, when the parameter value is set to Auto-detect, Center of Beam or Top of Beam, the ElementId value is negative.

Figure 27: Storage type sample

The following code sample shows how to check whether a parameter's value can be set to a double value, based on its StorageType:

Code Region 8-4: Checking a parameter's StorageType

public bool SetParameter(Parameter parameter, double value)
{
        bool result = false;
        //if the parameter is readonly, you can't change the value of it
        if (null != parameter && !parameter.IsReadOnly)
        {
                StorageType parameterType = parameter.StorageType;
                if (StorageType.Double != parameterType)
                {
                        throw new Exception("The storagetypes of value and parameter are different!");
                }
 
                //If successful, the result is true
                result = parameter.Set(value);
        }
        
        return result;
}

The Set() method return value indicates that the Parameter value was changed. The Set() method returns true if the Parameter value was changed, otherwise it returns false.

Not all Parameters are writable. An Exception is thrown if the Parameter is read-only.