GetPoint Not Working at Certain Angles

At the risk of sounding like a dunce, I’m having some issues getting my GetPoint to work reliably when the camera is positioned at certain angles to view objects that are far removed from the XY world plane.

While running the command and moving the camera/cursor around I will periodically find that the little preview point from the GetPoint just stops following the crosshair cursor like it’s stuck somewhere and unable to compute the current location. If I leave the camera in exactly this position, end my command, and re-start my command, I’ll then see the that I’m still in this invalid state but my cursor is now a red warning symbol instead of the usual crosshairs.

I do not understand why this happens. Perhaps my GetPoint is configured incorrectly?

Here is the code for my full test command:

using Rhino.Commands;
using Rhino.Input.Custom;
using Rhino.Input;
using Rhino;

public class TestGetPointCommand : Command
{
    public TestGetPointCommand()
    {
        Instance = this;
    }

    public static TestGetPointCommand Instance
    {
        get; private set;
    }

    public override string EnglishName => $"TestGetPoint";

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
        var getPoint = new GetPoint();
        getPoint.AcceptCustomMessage(true);
        getPoint.AcceptNothing(true);
        getPoint.ConstrainToTargetPlane();
        getPoint.ClearConstraints();
        getPoint.PermitObjectSnap(false);
        getPoint.PermitOrthoSnap(false);

        Result getPointCommandResult;

        while (true)
        {
            // Reset command options
            getPoint.ClearCommandOptions();

            // Get
            getPoint.Get(true);

            // Command results
            getPointCommandResult = getPoint.CommandResult();

            // Anything other than Success means we end the loop unsuccessfully
            if (getPointCommandResult != Result.Success)
            {
                break;
            }

            // Get results
            GetResult getPointGetResult = getPoint.Result();

            // End loop successfully
            if (getPointGetResult == GetResult.Nothing)
            {
                break;
            }

            if (getPointGetResult == GetResult.Point)
            {
                RhinoApp.WriteLine(getPoint.Point().ToString());
            }
        }

        // Check if we broke out of the option loop successfully
        if (getPointCommandResult != Result.Success && getPointCommandResult != Result.Nothing)
        {
            return getPointCommandResult;
        }

        return Result.Success;
    }
}

Any insight would be appreciated. I’ve included a 3dm which when you open it and then run my command it should demonstrate my problem at the saved camera angle & position.

GetPointTest.3dm (240.1 KB)

1 Like

I can repeat this somewhat simply by trying to place a Rhino point (object snaps disabled) with the Point command - which uses the same GetPoint() method in the background. The problem is that if there is no object snap active - which you disabled with getPoint.PermitObjectSnap(false) - then by default GetPoint() is looking for a screen pick (pixel) the projection of which falls on the active CPlane’s XY Plane. But, if you are looking from below the horizon, at the angle you show, it cannot find the plane anywhere on the screen to project to…

Thank you for your assistance. Your explanation made sense to me and I was able to fix the issue by implementing your suggestion.