The .mesh command
So you are working with objects from dozens of artists, some using Editable Poly and some using Editable Mesh, and you need to perform data collection on them.
GetNumfaces will return the polycount of an object, but it returns a tri count for emesh objects and a n-gon count for epoly objects. The tri count is the one we are generally more interested in knowing.
There are 2 methods that people seem to use for getting the tri count:
- Create a virtual copy of the object as an editable mesh. This one is the most common.
- Access the underlying mesh using the .mesh command. I had been writing script for years before I discovered this.
If you create a box that is 2x2x2 you can see how this works. I called the box epolyobj and then cloned it to an editable mesh that I called emeshobj. Let’s run some commands on those items.
getnumfaces $emeshobj -- gives a tri count on the mesh object
getnumfaces $epolyobj -- gives an n-gon count on the poly object
getnumfaces $epolyobj.mesh -- gives a tri count on the poly object
virtualmesh = snapshotAsMesh $epolyobj -- clone the poly object in memory as a mesh object
getnumfaces virtualmesh -- gives a tri count on the virtual poly object (that we've made into a mesh)
This can only be used to read data from the mesh and do selections, it can’t be used to write data (like vertex colours) to the mesh.
Oh, and it seems that querying (epolyobj.mesh) is much slower than querying (copy epolyobj.mesh).