PickObjects always returns an empty array

Hello,

I can not get Function PickObjects to work.
I checked the arguments, everything is fine.

The GetFrustumLine signature is :
public bool GetFrustumLine (double screenX, double screenY, out Line worldLine);
but in the example https://wiki.mcneel.com/developer/rhinocommonsamples/gumball, screenX and screenX are set with a client point (GetPointMouseEventArgs.WindowPoint)

Can you confirm me that the GetFrustumLine take a screen coordinates ?

Does the PickObjects function work for you ?

my code:

    class Helper
    {
        public static int PickObjects (Rhino.RhinoDoc doc, RhinoView view, System.Drawing.Point clientPoint, ref ObjRef[] Objects)
        {
            if( view == null ) return 0;

            var vp = view.ActiveViewport;

            PickContext ctx = new PickContext ();
            ctx.View = view;
            ctx.PickStyle = PickStyle.PointPick;
            ctx.PickMode = PickMode.Shaded;

            var xform = vp.GetPickTransform (clientPoint);
            if( xform == null ) return 0;
            ctx.SetPickTransform (xform);

            var screenPoint = vp.ClientToScreen (clientPoint);
            vp.GetFrustumLine (screenPoint.X, screenPoint.Y, out Line ln);
            ctx.PickLine = ln;
            ctx.SubObjectSelectionEnabled = true;
            ctx.UpdateClippingPlanes ();

            Objects = doc.Objects.PickObjects (ctx);
            return Objects.Length;
        }
    }

Thank you.

Hi @kitjmv,

Is there a reason you want to use this method instead of just using a GetObject object?

– Dale

Hello Dale,

Yes, Actually i build a custom contextual menu based on the selection.

In Rhino v6, the ability to select sub-objects adds a new way to build volumes.

So i use a lot of gumball and the shortcuts for it (like Move or Extrude) but the combination of keys is not alway easy.
And when we are outside a command, we can not select the loops but just the edges.

For these two reasons, I would like to add to my menu the possibility of selecting the sub-object below the pick point.

And also, inside my code i can substract an sub object to the object, for exemple:
Object1 - Object1.Edges[0] == All other edges
Object1 - Object1.Faces[0] == All other faces

The menu can be this:

I have read the documentation and I don’t see any other way with the C # API.

But despite my efforts, the PicObjects function does not want to work and I do not understand why …

Thank you.