GetLinkOverrides Method
Gets the graphic overrides of a RevitLinkType or RevitLinkInstance in view.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 24.0.0.0 (24.0.0.0)
Since:  2024

Syntax

C#
public RevitLinkGraphicsSettings GetLinkOverrides(
	ElementId linkId
)
Visual Basic
Public Function GetLinkOverrides ( _
	linkId As ElementId _
) As RevitLinkGraphicsSettings
Visual C++
public:
RevitLinkGraphicsSettings^ GetLinkOverrides(
	ElementId^ linkId
)

Parameters

linkId
Type: Autodesk.Revit.DB..::..ElementId
The id of the RevitLinkType or RevitLinkInstance.

Return Value

Settings representing graphic overrides for the input element id in the view, or nullNothingnullptra null reference (Nothing in Visual Basic) if the input id references RevitLinkInstance and it doesn't have overrides in the view.

Examples

CopyC#
public static void PrintLinkOverridesInView(View view)
{
    var ids = new FilteredElementCollector(view.Document)
                  .WhereElementIsElementType()
                  .OfType<RevitLinkType>()
                  .Select(link => link.Id)
                  .ToList();

    ids.AddRange(new FilteredElementCollector(view.Document)
                     .WhereElementIsNotElementType()
                     .OfType<RevitLinkInstance>()
                     .Select(link => link.Id)
                     .ToList());

    StringBuilder message = new StringBuilder();
    foreach(ElementId id in ids)
    {
        RevitLinkGraphicsSettings settings = view.GetLinkOverrides(id);
        if (settings == null)
        {
            message.AppendLine(string.Format("Element with Id - {0} doesn't have graphical overrides in the view.",
                                             id.Value.ToString()));
            continue;
        }

        message.AppendLine(string.Format("Element with Id - {0} has overrides of the type {1} and references LinkedView: {2}.", 
                                         id.Value.ToString(), settings.LinkVisibilityType, settings.LinkedViewId.Value.ToString()));
    }

    TaskDialog.Show("Link Overrides report", message.ToString());
}

Exceptions

ExceptionCondition
Autodesk.Revit.Exceptions..::..ArgumentException The input id is not a valid RevitLinkInstance or RevitLinkType id.
Autodesk.Revit.Exceptions..::..ArgumentNullException A non-optional argument was null
Autodesk.Revit.Exceptions..::..InvalidOperationException The view type does not support Visibility/Graphics Overriddes. -or- The view does not support link graphical overrides.

See Also