CGTalk > Software > Autodesk 3ds max
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 01-31-2013, 10:49 PM   #1
Mambo4
not a jedi yet
 
Mambo4's Avatar
portfolio
Logan Bender
Game Technical Artist
Greater Seattle, USA
 
Join Date: Nov 2010
Posts: 432
Storing objects / arrays of objects in custom attributes

i am setting up an ik/fk switcher using max script

I want to show/hide groups of ctrls depending on the mode.

I can do this with arrays easily.

inside my custom attribute definition rollout block,
I have code like:

Code:
--define an array of max objects fk_ctrls=#($fk_upper_arm,$fk_lowerArm,$fk_hand) ... --hide the array fn hide_fk =( fk_ctrls.hidden=true )


but this is very object specific.
I want to build a generic fk/ik setup tool
that uses variables (attributes i guess) to hold these objects
so i can simply pick the objects involved and run the script to set the system up.

like :

Code:
--assign max objects to a set of vars fk_upper_arm= $ctrl_fk_r_arm_a fk_lower_arm= $ctrl_fk_r_arm_b fk_hand= $ctrl_fk_r_arm_c ... --and in the rollout block ... --define the array using vars instead of objects fk_ctrls=#(fk_upper_arm,fk_lowerArm,fk_hand) ... --hide the array fn hide_fk =( fk_ctrls.hidden=true )


What is the best way to store the variable assignments with the custom attribute?
 
Old 01-31-2013, 11:19 PM   #2
PEN
R&D/Technical Director
 
PEN's Avatar
portfolio
Paul Neale
PEN Productions
Canada
 
Join Date: Jun 2002
Posts: 7,416
Create a param block that is type:#maxObjectTab and use a nodeTransformMonitor to store references to the nodes and place them in the maxObjectTab. This will make sure that circular references are not created. You can also use #nodeTab and just propulate it with nodes how ever you could run into issues with circular references.
__________________
Paul Neale
http://paulneale.com
 
Old 02-01-2013, 12:37 AM   #3
Mambo4
not a jedi yet
 
Mambo4's Avatar
portfolio
Logan Bender
Game Technical Artist
Greater Seattle, USA
 
Join Date: Nov 2010
Posts: 432
I take it this is the method outlined in your tutorial
thanks, I suspected as much.
I'll have to put my brain on it.
 
Old 02-01-2013, 05:52 PM   #4
Mambo4
not a jedi yet
 
Mambo4's Avatar
portfolio
Logan Bender
Game Technical Artist
Greater Seattle, USA
 
Join Date: Nov 2010
Posts: 432
OK I've gone through the tutorial example at your site and have begun adapting to my needs.
I was hoping I could store these as some kind of dictionary of key:value pairs.

but it looks like I will just have to store an array of all the objects, and assign by index to local vars inside the rollout block...

Code:
ikfk_ca = attributes ikfk_attribs ( parameters ikfk_params rollout: ikfk_roll ( --nodeStore for the ikfk objects 'ikfkNodes' type:#maxObjectTab tabSize:0 tabSizeVariable:true ) rollout ikfk_roll "IK-FK" ( --define ikfk objects from ikfkNodes param local def_1 = fkikNodes[1] local def_2 = fkikNodes[2] local def_3 = fkikNodes[3] ... ) ) --assign ca to ikCtrlObject custAttributes.add ikCtrlObject.modifiers[1] ikfk_ca --after assigning the ca, define the actual object array ikfkArray=#() ikfkArray[1]=def_1=$FBX_r_arm_a ikfkArray[2]=def_2=$FBX_r_arm_b ikfkArray[3]=def_3=$FBX_r_wrist ... --and assign that array to ikCtrlObject.modifiers[1].ikfkNodes for each in ikfkArray do ( obj=nodeTransformMonitor node:each forwardTransformChangeMsgs:false append ikCtrlObject.modifiers[1].ikfkNodes obj )


testing this now...

Last edited by Mambo4 : 02-01-2013 at 06:11 PM.
 
Old 02-01-2013, 06:29 PM   #5
Mambo4
not a jedi yet
 
Mambo4's Avatar
portfolio
Logan Bender
Game Technical Artist
Greater Seattle, USA
 
Join Date: Nov 2010
Posts: 432
Code:
Plug-in not active, unable to access plug-in local or parameter: ikfkNodes


it appears I cannot assign elements in the ikfkNodes param to local variables.
 
Old 02-01-2013, 07:07 PM   #6
Swordslayer
isKindOf Artist
 
Swordslayer's Avatar
portfolio
Vojtech Cada
3D generalist
Czech Republic
 
Join Date: Jun 2006
Posts: 376
Send a message via ICQ to Swordslayer
Why do you want to do it this way anyway? It's not even a fixed-size array so it doesn't make much sense to do something like local def_n = fkikNodes[n]. If the size of the array was fixed, you could declare your variables in the rollout scope like you do now (without assigning the values) and intialize them in rollout open handler.
__________________
Blog :: LinkedIn profile
 
Old 02-01-2013, 07:30 PM   #7
Mambo4
not a jedi yet
 
Mambo4's Avatar
portfolio
Logan Bender
Game Technical Artist
Greater Seattle, USA
 
Join Date: Nov 2010
Posts: 432
I'm just trying to save an array of the objects I wish to manipulate when switching form fk to ik.
so that the system is not tied to hard coded object names.
 
Old 02-01-2013, 09:03 PM   #8
Swordslayer
isKindOf Artist
 
Swordslayer's Avatar
portfolio
Vojtech Cada
3D generalist
Czech Republic
 
Join Date: Jun 2006
Posts: 376
Send a message via ICQ to Swordslayer
All I'm saying is that if you want to initialize a fixed amount of locals, you should also use fixed-size array they are associated with to prevent shooting yourself in the foot later on. And then there's no problem with initializing all of them in the open rollout handler, something like:

Code:
( parameters ikfk_params rollout:ikfk_roll ( ikfkNodes type:#maxObjectTab tabSize:5 on ikfkNodes set val index do this.ikfk_roll.updateLocals() ) rollout ikfk_roll "IK-FK" ( local def_1, def_2, def_3, def_4, def_5 fn updateLocals = for item = 1 to 5 do setProperty this.ikfk_roll ("def_" + item as string) ikfkNodes[item] on ikfk_roll open do updateLocals() ) )
__________________
Blog :: LinkedIn profile
 
Old 02-01-2013, 09:03 PM   #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 01:20 AM.


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