Python noob, trying to convert my dynamo scripts to pyRevit python scripts
I’ve got a tool similar to Sync views, but doesn’t run actively and can sync on a sheeted view. I feel I’ve hit wall, can anyone help or point me to a resource about views API.
# import pyrevit libraries
import os
import os.path as op
import pickle as pl
import math
from pyrevit import framework
from pyrevit import script, revit
from pyrevit import DB, UI
from pyrevit import forms,revit,DB,script
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI 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
rect = uiview.GetZoomCorners()
for uv in uidoc.GetOpenUIViews():
if uv.ViewId.Equals( doc.ActiveView.Id ):
uiview = uv
for view in uidoc.GetOpenUIViews():
if not view.ViewId.Equals( doc.ActiveView.Id ):
view.ZoomAndCenterRectangle(rect[0], rect[1])
I’ve managed to get it to 1 single custom node working in Dynamo (iron2.7).
I think I’m messing up on what to call library wise, pyRevit vs dynamo? and how the script exits, based on similar code by Eshan and Gavin
If anyone has any link to a post or YouTube vid roughly about this would be much appreciated
import clr
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI 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
for uv in uidoc.GetOpenUIViews():
if uv.ViewId.Equals( doc.ActiveView.Id ):
uiview = uv
rect = uiview.GetZoomCorners()
exit = []
for view in uidoc.GetOpenUIViews():
if not view.ViewId.Equals( doc.ActiveView.Id ):
view.ZoomAndCenterRectangle(rect[0], rect[1])
exit.append(view.ViewId)
OUT = exit