Max Scripting : How can we find number of polygons of an object and save it in a variable?

StackOverflow https://stackoverflow.com/questions/23177256

  •  06-07-2023
  •  | 
  •  

سؤال

Max Scripting : I am creating a script as a beginner, in which I need to calculate number of polygons of any selected object! How can we find it for an object and save it in a variable?

هل كانت مفيدة؟

المحلول

Only editablemesh and editablepoly objects can be queried for number of faces. Assuming obj is your objects:

local numFaces = getNumFaces obj

or

local numFaces = obj.numFaces

If obj is a different object which can be evaluated to an editableMesh or editablePoly, you can use the .mesh property of the object:

local m = obj.mesh
local numFaces = m.numFaces
free m

edit:

There is actually:

getPolygonCount <obj>

which works on all objects regardless of their class.

نصائح أخرى

If you want the number of triangles. use this:

getPolygonCount <node>

If you need the number of polygons in a poly object, you should use the polyop method, but bBeware it counts dead faces as well, so it's a good idea to clean-up the poly before-hand by collapsing the dead stuff:

polyop.CollapseDeadStructs <poly>
polyop.getNumFaces <poly>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top