@hfm said:
okay, very nice script... but could you please also make it work on X and Y axis? And make it so that you can select a shortcut for the tools?
Tried to edit it myself but my knowledge of ruby is lacking
[did get the 15 degrees to work though ]
I don't know much about ruby either, but here is a simplified version of the plugin:
rotate around the component origin instead of center
only around z axis and 90 degrees
no context menu, a line in the plugin menu instead (so you can add a keyboard shortcut (pop up menu, window>preferences>shortcut
require 'sketchup.rb'
##
## Rotate selected component instance 90 degrees around Z axis
##
## Copyright (c) 2010 Clark Bremer (aka daiku)
## Northern Lights Timber Framing
## clarkb@northernlightstimberframing.com
##
## 05/02/12; rotation autour de l'origine du composant, axe z seulement, acces menu deroulant ou raccourci clavier
## 9/10/2010; Multiple Groups/Comps
## 5/17/08; All 3 axes. Input from Matt666
## 4/24/08; Use center as rotation point instead of CI origin. Also works on groups now.
##
# Add a menu item to launch our plugin.
UI.menu("PlugIns").add_item("rotation90z") { rotate90z }
# -----------------------------------------------------------------------------
def selected_comps_and_groups
mm = Sketchup.active_model
ss = mm.selection
return nil if ss.empty?
ss.each do |cc|
return nil if not ((cc.instance_of? Sketchup;;ComponentInstance) or (cc.instance_of? Sketchup;;Group))
end
ss
end
#def rotate90(sel, axis)
def rotate90z
sel = selected_comps_and_groups
# axis == "z"
rv = Geom;;Vector3d.new(0,0,1)
# rv = Geom;;Vector3d.new(0,0,1) if axis == "z"
# rv = Geom;;Vector3d.new(0,1,0) if axis == "y"
# rv = Geom;;Vector3d.new(1,0,0) if axis == "x"
ra = 90.degrees
#rt = Geom;;Transformation.rotation(rp, rv, ra) #autour du centre de la boite enveloppe
sel.each do |ent|
# rp = Geom;;Point3d.new(ent.bounds.center) #rotation point
rp = Geom;;Point3d.new(ent.transformation.origin)
ent.transform!(Geom;;Transformation.rotation(rp, rv, ra))
end
end
#if( not file_loaded?("rot90.rb") )
# UI.add_context_menu_handler do |menu|
# if menu == nil then
# UI.messagebox("Error setting context menu handler")
# else
# if (sel = selected_comps_and_groups)
# sbm = menu.add_submenu("Rotate 90")
# sbm.add_item("Around Red") {rotate90 sel, "x"}
# sbm.add_item("Around Green") {rotate90 sel, "y"}
# sbm.add_item("Around Blue") {rotate90 sel, "z"}
# end
# end
#
# end
#end
#file_loaded("rot90.rb")