[Plugin] Key Rotate
-
This is the first plugin I wrote. I just wanted a simple plugin to rotate groups 90 degrees in all 3 axis. Got tired of doing it by dragging stuff with the mouse. I use it alot. I was totally clueless, at the time, so credit goes to TBD and his Rotix plugin. The structure will look similar. I deleted alot of stuff and added a few things. Though after writing the PushPull&Group plugin, I imported some extra picker logic back as improvement.
To use, just hover over a group to auto select and hit the following keys to rotate 90 deg. Arrow keys for x,y and Home/End for Z. I normally just reach over with my left hand. It might be disorienting at first, but you should quickly get the hang of it. Z should be no problem. A tip for x,y is; line yourself up on the standard position, facing the xy plane. And imagine the arrows on the surface of the part. And imagine pushing on an arrow, will push that edge down.
You can see me using it at ~6 minute mark in the F15 video: http://forums.sketchucation.com/viewtopic.php?f=323&t=28072#p243453
@unknownuser said:
Copyright(C) 2010, kyyu
All Rights ReservedName: Key Rotate
Version: 1.02
SU Version: 7.0
Date: 05-04-2010Purpose: This plugin helps with the assembly of 3D models & puzzles for 1/4" sheet stock.
Description: Mouse over a group and use keyboard keys to rotate group 90 deg (about their center)
Usage:Right & Left arrow keys => rotate about the green (Y) axis direction
Up & Down arrow keys => rotate about the red (X) axis direction
Home & End arrow keys => rotate about the blue (Z) axis direction
# ** Hold Shift Key to add to selection
Credits: I learned alot buy studying TBD's Rotix plugin. Thanks you, for making it!
History:
1.0 (05-04-2010) - first version
1.01-2 added to description text-Kwok
-
Hi,
after checking your Key rotate out, it's ALMOST the perfect thing I need for a problem I'm working on.
I've been able to get it to rotate all the way down to 1 degree increments per axis - which is part 1 of what I need - but does Anyone know what would need to be modified to make each component rotate on it's COMPONENT axis?Fingers crossed,
cheers,
Woz.
-
The variable "v" specifies the vector, representing the rotation axis. For example, for the Z axis: "v = Geom::Vector3d.new(0,0,1)"
Oh, I guess you need the rotation point, also.
It's these two lines of code that does the rotation:
tr = Geom::Transformation.rotation(pt,v,angle.degrees)
Sketchup.active_model.active_entities.transform_entities(tr,e)Study the Sketchup Ruby API. For example, for the 1st line: http://code.google.com/apis/sketchup/docs/ourdoc/transformation.html#rotation
-Kwok
-
@kyyu said:
The variable "v" specifies the vector, representing the rotation axis. For example, for the Z axis: "v = Geom::Vector3d.new(0,0,1)"
DANG!
....I'm going to have to REALLYswat up now and see if I can get to a stage where I can fully understand your answer (only JUST getting into the bare rudiments of scripting over these last few weeks).So... you're meaning I have to find a way of relating to the relevant axis that has already been Assignedto each selected component?
...LOTS of leaning ahead 4 me m'thinks...
Thanks kyyu.
Woz
-
Well, I'm STILL wading through the link you pointed me to.
...but I think I'm still a VERY long way in my learning enough to see clearlywhat's going on in all of your script.
So... as is, does your script transform the active entities (group, component) around their arbitrary geometric central axis?
I'm trying to see which part of the script works that particular bit out.I would imagine my next step is to find out how to point your script to something that would describe the active entity's "COMPONENT AXIS" in each case.
In my ultimate desired use, all of the component axis's would also fall on the same real-world axis for each piece. If you could imagine each component looks a bit like a floating piece of a "cracked-apart spherical "shell" each rotating about a common "core" but each on slightly different layers so that they can "sheer" over each other.
As you might visualize, ultimately, it would be like pushing and rotating continents around on the surface of a little globe of the earth in any direction, each continent always properly oriented to the Core, and appearing to "float" with respect to the surface and each other.
With your script, I've managed now to at least get each component to rotate by 2 degree increments for each keystroke, but of course they just rotate where they are, intersecting each other.
Lots of working out ahead.
Thanks again Kwok,
Cheers,
Woz
@kyyu said:
The variable "v" specifies the vector, representing the rotation axis. For example, for the Z axis: "v = Geom::Vector3d.new(0,0,1)"
Oh, I guess you need the rotation point, also.
It's these two lines of code that does the rotation:
tr = Geom::Transformation.rotation(pt,v,angle.degrees)
Sketchup.active_model.active_entities.transform_entities(tr,e)Study the Sketchup Ruby API. For example, for the 1st line: http://code.google.com/apis/sketchup/docs/ourdoc/transformation.html#rotation
-Kwok
-
@unknownuser said:
So... as is, does your script transform the active entities (group, component) around their arbitrary geometric central axis?
I'm trying to see which part of the script works that particular bit out.Yes, it rotates about the center point of the group/component:
pt = e.bounds.centerThis is real basic, which means you need to learn the basics 1st. I will give you a link to some videos and to a book, later below.
Like I said it's just two lines. You define a tranformation, in this case rotation:
tr = Geom::Transformation.rotation(pt,v,angle.degrees)
You only need to supply a point of rotation, a vector(ie an axis), and the angle.
Then you apply the transformation to something, in this case the group/component reference by the variable "e":
Sketchup.active_model.active_entities.transform_entities(tr,e)@unknownuser said:
I would imagine my next step is to find out how to point your script to something that would describe the active entity's "COMPONENT AXIS" in each case.
In my ultimate desired use, all of the component axis's would also fall on the same real-world axis for each piece. If you could imagine each component looks a bit like a floating piece of a "cracked-apart spherical "shell" each rotating about a common "core" but each on slightly different layers so that they can "sheer" over each other.
As you might visualize, ultimately, it would be like pushing and rotating continents around on the surface of a little globe of the earth in any direction, each continent always properly oriented to the Core, and appearing to "float" with respect to the surface and each other.
With your script, I've managed now to at least get each component to rotate by 2 degree increments for each keystroke, but of course they just rotate where they are, intersecting each other.
Lots of working out ahead.
Thanks again Kwok,
Cheers,
Woz
You say you want to use the "COMPONENT AXIS", but I don't see why. You can simply rotate about the center of your sphere.
You can test out snippets of code, without writing a full plugin. Look at Chris Fullmers video tutoirals, 1st 6: http://www.youtube.com/user/ChrisFullmer#g/u
And then try out this snippet of code. Select something and execute the snippet of code and that something will rotate/orbit around the origin, 30 deg each time. I am assuming this is what you had in mind.model = Sketchup.active_model ent = model.entities sel = model.selection pt = [0,0,0] v = Geom;;Vector3d.new(0,0,1) tr = Geom;;Transformation.rotation(pt,v,30.degrees) Sketchup.active_model.active_entities.transform_entities(tr,sel[0])
And read this book. The full pdf version is free: http://www.autosketchup.com/
Sketchup Ruby API: http://code.google.com/apis/sketchup/docs/index.html
Oh, and you should start a new thread for more help with your new plugin, so as not to tie up this one. Go ahead and post a link here to the new thread.
-Kwok
-
(No experience with ruby) I'm trying to alter this to rotate around component base instead of center.
It seems I just need to change this line:pt = e.bounds.center
Can anyone help me find out what I need to write to make the component center its point of rotation?
Any help would be greatly appreciated.
Advertisement