View Full Version : Modifying Custom Attributes
05-25-2011, 08:08 AM
I am trying to script a script that can modify a Custom Attribute code on an object with Attribute Holder holding several animation sliders. I'm fairly new to scripting and Maxscript so I'm not sure if this is even a possible or good way of approaching the issue, but so far I've "extracted" the code from the object this way
custAttributeCode = custAttributes.getDef (custAttributes.get $.modifiers 1)
custAttributeCode.source now holds the Custom Attributes code and I'd like the script to look through the code and find all Sliders, store their name in an Array (going to look up their animation track later), adjust their Width, left align and add a SetKeyframe Button to the right of each slider. And finally update the new Custom Attribute code on the object.
Problem is that I'm having problems finding a way to to modify the code with maxscript. Any help or suggestions is appreciated! :)
That will be a bit of a tough one. Was the ca def created using the attribute editor or was it written by hand?
If created by the attribute editor you read the def data and use it to rebuild the definition string and then update the def.
If it was hand written then you are going to have to parse the def string that you have and rebuild it with the needed changes.
05-26-2011, 07:45 AM
Hi, thanks for your reply. The CAs I'm modifying has been created with the Parameter Editor, so the code format should be fairly standardized on all the CAs I want to modify.
Parameters main rollout:params
'Slider1' Type:#float UI:'Slider1' Default:0.0
'Extend' Type:#float UI:'Extend' Default:0.0
'Move' Type:#float UI:'Move' Default:0.0
Rollout Params "Custom Attributes"
slider 'Slider1' "Slider1:" Width:160 Height:25 Align:#Center Offset:[0,0] Type:#float Range:[0,100,0] Orient:#Horizontal Ticks:0
slider 'Extend' "Extend:" Width:160 Height:25 Align:#Center Offset:[0,0] Type:#float Range:[0,100,0] Orient:#Horizontal Ticks:0
slider 'Move' "Move:" Width:160 Height:25 Align:#Center Offset:[0,0] Type:#float Range:[0,100,0] Orient:#Horizontal Ticks:0
I could code the CAs from scratch, but I'd like to try to keep the ranges and wire parameters that's already set up.
A friend sent me some example maxscript code for searching and replacing text with findString and replace last night. I might be able to use that, but I'll have to study the code a little bit more before getting the grasp of it.
05-26-2011, 11:07 AM
if you use something like Grant Adam's attribute editor (http://www.scriptspot.com/3ds-max/scripts/custom-attribute-editor) you can extract the CADef to a file, then use the Visual Maxscript editor to make your changes. Then save the file you are working on, and press 'redefine' on the attribute editor. Simples! You can use the same def on any other objects with the same setup.
Similarly if they are the same attribute (but unique) in the scene on a variety of objects, you can perform a blanket update using something like this -
newAttrib = custAttributes.getDefSource <your new attribute>
Defs = for i in (custAttributes.getSceneDefs()) where i.name == #Custom_Attributes collect i
if Defs.count > 0 then
for eachDef in Defs do
custAttributes.redefine eachdef newAttrib
If you have a multitude of different types of attributes, then as Paul said it would be a pain and you'd have to parse each def source, looking for the properties that you want to change and add the bits to it. Nasty. :banghead:
05-26-2011, 11:49 AM
Yeah, all our rigs have different named sliders, ranges etc, so I guess I would have to parse the code. Your link to Grant's CA Manager might be a timesaver though! Thanks!
If I can easily modify our old CA with this I can concentrate my script on a good setup for creating future Custom Attributes from scratch.
05-26-2011, 11:49 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.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.