Could use some help :) <<Unknown system exception>>
Heyho!
i am currently messing around with max script a bit, trying to understand it and learn the commands, so i'm really new to this. For training i wrote this small script:
macroScript checkSelCount category:"Custom"
(
rollout checkSelCount "checkSelCount" width:132 height:63
(
edittext edt " " pos:[4,5] width:116 height:22
button btn "Update selection" pos:[3,33] width:122 height:23
)--end rollout
fn check_sel_count = (
if selection.count == 0 then
checkSelCount.edt.text = "Nothing selected" else
if selection.count > 1 then
checkSelCount.edt.text = "Multiple selected" else
checkSelCount.edt.text = "''" + $.name as String + "''" + " selected"
)--end function
on btn pressed do
(
check_sel_count()
)--end on
createDialog checkSelCount 132 63
checkSelCount.edt.readOnly = true
check_sel_Count()
)--end macroScript
It should simply print out in the edittext-field if nothing, one or multiple objects are selected (on start or when i hit the update button. I already had this working, but after i restarted max, i got lots of errors with undefined properties and after changing the order of some things, i now always get a an "unknown system exception".
I guess it's really simple to solve, but i'm stuck. Any ideas? And is there a better way to check if anything has been selected? And why do i sometimes get a Number in the Listener after evaluating my script, instead of "OK"?
Screenshot: http://s5.directupload.net/file/d/1969/o5wbx2l5_jpg.htm
Greetings :)
Comments
I am glad that I helped you.
I am glad that I helped you. I forgot to add the "ro_" in the function as well :) and yes, in some cases the same names of macros and rollout will bring "unknown system exception".
And one hint about ";" symbol -- its end-of-line but needed only in case where you want to write 2 commands in 1 line, for example:
my recent MAXScripts RSS (archive here)
Ah...to tell the truth don't
Ah...to tell the truth don't remember why I put those " ; " there. I did a little ActionScript some years ago, guess i mixed it up in that moment :P Anyway, thanks for the advice.
Never get low & slow & out of ideas
Great :) I did not know you
Great :) I did not know you have to place button events in the rollout. Will I run into problems when my rollout does have the same name as my macroscript?
I added the "ro_" in the function as well, and now it works, thanks alot Anubis :) !
Greetings
Just for testing out how you did that formatted code:
Never get low & slow & out of ideas
Your button event (on
Your button event (on pressed) is out of rollout.
Also I renamed rollout to ro_checkSelCount to not match the macros name.
my recent MAXScripts RSS (archive here)