ViewCaptureToFile bug

Using Rhino 4, rendered display mode, and scripting to capture 300-400 frames to file a simple animation where objects are switched to a different layer a few times as the camera orbits around subject, with “-viewcapturetofile”.

The bug is that, while the on screen display is correct, at some random but somewhat consistent points, the saved images don’t correspond to the display at all, the objects either have wrong materials / layers, or the environment texture seems to be missing. It’s not a scripting bug.

Tried putting rhino.sleep before the capture at no avail. Is there a trick solution? I’m under a deadline.

Hi Tom,

How can we repeat what you are seeing? Do you have a script and a sample file that we can use to repeat the problem?

– Dale

Thanks Dale. Unfortunately, I cannot publish or post any of the scene or script (NDA), and I could not duplicate the problem with a quick simple setup. I don’t have time to strip it down to just before the bug either.

All I can say is that I first tried splitting the script into multiple parts, so the script execution halts in between the parts, control returns to the UI and I run the second part of the script WITHOUT touching the state of the file in memory when script stopped. That didn’t work.

What worked is running the script twice, first saving frames until the bug surfaces, then, reloading the startup file, but for the first 125 frames, skip capturing the frames. The frames captured this way on the second run were fine. In other words, the following code worked, when I load the file set RunNo=1, run, then reload the file, set RunNo=2 and run. I don’t think 125 is a magic number but the point where something gets corrupt in the buffer for that particular file. Again, display is always correct.

Dim RunNo
RunNo = 1

Dim FrameNo
FrameNo = -1

Function SaveView
Call Rhino.Command(“ClearUndo")
FrameNo = FrameNo + 1
If (RunNo = 1) And (FrameNo>124) Then Err.Raise 9999,“Me”,“End of first run"
If (RunNo = 2) And (FrameNo<125) Then Exit Function
Call Rhino.Command(”
-ViewCaptureToFile " & Quote( “C:\TEST\FRAME” & CStr(FrameNo) & “.PNG” ) & " Enter Enter” , False )
End Function

Hi Tom,

Just curious, what kind of video card do you have? Can you take a screen capture of your OpenGL page? (Tools -> Options ->View -> OpenGL) I’m not sure this has anything to do with what you are seeing.

I’ve have written scripts that “viewcapture” far more than 125 frames. I’ll try to dig up a sample for you to try.

– Dale

Hi Tom,

Try the following sample:

You will need to download and install RhionPolyhedra too.

My bootcamped MacBook Pro with Windows 7 and Rhino 5 SR8 can “view capture” all 400+ shapes.

– Dale

Dale, I’m working on Rhino4, so I did not try Rhino Polyhedra. However, I can repeat the problem with a simple script below. Before running the script, open a new file, detach the perspective viewport to float it, and on the material of the “default” layer, add an environment map (I used “chrome.jpg” from auxpecker package).

On my system, environment map disappears at frame 255 in saved images, while it remains present on viewport. Video card is ATI FirePro V4800, OpenGL version 4.2.12338

Once the environment map goes missing from saved images, cancelling the script and running it again, environment map is missing from the very first frame. One has to start with a new file to get it back.

The number 255 is a bit curious, but I don’t have time to experiment too much, still trying to finish the animation while dealing with this problem.

Option Explicit

Dim FrameNo
FrameNo = 0

Sub SaveView
  Rhino.Command "_ClearUndo"
  Rhino.Command "_-ViewCaptureToFile " & Quote( "C:\TEMP\FRAME" & CStr(FrameNo) & ".PNG" ) & " Enter Enter" , False
  FrameNo = FrameNo + 1
End Sub

Sub TestViewCap
  Dim i
  Rhino.Command "-ViewportProperties Size 600 600 Enter"
  Rhino.ViewDisplayMode ,2
  Rhino.Command "MeshSphere V 1000 R 1000 0,0,0 10"
  For i=0 To 999
    Rhino.RotateView , 1, 1
End Sub


Hi Tom,

I am able to repeat the 255 image limit, using your sample script, with Rhino 4.0 SR9 on my Intel HD Graphics 4600 system.

The script works just fine using Rhino 5, either 32-bit or 64-bit.

You might consider trying the Rhino 5 evaluation version, which runs for 90 days. Also, there is a version of AuxPecker for Rhino 5…

– Dale

Hi All - I am consistently having very similar issues with -ViewCaptureToFile.

If I change views it will capture the previous view, not the new view.

If I select an object in the scene it will capture the new view - however, it will show the object highlighted even if it is no longer selected during the screen capture.

If I turn geometry on in a scene - it will omit that newly visible geometry.

One work around is to draw something behind the camera, select it and then perform the -ViewCaptureToFile command - this will export properly - but is annoying to perform every time.

Does anyone have a clue what is happening?