Last active
April 10, 2021 02:33
-
-
Save chuongmep/bff89c9b58e71bd6315fbe682e85420a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static double Angle(Autodesk.Revit.DB.TextNote textnote) | |
{ | |
XYZ direction = textnote.UpDirection; | |
XYZ coordinate = new XYZ(0, 1, 0); | |
double angle = direction.AngleTo(coordinate) * 180 / Math.PI; | |
double baseX = textnote.BaseDirection.X; | |
double baseY = textnote.BaseDirection.Y; | |
double upX = textnote.UpDirection.X; | |
double upY = textnote.UpDirection.Y; | |
if (baseX <= 0 && baseY >= 0 && upX >= 0 && upY >= 0) return angle; | |
if (baseX >= 0 && baseY >= 0 && upX <= 0 && upY >= 0) return angle; | |
if (baseX <= 0 && baseY >= 0 && upX <= 0 && upY <= 0) return angle; | |
if (baseX <= 0 && baseY <= 0 && upX >= 0 && upY <= 0) return 360 - angle; | |
if (baseX >= 0 && baseY <= 0 && upX >= 0 && upY >= 0) return 360- angle; | |
return angle; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment