"Attribute error" 'list[object]' object has no attribute 'CropBoxActive'

Hi all,

I am trying to assign crop box to floor plan views using bounding boxes.

In the script below, I am using View properties in the API to apply the bounding box. However, it reflects “Attribute error” ‘list[object]’ object has no attribute ‘CropBoxActive’.

Any help to diagnose is appreciated.

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements) 

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

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

doc = DocumentManager.Instance.CurrentDBDocument

# The inputs to this node will be stored as a list in the IN variables.
newBB = IN[0]
views = UnwrapElement(IN[1])
output = []


TransactionManager.Instance.EnsureInTransaction(doc)
views.CropBoxActive = True
views.CropBox = newBB
output.append(views)

# Place your code below this line
TransactionManager.Instance.TransactionTaskDone()
# Assign your output to the OUT variable.
OUT = output

Hi @JHJHJHJH,

You have a list of one view with the node FloorPlanView.ByLevel so you have to iterate over the element in the list :

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements) 

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

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

doc = DocumentManager.Instance.CurrentDBDocument

# The inputs to this node will be stored as a list in the IN variables.
newBB = IN[0]
views = UnwrapElement(IN[1])
output = []


TransactionManager.Instance.EnsureInTransaction(doc)
for view in views :
	view.CropBoxActive = True
	view.CropBox = newBB
	output.append(view)

# Place your code below this line
TransactionManager.Instance.TransactionTaskDone()
# Assign your output to the OUT variable.
OUT = output 

The function Cropbox expects a BoundingBoxXYZ (Revit Boundingbox).

1 Like

@Alban_de_Chasteigner Thanks for your help Alban! :slight_smile: