[Closed] code works, but fails when in a button ?
Does anybody know why the following few lines of code always generates an :
[size=1][color=#ff0000]>> MAXScript Rollout Handler Exception: – Unknown system exception <<
the code workes fine on its own but if I put it in a button event or a function it fails.
I`m sure I am making a fundermental mistake, I have gone through the docs but can not find anything on the limitations of what code can be put within a button.
rollout[/color][/size] AutoSpline “spline” width:162 height:92
(
button btn1 “Button” pos:[38,23] width:81 height:43
on btn1 pressed [color=#0000ff][color=#fffffe]do[/color][/color]
(
sx = SplineShape pos:[0.0, 0.0, 0.0]
addNewSpline sx
addKnot sx 1 #corner #line [0.0, 0.0, 0.0]
addKnot sx 1 #corner #line [0.0, -10.0, 0.0]
updateShape sx
animateVertex sx #all
–completeRedraw()
sx[#Object__Editable_Spline][#Master][2].controller = point3_script()
sx[#Object__Editable_Spline][#Master][5].controller = point3_script()
)
)
createdialog AutoSpline 162 92
Cheers
Dan
Thanks for taking a look, it must be a new bug? I am using max 8. Has anybody got a work around.
Cheers
Dan
Does maxscript compiler echo any variables on the listener???
Have a closer look at the listener for clues. See if there are any undefined variables.
Regards
Mobeen
Works fine in max 7 here too dan – maybe it’s keeping variables in memory and causing problems?
Hello again.
I restarted max and ran my script again and this is what the listener came up with:
– Error occurred in btn1.pressed()
– Frame:
– sx: $Shape01
[size=3]>> MAXScript Rollout Handler Exception: – Unknown system exception <<
This is hurting my head!
Many Thanks for the replies.
Dan
[/size]
id work by commenting out all the lines and going and and uncommenting each line ot see where the problem is, or use prints between each line…
find the line thats not working right…
Cheers Gibbz, I isolated the lines of code which cause it to fail they were:
sx[#Object__Editable_Spline][#Master][2].controller = point3_script()
sx[#Object__Editable_Spline][#Master][5].controller = point3_script()
which is the code to apply point3_script controllers to the knot points!
but these lines should not cause errors, all of this works perfectly well when outside
a button press? why should simply putting it inside the button cause an error?
I have even tried accesing the knot points using the index access method but still fails.
Are you using max 8 did it fail for you?
Cheers
Dan
If it only fails when it’s in a button event, put it in a function, then call that function in the button event. Here’s how it’d look.
rollout AutoSpline "spline" width:162 height:92 (
fn doSomething = (
sx = SplineShape pos:[0.0, 0.0, 0.0]
addNewSpline sx
addKnot sx 1 #corner #line [0.0, 0.0, 0.0]
addKnot sx 1 #corner #line [0.0, -10.0, 0.0]
updateShape sx
animateVertex sx #all
--completeRedraw()
sx[#Object__Editable_Spline][#Master][2].controller = point3_script()
sx[#Object__Editable_Spline][#Master][5].controller = point3_script()
)
button btn1 "Button" pos:[38,23] width:81 height:43
on btn1 pressed do (
doSomething()
)
)
createdialog AutoSpline 162 92
Hi Stev,
I had tried that when I initially ran into this problem, I copied and pasted your code just to double check and it still throws the same error.
Are you on Max 8? is it working for you?
Cheers
Dan