[Closed] Adding custom attributes to existing rollout
Hey there,
Brain freeze. How can I add additional custom attributes to an existing rollout?
I create the rollout, attributes & parameter stuff once, and the attribute shows up under the appropriately named rollout. How do I add a new attribute to that same rollout, particularly if there are other rollouts associated with that same node (or attribute holder)?
Thanks,
Alec
depending on your needs, you can either replace (redefine) the specific custom attribute:
curDef = custAttributes.getDef $ 1
newDef = attributes "test" redefine:curDef ( etc. )
or
curDef = custAttributes.getDef $ 1
custAttributes.redefine curDef "attributes \"test\" ( etc. )"
or you can make your custom attribute block global:
def = attributes test attribID:#(0xdeadbeef,0x900df00d) ( etc. )
Then any time you change the ‘etc.’, it will automatically update the definition as used anywhere in the scene.
This addresses the attributes themselves, but not the rollouts associated with the attributes.
I’m looking for a method of adding new controls to a rollout while maintaining the integrity of the previously existing controls. So, for instance, if I’ve coded a param/rollout setup that connects a spinner to a float_reactor(), rather than destroying the rollout and recreating it, I’d like to be able to append a new spinner or UI element.
Is this sort of thing possible in conjunction with the attribute update?
Thanks,
Alec
I… think it should stay perfectly intact ‘as is’?
Start out with this custom attribute:
ca_test = attributes test (
rollout roll_test "rollout test" (
spinner spn_myval "myVal"
)
parameters main rollout:roll_test (
myval type:#float ui:spn_myval
)
)
- create a sphere, add ca_test to that sphere.
- create another sphere
- right-click on the myVal spinner, bring up the param wire dialog
- wire myval to the other sphere’s radius
- play with the value of myval to make sure the 2nd sphere’s radius is affected
get the current definition:
oldCA = custAttributes.getDef $ 1
and redefine it – adding a myValTwo
ca_test = attributes test redefine:oldCA (
rollout roll_test "rollout test" (
spinner spn_myval "myVal"
spinner spn_myvaltwo "myVal2"
)
parameters main rollout:roll_test (
myval type:#float ui:spn_myval
myvaltwo type:#float ui:spn_myvaltwo
)
)
UI should auto-update to show the 2nd spinner if you still had the UI open.
- play with myVal… the 2nd sphere’s radius should still be affected.
The same applies when you use the “controller:<controller>” form within the rollout specification, just make sure you still specify that when redefining.
You are right indeed! I’m not sure what the hell I was doing before, but your example works fine and I’ve applied the method to my code with great success.
Thanks a ton for the help.
Alec