Is there a more effective way to fix this issue other than copying and recreating the legends?
#https://forum.dynamobim.com/t/set-crop-region-visible-to-no/44658/4
##from rpw import db.element.Element
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from functools import wraps
from Autodesk.Revit.Exceptions import InvalidOperationException
ViewsDone=[]
ViewPreVis=[]
ViewPreCrop=[]
ViewPreAnno=[]
##https://www.revitapidocs.com/code/#Python_RevitTransactionDecorator-py
def revit_transaction(transaction_name):
def wrap(f):
@wraps(f)
def wrapped_f(*args):
try:
t = Transaction(doc, transaction_name)
t.Start()
except InvalidOperationException as errmsg:
print('Transaciton Error: {}'.format(errmsg))
return_value = f(*args)
else:
return_value = f(*args)
t.Commit()
return return_value
return wrapped_f
return wrap
#@revit_transaction('ViewCropReset') ##Need to understand how wrapping works and how to call
def ViewCheck (views):
for v in views:
v=UnwrapElement(views)
ViewPreVis = v.CropBoxVisible
ViewPreCrop = v.CropView
ViewPreAnno = v.AnnotationCrop
#The inputs to this node will be stored as a list in the IN variables.
views = UnwrapElement(IN[0])
ViewCheck (views)
#TransactionManager.Instance.TransactionTaskDone()
#Assign your output to the OUT variable.
OUT = [ViewPreVis,ViewPreCrop,ViewPreAnno]
Your code also looks off. You have for v in view: but then set v equal to the unwrapped list of views. I assume this should just be the unwrapped view itself (which is also redundant since you unwrap the views before feeding them to ViewCheck).
I’m also not sure what your next steps are, but I don’t think your final output OUT is returning anything. Your function ViewCheck doesn’t return any values. You would likely want to add that output to the function itself and then have OUT = ViewCheck(views).
Thanks Nick. Yeah, it’s odd. I was starting to look at the py wrapper utility but I think it is gone in 2022.
I filtered them out moving forward… but as for all the broken ones- ugh.
I was hoping for a way to reset the limits of the legend view having initially broken them all with the script. Must be an glitch/error in the '22 database. I’ll try an audit repair.
FYI, Legends DO have crop boundaries and you can ONLY turn them on or off in the API. Ran into this with a script that was to turn all crops on / off on a sheet, and it broke all the Legends and it took a little bit before I figured out.
Yes @Nick_Boyts, when I ran into it before it was resolved by setting it back. We too initially thought it was corrupted and tried to copy, but the setting went with it.