AddFormulaParameter Method


Add a formula-driven parameter to the shape definition.

Namespace: Autodesk.Revit.DB.Structure
Assembly: RevitAPI (in RevitAPI.dll) Version: 21.0.0.0 (21.1.1.109)
Since: 2009

Syntax

C#
public void AddFormulaParameter(
	ElementId paramId,
	string formula
)
Visual Basic
Public Sub AddFormulaParameter ( _
	paramId As ElementId, _
	formula As String _
)
Visual C++
public:
void AddFormulaParameter(
	ElementId^ paramId, 
	String^ formula
)

Parameters

paramId
Type: Autodesk.Revit.DB ElementId
The parameter. To obtain the id of a shared parameter, call RebarShapeParameters.GetElementIdForExternalDefinition.
formula
Type: System String
The formula expressed as a string. The string is exactly what a user would type into the Family Types dialog, e.g. "Total Length*3.14159*(Bar Diameter/2)*(Bar Diameter/2)"

Remarks

Like AddParameter(), this function introduces a parameter into the shape definition, but the parameter's value is driven by a formula. Formula parameters cannot be used in constraints to drive the shape. The formula is in the same format as in Revit families. The formula is allowed to refer to other parameters that are already in the definition, plus the builtin parameters REBAR_INSTANCE_BAR_DIAMETER, REBAR_INSTANCE_BEND_DIAMETER, REBAR_SHAPE_START_HOOK_LENGTH, REBAR_SHAPE_START_HOOK_OFFSET, REBAR_SHAPE_PARAM_START_HOOK_TAN_LEN, REBAR_SHAPE_PARAM_END_HOOK_TAN_LEN, REBAR_SHAPE_END_HOOK_LENGTH, REBAR_SHAPE_END_HOOK_OFFSET, REBAR_ELEM_LENGTH, REBAR_ELEM_TOTAL_LENGTH, and REBAR_ELEM_QUANTITY_OF_BARS.

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException paramId is not the id of a shared parameter in the current document, or its unit type is not UT_Reinforcement_Length or UT_Angle. -or- The name of a shared parameter identified by paramId was already used by another shared parameter of the element.
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was NULL
Autodesk.Revit.Exceptions DisabledDisciplineException None of the following disciplines is enabled: Structural.

See Also