CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 06-08-2003, 05:59 PM   #1
Peder
New Member
 
Join Date: Sep 2002
Posts: 12
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?
 
Old 06-08-2003, 07:27 PM   #2
Peder
New Member
 
Join Date: Sep 2002
Posts: 12
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]

Last edited by Peder : 06-08-2003 at 08:18 PM.
 
Old 06-08-2003, 10:17 PM   #3
magicm
Maxscript Generator
 
magicm's Avatar
CGSociety Member
portfolio
Martijn van Herk
VFX Technical Director
Freelance
Rotterdam, Netherlands
 
Join Date: Jun 2002
Posts: 1,139
Quote:
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

Quote:
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]
 
Old 06-09-2003, 04:01 PM   #4
Kramsurfer
Don't Know-it-All.
 
Kramsurfer's Avatar
portfolio
Keith R Morrison
Custom Tools Developer
Focus360
San Diego, USA
 
Join Date: Sep 2002
Posts: 426
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
 
Old 11-02-2004, 08:14 AM   #5
galagast
Forlorn Battle Acolyte
 
galagast's Avatar
Jeff Lim
Philippines
 
Join Date: Oct 2004
Posts: 572
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.
 
Old 11-02-2004, 06:30 PM   #6
Kramsurfer
Don't Know-it-All.
 
Kramsurfer's Avatar
portfolio
Keith R Morrison
Custom Tools Developer
Focus360
San Diego, USA
 
Join Date: Sep 2002
Posts: 426
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
)
 
Old 11-02-2004, 06:46 PM   #7
galagast
Forlorn Battle Acolyte
 
galagast's Avatar
Jeff Lim
Philippines
 
Join Date: Oct 2004
Posts: 572
ok! thnx! dat was an approach that never occured to me. Cool!
 
Old 11-04-2004, 05:03 PM   #8
magicm
Maxscript Generator
 
magicm's Avatar
CGSociety Member
portfolio
Martijn van Herk
VFX Technical Director
Freelance
Rotterdam, Netherlands
 
Join Date: Jun 2002
Posts: 1,139
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:

Quote:
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
 
Old 01-15-2006, 09:00 AM   #9
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 06:21 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.