यह एक जटिल सवाल हो सकता है क्योंकि यह संभव है कि आप में से बहुत से सॉफ्टवेयर को यह नहीं पता कि मैं इसे लिख रहा हूं: Autodesk माया 2011. मैं एक कठिन धीमी प्रक्रिया को तेज करने की कोशिश कर रहा हूं (rigging: 3 डी अक्षर दे स्थानांतरित करने की क्षमता) एक स्क्रिप्ट लिखकर जो स्वचालित रूप से करता है।पायथन में एक बार में तीन सूचियों के माध्यम से इटरेटिंग?
मैं स्थिति की व्याख्या करने के लिए अपनी पूरी कोशिश करूंगा।
मेरे पास एक ऐसी स्क्रिप्ट है जो ऑब्जेक्ट लेती है, उस ऑब्जेक्ट के बच्चों के माध्यम से पुनरावृत्ति करती है, उन्हें सूची में संग्रहीत करती है, फिर सूची के अंत में प्रारंभिक ऑब्जेक्ट रखती है, सूची को उलट देती है क्योंकि यह गलत तरीका है, फिर प्रारंभिक वस्तु को सामने रखता है।
समस्या: तीन अलग-अलग सूचियों की सभी अलग-अलग सूचियां हैं लेकिन विभिन्न नामों के साथ और वे वास्तव में अलग-अलग वस्तुएं हैं। मेरा लक्ष्य उन्हें 'मिश्रण रंग' नामक नोड्स उत्पन्न करके एक साथ जोड़ना है। लेकिन अगर मेरे पास सूची ए में प्रत्येक ऑब्जेक्ट के लिए उन्हें उत्पन्न करने के लिए एक लूप है, तो मुझे लूप की आवश्यकता है जो उन्हें अन्य सूचियों में ऑब्जेक्ट्स से कनेक्ट करे और मैं इसे समझ नहीं पा रहा हूं।
यहां मेरा कोड है, यह खेला गया है, जहां तक वास्तविक लूप जाता है, उससे पहले अधूरा अधिक अधूरा है।
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')
सभी तीन सूचियों में अनुक्रमित एक ही हैं? अर्थात। 0 सभी तीन सूचियों के लिए समान है? – GWW
वैरिएबल नाम लाइन शोर नहीं होने पर आपका कोड क्या करने का प्रयास कर रहा है, इसका पालन करना बहुत आसान होगा। – Daenyth
@ डेनथ: यदि आप समस्या स्थान को समझते हैं तो वे लाइन शोर नहीं हैं। –