[Closed] How to control Custom Attributes?
Hello everybody!
I wanna add a custom attributes to a spline to control the animation. I added a listbox and a pickbutton to it, and gonna achieve this: picked an object then the object’s name display in the listbox item.
Here’s my script:
testCA = attributes listBoxTest
(
parameters main rollout params
(
-------------------------------------------------------
)
rollout params "Test"
(
fn shapesOnly obj = isKindOf obj shape
listBox objLb ""
pickbutton objPb "Pick an Object" filter:shapesOnly
on objPb picked obj do
objLb.items = #(obj.name)
)
)
custAttributes.add $.modifiers[1] testCA
But when I selected another object then selected the object again, the data was gone.
So how to save the data? I know that I should set some parameters but how to do it?
Thank you.
your missing parameter attributes, you can associate with a UI element, that can be animated.
testCA = attributes listBoxTest
(
parameters main rollout params
(
theNode type:#node
theString type:#stringTab tabSizeVariable:true default:#()
)
rollout params “Test”
(
fn shapesOnly obj = isKindOf obj shape
listBox objLb “”
pickbutton objPb “Pick an Object” filter:shapesOnly
on objPb picked obj do
(
theNode = obj
append theString obj.name
objLb.items = theString
)
on params open do
(
objLb.items = theString
)
)
)
custAttributes.add $.modifiers[1] testCA
the rollout can’t be open twice, so you’ll have to remove it, then open it as a dialog; not pretty
removeRollout $.params
createDialog $.params
of course – only with minimal testing, though… again, parameters weren’t really meant to be in a floating dialog
myAttribs = attributes test (
rollout roll_test "Test" (
spinner spn_test "test spinner"
checkbutton ckb_float "float me"
on ckb_float changed state do (
if (state) then (
if (not (roll_test.inDialog)) then (
removeRollout roll_test
createDialog roll_test
)
ckb_float.text = "unfloat me"
ckb_float.checked = true
)
else (
destroyDialog roll_test
addRollout roll_test
ckb_float.text = "float me"
)
)
)
parameters main rollout:roll_test (
someValue type:#float ui:spn_test
on someValue set val do (
format "someValue set to: %
" val
)
)
)
mySphere = sphere()
select mySphere
custAttributes.add mySphere myAttribs