[Closed] Put object names in a variabel
I am working with some animation scripts and need to make someting like group.
I want to have someting like this:
variabelname=(L_foot, H_foot, COM)
and if I take variabelname[1] then it will return L_foot.
I am new to script but someting like this I have seen in C++.
How to do this?
setobjects=#()
for i = 1 to selection.count do
(
setobjects[i] = selection[i]
)
How can I select now setobjects[1]
I get now:
$Editable_Spline:man_footRCTRL @[-3.691000,4.678302,1.408482]
Originally posted by Peder
setobjects=#()
for i = 1 to selection.count do
(
setobjects[i] = selection[i]
)
this does the same but as a one-liner:
setobjects = for i in selection collect i
How can I select now setobjects[1]
I get now:
$Editable_Spline:man_footRCTRL @[-3.691000,4.678302,1.408482]
to select the first object in the array, you could say:
select setobjects[1]
The two examples posted above assume that you have your objects selected. If your objects are consistently named, you can hard code them into the script like so.
NodeName=#( $‘Box01’, $‘Box02’, $‘Box03’ ) – Name of the object between the ’ ‘s
select NodeName[2] – will select Box02.
You do not need to have an object selected to do most maxscript functions. Simply doing I function to the object by name will produce the desired results.
rotate NodeName[1] (angleaxis 45 [0,0,1])
Will Rotate Box01 45 degrees.
Watch the maxListener window for commands that you may want to script. [ Bottom, left part of screen, right click to expand it! ]
Good Luck
Keith Morrison
hi, this is my first post here in the forums… i hope somebody cud help me with…
how do i collect objects in array by names using an edittext?
i did this…
foo = for obj in $text* collect obj
or
foo = “$” + text + “*”
execute foo
the first one isnt working… but the second one gives me “$foo*”…
what i wanted to do is have an edittext box, where i cud enter the name of all the objects that goes by it, so that i cud alter thier properties at the same time.
Your Close!!
foo = $‘text*’
Will assign foo with an Array of all objects with “text” as the first four letters in their name.
to do dynamically…
(
Global ObjArray = #()
ObjName = “Box”
ExecString = ( “ObjArray = $’”+ ObjName + “’”)
execute ExecString
)
Actually, it’s better to use getNodeByName instead of execute (which really slows down your script when used in a loop).
ObjName = “Box”
getNodeByName ObjName
from the 3dsmax7 online reference:
getNodeByName <string> exact:<bool> ignoreCase:<bool> all:<bool>
Returns first node with the specified name. If exact is false (default), the normal MAXScript node name comparisons are performed.
NEW in 3ds max 7:
ignoreCase specifies whether the comparisons should be case sensitive or not. When set to true, non-case-sensitive comparison will be performed.
If all is true, an array of nodes with the specified name is returned.
Default is exact:false ignoreCase:true all:false
- Martijn