Notifications
Clear all

[Closed] Custom Attribute Variables

Hi. I’m relatively new to Maxscript, but am trying something that seems quite advanced to me. I want to add some custom attributes to an IK Chain to allow the animator more control over certain aspects of the IK controller. I have collected some useful bits to use and I need to write the custom attribute. However, in the only custom attribute script I have written, I accessed parameters using direct references to objects (no variables). So I don’t know where to declare variables in the custom attribute script so that the script can be altered for different IK chains and or characters. Wherever I do it, it seems to cause an error in the declaration of the variable.

And I don’t really know how those variables would work. If I had multiple variables (with the same name) in multiple attribute holder modifiers on multiple objects, would the variables be local to the object? Would changing one value change them all? Would I have to write multiple scripts with different variable names (thus making the variable declaration thing pointless and irrelevant)?

I hope this makes some sense. I haven’t found any good information on this in the internet and the maxscript help file after at least an hour’s searching. If you can help, I would be very grateful!

4 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

[left]attributes <name> [version:n] [silentErrors:t/f] [initialRollupState:0xnnnnn]
[remap:#(<old_param_names_array>, <new_param_names_array>)]
[/left]
[left](
[/left]
[left]<locals>
[/left]
[left]<globals>
[/left]
[left]<parameters>
[/left]
[left]<rollouts>
[/left]
[left]<handlers>
[/left]
[left])
[/left]
[left]it’s from mxs help.

You can store nodes in parameter block of scripted attribute (will be saved with a scene) or in local scope (temporarily for scene session). In both cases the data might be unique for every attribute instance.

[/left]

Thanks mate, not sure how I overlooked that. You say the local scope is temporary for the scene session – what if there are are multiple objects with the same custom attribute (same attribID: etc? Is a local variable unique for each one?
Thanks for the help.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

local scope is unique for each attribute instance.


 global test_attrib = attributes "Test Data" attribID:#(0x1cabed9b, 0x5555de47)
 (
 	local local_data = "local"
 	parameters main rollout:params
 	(
 		param_data type:#string ui:ui_param_data default:"param"
 		on param_data set val do (format "param:%
" val)
 	)
 	rollout params "Parameters" 
 	(
 		edittext ui_local_data "Local:" labelOnTop:on width:130 
 		edittext ui_param_data "Param:" labelOnTop:on width:130
 		
 		on ui_local_data changed text do (format "local:%
" (local_data = text))
 		on params open do ui_local_data.text = local_data
 	)
 )
 (
 	delete objects
 	b = box isselected:on
 	em1 = emptyModifier name:"Data 1"
 	em2 = emptyModifier name:"Data 2"
 	addmodifier b em1
 	addmodifier b em2
 	custAttributes.add em1 test_attrib
 	custAttributes.add em2 test_attrib
 
 	format "mod#1 local:% param:%
" em1.local_data  em1.param_data 
 	format "mod#2 local:% param:%
" em2.local_data  em2.param_data 
 )
 

Thanks a lot mate, got all this sorted now thanks to you!