[Closed] after action done, close dialog // DestroyDialog rollout
hello everyone.
i got this simple script her:
rollout modalRollout “rim orientation”
(
button btn_ok "ok"
button btn_rot "flip"
on btn_ok pressed do
DestroyDialog modalRollout
on btn_rot pressed do
rotate $rim (angleaxis 180 [0,0,1]) + DestroyDialog rimOr
)
createdialog modalRollout modal:true
-it creates a dialog and asks if a object is looking right or not
-if yes (pressing ok) dialog closes and script goes on
-if no (pressing flip) the object is rotated by 180° and after that the dialog closes and the script moves on.
problem: the listener shows mit this error:
– Error occurred in btn_rot.pressed();
the script itself works and no obvious error messages appear, just in the background the lisener shows me some error. any ideas how to fix this…OR any better solution possible?
here’s your error, remove red part or replace it by
rotate $rim (angleaxis 180 [0,0,1]); DestroyDialog modalRollout
chechinkg that $rim exist before would be better
rollout modalRollout "rim orientation"
(
button btn_ok "ok"
button btn_rot "flip"
on btn_ok pressed do
DestroyDialog modalRollout
on btn_rot pressed do
rotate $rim (angleaxis 180 [0,0,1]) + DestroyDialog rimOr
)
createdialog modalRollout modal:true
ok after another round of “google” (i searched after my error message) i know got this and is has no errors anymore and works fine:
rollout modalRollout “rim orientation”
(
button btn_ok “ok”
button btn_rot “flip”
on btn_ok pressed do
DestroyDialog modalRollout
on btn_rot pressed do
(
rotate $rim (angleaxis 180 [0,0,1])
DestroyDialog modalRollout
)
)
createDialog modalRollout modal:true
what i learned:
if this: on btn_rot pressed do has more then one job to do like mine, i have to wrap these two ( ) arround
thanks for your try
I should have replace all code.
It sounded natural for me to put my separate line beetween parenthesis.
At least you will remenber it forever because you learned it the hard way
As suggested above, for added safety I would modify slightly to this:
on btn_rot pressed do
(
if $rim != undefined do
(
rotate $rim (angleaxis 180 [0,0,1])
)
DestroyDialog modalRollout
)
)
thanks all of you for your suggestions!
yes lanimal, sometimes is learning things the hard way the best way
because the dialog is modal you should check a node existence before its showing.
i would simply use the queryBox:
if isvalidnode node and queryBox ("Do you want to flip \"" + node.name + "\"?") beep:off do rotate node ...