is there any way we can get information about animation in a rhino scene? All I could find are the “player” commands (next frame, previous frame, last frame). Is there any way we can get the current frame and the last frame inside a script (either python or rhinoscript)?
I could not find anything, but I could see that VRay is able to stop at the last frame when rendering an animation.
yes, I was talking about the builtin animation tools. Too bad there is no access to that, in this case I guess the closest I can get to go to a frame is a function like (haven’t tried it yet)
Sub GoToFrame(fr_number)
Rhino.Command("_ViewFirstFrame")
Dim index
For index = 1 To fr_number
Rhino.Command("_ViewNextFrame")
Next
End Sub
it is quite convoluted but not impossible to get the total number of frames or the current frame via scripting.
It needs to be done via analyzing the info that Rhino animation commands print to the command history.
Take a look at the attached RhinoScript sample functions that do it. Please note it will only work with English Rhino version - would need to be modified for other languages.
Also, few other things to note:
Rhino Animation frame count is 0-based, so 0 is the 1st frame and in 12 frame-animation, #11 is the last frame.
The “ViewFrameNumber” command for some reason will not let you set 1st (0) and last frame to view, these need to be accessed via ViewFirstFrame/ ViewLastFrame commands, hence some more code in the script to trap these cases.
thank you so much, now I can extract the settings I need. I used your function as a blueprint for my python script
import rhinoscriptsyntax as rs
def getTotalFrames():
"""Return the duration in frames of the animation for the current View"""
# tries to set an outrageously high frame number,
# parses the "Number must be Smaller than..." reply
rs.Command('_-ViewFrameNumber 9999999999999999 _-Enter', 1)
out_msg = "Number must be"
cmd_out = rs.CommandHistory().rfind(out_msg)
return rs.CommandHistory()[cmd_out + len(out_msg):].split()[2]