Parent Group of a Face

Perusing the forum I can’t seem to find an easy way to find the parent group of a face.

I’m using the picked_face method to grab the best face and now I want to grab the handle to the group that contains this face.

So far my code is simply:

@ph.do_pick(x, y)
@best_face = @ph.picked_face

I mistakenly thought the parent method would do this for me but instead it gives me the definition handle. I know I’m not the first to run into this.

@ph.element_at(@ph.count-2)

The path is a 0 based array. Index pickhelper.count-1 would be the last item. So -2 is the instance/group above the leaf.

1 Like

You might also try …

if @best_face
  ipath = @ph.view.inputpoint(x,y).instance_path
  @face_owner =( ipath.nil? ? ipath : ipath[-2] ) # check for nil !
end
1 Like

Sheesh, why didn’t I think of that, it’s so obvious. Your first example, not the second.