ExternalDefinition Class


The ExternalDefinition object adds properties specific to Autodesk Revit shared parameter definitions.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)

Syntax

C#
public class ExternalDefinition : Definition, 
	IDisposable
Visual Basic
Public Class ExternalDefinition _
	Inherits Definition _
	Implements IDisposable
Visual C++
public ref class ExternalDefinition : public Definition, 
	IDisposable

Remarks

The ExternalDefinition object can be created by a definition Group object from a shared parameters file. External parameter definition must belong to a Group which is nothing more than a collection of shared parameter definitions. The following process should be followed to add a parameter to an element: Open the shared parameters file, via the Application.OpenSharedParameterFile() method. Access an existing or create a new group, via the DefinitionFile.Groups property. Access an existing or create a new external parameter definition, via the DefinitionGroup.Definitions property. Create a new Binding object with the categories to which the parameter will be bound using an InstanceBinding or a TypeBinding object. Finally add the binding and definition to the document using the Document.ParameterBindings object.

Examples

Copy C#
private void ReadEditExternalParam(DefinitionFile file)
{
    // get ExternalDefinition from shared parameter file
    DefinitionGroups myGroups = file.Groups;
    DefinitionGroup myGroup = myGroups.get_Item("MyGroup");
    if (myGroup != null)
    {
         ExternalDefinition myExtDef = myGroup.Definitions.get_Item("MyParam") as ExternalDefinition;
         if (myExtDef != null)
         {
             DefinitionGroup newGroup = myGroups.get_Item("AnotherGroup");
             if (newGroup != null)
             {
                 // change the OwnerGroup of the ExternalDefinition
                 myExtDef.OwnerGroup = newGroup;
             }
         }
    }
}
Copy VB.NET
Private Sub ReadEditExternalParam(file As DefinitionFile)
    ' get ExternalDefinition from shared parameter file
    Dim myGroups As DefinitionGroups = file.Groups
    Dim myGroup As DefinitionGroup = myGroups.Item("MyGroup")
    If myGroup IsNot Nothing Then
        Dim myExtDef As ExternalDefinition = TryCast(myGroup.Definitions.Item("MyParam"), ExternalDefinition)
        If myExtDef IsNot Nothing Then
            Dim newGroup As DefinitionGroup = myGroups.Item("AnotherGroup")
            If newGroup IsNot Nothing Then
                ' change the OwnerGroup of the ExternalDefinition
                myExtDef.OwnerGroup = newGroup
            End If
        End If
    End If
End Sub

Inheritance Hierarchy

System Object
Autodesk.Revit.DB Definition
Autodesk.Revit.DB ExternalDefinition

See Also

ArchiLabs

Stop fighting Revit automation.

Build repeatable BIM design and documentation workflows with scripts, data, and AI in one place, without wrestling brittle one-off automations.

Try ArchiLabs →