Hello,
On a single view it’s working great.
When I try to apply this script on multiple views I get this error:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 74, in
File “”, line 51, in GetViewCropBoxElement
AttributeError: ‘List[object]’ object has no attribute ‘CropBoxVisible’
While the crop regions are visible in all views.
Any idea ?
Best regards, Fred
import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
Import DocumentManager and TransactionManager
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
Import RevitAPI
clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
from System.Collections.Generic import *
Import ToDSType(bool) extension method
clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
################### Definitions ###################
def RotateCropBox(view, cropBox, angle):
doc = DocumentManager.Instance.CurrentDBDocument
bbox = view.CropBox
center = 0.5 * (bbox.Max + bbox.Min)
axis = Line.CreateBound(center, center + XYZ.BasisZ)
TransactionManager.Instance.EnsureInTransaction(doc)
ElementTransformUtils.RotateElement(doc, cropBox.Id, axis, angle*0.0174533)
TransactionManager.Instance.TransactionTaskDone()
return view
def GetViewCropBoxElement(view):
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.ForceCloseTransaction()
tGroup = TransactionGroup(doc, “Temp to find crop box element”)
tGroup.Start()
trans1 = Transaction(doc, “Temp to find crop box element”)
trans1.Start()
view.CropBoxVisible = False
trans1.Commit()
shownElems = FilteredElementCollector(doc, view.Id).ToElementIds()
trans1.Start()
view.CropBoxVisible = True
trans1.Commit()
cropBoxElement = FilteredElementCollector(doc, view.Id).Excluding(shownElems).FirstElement()
tGroup.RollBack()
return cropBoxElement
doc = DocumentManager.Instance.CurrentDBDocument
################### Inputs ###################
#get the bool in port IN[0]…
views = (UnwrapElement(IN[0]))
angle = (UnwrapElement(IN[1]))
center =
RotateCropBox(views, GetViewCropBoxElement(views), angle)
OUT = RotateCropBox