lisa-marie mueller

lisa-marie mueller

bullet pont

tag location part 2 link

November 6, 2020

paper airplanes and falling sheet of paper with title - in purple Happy Friday! Last week we looked at the simple way to get our tag location, this week we will look at adjusting the location to ensure it is in our view.

get elevation endpoints

The first thing we will need to do in order to ensure our tag is within our view, is to get the endpoints of the interior elevation view. We set up a new method which will return a Tuple to store our two endpoints. The only parameter that we need is the ViewSection. We can get the min and max values of the CropBox and assign them to variables. This will give us the opposite corners of the cube, but we want the opposite corners of the plane that forms the boundary of our view. This means the smaller endpoint will be the X and Y coordinates of the CropBox min and the Z coordinate of the CropBox max. The larger endpoint will be the Y coordinate of the CropBox min and the X and Z coordinates of the CropBox max.

tag location in view

We can then use the endpoints we just found to adjust our GetTagLocation method from last week. We still get the endpoints of the wall, but we then need to transform these coordinates into the view’s coordinate system because they are located in the project coordinate system.

After we transform the endpoints, we need to confirm that endpoint 1 is still the min and endpoint 2 is still the max, if not, we need to swap those values. Then we can compare the endpoint of the wall to the endpoints of the view. If the minimum value of the wall’s endpoint is smaller than the view’s, we know that the end of that wall falls outside of the current view. In that case, we want to take the view’s endpoint instead. We also check the same for the maximum. Then we use the updated endpoint values to get the center of the part of the wall that is visible in the view.

We transform this coordinate back into the project’s coordinate space and then can offset by two feet again so the tag sits below the view.


And that is how we can adjust the location to be within our view and centered on the visible portion of the wall. Next week, we’ll cover how to place the tag now that we have the required parameters and we will look at some of the challenges with placing material tags through the API.


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