RobotStudio event

GraphicPicker and surface normal

Hi!

I'm using GraphicPicker class on some of my RS AddIns and I was just wondering what is the easiest way to get the surface normal vector form the picked position? GraphicPickEventArgs doesn't seem to contain that information so currently I'm using ProjectRay on the selected position to get a ProjectObject. Then I cast PO to either Face or Part type and the I use GetNormalToSurface and TryGetNormalToSurface methods which give me the normal vector. It works somehow but I would like to know if there's a better way.

-Keijo

Comments

  • Hi Keke,
    Your approach seems right but I'm not sure why you would need to call ProjectRay(), since GraphicPickEventArgs contains the picked object.

    Regards,
    Johannes
    Johannes Weiman
    Software Engineer
    RobotStudio Team, ABB Robotics
  • You are right, but I usually want to reset selection mode and in that case GraphicPickEventArgs.PickedObject is null. ProjectRay gives me the object regardless of the selection mode.

    The reason why I want to usually reset selection mode is that when picking positions I don't really want to select bodies or parts (I don't want to change the color). Also if I have Group selection on and there are hidden parts in the group, those become visible when group is under the cursor. Same with Part selection and hidden bodies. This is very annoying when trying to pick positions inside some enclosure whose walls are hidden. These are of course small issues but devil is in the details :)

    -Keijo