-
Notifications
You must be signed in to change notification settings - Fork 0
/
veRegSeqSetup.py
143 lines (115 loc) · 5.35 KB
/
veRegSeqSetup.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
__author__ = 'andrew.willis'
#Shot Setup - VE Version
#Andrew Willis 2014
import maya.cmds as cmds
import asiist
epsInts=[]
dataHeader=None
class shotSetupCls:
def __init__(self):
if cmds.window('veShotSetup',exists=True):cmds.deleteUI('veShotSetup',wnd=True)
cmds.window('veShotSetup',t='Shot Setup', s=False)
cmas=cmds.columnLayout(adj=True)
f1=cmds.frameLayout(l='ECF File',p=cmas)
cmds.rowColumnLayout(nc=2)
cmds.textField('ecfBrowse',w=200)
cmds.button(l='...',w=20,c=self.openFile)
f3=cmds.frameLayout(l='Episode Name',p=cmas)
cmds.text('episodeName',l='',h=30,fn='boldLabelFont')
f2=cmds.frameLayout(l='Episode Content',p=cmas)
cmds.columnLayout(adj=True)
cmds.textScrollList('shotContent',w=220)
cmds.showWindow()
f4=cmds.frameLayout(l='Command',p=cmas)
cmds.rowColumnLayout(nc=3)
cmds.button(l='SETUP SHOT',c=lambda*args:self.setupShot(new=True),bgc=[1.0,0.643835616566,0.0])
cmds.button(l='UPDATE SHOT',c=lambda*args:self.setupShot(new=False))
cmds.button(l='CLEAR SHOT',c=self.deleteShot)
return
def deleteShot(self,*args):
repVar=cmds.confirmDialog(icn='question',t='New',\
m='This will clear current sequence. Proceed?',\
button=['Ok','Cancel'])
if repVar=='Ok':cmds.file(new=True,f=True)
return
def openFile(self,*args):
global epsInts,dataHeader
file=cmds.fileDialog()
reader=open(file,'r')
data=reader.readlines()
reader.close()
dataHeader=file[file.rfind('/')+1:]
epsInts = []
for chk in data:
chk=chk.replace('\r\n','')
epsInts.append([chk[:chk.find(':')],chk[chk.find(':')+1:]])
cmds.textScrollList('shotContent',e=True,ra=True)
for chk in epsInts:cmds.textScrollList('shotContent',e=True,a=chk[0])
cmds.textField('ecfBrowse',e=True,tx=str(file))
cmds.text('episodeName',e=True,l=file[file.rfind('/')+1:file.rfind('.')])
return
def setupShot(self,new=False):
global epsInts,dataHeader
if epsInts==[] or dataHeader==None:
cmds.confirmDialog(icn='error',t='Error',m='No episode opened!',button=['OK'])
cmds.error('error : no episode opened')
selShot=cmds.textScrollList('shotContent',q=True,si=True)
if selShot==None:
cmds.confirmDialog(icn='error',t='Error',m='No shot selected!',button=['OK'])
cmds.error('error : no shot selected')
record=None
for chk in epsInts:
if chk[0]==selShot[0]:record=chk
if new==True:
if cmds.objExists('shotMaster'):
cmds.confirmDialog(icn='error',t='Error',m='Shot master exists!',button=['OK'])
cmds.error('error : shot master exists')
cmds.group(em=True,n='shotMaster')
self.sceneInfo()
cmds.confirmDialog(icn='information',t='Done',m='Shot setup done.',button=['Ok'])
else:
if cmds.objExists('sceneInfo'):cmds.delete('sceneInfo')
self.sceneInfo()
cmds.confirmDialog(icn='information',t='Done',m='Shot update done.',button=['Ok'])
return
def sceneInfo(self):
selShot=cmds.textScrollList('shotContent',q=True,si=True)
record=None
for chk in epsInts:
if chk[0]==selShot[0]:record=chk
#implement sequence information
enviFetch=asiist.getEnvi()
for chk in enviFetch:
if chk[0] == 'resWidth': resWidth = chk[1]
if chk[0] == 'resHeight': resHeight = chk[1]
if chk[0] == 'resAspectRatio': resAspectRatio = chk[1]
cmds.setAttr('defaultResolution.width', float(resWidth))
cmds.setAttr('defaultResolution.height', float(resHeight))
cmds.setAttr('defaultResolution.deviceAspectRatio', float(resAspectRatio))
#create empty group
cmds.group(em=True,n='sceneInfo',p='shotMaster')
cmds.group(em=True,n='char',p='shotMaster')
cmds.group(em=True,n='prop',p='shotMaster')
cmds.group(em=True,n='sets',p='shotMaster')
#additional data to sceneInfo
cmds.select('sceneInfo')
for chk in asiist.getEnvi():
cmds.addAttr(ln=str(chk[0]),k=True,at='enum',en=str(chk[1]))
cmds.setAttr('sceneInfo.'+str(chk[0]),l=True)
if chk[0]=='unit':cmds.currentUnit(time=chk[1])
cmds.addAttr(ln='__________',k=True,at='enum',en='__________')
cmds.setAttr('sceneInfo.__________',l=True)
cmds.addAttr(ln='episodeName',k=True,at='enum',en=str(cmds.text('episodeName',q=True,l=True)))
cmds.setAttr('sceneInfo.episodeName',l=True)
cmds.addAttr(ln='shotName',k=True,at='enum',en=str(record[0]))
cmds.setAttr('sceneInfo.shotName',l=True)
cmds.addAttr(ln='frameCount',k=True,at='enum',en=str(record[1]))
cmds.setAttr('sceneInfo.frameCount',l=True)
#lock standard channel
for object in ['shotMaster','sceneInfo','char','prop','sets']:
for channel in ['tx','ty','tz','rx','ry','rz','sx','sy','sz','visibility']:
cmds.setAttr(object+'.'+channel,l=True,cb=False,k=False)
#impose shot range
cmds.rangeControl(min=101,max=101+(int(record[1])-1))
return
shotSetupCls()