"Unable to convert OK to type:Float" error

"Unable to convert OK to type:Float" error

bhnh
Advocate Advocate
1,403 Views
2 Replies
Message 1 of 3

"Unable to convert OK to type:Float" error

bhnh
Advocate
Advocate
Here's a bit of code to make a checkbox in one object hide/unhide another object...
(
ca = attributes New
(
parameters main rollout:params
(
hidestuff type:#boolean ui:ckb_hs
)
rollout params "Checkbox Controller"
(
checkbox ckb_hs "Hide Unselected Stuff"
on ckb_hs changed theState do
(print this.hidestuff)
)
)
rollout demo "CustAtt Checkbox Demo"
(
button btn "Make Shapes"

on btn pressed do
(
s = sphere radius:12
c = cone pos:

custAttributes.add s ca
s.hidestuff = false
watcher = point()
watcher.parent = s
fs = float_script()
watcher.axistripod.controller = fs
fs.addNode "ctrlBall" s
fs.addNode "coneshape" c
fs.script = "with animate off (if ctrlBall.hidestuff == true then hide coneshape else unhide coneshape)"
)
)
createDialog demo 200 50
)

When I evaluate, I get the following error:
-- Runtime error: IScriptCtrl::SetExpression - Expression evaluation error: 
-- Unable to convert: OK to type: Float

Any clues for the clueless here? Many thanks.
0 Likes
1,404 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
I think I see it: fs.script is supposed to return a Float value at the end. Hide and unhide both return OK.
0 Likes
Message 3 of 3

bhnh
Advocate
Advocate
I think I see it: fs.script is supposed to return a Float value at the end. Hide and unhide both return OK.


That's it, Stokes. Tyson Ibele over at SimplyCG pointed out that simply adding \n 0 to the end of the fs.script solves the problem...
(
ca = attributes New
(
parameters main rollout:params
(
hidestuff type:#boolean ui:ckb_hs
)
rollout params "Checkbox Controller"
(
checkbox ckb_hs "Hide Unselected Stuff"
on ckb_hs changed theState do
(print this.hidestuff)
)
)
rollout demo "CustAtt Checkbox Demo"
(
button btn "Make Shapes"

on btn pressed do
(
s = sphere radius:12
c = cone pos:

custAttributes.add s ca
s.hidestuff = false
watcher = point()
watcher.parent = s
fs = float_script()
watcher.axistripod.controller = fs
fs.addNode "ctrlBall" s
fs.addNode "coneshape" c
fs.script = "if ctrlBall.hidestuff == true then hide coneshape else unhide coneshape\n 0"

)
)
createDialog demo 200 50
)

Run the code, check the box, click on the time slider (or animate) and voila.
0 Likes