Set(FieldType) Method (String, FieldType, ForgeTypeId)


Stores the value of the field in the entity.

Namespace: Autodesk.Revit.DB.ExtensibleStorage
Assembly: RevitAPI (in RevitAPI.dll) Version: 24.0.0.0 (24.0.0.0)
Since:  2012

Syntax

C#
public void Set<FieldType>(
	string fieldName,
	FieldType value,
	ForgeTypeId unitTypeId
)
Visual Basic
Public Sub Set(Of FieldType) ( _
	fieldName As String, _
	value As FieldType, _
	unitTypeId As ForgeTypeId _
)
Visual C++
public:
generic<typename FieldType>
void Set(
	String^ fieldName, 
	FieldType value, 
	ForgeTypeId^ unitTypeId
)

Parameters

fieldName
Type: SystemString
The name of the field to update.
value
Type: FieldType
unitTypeId
Type: Autodesk.Revit.DBForgeTypeId
Identifier of the unit from which the value will be converted before storing. Must be compatible with the spec specified when creating the Schema.

Type Parameters

FieldType
The type of the field

Remarks

The template parameter must match the type of the field (specified when creating the Schema) exactly; this method does not perform data type conversions. The types for containers are IList for arrays and IDictionary for maps.

This method only modifies your copy of the Entity. Store the Entity in an element or another Entity to save the new value. Write access check is not performed on each call to Set. Instead, write access is checked when you try to save the Entity in an Element or another Entity.

This method is a shortcut that will look up the field by name. If you want to call it on many entities, it is faster if you look up the field yourself.

Exceptions

ExceptionCondition
Autodesk.Revit.ExceptionsArgumentNullException A non-optional argument was NULL
Autodesk.Revit.ExceptionsInvalidOperationException The Field belongs to a different Schema from this Entity, or this Entity is invalid.
Autodesk.Revit.ExceptionsArgumentException Requested type does not match the field type.
Autodesk.Revit.ExceptionsArgumentException The name matches no field in this Entity's Schema.
Autodesk.Revit.ExceptionsArgumentException The unitTypeId value is not compatible with the field description.
Autodesk.Revit.ExceptionsArgumentException This field's subschema prevents writing.
Autodesk.Revit.ExceptionsArgumentException Invalid floating-point value.

See Also