In Revit, the View and the CropBox have different element Ids. If I want override the crop region outline in a given view, I need to get the cropbox outline in the view. Unfortunately, it has the same Category and Type as the View. I can’t find an api method to get the CropBox from the View. However, by coincidence I realised that the view CropBox element almost always has an ElementId one ‘less’ than the View itself. I know this method is bad (could be unpredictable), so I’m still looking for a better way. Does anyone know correct API process to get the CropBox ‘element’ from the View?
Note: this method was actually successful, I just want it to be more safe:
Awesome Dimitar! Thanks.
What would be the best way to map a given View to these Elements. View Name might be too generic?
if you got a view and want to find the crop box element for that view there is another option:
1. you can turn off the crop box (view.CropBoxVisible = False)
2. then select all elements in a view using the FilteredElementCollector(doc, view.id).ToElementIds()
3. Then the CropBox back on
4. Finally use the FilteredElementCollector(doc, view.id).Excluding(element ids from first collector).FirstElement()
That should give you the CropBox Element.
I packaged up Dimitar’s code and the view name matching method into this node:
This topic is marked as closed to new replies, however your posting capabilities still allow you to do so.