IExternalCommandAvailability Interface


An interface that should be implemented to provide the implementation for a accessibility check for a Revit add-in External Command.

Namespace: Autodesk.Revit.UI
Assembly: RevitAPIUI (in RevitAPIUI.dll) Version: 2015.0.0.0 (2015.0.0.0)

Syntax

C#
public interface IExternalCommandAvailability
Visual Basic
Public Interface IExternalCommandAvailability
Visual C++
public interface class IExternalCommandAvailability

Remarks

This interface should share the same assembly with add-in External Command.

Examples

Copy C#
public class SampleAccessibilityCheck : IExternalCommandAvailability
{
    public bool IsCommandAvailable(Autodesk.Revit.UI.UIApplication applicationData, 
        CategorySet selectedCategories)
    {
        // Allow button click if there is no active selection
        if (selectedCategories.IsEmpty)
            return true;
        // Allow button click if there is at least one wall selected
        foreach (Category c in selectedCategories)
        {
            if (c.Id.IntegerValue == (int)BuiltInCategory.OST_Walls)
                return true;
        }
        return false;
    }
}
Copy VB.NET
Public Class SampleAccessibilityCheck
    Implements IExternalCommandAvailability
    Public Function IsCommandAvailable(applicationData As Autodesk.Revit.UI.UIApplication, selectedCategories As CategorySet) As Boolean Implements IExternalCommandAvailability.IsCommandAvailable
        ' Allow button click if there is no active selection
        If selectedCategories.IsEmpty Then
            Return True
        End If
        ' Allow button click if there is at least one wall selected
        For Each c As Category In selectedCategories
            If c.Id.IntegerValue = CInt(BuiltInCategory.OST_Walls) Then
                Return True
            End If
        Next
        Return False
    End Function
End Class

See Also

ArchiLabs Desktop

Put AI to work inside Revit.

Give Desktop your instructions and project files to build Revit families, update model elements, and create views and schedules. Works directly in Revit and AutoCAD.

Explore Desktop →