Notifications
Clear all

[Closed] Select by Polycount

Does anyone know of a method for selecting objects based on their polycount?
For example can I select all objects that are under 500?

6 Replies

Hi Alexander,

you could try this:


 --select all objects with a polycount smaller than 500
--convert objects to EPoly first
   
   	myArray = #()
   	for o in selection do 
   	(
   		myPolyCount = polyop.getNumFaces o
   		if (myPolyCount<500) then append myArray o
   	)
   	select myArray

Michael


http://michaelkiss.wordpress.com/

Hi,

You can also use getPolygonCount &lt;node&gt; function - so you don't have to convert nodes to EPoly:

    fn selectByPolygonCount  arrayOfNodes numFaceFrom numFaceTo = ( 
    	
    --clear selection
    clearSelection()
    		 
    --loop through array of nodes
    for obj in arrayOfNodes do
    (
       tmpArr = getPolygonCount obj
       numFaces = tmpArr[1]
       if  numFaces >= numFaceFrom and numFaces <= numFaceTo do selectMore obj
    )
   
   )	
    
(I attached working script with ui)

regards

jk
 JHN

getPolygonCount returns tri’s so it won’t count the quads, create a box and do getPolygonCount $ it returns 12 (6×2 tri’s). It won’t be helpfull for all situations.

-Johan

Definitely right Johan. I wonder if there’s better way to get exactly quads –

( 1. convert object to EPoly )
2. loop through all faces
3. check if face is quad and count it

jk

 JHN

I think first Alexander has to decide if he want’s to know what type of poly he needs. tri’s or quads or whatever n-sided poly.

-Johan

Thank you very much jkwiatkowski and michaelkiss!
JK’s script seems to only retrieve quads. However that is on a clean and fresh mesh.
If I have an object which is triangulated then it seems to count the tris which makes a pretty good chunk of sense to me.

In my specific use case it is irrelevant whether it is tris or quads as the difference between the objects I want selected and the objects I don’t range from 10,000 to 100,000 quads/tris.
Unless I miss a zero both posted scripts work quite nicely for me.

So thanks again.