Это может быть довольно сложный вопрос, поскольку многие из вас могут не знать, для какого программного обеспечения я пишу это: Autodesk Maya 2011. Я пытаюсь ускорить утомительный медленный процесс символы способности), написав скрипт, который делает это автоматически.
Я постараюсь объяснить ситуацию.
У меня есть сценарий, который берет объект, перебирает дочерние объекты этого объекта, сохраняет их в списке, затем помещает начальный объект в конец списка, переворачивает список, потому что это неправильно, и помещает начальный объект спереди.
Проблема: существует три разных списка одного и того же ТИПА объекта, но с разными именами, и на самом деле это разные объекты. Моя цель - соединить их вместе, генерируя узлы, называемые «blendcolors». Но если у меня есть цикл для генерации их для каждого объекта в списке A, то мне нужны циклы, которые также связывают их с объектами в других списках, и я не могу понять это.
Вот мой код, с которым он был воспроизведен, поэтому он более неполный, чем раньше, в том, что касается самого цикла.
import maya.cmds as cmds
def crBC(IKJoint, FKJoint, bindJoint, xQuan, switch):
# gets children joints of the selected joint
chHipIK = cmds.listRelatives(IKJoint, ad = True, type = 'joint')
chHipFK = cmds.listRelatives(FKJoint, ad = True, type = 'joint')
chHipBind = cmds.listRelatives(bindJoint, ad = True, type = 'joint')
# list is built backwards, this reverses the list
chHipIK.reverse()
chHipFK.reverse()
chHipBind.reverse()
# appends the initial joint to the list
chHipIK.append(IKJoint)
chHipFK.append(FKJoint)
chHipBind.append(bindJoint)
# puts the last joint at the start of the list because the initial joint
# was added to the end
chHipIK.insert(0, chHipIK.pop())
chHipFK.insert(0, chHipFK.pop())
chHipBind.insert(0, chHipBind.pop())
# pops off the remaining joints in the list the user does not wish to be blended
chHipBind[xQuan:] = []
chHipIK[xQuan:] = []
chHipFK[xQuan:] = []
# goes through the bind joints, makes a blend colors for each one, connects
# the switch to the blender
for a in chHipBind
rotBC = cmds.shadingNode('blendColors', asUtility = True, n = a + 'rotate_BC')
tranBC = cmds.shadingNode('blendColors', asUtility = True, n = a + 'tran_BC')
scaleBC = cmds.shadingNode('blendColors', asUtility = True, n = a + 'scale_BC')
cmds.connectAttr(switch + '.ikFkSwitch', rotBC + '.blender')
cmds.connectAttr(switch + '.ikFkSwitch', tranBC + '.blender')
cmds.connectAttr(switch + '.ikFkSwitch', scaleBC + '.blender')
# goes through the ik joints, connects to the blend colors
for b in chHipIK:
cmds.connectAttr(b + '.rotate', rotBC + '.color1')
cmds.connectAttr(b + '.translate', tranBC + '.color1')
cmds.connectAttr(b + '.scale', scaleBC + '.color1')
# connects FK joints to the blend colors
for c in chHipFK:
cmds.connectAttr(c + '.rotate', rotBC + '.color2')
cmds.connectAttr(c + '.translate', tranBC + '.color2')
cmds.connectAttr(c + '.scale', scaleBC + '.color2')
# connects blend colors to bind joints
cmds.connectAttr(rotBC + '.output', d + '.rotate')
cmds.connectAttr(tranBC + '.output', d + '.translate')
cmds.connectAttr(scaleBC + '.output', d + '.scale')
# executes function
crBC('L_hip_IK', 'L_hip_FK', 'L_hip_JNT', 6, 'L_legSwitch_CTRL')