Problems with recreating view crop boundaries and sheet viewports from link into host

My goal here is to set up sheets in an MEP model that very similarly match those in a linked architectural model. The reason is to develop uniformity across the drawing sheets of an entire project. I know there are in-process projects by others on this topic, but I remain bound and determined to keep trying myself.

I’m trying this by the method described by @Nick_Boyts, in a previous posts on the topic:

I’ve successfully been able to get the crop boundaries from views and viewports from sheets in the linked model, recreate those same boundaries applied to new views in the host model and place them on sheets by recreating the viewports.

Problem #1 - there is a very slight translation in the coordinates of the crop boundaries, as shown here:

Problem #2 - there is a very slight difference in the viewports too, as shown here:

Any insight on why this may be happening would be greatly appreciated! Thanks!

1 Like

Do both models have the same levels at the same elevations and also share the origin? If the only change is Z, makes me think it’s a level thing.

I will have to check on the origins, but all the levels are the same in the host as in the link, including the elevations.

Viewport placement also depends on the location of the title block. You would hope that everybody’s TB is located at 0,0 in the sheet view, but that may not be the case. You may have to automate matching the TB location for each sheet as well.

@JustinStirling: I am also trying to match sheets from a linked model. I am curious if your issue could be caused by the same issue that I am having:

The location of the viewport is determined by a bounding box that is NOT equal to the view crop boundary. This bounding box is drawn around annotations that may extend outside of the view crop boundary (such as grids, or tags). Perhaps there are annotations in your architectural link that are affecting the bounding box?

Here is an example from my current project. I run a dynamo script that measures the location of all viewports in the project. Then, the viewports are moved by the same vector, except negative. I expect the two views on this sheet to return to the origin and appear directly on top of each other because they have identical view crop boundaries. However, this is what I get:

Because there is a tag that extends way outside of the view crop boundary, the viewports’ MinPoints are not identical. This can also be caused by grids.

I have no idea if this is causing your problem, but I suppose it is something to check. Annotations from the arch model could be causing the viewport bounding box to change size when you copy the view to your model (because I’m guessing you don’t also copy their annotations). The box center wouldn’t appear to be altered if the copying method is based on the center of the bounding box.

1 Like

@Frank_Loftus, thanks for explaining your issue and bringing this to my attention. This idea has been shelved for a while since I couldn’t get it figured out. I’ll try to resurrect my script and see if I can figure out where I left off. Thanks again, I’ll report back my findings!

I have seen folks turn off all annotations, get the points, then set the box center. I have also solved it by using the boundingbox of the view and not Viewport. Then use the U and Band 0z to set the Viewport location. This may still not be 100% accurate but usually VERY close if you don’t have major rogue annotations like the example above.

@SeanP, any chance you could elaborate a little on the “turn off all annotations” approach?

I’m guessing I need to:

  • get the view in the linked model I want to try and recreate - I can do this easily.

  • turn off all annotations in the linked model view - I do not know how to do this

  • get the bounding box curves (or scope box) of the linked model view and apply to new view in host model - I can do this

  • turn off all annotations in the host model view - I do not know how to do this

  • get the bounding box curves and center point of the viewport on the linked sheet so the viewport can be recreated in the host model - I can’t say I’ve figured this out yet either.

Part of my problem might solely be in the terminology I’m using…and how incorrect it is.

Any help would be greatly appreciated! Thank you!

So, I don’t think I was following at first as you can’t do any modifications to a linked model without actually opening it. So, this is code that can do it, but it will not work on a straight linked doc.

for cat in doc.Settings.Categories:
    if cat.get_AllowsVisibilityControl(view):
        if cat.CategoryType == CategoryType.Annotation:
            view.SetCategoryHidden(cat.Id, True)

@SeanP , you mentioned a method of using the bounding box of the view instead of the viewport. Can you elaborate on that? That would eliminate the need to turn off annotations in the linked model, right?

Such a method would really help me as I’m trying to locate views on a sheet regardless of any annotations that may be enlarging the bounding box.

Just an update - Here is a python script that I wrote to hide all annotation categories in views. This is necessary in order to position viewports on sheets properly. You would probably need this as part of the process for copying linked viewports. If you turn off annotations, you can then get the viewport box center accurately, and then use that box center in the host model to position your viewports on the sheet:

# 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

After the view is placed on the sheet, use another instance of this python node, but change the value of “AreAnnotationCategoriesHidden” to 0. This will unhide annotation categories for the views passed into the node.

1 Like

@jmayesP84R8 FYI.

Does it work when there are view templates applied?
I have had the same problem of recreating and placing viewports and the solution I used was to temporarily assign a view template where the annotations are hidden.

Should probably use Input here rather than IN[0].

Any reason why? When I do that I get this error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 29, in
AttributeError: ‘List[object]’ object has no attribute ‘AreAnnotationCategoriesHidden’

I’m not an expert with python, but it seems like unwrapping the list breaks the “if” statement, so I used IN[0]. Thanks for looking into the code, though. I don’t really know why, but it seems to work for my purposes.

If you feed “all elements of category” “views” into the python node, it will actually turn off annotations for all views (including view templates, which are views themselves). So yes you can use it when there are view templates applied, as long as you also modify the view templates in the process:

1 Like