Short explanation how the program works
We are creating a Web Dialogue instance called "wd". The title of the dialog is called "Rotator". Next we define the dialog so that it has a scroll bar. The register information is stored in the "Info" file Then, we define the size of the window, ie width and height, and that the size of the window can not be changed. Next we are using add_action_callback method so Ruby is waiting a contact from JavaScript. When button is pressed the "message" value is passed from WebDialog to Ruby. Then we convert the string value to integer and set the value to variable named "angle". Next, we define the geometric transfers according to the different axes and the program rotates the objects according to the given angles. Finally we show the WebDialog.
--------------------------------------------------------------------------------
require 'sketchup.rb' wd=UI::WebDialog.new( "Rotator", true, "Info",300, 650, 100, 100, false ) wd.add_action_callback("first_ac") do |js_wd, message|
angle = message.to_i tr = Geom::Transformation.rotation([0,0,0],[1,0,0],angle.degrees) Sketchup.active_model.active_entities.transform_entities(tr,Sketchup.active_model.selection) wd.add_action_callback("second_ac") do |js_wd, message| angle = message.to_i tr = Geom::Transformation.rotation([0,0,0],[0,1,0],angle.degrees) Sketchup.active_model.active_entities.transform_entities(tr,Sketchup.active_model.selection) wd.add_action_callback("third_ac") do |js_wd, message| angle = message.to_i tr = Geom::Transformation.rotation([0,0,0],[0,0,1],angle.degrees) Sketchup.active_model.active_entities.transform_entities(tr,Sketchup.active_model.selection)
end end end wd.set_file( "C:/Program Files/SketchUp/SketchUp 2017/Tools/Rotation.html" ) wd.show()