PDA

View Full Version : code works, but fails when in a button ?


djlane
04-18-2006, 06:54 PM
Does anybody know why the following few lines of code always generates an :
>> 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 AutoSpline "spline" width:162 height:92
(

button btn1 "Button" pos:[38,23] width:81 height:43

on btn1 pressed do
(
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

mobeen
04-19-2006, 11:38 AM
Its working in 3ds max 5.

djlane
04-19-2006, 12:03 PM
Thanks for taking a look, it must be a new bug? I am using max 8. Has anybody got a work around.



Cheers

Dan

mobeen
04-19-2006, 12:14 PM
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

joconnell
04-19-2006, 12:31 PM
Works fine in max 7 here too dan - maybe it's keeping variables in memory and causing problems?

djlane
04-19-2006, 01:58 PM
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

>> MAXScript Rollout Handler Exception: -- Unknown system exception <<


-----------------------------------

This is hurting my head!

Many Thanks for the replies.

Dan

Gibbz
04-27-2006, 12:06 PM
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...

djlane
04-27-2006, 05:37 PM
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

_stev_
04-27-2006, 09:24 PM
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

djlane
04-27-2006, 11:22 PM
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

_stev_
04-27-2006, 11:42 PM
I'm in Max 7. I didn't get an error. I'm not sure what else could be wrong here.

Try throwing in "Max Motion Mode." Sometimes that has fixed strange errors for me.

Lata,
Stev

ajohnson
04-28-2006, 08:08 AM
I just want to confirm that I'm seeing this too in Max 8. I installed SP3 to see if perhaps this was a bug that they fixed. Unfortunately I got the error in SP3 as well :sad:

djlane
04-28-2006, 09:47 AM
Thanks for the confirmation, now I know its a bug not my crappy scripting skills.


Cheers

Dan

hblan
04-30-2006, 03:28 PM
sx[#Object__Editable_Spline][#Master][5].controller = point3_script()

for i have never use array like this , maybe i m not right :
i will first get the index of array to a variable , and then use it : maybe like this :
(
local index_1 = ( ......)-- integer . sorry for i dont like use name value as array index .
local index_2= (......) -- integer .

sx[index_1][index_2][5].controller = point3_script()
)

CGTalk Moderation
04-30-2006, 03:28 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.