Home Technical Talk

MAXSCRIPT - convert each selected group to one object

Rolls
null
Offline / Send Message
Rolls null
Hi,

is there an option to create a script which turns EACH of the SELECTED groups to one single object respectively (collapses the objects in each group to one object), and preserve materials (collected to multisubobject).

Thanks R .)

Replies

  • monster
    Options
    Offline / Send Message
    monster polycounter
    Not a lot of error checking here, but it seems to work.

    --SCRIPT THAT COMBINES BY GROUP
    (
    	fn combineSelection newName =
    	(
    		local Objs,firstObj
    
    		--GET THE SELECTION AS ARRAY
    		Objs = getcurrentSelection()
    
    		--DELETE THE REFERENCE TO THE FIRST ITEM OF THE SELECTED ARRAY
    		firstObj = convertToPoly(Objs[1])
    		firstObj.name = newName
    		deleteItem Objs 1
    
    		--ATTACH ALL OTHER ITEMS TO THE FIRST NODE.
    		for obj in objs where canConvertTo obj Editable_Poly do firstObj.attach obj firstObj
    	)
    	
    	--FIND THE GROUPS
    	groups = #()
    	for obj in objects do
    	(
    		if isGroupHead obj do append groups obj
    	)
    	
    	--EXPLODE AND ATTACH GROUPS
    	for g in groups do
    	(
    		gName = g.name
    		select g
    		explodeGroup g
    		combineSelection gName
    	)
    	
    )

  • Rolls
    Options
    Offline / Send Message
    Rolls null
    You are the man! :)
Sign In or Register to comment.