# Rotate crop views on sheet

**URL:** <https://forum.dynamobim.com/t/rotate-crop-views-on-sheet/4307>\
**Category:** Developers\
**Tags:** revit\
**Created:** [June 3, 2016, 12:59am UTC](https://forum.dynamobim.com/t/rotate-crop-views-on-sheet/4307 "2016-06-03T00:59:32Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Konrad\_K\_Sobon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/konrad_k_sobon/32/8838_2.png) [@Konrad\_K\_Sobon](https://forum.dynamobim.com/u/Konrad_K_Sobon)\
**Post date:** [June 3, 2016, 1:34pm UTC](https://forum.dynamobim.com/t/rotate-crop-views-on-sheet/4307/7 "2016-06-03T13:34:05Z")

</div>

Why not? It’s pretty simple. Here’s some code:

```auto
    def RotateCropBox(view, cropBox, angle):
        doc = DocumentManager.Instance.CurrentDBDocument
	bbox = view.CropBox
	center = 0.5 * (bbox.Max + bbox.Min)
	axis = Line.CreateBound(center, center + XYZ.BasisZ)
	ElementTransformUtils.RotateElement(doc, cropBox.Id, axis, angle)
	return view

```

Now the trick of course is to get the proper angle to rotate the view by, because I am guessing that you are looking to align it with some element in view (wall, grid etc.). To get view crop box I was using a little trick that Jeremy Tammik shared on his blog:

```auto
def GetViewCropBoxElement(view):
	doc = DocumentManager.Instance.CurrentDBDocument
	TransactionManager.Instance.ForceCloseTransaction()
	tGroup = TransactionGroup(doc, "Temp to find crop box element")
	tGroup.Start()
	trans1 = Transaction(doc, "Temp to find crop box element")
	trans1.Start()
	view.CropBoxVisible = False
	trans1.Commit()
	
	shownElems = FilteredElementCollector(doc, view.Id).ToElementIds()
	
	trans1.Start()
	view.CropBoxVisible = True
	trans1.Commit()
	
	cropBoxElement = FilteredElementCollector(doc, view.Id).Excluding(shownElems).FirstElement()
	tGroup.RollBack()
	return cropBoxElement

```

What happens here is that you turn off the crop box, select everything in view, then create exclusion filter for all these elements, then turn the crop box back on and select everything but previously selected things. This should leave you with the only new thing visible in view: CROP BOX.

I will leave the rest for you to figure out.

Cheers!

---

_[View the full topic](https://forum.dynamobim.com/t/rotate-crop-views-on-sheet/4307)._
