Search code examples
.netautodeskrevit-apirevit

Find Temporarily Hidden Elements In Revit View


I've got a method that checks on some visibility issues in Revit. The problem is that it throws an error on an extremely common issue: "a user manually hiding the element in it's view".

This line of code

public bool IsElementManuallyHidden(View view, Element element)
{
     return view.IsElementVisibleInTemporaryViewMode(TemporaryViewMode.RevealHiddenElements, _element.Id);
}

throws an ArgumentExceptionError stating that: "This view mode is not supported for checking element visibility."

Anyone know of any potential workarounds?


Solution

  • Ok - apparently, two more seconds of work found me a workaround :).

    public bool IsElementManuallyHidden(View view, Element element)
    {
        return element.IsHidden(view) || view.IsElementVisibleInTemporaryViewMode(TemporaryViewMode.RevealHiddenElements, _element.Id);
    }
    

    with element.IsHidden(view) being the key factor. I don't love that I can't check the Temporary modes though so if anyone has a better answer, I'll accept that instead.