Batch rendering different layers visibility in rhino7?

its 2022… any batch rendring for Rhino7?
like vray has, or badger (that works only on rhino5)
seems like a must have, an i need it :slight_smile:

Maybe _BatchRenderNamedViews will do?

'BatchRenderNamedViews` doesnt give the option for different layer states.
like if i want to render an object indifferent colors, i would to render one color, change color layer, render again… same in animation.
In veray plugin, the batch render lets you load batch of files, each with different layers on, and selec all the named views and animations to render, and 1 click to render batch them all.

seems simple,but dont see it it exists in rhino render.
this link show something close to what would be needed, as in if named views also kept layer visibility states within them, making 'BatchRenderNamedViews` actully work for multiple colors/states batch renders

Is there something similar for snapshots?

-paul

Hi Paul,

just tried this in python and it seems to work:

import scriptcontext as sc
import rhinoscriptsyntax as rs


names = sc.doc.Snapshots.Names
for name in names:
    cmd = "-_Snapshots _Restore %s EnterEnd" %name
    rs.Command(cmd)
    rs.Redraw()
    rs.Command("_Render")
1 Like

Hey thanks for the effort!
I’m sorry, I don’t have any experience with this! Can I use it as a command or what do I do with it?
-paul

@Paul_96
See attached .py
batch_render_snapshots.py (231 Bytes)

to run, put this in a button or assign it to an alias:

! -_RunPythonScript (
"full\path\to\pythonscript.py"
)

1 Like

Alright! Thank you very much.
I’ll try it after my vacation:)
Merry Christmas :christmas_tree:
-paul

Hey Gijs,
I apologize for the late reply. I just tried it out now.
This works really well! Thank you for that.
It’s also better to have a copy of your original file that contains the needed snapshots only.
Also, my PC crashes after some time.
It seems to me, that it has something to do with the time the script is running.
E.g.
I have 11 snapshots.
Render 10 samples, 10 seconds each. Fine.
Render 350 samples, 3m20s. Fine.
Render 500 samples, 5m. Pc crashes.

I don’t know what this is about. Since I never used anything like this before or have any clue about programming.

Thanks for the help, I really appreciate the effort on this! If I can help with anything. Let me know!
-Paul

If you say the pc crashes. Does this mean it completely crashes? Or is only Rhino crashing?
Does it crash at the first renderings?
Does it also crash if you render 5 minutes without the script running?

In any case can you type _systeminfo in Rhino and post back the results?

The whole PC froze two times.
It crashes at about nr. 5-7 of 12.
It does not crash when I render without the script.
The last rounds were without problems.

Rhino 7 SR22 2022-9-12 (Rhino 7, 7.22.22255.05001, Git hash:master @ 196b1bc7dd093321e28dcc7a2bb8709a9bebe12d)
License type: Commercial, build 2022-09-12
License details: LAN Zoo Network Node

Windows 11 (10.0.22000 SR0.0) or greater (Physical RAM: 32Gb)

Computer platform: DESKTOP

Standard graphics configuration.
Primary display and OpenGL: NVIDIA GeForce RTX 3060 (NVidia) Memory: 12GB, Driver date: 12-22-2022 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 528.02
> Accelerated graphics device with 4 adapter port(s)
- Windows Main Display attached to adapter port #0

OpenGL Settings
Safe mode: Off
Use accelerated hardware modes: On
Redraw scene when viewports are exposed: On
Graphics level being used: OpenGL 4.6 (primary GPU’s maximum)

Anti-alias mode: 4x
Mip Map Filtering: Linear
Anisotropic Filtering Mode: High

Vendor Name: NVIDIA Corporation
Render version: 4.6
Shading Language: 4.60 NVIDIA
Driver Date: 12-22-2022
Driver Version: 31.0.15.2802
Maximum Texture size: 32768 x 32768
Z-Buffer depth: 24 bits
Maximum Viewport size: 32768 x 32768
Total Video Memory: 12 GB

