[Closed] Adding single attribute to existing rollout
Hi,
I couldn’t find anything on this in the search or in the help file, so I’m hoping someone here can help me (again!)
I am writing a script that creates sliders for face morphs, and the number of sliders will change depending on the rig. I would like to put these sliders into the face attribute holder that I have on my face control object.
I have written a script that does this by simply creating a new attribute definition and then uses custAttributes.add to put them into the attribute holder. But each time I do that I get a new rollout, which ends up looking quite messy. I cannot figure out how to add a new attribute to an existing definition. I have tried doing “attributes newDef redefine:oldDef”, but that rewrites the existing attribute rollout instead of adding to it.
Could anyone help me out?
There is no direct way to just add an attribute to an existing definition without supplying the entire definition again. What you need to do is parse the existing definition string and add in the new lines then redefine the definition. What you can do is have the whole def built out of a string that you just execute. This way you can loop trough and add the existing information. The way the built in tool does this is with the defData, it stores a string that defines the UI items as there is no way to get this information from a UI item it self. It them rebuilds the def adding the new lines.
Thanks a lot for the pointers Paul, it’s very good to have a direction to follow instead of looking blindly through the help file. I’ll take a look at string parsing and see if I can manage to script the solution you outline. Cheers!