ScriptSpot

Forum topic · General Scripting

Open All groups (and sub-groups)

By caebrasil · 2011-01-26

Description

Hi everybody!

I need to create a script to simplify my work. I need to open all groups in the scene, but it means all sub-groups too (groups inside antoher group). Something like a loop in the command "Select All" and "Group Open", until open all groups, that's what I'm doing manually.
To close is simple, one time command, but to open...
I don't know script, my only experience are recording actions and create scripts with it. Very, very, very basic...

Can anyone help me?

Regards,

Caetano Brasil

Comments (11)

open - modify internal object than close

pfbelesa · 2016-02-24

Hi i have a problem that maybe this open/close groups can help me.
I got a VERY big set of groups of wide flange shapes with extrusion on my scene, all of them grouped together in groups of 4 to 12 wide flanges, but because my camera is VERY far from those objects they got invisible on the final render so i need to forcely change their sizes.

how could i add to this script a funcion or action to open all groups and set new size to all wide flange shapes?

thanks in advance

barigazy · 2016-02-24

You not need to open all groups to change Extrude modifier value.
Select all objects ei. groups where want to change extrude mod amout and run this code.

fn changeExtrudeValue value:0 = if selection.count > 0 do
(
modifier = #()
for o in selection where canConvertTo o Editable_mesh and o.modifiers.count > 0 do
(
join modifier (getClassInstances Extrude target:o)
)
if (modifier = makeUniqueArray modifier).count > 0 do for m in modifier do m.amount = value
)
-- change only value number below
changeExtrudeValue value:20

ungroupAll

barigazy · 2013-04-02

To ungroup all scene groups here is a little snippet

groups = for o in helpers where isGroupHead o collect o
while groups.count > 0 do
(
ungroup groups[groups.count] ; groups.count = groups.count-1
)

hello all,

crystal3d · 2011-11-24

i did also benefit from this script and i like it, just that it opens the hidden groups aswell.

is it simple to convert it to "operate only on selected groups"?

Hi,

caebrasil · 2011-01-26

Sorry for my poor English, maybe I don't explained very well: I don't want to ungroup, just open groups, in all levels (groups inside another groups). But I need to maintain my actual group structure.

@Swordslayer, when I create a script with your command, I receive a error message:

 -- Error occurred in anonymous codeblock; filename: S:\3DSMAX\- BASE\usermacros\Open ALL Groups.mcr; position: 104; line: 6

>> MAXScript MacroScript Compile - S:\3DSMAX\- BASE\usermacros\Open ALL Groups.mcr, offset 104; Exception: -- Syntax error: at function, expected (

--  In line: fn u <<

Problably I'm doing something wrong creating the script?

@Anubis, thank you! But, as I say, I can't lost my groups structure...

Thank you very much for your attention, guys!

Swordslayer · 2011-01-26

Okay, just make a new script, copy-paste what I first sent there, change "setGroupOpen o false" to "setGroupOpen o true" and either comment out or delete the line "ungroup o". Hit CTRL+E. Then it should work.

caebrasil · 2011-01-26

PERFECT!

Thank you!

Here is the simple function...

duckylock · 2013-03-12

Here is a simple function to do what you need.

Voici une fonction simple pour faire ce que tu veux.


--create function named openGroups with a parameter (objects to check)
function openGroups mySelection = 
(
	--loop into selected object
	for obj = mySelection do
	(
		--to find group end open it
		if isGroupHead obj then setGroupOpen obj true
	)
)
--run this function with the current selection as parameter
openGroups $selection

or just with one command

Anubis · 2011-01-26

explodeGroup objects

Swordslayer · 2011-01-26

This should do the trick:

fn ungroupAll objs =
(
	group_arr = for o in objs where isValidNode o AND isGroupHead o collect o

	with redraw off
	(
		for o in group_arr do
		(
			setGroupOpen o false
			ungroup o
		)
	)
)

ungroupAll objects