Convert groups to single objects script

Hello all,

I typically import AutoCAD Geometry in 3DS Max. The AutoCAD DWG's consist of multiple AutoCAD Block. When I import them I check the convert blocks to groups under general options of the dialog box so I don't get a million pieces and can move stuff around with ease.

I wanted to know if there is a scrips that can covert multiple max groups to single objects?

I would greatly appreciate any assistance.




Comment viewing options

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

Allmost there!

So I almost have a working script! The only problem is when I have a group inside a group the script error out.

fn getGroupHead objArr = (
for grp in objArr where isGroupHead grp collect grp
fn getGroupMember objArr = (
for grp in objArr where isGroupMember grp collect grp

--Collect the Group Objects of the current selection
grpHeads = getGroupHead selection
--Find any nested Group Objects
grpHdMbr = getGroupMember grpHeads
--If there are nested groups then ungroup it
if grpHdMbr.count !=0 then (
unGrp = true
) else (
unGrp = false

fn detachGroups objArr unGrp = (
while unGrp do (
for cnt in 1 to objArr.count do (
grpHead = objArr[cnt].parent
if isGroupHead grpHead do (
deGrp = for val in (getGroupMember objArr[cnt].children) where not isGroupHead val collect val
append deGrp objArr[cnt]
setGroupOpen grpHead true
detachNodesFromGroup deGrp
objArr[cnt].parent = grpHead.parent
setGroupOpen grpHead false
objArr = getGroupMember grpHeads
if objArr.count !=0 then (
unGrp = true
) else (
unGrp = false

detachGroups grpHdMbr true
--Switch to Collapse Utility
UtilityPanel.OpenUtility collapse
--Get the HWND for the Collapse Utility and Buttons
HWNDCollapse = windows.getChildHWND #max "Collapse Selected"
HWNDbtn = windows.getChildrenHWND HWNDCollapse[2]

fn getBtnHWND hwnd btnStr = (
try ((for btn in hwnd where btn[5] == btnStr collect btn)[1][1]) catch ()

-- Get the HWND for the specific Collapse Buttons
BTN_CollapseSelected = getBtnHWND HWNDbtn "Collapse Selected"
BTN_Mesh = getBtnHWND HWNDbtn "Mesh"
BTN_SingleObject = getBtnHWND HWNDbtn "Single Object"
--Set the Collapse Utility to Mesh
UIAccessor.PressButton BTN_Mesh
--Set the Collapse Utility to Single Object
UIAccessor.PressButton BTN_SingleObject

for obj in grpHeads do (
select obj
--Collapse the Groups to Mesh, NOTE: Nested groups will be collapsed to a single mesh
UIAccessor.PressButton BTN_CollapseSelected
-- ungroup any remaining groups that hold the collapsed meshes
if isvalidNode obj do ungroup obj

Anubis's picture

try this one

explodeGroup (for obj in helpers where isGroupHead obj and not isGroupMember obj collect obj)

my recent MAXScripts RSS (archive here)

eyepiz's picture

It explodes the group but

It explodes the group but does not attached all the objects.

barigazy's picture

are you try with Utility >

are you try with Command Panel > Utility > Collaps?


eyepiz's picture

I tried it...Works if I

I tried it...Works if I select one group at a time...I would be nice if I select multiple groups and collapse to multiple singe objects.

Maybe a script could do it.

Thanks fir the help.


Comment viewing options

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