Convert Group to mesh

summary:
lets say; you have a tree object with all leaves as separate meshes , when attach them into one big heavy mesh at once, max crashes.

but i can attach them one by one which takes quite alot of time...

the script will divide the group of high level geometery into 3-10 meshes.

how long does it take to make a script like this one below?is it beginner level?

get selected group's name

explode group

rename the meshes inside , sequentially according to group name like: "groupname_01-02-03"

count polygon of each mesh.

attach small(number of polygon) meshes to "groupname_01" until
mesh reaches 1000 polygons.then

attach medium meshes untill mesh reaches 1000 polygons and name it:"groupname_M_01,02..."

rename large meshes that has more than 1000 polygons as "groupname_L_01,02,03.."

attach all created meshes in to one big mesh , named"groupname"

looking foward to any replies.

thanks.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
crystal3d's picture

Hi Anubis ; i copied and

Hi Anubis ;
i copied and pasted your script , i grouped 27 objects , selected the group01 and ran the script:

-unable to convert:undefined to type:

and highlights this string at 7:
"if (getPolygonCount allObjs[i])[1] <= 500 do ("

http://yfrog.com/j3test1grp2meshj (error screen)

Anubis's picture

Ok, I suspect so you have not

Ok, I suspect so you have not MaxScript knowledge. This is a snippet code that you need to modify for your needs. The error itself come from the "allObjs" that Max see as undefined. In this 1st step: allObjs = selection as array -- collect all to array you need to select your objects first and collect them to the array. If they are grouped, just ungroup before.

my recent MAXScripts RSS (archive here)

crystal3d's picture

yes indeed ;i am at scripting

yes indeed ;i am at scripting 0 , if "collect to array "means that i really have to create an array some how :) will try...

i hope just mean to explod the group+select the objects and run the script... which is my cup of tea.

Anubis's picture

Well, when my code will not

Well, when my code will not help alot :) My idea was to select all objects what need to be attached and organize them into arrays (by objects poly-count). But as you group as you dont need this organazing step. So, shortly, all what you need is to know the name of the object to wich you will attach. Lets to sey it is named "main"; [1] ungroup 1st group; [2] select ungrouped objects and [3] run this code line:
for i in selection do attach $main i
...and repeat steps 1-3 for all groups.

my recent MAXScripts RSS (archive here)

Anubis's picture

I hope this help allObjs =

I hope this help

allObjs = selection as array -- collect all to array
trgMesh = allObjs[1] -- mesh to attach to
deleteItem allObjs 1 -- remove it from the array
 
pass1 = #() -- array to store (for example) obj with poly's <= 500
for i=1 to allObjs.count do (
    if (getPolygonCount allObjs[i])[1] <= 500 do (
        append pass1 allObjs[i]
        deleteItem allObjs i
    )
)
 
pass2 = #() -- array to store (for example) obj with poly's <= 1000
for i=1 to allObjs.count do (
    if (getPolygonCount allObjs[i])[1] <= 1000 do (
        append pass2 allObjs[i]
        deleteItem allObjs i
    )
)
-- and so on...
 
for i in pass1 do attach trgMesh i -- attach process pass 1
for i in pass2 do attach trgMesh i -- attach process pass 2
-- and so on...

my recent MAXScripts RSS (archive here)

crystal3d's picture

for example it took 20

for example it took 20 minutes to attach a 500k faced furniture model into one mesh, i had to do it in 5 passes...
if i did it on one go! my system would hang , its 2 gbs xp64..

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.