forked from cstml/batch-renderer-rhino-vray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·72 lines (65 loc) · 1.92 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""
Rhino batch render of all layers:
Have atleast one view
"""
import rhinoscriptsyntax as rs
import scriptcontext as sc
import sys
import Rhino
def Export():
count = 0
folder = ChooseFolderPath()
layer_names = rs.LayerNames()
newDefaultLayer = 'NewDefault'
rs.AddLayer(newDefaultLayer)
rs.CurrentLayer(newDefaultLayer)
for l in layer_names:
if l != newDefaultLayer:
for t in layer_names:
if rs.IsLayer(l):
if l != newDefaultLayer:
rs.LayerVisible(t, False)
else:
print "The layer does not exist."
rs.LayerVisible(l, True)
if rs.CurrentLayer() == l:
break
"""answer = rs.MessageBox("Continue?", 1 | 32)
if answer is 2: break
rs.Sleep(1000)"""
Render(folder, count)
count += 1
rs.LayerVisible(l, False)
for l in layer_names:
if l != newDefaultLayer:
rs.LayerVisible(l, False)
rs.CurrentLayer(l)
rs.DeleteLayer(newDefaultLayer)
def ChooseFolderPath():
"""
pick a folder to save the renderings to
return the folder
"""
folder = rs.BrowseForFolder(rs.DocumentPath, "Browse for folder", "Batch Render")
return folder
def Render(folder, count):
"""
Defines the Rendering action
Saves the render to the browsed folder
Adds the name of the view and the name
of the layer state to the naming of the
view
"""
FileName = '"'+folder+'/img_'+str(count)+'"'
FileName = str(FileName)
rs.Command ("!_-Render")
rs.Command ("_-SaveRenderWindowAs "+FileName)
rs.Sleep(2000)
rs.Command ("_-CloseRenderWindow")
rs.Sleep(1000)
return 1
def ChangeView(View):
arrLayers = Rhino.LayerNames
rs.Command ("_-NamedView _Restore " + View + " _Enter", 0)
if __name__ == "__main__":
Export()