Find angle of current view Dynamo 2.x and Revit 2020

Around two years ago I asked for a method to find the angle of the current view. This got answered well and I’ve been using that python script for several years now:

However, I’m currently dealing with a Revit 2020 project which runs in Dynamo 2.x as well, and currently that Python script doesn’t give the right result anymore.

I’m really curious what changed, and especially if someone has an idea on how to tackle this problem.

Can you post the files needed to reproduce the error?

I won’t but I’ll share the script, really all you need and I’m flat out not getting the right value from it:

 #Thanks Kenny!
# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

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

import math


doc = DocumentManager.Instance.CurrentDBDocument

if 1==1:

    # The inputs to this node will be stored as a list in the IN variables.
    activeview = doc.ActiveView
    cropmanager = activeview.GetCropRegionShapeManager()
    if activeview.CropBoxActive:
        shape = cropmanager.GetCropShape()[0]
        iter = shape.GetCurveLoopIterator()
        curve = iter.Current
        ept = curve.GetEndPoint(0)
        spt = curve.GetEndPoint(1)
        dynEPT = Point.ByCoordinates(ept.X, ept.Y)
        dynSPT = Point.ByCoordinates(spt.X, spt.Y)
        newLine = Line.ByStartPointEndPoint(dynEPT, dynSPT)
        nLdirection = newLine.Direction
        xDir = nLdirection.X
        yDir = nLdirection.Y
        angle = math.degrees(math.atan(xDir/yDir))

    else:
        angle = 0
else: 
    angle = 'set runit to true'

OUT = angle #newLine, nLdirection, xDir, yDir,

Looks like this was relying on the direction of the first line drawn to get the orientation. Is that what you were actually after?

Not specifically, just the view rotation, however I can.

That’s the thing, the view might not have a rotation.

Edit a view’s cropbox to be a triangle. Rotate the triangle sketch by a random number between 0 and 60.

What angle is that view rotated?

Of course, but if it doesn’t have a rotation I’m not having any trouble.

What angle is that view rotated?

I’ve tried. The angle simply doesn’t come out right. It’s some number *10^-13

That is the correct number. You just have to take into account the floating point precision. Add a round to the function to the python code, or use a Math.Round node on the returned result. 6 digits should be sufficient.

Except I’m expecting 180 degrees, not zero.

I don’t know if I understood your problem correctly.
The view cropbox rotation :

Might work but I don’t know that package, nor can I find the node in the Geniusloci package.

Edit: nevermind, something went wrong with the package download, I’ll message again when I tried.

When I twist the view 180 or 90 degrees I’m still getting a result of 0.

I can’t reproduce your issue. Is the Genius Loci package up-to-date ?


I just downloaded the last one. I am however using a different method to get the current view, not an element, just the current view.

It is also possible with a view :

With shame I have to admit that the mistake was all mine here.

The angle I considered to be wrong, was an actual problem here and the program had been working as such for years, it had simply never been a problem until recently (no one ever turned the view 180 degrees because there was no need to).

The problem seems to have existed in the 2017-2019 version as well but I simply forgot to test it and the actual problem was completely somewhere else in the graph.

1 Like