2024 Method
Changes 8
M

View.GetLinkOverrides

Description:
Gets the graphic overrides of a or in view.
public RevitLinkGraphicsSettings GetLinkOverrides(
	ElementId linkId
)
Return Value RevitLinkInstance Settings representing graphic overrides for the input element id in the view, or null Nothing nullptr a null reference ( Nothing in Visual Basic) if the input id references RevitLinkInstance and it doesn't have overrides in the view.
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());
}