Check "if view?"
-
does anyone know if there is a way to check whether one is aligned to a standard view (current view)?
tried various combinations, "if view=='ViewTop" etc. there seems to be nothing in the api.
Thanks
-
This will return true if the view is looking straight down (top view)
if Sketchup.active_model.active_view.camera.zaxis == [0,0,-1]
-
I like
Camera#direction
- it's more clear than zaxis.Vector3d#parallel?
andVector3d#samedirection?
might be better than==
since they consider tolerance. -
thanks J, that's promising!
EDIT: something's moving...! will report back
yes....just wonderful, all works great.
Jim, are you trying to scare me?
Thanks!
-
@cadfather said:
Jim, are you trying to scare me?
Thanks!Not very scary.
cam_dir = Sketchup.active_model.active_view.camera.direction if cam_dir.samedirection?(Y_AXIS) # Front elsif cam_dir.samedirection?(Y_AXIS.reverse) # Back elsif cam_dir.samedirection?(X_AXIS) # Left elsif cam_dir.samedirection?(X_AXIS.reverse) # Right elsif cam_dir.samedirection?(Z_AXIS) # Bottom elsif cam_dir.samedirection?(Z_AXIS.reverse) # Top else # Not aligned to Std View end
-
Jim, that neat way, makes perfect sense..!
here's the follow up to the previous if anyone has any idea:
working with this below, all good. but are there not controls for the 'look around' tool as well?
(nothing in the api)def onKeyDown(key, repeat, flags, view) case key when @upArrow then Sketchup.active_model.active_view.zoom 1.01 when @downArrow then Sketchup.active_model.active_view.zoom 0.99 end
what i'm trying to achieve is a plugin that will use the keyboard to incrementally spin and turn around the model or a selection. (will be out in 2019).
-
Indeed much nicer way to do it, jim
Advertisement