Rotate View Instantly


#1

Hi, I am trying to make cameraview rotate around a target instantly,
but i dont know where i went wrongly,

import rhinoscriptsyntax as rs 

for i in range(360):

    rs.Redraw()
    viewPort = rs.CurrentView()
    tar = rs.ViewTarget(viewPort)
    cameraPlane = rs.ViewCameraPlane(viewPort)
    rotated = rs.RotatePlane(cameraPlane, 1 * i, [0,0,1])
    newView = rs.ViewCPlane(viewPort, cameraPlane)

(Steve Baer) #2

I think you want a script that works something like the following

import rhinoscriptsyntax as rs
import Rhino

for i in range(360):
    viewPort = rs.CurrentView()
    rs.RotateView(viewPort, 0, 1)
    Rhino.RhinoApp.Wait()

#3

perfect, thank you Steve

there are two things i would know about,

first, what is that things let me control (wait) the timing or redraw and set it according to seconds milliseconds like how it works in grasshopper timer, or in processing frameRate command

secondly,

how can i make the rotation function work instantly, without affecting/be affected by the running/stop of the scripts, and make the view turn around INSTANTLY, until i ask it to stop rotating or i end the script


#4

This is a bit off topic, but you might find what you need in the “turntable” command.

And I am not sure what you mean with INSTANTLY, do you mean CONTINUOUSLY?

Do you want the viewport to spin all the time, even when you are working on the Rhino file?

If you just want it to spin until you hit [escape] then you have to add

import scriptcontext

to the start, and then:

#check for esc press
if scriptcontext.escape_test(False):
    break      #get out of the loop

into the script, and put the script in a “Wile true”: loop.

The script will then look like this:

import scriptcontext
import rhinoscriptsyntax as rs
import Rhino

viewPort = rs.CurrentView()

while True:
    rs.RotateView(viewPort, 0, 3.6)
    Rhino.RhinoApp.Wait()
    if scriptcontext.escape_test(False):
        Break

#5

Holo,

I think there is something goes wrong when i applied the script,
the script is running, and still running, until now
i even opened new file, i deleted the script from grasshopper and python,
but the view port still rotating

and the escape test never work


#6

Hm… That’s strange. I don’t use Grasshopper now, so the script was intended for “pure” Python script use.
(To be used in the Python script editor)

Maybe @stevebaer can help you out.

Could you quit Rhino to stop the script?


#7

mmmm, yes, that is the only thing you can do, because it take all the processing
even when you delete the python script, and close the grasshopper file, and even start a new file, the Rhino file keep spinning, and even when i open a new rhino file, without closing, its still rotating

i need the rotation to work without interrupting the process of running the script


#8

I am working on Jake Hebbert Scripts


(Steve Baer) #9

If you are in Grasshopper, just use a Grasshopper timer to control the interval. That would force your script to be executed on an interval


#10

How?

and what about the module called Time in python ( import Time)
how does it work


#11

I tried this


(Steve Baer) #12

Here’s a grasshopper definition that hopefully displays how to do this
rotate_with_timer.gh (2.3 KB)


#13

Hi,
Thank you Steve
i think i am using the old version

can you write the code
or share it with the older version


(Steve Baer) #14

Just curious; is there a reason you can’t update?


(Steve Baer) #15

Also, the code inside the component is simply

import rhinoscriptsyntax as rs

viewPort = rs.CurrentView()
rs.RotateView(viewPort, 0, 3.6)

The grasshopper timer is wired up to this component and causes it to execute at every interval.


#16

I Think it is a student version,


#17

But how do i apply a time interval ( by seconds or milliseconds) inside the a scripting in python


#18

Hmm, you don’t know for sure? It should say in the title bar “Educational”. If you have a real student version, you should be able to update it to the latest service release.

–Mitch


#19

i think its not real student version :frowning:
so this why it seem not updating


#20