lisa-marie mueller

lisa-marie mueller

bullet pont

align ViewSection CropBox to Wall CropBox link

April 11, 2020

ipad with title, large neon star, movie reel, marker, orange I hope you are all staying healthy. Due to some computer problems, I’ve had a slight delay in releasing some of my posts the past month, but I have my laptop back now and hopefully, everything keeps running smoothly.

As you know, I am tackling placing exterior elevations based on selected walls. Once the elevations are placed, adjust the CropBox of each elevation manually would be time-consuming. Instead, we want the program to adjust the CropBox to match the wall that we are viewing. So this week we will walk through how to align the CropBox of the ViewSection with that of the Wall.

goals and considerations

  • create an elevation marker for exterior walls by having the user select the walls
  • place the marker and elevation offset from the wall so it is legible
  • correctly phase the elevation markers
  • accommodate curved and angled walls

if you missed it:

Part 1: elevation by wall

Part 2: phases

Part 3: rotating elevation markers

wall endpoints

While testing this plug-in I found that the wall’s CropBox wasn’t always the same width as the wall. Because of this, I am going to use the endpoints of the wall to get the new coordinates for the ViewSection CropBox. First, we create a new public method and call it SetCropBox. It doesn’t need to return anything. We will need the document, the elevation marker we have created, and the wall as parameters. We need to find the values that we are going to use to set the minimum and maximum points of the ViewSection CropBox. The first step is to get the endpoints of the wall. We can do this by finding the LocationCurve of the wall and using the GetEndPoint method at the first and second index. Then we can get the wall’s height from the WALL_USER_HEIGHT_PARAM BuiltInParameter. The wall’s minimum coordinate will just be the first endpoint of the curve. To get the wall’s maximum coordinate, we will need to add the wall height to the Z coordinate.


Now that we have the points we need, we have to transform these points into the ViewSection’s coordinate system. I had written a few utility methods for this which you can read about in my previous post about resizing CropBoxes for interior elevations. The methods transform the minimum and maximum values and the ViewSection’s origin from the project’s coordinate system into the ViewSection’s coordinate system.

check min and max

After we transform the coordinates, it is possible that the minimum is no longer the smaller value and is instead the maximum. Because of this, we want to check the two coordinates and take the higher value and assign it to the max and take the lower value an assign it to the min. Since I have been using this a few times now, I added it to my Utility methods.

So in our method we can just add the following:

update CropBox

The last step is just to update the crop box with the new coordinates. We keep the Z coordinate of the ViewSection’s original CropBox because this is the depth and we don’t need to change that. When we assign the X and Y values, we need to make sure to subtract the translated origin. This is because when we translated the wall’s endpoints, this translation was relative to ViewSection’s origin rather than the project’s origin.

We also want to subtract a small fraction from the height of the new CropBox. This ensures that the elevation marker is hidden in the plans that do not correspond to the same level as the wall. If we don’t subtract 0.01, the top of the CropBox aligns with the level at the top of the wall. So if the wall goes from 0’-0” at the first floor to 12’-0” at the second floor, and the CropBox goes from 0’-0” to 12’-0” then it will be visible on the second floor plan. If it goes to 11’-11.98” then it will not show on the second floor plan.

We can then also set the CropBox line to be invisible by setting CropBoxVisible to false.


And that wraps up the steps we need to take to have the CropBox of the ViewSection match the CropBox of the wall. Since we have cropped the height of the elevation to the height of the wall, the elevation marker will only display on the floor plans that correspond to the same level as the wall. Now we need to make adjustments so that our plug-in works for curved walls and allow for the user to select the walls they want to elevate.


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.

Revit API Docs

bullet pont

recommended next