Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import maya.cmds as cmds
- #Must have ** selectedd:
- def popUpSlct():
- if cmds.window("SelectSmth", query=True, exists=True):
- cmds.deleteUI("SelectSmth", window=True)
- else:
- slctWindow = cmds.window('SelectSmth', title="Selector Alert Pop Up Prevention Task Force", width=180, )
- cmds.columnLayout(rowSpacing=10, )
- cmds.text(label='! MUST SELECT CONTROLLER !', width=180, )
- cmds.button(label='Ok', align="center", command=('mc.deleteUI(\"'+slctWindow+'\", window=True)'), width=180, )
- cmds.showWindow(slctWindow)
- #Delete window if existing:
- if cmds.window("toolBox_window", query=True, exists=True):
- cmds.deleteUI("toolBox_window", window=True)
- #Manip Creation:
- def manipCreation(*arg):
- jointSelected = cmds.ls(sl=True, )
- n = 0
- if jointSelected:
- for n in jointSelected:
- jointName = (n[2:])
- jointTransVal = cmds.xform(n, query=True, translation=True, worldSpace=True)
- jointRotVal = cmds.xform(n, query=True, rotation=True)
- manip = cmds.circle(nr=(0,1,0), n="c%s" %jointName)
- cmds.xform(manip[0], translation=jointTransVal, worldSpace=True)
- cmds.xform(manip[0], rotation=jointRotVal, worldSpace=True)
- else :
- cmds.circle(nr=(0,1,0), n="c_manip_01")
- #Shape Renamer:
- def renamer(*arg):
- newName = cmds.textFieldGrp(nameChosen, q=1, text=1)
- listObj = cmds.ls(sl=True)
- objSlctd = len(listObj)
- if objSlctd != 1:
- print ('Nothing Selected')
- else:
- cmds.rename( listObj, newName )
- #Change manip's shape:
- def manipCircle(*arg):
- k = 0
- oldManipShape = cmds.listRelatives(shapes=True)
- manip = cmds.ls(selection = True)
- shpSlctd = len(manip)
- if shpSlctd ==0:
- popUpSlct()
- print ('Nothing Selected')
- else:
- for n in manip:
- manipAll = cmds.ls(selection = True)
- cmds.select(manip[k])
- trgtTranslate = cmds.xform( query=True, translation=True, worldSpace=True, )
- trgtRotate = cmds.xform( query=True, rotation=True, worldSpace=True, )
- circleManip = cmds.circle(nr=(0,1,0), )
- cmds.xform(circleManip[0], translation=trgtTranslate, worldSpace=True, )
- cmds.xform(circleManip[0], rotation=trgtRotate, )
- newManip = cmds.ls(sl=True)[0]
- newManipShape = cmds.listRelatives(shapes=True)
- cmds.select(newManipShape, manip[k] )
- cmds.parent(relative=True, shape=True)
- cmds.delete(oldManipShape[k])
- cmds.rename(newManipShape, oldManipShape[k])
- cmds.delete(newManip)
- k+=1
- cmds.select(manip)
- print 'circle'
- def manipSquare(*arg):
- k = 0
- manip = cmds.ls(selection = True)
- oldManipShape = cmds.listRelatives(shapes=True)
- shpSlctd = len(manip)
- if shpSlctd ==0:
- popUpSlct()
- print ('Nothing Selected')
- else:
- for n in manip:
- manipAll = cmds.ls(selection = True)
- cmds.select(manip[k])
- trgtTranslate = cmds.xform(query=True, translation=True, worldSpace=True, )
- trgtRotate = cmds.xform(query=True, rotation=True, worldSpace=True, )
- squareManip = cmds.circle(nr=(0,1,0), degree = 1, sections = 4, )
- squareShape = cmds.listRelatives(squareManip, shapes=True)
- squareTranform = cmds.listRelatives(squareShape, parent=True)
- cmds.move(-1, 0, 1, squareTranform[0] + ".cv[1]")
- cmds.move(1, 0, 1, squareTranform[0] + ".cv[0]" , squareTranform[0] + ".cv[4]")
- cmds.move(-1, 0, -1, squareTranform[0] + ".cv[2]")
- cmds.move(1, 0, -1, squareTranform[0] + ".cv[3]")
- cmds.xform(squareManip[0], translation=trgtTranslate, worldSpace=True, )
- cmds.xform(squareManip[0], rotation=trgtRotate, )
- newManip = cmds.ls(sl=True)[0]
- newManipShape = cmds.listRelatives(shapes=True)
- cmds.select(newManipShape, manip[k] )
- cmds.parent(relative=True, shape=True)
- cmds.delete(oldManipShape[k])
- cmds.rename(newManipShape, oldManipShape[k])
- cmds.delete(newManip)
- k+=1
- cmds.select(manip)
- print 'square'
- def manipTriangle(*arg):
- manip = cmds.ls(selection = True)
- oldManipShape = cmds.listRelatives(shapes=True)
- trgtTranslate = cmds.xform(query=True, translation=True, worldSpace=True, )
- trgtRotate = cmds.xform(query=True, rotation=True, worldSpace=True, )
- triangleManip = cmds.circle(nr=(0,1,0), degree = 1, sections = 3, )
- triangleShape = cmds.listRelatives(triangleManip, shapes=True)
- triangleTranform = cmds.listRelatives(triangleShape, parent=True)
- cmds.xform(triangleManip, translation=trgtTranslate, worldSpace=True, )
- cmds.xform(triangleManip, rotation=trgtRotate, )
- newManip = cmds.ls(sl=True)[0]
- newManipShape = cmds.listRelatives(shapes=True)
- cmds.select(newManipShape, manip )
- cmds.parent(relative=True, shape=True)
- cmds.delete(oldManipShape)
- cmds.rename(newManipShape, oldManipShape)
- cmds.delete(newManip)
- cmds.select(manip)
- print 'triangle'
- def manipArrow(*arg):
- manip = cmds.ls(selection = True)
- oldManipShape = cmds.listRelatives(shapes=True)
- trgtTranslate = cmds.xform(query=True, translation=True, worldSpace=True, )
- trgtRotate = cmds.xform(query=True, rotation=True, worldSpace=True, )
- arrowManip = cmds.circle(nr=(0,1,0), degree = 1, sections = 7, )
- arrowShape = cmds.listRelatives(arrowManip, shapes=True)
- arrowTranform = cmds.listRelatives(arrowShape, parent=True)
- cmds.move(0, 0, -2, arrowTranform[0] + ".cv[0]" , arrowTranform[0] + ".cv[7]")
- cmds.move(1, 0, -1, arrowTranform[0] + ".cv[1]")
- cmds.move(-1, 0, -1, arrowTranform[0] + ".cv[6]")
- cmds.move(0.5, 0, -1, arrowTranform[0] + ".cv[2]")
- cmds.move(-0.5, 0, -1, arrowTranform[0] + ".cv[5]")
- cmds.move(0.5, 0, 1, arrowTranform[0] + ".cv[3]")
- cmds.move(-0.5, 0, 1, arrowTranform[0] + ".cv[4]")
- cmds.xform(arrowManip, translation=trgtTranslate, worldSpace=True, )
- cmds.xform(arrowManip, rotation=trgtRotate, )
- newManip = cmds.ls(sl=True)[0]
- newManipShape = cmds.listRelatives(shapes=True)
- cmds.select(newManipShape, manip )
- cmds.parent(relative=True, shape=True)
- cmds.delete(oldManipShape)
- cmds.rename(newManipShape, oldManipShape)
- cmds.delete(newManip)
- cmds.select(manip)
- print 'arrow'
- def manipCross(*arg):
- manip = cmds.ls(selection = True)
- oldManipShape = cmds.listRelatives(shapes=True)
- trgtTranslate = cmds.xform(query=True, translation=True, worldSpace=True, )
- trgtRotate = cmds.xform(query=True, rotation=True, worldSpace=True, )
- arrowManip = cmds.circle(nr=(0,1,0), degree = 1, sections = 24, )
- arrowShape = cmds.listRelatives(arrowManip, shapes=True)
- arrowTranform = cmds.listRelatives(arrowShape, parent=True)
- cmds.move(0, 0, -2, arrowTranform[0] + ".cv[0]", arrowTranform[0] + ".cv[24]", )
- cmds.move(-0.6, 0, -1, arrowTranform[0] + ".cv[1]", )
- cmds.move(0.6, 0, -1, arrowTranform[0] + ".cv[23]", )
- cmds.move(-0.25, 0, -1, arrowTranform[0] + ".cv[2]", )
- cmds.move(0.25, 0, -1, arrowTranform[0] + ".cv[22]", )
- cmds.move(2, 0, 0, arrowTranform[0] + ".cv[18]", )
- cmds.move(1, 0, 0.6, arrowTranform[0] + ".cv[17]", )
- cmds.move(1, 0, -0.6, arrowTranform[0] + ".cv[19]", )
- cmds.move(1, 0, 0.25, arrowTranform[0] + ".cv[16]", )
- cmds.move(1, 0, -0.25, arrowTranform[0] + ".cv[20]", )
- cmds.move(0, 0, 2, arrowTranform[0] + ".cv[12]", )
- cmds.move(-0.6, 0, 1, arrowTranform[0] + ".cv[11]", )
- cmds.move(0.6, 0, 1, arrowTranform[0] + ".cv[13]", )
- cmds.move(-0.25, 0, 1, arrowTranform[0] + ".cv[10]", )
- cmds.move(0.25, 0, 1, arrowTranform[0] + ".cv[14]", )
- cmds.move(-2, 0, 0, arrowTranform[0] + ".cv[6]", )
- cmds.move(-1, 0, -0.6, arrowTranform[0] + ".cv[5]", )
- cmds.move(-1, 0, 0.6, arrowTranform[0] + ".cv[7]", )
- cmds.move(-1, 0, -0.25, arrowTranform[0] + ".cv[4]", )
- cmds.move(-1, 0, 0.25, arrowTranform[0] + ".cv[8]", )
- cmds.move(-0.25, 0, -0.25, arrowTranform[0] + ".cv[3]", )
- cmds.move(-0.25, 0, 0.25, arrowTranform[0] + ".cv[9]", )
- cmds.move(0.25, 0, 0.25, arrowTranform[0] + ".cv[15]", )
- cmds.move(0.25, 0, -0.25, arrowTranform[0] + ".cv[21]", )
- cmds.xform(arrowManip, translation=trgtTranslate, worldSpace=True, )
- cmds.xform(arrowManip, rotation=trgtRotate, )
- newManip = cmds.ls(sl=True)[0]
- newManipShape = cmds.listRelatives(shapes=True)
- cmds.select(newManipShape, manip )
- cmds.parent(relative=True, shape=True)
- cmds.delete(oldManipShape)
- cmds.rename(newManipShape, oldManipShape)
- cmds.delete(newManip)
- cmds.select(manip)
- print 'cross'
- #Change manip's color:
- def manipRed(*arg):
- manip = cmds.ls(sl=True)
- manipShp = cmds.listRelatives(manip, s = True)
- shpSlctd = len(manip)
- if shpSlctd ==0:
- popUpSlct()
- print ('Nothing Selected')
- else:
- for n in manipShp:
- cmds.setAttr(n + ".overrideEnabled", 1)
- cmds.setAttr(n + ".overrideColor", 13)
- print 'Roses Are Red...'
- def manipBlue(*arg):
- manip = cmds.ls(sl=True)
- manipShp = cmds.listRelatives(manip, s = True)
- shpSlctd = len(manip)
- if shpSlctd ==0:
- popUpSlct()
- print ('Nothing Selected')
- else:
- for n in manipShp:
- cmds.setAttr(n + ".overrideEnabled", 1)
- cmds.setAttr(n + ".overrideColor", 6)
- print 'Violets Are Blue!'
- def manipYellow(*arg):
- manip = cmds.ls(sl=True)
- manipShp = cmds.listRelatives(manip, s = True)
- shpSlctd = len(manip)
- if shpSlctd ==0:
- popUpSlct()
- print ('Nothing Selected')
- else:
- for n in manipShp:
- cmds.setAttr(n + ".overrideEnabled", 1)
- cmds.setAttr(n + ".overrideColor", 17)
- print 'Your controller is now yellow'
- def manipGreen(*arg):
- manip = cmds.ls(sl=True)
- manipShp = cmds.listRelatives(manip, s = True)
- shpSlctd = len(manip)
- if shpSlctd ==0:
- popUpSlct()
- print ('Nothing Selected')
- else:
- for n in manipShp:
- cmds.setAttr(n + ".overrideEnabled", 1)
- cmds.setAttr(n + ".overrideColor", 14)
- print 'Your controller is now green'
- def manipSkyBlue(*arg):
- manip = cmds.ls(sl=True)
- manipShp = cmds.listRelatives(manip, s = True)
- shpSlctd = len(manip)
- if shpSlctd ==0:
- popUpSlct()
- print ('Nothing Selected')
- else:
- for n in manipShp:
- cmds.setAttr(n + ".overrideEnabled", 1)
- cmds.setAttr(n + ".overrideColor", 18)
- print 'Your controller is now skyBlue'
- #UI:
- window = cmds.window("toolBox_window", title="Tool Box Kawai", menuBar=True, width=250, height=100, backgroundColor=(0.75, 0.25, 0.5))
- cmds.menu(label='Options')
- cmds.menuItem(label='Turn Off Auxilliary power', command=('cmds.deleteUI(\"'+window+'\", window=True)'))
- cmds.columnLayout('columnMain', adjustableColumn=True, rowSpacing=5, )
- cmds.separator(height=10, style='none', bgc=(0.7, 0.2, 0.5), )
- cmds.button('manipBtn', label='Create Manip', command = manipCreation, bgc=(0.6, 0.2, 0.5), )
- cmds.separator(height=10, style='none', bgc=(0.7, 0.2, 0.5), )
- cmds.rowLayout('rowManipRename', numberOfColumns=3, )
- cmds.text(label='New Name :', height=30, width = 60, )
- nameChosen = cmds.textFieldGrp('newNameChosen', bgc=(0.1, 0.1, 0.1), width = 130, )
- cmds.button('renameBtn', label='Rename', command = renamer, width = 65, bgc=(0.6, 0.2, 0.5), )
- cmds.setParent( '..' )
- cmds.separator(height=10, style='none', bgc=(0.7, 0.2, 0.5), )
- #Change manip's shape UI:
- cmds.text(label='Change Manip\'s Shape', height=30 )
- cmds.rowLayout('rowManipShape', numberOfColumns=5, columnWidth5=(50, 50, 50, 50, 50), )
- cmds.iconTextButton('circle', style='iconAndTextVertical', label='Circle', width=50, image='', command = manipCircle, )
- cmds.iconTextButton('square', style='iconAndTextVertical', label='Square', width=50, image='', command = manipSquare, )
- cmds.iconTextButton('triangle', style='iconAndTextVertical', label='Triangle', width=50, image='', command = manipTriangle, )
- cmds.iconTextButton('arrow', style='iconAndTextVertical', label='Arrow', width=50, image='', command = manipArrow, )
- cmds.iconTextButton('cross', style='iconAndTextVertical', label='Cross', width=50, image='', command = manipCross, )
- cmds.setParent( '..' )
- cmds.separator(height=10, style='none', bgc=(0.7, 0.2, 0.5), )
- #Change manip's color UI:
- cmds.text(label='Change Manip\'s Color', height=30 )
- cmds.rowLayout('rowManipColor', numberOfColumns=5, columnWidth5=(50, 50, 50, 50, 50), )
- cmds.iconTextButton('red', style='iconAndTextVertical', label='Red', width=50, image='', command = manipRed, )
- cmds.iconTextButton('blue', style='iconAndTextVertical', label='Blue', width=50, image='', command = manipBlue, )
- cmds.iconTextButton('yellow', style='iconAndTextVertical', label='Yellow', width=50, image='', command = manipYellow, )
- cmds.iconTextButton('green', style='iconAndTextVertical', label='Green', width=50, image='', command = manipGreen, )
- cmds.iconTextButton('skyBlue', style='iconAndTextVertical', label='Sky Blue', width=50, image='', command = manipSkyBlue, )
- cmds.setParent( '..' )
- cmds.showWindow(window)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement