Just started with MaxScript - pls some little help :)

Hi everyone!

I started to play around with MaxScript, because I want to do a timesaver for further projects. The endresult should be something like a Toolset for me and my working mates. So we can yous it to export and do some technical stuff which needs to be done correctly, nameconventions and stuff, with some simple MacroScripts.

so I started with a pretty simple thing:
I want to generate a group with a specific name when the function is called.
my problem is, that I always get a dialog to enter the name but I dont want this dialog but rename it with a given name.

this is my first attempt where the dialog pops up:

-- Group selected and Rename it
fn GROUP_NAME
(
	actionMan.executeAction 0 "40140" -- group selected
	clearSelection
	select $Group01
	$.name ="thename" -- "thename" is the name var
)

is that the correct attempt to this or is there an easier or more beautiful way to get this? e.g. a command with which you can group a selection and give it a name at once...

thx in advance, so long,
zumpi

Comments

Comment viewing options

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

Real08121985 already post

Real08121985 already post good reply. I will supplement only so yours first line in the function run popup dialog:

actionMan.executeAction 0 "40140"

And some trick. If your thename var is constant string, for example:

thename = "Object"

then you can use 'uniquename' definition like this:

group selection name:(uniquename thename)

Now your group renamed to "Object01". If this name already in use, will renamed to "Object02" and so on. This way you will avoid coincidence of the names.

regards, Anubis

my recent MAXScripts RSS (archive here)

real08121985's picture

Hey, MaxScript is very

Hey, MaxScript is very powerful. Right now you starting to learn MaxScript, but you also start to learn the usage of the MaxScript-Reference. It makes a lot things easier when you know where to find the answer of your question in this reference.

I open up the MaxScript-Reference and type at index "group".
There are some results and i click on result named "group()", this is the name of the grouping-function.

Now Max asks me if I would like to open "Node Common Properties ..." or "NodeCommonMethods_Group_Methods". I choose the second, cause it sounds good .. "Group" and "Method".

Now I am on the group-function-page of the MaxScript-Reference. On top you see the explanation how the function works:

group < node_collection > [ name:< string > ] [ prefix:< string > ] [ select:< boolean > ]

< > = you must use
[ ] = you can use

so based on this I know how to use the group-function. If I would like to group my selection and every group I create with my function should have the prefix "Group_" and I want to select the group after creation, then based on the reference I got this:

group selection name:"GroupedObjects" prefix:"Group_" select:true

Knowing how to use the MaxScript reference is very useful :)

Comment viewing options

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