Rename View by Matching Elevation Tag with Room

Today is the last morning meeting with my European DevTech colleagues here in Brittany, and time to travel back to Switzerland.

Before leaving, here is a useful real-world productivity tool by Trevor Taylor of ZGF,
Zimmer Gunsul Frasca Architects LLP,
with his own description of the task and its solution:

The task I want to address is to match interior elevation tags with the rooms they fall inside.

This is used to track back and rename the corresponding views.

Naming interior elevation views is a major time-burner as there can be thousands of views in a project to rename, and they have to be coordinated when the room numbers or names change.
If we don’t tie view names to rooms, we have no hope of ever keeping track of so many views.

I originally attacked this by trying to determine the location of the view tags in the model, but had to give up on that one.

Ben Bishoff of Ideate gave me the idea to approach the problem from the view rather than from the interior elevation tag, so I worked backwards from the view cropbox property using the RevitLookup app and arrived at this simple solution:

1. Collect all views of class ‘ViewSection’, then filter down to those of ‘Interior Elevation’ type:


  FilteredElementCollector collector
    = new FilteredElementCollector( m_doc )
      .OfClass( typeof( ViewSection ) );
 
  foreach( ViewSection current in collector )
  {
    ViewFamilyType vft = m_doc.GetElement(
      current.GetTypeId() ) as ViewFamilyType;
 
    if( null != vft
      && vft.Name == "Interior Elevation" )
    {
      m_int_elevation_views.Add( current );
    }
  }

2. Construct a point at the midpoint of the front bottom edge of each interior elevation view’s CropBox.
The CropBox is conveniently relative to the projection plane of the view.
X is to right, Y is up, and Z is the view depth:


  // Construct a point at the midpoint of the 
  // front bottom edge of the elev view cropbox
 
  double xmax = v.CropBox.Max.X;
  double xmin = v.CropBox.Min.X;
  double zmax = v.CropBox.Max.Z;
 
  XYZ pt = new XYZ(
    xmax - 0.5 * ( xmax - xmin ),
    1.0,
    zmin );

3. Get pt’s translation to project’s coordinate system:


  // Get pt's translation to 
  // project coordinate system
 
  pt = v.CropBox.Transform.OfPoint( pt );
 

That takes care of the heavy lifting. Pass pt to the GetRoomAtPoint method and you obtain the room, if there is one to get:

4. Retrieve the room:


  Autodesk.Revit.DB.Architecture.Room rm
    = m_doc.GetRoomAtPoint( pt );

It does exactly what I want it to now and will save our teams countless hours on large projects by organizing the names of interior elevation views by room name:

Elevation renaming map

Here is a
complete sample project including
a test model in case you’d like to check it out yourself.

Many thanks to Trevor for this useful tool, his research, implementation, and generous sharing.

Before I sign off, here are two other nice pointers, not related to Revit:

Au Bout du Monde and Super-Sonic Stereo

Brittany is at the end of the earth, or Finisterre, au bout du monde, and I have seen many restaurants, a parking place, and a number of other establishments named after that around here.

That reminded me of one of my favourite humorous YouTube films, a Russian cartoon also named
Au Bout du Monde,
by Konstantin Bronzit:

It was very fitting to share with my colleagues, since two of us are Russian as well.
We enjoyed it a lot, and I hope you like it as much as I do.

While we are at it, yesterday, my son Christopher pointed out another quite nice blog with explanations of what-if questions, the most recent one featuring sound sources, asking
what if my stereo flew around at super-sonic speed?
I enjoyed that as well, and so might you.

Last but not least, today is the first day of spring and

vernal equinox
!

Spring and vernal equinox

Off we go to the airport…


Comments

10 responses to “Rename View by Matching Elevation Tag with Room”

  1. Hi Jeremy,
    How can this be used by ordinary people, without coding skills?
    When downloading the dataset, the only thing I get is a lot of .cs files, some .addin files and some other files with different extensions.
    This would be very useful for us to be able to use.
    /Martin

  2. Dear Martin,
    I am glad to hear that this looks useful to you!
    I am sorry that I cannot publish executable binaries for legal reasons.
    The best would be for you to have someone at hand with some Revit API knowledge and a compiler to create an executable for you.
    That would also enable you to modify it, for instance if there are some hard-coded paths or something else that does not fit your needs.
    You could always try contacting Trevor and asking him for the .NET assembly DLL.
    Another way would be to convert it to a macro … you already have the Revit macro editor and IDE installed, since it is part of Revit nowadays.
    Good luck!
    Cheers, Jeremy.

  3. Hi Jeremy,
    Is there a ‘WithEvents’ or some equivalent for views/sheets? I want to build an app to manage view naming transparently.
    What you describe above is part of the puzzle actually : ) defining elevation view tag names on the room name/number.
    The app would basically use rule based criteria to create names- like “AFP01”, “MFP01” “SFP01” etc. instead of “floor plan – level 1”. This becomes helpful with ‘sim’ callouts to existing views, or sections or details.
    I was thinking I might replace the buttons for creating callouts, plans, etc. on the ribbon with custom versions, but a withevents would be better- intercepting created views/sheets immediately prior to creation and naming them, then creating them.
    Thanks-
    Ron

  4. Dear Ron,
    Nope, sorry.
    Cheers, Jeremy.

  5. Instad of InteriorElevation how can i get Bilding Elevation? or all the sections are called as InteriorElevation?
    tery to create a program to rename section view Name in Browser with assocated drawing number or detail number they are on.

  6. Dear Babu,
    Please use a spell checker before submitting a comment.
    Cheers, Jeremy.

  7. Jeremy,
    Sorry sent from my phone,
    while I was on Bus.

  8. Hi Jeremy,
    Instead of InteriorElevation,
    how can I get Building Elevation?
    After placing sections/details on sheet
    I want to rename section’s view Name
    in project Browser with
    Drawing number + Detail number
    of that sheet they are on.
    thanks
    Babu

  9. Dear Babu,
    Sure, no problem. I just did not understand what you want.
    Cheers, Jeremy.

  10. Dear Babu,
    Sorry, I don’t really know the difference between these kind of objects. I imagine that you can easily solve your task by analysing the project using RevitLookup and doing some research yourself.
    Cheers, Jeremy.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading