- import structures.faceRigNode.nodeReaderUI as nUI
- reload(nUI)
- from PyQt4 import QtCore, QtGui
- import sip
- import maya.mel as mel
- import maya.cmds as cmd
- import maya.OpenMayaUI as apiUI
- try:
- _fromUtf8 = QtCore.QString.fromUtf8
- except AttributeError:
- _fromUtf8 = lambda s: s
- def setSdkNew (faceRigNodeUi):
- fNode= faceRigNodeUi.faceRigNodeList.currentText()
- '''NEW POSE'''
- '''pose check '''
- if faceRigNodeUi.newPoseC.isChecked()==1:
- poseName = faceRigNodeUi.posesNewName.text()
- fNode= faceRigNodeUi.faceRigNodeList.currentText()
- elements =cmd.getAttr("{fNode}.poseName".format(fNode=fNode) ,mi=True)
- if elements :
- for element in elements :
- poseNameNode = cmd.getAttr("{fNode}.poseName[{element}]".format(fNode=fNode,element=element))
- if poseName!=poseNameNode:
- pass
- else:
- cmd.error ("Pose already existing in the node")
- if elements:
- newElement = elements[-1]
- newElement+=1
- else :
- newElement=0
- '''input store '''
- if faceRigNodeUi.inputField.text()!="":
- '''input name '''
- input =faceRigNodeUi.inputField.text()
- inputattr = faceRigNodeUi.inputAttrList.currentItem().text()
- finalInput = input+"."+inputattr
- '''Input min max value '''
- inputV= cmd.getAttr("{finalInput}".format(finalInput=finalInput))
- else :
- cmd.error ("No input object")
- attr =cmd.getAttr("faceRigNode1.inputMinMax" ,mi=True)
- #
- #
- '''target store'''
- '''store target name'''
- targets=[]
- targetsAttrs=[]
- targetValues=[]
- if faceRigNodeUi.targetObjectList.count():
- isSelected=0
- isAttributeSelected=0
- for i in range(faceRigNodeUi.targetObjectList.count()):
- selectedValue = faceRigNodeUi.targetObjectList.isItemSelected(faceRigNodeUi.targetObjectList.item(i))
- if selectedValue == 1:
- isSelected=1
- if isSelected==1:
- for i in range(faceRigNodeUi.targetObjectAttrList.count()):
- selectedValue = faceRigNodeUi.targetObjectAttrList.isItemSelected(faceRigNodeUi.targetObjectAttrList.item(i))
- if selectedValue == 1:
- isAttributeSelected=1
- if isAttributeSelected==1:
- for i in range(faceRigNodeUi.targetObjectList.count()):
- selected = faceRigNodeUi.targetObjectList.isItemSelected(faceRigNodeUi.targetObjectList.item(i))
- if selected ==1:
- target =faceRigNodeUi.targetObjectList.item(i).text()
- targets.append(str(target) )
- '''store target attribute'''
- for i in range(faceRigNodeUi.targetObjectAttrList.count()):
- selected = faceRigNodeUi.targetObjectAttrList.isItemSelected(faceRigNodeUi.targetObjectAttrList.item(i))
- if selected ==1:
- targetsAttrs.append( str(faceRigNodeUi.targetObjectAttrList.item(i).text()))
- else:
- cmd.error("No target attribute selected")
- else:
- cmd.error("No target selected please select at least one ")
- else:
- cmd.error("No target loaded, please load at least one")
- # try:
- # '''set pose name'''
- #
- cmd.setAttr ("{fNode}.poseName[{element}]".format(fNode=fNode,element=newElement),poseName,type="string")
- faceRigNodeUi.setFaceRigNode()
- '''set input name'''
- cmd.setAttr ("{fNode}.inputName[{element}]".format(fNode=fNode,element=newElement),finalInput,type="string")
- '''set input min max'''
- if faceRigNodeUi.setDefaultPoseC.isChecked()==1:
- cmd.setAttr("{fNode}.inputMinMax[{element}].inputMinMaxArray[0]".format(fNode=fNode,element=newElement),inputV)
- elif faceRigNodeUi.setMaxPoseC.isChecked()==1:
- cmd.setAttr("{fNode}.inputMinMax[{element}].inputMinMaxArray[1]".format(fNode=fNode,element=newElement),inputV)
- cmd.setAttr("{fNode}.inputStored[{element}]".format(fNode=fNode,element=newElement),inputV)
- cmd.setAttr("{fNode}.inputChanged[{element}]".format(fNode=fNode,element=newElement),0)
- print "lol"
- #
- #
- for i in range(len(targets)):
- cmd.setAttr("{fNode}.bonePoseName[{element}].boneName[{i}]".format(fNode=fNode,element=newElement,i=i),targets[i],type="string")#
- '''store target attributes'''
- for x in range(len(targets)):
- for i in range(len(targetsAttrs)):
- cmd.setAttr("{fNode}.channelsPoseName[{element}].channelsBoneName[{x}].channelName[{i}]".format(fNode=fNode,element=newElement,x=x,i=i),targetsAttrs[i],type="string")
- value = cmd.getAttr ("{targets}.{targetsAttrs}".format(targets=targets[x],targetsAttrs=targetsAttrs[i]))
- if faceRigNodeUi.setDefaultPoseC.isChecked()==1:
- cmd.setAttr("{fNode}.minMaxPose[{element}].minMaxBone[{x}].minMaxChannels[{i}].minMaxValue[0]".format(fNode=fNode,element=newElement,x=x,i=i),value)
- if faceRigNodeUi.setMaxPoseC.isChecked()==1:
- cmd.setAttr("{fNode}.minMaxPose[{element}].minMaxBone[{x}].minMaxChannels[{i}].minMaxValue[1]".format(fNode=fNode,element=newElement,x=x,i=i),value)
- #
- ##
- '''store output name'''
- bones=cmd.getAttr("faceRigNode1.outputBoneNames" ,mi=True)
- bonesName = []
- if bones :
- for bone in bones :
- #print getAttr ("{fNode}.bonesNames[{bone}]".format(fNode=fNode,bone=bone))
- bonesName.append(cmd.getAttr ("faceRigNode1.outputBoneNames[{bone}]".format(bone=bone)))
- print bonesName
- #
- #
- #
- if bonesName :
- for x in range(len(targets)):
- if bonesName.count(targets[x])==0:
- bones2=cmd.getAttr("{fNode}.outputBoneNames".format(fNode=fNode) ,mi=True)
- size =len(bones2)
- cmd.setAttr ("{fNode}.outputBoneNames[{bone}]".format(fNode=fNode,bone=size),targets[x],type="string")
- for i in range(len(targetsAttrs)):
- cmd.setAttr("{fNode}.outputBoneChannel[{element}].outputChannelName[{i}]".format(fNode=fNode,element=size,i=i),targetsAttrs[i],type="string")
- print "new target set:" +targets[x]
- print "new target attr set:" +targetsAttrs[i]
- elif bonesName.count(targets[x])!=0:
- for
- else:
- print "storing new"
- for x in range(len(targets)):
- bones2=cmd.getAttr("{fNode}.outputBoneNames".format(fNode=fNode) ,mi=True)
- if bones2:
- size =len(bones2)
- else :
- size=0
- cmd.setAttr ("{fNode}.outputBoneNames[{bone}]".format(fNode=fNode,bone=size),targets[x],type="string")
- for i in range(len(targetsAttrs)):
- cmd.setAttr("{fNode}.outputBoneChannel[{element}].outputChannelName[{i}]".format(fNode=fNode,element=size,i=i),targetsAttrs[i],type="string")
- bones=cmd.getAttr("faceRigNode1.outputBoneNames" ,mi=True)
- bonesName = []
- if bones :
- for bone in bones :
- #print getAttr ("{fNode}.bonesNames[{bone}]".format(fNode=fNode,bone=bone))
- bonesName.append(cmd.getAttr ("faceRigNode1.outputBoneNames[{bone}]".format(bone=bone)))
- print bonesName
- #
- # for x in range(len(targets)):
- # for i in range(len(targetsAttrs)):
- # cmd.setAttr("{fNode}.targetObjectChannelComp[{element}].targetObjectChannel[{x}].targetChannel[{i}]".format(fNode=fNode,element=newElement,x=x,i=i),targetsAttrs[i],type="string")
- # value = cmd.getAttr ("{targets}.{targetsAttrs}".format(targets=targets[x],targetsAttrs=targetsAttrs[i]))
- # if faceRigNodeUi.setDefaultPoseC.isChecked()==1:
- # cmd.setAttr("{fNode}.bonesMinMaxPose[{element}].bonesMinMaxTarget[{x}].boneMinMaxChannels[{i}].bonesMinMax[0]".format(fNode=fNode,element=newElement,x=x,i=i),value)
- # if faceRigNodeUi.setMaxPoseC.isChecked()==1:
- # cmd.setAttr("{fNode}.bonesMinMaxPose[{element}].bonesMinMaxTarget[{x}].boneMinMaxChannels[{i}].bonesMinMax[1]".format(fNode=fNode,element=newElement,x=x,i=i),value)
- #
- #
- #
- #
- # except RuntimeError:
- # cmd.error("DAFAQ? how the hell in the world could you break this node?? you dumbass!X")
- #
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.