Skip to content

Instantly share code, notes, and snippets.

@Roumenov
Last active August 10, 2019 08:59
Show Gist options
  • Save Roumenov/3cdf69110165e4cecc337418fc2dc83e to your computer and use it in GitHub Desktop.
Save Roumenov/3cdf69110165e4cecc337418fc2dc83e to your computer and use it in GitHub Desktop.
need to sort meshes relative to each other by various parameters.
import pymel.core as pm
import maya.mel as mel
def mesh_density_calc(mesh, operation = 'density'):
#TODO: add line ot save existing selection and reselect at the end
pm.select(mesh)
if operation == 'volume':
return mel.eval('computePolysetVolume ')
elif operation == 'polycount':
mesh_polycount = pm.polyEvaluate(f=1)#could also use this to get area and modulate specular against area/density
return (mesh_polycount)
elif operation == 'density':
mesh_volume = mel.eval('computePolysetVolume ')
mesh_polycount = pm.polyEvaluate(f=1)
return (mesh_volume/mesh_polycount)
else:
warning('invalid operation parameter')
#print("=================")
#print('Mesh has a volume of %s, with a polycount of %s, for a density value of %s') %(mesh_volume, mesh_polycount, mesh_density)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment