asch75 asch75 - 5 months ago 31
Python Question

Maya python trying to template / untemplate channel

I'm a newbie on Maya programming.

I'm trying to make a script to check and template/untemplate a channel.
I have a transform node opened in graph editor called 'SKEL01_002:main_C_001_CTRL'. Then I select 'TranslateX', and still in graph editor I go to CURVES --> TEMPLATE CHANNEL

I can list the Curves with:


cmds.listConnections('SKEL01_002:main_C_001_CTRL', t='animCurve')


But I can't figure out how to template/untemplate in python.

So thanks in advance for your help.

Answer

listening with echo all command, you see it prompt : doTemplateChannel graphEditor1FromOutliner 1;

doing whatIs doTemplateChannel; , you can see it prompt the mel procedure : // Result: Mel procedure found in: somePath/autodesk/maya2015-x64/scripts/others/loadAnimMenuLibrary.mel //

finding the proc, you can read another obscur proc called : expandSelectionConnectionAsArray

doing a whatIS, you find :

cmds.selectionConnection('graphEditor1FromOutliner' , q=1, object=1)
# Result: [u'pSphere1.translateX'] # 

returning to the doTemplateChannel.mel, the command to find the animCurve node is :

cmds.listConnections('pSphere1.translateX', type='animCurve') # Result: [u'pSphere1_translateX'] # 

And at the end, the command to template/untemplate :

cmds.setAttr( 'pSphere1_translateX.ktv', l = 1) # use 1 to lock and 0 to unlock

I hope it will help you ton find all next command that are not prompted ^^