[Closed] Maxscript execution jamming/confusion
In Max 2012 Ive noticed my max scripts running from the maxscript editor often seem to get A) jammed or B) confused as to what code to run when I run the script after working on it. I’ve seen this more on my more complex scripts but strangely there doesn’t appear to be anything wrong with the code. For example:
A) Most commonly I notice the following:
- I press ctrl E.
- Script doesnt do anything
- Listener displays no errors
- Usually the listener displays correct result of a getcurrentselection() or some other simple code at the start of my script but nothing else.
- I try pressing ctrl E again.
- No response
- I click in the listener and press escape.
- Listener displays ** interrupted **
- I press ctrl E once more and even try Tools>evaluate all.
- Again no response
- I click on a random line in my code in the maxscript editor (something very simple that can’t fail to execute properly) and press num-pad enter to run just that line of code.
- Suddenly the entire script runs as it should have done earlier.
B) Less commonly Ive noticed the following behaviour:
Let’s say I run a script containing a for loop that is hard coded to run from i = 1 to 50. The script runs fine and then I change the for loop to i = 1 to 100 then execute again. The script then runs as if I hadnt made the change (i only reaches 50), but if I run the script a third time it normally then runs to 100 as it should.
Its almost as if the evaluation process recalls the script in the state when you last ran it and runs that instead of the latest code.
Has anyone experienced this behaviour or can someone shed some light on what is going on?
[Edit:] The Tools>evaluate all command does actually seem to make the whole script run properly, at least some of the time for situation A.
Many thanks
Graham
This sounds like the expected result when your script is missing a closing parentheses.
Hi Rotem,
Thanks for your help.
I had a close look through and cant see any missing closing or opening parentheses.
As a test I tried removing the final parenthesis and ran my script:
1) With ctrl-E, script didnt run and listener shows an error only sometimes (I cant see a pattern).
2) With Tools>evaluate all, the listener always shows appropriate error for the missing parentheses and of course the script doesnt run which is to be expected.
The script Im working on right now creates float scripts on maps within a multi/sub material which are set by the script to be controlled by a custom attribute in the scene.
As a further test I removed the bottom 90% of my script (adding a few closing parentheses as needed). When I ran this code (see below) via ctrl-E, the listener displays:
#($Editable_Mesh:Line015 @ [3.517014,-2.448156,0.147664])
Which is the object I have selected in the scene, and the rest of the code does not run.
I next place the curser at the end of any line of code (except a closing parentheses) and press num-pad enter, the full script suddenly runs.
The first time I tried this test the script ran and setup all the float scripts as if It were running the old code. Upon repeat attempts it always seemed to run the correct code in the editor (once I pressed num-pad enter)
Sel = getcurrentselection()
if sel.count == 1 then
(
format "One object selected
"
undo on
(
for i = 2 to 33 do
(
format "entered for loop on i = %
"i
)
)
)
I wondered if this was perhaps a windows problem (Im using win 7 64bit) so I tried the above code in Max 2010 32bit, Max 2010 64bit and Max 2011 64bit across different machines (XP, wind 7) and found that ctrl-E is behaving in the same strange way every time.
Is it that the ctrl-E shortcut has a bug that nobody talks about or am I missing something???
Thanks again for any help!
Graham
Having strange errors with max2011 as well. I’ve had this issue before where if I’m using If…= … then
I need to have an else clause to make the script work. Or switch the ‘then’ to a ‘do’.
Even with this if you hit the Escape key in the maxscript listener it still prints “** interrupted **” so it’s still got something wrong with it…
Sel = GetCurrentSelection()
if sel.count == 1 then
(
format "One object selected
"
undo on
(
for i = 2 to 33 do
(
format "entered for loop on i = %
" i
)
)
)
else
(
)
Thanks guys for your help,
It is definitely the if/then thats causing the problem.
If I add else() in the appropriate place or change then to do all issues are resolved!!
DaveWortley, Ive noticed that no matter what code is run, if you hit escape just after in the listener it will always print “** interrupted **”
Eg:
Temp = 10
--Press escape
** interrupted **
--Press escape
--nothing prints
Temp = 10
--Press escape
** interrupted **
Cheers
Graham