Match View's cropbox shape

Do you want to match CropBox of one view and apply it to many others? Here is a Snippet with a function to do so.

Tags:  Revit API
Dec 2020

CropBox

It's a simple, but yet handy function. You just need to provide 2 views to match CropBox of a source_view.

There is a method view.GetCropRegionShapeManager() that allows us to .GetCropShape() and to SetCropShape().

code
def match_cropbox_shape(source_view, view):
    # type: (View, View) -> None
    """Function to match cropbox shape outline from source view to another view."""
    source_CropManager = source_view.GetCropRegionShapeManager()
    source_CropShape   = source_CropManager.GetCropShape()

    CropManager = view.GetCropRegionShapeManager()
    CropManager.SetCropShape(source_CropShape)