lisa-marie mueller

lisa-marie mueller

bullet pont

is point in room link

January 17, 2020

laptop with code on screen, party hat, whistle, red After automating the interior elevation process in my last series, I wanted to see what it would take to just rename interior elevations. I am using the same naming rules as I did in Part 10 of the previous series. When I automated interior elevations, the steps started with a room so the room information and elevation name was easy to pair. When looking at renaming elevations as a stand-alone tool, you need to determine which room each elevation is in.

room helper methods

The first two steps are very straight forward. I wrote two methods that I added to my Utility project because I found I was using them a lot. The first is a simple FilteredElementCollector to get all the rooms. The next item we need to consider is phases. We need to filter out the rooms that are the same phase as the interior elevation that we are looking at. This is because you may have rooms that overlap in different phases of the project and you want to make sure you are renaming the interior elevation according to the correct room number and name.

GetElevRoom

Then we can write the method that finds the room that our elevation is in. We create a new public method that will return our Room and call it GetElevRoom. It needs a ViewSection and the list of rooms as parameters. First, we take the BropBox of the interior elevation ViewSection and assign the min and max values to a variable. Then we find the center of the CropBox. The center is located in the coordinate system of the interior elevation ViewSection but we need to find that coordinate in the project coordinate system to compare it to the rooms. To do this, I use a number of the methods I had written for my Utility project which you can read more about in Part 9 of the Automating Interior Elevations series. These methods rotate the coordinate to orient it to the project coordinate system. We still need to translate the point which we do by adding the interior elevation’s Origin property. Lastly, we check each room in our list of rooms to see if the point is in that room. If it is, we need to return the room so we can use it to rename the elevation.

add to execute

In our execute method we now need to call the method we just wrote. We use a for-each loop to circle through each interior elevation. First, we get the list of rooms filtered by the correct phase, then we find which room the elevation is in, and finally, we rename the elevation with a similar process as I discussed in Part 10 of the Automating Interior Elevations series.

And that’s all it takes to rename the interior elevations. Next week, I will discuss how to add a WinForms user interface with a DataGrid to this plug-in.

resources

If you want to learn to code and don’t know where to start check out my posts about Steps to Learn to Code [for architects and designers] Part 1 and Part 2.

if you missed it:

Part 1: filtered element collector [c#]

Part 2: finding centroids and considering exceptions

Part 3: ViewFamilyTypeId

Part 4: ViewPlanId and Levels

Part 5: phases & goal #1 complete [includes GitHub link to the release]

Part 6: view tempaltes

Part 7: resizing CropBoxes

Part 8: creating FilledRegions & Goal #2 Complete [includes GitHub link to release]

Part 9: coordinate system utilities

Part 10: rename views & goal #3 complete [includes GitHub link to release]

Revit API Docs