Forum Groups
  All forums
    Help & Feedback
      Questions
      Work in progress
      Finished Art
      Non-Max related
    Community
      Offtopic
      News
    Hardware
    Photography



Maxunderground news unavailable

 
First page  Go to the previous page   [01]  [02]  Go to the next page  Last page
 
Sort objects by triangle count?
show user profile  Dave
I'm not really sure how this would work. I guess what I'm looking for is perhaps some kind of "Select densest mesh in the scene"

Is this even possible? I've done a bit of googling and sat staring at Max, scratching my chin... but nothing's come up!

"I flew over Egypt once"

read 442 times
11/26/2014 2:54:56 PM (last edit: 11/26/2014 2:54:56 PM)
show user profile  reeves1984
I don't see why you couldn't do it through scripting

Loop through all objects that are meshes, get their point or poly count, store each one, then compare


--
Simon Reeves


www.simonreeves.com - VFX Artist & Blog
twitter


www.analogstudio.co.uk <-- I work here

read 429 times
11/26/2014 3:40:13 PM (last edit: 11/26/2014 3:40:13 PM)
show user profile  reeves1984
http://forums.cgsociety.org/showthread.php?t=839686


--
Simon Reeves


www.simonreeves.com - VFX Artist & Blog
twitter


www.analogstudio.co.uk <-- I work here

read 427 times
11/26/2014 3:41:04 PM (last edit: 11/26/2014 3:41:04 PM)
show user profile  Nik Clark
Easily scriptable.

I wrote a script that colors meshes from blue to red, where the more verts, the redder the object, for easily identifying heavy objects. I can't find it now though. Will have a look later. It sorted all objects in scene by mesh density.



Click here to send me an emailClick here to visit my websiteClick here to visit my photo gallery on Flickr

read 422 times
11/26/2014 3:46:45 PM (last edit: 11/26/2014 3:46:45 PM)
show user profile  Dave
Ah cheers folks.

I might have to dust off whatever part of my brain has written scripts in the past and get to it then.

"I flew over Egypt once"

read 418 times
11/26/2014 3:52:03 PM (last edit: 11/26/2014 3:52:03 PM)
show user profile  Nik Clark
max select all
mySel = #()
mySel = selection as array

fn mySort objectOne objectTwo =
(
case of
(
((getPolygonCount objectOne)[1] < (getPolygonCount objectTwo)[1]): -1
((getPolygonCount objectOne)[1] > (getPolygonCount objectTwo)[1]): 1
default: 0
)
)

qsort mySel mySort



This should sort objects into an array "mySel" which contains the objects in order of number of polygons

EDIT: It presumes everything is not grouped and is a valid mesh.


Click here to send me an emailClick here to visit my websiteClick here to visit my photo gallery on Flickr

read 400 times
11/26/2014 5:31:36 PM (last edit: 11/26/2014 5:45:42 PM)
show user profile  Dave
Much appreciated Nick,

That's likely ringing on the doorbell in terms of what I need, but I'm not smart enough to work out how to open the door!

I tried the script on 790 objects, and unfortunately the list just ended with a "...)" I guess to imply that there are more results... but I don't know what they are.

Bearing in mind, I'm checking the readings in the listener, which might not be the right thing to do. The first result seems to be the lowest poly mesh in the selection.

It's like you've given me all the info I need to be able to write my own script that selects the densest mesh in the scene, but I'm just sat here banging rocks together.



"I flew over Egypt once"

read 390 times
11/26/2014 5:48:59 PM (last edit: 11/26/2014 5:48:59 PM)
show user profile  Garp
Arh, Nik! What do I do with my code now?
Ah, well. I'll post it blank.




read 384 times
11/26/2014 6:00:35 PM (last edit: 11/26/2014 6:06:21 PM)
show user profile  Nik Clark
No worries mate. Just add the following line to the end of the script, and it should select the highest poly object in the scene.


select mysel[mysel.count]

EDIT: Here comes Garp to make my code look stupid and clumsy yet again! :o)



Click here to send me an emailClick here to visit my websiteClick here to visit my photo gallery on Flickr

read 381 times
11/26/2014 6:04:02 PM (last edit: 11/26/2014 6:04:50 PM)
show user profile  Garp
> Here comes Garp to make my code look stupid and clumsy yet again!

See? Exactly what I meant. Now I look bad :\




read 377 times
11/26/2014 6:08:49 PM (last edit: 11/26/2014 6:08:49 PM)
show user profile  Dave
God damn, you guys are wizards. Thank you so much!

"I flew over Egypt once"

read 371 times
11/26/2014 6:15:47 PM (last edit: 11/26/2014 6:15:47 PM)
show user profile  Nik Clark
I am but a level 2 apprentice with access to the help files.
Garp is a level 16 Mage with a +8 wand of coding.



Click here to send me an emailClick here to visit my websiteClick here to visit my photo gallery on Flickr

read 359 times
11/26/2014 7:34:53 PM (last edit: 11/26/2014 7:34:53 PM)
show user profile  Dave
I'm the kid who's eating sand after I pee on it.

"I flew over Egypt once"

read 349 times
11/26/2014 7:58:35 PM (last edit: 11/26/2014 7:58:35 PM)
show user profile  Garp
I assure you my wand's got nothing to do with it.




read 348 times
11/26/2014 8:00:20 PM (last edit: 11/26/2014 8:00:20 PM)
show user profile  Dave
I'll actually end up using both your codes.

I noticed that Garps uber code didn't care if things were in hidden layers or anything, it just ran through everything, I changed that to be selection based, and kept your (Nik) script in as "view based"

Here it is in a nice little UI if anyone ever googles this shit and needs it: (I would do the magic MF code box but I've even forgotten how to do that... christ)

rollout SelectDense "Dense Mesh"

(
group "Selection Based"
(
button Sel_Butt "Find It!" width:45 height:24 align:#center
tooltip:"Find densest based on selection"
)

group "View Based"
(
button View_Butt "Find It!" width:45 height:24 align:#center
tooltip:"Find densest based on what's visible."
)

on Sel_Butt pressed do
if selection.count <= 1 then
return messagebox "You haven't made a selection."
else
(
meshes = for obj in selection where isProperty obj.mesh #numFaces collect obj
fn max_tricount m1 m2 = m2.mesh.numFaces - m1.mesh.numFaces
qsort meshes max_tricount

for obj in meshes do format "(%)%\n" obj.mesh.numFaces obj.name
select meshes[1]
)

on View_Butt pressed do
(
max select all
if selection.count <= 1 then
return messagebox "There are no objects here"

else
mySel = #()
mySel = selection as array

fn mySort objectOne objectTwo =
(
case of
(
((getPolygonCount objectOne)[1] < (getPolygonCount objectTwo)[1]): -1
((getPolygonCount objectOne)[1] > (getPolygonCount objectTwo)[1]): 1
default: 0
)
)

qsort mySel mySort
select mysel[mysel.count]
)

)
createDialog SelectDense

Edit
And thanks again, my job just got 3% easier.

"I flew over Egypt once"

read 338 times
11/26/2014 9:26:24 PM (last edit: 11/26/2014 9:29:31 PM)
 
First page  Go to the previous page   [01]  [02]  Go to the next page  Last page
 
#Maxforums IRC
Open chat window


Support Maxforums.org