How to Reset Crop view using Dynamo

Something went wrong in @solamour’s formatting. There’s a flaw in the if-sentence indentation:

i corrected it here:

import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument

view = UnwrapElement(IN[0])

# If the Input List doesn't have the attribute of '__iter__' (Which means iterable 
# - i.e it's an object that contains objects such as a 'List') then we want to 
# wrap that singular item (In our case a view) into a List of one thing. 
# This way our For Loop will never fail :)

if not hasattr(view, '__iter__'):
	view = [view]

TransactionManager.Instance.EnsureInTransaction(doc)

for v in view:
	if v.CropBoxActive == True:
		csm = v.GetCropRegionShapeManager()
		csm.RemoveCropRegionShape()

TransactionManager.Instance.TransactionTaskDone()

OUT = 0

This ran without errors with a list of views.

What a messy thread. Sorry :smiley:

7 Likes