GetDefinition Method


Get the definition representing this parameter element.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 20.0.0.0 (20.1.1.1)
Since: 2016

Syntax

C#
public InternalDefinition GetDefinition()
Visual Basic
Public Function GetDefinition As InternalDefinition
Visual C++
public:
InternalDefinition^ GetDefinition()

Return Value

The parameter.

Examples

Copy C#
// Check if a given shared parameter in a schedule can vary across groups
public bool CanParamVaryAcrossGroups(ViewSchedule schedule, string sharedParamName)
{
    bool variesAcrossGroups = false;

    int numFields =  schedule.Definition.GetFieldCount();
    // Find the field with the given name
    for (int i = 0; i < numFields; i++)
    {
        ScheduleField field = schedule.Definition.GetField(i);
        if (field.GetName().Contains(sharedParamName))
        {
            // Get the SharedParameterElement from the field's parameter id
            SharedParameterElement spe = schedule.Document.GetElement(field.ParameterId) as SharedParameterElement;
            if (spe != null)
            {
                InternalDefinition definition = spe.GetDefinition();
                variesAcrossGroups = definition.VariesAcrossGroups;
            }
        }
    }

    return variesAcrossGroups;
}
Copy VB.NET
  ' Check if a given shared parameter in a schedule can vary across groups
  Public Function CanParamVaryAcrossGroups(schedule As ViewSchedule, sharedParamName As String) As Boolean
   Dim variesAcrossGroups As Boolean = False

   Dim numFields As Integer = schedule.Definition.GetFieldCount()
   ' Find the field with the given name
   For i As Integer = 0 To numFields - 1
      Dim field As ScheduleField = schedule.Definition.GetField(i)
      If field.GetName().Contains(sharedParamName) Then
         ' Get the SharedParameterElement from the field's parameter id
         Dim spe As SharedParameterElement = TryCast(schedule.Document.GetElement(field.ParameterId), SharedParameterElement)
         If spe IsNot Nothing Then
            Dim definition As InternalDefinition = spe.GetDefinition()
            variesAcrossGroups = definition.VariesAcrossGroups
         End If
      End If
   Next

   Return variesAcrossGroups
End Function

See Also