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)
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.
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.
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!