Notifications
Clear all

[Closed] Maxscript execution jamming/confusion

In Max 2012 I’ve 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:

  1. I press ctrl “E”.
  • Script doesn’t 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.
  1. I try pressing ctrl “E” again.
  • No response
  1. I click in the listener and press escape.
  • Listener displays ** interrupted **
  1. I press ctrl “E” once more and even try Tools>evaluate all.
  • Again no response
  1. 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 I’ve 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 hadn’t 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.
It’s 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

5 Replies
 lo1

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 can’t 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 didn’t run and listener shows an error only sometimes (I can’t see a pattern).
 2) With Tools>evaluate all, the listener always shows appropriate error for the missing parentheses and of course the script doesn’t run which is to be expected.
 
 The script I’m 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 (I’m 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
 lo1

try replacing if/then with if/do.

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 that’s causing the problem.

If I add else() in the appropriate place or change “then” to “do” all issues are resolved!!

DaveWortley, I’ve 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