Check if Viewport has bounds inside sheet

Hello everyone,

I am having issues with checking if certain viewports have their bounds inside a drawing sheet.
My current objective is to have the views with a scale that is a multiple of 50 (like 100, 150, 200, 250, etc…) so that, this way, they can be inside the drawing sheet limits.
I have tried the following method:

However, when I run the dynamo script, one of the following happens (pictures bellow):

  • The view gets a scale that makes it be too small for the drawing sheet;
  • The view gets a scale that makes it exceed the drawing sheet limits because it has too big of a scale.

Is there a way of implementing something along the lines of what I described?

The full script is too big to take a screenshot so here’s the .dyn file, the .rvt file used and the Excel spreadsheets needed for the 3D model creation:
bars.xlsx (57.5 KB)
nodes.xlsx (30.1 KB)
structureV25.dyn (2.4 MB)
Template.rvt (3.3 MB)

Hi @joaofmoco!
I’ve done similar task for decreasing scale of viewport. If we have centers of drawing frame and viewport in one point,
we need iteratelely decrease scale of viewport until upper right corner X coordinate will’be smaller, than upper right corner X of drawing frame. You can try to do it with While loop, or just push the list of your scales (100, 150, 200, 250, etc…) and catch first “true” when we have vieport’s corner inside frame.
We can do all of that just with rectangles, or points, avoiding revit transactions. And apply final scale to viewport once at the end.

Also look into this: Laying Out Sheets with Generative Design in Revit - Dynamo BIM

Can you share rvt file with created views? Something crashes in my excel import(

Hello and thank you for your reply,

I thought about a while loop to be honest. I just didn’t really know where to start because it seems more complex than just a while loop. Thank you for making it clearer :slight_smile:
Also, here’s the .rvt file with the created views:
Template(with model).rvt (5.4 MB)

1 Like

@joaofmoco, look here for Loop While:

1 Like

Of note that I’m currently using Revit 2020. Maybe that was why the Excel import didn’t work.


I have created a partial script (pictures bellow) that extracts the bounding boxes of the viewports and the sheets.

Then it proceeds to check if the XY values of the viewport are different than the XY values of the sheet in a way that the viewport is not contained inside of the drawing sheet. If there are false values returned, the script extracts the indices of the viewports in the list.

After this, the viewports that are out of the sheets bounds are saved and the view inside them is scaled down (placeholder value as this is where I wanted the scale value to be iterated - Like with that list with multiples of 50). Then, after the scaling is done, the viewport needs to be recentered.

However, the results have a view title that has a huge extend line (picture bellow).

In short:
How do I do the loop to test the scales in the list?
How do I change the extend line end point?

@joaofmoco , have a look:
VPScale3.dyn (52.6 KB)
I feel, we don’t need loops at all.

I replaced some nodes by nodes of:

  • packages that I have installed
  • default Dynamo

Here’s the script:

I only didn’t replace RIE because i don’t know an equivalent for this package node

It can be replaced with OOTB nodes. Active view is built-in. Just was in a hurry) Or install RIE and take python.

1 Like

Okay so I replaced some of the nodes of my script by the nodes on yours and adapted the code a bit (pic bellow).

However, when I run the script the following happens (examples):

These are the nodes that have thrown up a warning:

What might have gone wrong?
Here’s the script bellow:
structureV27.dyn (2.4 MB)

Batch rescaling of sheet placed views:
VPScale4.dyn (67.1 KB)
Connect it after your views placemet.

1 Like

Hello, I’ve made some changes so that it would run on the script and it’s still producing some errors.
Here’s the part of the script I’ve changed. It’s still producing some errors but it’s better now:

And here’s the full script:
structureV27-2.dyn (2.4 MB)

Share current rvt file, with all views placed, but not scaled, please.

Hello, I have shared the .rvt file with the placed models. However, here’s the rvt file with views already placed:
Template(with model).rvt (5.4 MB)

Thank you for your patience

Well, veiwport scaling part is independent. All before doesn’t work for me, but scaling is successful (checked twice!). Maybe we need regenerate before starting scaling (red group in script).
structureV27-2.dyn (499.6 KB)

1 Like


I have figured out a solution to this. I calculated the scale ratios and then checked which ratios were the biggest (X or Y) for each view. Then, I proceeded to create a list with all the needed ratios. After this step, I multiplied it times 100 and rounded up the scale value with multiples of 50. Then, I went and set the scale and set the viewport center.

Full script:
structureV25.dyn (2.4 MB)