Notifications
Clear all

[Closed] New Scripter

Hi, just wondering how can you add a custom attribute to a custom attribute holder using max script?

5 Replies

A bit more about the issue:

I have a controller object that will contain sliders that control the rotations of the fingers.

I want to set up a bunch of parameters eg:
Thumb_X
Thumb_Y
Thumb_Z

I wish for them to be a slider type with a range of -1 to 1.

right now I have something like:

$‘Right Hand Ctrl’.modifiers[#PEN_Attribute_Holder_2].Custom_Attributes.add [#Thumb_X]

Max has no clue what “.add” is and I am not sure what else to put to make sure the attribute is a slider with a range of -1 to 1.

This part just has me all stuck. :banghead:


 penHisMod = $.modifiers[1]
 PEN_Attribute_Holder 2:PEN_Attribute_Holder 2
 
 attr_helloworld = attributes "Hello World" (
 	rollout roll_hello "Hello!" (
 		slider sld_world "World" range:[-1,1,0] type:#float
 	)
 	parameters main rollout:roll_hello (
 		world type:#float ui:sld_world
 	)
 )
 <AttributeDef:Hello World>
 
 custAttributes.add penHisMod attr_helloworld
 true
 penHisMod.world
 0.0
 -- manually move slider all the way left
 penHisMod.world
 -1.0
 -- manually move slider all the way right
 penHisMod.world
 1.0
 

Edit: ignore the ‘interval:0.01’ I had on the slider – that was for an internal tool ( gotten too used to writing it >_< )

Thanks for posting back.

I guess before I can implement this code, I need to understand it a bit more.

Right now I’m at a level 0 for scripting. My scripts are stupid simple and taken out of MaxScript Listener. If MaxScript doesn’t “hear” it, I am lost.

I have a script to add a rotation list and an extra euler to a bone, and to rename them, looks like this:

--Left Hand 
-- Left Index Finger 
$'Left Index 00'.rotation.controller = rotation_list ()
$'Left Index 00'.rotation.controller.Available.controller = Euler_XYZ () 
$'Left Index 00'.rotation.controller.setname 1 "init" 
$'Left Index 00'.rotation.controller.setname 2 "Wire" 
$'Left Index 00'.rotation.controller.setActive 2 

$'Left Index 01'.rotation.controller = rotation_list () 
$'Left Index 01'.rotation.controller.Available.controller = Euler_XYZ () 
$'Left Index 01'.rotation.controller.setname 1 "init" 
$'Left Index 01'.rotation.controller.setname 2 "Wire" 
$'Left Index 01'.rotation.controller.setActive 2 

$'Left Index 02'.rotation.controller = rotation_list () 
$'Left Index 02'.rotation.controller.Available.controller = Euler_XYZ () 
$'Left Index 02'.rotation.controller.setname 1 "init" 
$'Left Index 02'.rotation.controller.setname 2 "Wire" 
$'Left Index 02'.rotation.controller.setActive 2 

-- Left Middle Finger 
$'Left Middle 00'.rotation.controller = rotation_list () 
$'Left Middle 00'.rotation.controller.Available.controller = Euler_XYZ () 
$'Left Middle 00'.rotation.controller.setname 1 "init" 
$'Left Middle 00'.rotation.controller.setname 2 "Wire" 
$'Left Middle 00'.rotation.controller.setActive 2 

$'Left Middle 01'.rotation.controller = rotation_list () 
$'Left Middle 01'.rotation.controller.Available.controller = Euler_XYZ () 
$'Left Middle 01'.rotation.controller.setname 1 "init" 
$'Left Middle 01'.rotation.controller.setname 2 "Wire" 
$'Left Middle 01'.rotation.controller.setActive 2
ect...

Then I have a script to wire them to the controller, looks like this:

select $'Left Thumb 01' paramWire.connect 
$'Left Hand Ctrl'.modifiers[#PEN_Attribute_Holder_2].Custom_Attributes[#Thumb_X] 
$.rotation.controller.wire.controller[#X_Rotation] "Thumb_X" paramWire.connect 
$'Left Hand Ctrl'.modifiers[#PEN_Attribute_Holder_2].Custom_Attributes[#Thumb_Y] 
$.rotation.controller.wire.controller[#Y_Rotation] "Thumb_Y" paramWire.connect 
$'Left Hand Ctrl'.modifiers[#PEN_Attribute_Holder_2].Custom_Attributes[#Thumb_Z] 
$.rotation.controller.wire.controller[#Z_Rotation] "Thumb_Z" 

select $'Left Thumb 02' paramWire.connect 
$'Left Hand Ctrl'.modifiers[#PEN_Attribute_Holder_2].Custom_Attributes[#Thumb_X] 
$.rotation.controller.wire.controller[#X_Rotation] "Thumb_X" paramWire.connect 
$'Left Hand Ctrl'.modifiers[#PEN_Attribute_Holder_2].Custom_Attributes[#Thumb_Y] 
$.rotation.controller.wire.controller[#Y_Rotation] "Thumb_Y" paramWire.connect 
$'Left Hand Ctrl'.modifiers[#PEN_Attribute_Holder_2].Custom_Attributes[#Thumb_Z] 
$.rotation.controller.wire.controller[#Z_Rotation] "Thumb_Z" 

select $'Left Index 00' paramWire.connect 
$'Left Hand Ctrl'.modifiers[#PEN_Attribute_Holder_2].Custom_Attributes[#Index_X] 
$.rotation.controller.wire.controller[#X_Rotation] "Index_X" paramWire.connect 
$'Left Hand Ctrl'.modifiers[#PEN_Attribute_Holder_2].Custom_Attributes[#Index_Y] 
$.rotation.controller.wire.controller[#Y_Rotation] "Index_Y" paramWire.connect 
$'Left Hand Ctrl'.modifiers[#PEN_Attribute_Holder_2].Custom_Attributes[#Index_Z] 
$.rotation.controller.wire.controller[#Z_Rotation] "Index_Z" 

select $'Left Index 01' paramWire.connect 
$'Left Hand Ctrl'.modifiers[#PEN_Attribute_Holder_2].Custom_Attributes[#Index_X] 
$.rotation.controller.wire.controller[#X_Rotation] "Index_X" paramWire.connect 
$'Left Hand Ctrl'.modifiers[#PEN_Attribute_Holder_2].Custom_Attributes[#Index_Y] 
$.rotation.controller.wire.controller[#Y_Rotation] "Index_Y" paramWire.connect 
$'Left Hand Ctrl'.modifiers[#PEN_Attribute_Holder_2].Custom_Attributes[#Index_Z] 
$.rotation.controller.wire.controller[#Z_Rotation] "Index_Z"
ect...

I tried using your script to add the “Hello World” to a pen attribute holder to a box with that modifier. When I tried to run the script I would get an issue with the second line:

PEN_Attribute_Holder 2:PEN_Attribute_Holder 2

Anyway, Thanks for taking the time to help out a scriptnub.

1 Reply
(@zeboxx2)
Joined: 1 year ago

Posts: 0

Sorry about that

Lines in regular color are actual script code lines to evaluate.
Lines starting with – and in dark green are comment lines
Lines in blue are MaxScript Listener feedback. Basically they show you the result that the Listener should give you if you evaluate the line(s) preceding it.

So when it says…


penHisMod = $.modifiers[1]
 PEN_Attribute_Holder 2:PEN_Attribute_Holder 2

The first line is the line you’d evaluate – it assumes that you have 1 object selected ($), and it has at least one modifier, the top-most ([1]) of which is accessed.
The second line, in blue, is the result of the first line, and returns the value of that modifier – in this case, the PEN_Attribute_Holder 2, with a name of “PEN Attribute Holder 2” (maxscript automatically changes spaces into underscores in some cases).

So… don’t evaluate the blue lines

Awesome! Got it working now. Now to see if I can tweek it to have a roll out per each finger.

Thanks much for the help!