Convert Group to mesh

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.



Comment viewing options

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

select what you want to

select what you want to combine and run the script ;)

Raphael 'Insanto' Steves

twoapple's picture

Break face material id

Hi dear raphael,
your code works like a charm but when I apply it to my objects with diffrent material id,material id break and all of the material are in 1.

tassel's picture

Nice one Graph :) An "max

Nice one Graph :)

An "max group ungroup" at the end is also nice ;)

Raymond H.Ingebretsen -

Graph's picture

tested this one with 2k

tested this one with 2k objects and max didnt crash, just froze a bit:
have phun

	max create mode
	with undo off
		local sel = for o in selection where superclassOf o == geometryClass collect o
		local meshO = sel[1]
		deleteItem sel (findItem sel meshO)
		convertToMesh meshO
		for o in sel do attach meshO o

Raphael 'Insanto' Steves

crystal3d's picture

Hey, this is partially working great!

Some problems though...

1)It does not give the group's name to the attached object

2) if i run it without a selection, it gives an error and stops,
the real problem is it stops after the command :" disableSceneRedraw()" so the viewpot stops untill i restart max,

can it just warn instead?

crystal3d's picture

hello and thanks for

hello and thanks for interest;

i copy pasted your script , and ran it but nothing happened?

as i stated before, i have no scripting experience

crystal3d's picture

i am still looking for a

i am still looking for a one-click solution :)

crystal3d's picture

this example script of yours

this example script of yours is "no-go" for non-scripters sadly.

atm i explode the group , select one and use attach list to sort by face count , attach them gradually...

Anubis's picture

Ok, you need to sort them by

Ok, you need to sort them by face count and then attach them gradually, and I'll try to help you, but is there a script for non-scripters?... So try this for illustration:

b = box() -- create a box
(getPolygonCount b)[1] --> 12
-- so? this return poly-count = (getPolygonCount b)[1] as string --> rename the box to "12"
-- now make an example array of strings (just for test):
a = #("13", "0", "-22", "7")
sort a --> #("-22", "0", "13", "7")

With this in mind I hope you catch my idea that is to (1) rename the objects (using their poly-count as names), (2) collect their names to array, (3) sort array, (4) attach. Lets try then, - after explode the group, select all its objects and run the script:

-- 1st rename them
for i in selection do ( = (getPolygonCount i)[1] as string)
a = for i in selection collect -- collect their names
sort a -- sort the array
select (getNodeByName a[1]) -- select first object
deleteItem a 1 -- remove it from the array (this not delete the node, just array item)
-- last step: attach
-- if in 1 loop will be:
for i in a do attach selection[1] (getNodeByName i)
-- and if is this to "hard", you can break the procedure, e.g.
for i=1 to 5 do ( -- this will attach only the first 5 objects
    attach selection[1] (getNodeByName a[i])
    deleteItem a i
) -- end of step 1
-- end so on...

my recent MAXScripts RSS (archive here)

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 (" (error screen)

Comment viewing options

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