As a matter of fact, I am dumb.
I have written this piece of code to rotate a group or component around its bounding box's center. It works for the red and the green axis, but not for the blue one. Ridiculously, I can't see why. Probably I've spent too much time on this one. Can you help?
Thanks a lot,
Thierry
class Rotate
def Rotate;;move
if checkselection(true)
obj = nil
obj = Sketchup.active_model.selection[0]
box = obj.bounds
p = Geom;;Point3d.new(box.center)
values = 0.0, 0.0, 0.0
results = inputbox ["X (Red)","Y (Green)", "Z (Blue)"], values, "Rotation"
return if not results
x, y, z = results
count = 0
if x != 0.0
count = count + 1
end
if y != 0.0
count = count + 1
end
if z != 0.0
count = count + 1
end
puts x
puts y
puts z
if count == 0
UI.messagebox "Nothing to process!"
return nil
end
if count > 1
UI.messagebox "Only one rotation at a time, please!"
return nil
end
if x != 0.0
rv = Geom;;Vector3d.new(1.0, 0.0, 0.0)
ra = x.degrees
end
if y != 0.0
rv = Geom;;Vector3d.new(0.0, 1.0, 0.0)
ra = y.degrees
end
if z != 0.0
rv = Geom;;Vector3d.new(0.0, 0.0, 1.0)
ra = z.degrees
end
trans = Geom;;Transformation.new(p, rv, ra)
obj.transform!(trans)
else
UI.messagebox "Only Groups and Components can be rotated!"
end
Sketchup.active_model().active_view().invalidate
end
def Rotate;;checkselection(lock_check)
sel_obj = Sketchup.active_model.selection[0]
if sel_obj
case sel_obj.typename
when "Group","ComponentInstance"
return nil if (Sketchup.active_model.selection[0].locked? & lock_check)
return true
end
end
return nil
end
end