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:
I’ve been creating a family that contains several parts that need to be placed seperately, I managed to streamline a lot of that using
Sastrugi’s pick points on worklplane (thanks a ton for that one @Ewan_Opie) as well as using this great python script which creates pop up window from which you can get data (I’m still having projects in Revit 2017 so making use of a more advanced Dynamo Player isn’t really an option).
Anyway, with placing the parts I’ve ran into one problem: the angle of the fa…
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:
# Enable Python support and load DesignScript library
from Autodesk.DesignScript.Geometry import *
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
# The inputs to this node will be stored as a list in the IN variables.
activeview = doc.ActiveView
cropmanager = activeview.GetCropRegionShapeManager()
shape = cropmanager.GetCropShape()
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))
angle = 0
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.