Rhino plugins that do not ship with Rhino
C:\Users\praktikant\AppData\Roaming\McNeel\Rhinoceros\packages\7.0\NVIDIADenoiser\0.4.3\NVIDIADenoiser.Windows.rhp “NVIDIADenoiser.Windows” 0.4.3.0

Rhino plugins that ship with Rhino
C:\Program Files\Rhino 7\Plug-ins\Commands.rhp “Commands” 7.22.22255.5001
C:\Program Files\Rhino 7\Plug-ins\rdk.rhp “Renderer Development Kit”
C:\Program Files\Rhino 7\Plug-ins\RhinoBonusTools.rhp “Rhino Bonus Tools”
C:\Program Files\Rhino 7\Plug-ins\AnimationTools.rhp “AnimationTools”
C:\Program Files\Rhino 7\Plug-ins\RhinoRenderCycles.rhp “Rhino Render” 7.22.22255.5001
C:\Program Files\Rhino 7\Plug-ins\rdk_etoui.rhp “RDK_EtoUI” 7.22.22255.5001
C:\Program Files\Rhino 7\Plug-ins\rdk_ui.rhp “Renderer Development Kit UI”
C:\Program Files\Rhino 7\Plug-ins\NamedSnapshots.rhp “Snapshots”
C:\Program Files\Rhino 7\Plug-ins\RhinoCycles.rhp “RhinoCycles” 7.22.22255.5001
C:\Program Files\Rhino 7\Plug-ins\Toolbars\Toolbars.rhp “Toolbars” 7.22.22255.5001
C:\Program Files\Rhino 7\Plug-ins\3dxrhino.rhp “3Dconnexion 3D Mouse”
C:\Program Files\Rhino 7\Plug-ins\Displacement.rhp “Displacement”

One thing that I can think of is this

Can you try to see if that solves your issue?

So clearing the undo stack at the end of each render. WARNING this clears ALL your undos:

import scriptcontext as sc
import rhinoscriptsyntax as rs


names = sc.doc.Snapshots.Names
for name in names:
    cmd = "-_Snapshots _Restore %s EnterEnd" %name
    rs.Command(cmd)
    rs.Redraw()
    rs.Command("_Render")
    rs.Command("ClearUndo")

@Gijs I’m looking to modify this simple script to export saved snapshots using _ViewCaptureToFile and have each view save to a folder based on the name of the snapshot. Any pointers on achieving this?

import scriptcontext as sc
import rhinoscriptsyntax as rs

names = sc.doc.Snapshots.Names
for name in names:
cmd = “-_Snapshots _Restore %s EnterEnd” %name
rs.Command(cmd)
rs.Redraw()
rs.Command(“_ViewCaptureToFile”)

Note that in your posted scripts there were double quotes that are not supported, only use the straight ones. Furthermore, if the snapshot has spaces in the name, it needs to be encapsulated with “” as well (I see I forgot that in the earlier posted script, and the redraw is not really necessary).

if you copy this to a button it should work:

-Runpythonscript (
import scriptcontext as sc
import rhinoscriptsyntax as rs

names = sc.doc.Snapshots.Names
for name in names:
    cmd = "-_Snapshots _Restore \"%s\" EnterEnd" %name
    rs.Command(cmd)
    rs.Command("_ViewCaptureToFile")
)
1 Like

Thanks @Gijs

When I run this script, I get the View Capture Settings dialogue box for each saved snapshot and it also brings up the save window and offers the default naming convention “ViewCapture01010101” in the file name field.

Is it possible to embed the view capture settings and location to save the files into the script so it will batch them all at once?

Yes that should be possible, for example:

import scriptcontext as sc
import rhinoscriptsyntax as rs

def savesnapshots():
    filepath = rs.BrowseForFolder(message="Select folder to save files")
    if not filepath:
        return
    
    names = sc.doc.Snapshots.Names
    for name in names:
        cmd = "-_Snapshots _Restore \"%s\" EnterEnd" %name
        rs.Command(cmd)
        file = filepath + "\\" + name
        rs.Command("_-ViewCaptureToFile _Width=2000 _Height=1000 \"%s\"" %file)
savesnapshots()
1 Like