本文整理汇总了Python中maya.cmds.timerX函数的典型用法代码示例。如果您正苦于以下问题:Python timerX函数的具体用法?Python timerX怎么用?Python timerX使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了timerX函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: buildData
def buildData(self,curve,worldSpace=False):
'''
Build NurbsCurveData class.
@param curve: Curve to build data from
@type curve: str
'''
# ==========
# - Checks -
# ==========
# Check Curve
if not glTools.utils.curve.isCurve(curve):
raise Exception('Object "'+curve+'" is not a vaild NURBS curve node!')
# World Space
space = OpenMaya.MSpace.kObject
if worldSpace: space = OpenMaya.MSpace.kWorld
# ==============
# - Build Data -
# ==============
# Start timer
timer = mc.timerX()
# Get basic curve info
self._data['name'] = curve
# Get Curve Function Class
curveFn = glTools.utils.curve.getCurveFn(curve)
# Get Curve Degree and Form
self._data['degree'] = curveFn.degreeU()
self._data['form'] = int(curveFn.formInU())
# Get Curve Knots
knotArray = OpenMaya.MDoubleArray()
curveFn.getKnotsInU(knotArray)
self._data['knots'] = list(knotArray)
# Get Control Vertices
cvArray = OpenMaya.MPointArray()
curveFn.getCVs(cvArray,space)
self._data['cv'] = [(cvArray[i].x,cvArray[i].y,cvArray[i].z) for i in range(cvArray.length())]
# Get Edit Points
editPt = OPenMaya.MPoint()
for u in self._data['knots']:
curveFn.getPointAtParam(u,editPt,space)
self._data['editPt'].append((editPt.x,editPt.y,editPt.z))
# =================
# - Return Result -
# =================
# Print timer result
buildTime = mc.timerX(st=timer)
print('NurbsCurveData: Data build time for curve "'+curve+'": '+str(buildTime))
return self._data['name']
示例2: cleanDeformers
def cleanDeformers(eightThreshold=0.001,showProgress=False):
'''
Cleaning all deformers
Prune small weights and membership
'''
print('# Clean Rig: Cleaning Deformers (prune weights and membership)')
# Start Timer
timer = mc.timerX()
deformerList = glTools.utils.deformer.getDeformerList(nodeType='weightGeometryFilter')
if showProgress and interactive:
mc.progressBar( gMainProgressBar,e=True,bp=True,ii=True,status=('Cleaning Deformers...'),maxValue=len(deformerList) )
# For Each Deformer
for deformer in deformerList:
# Clean Deformers
try: glTools.utils.deformer.clean(deformer,threshold=weightThreshold)
except: print('# Clean Rig: XXXXXXXXX ======== Unable to clean deformer "'+deformer+'"! ======== XXXXXXXXX')
# Update Progress Bar
if showProgress and interactive:
if mc.progressBar(gMainProgressBar,q=True,isCancelled=True):
mc.progressBar(gMainProgressBar,e=True,endProgress=True)
raise UserInterupted('Operation cancelled by user!')
mc.progressBar(gMainProgressBar,e=True,step=1)
if showProgress and interactive:
mc.progressBar(gMainProgressBar,e=True,endProgress=True)
# Print Timed Result
print('# Clean Rig: Clean Deformers - '+str(mc.timerX(st=timer)))
示例3: pythonScripts
def pythonScripts():
if (cmds.menu ('pythonScripts_menu', exists=True)):
print ("Removing old pythonScripts menu...")
cmds.deleteUI ('pythonScripts_menu')
gMainWindow = maya.mel.eval('$temp1=$gMainWindow')
gMainProgressBar = maya.mel.eval('$temp=$gMainProgressBar')
mainDir = findFile('pythonScripts.py')
timer = cmds.timerX()
cmds.waitCursor (state=True)
print ""
cmds.progressBar (gMainProgressBar, edit=True,
beginProgress=True,
isInterruptable=True,
status="Creating pythonScripts...",
maxValue=100)
pMenu = (cmds.menu ('pythonScripts_menu', parent=gMainWindow, tearOff=True, aob=True, label="pythonScripts"))
gen_pythonScripts(mainDir, pMenu)
cmds.waitCursor (state=False)
endTime = cmds.timerX(startTime=timer)
cmds.progressBar (gMainProgressBar, edit=True,
endProgress=True,)
print ("pythonTools has now been updated in: " + str(endTime) + " seconds...!")
示例4: getClosestPointList
def getClosestPointList(self,ptList):
'''
'''
# Start timer
timer = mc.timerX()
# Display Progress
glTools.utils.progressBar.init(status=('Building Closest Point Coord Array...'),maxValue=int(len(ptList)*0.1))
# Rebuild Mesh Data
meshUtil = OpenMaya.MScriptUtil()
numVertices = len(self._data['vertexList'])/3
numPolygons = len(self._data['polyCounts'])
polygonCounts = OpenMaya.MIntArray()
polygonConnects = OpenMaya.MIntArray()
meshUtil.createIntArrayFromList(self._data['polyCounts'],polygonCounts)
meshUtil.createIntArrayFromList(self._data['polyConnects'],polygonConnects)
# Rebuild Vertex Array
vertexArray = OpenMaya.MFloatPointArray(numVertices,OpenMaya.MFloatPoint.origin)
vertexList = [vertexArray.set(i,self._data['vertexList'][i*3],self._data['vertexList'][i*3+1],self._data['vertexList'][i*3+2],1.0) for i in xrange(numVertices)]
# Rebuild Mesh
meshFn = OpenMaya.MFnMesh()
meshData = OpenMaya.MFnMeshData().create()
meshObj = meshFn.create(numVertices,numPolygons,vertexArray,polygonCounts,polygonConnects,meshData)
# Build Mesh Intersector
meshPt = OpenMaya.MPointOnMesh()
meshIntersector = OpenMaya.MMeshIntersector()
meshIntersector.create(meshObj,OpenMaya.MMatrix.identity)
# Get Closest Point Data
ptCount = len(ptList)
pntList = [ (0,0,0) for i in range(ptCount) ]
for i in range(ptCount):
# Get Closest Point
mpt = glTools.utils.base.getMPoint(ptList[i])
meshIntersector.getClosestPoint(mpt,meshPt,self.maxDist)
# Get Mesh Point Data
pt = meshPt.getPoint()
pntList[i] = (pt[0],pt[1],pt[2])
# Update Progress Bar (Every 10th Iteration)
if not i % 10: glTools.utils.progressBar.update(step=1)
# =================
# - Return Result -
# =================
# End Progress
if showProgress: glTools.utils.progressBar.end()
# Print timer result
buildTime = mc.timerX(st=timer)
print('MeshIntersectData: Closest Point search time for mesh "'+self._data['name']+'": '+str(buildTime))
return pntList
示例5: deleteUnusedNodes
def deleteUnusedNodes():
"""
Delete unused nodes
"""
# Start Timer
timer = cmds.timerX()
# BindPose
print('Deleting bind pose ("dagPose") nodes')
dagPoseNodes = cmds.ls(type='dagPose')
if dagPoseNodes: cmds.delete(dagPoseNodes)
# Unknown
print('Deleting unknown nodes')
glTools.utils.cleanup.deleteUnknownNodes()
# Sets
# print('Deleting empty sets')
# glTools.utils.cleanup.deleteEmptySets()
# Display Layers
print('Deleting display layers')
glTools.utils.cleanup.deleteDisplayLayers()
# Render Layers
print('Deleting render layers')
glTools.utils.cleanup.deleteRenderLayers()
# Turtle
print('Removing Turtle plugin')
glTools.utils.cleanup.removeTurtle()
# Print Timed Result
print('# Clean Rig: Delete Unused Nodes - ' + str(cmds.timerX(st=timer)))
示例6: cleanSkinClusters
def cleanSkinClusters(showProgress=False):
"""
@param showProgress:
"""
# Start Timer
timer = cmds.timerX()
# Clean SkinClusters
skinClusterList = cmds.ls(type='skinCluster')
if showProgress and interactive:
cmds.progressBar(gMainProgressBar, e=True, bp=True, ii=True, status=('Cleaning SkinClusters...'),
maxValue=len(skinClusterList))
for skinCluster in skinClusterList:
try:
glTools.utils.skinCluster.clean(skinCluster, tolerance=0.001)
except:
print(
'# Clean Rig: XXXXXXXXX ======== Unable to clean skinCluster "' + skinCluster + '"! ======== XXXXXXXXX')
# Update Progress Bar
if showProgress and interactive:
if cmds.progressBar(gMainProgressBar, q=True, isCancelled=True):
cmds.progressBar(gMainProgressBar, e=True, endProgress=True)
raise UserInterupted('Operation cancelled by user!')
cmds.progressBar(gMainProgressBar, e=True, step=1)
if showProgress and interactive:
cmds.progressBar(gMainProgressBar, e=True, endProgress=True)
# Print Timed Result
print('# Clean Rig: Clean SkinClusters - ' + str(cmds.timerX(st=timer)))
示例7: Cas_MCW_convertRidgidToSoftButton_cmd
def Cas_MCW_convertRidgidToSoftButton_cmd():
sel = cmds.ls(sl=True , tr= 1)
if (sel == None) or (sel==[]):
Cas_IO.Cas_printWarning ("Please select at lease one objects or group to convert...")
return
org = []
rel = cmds.listRelatives(sel[:],ad = 1,pa =1 , typ="transform")
if rel != None:
org = rel
org.extend(sel[:])
source = org[:] # make a copy
for node in org :
shape = cmds.listRelatives(node , s=1 , type = "mesh")
if shape == None:
source.remove(node);
#print source
result = Cas_convertRigidToSmooth.Cas_convertRigidToSmooth_cmd(source)
if result[1] == 0:
Cas_IO.Cas_printInfo("%s rigid skin converted to smooth skin" %result[0])
else:
Cas_IO.Cas_printWarning("%s rigid skin converted to smooth skin with %s warnings. please check your script editor" %(result[0],result[1]))
autoDelete = cmds.checkBox(Cas_MCW_autoDeleteJointClusterCheckCT,q=True,v=True)
if autoDelete == True:
time2 = cmds.timerX()
confirm = cmds.confirmDialog( title="Delete rigid joint clusters" , message="It will disconnect the other objects bind to the deleted clusters as well"+"\n"\
+" Are you sure?", button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No' )
timeTook2 = cmds.timerX(st=time2)
if confirm == "Yes":
Cas_convertRigidToSmooth.Cas_CRTS_deleteJointCluster(source)
示例8: rebuild
def rebuild(self,skinClusterList=[]):
'''
Rebuild a list of skinClusters using the data stored in the class member dictionaries.
@param skinClusterList: List of scene skinClusters to rebuild. If empty, use all saved skinClusters.
@type skinClusterList: list
'''
# Check skinClusterList
if not skinClusterList: skinClusterList = self.data.keys()
# Start timer
print('Rebuilding skinClusters...')
timer = mc.timerX()
# Rebuild each skinCluster
for skinCluster in skinClusterList:
# Check skinCluster
if not self.data.has_key(skinCluster):
raise Exception('No data stored for skinCluster "'+skinCluster+'"!')
# Rebuild skinCluster
self.rebuildSkinCluster(skinCluster)
# Print timed result
totalTime = mc.timerX(st=timer)
print('Total rebuild time: '+str(totalTime))
示例9: rebuildMesh
def rebuildMesh(self):
'''
'''
# Start timer
timer = mc.timerX()
# Rebuild Mesh Data
meshData = OpenMaya.MObject()
meshUtil = OpenMaya.MScriptUtil()
numVertices = len(self._data['vertexList'])/3
numPolygons = len(self._data['polyCounts'])
polygonCounts = OpenMaya.MIntArray()
polygonConnects = OpenMaya.MIntArray()
meshUtil.createIntArrayFromList(self._data['polyCounts'],polygonCounts)
meshUtil.createIntArrayFromList(self._data['polyConnects'],polygonConnects)
# Rebuild UV Data
uArray = OpenMaya.MFloatArray()
vArray = OpenMaya.MFloatArray()
meshUtil.createFloatArrayFromList(self._data['uArray'],uArray)
meshUtil.createFloatArrayFromList(self._data['vArray'],vArray)
uvCounts = OpenMaya.MIntArray()
uvIds = OpenMaya.MIntArray()
meshUtil.createIntArrayFromList(self._data['uvCounts'],uvCounts)
meshUtil.createIntArrayFromList(self._data['uvIds'],uvIds)
# Rebuild Vertex Array
vertexArray = OpenMaya.MFloatPointArray(numVertices,OpenMaya.MFloatPoint.origin)
vertexList = [vertexArray.set(i,self._data['vertexList'][i*3],self._data['vertexList'][i*3+1],self._data['vertexList'][i*3+2],1.0) for i in xrange(numVertices)]
# Rebuild Mesh
meshFn = OpenMaya.MFnMesh()
meshObj = meshFn.create( numVertices,
numPolygons,
vertexArray,
polygonCounts,
polygonConnects,
uArray,
vArray,
meshData )
# Assign UVs
meshFn.assignUVs(uvCounts,uvIds)
# Rename Mesh
mesh = OpenMaya.MFnDependencyNode(meshObj).setName(self._data['name'])
meshShape = mc.listRelatives(mesh,s=True,ni=True,pa=True)[0]
# Assign Initial Shading Group
mc.sets(meshShape,fe='initialShadingGroup')
# Print timer result
buildTime = mc.timerX(st=timer)
print('MeshIntersectData: Geometry rebuild time for mesh "'+mesh+'": '+str(buildTime))
# =================
# - Return Result -
# =================
return mesh
示例10: buildData
def buildData(self,surface,worldSpace=False):
'''
Build NurbsSurfaceData class.
@param surface: Surface to build data from
@type surface: str
'''
# ==========
# - Checks -
# ==========
# Check Surface
if not glTools.utils.surface.isSurface(surface):
raise Exception('Object "'+surface+'" is not a vaild NURBS surface node!')
# World Space
space = OpenMaya.MSpace.kObject
if worldSpace: space = OpenMaya.MSpace.kWorld
# ==============
# - Build Data -
# ==============
# Start timer
timer = mc.timerX()
# Get basic surface info
self._data['name'] = surface
# Get Surface Function Class
surfaceFn = glTools.utils.surface.getSurfaceFn(surface)
# Get Surface Degree and Form
self._data['degreeU'] = surfaceFn.degreeU()
self._data['degreeV'] = surfaceFn.degreeV()
self._data['formU'] = int(surfaceFn.formInU())
self._data['formV'] = int(surfaceFn.formInV())
# Get Surface Knots
knotsUarray = OpenMaya.MDoubleArray()
knotsVarray = OpenMaya.MDoubleArray()
surfaceFn.getKnotsInU(knotsUarray)
surfaceFn.getKnotsInV(knotsVarray)
self._data['knotsU'] = list(knotsUarray)
self._data['knotsV'] = list(knotsVarray)
# Get Control Vertices
cvArray = OpenMaya.MPointArray()
surfaceFn.getCVs(cvArray,space)
self._data['cv'] = [(cvArray[i].x,cvArray[i].y,cvArray[i].z) for i in range(cvArray.length())]
# =================
# - Return Result -
# =================
# Print timer result
buildTime = mc.timerX(st=timer)
print('NurbsSurfaceData: Data build time for surface "'+surface+'": '+str(buildTime))
return self._data['name']
示例11: rebuildSurface
def rebuildSurface(self):
"""
"""
# Start timer
timer = cmds.timerX()
# ========================
# - Rebuild Surface Data -
# ========================
# Rebuild Control Vertices
nucmdsVs = len(self._data["cv"])
cvArray = OpenMaya.MPointArray(nucmdsVs, OpenMaya.MPoint.origin)
for i in range(nucmdsVs):
cvArray.set(OpenMaya.MPoint(self._data["cv"][i][0], self._data["cv"][i][1], self._data["cv"][i][2], 1.0), i)
# Rebuild Surface Knot Arrays
numKnotsU = len(self._data["knotsU"])
numKnotsV = len(self._data["knotsV"])
knotsU = OpenMaya.MDoubleArray(numKnotsU, 0)
knotsV = OpenMaya.MDoubleArray(numKnotsV, 0)
for i in range(numKnotsU):
knotsU.set(self._data["knotsU"][i], i)
for i in range(numKnotsV):
knotsV.set(self._data["knotsV"][i], i)
# Rebuild Surface
surfaceFn = OpenMaya.MFnMesh()
surfaceData = OpenMaya.MObject()
surfaceObj = surfaceFn.create(
cvArray,
knotsU,
knotsV,
self._data["degreeU"],
self._data["degreeV"],
self._data["formU"],
self._data["formV"],
self._data["rational"],
surfaceData,
)
# Rename Surface
surface = OpenMaya.MFnDependencyNode(surfaceObj).setName(self._data["name"])
surfaceShape = cmds.listRelatives(surface, s=True, ni=True, pa=True)[0]
# Assign Initial Shading Group
cmds.sets(surfaceShape, fe="initialShadingGroup")
# =================
# - Return Result -
# =================
# Print timer result
buildTime = cmds.timerX(st=timer)
print('NurbsSurfaceData: Geometry rebuild time for surface "' + surface + '": ' + str(buildTime))
return surface
示例12: rebuild
def rebuild(self):
"""
"""
# Start timer
timer = cmds.timerX()
# Rebuild Mesh Data
meshUtil = OpenMaya.MScriptUtil()
numVertices = len(self._data['vertexList']) / 3
numPolygons = len(self._data['polyCounts'])
polygonCounts = OpenMaya.MIntArray()
polygonConnects = OpenMaya.MIntArray()
meshUtil.createIntArrayFromList(self._data['polyCounts'], polygonCounts)
meshUtil.createIntArrayFromList(self._data['polyConnects'], polygonConnects)
# Rebuild UV Data
uvCounts = OpenMaya.MIntArray()
uvIds = OpenMaya.MIntArray()
meshUtil.createIntArrayFromList(self._data['uvCounts'], uvCounts)
meshUtil.createIntArrayFromList(self._data['uvIds'], uvIds)
uArray = OpenMaya.MFloatArray()
vArray = OpenMaya.MFloatArray()
meshUtil.createFloatArrayFromList(self._data['uArray'], uArray)
meshUtil.createFloatArrayFromList(self._data['vArray'], vArray)
# Rebuild Vertex Array
vertexArray = OpenMaya.MFloatPointArray(numVertices, OpenMaya.MFloatPoint.origin)
vertexList = [vertexArray.set(i, self._data['vertexList'][i * 3], self._data['vertexList'][i * 3 + 1],
self._data['vertexList'][i * 3 + 2], 1.0) for i in xrange(numVertices)]
# Rebuild Mesh
meshFn = OpenMaya.MFnMesh()
meshData = OpenMaya.MFnMeshData().create()
meshObj = meshFn.create(numVertices,
numPolygons,
vertexArray,
polygonCounts,
polygonConnects,
uArray,
vArray,
meshData)
# Assign UVs
meshFn.assignUVs(uvCounts, uvIds)
meshObjHandle = OpenMaya.MObjectHandle(meshObj)
# Print Timed Result
buildTime = cmds.timerX(st=timer)
print('MeshIntersectData: Data rebuild time for mesh "' + self._data['name'] + '": ' + str(buildTime))
# =================
# - Return Result -
# =================
return meshObjHandle
示例13: copyInputShapeAttrs
def copyInputShapeAttrs():
"""
"""
# Start Timer
timer = cmds.timerX()
print('# Clean Rig: Copy Input Shape User Attributes')
glTools.utils.cleanup.copyInputShapeAttrs(0)
# Print Timed Result
print('# Clean Rig: Copy Input Shape User Attributes - ' + str(cmds.timerX(st=timer)))
示例14: pub_cleanLocators
def pub_cleanLocators():
_sel = mc.ls(sl=True)
#START - get the number of pieces
_pieceNumber = len(_sel) - 1
if ( _pieceNumber <= 0):
#print "Not enough cutting points!"
mm.eval('error -showLineNumber False "Not enough cutting points!";')
#END - get the number of pieces
#
#START - get the object to cut and check if it`s valid
_baseObj = _sel[ len(_sel) - 1]
_shps = mc.listRelatives( _baseObj, shapes=True )
for _shp in _shps:
#print mc.objectType( _shp )
if mc.objectType(_shp) != "mesh":
mm.eval('error -showLineNumber False "Make sure the last object selected is a polygon object!";')
#print "Make sure the last object selected is a polygon object!"
# END - get the object to cut and check if it`s valid
#
#
# START - clean the object for anouther round :)
if mc.attributeQuery( 'factureCrack', node=_baseObj, ex=True) == 1:
mc.deleteAttr( _baseObj, at='factureCrack' )
# END - clean the object for anouther round :)
#
# START - Preparing progressBar
ui_addPB( "add", 0, "Preparing cut points...", _pieceNumber)
# END - Preparing progressBar
_startTime = mc.timerX()
for _i in range (0, _pieceNumber):
_loc = _sel[_i];
gMainProgressBar = mm.eval('$tmp = $gMainProgressBar');
if mc.progressBar(gMainProgressBar, query=True, isCancelled=True ):
break
ui_addPB( "edit", 1, "Testing cut point %d/%d " % (_i, _pieceNumber), 0)
print "Locator " + _loc + ":"
#priv_rayIntersect(_loc, _baseObj )
if priv_rayIntersect(_loc, _baseObj ) == 0:
#mc.select( _loc, replace=True )
mc.delete( _loc )
#START - close the progressBar
ui_addPB( "del", 0, "", 0)
#END - close the progressBar
#
#START - show some statistics
_totalTime = mc.timerX( startTime= _startTime)
print ("Sorting %d cutting points took %g s to complete." % (_pieceNumber, _totalTime))
示例15: rebuild
def rebuild(self, nodeList=None):
"""
Rebuild constraint(s) from data
@param nodeList: List of constraint nodes to rebuild. If None, rebuild all stored data.
@type nodeList: list
"""
# ==========
# - Checks -
# ==========
self.verify()
# ===========================
# - Rebuild Constraint Data -
# ===========================
# Start timer
timer = cmds.timerX()
# Get Node List
if not nodeList:
nodeList = self._data.keys()
# =================================
# - Rebuild Constraints from Data -
# =================================
print(self.name() + ': Rebuilding Constraints...')
constraintList = []
for constraint in nodeList:
# Check Constraint Key
if not self._data.has_key(constraint):
print('No constraint data for "' + constraint + '"!! Skipping...')
continue
if not self._data[constraint]['type'] == 'aicmdsonstraint':
raise Exception('Invalid constraint data type! (' + self._data[constraint]['type'] + ')')
# Rebuild Constraint
print('REBUILDING - "' + constraint + '"...')
constraintNode = self.rebuildConstraint(constraint)
constraintList.append(constraintNode)
# Print Timer Result
buildTime = cmds.timerX(st=timer)
print(self.name() + ': Rebuild time "' + str(nodeList) + '": ' + str(buildTime))
# =================
# - Return Result -
# =================
return constraintList