def create_rootCON () : selectedCON = cmds.ls(sl=1) selectedCON_NUL = cmds.listRelatives (selectedCON, p=1) selectedCON_copy = cmds.duplicate (selectedCON) cmds.parent (selectedCON_copy, w=1) tempGRP = cmds.group(em=1, n=selectedCON[0].replace('CON', 'tempGRP')) cmds.parent (selectedCON_copy, tempGRP) tempGRP_bbInfo = cmds.xform(tempGRP, worldSpace=1, query=1, boundingBox=1) tempGRP_bbInfo_X = (tempGRP_bbInfo[0] + tempGRP_bbInfo[3]) / 2.0 tempGRP_bbInfo_Y = (tempGRP_bbInfo[1] + tempGRP_bbInfo[4]) / 2.0 tempGRP_bbInfo_Z = (tempGRP_bbInfo[2] + tempGRP_bbInfo[5]) / 2.0 tempGRP_bbsX = cmds.getAttr("%s.boundingBoxSizeX" %tempGRP)/ 1.8 tempGRP_bbsY = cmds.getAttr("%s.boundingBoxSizeY" %tempGRP)/ 1.8 tempGRP_bbsZ = cmds.getAttr("%s.boundingBoxSizeZ" %tempGRP)/ 1.8 rootCON = cmds.curve (degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) rootCON_rename_01 = cmds.rename ('root_%s'%tempGRP) rootCON_rename_02 = cmds.rename (rootCON_rename_01.replace('tempGRP', 'CON')) rootNUL = cmds.group(em=1, n=rootCON_rename_02.replace('CON', 'NUL')) cmds.parent (rootCON_rename_02, rootNUL) cmds.scale (tempGRP_bbsX, tempGRP_bbsY, tempGRP_bbsZ, rootNUL) cmds.move (tempGRP_bbInfo_X, tempGRP_bbInfo_Y, tempGRP_bbInfo_Z, rootNUL) cmds.makeIdentity (rootNUL, apply=1, s=1) CL.con_overrideColor_SET () cmds.parent (rootNUL, 'control_GRP') cmds.delete (tempGRP) for m in selectedCON_NUL : cmds.parentConstraint (rootCON_rename_02, m, mo=1) con_ChannelBox () cmds.select (deselect = True)
def create_rootCON_CT () : selectedCON_CT = cmds.ls(sl=1) selectedCON_NUL_CT = cmds.listRelatives (selectedCON_CT, p=1) selectedCON_copy_CT = cmds.duplicate (selectedCON_CT) cmds.parent (selectedCON_copy_CT, w=1) tempGRP_CT = cmds.group(em=1, n=selectedCON_CT[0].replace('CON', 'tempGRP')) cmds.parent (selectedCON_copy_CT, tempGRP_CT) tempGRP_bbInfo_CT = cmds.xform(tempGRP_CT, worldSpace=1, query=1, boundingBox=1) tempGRP_bbInfo_X_CT = (tempGRP_bbInfo_CT[0] + tempGRP_bbInfo_CT[3]) / 2.0 tempGRP_bbInfo_Y_CT = (tempGRP_bbInfo_CT[1] + tempGRP_bbInfo_CT[4]) / 2.0 tempGRP_bbInfo_Z_CT = (tempGRP_bbInfo_CT[2] + tempGRP_bbInfo_CT[5]) / 2.0 tempGRP_bbsX_CT = cmds.getAttr("%s.boundingBoxSizeX" %tempGRP_CT)/ 1.8 tempGRP_bbsY_CT = cmds.getAttr("%s.boundingBoxSizeY" %tempGRP_CT)/ 1.8 tempGRP_bbsZ_CT = cmds.getAttr("%s.boundingBoxSizeZ" %tempGRP_CT)/ 1.8 rootCON_CT = cmds.curve (degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) rootCON_rename_01_CT = cmds.rename ('root_%s'%tempGRP_CT) rootCON_rename_02_CT = cmds.rename (rootCON_rename_01_CT.replace('tempGRP', 'CON')) rootNUL_CT = cmds.group(em=1, n=rootCON_rename_02_CT.replace('CON', 'NUL')) cmds.parent (rootCON_rename_02_CT, rootNUL_CT) cmds.scale (tempGRP_bbsX_CT, tempGRP_bbsY_CT, tempGRP_bbsZ_CT, rootNUL_CT) cmds.move (tempGRP_bbInfo_X_CT, tempGRP_bbInfo_Y_CT, tempGRP_bbInfo_Z_CT, rootNUL_CT) cmds.move (0, 0, 0, "%s.scalePivot" % rootNUL_CT, "%s.rotatePivot" % rootNUL_CT) cmds.move (0, 0, 0, "%s.scalePivot" % rootCON_rename_02_CT, "%s.rotatePivot" % rootCON_rename_02_CT) cmds.makeIdentity (rootNUL_CT, apply=1, s=1) CL.con_overrideColor_SET () cmds.parent (rootNUL_CT, 'control_GRP') cmds.delete (tempGRP_CT) for n in selectedCON_NUL_CT : cmds.parentConstraint (rootCON_rename_02_CT, n, mo=1) con_ChannelBox () cmds.select (deselect = True)
def create_CON_separate_CT_noConnect () : sepaCON_selPLY_CT = cmds.ls(selection=True) for e in sepaCON_selPLY_CT : # Bounding Box : centerPivot sepaCON_bbInfo_CT = cmds.xform(e, worldSpace=True, query=True, boundingBox=True) sepaCON_bbCT_X_CT = (sepaCON_bbInfo_CT[0] + sepaCON_bbInfo_CT[3]) / 2.0 sepaCON_bbCT_Y_CT = (sepaCON_bbInfo_CT[1] + sepaCON_bbInfo_CT[4]) / 2.0 sepaCON_bbCT_Z_CT = (sepaCON_bbInfo_CT[2] + sepaCON_bbInfo_CT[5]) / 2.0 # Bounding Box : Size sepaCON_bbsX_CT = cmds.getAttr ("%s.boundingBoxSizeX" %e) /1.5 sepaCON_bbsY_CT = cmds.getAttr ("%s.boundingBoxSizeY" %e) /1.5 sepaCON_bbsZ_CT = cmds.getAttr ("%s.boundingBoxSizeZ" %e) /1.5 # CON sepaCON_CT = cmds.curve (degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) sepaCON_rename_CT = cmds.rename (e.replace ('PLY', 'CON')) CL.con_overrideColor_SET () sepaCON_NUL_CT = cmds.group (em=True, n=e.replace ('PLY', 'NUL')) cmds.parent (sepaCON_rename_CT, sepaCON_NUL_CT) cmds.scale (sepaCON_bbsX_CT, sepaCON_bbsY_CT, sepaCON_bbsZ_CT, sepaCON_NUL_CT) cmds.move (sepaCON_bbCT_X_CT, sepaCON_bbCT_Y_CT, sepaCON_bbCT_Z_CT, sepaCON_NUL_CT) cmds.move (0, 0, 0, "%s.scalePivot" %sepaCON_NUL_CT, "%s.rotatePivot" %sepaCON_NUL_CT) cmds.move (0, 0, 0, "%s.scalePivot" %sepaCON_rename_CT, "%s.rotatePivot" %sepaCON_rename_CT) cmds.makeIdentity (sepaCON_NUL_CT, apply=1, s=1) cmds.parent (sepaCON_NUL_CT, 'control_GRP') con_ChannelBox () cmds.select (deselect = True)
def create_CON_combine_CT () : combCON_selPLY_CT = cmds.ls(selection=True) combCON_selPLY_copy_CT = cmds.duplicate (combCON_selPLY_CT) combCON_tempPLY_CT = cmds.polyUnite(combCON_selPLY_copy_CT, mergeUVSets=1, constructionHistory=True, n=combCON_selPLY_CT[0].replace('PLY', 'RE')) cmds.delete (combCON_tempPLY_CT, ch=1) # like a historyDelete and delete emptyGroup, Also Node Check # CON combCON_CT = cmds.curve (degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) combCON_rename_CT = cmds.rename (combCON_selPLY_CT[0].replace('PLY', 'CON')) combCON_Shape_CT = cmds.listRelatives (combCON_rename_CT, shapes=1) CL.con_overrideColor_SET () combCON_NUL_CT = cmds.group (em=True, n=combCON_selPLY_CT[0].replace('PLY', 'NUL')) cmds.parent (combCON_rename_CT, combCON_NUL_CT) cmds.select (combCON_tempPLY_CT[0]) boundingBox_Info () cmds.scale (propRig_bbsX[-1], propRig_bbsY[-1], propRig_bbsZ[-1], combCON_NUL_CT) cmds.move (propRig_bbX_CT[-1], propRig_bbY_CT[-1], propRig_bbZ_CT[-1], combCON_NUL_CT) cmds.move (0, 0, 0, "%s.scalePivot" %combCON_NUL_CT, "%s.rotatePivot" %combCON_NUL_CT) cmds.move (0, 0, 0, "%s.scalePivot" %combCON_rename_CT, "%s.rotatePivot" %combCON_rename_CT) cmds.makeIdentity (combCON_NUL_CT, apply=1, s=1) con_ChannelBox () cmds.delete (combCON_tempPLY_CT[0]) cmds.parent (combCON_NUL_CT, 'control_GRP') for d in combCON_selPLY_CT : cmds.parentConstraint (combCON_rename_CT, d, mo=1) cmds.scaleConstraint (combCON_rename_CT, d, mo=1) cmds.select (deselect=1)
def create_CON_combine_noConnect(): combCON_selPLY = cmds.ls(selection=True) combCON_selPLY_copy = cmds.duplicate(combCON_selPLY) combCON_tempPLY = cmds.polyUnite(combCON_selPLY_copy, mergeUVSets=1, constructionHistory=True, n=combCON_selPLY[0].replace('PLY', 'RE')) cmds.delete( combCON_tempPLY, ch=1) # like a historyDelete and delete emptyGroup, Also Node Check cmds.select(combCON_tempPLY[0]) boundingBox_Info() cmds.select(deselect=1) # CON combCON = cmds.curve(degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) combCON_reName = cmds.rename(combCON_selPLY[0].replace('PLY', 'CON')) combCON_Shape = cmds.listRelatives(combCON_reName, shapes=1) CL.con_overrideColor_SET() combCON_NUL = cmds.group(em=True, n=combCON_selPLY[0].replace('PLY', 'NUL')) cmds.parent(combCON_reName, combCON_NUL) cmds.scale(propRig_bbsX[-1], propRig_bbsY[-1], propRig_bbsZ[-1], combCON_NUL) cmds.move(propRig_bbX_CT[-1], propRig_bbY_CT[-1], propRig_bbZ_CT[-1], combCON_NUL) cmds.makeIdentity(combCON_NUL, apply=1, s=1) con_ChannelBox() cmds.delete(combCON_tempPLY[0]) cmds.parent(combCON_NUL, 'control_GRP') cmds.select(deselect=1)
def create_CON_separate_noConnect(): sepaCON_selPLY = cmds.ls(selection=True) for i in sepaCON_selPLY: # Bounding Box : centerPivot sepaCON_bbInfo = cmds.xform(i, worldSpace=True, query=True, boundingBox=True) sepaCON_bbCT_X = (sepaCON_bbInfo[0] + sepaCON_bbInfo[3]) / 2.0 sepaCON_bbCT_Y = (sepaCON_bbInfo[1] + sepaCON_bbInfo[4]) / 2.0 sepaCON_bbCT_Z = (sepaCON_bbInfo[2] + sepaCON_bbInfo[5]) / 2.0 # Bounding Box : Size sepaCON_bbsX = cmds.getAttr("%s.boundingBoxSizeX" % i) / 1.5 sepaCON_bbsY = cmds.getAttr("%s.boundingBoxSizeY" % i) / 1.5 sepaCON_bbsZ = cmds.getAttr("%s.boundingBoxSizeZ" % i) / 1.5 # CON sepaCON = cmds.curve(degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) sepaCON_rename = cmds.rename(i.replace('PLY', 'CON')) CL.con_overrideColor_SET() sepaCON_NUL = cmds.group(em=True, n=i.replace('PLY', 'NUL')) cmds.parent(sepaCON_rename, sepaCON_NUL) cmds.scale(sepaCON_bbsX, sepaCON_bbsY, sepaCON_bbsZ, sepaCON_NUL) cmds.move(sepaCON_bbCT_X, sepaCON_bbCT_Y, sepaCON_bbCT_Z, sepaCON_NUL) cmds.makeIdentity(sepaCON_NUL, apply=1, s=1) cmds.parent(sepaCON_NUL, 'control_GRP') con_ChannelBox() cmds.select(deselect=True)
def create_JNT_separate_CT(): sepaJNT_selPLY_CT = cmds.ls(sl=1) for b in sepaJNT_selPLY_CT: # Bounding Box : centerPivot sepaJNT_selPLY_bbInfo_CT = cmds.xform(b, worldSpace=1, query=1, boundingBox=1) sepaJNT_bbCT_X_CT = (sepaJNT_selPLY_bbInfo_CT[0] + sepaJNT_selPLY_bbInfo_CT[3]) / 2.0 sepaJNT_bbCT_Y_CT = (sepaJNT_selPLY_bbInfo_CT[1] + sepaJNT_selPLY_bbInfo_CT[4]) / 2.0 sepaJNT_bbCT_Z_CT = (sepaJNT_selPLY_bbInfo_CT[2] + sepaJNT_selPLY_bbInfo_CT[5]) / 2.0 cmds.select(deselect=1) # create joint sepaJNT_CT = cmds.joint(p=(sepaJNT_bbCT_X_CT, sepaJNT_bbCT_X_CT, sepaJNT_bbCT_X_CT), n=b.replace('PLY', 'JNT')) cmds.joint(sepaJNT_CT, edit=True, radius=0.5) sepaJNT_rename_CT = cmds.rename('C_Skin_%s' % sepaJNT_CT) # skinBind cmds.select(b, replace=1) cmds.select(sepaJNT_rename_CT, add=1) cmds.SmoothBindSkin(toSelectedBones=1) # Bounding Box : Size sepaJNT_bbsX_CT = cmds.getAttr("%s.boundingBoxSizeX" % b) / 1.5 sepaJNT_bbsY_CT = cmds.getAttr("%s.boundingBoxSizeY" % b) / 1.5 sepaJNT_bbsZ_CT = cmds.getAttr("%s.boundingBoxSizeZ" % b) / 1.5 cmds.select(deselect=1) # CON sepaJNT_CON_CT = cmds.curve(degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) sepaJNT_CON_rename_CT = cmds.rename(b.replace('PLY', 'CON')) CL.con_overrideColor_SET() sepaJNT_NUL_CT = cmds.group(em=1, n=b.replace('PLY', 'NUL')) cmds.parent(sepaJNT_CON_rename_CT, sepaJNT_NUL_CT) cmds.scale(sepaJNT_bbsX_CT, sepaJNT_bbsY_CT, sepaJNT_bbsZ_CT, sepaJNT_NUL_CT) cmds.move(sepaJNT_bbCT_X_CT, sepaJNT_bbCT_Y_CT, sepaJNT_bbCT_Z_CT, sepaJNT_NUL_CT) cmds.move(0, 0, 0, "%s.scalePivot" % sepaJNT_NUL_CT, "%s.rotatePivot" % sepaJNT_NUL_CT) cmds.move(0, 0, 0, "%s.scalePivot" % sepaJNT_CON_rename_CT, "%s.rotatePivot" % sepaJNT_CON_rename_CT) cmds.makeIdentity(sepaJNT_NUL_CT, apply=1) cmds.parentConstraint(sepaJNT_CON_rename_CT, sepaJNT_rename_CT, mo=1) cmds.parent(sepaJNT_rename_CT, 'joint_GRP') cmds.setAttr('joint_GRP.visibility', 0) cmds.parent(sepaJNT_NUL_CT, 'control_GRP') con_ChannelBox() cmds.select(deselect=1)
def create_JNT_combine_CT(): combJNT_selPLY_CT = cmds.ls(sl=True) combJNT_selPLY_copy_CT = cmds.duplicate(combJNT_selPLY_CT) combJNT_tempPLY_CT = cmds.polyUnite(combJNT_selPLY_copy_CT, mergeUVSets=1, constructionHistory=True, n=combJNT_selPLY_CT[0].replace( 'PLY', 'RE')) cmds.delete( combJNT_tempPLY_CT, ch=1) # like a historyDelete and delete emptyGroup, Also Node Check cmds.select(combJNT_tempPLY_CT[0]) boundingBox_Info() cmds.select(deselect=True) # create joint combJNT_CT = cmds.joint(p=(propRig_bbX_CT[-1], propRig_bbY_CT[-1], propRig_bbZ_CT[-1]), n=combJNT_selPLY_CT[0].replace('PLY', 'JNT')) cmds.joint(combJNT_CT, edit=True, radius=0.5) combJNT_rename_CT = cmds.rename('C_Skin_%s' % combJNT_CT) # skinBind cmds.select(combJNT_selPLY_CT, replace=True) cmds.select(combJNT_rename_CT, add=True) cmds.SmoothBindSkin(toSelectedBones=True) # CON cmds.select(deselect=1) combJNT_CON_CT = cmds.curve(degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) combJNT_CON_rename_CT = cmds.rename(combJNT_selPLY_CT[0].replace( 'PLY', 'CON')) combJNT_CONShape_CT = cmds.listRelatives(combJNT_CON_rename_CT, shapes=True) CL.con_overrideColor_SET() combJNT_NUL_CT = cmds.group(em=True, n=combJNT_selPLY_CT[0].replace('PLY', 'NUL')) cmds.parent(combJNT_CON_rename_CT, combJNT_NUL_CT) cmds.scale(propRig_bbsX[-1], propRig_bbsY[-1], propRig_bbsZ[-1], combJNT_NUL_CT) cmds.move(propRig_bbX_CT[-1], propRig_bbY_CT[-1], propRig_bbZ_CT[-1], combJNT_NUL_CT) cmds.move(0, 0, 0, "%s.scalePivot" % combJNT_NUL_CT, "%s.rotatePivot" % combJNT_NUL_CT) cmds.move(0, 0, 0, "%s.scalePivot" % combJNT_CON_rename_CT, "%s.rotatePivot" % combJNT_CON_rename_CT) cmds.makeIdentity(combJNT_NUL_CT, apply=1) con_ChannelBox() cmds.delete(combJNT_tempPLY_CT[0]) cmds.parentConstraint(combJNT_CON_rename_CT, combJNT_rename_CT, mo=1) cmds.parent(combJNT_rename_CT, 'joint_GRP') cmds.setAttr('joint_GRP.visibility', 0) cmds.parent(combJNT_NUL_CT, 'control_GRP') cmds.select(deselect=True)
def create_JNT_separate(): # sepaJNT_selPLY = cmds.ls(sl=True) for a in sepaJNT_selPLY: # Bounding Box : centerPivot sepaJNT_selPLY_bbInfo = cmds.xform(a, worldSpace=True, query=True, boundingBox=True) sepaJNT_bbCT_X = (sepaJNT_selPLY_bbInfo[0] + sepaJNT_selPLY_bbInfo[3]) / 2.0 sepaJNT_bbCT_Y = (sepaJNT_selPLY_bbInfo[1] + sepaJNT_selPLY_bbInfo[4]) / 2.0 sepaJNT_bbCT_Z = (sepaJNT_selPLY_bbInfo[2] + sepaJNT_selPLY_bbInfo[5]) / 2.0 # create joint cmds.select(deselect=True) sepaJNT_selPLY_nameList = a.split('_') sepaJNT = cmds.joint(p=(sepaJNT_bbCT_X, sepaJNT_bbCT_Y, sepaJNT_bbCT_Z), n=a.replace('PLY', 'JNT')) sepaJNT_rename = cmds.rename('C_Skin_%s' % sepaJNT) cmds.joint(sepaJNT_rename, edit=True, radius=0.5) # skinBind cmds.select(a, replace=True) cmds.select(sepaJNT_rename, add=True) cmds.SmoothBindSkin(toSelectedBones=True) # Bounding Box : Size sepaJNT_bbsX = cmds.getAttr("%s.boundingBoxSizeX" % a) / 1.5 sepaJNT_bbsY = cmds.getAttr("%s.boundingBoxSizeY" % a) / 1.5 sepaJNT_bbsZ = cmds.getAttr("%s.boundingBoxSizeZ" % a) / 1.5 # CON cmds.select(deselect=True) sepaJNT_CON = cmds.curve(degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) sepaJNT_CON_rename = cmds.rename(a.replace('PLY', 'CON')) CL.con_overrideColor_SET() sepaJNT_NUL = cmds.group(em=True, n=a.replace('PLY', 'NUL')) cmds.parent(sepaJNT_CON_rename, sepaJNT_NUL) cmds.scale(sepaJNT_bbsX, sepaJNT_bbsY, sepaJNT_bbsZ, sepaJNT_NUL) cmds.move(sepaJNT_bbCT_X, sepaJNT_bbCT_Y, sepaJNT_bbCT_Z, sepaJNT_NUL) cmds.makeIdentity(sepaJNT_NUL, apply=1, s=1) cmds.parentConstraint(sepaJNT_CON_rename, sepaJNT_rename, mo=1) cmds.parent(sepaJNT_rename, 'joint_GRP') cmds.setAttr('joint_GRP.visibility', 0) cmds.parent(sepaJNT_NUL, 'control_GRP') con_ChannelBox() cmds.select(deselect=1)
def create_CON_combine(): selObjs_J = cmds.ls(selection=True) # J : Join # if 'GRP' in selObjs_J[0]: # JGC : Join Group Controller # cmds.select(selObjs_J, r=1) selobjs_PGRP = cmds.listRelatives(p=1) # PGRP : Parent GRP selobjs_J_tempGRP = cmds.group( n=selObjs_J[0].replace('GRP', 'tempGRP')) boundingBox_Info() selobjs_JGC = cmds.curve(degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) CL.con_overrideColor_SET() selobjs_JGC_rename = cmds.rename(selObjs_J[0].replace('GRP', 'CON')) selobjs_JGC_NUL = cmds.group(em=1, n=selobjs_JGC_rename.replace( 'CON', 'NUL')) cmds.parent(selobjs_JGC_NUL, selobjs_JGC_rename) cmds.move(0, 0, 0, selobjs_JGC_NUL, ls=1) cmds.parent(selobjs_JGC_NUL, w=1) cmds.parent(selobjs_JGC_rename, selobjs_JGC_NUL) cmds.scale(propRig_bbsX[-1], propRig_bbsY[-1], propRig_bbsZ[-1], selobjs_JGC_NUL) cmds.move(propRig_bbX_CT[-1], propRig_bbY_CT[-1], propRig_bbZ_CT[-1], selobjs_JGC_NUL) cmds.makeIdentity(selobjs_JGC_NUL, a=1, s=1) cmds.parent(selobjs_JGC_NUL, 'control_GRP') cmds.parent(selObjs_J, selobjs_PGRP) cmds.delete(selobjs_J_tempGRP) for JGCC in selObjs_J: cmds.parentConstraint(selobjs_JGC_rename, JGCC, mo=1) cmds.scaleConstraint(selobjs_JGC_rename, JGCC, mo=1) else: selObjs_JC = cmds.duplicate(selObjs_J) # JC : Join_Copy # selObjs_JC_temp = cmds.polyUnite(selObjs_JC, mergeUVSets=1, constructionHistory=True, n=selObjs_J[0].replace('PLY', 'RE')) cmds.delete( selObjs_JC_temp, ch=1 ) # like a historyDelete and delete emptyGroup, Also Node Check cmds.select(selObjs_JC_temp[0]) boundingBox_Info() cmds.select(deselect=1) selObjs_JPC = cmds.curve(degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) # JPC : Join_PLY_CON # CL.con_overrideColor_SET() selObjs_JPC_rename = cmds.rename(selObjs_J[0].replace('PLY', 'CON')) selObjs_JPC_NUL = cmds.group(em=1, n=selObjs_JPC_rename.replace( 'CON', 'NUL')) cmds.parent(selObjs_JPC_rename, selObjs_JPC_NUL) cmds.scale(propRig_bbsX[-1], propRig_bbsY[-1], propRig_bbsZ[-1], selObjs_JPC_NUL) cmds.move(propRig_bbX_CT[-1], propRig_bbY_CT[-1], propRig_bbZ_CT[-1], selObjs_JPC_NUL) cmds.makeIdentity(selObjs_JPC_NUL, apply=1, s=1) cmds.delete(selObjs_JC_temp[0]) cmds.parent(selObjs_JPC_NUL, 'control_GRP') for JPCC in selObjs_J: # JPCC : Join PLY Controller Constraints # cmds.parentConstraint(selObjs_JPC_rename, JPCC, mo=1) cmds.scaleConstraint(selObjs_JPC_rename, JPCC, mo=1) con_ChannelBox() cmds.select(deselect=1)
def create_CON_combine_CT(): selObjs_J_CT = cmds.ls(sl=1) if 'GRP' in selObjs_J_CT[0]: selobjs_PGRP_CT = cmds.listRelatives(selObjs_J_CT, p=1) # PGRP : Parent GRP selobjs_J_CT_tempGRP = cmds.group( n=selObjs_J_CT[0].replace('GRP', 'tempGRP')) boundingBox_Info() # JGC : Join Group CON selobjs_JGC_CT = cmds.curve(degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) CL.con_overrideColor_SET() selobjs_JGC_CT_rename = cmds.rename(selObjs_J_CT[0].replace( 'GRP', 'CON')) selobjs_JGC_CT_NUL = cmds.group(em=1, n=selobjs_JGC_CT_rename.replace( 'CON', 'NUL')) cmds.parent(selobjs_JGC_CT_NUL, selobjs_JGC_CT_rename) cmds.move(0, 0, 0, selobjs_JGC_CT_NUL, ls=1) cmds.rotate(0, 0, 0, selobjs_JGC_CT_NUL) cmds.scale(1, 1, 1, selobjs_JGC_CT_NUL, ls=1) cmds.parent(selobjs_JGC_CT_NUL, w=1) cmds.parent(selobjs_JGC_CT_rename, selobjs_JGC_CT_NUL) cmds.scale(propRig_bbsX[-1], propRig_bbsY[-1], propRig_bbsZ[-1], selobjs_JGC_CT_NUL) cmds.move(propRig_bbX_CT[-1], propRig_bbY_CT[-1], propRig_bbZ_CT[-1], selobjs_JGC_CT_NUL) cmds.move(0, 0, 0, "%s.scalePivot" % selobjs_JGC_CT_NUL, "%s.rotatePivot" % selobjs_JGC_CT_NUL) cmds.move(0, 0, 0, "%s.scalePivot" % selobjs_JGC_CT_rename, "%s.rotatePivot" % selobjs_JGC_CT_rename) cmds.makeIdentity(selobjs_JGC_CT_NUL, a=1) cmds.parent(selobjs_JGC_CT_NUL, 'control_GRP') cmds.parent(selObjs_J_CT, selobjs_PGRP_CT) cmds.delete(selobjs_J_CT_tempGRP) for JGCC in selObjs_J_CT: cmds.parentConstraint(selobjs_JGC_CT_rename, JGCC, mo=1) cmds.scaleConstraint(selobjs_JGC_CT_rename, JGCC, mo=1) else: combCON_selPLY_copy_CT = cmds.duplicate(selObjs_J_CT) combCON_tempPLY_CT = cmds.polyUnite(combCON_selPLY_copy_CT, mergeUVSets=1, constructionHistory=True, n=selObjs_J_CT[0].replace( 'PLY', 'RE')) cmds.delete( combCON_tempPLY_CT, ch=1 ) # like a historyDelete and delete emptyGroup, Also Node Check # CON combCON_CT = cmds.curve(degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) combCON_rename_CT = cmds.rename(selObjs_J_CT[0].replace('PLY', 'CON')) combCON_Shape_CT = cmds.listRelatives(combCON_rename_CT, shapes=1) CL.con_overrideColor_SET() combCON_NUL_CT = cmds.group(em=True, n=selObjs_J_CT[0].replace('PLY', 'NUL')) cmds.parent(combCON_rename_CT, combCON_NUL_CT) cmds.select(combCON_tempPLY_CT[0]) boundingBox_Info() cmds.scale(propRig_bbsX[-1], propRig_bbsY[-1], propRig_bbsZ[-1], combCON_NUL_CT) cmds.move(propRig_bbX_CT[-1], propRig_bbY_CT[-1], propRig_bbZ_CT[-1], combCON_NUL_CT) cmds.move(0, 0, 0, "%s.scalePivot" % combCON_NUL_CT, "%s.rotatePivot" % combCON_NUL_CT) cmds.move(0, 0, 0, "%s.scalePivot" % combCON_rename_CT, "%s.rotatePivot" % combCON_rename_CT) cmds.makeIdentity(combCON_NUL_CT, apply=1) cmds.delete(combCON_tempPLY_CT[0]) cmds.parent(combCON_NUL_CT, 'control_GRP') for d in selObjs_J_CT: cmds.parentConstraint(combCON_rename_CT, d, mo=1) cmds.scaleConstraint(combCON_rename_CT, d, mo=1) con_ChannelBox() cmds.select(deselect=1)
def create_CON_separate(): selObjs_S = cmds.ls(selection=True) # S : Single # if 'GRP' in selObjs_S[0]: # SGC : Sing Group Controller # for SGCC in range( len(selObjs_S)): # SGCC : Single Group Controller Constraint # # Bounding Box : centerPivot SGC_bbInfo = cmds.xform(selObjs_S[SGCC], worldSpace=True, query=True, boundingBox=True) SGC_bbCT_X = (SGC_bbInfo[0] + SGC_bbInfo[3]) / 2.0 SGC_bbCT_Y = (SGC_bbInfo[1] + SGC_bbInfo[4]) / 2.0 SGC_bbCT_Z = (SGC_bbInfo[2] + SGC_bbInfo[5]) / 2.0 # Bounding Box : Size SGC_bbsX = cmds.getAttr( "%s.boundingBoxSizeX" % selObjs_S[SGCC]) / 1.5 SGC_bbsY = cmds.getAttr( "%s.boundingBoxSizeY" % selObjs_S[SGCC]) / 1.5 SGC_bbsZ = cmds.getAttr( "%s.boundingBoxSizeZ" % selObjs_S[SGCC]) / 1.5 selObjs_SGC = cmds.curve(degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) CL.con_overrideColor_SET() selObjs_SGC_rename = cmds.rename(selObjs_S[SGCC].replace( 'GRP', 'CON')) selObjs_SGC_NUL = cmds.group(em=1, n=selObjs_SGC_rename.replace( 'CON', 'NUL')) cmds.parent(selObjs_SGC_rename, selObjs_SGC_NUL) cmds.scale(SGC_bbsX, SGC_bbsY, SGC_bbsZ, selObjs_SGC_NUL) cmds.move(SGC_bbCT_X, SGC_bbCT_Y, SGC_bbCT_Z, selObjs_SGC_NUL) cmds.makeIdentity(selObjs_SGC_NUL, apply=1, s=1) cmds.parent(selObjs_SGC_NUL, 'control_GRP') cmds.parentConstraint(selObjs_SGC_rename, selObjs_S[SGCC], mo=1) cmds.scaleConstraint(selObjs_SGC_rename, selObjs_S[SGCC], mo=1) else: for i in selObjs_S: # Bounding Box : centerPivot sepaCON_bbInfo = cmds.xform(i, worldSpace=True, query=True, boundingBox=True) sepaCON_bbCT_X = (sepaCON_bbInfo[0] + sepaCON_bbInfo[3]) / 2.0 sepaCON_bbCT_Y = (sepaCON_bbInfo[1] + sepaCON_bbInfo[4]) / 2.0 sepaCON_bbCT_Z = (sepaCON_bbInfo[2] + sepaCON_bbInfo[5]) / 2.0 # Bounding Box : Size sepaCON_bbsX = cmds.getAttr("%s.boundingBoxSizeX" % i) / 1.5 sepaCON_bbsY = cmds.getAttr("%s.boundingBoxSizeY" % i) / 1.5 sepaCON_bbsZ = cmds.getAttr("%s.boundingBoxSizeZ" % i) / 1.5 # CON sepaCON = cmds.curve(degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) sepaCON_rename = cmds.rename(i.replace('PLY', 'CON')) CL.con_overrideColor_SET() sepaCON_NUL = cmds.group(em=True, n=i.replace('PLY', 'NUL')) cmds.parent(sepaCON_rename, sepaCON_NUL) cmds.scale(sepaCON_bbsX, sepaCON_bbsY, sepaCON_bbsZ, sepaCON_NUL) cmds.move(sepaCON_bbCT_X, sepaCON_bbCT_Y, sepaCON_bbCT_Z, sepaCON_NUL) cmds.makeIdentity(sepaCON_NUL, apply=1, s=1) cmds.parent(sepaCON_NUL, 'control_GRP') cmds.parentConstraint(sepaCON_rename, i, mo=1) cmds.scaleConstraint(sepaCON_rename, i, mo=1) con_ChannelBox() cmds.select(deselect=True)
def create_CON_separate_CT(): selObjs_S_CT = cmds.ls(selection=True) # S : Single # if 'GRP' in selObjs_S_CT[0]: # SGC : Sing Group Controller # for SGCC in range(len( selObjs_S_CT)): # SGCC : Single Group Controller Constraint # # Bounding Box bbInfo_CT = cmds.xform(selObjs_S_CT[SGCC], worldSpace=True, query=True, boundingBox=True) bbCT_X = (bbInfo_CT[0] + bbInfo_CT[3]) / 2.0 bbCT_Y = (bbInfo_CT[1] + bbInfo_CT[4]) / 2.0 bbCT_Z = (bbInfo_CT[2] + bbInfo_CT[5]) / 2.0 bbsX = cmds.getAttr( "%s.boundingBoxSizeX" % selObjs_S_CT[SGCC]) / 1.5 bbsY = cmds.getAttr( "%s.boundingBoxSizeY" % selObjs_S_CT[SGCC]) / 1.5 bbsZ = cmds.getAttr( "%s.boundingBoxSizeZ" % selObjs_S_CT[SGCC]) / 1.5 # CON.group selObjs_SGC_CT = cmds.curve(degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) CL.con_overrideColor_SET() selObjs_SGC_rename_CT = cmds.rename(selObjs_S_CT[SGCC].replace( 'GRP', 'CON')) selObjs_SGC_NUL_CT = cmds.group(em=1, n=selObjs_SGC_rename_CT.replace( 'CON', 'NUL')) cmds.parent(selObjs_SGC_rename_CT, selObjs_SGC_NUL_CT) cmds.scale(bbsX, bbsY, bbsZ, selObjs_SGC_NUL_CT) cmds.move(bbCT_X, bbCT_Y, bbCT_Z, selObjs_SGC_NUL_CT) cmds.move(0, 0, 0, "%s.scalePivot" % selObjs_SGC_NUL_CT, "%s.rotatePivot" % selObjs_SGC_NUL_CT) cmds.move(0, 0, 0, "%s.scalePivot" % selObjs_SGC_rename_CT, "%s.rotatePivot" % selObjs_SGC_rename_CT) cmds.makeIdentity(selObjs_SGC_NUL_CT, apply=1) cmds.parent(selObjs_SGC_NUL_CT, 'control_GRP') cmds.parentConstraint(selObjs_SGC_rename_CT, selObjs_S_CT[SGCC], mo=1) cmds.scaleConstraint(selObjs_SGC_rename_CT, selObjs_S_CT[SGCC], mo=1) else: for e in selObjs_S_CT: # Bounding Box : centerPivot bbInfo_CT = cmds.xform(e, worldSpace=True, query=True, boundingBox=True) bbCT_X_CT = (bbInfo_CT[0] + bbInfo_CT[3]) / 2.0 bbCT_Y_CT = (bbInfo_CT[1] + bbInfo_CT[4]) / 2.0 bbCT_Z_CT = (bbInfo_CT[2] + bbInfo_CT[5]) / 2.0 bbsX_CT = cmds.getAttr("%s.boundingBoxSizeX" % e) / 1.5 bbsY_CT = cmds.getAttr("%s.boundingBoxSizeY" % e) / 1.5 bbsZ_CT = cmds.getAttr("%s.boundingBoxSizeZ" % e) / 1.5 # CON sepaCON_CT = cmds.curve(degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) CL.con_overrideColor_SET() sepaCON_rename_CT = cmds.rename(e.replace('PLY', 'CON')) sepaCON_NUL_CT = cmds.group(em=True, n=e.replace('PLY', 'NUL')) cmds.parent(sepaCON_rename_CT, sepaCON_NUL_CT) cmds.scale(bbsX_CT, bbsY_CT, bbsZ_CT, sepaCON_NUL_CT) cmds.move(bbCT_X_CT, bbCT_Y_CT, bbCT_Z_CT, sepaCON_NUL_CT) cmds.move(0, 0, 0, "%s.scalePivot" % sepaCON_NUL_CT, "%s.rotatePivot" % sepaCON_NUL_CT) cmds.move(0, 0, 0, "%s.scalePivot" % sepaCON_rename_CT, "%s.rotatePivot" % sepaCON_rename_CT) cmds.makeIdentity(sepaCON_NUL_CT, apply=1) cmds.parent(sepaCON_NUL_CT, 'control_GRP') cmds.parentConstraint(sepaCON_rename_CT, e, mo=1) cmds.scaleConstraint(sepaCON_rename_CT, e, mo=1) con_ChannelBox() cmds.select(deselect=True)