Notifications
Clear all

[Closed] Code line skipped in 2011

Hi…i have a question…
i did a script in 2009 and it works perfect but
when i run it on 2011 it skips line codes and give errors.
The weird thing is that if i shift+enter line by line in 2011 it works, but
it doesn’t if i run the whole thing…

one of the skipped lines is :

WM3_MC_BuildFromNode orig.morpher 1 targ

What changed from 2009 to 2011???

6 Replies

Shift+Enter lines evaluates them in global scope. So if you have variable scoping issues (either orig or targ could be undefined in the active scope), evaluating line by line circumvents the problem by making them all global. Thus it is not a solution if that was the problem.

Posting the actual error message would be useful. Posting some actual code even more.

Heya Bobo!
This is the code working ok on 2009 but failing on 2011
the error is:

– Error occurred in crea.pressed(); filename: C:\Scripts\morphs simetricos UI.ms; position: 910; line: 32
– Frame:
>> MAXScript Rollout Handler Exception: – Unknown system exception <<

The problem is that the script skips the line where the morph slot 1 is set with a target.

–> WM3_MC_BuildFromNode orig.morpher 1 targ

but shfting+enter (global scope) works

the strangest is this 2009-2011 compatibility.
Any clue?

P.S.- I know the script is pretty crude (it doesn’t filter valid selections, etc, but
selecting valid selections should work on 2011 as it does on 2009)

rollout TheTool "" width:160 height:144
(
	global Orig,Targ
	button crea "CREATE" pos:[32,104] width:96 height:24
	pickbutton but_ori "<<PICK Original>>" pos:[16,32] width:128 height:24
	pickbutton but_tar "<< PICK Target>>" pos:[16,64] width:128 height:24
	label lbl1 "Morph Mirror Tool" pos:[16,8] width:136 height:16
	
	on crea pressed do
	(
		max create mode
		Orig.position = [0,0,0]
		Targ.position = [0,0,0]
		converttomesh Orig
		converttomesh Targ
		addmodifier Orig (morpher())
		select orig
		WM3_MC_BuildFromNode orig.morpher 1 targ -- skips this none!
		delete targ
		targ = copy orig
		converttomesh Targ
		select targ
		addmodifier Targ (skin_wrap())
		Targ.skin_wrap.engine = 0 
		Targ.skin_wrap.falloff= 0.001 
		select orig
		addmodifier orig (mirror()) 
		orig.mirror.mirror_axis = 0 
		select targ
		targ.skin_wrap.meshlist = #(orig) 
		select orig
		orig.morpher[1].value = 100
		converttomesh Targ
		delete orig
		targ.name = "The Mirrored"
	)
	on but_ori picked obj do ( but_ori.text = obj.name;  Orig = copy obj )
	
	on but_tar picked obj do ( but_tar.text = obj.name; Targ = copy obj ) 
)

createdialog TheTool

You should have started with the fact it was an “Unknown System Exception”.
That means you did nothing wrong (and explains why it was working in 2009). Unknown System Exception usually means a memory violation or something else bad going on deep in Max and not really in your script. It is possible something was broken in the Morpher support in 2011.

Unfortunately I don’t have access to a 2011 build right now and cannot test/look for workarounds.
As a shot in the dark, try changing the first line of the code to ‘max modify mode’ and see if it makes any difference in 2011. It is possible that the morpher is not initializing correctly if the Create tab is active in the Command Panel.

wow! you rock bobo

The modify trick did the job.
I also had to change the line where i select the orig for set it blend to 100 for
select the targ so this way the skin wrap updates…the other way it doesn’t.

Works perfect now. The performance is obviously a lot slower because all the refreshes
in the modify panel but it works. Now i’ll try to set all the filters and prevents for the
script working as it should in the cases of wrong picks, etc.

You did it again. Thank you!

I feel really good because I was flying blind (it works in 2010 too).

You could try to keep the max create mode in the beginning, switch to max modify mode before the command is called and then if it worked, switch back to create mode for the rest to speed it up again.
Not sure if it will work or not, but it is worth trying…

Great idea. Speed improved