# Created views upside down; Rotate crop?

**URL:** <https://forum.dynamobim.com/t/created-views-upside-down-rotate-crop/20484>\
**Category:** Revit\
**Tags:** revit, dynamo\
**Created:** [March 27, 2018, 11:42am UTC](https://forum.dynamobim.com/t/created-views-upside-down-rotate-crop/20484 "2018-03-27T11:42:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjoerd](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@sjoerd](https://forum.dynamobim.com/u/sjoerd)\
**Post date:** [March 27, 2018, 11:42am UTC](https://forum.dynamobim.com/t/created-views-upside-down-rotate-crop/20484/1 "2018-03-27T11:42:36Z")

</div>

I am trying to automate the creation of sheets with 3 section views(top side front) of windows. I used Dieter Vermeulens code to create the section views.

> **[Element View Generation in Revit with Dynamo](https://revitbeyondbim.wordpress.com/2017/02/10/element-view-generation-in-revit-with-dynamo-revised/)**
>
> In October 2015, I wrote this post on this blog about how to automate the generation of detail (section) views of some specific Revit elements by means of a Dynamo graph. With the functionalities a…

To place the views on a sheet I used code from Daniel\_Woodcock1.

> [@Placing views on sheets by coordinates](https://forum.dynamobim.com/t/placing-views-on-sheets-by-coordinates/10901/3):
>
> Hi @mbnbrs. Here is an example using Python to place views on sheet at specific locations (Note: I have only allowed for one sheet at a time)… [PlaceViewsOnSheetByLocation.dyn](https://forum.dynamobim.com/uploads/short-url/asXn2FwEJt1DO8lkxUbSyIEZbEq.dyn) (31.6 KB) I have also added a way to visualise View Placement before actually placing in Revit. I hope this helps. Cheers, Dan

But currently I am running into a problem; the section Side(top) created by Dieter Vermeulens script is upside down, I tried changing various things in the _element view creation code_ but could not manage to get it with the right way upwards.

I then realised I could also make it work by rotating the viewport on sheet, however revit only allows up to 90 degrees rotation on sheets. I tried using the code from the link below but it didn’t do what I desire

> [@Rotate crop views on sheet](https://forum.dynamobim.com/t/rotate-crop-views-on-sheet/4307):
>
> Hi Everyone, I just wonder if anyone come across this idea before, due to my work I have to keep rotate and line up views in sheet. is it anyway we can rotate selected view with Dynamo? The rotate on sheet of Revit is very poor command, I usually have activate every single views then select crop view visible then rotate it. Is there any node or routine to allow rotate selected views? Thanks for reading Vinh

I am now trying to rotate the cropview, effectively rotating the view. But even this I can’t get to work and now I pretty much ran out of ideas.

So I’m wondering can Dieter Vermeulens code be changed in such a way that the side(top) view rotates 180\*. Or if that is not possible can crop views be rotated to effectively rotate the view?

This is what I currently have:

 ![1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/5/d5babbca8db02ae90803b7c1f1c2152ad6703ae7.png)

And this is the result I’m looking for:

 ![2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/4/44685b2076cb5e618d25b04f95498dc94b95d9c2.png)

Thank you in advance

---

<div class="post-metadata">

**Author:** ![sjoerd](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@sjoerd](https://forum.dynamobim.com/u/sjoerd)\
**Post date:** [April 9, 2018, 10:18am UTC](https://forum.dynamobim.com/t/created-views-upside-down-rotate-crop/20484/2 "2018-04-09T10:18:47Z")

</div>

@Konrad_K_Sobon @Dieter_Vermeulen

---

<div class="post-metadata">

**Author:** ![ScottWeiter5186](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/scottweiter5186/32/36460_2.png) [@ScottWeiter5186](https://forum.dynamobim.com/u/ScottWeiter5186)\
**Post date:** [December 11, 2018, 7:25pm UTC](https://forum.dynamobim.com/t/created-views-upside-down-rotate-crop/20484/3 "2018-12-11T19:25:45Z")

</div>

I’ve noticed the same thing and have been looking on how to flip it.

---

<div class="post-metadata">

**Author:** ![sjoerd](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@sjoerd](https://forum.dynamobim.com/u/sjoerd)\
**Post date:** [December 18, 2018, 11:59am UTC](https://forum.dynamobim.com/t/created-views-upside-down-rotate-crop/20484/4 "2018-12-18T11:59:58Z")

</div>

Are you creating views the same way as I am? Because I managed to get them oriented the right direction by playing with the vectors until I got the correct result.  
If not, I’m not sure how to rotate the crop regions. I might have managed to rotate them but don’t quite remember.

---

<div class="post-metadata">

**Author:** ![ScottWeiter5186](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/scottweiter5186/32/36460_2.png) [@ScottWeiter5186](https://forum.dynamobim.com/u/ScottWeiter5186)\
**Post date:** [December 21, 2018, 4:08pm UTC](https://forum.dynamobim.com/t/created-views-upside-down-rotate-crop/20484/5 "2018-12-21T16:08:23Z")

</div>

I will have to play with them and see if I can get them to face the correct direction. Thanks it’s been driving crazy with everyone complaining.

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [December 21, 2018, 5:13pm UTC](https://forum.dynamobim.com/t/created-views-upside-down-rotate-crop/20484/6 "2018-12-21T17:13:25Z")

</div>

Hey,

This works, hopefully you can make use of it…

Happy Christmas,

Mark

```
#all thanks to Konrad @ Archi-lab, Jeremy Tammik and pretty much everyone else on the forum! No credit goes to me for this.

import clr

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

rot = IN[0]
viewport = UnwrapElement(IN[1])

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
	
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)
    TransactionManager.Instance.EnsureInTransaction(doc)
    ElementTransformUtils.RotateElement(doc, cropBox.Id, axis, angle)
    TransactionManager.Instance.TransactionTaskDone()
    
    return view

crpbx = GetViewCropBoxElement(viewport)
crpbxRt = RotateCropBox(viewport, crpbx, rot)

OUT = crpbx, crpbxRt

```

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/d/6d27db1c72d52a58380ba30b4f00ec03c4989bbb.png)

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/f/ef510400020a57dbccb6cf1917a788e329c20e42.png)

---

<div class="post-metadata">

**Author:** ![Dennis\_Pfaff](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Dennis\_Pfaff](https://forum.dynamobim.com/u/Dennis_Pfaff)\
**Post date:** [June 13, 2019, 2:48pm UTC](https://forum.dynamobim.com/t/created-views-upside-down-rotate-crop/20484/7 "2019-06-13T14:48:33Z")

</div>

This is awesome, Thanks!  
Is it possible to feed in a list of viewports?

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [June 13, 2019, 3:34pm UTC](https://forum.dynamobim.com/t/created-views-upside-down-rotate-crop/20484/8 "2019-06-13T15:34:09Z")

</div>

No worries, apologies I can’t test it right now, but amending it to something like…

```
For v in viewport:
    crpbx = GetViewCropBoxElement(v)
    crpbxRt = RotateCropBox(v, crpbx, rot)

```

should work? have a play with it 🙂

Cheers,

Mark

---

<div class="post-metadata">

**Author:** ![linderoth](https://avatars.discourse-cdn.com/v4/letter/l/dec6dc/32.png) [@linderoth](https://forum.dynamobim.com/u/linderoth)\
**Post date:** [June 5, 2021, 4:40pm UTC](https://forum.dynamobim.com/t/created-views-upside-down-rotate-crop/20484/9 "2021-06-05T16:40:43Z")

</div>

Hi! When I try this code, the view rotates but not the crop box…any ideas?

 ![imagen](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/b/db77f7cbbd66647e5493081194957f2b842f506d.png)

Thanks!!
