If you want to deal with it post selection, then you can test the Selection set …
ss = Sketchup.active_model.selection
if !ss.empty? && ss.single_object? && ss.first.is_a?(Sketchup::Face)
# do stuff
end
But there is a problem. If the user picked a face within a group (or instance) they’d need to be in that context, because if they back out, the selection set is cleared.
So, that rules out post selection, … so you need to write a Ruby tool class, and have your tool use the PickHelper class which can pick through contexts.
This is big problem because groups and instances do not actually “own” drawingelement entities.
It is their definition that has the entities collection.
Luckily, the PickHelper class has a #path_at method that lets you retrieve a path array of the nesting down to the face.
Make sure you read ThomThom’s help blog on PickHelper.