help with script

In part of my script I am trying to find all the groups in the scene.

So as a novice I've tried this.
I open up the max file and pick one of the groups I have
In the listener I type in the following

classof $
ObjectSet --get back this

I then try this but it doesn't seem to work.
I'm looking for a list of names I can populate a dropdown list

sceneGroups = for obj in geometry
where classof obj == ObjectSet
collect obj
#() --get back this

sceneGroups.count
0 --get back this

I have been through the Maxscript reference but can't find the proper syntax.
any ideas?
thanks Lowell

Comments

Comment viewing options

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

Ok, something like this?

Ok, something like this? Anubis, do you have a nicer way to do this?? :D

try(destroyDialog GroupSelector)catch()
 
rollout GroupSelector "Lazy Group Selector"
(
	button btn_UpdateGroups "Update" Width:150 height:25 align:#center
	group "Select Group:"
		(
			dropdownlist DD_Group "" items:#()
		)
 
	local allObj = #()
	local Groups_Array = #()
 
	fn Update_Groups =
         (
			allObj = objects -- as array
			Groups_Array = for i in allObj where (isGroupHead i and isValidNode i) collect i -- as string
			DD_Group.items = for i in allObj where (isGroupHead i and isValidNode i) collect i.name -- as string
        )
 
	on GroupSelector open do Update_Groups()
	on DD_Group selected i do select Groups_Array[i]
	on btn_UpdateGroups pressed do Update_Groups()
 )
 
createDialog GroupSelector

/ Raymond

lucky_lowell's picture

to continue...

I added this line to create a copy of the selection

maxOps.cloneNodes (getNodeByName DD_Group.selected) cloneType:#copy newNodes:&nnl

I get a copy of the group incremented by one digit.

Now I would like to rename it. but again the syntax eludes me.

this is killing me..
I thought I would try this... but its no good.
theCopy = maxOps.cloneNodes (getNodeByName DD_Group.selected) cloneType:#copy newNodes:&nnl

theCopy.name = "new_name"

thanks for your help

Anubis's picture

renaming...

Renaming objects is a large subject (with "many faces", you know ;) ), so better open new thread and describe there in details what exactly your renaming would like.

my recent MAXScripts RSS (archive here)

Anubis's picture

RE: Anubis, do you have a nicer way to do this?? :D

Hey, you did it well ;) If you ask for tips... I think that storing all objects not necessary, and as you loop in objects collection - you can omit isValidNode as well.

local Groups_Array = #()
 
fn Update_Groups =
(
	Groups_Array = for o in objects where isGroupHead o collect o
	DD_Group.items = for o in Groups_Array collect o.name
)

my recent MAXScripts RSS (archive here)

tassel's picture

Ahh.. Thank you for the

Ahh.. Thank you for the information Anubis :)

/ Raymond

tassel's picture

Something like this?select

Something like this?

select (for o in selection where isValidNode o AND isGroupHead o collect o)

EDIT: Ahh.. Sorry, Did not read your post properly the first time

Here is an Example:

rollout Dropdownlist "Choose Group"
(
dropDownList dl_Dropdownlist "Choose Group" items:(for i in selection where (isGroupHead i) collect i.name as string)
)
 
createdialog Dropdownlist witdh:220

Just change for i in selection with for i in objects if you want it to select all objects in scene.

/ Raymond

lucky_lowell's picture

Ray,Sweet website. Thanks

Ray,
Sweet website. Thanks for replying. The behavior I'm getting is close but not complete. I only get an item in this drop down list if its preselected. Otherwise nothing.
thanks
Lowell

I changed the line from selection to objects and it works fine thanks again.

rollout Dropdownlist "Choose Group"
(
dropDownList dl_Dropdownlist "Choose Group" items:(for i in objects where (isGroupHead i) collect i.name as string)
)

createdialog Dropdownlist witdh:220

Comment viewing options

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