Rotation about the origin
-
Hi guys,
I am trying to write a script that very simply rotates selected objects by 90 degrees in the Z axis. I have put together some code but it isn't working. Can anyone help? I am new to Ruby so I have probably made some really basic mistakes.
Ross
require 'sketchup.rb' # Add a menu item UI.menu("PlugIns").add_item("rotate90") { rotate90 # Call method. } def rotate90 rv = Geom;;Vector3d.new(0,0,1) ra = 90.degrees rp = Geom;;Point3d.new(0,0,0) Sketchup.active_model.Transformation.rotation(rp, rv, ra)) end -
require 'sketchup.rb' # Add a menu item UI.menu("PlugIns").add_item("rotate90") { rotate90 } # Call method. def rotate90 mod = Sketchup.active_model ent = mod.entities sel = mod.selection rv = Geom;;Vector3d.new(0,0,1) ra = 90.degrees rp = Geom;;Point3d.new(0,0,0) # define the rotation transformation trr = Geom;;Transformation.rotation(rp, rv, ra) # apply the rotation transformation to the selection ent.transform_entities(trr,sel.to_a) endYou were close. Use http://code.google.com/apis/sketchup/docs/index.html to help with syntax.
-
Sam,
Thanks very much that works perfectly.
Ross
-
Are you planning to build on your programming skills and add functionality to this?
What I have always found really frustrating is when you use the group/component 'handles' to rotate components. It is a neat time-saver, but for years I have always wanted to rotate about a component's origin.
Alternatively if anyone else out there has a plugin that does this, I would be grateful if someone could please point me in its direction.
-
@bigstick said:
Are you planning to build on your programming skills and add functionality to this?
What I have always found really frustrating is when you use the group/component 'handles' to rotate components. It is a neat time-saver, but for years I have always wanted to rotate about a component's origin.
Alternatively if anyone else out there has a plugin that does this, I would be grateful if someone could please point me in its direction.
Check out Rotate&Scale on my blog. It works with groups and components and rotation is about the origin.
-
This already exists here:
http://rhin.crai.archi.fr/rld/plugin_details.php?id=345
and here:
http://forums.sketchucation.com/viewtopic.php?f=323&t=9739&hilit=rot90
Perfect for mapping to a shortcut key.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement