| Very introductory Maxscript tutorial 5 |
dracayr |
hi, I get that error too. I even get it if I try this script: MacroScript Random_Rotate category:"Rhys Tools" buttonText:"Random Rotate" tooltip:"Random Rotate" ( for obj in $ do ( if(selection.count >0)then ( messagebox "objects are selected" ) else ( messagebox "no objects are selected" ) ) )
read 2051 times 1/6/2008 12:14:58 PM (last edit: 1/6/2008 12:14:58 PM)
|
Dub. |
that script works fine for me...
what seems to be the problem?
read 2038 times 1/6/2008 2:38:27 PM (last edit: 1/6/2008 2:38:27 PM)
|
SgtSKU |
first, great tut dub! i really learned alot here... but the last script wouldnt work... if i executed it from maxscript it worked fine... but when i executed it from the menu (the Rhys Tools) it didnt... no "map" function for undefined.. it may be some things i have messed up i dont no... thanks for the tut anyway :p
read 2000 times 1/13/2008 11:48:34 AM (last edit: 1/13/2008 11:48:34 AM)
|
Dub. |
Oops! Many apologies, I put you wrong there.
There was actually a logic error in the code. If you look at your code carefully, you'll notice that you are launching into the loop which loops though the objects selected BEFORE you check if any are actually selected. so if there are none selected, the program tries to loop through the selection which doesn't exist and thus crashes.
Here is the correct way to do it.
MacroScript Random_Rotate category:"Rhys Tools" buttonText:"Random Rotate" tooltip:"Random Rotate" ( if(selection.count >0)then ( for obj in selection do ( messagebox "objects are selected" ) ) else ( messagebox "no objects are selected" ) )
Rhys.
read 1986 times 1/13/2008 1:34:35 PM (last edit: 1/13/2008 1:34:35 PM)
|
SgtSKU |
em... so the full kode will be? :p
read 1982 times 1/13/2008 1:47:54 PM (last edit: 1/13/2008 1:47:54 PM)
|
Dub. |
rollout RandomRotateRollout "Random Rotate" width:162 height:149 ( groupBox grp1 "Random Rotation Range" pos:[10,12] width:142 height:99 button btn1 "Exicute Rotate!" pos:[19,81] width:125 height:22 spinner spn1 "Minimum " pos:[22,34] width:122 height:16 range:[-360.0,360.0,0.0] spinner spn2 "Maximum" pos:[22,56] width:122 height:16 range:[-360.0,360.0,0.0] on btn1 pressed do ( if(selection.count > 0)then ( for obj in selection do ( randXrot = random spn1.value spn2.value randYrot = random spn1.value spn2.value randZrot = random spn1.value spn2.value rot_obj = eulerangles randXrot randYrot randZrot rotate obj rot_obj ) ) else ( messagebox "You must have at least one object selected!" ) ) ) createDialog RandomRotateRollout 162 166
read 1975 times 1/13/2008 2:10:34 PM (last edit: 1/13/2008 2:10:34 PM)
|
urgaffel |
"Exicute"? :P
 All I remember was shaving... then *BLAM*
Environment art/gamesindustry blog thing
read 1957 times 1/14/2008 3:02:35 AM (last edit: 1/14/2008 3:02:35 AM)
|
Dub. |
Technical term....
you wouldn't understand Urg....
read 1953 times 1/14/2008 3:28:12 AM (last edit: 1/14/2008 3:28:12 AM)
|