Hi!
Is there any extension allowing to rotate an entity in the view plane? I mean, the plane parallel to camera projection plane.
Not that I know.
Typically you want to rotate in a precise plane, e.g. the horizontal plane, or the plane of a roof that was drawn to an exact pitch. The camera on the other hand is typically controlled by eye measure and the precise orientation is in most cases unknown.
What is your use case?
Please expand on and clarify your question somewhat. When you say ârotateâ do you mean to rotate the model contents (as one would do with the Rotate tool), or to rotate your view of those contents (as one would do with the Orbit tool)? The visual effect is the same, but the implications are quite different! Rotate actually repositions entities in the model, whereas Orbit just changes the way you are looking at them.
to clarify, this is spinning each entity, around itâs centre point, parallel to the camera planeâŚ
itâs not an extensionâŚ
john
Slbaumgartner, I mean rotation, not orbiting. I want to rotate a group, letâs say, with rotation plane parallel to view plane.
Eneroth, I expected that it might be difficult to achieve but decided to ask anyways. Thank you for reply!
It isnât difficult in principle to program, just requires thorough understanding of SketchUpâs Transformation and Camera objects.
Do you want to be able to do this JUST depending on the arbitrary and usually non-repeatable view direction?
If so, it is in principle programmable in Ruby as Steve says.
Why not select it relative to some real geometry in the model? And for that, I donât quite understand why you wouldnât want to do that instead.
If you are looking at a face, R-click on it and choose âAlign viewâ then use the Rotate tool on the face, you will rotate round the camera viewing axis, normal to the face.
This is fairly simple to code in Ruby. You can open the Ruby Console and run this code:
model = Sketchup.active_model
camera = model.active_view.camera
point = camera.eye
vector = camera.target-camera.eye
angle = 30.degrees
transformation = Geom::Transformation.rotation(
point,
vector,
angle
)
model.active_entities.transform_entities(
transformation,
model.selection.to_a
)
Just replace â30â with the angle of your choice in degrees.
Still I wonder what John managed to express very clearly:
Eneroth, thank you for the code! This is what I needed I have no basic idea about coding.
John_drivenupthewall, did you use any similar code?
John_mccleanahan - you donât always have reference geometry you could use for aligning rotation - thatâs why I aked about camera view-based solution. It is very helpful for me.
@michal.p, instead of using the Ruby Console I would rather use a Ruby Code Editor like the one shown in the image attached:
This allows you to repeate the operation with same or different angles and/or undo the steps when not satisfied.
My code is similar, but uses the entity bounds centre to camera eye as the rotation axisâŚ
this is a better to understand gifâŚ
and it has a set number of steps to âdemoâ the actionâŚ
def spinit
model = Sketchup.active_model
ents = model.entities
sel = model.selection
view = model.active_view
cam = view.camera
grp = sel[0]
bb = grp.bounds
bbc = bb.center
eye = cam.eye
bbc_vec = bbc-eye
sel.add(ents[0]) if sel.empty?
rot = Geom::Transformation.rotation(bbc, bbc_vec, 4.degrees)
model.start_operation('spinit')
90.times do
model.active_entities.transform_entities(rot, grp)
view.refresh
end
ensure model.abort_operation
return true
end # spinit
to run enter spinit
after loading in Ruby ConsoleâŚ
john
Wo3Dan, you solved another big problem of mine. Only using Ruby Code Editor we can quickly undo massive action stack created when performing certain script on multiple entities. Thank you! I wasnât aware of that and used only Ruby Console which drove me mad when undoing complex operations
Two problems resolved in one thread, this is like winning a life
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.