Итерация по ТРЕМЯ спискам одновременно в Python?

Это может быть довольно сложный вопрос, поскольку возможно, что многие из вас не знают программное обеспечение, которое я пишу для: 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')
6
задан Jared 27 June 2011 в 19:22
поделиться