Model element locations on sheet

Hi all,

I ran into a problem concerning sheets and model elements.
I would like to place elements, like symbols and views, on my sheet on the position, or related to the position, of certain model elements.
In this case, I have some beams and want to place an arrow in the middle of it This arrow should point towards a section view concerning the beam. The situation is sketched below:

What I know is the Cropbox size and position in the model coordinate system.
What I also know is size and position of the Viewport in the local sheet coordinate system.
These things have nothing to do with each other and can not be easily scaled to get the right result.
The problem is: as for as I know, I can’t get the cropbox location information on the sheet.

The result should look something like this:

Does anyone know how I can determine what the beam location on the sheet is?
Or at least the cropbox location on the sheet? I can translate that to a beam location ofcourse.

Thanks all and happy holidays.

Maybe I can help you find the cropbox location on the sheet…

If you hide all annotations in the view, the viewport’s bounding box will shrink to match the view’s cropbox. That will give you the “cropbox location information” that you are looking for.

I use some python code to do this automatically within my graph:

# Written by Frank Loftus. This code sets the "AreAnnotationCategoriesHidden" property to 1(true).

# Load the Python Standard and DesignScript Libraries
import sys
import clr

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
Input = UnwrapElement(IN[0])

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
TransactionManager.Instance.EnsureInTransaction(doc)

viewsOut = []

if isinstance(IN[0], list):
	for View in Input:
		View.AreAnnotationCategoriesHidden = 1
		viewsOut.append(View)
else:
	Input.AreAnnotationCategoriesHidden = 1
	viewsOut.append(Input)

TransactionManager.Instance.TransactionTaskDone()

OUT = viewsOut

So, to use the above code, send the desired view(s) into the python node, and it will set their “AreAnnotationCategoriesHidden” property to 1. Then, you may need to use a Transaction.end and Transaction.Start node to apply the change.

After that, you can acquire the bounding box of the viewport on the sheet. I use Rhythm’s Viewport.LocationData node for this. Once you know the location of the viewport, I assume you will scale the beam’s location within the cropbox, and add it to the location of the viewport. This will give you the location of the beam on the sheet.

When you are done acquiring the location of the beam, you will have to show annotation categories again. To do that, simply use the above code in a separate python node, but set the “AreAnnotationCategoriesHidden” property to 0. You may need to end and restart the transaction again to apply the changes before doing other operations later in the script.

I wish it was simpler to get the cropbox location on the sheet, but I have not found any other way.

2 Likes

Great solution! Thanks a lot Frank.
There are a lot of transactions needed in this script since this only works if the crop view visibility is set tot True. Also I want all the settings turned back to the original but thats okay.
This put my on the right path, awesome!

I noticed that it does not seem to work in Revit 2021, do you know what the reason for that might be?

Hey Frank,

Thanks for that idea!
I asked a few times on the forum but never found out if it is posible to get the cropbox on a sheet. I think there is no way to do that.

I tried to hide all annotations, as you said the viewport shrinks, but there is an offset of a few millimeters.

If this offset is always the same this should do the trick.

Hey Gerhard,
From the few tests I have done this far it’s always the same if annotations are off indeed.
With the transformation you used in the other thread you should be able to complete it now.

I use the same python code in two separate nodes. In the first one, I set the property value to 1. Then I accomplish whatever I need to do. Afterwards, I place a second python node containing the same code, except I modify it to set the value to 0. Then the settings should return to the way you set them. Below I’ve pasted the code which sets the value to 0. You only have to change the script in the two places where it says “AreAnnotationCategoriesHidden = 0”. That should allow you to turn them on or off whenever you need:

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
Input = UnwrapElement(IN[0])

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
TransactionManager.Instance.EnsureInTransaction(doc)

viewsOut = []

if isinstance(IN[0], list):
	for View in Input:
		View.AreAnnotationCategoriesHidden = 0
		viewsOut.append(View)
else:
	Input.AreAnnotationCategoriesHidden = 0
	viewsOut.append(Input)

TransactionManager.Instance.TransactionTaskDone()

OUT = viewsOut

Also, I’m not sure why it didn’t work in Revit 2021, but I have a version of this dynamo script specifically for 2021. I looked in there and the code was slightly different, so hopefully the version I’ve pasted in this post will work for you. I know I’ve used it successfully in 2021.

1 Like

I actually was not aware of that offset. Obviously I could see that the outline is larger than the cropbox, but I suppose I assumed it was only a visual difference. I thought it wouldn’t affect the final position. Thank you for pointing that out. Luckily, I have not needed absolute precision for my purposes.

I think that’s an offset all around the cropbox so if you work from the center, you still have absolute precision.

A good addition is that this only works when the viewtemplate does not override the hide annotations function.

True, but since view templates are actually views, you can feed all view templates into the python node to handle them as well.

Also, I found the offset to be exactly .01 ft in my case. I wonder what the offset would be in a metric project? Is it an arbitrary number of millimeters, or is it .01 ft converted to mm?

Great tip, works way better.
The offset is also exacly 0,01ft as well in our European metric system.
See screenshots below.


image