RVTDocs.com
Namespace: Autodesk.Revit.DB Class: View

View.SetLinkOverrides

Method
Description:
Sets the graphic overrides of a or in the view.
Syntax
public void SetLinkOverrides(
	ElementId linkId,
	RevitLinkGraphicsSettings linkDisplaySettings
)
Examples
public static void UpdateOverridesInView(View view, ElementId linkElementId, ElementId linkedViewId, LinkVisibility visibilityType)
{
    RevitLinkGraphicsSettings settings = new RevitLinkGraphicsSettings();

    switch (visibilityType)
    {
        case LinkVisibility.ByHostView:
            settings.LinkVisibilityType = LinkVisibility.ByHostView;
            break;
        case LinkVisibility.ByLinkView:
            settings.LinkVisibilityType = LinkVisibility.ByLinkView;
            settings.LinkedViewId = linkedViewId;
            break;
        case LinkVisibility.Custom:
            settings.LinkVisibilityType = LinkVisibility.Custom;
            settings.LinkedViewId = linkedViewId;
            settings.ViewFilterType = LinkVisibility.Custom;
            settings.ViewRange = RevitLinkGraphicsSettings.IsViewRangeSupported(view) ? LinkVisibility.ByLinkView : LinkVisibility.ByHostView;
            settings.ColorFill = view.SupportedColorFillCategoryIds().Any() ? LinkVisibility.ByLinkView : LinkVisibility.ByHostView;
            settings.ObjectStyles = LinkVisibility.ByLinkView;
            settings.NestedLinks = LinkVisibility.ByLinkView;

            settings.SetDiscipline(LinkVisibility.Custom, ViewDiscipline.Mechanical);
            settings.SetPhase(LinkVisibility.Custom, ElementId.InvalidElementId);
            settings.SetPhaseFilter(LinkVisibility.Custom, ElementId.InvalidElementId);
            settings.SetViewDetailLevel(LinkVisibility.Custom, ViewDetailLevel.Medium);
            break;
        default:
            throw new InvalidOperationException("Not expected visibility type.");
    }

    using (Transaction transaction = new Transaction(view.Document, "Set link graphical overrides"))
    {
        transaction.Start();
        view.SetLinkOverrides(linkElementId, settings);    
        transaction.Commit();
    }
}
Parameters
Parameter Type Description
linkId ElementId The id of the <a href="2204a5ab-6476-df41-116d-23dbe3cb5407.htm">RevitLinkType</a> or <a href="a3a27c39-75bf-67d1-ae78-4cadd49a9c8e.htm">RevitLinkInstance</a>.
linkDisplaySettings RevitLinkGraphicsSettings Settings representing all link graphic overrides in the view.
Return Value
Exceptions
Exception Condition
ArgumentException The input id is not a valid RevitLinkInstance or RevitLinkType id. -or- The LinkedViewId of linkDisplaySettings has incorrect value for the specified LinkVisibilityType. -or- The ViewFilterType of linkDisplaySettings has incorrect value. -or- The ViewRange of linkDisplaySettings has unsupported value. -or- The phase or pahse type of linkDisplaySettings has incorrect value for the specified LinkVisibilityType. -or- The phase filter or phase filter type of linkDisplaySettings has incorrect value for the specified LinkVisibilityType. -or- The view detail level or the type of view detail level of linkDisplaySettings has incorrect value for the specified LinkVisibilityType. -or- The discipline or the discipline type of linkDisplaySettings has incorrect value for the specified LinkVisibilityType. -or- The ColorFill of linkDisplaySettings has incorrect value for the specified LinkVisibilityType. -or- The ObjectStyles of linkDisplaySettings has incorrect value for the specified LinkVisibilityType. -or- The NestedLinks of linkDisplaySettings has incorrect value for the specified LinkVisibilityType.
ArgumentNullException A non-optional argument was null
InvalidOperationException The view type does not support Visibility/Graphics Overriddes. -or- The view does not support link graphical overrides.