PDA

View Full Version : Put object names in a variabel


Peder
06-08-2003, 05:59 PM
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?

Peder
06-08-2003, 07:27 PM
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]

magicm
06-08-2003, 10:17 PM
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]

Kramsurfer
06-09-2003, 04:01 PM
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

galagast
11-02-2004, 07:14 AM
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.

Kramsurfer
11-02-2004, 05:30 PM
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
)

galagast
11-02-2004, 05:46 PM
ok! thnx! dat was an approach that never occured to me. Cool! :thumbsup:

magicm
11-04-2004, 04:03 PM
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

CGTalk Moderation
01-15-2006, 08:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.