View.CropBox is a read-only property that cannot be edited

Hi, I have been struggling for a few days and trying to find solutions to the problem I have. I am trying to edit the CropBox of a 3D view, because the Dynamo Node does not let me do that with an axonometric 3d View. So I tried it using methods I found online, and that are reported as working but when I try to change the value of the CropBox it says that the CropBox is a read-only property. Has it ever happened someone else that the cropbox of a view is not editable? How to get around it? The inputs is an axonometric 3d view, and a bounding box whose values I tried to editing the cropbox with. Thanks in advance!

# Phython-Standard- und DesignScript-Bibliotheken laden
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from Revit.Elements import *
from Autodesk.Revit.DB import BoundingBoxXYZ, XYZ

doc = DocumentManager.Instance.CurrentDBDocument


# Die Eingaben für diesen Block werden in Form einer Liste in den IN-Variablen gespeichert.
dataEnteringNode = IN
view = IN[0]
bbox = IN[1]
try:
    TransactionManager.Instance.EnsureInTransaction()

    # Create a new BoundingBoxXYZ
    box = BoundingBoxXYZ()
    box.Min = XYZ(bbox.MinPoint.X, bbox.MinPoint.Y, bbox.MinPoint.Z)
    box.Max = XYZ(bbox.MaxPoint.X, bbox.MaxPoint.Y, bbox.MaxPoint.Z)
    print(box.Min, bbox.MinPoint)
    
    # Set the crop box of the view
    view.CropBox = box  # Here is where I get the message that the property CropBox is read-only. 

    # Complete the transaction
    TransactionManager.Instance.TransactionTaskDone()
    
    OUT = "It worked"
except Exception as e:
    OUT = "Error: " + str(e)

Can you currently apply a crop box to that view in Revit?

2 Likes

Along these lines, 3D views are not accessbible as view templates in Revit, could be the crop boxes are not either? I know I have to filter out my 3D view templates when working with collectors because they return nulls.

1 Like

Hi,

for 3D Views it’s necessary to use the SetSectionBox() method

1 Like

happen to me issue was that one of the views (was changing multiple views) had an scope box assigned to it.

Thank you for the tip! But it seems like my axonometric view does not have a SetSectionBox() attribute. I try to implement it almost the same way as I did with CropBox, view.SetSectionBox(box) but it has no attribute according to the error message.

We can crop that view yes, if I understand the question correctly

And, to add, the CropBox is both turned on and visible in Revit

1 Like

Hi,
there is an example here, maybe it helps you

1 Like

Haha! I mistakenly responded in the other thread. I am gonna try that now.

Sorry for the delay, tried the script you recommended, and I managed finally. I think it might have just been the case of me before not unwrapping the element. Thank you for the help!