PDA

View Full Version : Maxscript execution jamming/confusion


GrahamMac
03-14-2012, 11:17 PM
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.

2) I try pressing ctrl ďEĒ again.
* No response

3) I click in the listener and press escape.
* Listener displays ** interrupted **

4) I press ctrl ďEĒ once more and even try Tools>evaluate all.
* Again no response

5) 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

lo
03-15-2012, 07:45 AM
This sounds like the expected result when your script is missing a closing parentheses.

GrahamMac
03-15-2012, 10:51 AM
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\n"
undo on
(
for i = 2 to 33 do
(
format "entered for loop on i = %\n"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

lo
03-15-2012, 11:03 AM
try replacing if/then with if/do.

DaveWortley
03-15-2012, 11:03 AM
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\n"
undo on
(
for i = 2 to 33 do
(
format "entered for loop on i = %\n" i
)
)
)
else
(

)

GrahamMac
03-15-2012, 12:36 PM
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

CGTalk Moderation
03-15-2012, 12:36 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.