Creating a component from a face crashes SketchUp!

My goal to achieve:
My goal is to convert all faces of a component to a component without losing the materials and their positions.

We have already worked on it in this topic and we have come to the conclusion that it is better to redraw faces from an edge.

This is why I need to find the exact UVs to apply to my new face component.

Is causing problem:
It seems to me that the method “face.get_UVHelper” included in are equoition the scale of the material and the position of the vertices of the face used.

As my method aims to convert these faces to a component, the position of the vertices are not the same because the original axis of the parent changes.

Conclusion:
Using get_UVHelper on a face before converting it to a component will not give the correct material position coordinates because the original axis will have changed.


I have just modified my profile as you requested, yes I am using Windows and SketchUp Make 2017.

Thank you for this tip which will prevent me from using “each” unnecessarily to browse a group.
I am aware that a group is created from the original axes of the model and that the faces have no edges.
Calculating the UVs of all the faces of a component is simple, the problem is that I convert my faces into a component which changes the UVs.


Going back to the basic problem:
I now know that grouping a face in a component necessarily causes Sketchup to crash when exiting the model:

mod = Sketchup.active_model
ents = mod.active_entities
sel = mod.selection	
sel.grep(Sketchup::ComponentInstance) do |s| 
  s.definition.entities.grep(Sketchup::Face) do |f| 
    ents.add_group(f)
  end
end