When adding groups components programmatically you got to think somewhat different from when you model.
When you model you first make the geometry and then group or make a component out of it.
When you program you create the group or component first and then add the geometry directly inside it.
model = Sketchup.active_model
entities = model.entities
# Create a series of "points", each a 3-item array containing x, y, and z.
pt1 = [0, 0, 0]
pt2 = [20, 0, 0]
pt3 = [20, 20, 0]
pt4 = [0, 20, 0]
# Call methods on the Entities collection to draw stuff.
new_face = entities.add_face pt1, pt2, pt3, pt4
new_face.pushpull 0.75
# Draw a circle on the ground plane around the origin.
center_point = Geom;;Point3d.new(1,1,0)
normal_vector = Geom;;Vector3d.new(0,0,1)
radius = 0.3
# Make a new component definition
comp_def = model.definitions.add("Cylinders")
# Generate the geometry. Note that component definitions has and Entities collection - as model does.
edgearray = comp_def.entities.add_circle(center_point, normal_vector, radius)
first_edge = edgearray[0]
face = first_edge.faces.select { |f| (f.outer_loop.edges & edgearray).length == edgearray.length }.first
face.pushpull(3)
# Now add an instance of hte component to the model
transformation = Geom;;Transformation.new([2,1,0])
componentinstance = entities.add_instance(comp_def, transformation)