Skip to content

Instantly share code, notes, and snippets.

@chuongmep
Last active April 10, 2021 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuongmep/bff89c9b58e71bd6315fbe682e85420a to your computer and use it in GitHub Desktop.
Save chuongmep/bff89c9b58e71bd6315fbe682e85420a to your computer and use it in GitHub Desktop.
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