Are you tired of repeatedly taping the tab key for selecting hidden room references? And you are doing so because of the applied view template, which you don’t want to switch to none and back, because it will take too long and you’ve got a deadline to make? Then all you’ll need is a efficient way to just quickly switch the visibility of the room reference on and off.

你厭倦了反覆地按同一 tab 鍵只為了選取房間量體的參考十字嗎?而你這麼做只是為了不想把已經設定好的視圖樣版在視圖控制取不取消之間轉換,而浪費寶貴的趕圖時間?若是,你需要的只是一個快速的房間參考顯示轉換機制。

The following code gives you an overview to see how to manipulate the active view by switch the category’s visibility. Surely, it depends on how the status of your currently view setup is. In this short code, we have two scenarios, with or without view template, as examples.


type ViewRoomReference() as this = 
  interface IExternalCommand with
    member x.Execute(cdata, msg, elset) =
      let uidoc = cdata.Application.ActiveUIDocument        
      let catRoom = 
        |> Seq.cast<Category>
        |> Seq.filter(fun cat -> cat.Name = "Rooms")
        |> Seq.head
      let subcats =
        catRoom.SubCategories |> Seq.cast<Category>
        |> Seq.filter(
          fun subcat ->
            subcat.Name = "Reference" ||
            subcat.Name = "Interior Fill"
      match uidoc.ActiveView with
      | :? View3D ->
        msg <- "3D View"
      | _ ->
        let catAll = [catRoom] @ (subcats |> List.ofSeq)
        let isStat = catAll |> cat -> uidoc.ActiveView.GetCategoryHidden(cat.Id))
        let toggle() =
          match isStat with
          | [false; false; false] ->
            |> List.iter(fun cat -> uidoc.ActiveView.SetCategoryHidden(cat.Id, true))
          | _ ->
            |> List.iter(fun cat -> uidoc.ActiveView.SetCategoryHidden(cat.Id, false))
        let t = new Transaction(uidoc.Document, string this)
        t.Start() |> ignore
        match uidoc.ActiveView.ViewTemplateId with
        | x when x = ElementId.InvalidElementId ->
        | _ ->
          match uidoc.ActiveView.IsTemporaryViewPropertiesModeEnabled() with
          | true ->
          | false ->
              ) |> ignore
        t.Commit() |> ignore

Our goal is to turn on the visibility of the room category in active view, and its sub-categories “interior fill” and “reference” as well, so that we can easily recognize where the room reference points are and select the room body which we want. If the active view is not under the control of a view template, it’s simple to turn on and off the categories related to rooms. However, even if it is, we can still set the view under the “temporary view properties” mode, and toggle the visibility of the room categories.


Of course, according to different workflows or office standards, the process can be customized according to the needs. The most important is, take your time to discover your own efficient way in Revit modeling.