Using PickContext in RhinoCommon

I am trying to do some custom pick filtering using the PickContext class. I found the C++ sample that uses the CRhinoPickContext at:

In implementing this in C# I cannot find the equivalent of RhinoDoc.PickObjects to find the objects that takes the PickContext and finds all objects that intersects the pick frustum. Is there an equivalent in C#?

Thanks, Larry

I think there is an example of what you are looking for in the Gumball example code: https://wiki.mcneel.com/developer/rhinocommonsamples/gumball

Look at OnMouseDown in the sample code:
Rhino.Input.Custom.PickContext pick_context = new Rhino.Input.Custom.PickContext();

HTH, Tom

Thanks Tom. The gumball example does a good job of showing how to use the PickContext in RhinoCommon. What I still don’t follow is how you perform the object intersection testing once you’ve constructed the PickContext. The C++ sample has a doc.PickObjects method to retrieve the objects intersected by the PickContext. In the gumball example it looks like the PickContext is used to set the gumball dragging constraints. In my case I’ve set up the PickContext but can’t see how to perform the object hit testing, specifically to see what subobjects are intersected in a brep.

Hey Larry,
I was making some fixes to this function last week :slight_smile: It is located on the document’s ObjectTable…

doc.Objects.PickObjects(pickcontext);

I’m not sure if my fixes made it into the WIP that you are currently using or if they are in the WIP that will be available tomorrow (guess you’ll know if the function crashes Rhino.)

1 Like

Thanks Steve. I was running the 11/15 version which didn’t appear to expose the method. That will teach me to stay up to date:)

I’ll let you know if I run into any issues.

I’ve installed the latest WIP version and the PickObjects method is there on the RhinoDoc class; in doing some testing on breps with many faces, I’ve set the SubObjectSelectionEnabled flag to true on the PickContext object, however when I call PickObjects I always get back the brep object I clicked on but none of its subobjects; I would have expected to get faces back in a shaded mode; is there something else I need to do to select brep faces using the PickContext?

Thanks, Larry

@dale or maybe @mikko, do you have any suggestions on properly setting up a pick context for subobject selection for Larry?

@lleibman, I’ll try to cook up a sample for you.

– Dale

Thanks @dale, let me know if you need any add’l info.

Larry