Hamed, This is a general problem and may happen many times. When you want to write some code for a group or component you’d better move it to the original coordinate and after finish codes return it back.
sele = Sketchup.active_model.selection
# Save the current transformation:
xform = sele.transformation
# Revert the current transformation:
# Create a new compound transformation with scaling:
compound_xform = Geom::Transformation.scaling(xform.origin, 2, 1, 1) * xform
# Apply the compound transformation:
sele.transform!( compound_xform )
@majid866, your code is being applied to the definition’s entities which will effect ALL instances rather that the instance selected.