Message 1 of 2
Driven keys script issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I am having an error with my python script, where I am trying to attach my blendshapes to a control handle with the setdrivenkeys command. I am trying to figure out the code that attaches them.
import maya.cmds as mc
#BLENDSHAPES
mc.select ('ORIGINAL')
mc.blendShape ('ORIGINAL', name= 'faceBlends')
grp = mc.select ('Human*')
mc.select ('ORIGINAL', d= True)
obj = mc.ls (selection = True, tr= True)
print (obj)
num = 0
for item in obj:
mc.blendShape ('faceBlends', e= True, t= ['ORIGINAL', num, item, 1.0])
num = num + 1
#CREATE UI WINDOW
def createWin():
if mc.window('Human', exists=True):
mc.deleteUI('Human')
mc.window('Human')
mc.columnLayout(adjustableColumn=True)
mc.button(l='Happy', c='Happy()')
mc.button(l='Sad', c='Sad()')
mc.button(l='Angry', c='Angry()')
mc.button(l='Shock', c='Shock()')
mc.showWindow('Human')
createWin()
menuName = "Extra"
mc.optionMenu( menuName, label='Extra')
mc.menuItem( label='EditFace', parent = menuName )
mc.button(l='OpenHandles', c='OpenHandles()')
#CTRLHANDLES
num = 0
sq= 'ctrlFrame' + str(num)
round= 'ctrlHandle' + str(num)
mc.curve (n= sq, d=1, p=[(0,1,0),(2,1,0),(2,0,0),(2,-1,0),(0,-1,0),(-2,-1,0),(-2,0,0),(-2,1,0), (0,1,0)])
mc.circle(n= round, nr= (0,0,1), r=1)
mc.transformLimits (tx= (-1,1), etx= (True,True),
ty= (0,0), ety= (True,True),
tz= (0,0), etz= (True,True))
mc.group (round, sq, n = 'Controls')
#TEST1
#side = 0
#up = 0
#num = 0
#while up < 2:
#while side < 2:
#mc.select ('Controls')
#mc.setAttr ('Controls.ty', up*2)
# mc.setAttr ('Controls.tx', side*2)
# side += 1
# num += 1
# side = 0
# up += 1
#HARDCODED
#mc.select ('Angry')
#mc.duplicate (n= 'Happy')
#mc.move (4.5, 0, 0)
#mc.duplicate (n= 'Sad')
#mc.move (4.5, 4.5, 0)
#mc.duplicate (n= 'Shock')
#mc.move (0, 4.5, 0)
mc.setDrivenKeyframe (at= 'ctrlHandle0' + '.tx', cd= 'Human1', dv = 0, v= 0)