Open/Close Group Toggle

a shortcut with this function would be very usefull for me!


Comment viewing options

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

I thought It was easier! so I

I thought It was easier!
so I will use simply 3 shortkeys
ctrl + g ---> group selected
shift + g ---> open group
alt + g ---> close group

Anubis's picture

here is some sketch...

...but my advice is to not use that code.

macroScript mcrOpenGroupToggle 
	category:"Tools" internalCategory:"Tools" 
	tooltip:"Open Group Toggle" buttontext:"Group Toggle" 
	on isEnabled return selection.count > 0
	on execute do
		if selection.count == 1 then
			if isOpenGroupHead selection[1] do
				setGroupOpen selection[1] false
		else -- multiple selected
			-- s'd find most top group head
			selParent = selection.parent
			topObjs = for obj in selection where \
				obj.parent == selParent and \
				isGroupHead obj collect obj
			if topObjs.count == 1 and Not isOpenGroupHead topObjs[1] do
				setGroupOpen topObjs[1] true

OK, here end the easy part, even above is not very safety. And closing group by selected member is a bit complicated.

What about if selected is closed group and is a part of other currently open group? The script will open selected group or will close its parent group?

If you like to close by member, more easy and safety (take care to not leave sub-groups open) w'd be if navigate (its easy) in the hierarchy using existing hotkeys:

PageUp (select ancesor)
PageDown (select child)

And once you select your group head
is easy to close it.

As for the Open/Close commands,
you can set hotkeys for both, see here:

my recent MAXScripts RSS (archive here)

harumscarum's picture


it is very annoying when if open the group objects are deselected.
not sure about open/close toggle, but we definitely need script to open group and keep objects selected

and here is two scripts which i use instead standard ones:

1. to group (no annoying naming dialog and pivot centered at the bottom of group)

on isenabled return selection.count>1
on execute do (
local grname=selection[1].name
local grhead
if selection.count >1 do group selection name:(grname + "_01")
select $(grname + "_01")
for i in selection where (isgrouphead i) do
i.pivot = [($.max.x+$.min.x)/2, ($.max.y+$.min.y)/2, $.min.z]

2. to close all groups (no need to select)

(for o in objects do if isGroupHead o and isOpenGroupHead o then setGroupOpen o false)

harumscarum's picture

is it possible?

so you need close last opened group by toggle? but if you need to open another group, while any already opened, it will be impossible.

tafkaandre's picture

I mean this: I' have a group

I mean this:
I' have a group closed. Select it, press my shortkey, and It's opened.
I' have a group opened. I select one object in the group, or the group, press my shortkey, and It's closed.

So, If I select a group or an object in a group, and I press my shortkey, the behavior, is to close if group is open. and open if the group is closed.

le1setreter's picture

how about subgroups? they

how about subgroups? they also should open/close?

Comment viewing options

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