Dear Dynamo Specialist,
My Viewports are dislocated from my sheet position. I know in a Dynamo Graph you can use the Transaction.End and Start.
How to Fix it in Python?
import clr
# Add references to the Revit, Revit Services and TransactionManager
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
#receive Revit Document
doc = DocumentManager.Instance.CurrentDBDocument
SHEETS = IN[0]
VIEWS_2D = IN[1]
VIEWS_3D = IN[2]
VIEWS_BERGING = IN[3]
viewports = []
for PLAATS in range(len(SHEETS)):
TransactionManager.Instance.EnsureInTransaction(doc)
viewports.append(Viewport.Create(doc, ElementId(SHEETS[PLAATS].Id), ElementId(VIEWS_2D[PLAATS].Id), XYZ(0, -320, 0)))
viewports.append(Viewport.Create(doc, ElementId(SHEETS[PLAATS].Id), ElementId(VIEWS_3D[PLAATS].Id), XYZ(175, -245, 0)))
viewports.append(Viewport.Create(doc, ElementId(SHEETS[PLAATS].Id), ElementId(VIEWS_BERGING[PLAATS].Id), XYZ(200, -340, 0)))
TransactionManager.Instance.TransactionTaskDone()
OUT = viewports
Thanks in advance!