Problem I’m solving
I want to ungroup all or ungroup all in selection via scripting
Solution
I know all these can be done without scripting. This is actually part of a model conversion script, so, if you’re interested to do this via scripting, this is the snippet!
Installation
- Simply just drag the script to the viewport to install.
- Right-click on the toolbar > Customize…
- Choose the tab ‘Toolbars’
- In the Category: dropdown, select ‘ManniiCode’
- Drag the script to the toolbar where ever you want!
Code
Maxscript
- Macroscript – Ungroup All (For drag and drop installation)
macroscript UngroupAllObjects
Category:"ManniiCode"
toolTip:"Ungroup All Objects"
(
fn UngroupAll objs toggle= (
group_arr = for o in objs where isValidNode o AND isGroupHead o collect o
with redraw off (
for o in group_arr do (
try (explodeGroup o) catch()
-- ungroup o
) -- end for
)-- end redraw
) -- end fn
UngroupAll objects true
)
- Macroscript – Ungroup Selection (For drag and drop installation)
macroscript UngroupAllObjects
Category:"ManniiCode"
toolTip:"Ungroup All Objects"
(
fn UngroupAll objs toggle= (
group_arr = for o in objs where isValidNode o AND isGroupHead o collect o
with redraw off (
for o in group_arr do (
try (explodeGroup o) catch()
-- ungroup o
) -- end for
)-- end redraw
) -- end fn
UngroupAll (getCurrentSelection()) true
)
- Snippet – Ungroup All (for using as code)
fn UngroupAll objs toggle= (
group_arr = for o in objs where isValidNode o AND isGroupHead o collect o
with redraw off (
for o in group_arr do (
try (explodeGroup o) catch()
-- ungroup o
) -- end for
)-- end redraw
) -- end fn
UngroupAll objects true
- Snippet – Ungroup Selection (for using as code)
fn UngroupAll objs toggle= (
group_arr = for o in objs where isValidNode o AND isGroupHead o collect o
with redraw off (
for o in group_arr do (
try (explodeGroup o) catch()
-- ungroup o
) -- end for
)-- end redraw
) -- end fn
UngroupAll objects true
