Rotation in a view plane

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.

1 Like

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:

1 Like

Eneroth, thank you for the code! This is what I needed :smiley: 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 :stuck_out_tongue:
Two problems resolved in one thread, this is like winning a life :stuck_out_tongue:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.