InstanceBinding Class


Instance Binding Class

The InstanceBinding object is used to signify a binding between a parameter definition and a parameter on each instance of an element, such as a wall.
Inheritance Hierarchy

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public class InstanceBinding : ElementBinding

The InstanceBinding type exposes the following members.

Constructors
Name Description
Public method InstanceBinding Constructs an empty instance binding.
Public method InstanceBinding(CategorySet) Constructs an instance binding with the set of categories passed.
Top
Properties
Name Description
Public property Categories Retrieve or set the categories to which a parameter definition will be bound.
(Inherited from ElementBinding )
Public property Code example IsReadOnly Identifies if the object is read-only or modifiable.
(Inherited from APIObject )
Top
Methods
Name Description
Public method Dispose Causes the object to release immediately any resources it may be utilizing.
(Inherited from APIObject )
Public method Equals Determines whether the specified object is equal to the current object.
(Inherited from Object )
Public method GetHashCode Serves as the default hash function.
(Inherited from Object )
Public method GetType Gets the Type of the current instance.
(Inherited from Object )
Public method ToString Returns a string that represents the current object.
(Inherited from Object )
Top
Remarks
Once bound the parameter will appear on all instance of the element and changing the parameter on any one single instance will not change the value on any other instance.
Example
public bool SetNewParameterToInstanceWall(UIApplication app, DefinitionFile myDefinitionFile)
{
    // create a new group in the shared parameters file
    DefinitionGroups myGroups = myDefinitionFile.Groups;
    DefinitionGroup myGroup = myGroups.Create("MyParameters1");

    // create an instance definition in definition group MyParameters
    ExternalDefinitionCreationOptions option = new ExternalDefinitionCreationOptions("Instance_ProductDate", SpecTypeId.String.Text);
    // Don't let the user modify the value, only the API
    option.UserModifiable = false;
    // Set tooltip
    option.Description = "Wall product date";
    Definition myDefinition_ProductDate = myGroup.Definitions.Create(option);

    // create a category set and insert category of wall to it
    CategorySet myCategories = app.Application.Create.NewCategorySet();
    // use BuiltInCategory to get category of wall
    Category myCategory = Category.GetCategory(app.ActiveUIDocument.Document, BuiltInCategory.OST_Walls);


    myCategories.Insert(myCategory);

    //Create an instance of InstanceBinding
    InstanceBinding instanceBinding = app.Application.Create.NewInstanceBinding(myCategories);

    // Get the BingdingMap of current document.
    BindingMap bindingMap = app.ActiveUIDocument.Document.ParameterBindings;

    // Bind the definitions to the document
    bool instanceBindOK = bindingMap.Insert(myDefinition_ProductDate,
                                    instanceBinding, GroupTypeId.Text);
    return instanceBindOK;
}
See Also