Rotate Section view. Not the section

Hey,

I am trying to rotate the section view. The view, not the section element.
My current section:


The result i want is to rotate the view 180 degrees like shown below.

With my current script i am rotating the section element and not the view.
Thanks!

Current script:
I created a section. Fill some parameters and am now trying to rotate the view.

Get the crop region of the view and rotate that. I believe the post below covers it.

1 Like

Here is code to rotate the crop region. It requires you to provide the crop region, a rotation axis line and the rotation degrees in radians.

import clr

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

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
from Autodesk.Revit.DB import XYZ, Line, ElementTransformUtils

doc = DocumentManager.Instance.CurrentDBDocument
crpreg = UnwrapElement(IN[0])
angle = IN[1]
line_axis = UnwrapElement(IN[2])
rot = []

crId = crpreg.Id
axis = line_axis.ToRevitType()

	
	
TransactionManager.Instance.EnsureInTransaction(doc)
ElementTransformUtils.RotateElement(doc, crId, axis, angle)
TransactionManager.Instance.TransactionTaskDone()

OUT = crpreg,angle
2 Likes

Thanks for your reply,]
But i dont seem to get it to work…
I think i am messing up with the line axis
I want to rotate it around its own axis

Hi @MelleH …this element rotate you show in first image is that one from genius loci, because that one should work i think…

1 Like

Hey,
I tried that, but it just rotates the section.
I think i found a workaround tho!
I rotate the view and the I reapply the cropbox.

1 Like

I believe the code I provided is similar to what the rhythm node is doing. But since you have it working with rhythm, that’s will be the best option.

FYI, for the axis line, you need to get a center point of the view and the view direction and use that with line by start point and direction. We only use the tool on assembly views. So to get a good center point of the view, I get a bounding box of the element in the view and the center point of the bounding box. This pretty much forces the view to stay in the exact same place. I also reset the crop region after the view has been rotated. This is mainly for when the view has been rotated 90 degrees.

1 Like