FreeTextHost.in host your text & codes anonymously


FREE TEXT HOST

You can save codes, scripts, sources & general debugging text and share / access / use them at any time (anonymously).
You can even set yourself a password if you want to keep it just for yourself.

Posted by "Anonymous" on Tue, June 19th, 2012, 6:09 AM - Never Expires
Download | New paste

  1. import structures.faceRigNode.nodeReaderUI as nUI
  2. reload(nUI)
  3.  
  4.  
  5. from PyQt4 import QtCore, QtGui
  6.  
  7.  
  8. import sip
  9. import maya.mel as mel
  10. import maya.cmds as cmd
  11. import maya.OpenMayaUI as apiUI
  12. try:
  13.     _fromUtf8 = QtCore.QString.fromUtf8
  14. except AttributeError:
  15.     _fromUtf8 = lambda s: s
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24. def setSdkNew (faceRigNodeUi):
  25.      fNode= faceRigNodeUi.faceRigNodeList.currentText()
  26.      
  27.      
  28.      
  29.      
  30.      
  31.      '''NEW POSE'''
  32.    
  33.    
  34.      '''pose check '''
  35.      if faceRigNodeUi.newPoseC.isChecked()==1:
  36.          
  37.          poseName = faceRigNodeUi.posesNewName.text()
  38.          fNode= faceRigNodeUi.faceRigNodeList.currentText()
  39.          elements =cmd.getAttr("{fNode}.poseName".format(fNode=fNode) ,mi=True)
  40.          
  41.          if elements :
  42.              for element in elements :
  43.                  poseNameNode = cmd.getAttr("{fNode}.poseName[{element}]".format(fNode=fNode,element=element))
  44.                  
  45.                  if poseName!=poseNameNode:
  46.                      
  47.                      
  48.                    
  49.                      pass
  50.                      
  51.                  else:
  52.                      
  53.                      cmd.error ("Pose already existing in the node")
  54.                      
  55.          if elements:
  56.              newElement = elements[-1]
  57.              newElement+=1
  58.          else :
  59.              newElement=0
  60.          
  61.          
  62.          '''input store '''
  63.  
  64.  
  65.          if faceRigNodeUi.inputField.text()!="":
  66.              '''input name '''
  67.              input =faceRigNodeUi.inputField.text()
  68.              inputattr = faceRigNodeUi.inputAttrList.currentItem().text()
  69.              finalInput = input+"."+inputattr
  70.              
  71.              '''Input min max value '''
  72.              
  73.              inputV= cmd.getAttr("{finalInput}".format(finalInput=finalInput))
  74.              
  75.          else :
  76.               cmd.error ("No input object")
  77.              
  78.  
  79.          attr =cmd.getAttr("faceRigNode1.inputMinMax" ,mi=True)
  80. #         
  81. #         
  82.          '''target store'''
  83.          
  84.          '''store target name'''
  85.          
  86.          targets=[]
  87.          targetsAttrs=[]
  88.          targetValues=[]
  89.          
  90.          if faceRigNodeUi.targetObjectList.count():
  91.              isSelected=0
  92.              isAttributeSelected=0
  93.              for  i in range(faceRigNodeUi.targetObjectList.count()):
  94.                  selectedValue =  faceRigNodeUi.targetObjectList.isItemSelected(faceRigNodeUi.targetObjectList.item(i))
  95.                  if selectedValue == 1:
  96.                      isSelected=1
  97.              if isSelected==1:
  98.                  for  i in range(faceRigNodeUi.targetObjectAttrList.count()):
  99.                      selectedValue =  faceRigNodeUi.targetObjectAttrList.isItemSelected(faceRigNodeUi.targetObjectAttrList.item(i))
  100.                      if selectedValue == 1:
  101.                          isAttributeSelected=1
  102.                          
  103.                  if isAttributeSelected==1:
  104.                  
  105.                      
  106.                  
  107.          
  108.                      for i in range(faceRigNodeUi.targetObjectList.count()):
  109.                          selected =  faceRigNodeUi.targetObjectList.isItemSelected(faceRigNodeUi.targetObjectList.item(i))
  110.                          if selected ==1:
  111.                              target =faceRigNodeUi.targetObjectList.item(i).text()
  112.                              
  113.                              targets.append(str(target) )
  114.                              
  115.                      '''store target attribute'''
  116.                      for i in range(faceRigNodeUi.targetObjectAttrList.count()):
  117.                          selected =  faceRigNodeUi.targetObjectAttrList.isItemSelected(faceRigNodeUi.targetObjectAttrList.item(i))
  118.                          if selected ==1:
  119.                              targetsAttrs.append( str(faceRigNodeUi.targetObjectAttrList.item(i).text()))
  120.                              
  121.  
  122.                              
  123.                  else:
  124.                      cmd.error("No target attribute selected")
  125.              else:
  126.                  cmd.error("No target selected please select at least one ")
  127.          
  128.          else:
  129.              cmd.error("No target loaded, please load at least one")
  130.                      
  131.  
  132.              
  133.  
  134.      
  135.  
  136. #         try:
  137. #            '''set pose name'''
  138. #               
  139.        
  140.          cmd.setAttr ("{fNode}.poseName[{element}]".format(fNode=fNode,element=newElement),poseName,type="string")
  141.          faceRigNodeUi.setFaceRigNode()
  142.      
  143.          '''set  input name'''
  144.          cmd.setAttr ("{fNode}.inputName[{element}]".format(fNode=fNode,element=newElement),finalInput,type="string")
  145.        
  146.          '''set input min max'''
  147.          if faceRigNodeUi.setDefaultPoseC.isChecked()==1:
  148.             cmd.setAttr("{fNode}.inputMinMax[{element}].inputMinMaxArray[0]".format(fNode=fNode,element=newElement),inputV)
  149.        
  150.          elif faceRigNodeUi.setMaxPoseC.isChecked()==1:
  151.             cmd.setAttr("{fNode}.inputMinMax[{element}].inputMinMaxArray[1]".format(fNode=fNode,element=newElement),inputV)
  152.        
  153.          
  154.          cmd.setAttr("{fNode}.inputStored[{element}]".format(fNode=fNode,element=newElement),inputV)
  155.          cmd.setAttr("{fNode}.inputChanged[{element}]".format(fNode=fNode,element=newElement),0)
  156.  
  157.        
  158.          print "lol"
  159. #             
  160. #           
  161.          for i in range(len(targets)):
  162.                          cmd.setAttr("{fNode}.bonePoseName[{element}].boneName[{i}]".format(fNode=fNode,element=newElement,i=i),targets[i],type="string")#           
  163.      
  164.          '''store target attributes'''
  165.          for x in range(len(targets)):   
  166.              for i in range(len(targetsAttrs)):
  167.                  cmd.setAttr("{fNode}.channelsPoseName[{element}].channelsBoneName[{x}].channelName[{i}]".format(fNode=fNode,element=newElement,x=x,i=i),targetsAttrs[i],type="string")
  168.                  value = cmd.getAttr ("{targets}.{targetsAttrs}".format(targets=targets[x],targetsAttrs=targetsAttrs[i]))
  169.                  if faceRigNodeUi.setDefaultPoseC.isChecked()==1:
  170.                      cmd.setAttr("{fNode}.minMaxPose[{element}].minMaxBone[{x}].minMaxChannels[{i}].minMaxValue[0]".format(fNode=fNode,element=newElement,x=x,i=i),value)                     
  171.                  if faceRigNodeUi.setMaxPoseC.isChecked()==1:
  172.                      cmd.setAttr("{fNode}.minMaxPose[{element}].minMaxBone[{x}].minMaxChannels[{i}].minMaxValue[1]".format(fNode=fNode,element=newElement,x=x,i=i),value)                     
  173. #             
  174. ##           
  175.          '''store  output name'''
  176.                
  177.          bones=cmd.getAttr("faceRigNode1.outputBoneNames" ,mi=True)
  178.          bonesName = []
  179.          if bones :
  180.              for bone in bones :
  181.                  #print getAttr ("{fNode}.bonesNames[{bone}]".format(fNode=fNode,bone=bone))
  182.                  bonesName.append(cmd.getAttr ("faceRigNode1.outputBoneNames[{bone}]".format(bone=bone)))
  183.          print bonesName
  184. #                     
  185. #             
  186. #           
  187.  
  188.          if bonesName :
  189.              for x in range(len(targets)):
  190.                  if bonesName.count(targets[x])==0:
  191.                      bones2=cmd.getAttr("{fNode}.outputBoneNames".format(fNode=fNode) ,mi=True)
  192.                      size =len(bones2)
  193.                      cmd.setAttr ("{fNode}.outputBoneNames[{bone}]".format(fNode=fNode,bone=size),targets[x],type="string")
  194.                      for i in range(len(targetsAttrs)):
  195.                          cmd.setAttr("{fNode}.outputBoneChannel[{element}].outputChannelName[{i}]".format(fNode=fNode,element=size,i=i),targetsAttrs[i],type="string")
  196.                          print "new target set:" +targets[x]
  197.                          print "new target attr set:" +targetsAttrs[i]
  198.                  elif bonesName.count(targets[x])!=0:
  199.                      for
  200.          
  201.          
  202.          else:
  203.              print "storing new"
  204.              for x in range(len(targets)):
  205.                  bones2=cmd.getAttr("{fNode}.outputBoneNames".format(fNode=fNode) ,mi=True)
  206.                  if bones2:
  207.                      size =len(bones2)
  208.                  else :
  209.                      size=0
  210.                  cmd.setAttr ("{fNode}.outputBoneNames[{bone}]".format(fNode=fNode,bone=size),targets[x],type="string")
  211.                  for i in range(len(targetsAttrs)):
  212.                      cmd.setAttr("{fNode}.outputBoneChannel[{element}].outputChannelName[{i}]".format(fNode=fNode,element=size,i=i),targetsAttrs[i],type="string")
  213.              
  214.          bones=cmd.getAttr("faceRigNode1.outputBoneNames" ,mi=True)
  215.          bonesName = []
  216.          if bones :
  217.              for bone in bones :
  218.                  #print getAttr ("{fNode}.bonesNames[{bone}]".format(fNode=fNode,bone=bone))
  219.                  bonesName.append(cmd.getAttr ("faceRigNode1.outputBoneNames[{bone}]".format(bone=bone)))
  220.          print bonesName         
  221. #                       
  222.            
  223. #            for x in range(len(targets)):   
  224. #                for i in range(len(targetsAttrs)):
  225. #                    cmd.setAttr("{fNode}.targetObjectChannelComp[{element}].targetObjectChannel[{x}].targetChannel[{i}]".format(fNode=fNode,element=newElement,x=x,i=i),targetsAttrs[i],type="string")
  226. #                    value = cmd.getAttr ("{targets}.{targetsAttrs}".format(targets=targets[x],targetsAttrs=targetsAttrs[i]))
  227. #                    if faceRigNodeUi.setDefaultPoseC.isChecked()==1:
  228. #                        cmd.setAttr("{fNode}.bonesMinMaxPose[{element}].bonesMinMaxTarget[{x}].boneMinMaxChannels[{i}].bonesMinMax[0]".format(fNode=fNode,element=newElement,x=x,i=i),value)                     
  229. #                    if faceRigNodeUi.setMaxPoseC.isChecked()==1:
  230. #                        cmd.setAttr("{fNode}.bonesMinMaxPose[{element}].bonesMinMaxTarget[{x}].boneMinMaxChannels[{i}].bonesMinMax[1]".format(fNode=fNode,element=newElement,x=x,i=i),value)                     
  231. #           
  232. #           
  233. #           
  234. #           
  235.            
  236.                        
  237. #         except RuntimeError:
  238. #             cmd.error("DAFAQ? how the hell in the world could you break this node?? you dumbass!X")       
  239. #
Language:
To highlight particular lines, prefix each line with @@








freetexthost.in © 2010-2013 - Powered by PASTE 1.0   website by GandhiG.com