One solution would be to get all viewports on the sheet and then filter the one i need. I often have many views on a sheet and i really don`t know how i could filter the viewports.
So why is the GetViewport node not working and is there any other method to get the viewport?
Would be really happy for any advice!Thank you very much in advance
Thanks for your reply, thats exactly the intended use for my script.
In your and mine example we only have one viewport, but i have plans with many views and i don`t want to filter the viewports to get the one that should be the template viewport.
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
def GetViewport(view):
return filter(lambda v: v.ViewId.IntegerValue.Equals(view.Id.IntegerValue),FilteredElementCollector(doc).OfClass(Viewport))
#Preparing input from dynamo to revit
view = UnwrapElement(IN[0])
# return the results
if isinstance(IN[0], list): OUT = [GetViewport(x) for x in view]
else: OUT = GetViewport(view)
I have found the reason for the offset, it`s because the viewports are not equal in size.
There are many elements that affect the viewport (grids, section lines, 2D-Elements,…), so these viewport location nodes are not reliable, at least not for my workflow.
It would be much more reliable if the location of the views would be set by the cropbox and not the viewport, because the cropboxes are always equal!
I will try to get the location of the cropbox on the sheet and move by vector or something like this.
For example, see how a section line affects the viewport:
I have resolved this by turning off ALL annotation categories, get crop box, then turn back on, move the viewpoint as required. It’s a pain, but it works.