This week we continue on the path to automating interior elevations. As a reminder, I have been building a plug-in that automates various parts of creating interior elevations, and I will continue to develop it. Since this project will evolve as I continue, I have determined to set my primary goal for each stage. With this goal in mind, I will develop a functioning piece of software to meet the goal. Then I will discuss topics that cover key aspects for each step for building the plug-in. At the end of each stage, I will move the plug-in to a public repository on GitHub so you can use it too.
Part 1: filtered element collector [c#]
Create interior elevations for all placed rooms, place the tag at the center of the rooms, place the tag on the correct level when multiple levels exist, ensure the tag is visible on the interior elevation key plans (already in the project), and ensure the interior elevation tags have the proper phase settings
To place an ElevationMarker we need four parameters:
The document is just a variable that we will declare, we already found our XYZ parameter in Part 2, and for the initial build, I will hard-code the scale. That leaves us to find the ElementId parameter which needs to be the ViewFamilyTypeId used for the elevations that are hosted on the ElevationMarker.
You will need an interior elevation View Type within the Revit project you are working with. I recommend you set this up already in your template. Check the Autodesk Knowledge Network for instructions on how to create a new View Type. To gather our ViewFamilyTypeId, we can use our favorite, a FilteredElementCollector. We need to filter for ViewFamilyTypes and of those, we want the elevations where the name contains “interior”. If it returns null, we need to throw an exception so the program doesn’t crash and our user knows the error that occurred.
Now we can start putting together our method that will place our ElevationMarkers. We are not returning anything so we want a public void method. We will call it PlaceElevations and it will need a few parameters Document doc, XYZ center [which we found in Part 2], and a ViewPlan [which we will discuss next week]. We use the CreateElevationMarker method in the ElevationMarker class using the paramters we have now defined. This method returns a new object of type ElevationMarker.