Dec 1, 2020
Get CropBox Id in Revit with Python.
Learn how to get CropBox Id in Revit API.
1️⃣ FilteredElementCollector.Excluding()
The first method is quite straight forward and goes like this:
Hide the CropBox
Use FilteredElementCollector(doc, view_id) to collect all elements you can see in the view.
Unhide the CropBox
Use FilteredElementCollector again, but this time exclude elements you collected the first time with .Excluding(element_ids)
Get ElementId of the CropBox from the collection.
Lastly, RollBack your Transactions so nothing has changed.
This method is a bit messy because of multiple transactions. So I have another option.
FilteredElementCollector.WherePasses()
I have found an article by Jeremy Tammik - "Efficiently Retrieve Crop Box for Given View" in C#.
So I've translated it to python for people who don't "speak" C# well enough. I encourage you to read his article to better understand the logic behind this function.
Be aware that FilteredElementCollector will grab CropBox and View so be aware of that.
Want to Learn More?
🔥 Amazing Revit API Resources!
Join Revit API
Newsletter Today!
Join Us!
which is already read by 4000+ people!
Get short Revit API Lessons and Tips directly in your mail!