View Capture to File Automation

(Ric) #1

Hi there

My issue:
I’m using the _ViewCaptureToFile command very often for several Named Views. For example: I have 8 Named views and i want to save each named view to a jpg, the change material and/or geometry and do again 8 jpgs one per named view each. so far i only managed to do it one by one.

Question:
Is there a possibility to apply _ViewCaptureToFile to a list of Named Views (preferably with a tick-box for each view). Would it work as a macro (never used so far), or would be possible to program such a command (for someone who never programmed a rhino command but would be interested to give it a try)?

Thanks a lot for your support :smiley:

PS. I was using it a lot in Rhino Mac 6 WIP with the use of textures and ambient occlusion - i really like this feature! Thanks a lot!

(Gustavo Fontana) #2

Nathan wrote a script to do this from with Snapshots. I haven’t tested it yet but I think this should do it:

(Graham) #3

Hi,
does this do something like what you are looking for? Type _EditPythonScript then paste the following into the python editor and press play

import rhinoscriptsyntax as rs

all_views = rs.NamedViews()
selected_views= rs.MultiListBox(all_views)
filename_base = rs.GetString("base file name","Rics_file_")

for view_name in selected_views:
    rs.RestoreNamedView(view_name)
    rs.Command('-_ViewCaptureToFile '+chr(34)+filename_base+view_name+'.jpg'+chr(34)+' _EnterEnd')
#4

Is there a way to tell it where to save the files? Currently I’m not getting any output using RhinoWIP.

(Graham) #5

yes you can hard code it or prompt for a path
hard coded below
EDIT : or uncomment the BrowseForFolder line to prompt the location
There is more room for customisation, eg selecting the different screen capture options, …

import rhinoscriptsyntax as rs
import os


all_views = rs.NamedViews() # a list of names (strings)
selected_views= rs.MultiListBox(all_views, message = "select views to save", defaults = all_views)

filename_base = rs.GetString("base file name","Rics_file_")
savepath = r"C:\Users\KNAPP\Documents\KNAPP"
# savepath = rs.BrowseForFolder(rs.DocumentPath(), "destination directory")
filepath = os.path.join(savepath, filename_base)

for view_name in selected_views:
    rs.RestoreNamedView(view_name)
    rs.Command('-_ViewCaptureToFile '+chr(34)+filepath+view_name+'.jpg'+chr(34)+' _EnterEnd')
1 Like
#6

Thanks! For Mac volumes, I changed line 9 to the user desktop (just replace “User_Name” with your user name, and I changed the output to PNG format:

import rhinoscriptsyntax as rs
import os


all_views = rs.NamedViews() # a list of names (strings)
selected_views= rs.MultiListBox(all_views, message = "select views to save", defaults = all_views)

filename_base = rs.GetString("base file name","View_")
savepath = r"/Users/User_Name/Desktop"
# savepath = rs.BrowseForFolder(rs.DocumentPath(), "destination directory")
filepath = os.path.join(savepath, filename_base)

for view_name in selected_views:
    rs.RestoreNamedView(view_name)
    rs.Command('-_ViewCaptureToFile '+chr(34)+filepath+view_name+'.png'+chr(34)+' _EnterEnd')
1 Like