InstanceBinding 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.

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

Syntax

C#
public class InstanceBinding : ElementBinding
Visual Basic
Public Class InstanceBinding _
	Inherits ElementBinding
Visual C++
public ref class InstanceBinding : public ElementBinding

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.

Examples

Copy C#
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", ParameterType.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, BuiltInParameterGroup.PG_TEXT);
    return instanceBindOK;
}
Copy VB.NET
Public Function SetNewParameterToInstanceWall(app As UIApplication, myDefinitionFile As DefinitionFile) As Boolean
   ' create a new group in the shared parameters file
   Dim myGroups As DefinitionGroups = myDefinitionFile.Groups
   Dim myGroup As DefinitionGroup = myGroups.Create("MyParameters1")

   ' create an instance definition in definition group MyParameters
   Dim [option] As New ExternalDefinitionCreationOptions("Instance_ProductDate", ParameterType.Text)
   ' Don't let the user modify the value, only the API
   [option].UserModifiable = False
   ' Set tooltip
   [option].Description = "Wall product date"
   Dim myDefinition_ProductDate As Definition = myGroup.Definitions.Create([option])

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


   myCategories.Insert(myCategory)

   'Create an instance of InstanceBinding
   Dim instanceBinding As InstanceBinding = app.Application.Create.NewInstanceBinding(myCategories)

   ' Get the BingdingMap of current document.
   Dim bindingMap As BindingMap = app.ActiveUIDocument.Document.ParameterBindings

   ' Bind the definitions to the document
   Dim instanceBindOK As Boolean = bindingMap.Insert(myDefinition_ProductDate, instanceBinding, BuiltInParameterGroup.PG_TEXT)
   Return instanceBindOK
End Function

Inheritance Hierarchy

See Also