how to add multiple group together to be a group/component

36 views
Skip to first unread message

Yafei Guan

unread,
Apr 23, 2016, 8:46:07 AM4/23/16
to SketchUp Ruby API
I used this code to draw and then rotate it/them to be multiple spheres on parallel rings. I can draw a sphere at any position and I can move it as a group and rotate it to generate more on a ring. but I still want to make all the spheres on the same ring to be a group or a component, then I can move or rotate them as a piece.
Could any body help me to figure it out how to make a group / component?
+++++++++++++++
c1 = group1.entities.add_circle(
ball_center, main, ball_radius)
c2 = group1.entities.add_circle(ball_center, path_main, ball_radius+1)
f = group1.entities.add_face(c1)
f.material= ball_color
f.material.alpha = 10
ball0=f.followme(c2)
ball0=c2.each {|edge| edge.erase!}
new_comp_def=group1.to_component

range=5
n=29
#0 1 2 3 4 5,,,29
y_location=n*35 # 0 35 70 105,,,,,+35
componentinstance_ball=Array.new( number_of_ball_per_ring )

# generate next ball on same ring
for i in 0..(number_of_ball_per_ring-1)
transformation_ball = Geom::Transformation.new [0, 0, ring_high], [0, ring_high, 0], radians*i+rand()*range*Math::PI/180 
#componentinstance_ball[i] = entities.add_instance(new_comp_def.definition, transformation_ball)
componentinstance_ball[i] = Sketchup.active_model.active_entities.add_instance(new_comp_def.definition, transformation_ball) 
#I want to add componentinstance_ball[i] to a group or component,,,,,
end

+++++++++++++++

Yafei Guan

unread,
Apr 23, 2016, 8:56:30 AM4/23/16
to SketchUp Ruby API
the attachment is what  I suppose to do, but I can not make this by coding.
thanks
group.jpg
Reply all
Reply to author
Forward
0 new messages