Hi all,
I am a bit stumped and any help would be appreciated.
I have a group which I want to copy/transform multiple times to various distances on the Z axis. The first three groups move only, the remaining groups move and rotate. (code below)
-
How do I change the rotation origin from global to a set position? Global = [0,0,0] new origin = [0,0,2327.mm]
-
Does being in a loop have an impact on changing the origin?
mod = Sketchup.active_model
ent = mod.active_entities
sel = mod.selection
# THE Z DIST FOR EACH GROUP FROM GLOBAL ORGIN [0,0,0]
z_dist = [0.mm, 50.mm, 147.mm,
2327.mm, 2339.mm, 2364.mm,
2402.mm, 2499.mm, 2500.mm]
# THE NUMBER OF GROUPS
num_copies = levels.length-1
# VERTICES FROM SELECTION
pts_arr= sel.grep(Sketchup::Face) {|f| f.vertices.map{|v| v.position } }
# VERTICES TO GROUP
group = ent.add_group(sel.to_a)
ent = group.entities
pts = ent.add_face (pts_arr)
# LOOP THE NUMBER OF GROUPS
for i in 1..num_copies
# Z DISTANCE NUM IS = TO NUM OF GROUPS
zed = z_dist[i]
orgin = [0,0,0]
# IF Z DIST > 2 THE ANGLE = 5 DEGREES ELSE ANGLE = 0
if i >2 then d = -5
# orgin = [0,0,2327] ????????????
# HOW TO CHNAGE THE TRANSFORMATION ORIGIN
else
d = 0
end
z_pos = Geom::Vector3d.new(0,0,zed.to_i)
tr_rot = Geom::Transformation.rotation(orgin, X_AXIS, d.degrees)
tr_mov = Geom::Transformation.translation(z_pos)
transform = tr_rot * tr_mov
t = group.transformation
t = transform
new_group = group.parent.entities.add_instance(group.entities.parent,t)
new_group.name = "group#{i+1}"
end