Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import maya.cmds as mc
- #Center the pivot on all selected objects
- def centerPivot():
- objectList = mc.ls(selection = True)
- if len(objectList) > 0:
- for object in objectList:
- mc.xform (object, cp = True,)
- else:
- print 'Please select the object or objects you would like to center the pivot on'
- #Combine multiple meshes into one
- def combineMeshes():
- selectedObjects = mc.ls(orderedSelection = True)
- currentUnitedPoly = selectedObjects[0]
- if(len(selectedObjects) > 1):
- mc.polyUnite(selectedObjects[0:len(selectedObjects)], name = 'Combined Mesh_#', ch = False, mergeUVSets = 1, centerPivot = True)
- else:
- print "Please select more than one object"
- #Conforms all normals to the most popular normal direction
- def conformNormals():
- objectList = mc.ls(selection = True)
- if len(objectList) > 0:
- for object in objectList:
- mc.polyNormal(object, normalMode = 2, userNormalMode = 0, ch = True)
- else:
- print 'Please select the object or objects you would like to conform normals on'
- #Harden the selected edges
- def hardenEdge():
- selectedObjects = mc.ls(orderedSelection = True)
- onlyEdges = mc.filterExpand(selectedObjects, sm= 32)
- mc.polySoftEdge (onlyEdges[0:len(onlyEdges)], a = 0, ch = 1)
- #Soften selected edges
- def softenEdge():
- selectedObjects = mc.ls(orderedSelection = True)
- onlyEdges = mc.filterExpand(selectedObjects, sm= 32)
- mc.polySoftEdge (onlyEdges[0:len(onlyEdges)], a = 180, ch = 1)
- #Fills all holes in an object
- def fillHoles():
- objectList = mc.ls(selection = True)
- if len(objectList) > 0:
- for object in objectList:
- mc.polyCloseBorder(object, ch = True)
- else:
- print 'Please select the object or objects you would like to conform normals on'
- #Apply an aim constraint to 2 objects
- def aimConstrain():
- selectedObjects = mc.ls(orderedSelection = True)
- if(len(selectedObjects) != 2):
- print 'Please only select 2 objects'
- else:
- cmds.aimConstraint( selectedObjects[0], selectedObjects[1], aimVector=[1, 0, 0], name='object_aimConstraint_#')
- #Apply a point constraint to 2 objects and determine if you want to maintain the offset on the objects
- def pointConstrain():
- selectedObjects = mc.ls(orderedSelection = True)
- mop = mc.checkBox('mop', query = True, value = True)
- if(len(selectedObjects) != 2):
- print 'Please only select 2 objects'
- else:
- cmds.pointConstraint( selectedObjects[0], selectedObjects[1], mo = mop, weight = 1, name='object_pointConstraint_#')
- #Merge polygon verts dependent upon the set Threshold value
- def mergeVertex():
- selectedObjects = mc.ls(orderedSelection = True)
- onlyVertices = mc.filterExpand(selectedObjects, sm=31)
- threshold = mc.floatSliderGrp('Threshold', query = True, value = True)
- if(len(onlyVertices) == 1):
- mc.polyMergeVertex (onlyVertices, d = threshold, am = 1, ch = 1)
- else:
- mc.polyMergeVertex (onlyVertices[0:len(onlyVertices)], d = threshold, am = 1, ch = 1)
- def deleteHistory():
- selectedObjects = mc.ls(selection = True)
- for object in selectedObjects:
- mc.delete(object, ch = True)
- def freezeTransform():
- selectedObjects = mc.ls(selection = True)
- for object in selectedObjects:
- mc.makeIdentity(object, apply = True, t = 1, r = 1, s = 1, n = 0, pn = 1)
- def allThree():
- centerPivot()
- deleteHistory()
- freezeTransform()
- def createToolKitWindow():
- if mc.window('Georges_Tool_Kit', exists = True):
- mc.deleteUI('Georges_Tool_Kit')
- mc.window('Georges_Tool_Kit', widthHeight = (500, 400), s = False)
- mc.columnLayout(adjustableColumn = True)
- mc.text(label = "George's Tool Kit", height = 50, font = 'boldLabelFont', bgc = [0.5, 0.5, 0.9])
- mc.separator (h=10, style = 'none')
- mc.separator (h=10, style = 'none')
- mc.button(label = 'Combine Meshes', command = 'combineMeshes()')
- mc.button(label = 'Conform Normals', command = 'conformNormals()')
- mc.button(label = 'Harden Edge', command = 'hardenEdge()')
- mc.button(label = 'Soften Edge', command = 'softenEdge()')
- mc.button(label = 'Fill Holes', command = 'fillHoles()')
- mc.button(label = 'Aim Constrain', command = 'aimConstrain()')
- mc.button(label = 'Point Constrain', command = 'pointConstrain()')
- mc.separator (h=10, style = 'none')
- mc.checkBox('mop', label = 'Maintain Offset', align = 'center')
- mc.separator (h=10, style = 'none')
- mc.button(label = 'Merge Vertex', command = 'mergeVertex()')
- mc.separator (h=10, style = 'none')
- mc.floatSliderGrp('Threshold', label = 'Threshold', field = True, minValue = 0, value = 10)
- mc.separator (h=10, style = 'none')
- mc.button(label = 'Center Pivot', command = 'centerPivot()')
- mc.button(label = 'Delete History', command = 'deleteHistory()')
- mc.button(label = 'Freeze Transformations', command = 'freezeTransform()')
- mc.button(label = 'CP + DH + FT', command = 'allThree()')
- mc.window('Georges_Tool_Kit', widthHeight = (500, 425), e = True)
- mc.showWindow('Georges_Tool_Kit')
- createToolKitWindow()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement