headsUpDisplay Query


#1

I want to get all data like FaceCount by querying headsUpDisplay:

import maya.mel as ML
ML.eval('TogglePolyCount')
print (MC.headsUpDisplay('HUDPolyCountFaces',q=True,sr=True))

but problem is that data works and will be updated only if HUD is visible. Is there any method to get updated data when HUD is off?


#2

Any reason you want to query the HUD instead of getting total poly face count through other means?

Here’s a super simple way of doing so with PyMEL

import pymel.core as pm

sel = pm.ls(g=1) # get all scene geometry

totalFaces = sum([len(x.f) for x in sel]) # find sum of all scene geometry face counts

print totalFaces

#3

this code doesn’t work for me:


# Error: line 1: AttributeError: file F:\Program Files\Autodesk\Maya2014\Python\lib\site-packages\pymel\core
odetypes.py line 332: nt.NurbsSurface(u'nurbsPlaneShape1') has no attribute or method named 'f' 

# 

#4

Ah I didn’t account for NURBS.

Here’s the modified code that will work if there are NURBS geometries in the scene:

import pymel.core as pm

sel = pm.ls(typ='mesh') # get all scene polygon meshes

totalFaces = sum([len(x.f) for x in sel]) # find sum of all scene mesh face counts

print totalFaces

#5

I got this for first execute:



# pymel.internal.factories : MFnDagNode.model is deprecated # 
# pymel.core : Updating pymel with pre-loaded plugins: DirectConnect, mayaHIK, AbcImport, tiffFloatReader, VectorRender, gpuCache, rotateHelper, Substance, MayaMuscle, AutodeskPacketFile, autoLoader, fbxmaya, matrixNodes, ik2Bsolver, modelingToolkit, OpenEXRLoader, ikSpringSolver, Mayatomr, AbcExport, ArubaTessellator, quatNodes, mayaCharacterization, OneClick, retargeterNodes, sceneAssembly # 
# Warning: pymel.internal.factories : could not create a PyNode for manipulator type nexManip #