Moving groups.

17 views
Skip to first unread message

surf808

unread,
Sep 26, 2008, 5:52:04 PM9/26/08
to Google SketchUp Help - Ruby API & SketchUp SDK
Hi. I had a question hopefully you could help me with. I have two
programs one which makes the objects and another which calls on it. I
want the program that calls on it to move the objects around. Here is
the code I'm working on.
z = 0
while (z < zdd)
y = 0
while (y < ydd)
x = 0
while (x < xdd)
group2 = group.copy
group2.transformation = [x, y, z]
x = x + stepx
end
y = y + stepy
end
z = z + stepz
end
group.erase!

I can move just one of the blocks but I want to move them all
together. So in short I'm wondering how to make them all into the same
group so I can pass it to the other program and move them around.

Thanks.

Todd Burch - Katy, Texas

unread,
Sep 26, 2008, 6:25:34 PM9/26/08
to Google SketchUp Help - Ruby API & SketchUp SDK
You don't have to put them all in the same group to move them all.
You can apply a transformation to all of them at once with
transform_entities()

See here: http://download.sketchup.com/sketchuphelp/gsu6_ruby/Docs/Ruby-Entities.html#transform_entities

Todd

surf808

unread,
Sep 27, 2008, 5:21:00 PM9/27/08
to Google SketchUp Help - Ruby API & SketchUp SDK
I am still having trouble. What I want to do is draw the entire wall
in one position. Then when that is complete move it to some other
point. When I do the method you suggested the only block that moves
is the last one. I tried something like this

point = Geom::Point3d.new(-400,-400,-400)
t = Geom::Transformation.new point
status = entities.transform_entities t, group2

On Sep 26, 12:25 pm, "Todd Burch - Katy, Texas"
<mr.todd.bu...@gmail.com> wrote:
> You don't have to put them all in the same group to move them all.
> You can apply a transformation to all of them at once with
> transform_entities()
>
> See here:http://download.sketchup.com/sketchuphelp/gsu6_ruby/Docs/Ruby-Entitie...

Todd Burch - Katy, Texas

unread,
Sep 27, 2008, 11:26:41 PM9/27/08
to Google SketchUp Help - Ruby API & SketchUp SDK
The point with transform_entities() I was trying to make, but failed
to do so, was that you can supply several objects at once, like this:

status = entities.transform_entities t, group2 , group1, group3,
group233, group1056, etc.

Todd

surf808

unread,
Sep 28, 2008, 12:39:03 AM9/28/08
to Google SketchUp Help - Ruby API & SketchUp SDK
Oh I see. Isn't there a way to transform them all at once? Is there
a way of selecting all objects on a certain layer and transforming
them?

On Sep 27, 5:26 pm, "Todd Burch - Katy, Texas"

surf808

unread,
Sep 28, 2008, 9:22:00 PM9/28/08
to Google SketchUp Help - Ruby API & SketchUp SDK
I got it to work. What I did was make a new group. I called it
group3[count] = group2. So I copy each in the while loop. Then I
have another to move them all again counting through each count in the
group3. If you have a better suggestion let me know.

group3 = []
count = 1
z = 0
while (z < zdd)
y = 0
while (y < ydd)
x = 0
while (x < xdd)
group2 = group.copy
point = Geom::Point3d.new(x, y, z)
t = Geom::Transformation.new point
entities.transform_entities t, group2
group3[count] = group2
count = count + 1
x = x + stepx
end
y = y + stepy
end
z = z + stepz
end
group.erase!

UI.messagebox count
point = Geom::Point3d.new(pointx,pointy,pointz)
t = Geom::Transformation.new point
count = 1
while (count <= 126)
group3[count].transform! t
count = count+1
end

Todd Burch - Katy, Texas

unread,
Sep 28, 2008, 10:01:22 PM9/28/08
to Google SketchUp Help - Ruby API & SketchUp SDK
You don't need to create yet another group if you don't want to - just
pass all the groups you want to move to transform_entities in a single
call. Done - finished - simple.

transform_entities() accepts a varying list or arguments - it doesn't
care how many you pass.

To move everything in the model up two units, you could create your
[0,0,2] transformation as "t", then call the method like this:

Sketchup.active_model.entities.transform_entities( t ,
Sketchup.active_model.entities )

Todd

surf808

unread,
Sep 29, 2008, 5:32:16 PM9/29/08
to Google SketchUp Help - Ruby API & SketchUp SDK
I tried your suggested method and get the error that
transform_entities. It says wrong argument type (expected
Sketchup::Entity).

On Sep 28, 4:01 pm, "Todd Burch - Katy, Texas"

Todd Burch - Katy, Texas

unread,
Sep 29, 2008, 6:18:35 PM9/29/08
to Google SketchUp Help - Ruby API & SketchUp SDK
Yes, I wasn't 100% precise, and no, you didn't think for yourself to
figure it out.

If the following is entered from the Ruby console, it will shift
everything to the right 50 units (when viewed from the default plan
view):

ent = Sketchup.active_model.entities
t = Geom::Transformation.new( [ 50 , 0, 0 ] )
ent.transform_entities( t , ent.to_a )

Todd
Reply all
Reply to author
Forward
0 new messages