Efficiently View Room Reference – 有效率地快速顯現與隱藏房間的參考

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 |> List.map(fun 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.


Published by

Ching-Hua Chen / 陳景華

The logic behind coding structures will be unveiled during step by step practices. A strong background from computer science is not what I have. I’m just an enthusiast of programming, especially in fields of geometry and architecture. Currently I work for an office in Vienna on a BIM project and I write codes in F# and Python, if needed, for the project, but mostly for my own interest.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.