# How to move a group with entities to global origin

hi guyes
I create a group and add to group face

``````group1 = entities.add_group
face = group1.definition.entities.add_face(f, f, f, f)``````

Next I will rotate everything in this group

``````[X_AXIS, Y_AXIS].each { |axis|
if not face.normal.samedirection?(Z_AXIS)
if face.normal.perpendicular?(axis)
angle = face.normal.angle_between(axis)
angle = 180 - (angle * 180 / Math::PI)
rotation = Geom::Transformation.rotation(group1.bounds.center, axis, angle.degrees)
group1.entities.transform_entities(rotation, group1.entities.to_a)
end
end
}``````

Next I need to move everything to the origin of global coordinates. How to do it?
group1.transformation.origin have zero coordinats, but group1 is not at zero.
how to move a group or its contents to another location?

Why are you rotating the entities of the group and not the group as a whole ?

If i rotating the group, I will not be able to determine the direction vector of the face inside the group, coordinates will be old, inside the group, the local coordinate system is used as in the Components

After rotating the group (as a whole) you should be able to get the normal vector direction of the face:

``````face_global_normal = face.normal.transform(group1.transformation)
``````

But this assumes that the current editing context is the top level model entities and that `group1` is a entity child in this context.

1 Like

It really works with the face and I rotated the group as I needed.
Now group1.transformation.origin shows coordinates, but these coordinates has nothing to do with the real ones. If I rebuild the group of these entities manually group1.transformation.origin show me real global coordinats. Why is this and how to solve it?
This is the code how to recreate the group:

``````ents = group1.explode
ents.select!{|e|
if e.is_a?(Sketchup::Face) or e.is_a?(Sketchup::Edge)
next e
end
}``````

You need to post the model in the problem state.