Get Angle

Demonstrates how to interactively pick an angle given a base point and two reference points.

partial class Examples
{
  public static Result GetAngle(RhinoDoc doc)
  {
    var gp = new GetPoint();
    gp.SetCommandPrompt("Base point");
    gp.Get();
    if (gp.CommandResult() != Result.Success)
      return gp.CommandResult();
    var base_point = gp.Point();

    gp.SetCommandPrompt("First reference point");
    gp.DrawLineFromPoint(base_point, true);
    gp.Get();
    if (gp.CommandResult() != Result.Success)
      return gp.CommandResult();
    var first_point = gp.Point();

    double angle_radians;
    var rc = RhinoGet.GetAngle("Second reference point", base_point, first_point, 0, out angle_radians);
    if (rc == Result.Success)
      RhinoApp.WriteLine("Angle = {0} degrees", RhinoMath.ToDegrees(angle_radians));

    return rc;
  }
}
from Rhino import RhinoMath
from Rhino.Commands import Result
from Rhino.Input import RhinoGet
from Rhino.Input.Custom import GetPoint

def RunCommand():
    gp = GetPoint()
    gp.SetCommandPrompt("Base point")
    gp.Get()
    if gp.CommandResult() != Result.Success:
        return gp.CommandResult()
    base_point = gp.Point()

    gp.SetCommandPrompt("First reference point")
    gp.DrawLineFromPoint(base_point, True)
    gp.Get()
    if gp.CommandResult() != Result.Success:
        return gp.CommandResult()
    first_point = gp.Point()

    rc, angle_radians = RhinoGet.GetAngle("Second reference point", base_point, first_point, 0)
    if rc == Result.Success:
        print("Angle = {0} degrees".format(RhinoMath.ToDegrees(angle_radians)))
    return rc

if __name__ == "__main__":
    RunCommand()