Set viewport location based on other. But using crop region instead

I have lots of views and due to different dimension placement on each the bounding box (the one marked with RED corners) is different sizes from viewport to viewport.

I have made a working script that takes example sheet and places views based on where the views are located in example sheet. But due to irregular sizes of bounding boxes the view placement isn’t consistent. Is there a way to place views drawing coordinates from crop region (marked with green corners). Or any other way so that placement is more consistent?

Views always work with box center of the view for setting and getting.

But if you want to try to build a point that works for you, you can use Viewport.SetBoxCenter to rebuild that node essentially.

Hello @1bitBoolean,

I also struggled with viewport sizes when placing views on sheets, there is only one real solution. You have to hide all annotation categories in the view. Then the viewport will have a consistant distance of exactly 0.01ft from the cropbox.
Later you can activate annotations again.

It is a good solution in my opinion.

1 Like

Not sure if I misread something, but I couldn’t get the code to work. However, I am able to get this to work correctly.

The viewport locations was a sticking point in one of my graphs, so thanks for the direction!!

What a clever workaround, thank you very much!

Unrelated question - where can I find those commands that you use in code blocks (Views.HideElements (v,e) in this case). They seam very useful maybe there are materials about them?

This is the working code I use in my graphs, revit 2022.
Do you get an error?

# 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

No error. It runs and returns the out, but it doesn’t do anything to the view. I may mess with it some more, but since the code blocks work, that will do for now.

Here is a link to a demo that @jacob.small was a part of that explains Designscripts. Very informative.

1 Like