Get rotation of cropped view

Hi

I have some views which have ‘crop view’ assigned. The crop region has been rotated and I’m trying to work out by how much so that I can sync this with a north point.

View direction (from Clockwork) returns I think the view plane - so a floor plan is 0,0,1. I think the parameter i need is ‘UpDirection’ but not sure how to retrieve it.

I though i could modify the Python script within the View.Direction custom node but it is returning different results.

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

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

def ViewDirection(view):
	if hasattr(view, "UpDirection"):
		return view.UpDirection.ToVector()
	else: return None

views = UnwrapElement(IN[0])

if isinstance(IN[0], list): OUT = [ViewDirection(x) for x in views]
else: OUT = ViewDirection(views)

Any suggestions?

Hey @Paul_Wintour,

Python:

import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

view = UnwrapElement(IN[0])

res = view.UpDirection

OUT = res
4 Likes

Thanks @MartinSpence. I modified slightly to take multiple views…

import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

view = UnwrapElement(IN[0])
res = []

for v in view:
	res.append(v.UpDirection)

OUT = res

Do you know what time of output it is? It seems to be a string instead of a vector or point. As a hack I’ve used split string but I’m sure there is a better way to handle it within the Python code.

Hey Paul,

Yeah cool :slight_smile:

It outputs a vector. I’ve tried to illustrate it here, where I’ve converted the Revit Vector to a DS vector:

I have manually rotated the crop 30 degrees.

1 Like