Created views upside down; Rotate crop?

dynamo
revit

#1

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.

To place the views on a sheet I used code from Daniel_Woodcock1.

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

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:

And this is the result I’m looking for:

Thank you in advance


#2

@Konrad_K_Sobon @Dieter_Vermeulen


#3

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


#4

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.


#5

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.


#6

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