[Closed] MacroScript Compile error when starting max
Hi there.
Here is the deal.
I’ve made a mapping tool which is meant to be run from the Mapping menu of the Edit UVWs dialog. The macroscript is bundled in an .mzp file, along with an install.ms script and an mzp.run file.
mzp.run first copies the macro to the usermacros folder and then tells max to run install.ms.
install.ms evaluates the macro, so max is aware of its existence, and creates an entry for it in the appropriate menu.
And that’s it.
This was written and tested (very extensively) on max 9 without any error showing up.
I had some people test it on other versions and some of them had one or both of the following problems.
1st problem:
Sometimes the .mzp file needs to be dropped twice in order for the tool to be installed.
This is bugging me but I can live with it.
2nd problem, which worries me a lot more:
After installing the macro and checking that it ran correctly (which it did), some people have an error popping up every time they restart max. It says MAXScript MacroScript Compile –, followed by the path to the macro, followed by ‘,offset 0; Exception: – Unknown system exception. But still after that, the tool would run just fine. Which makes me wonder. How can max fail to compile the macro but still execute it correctly?
Once the macro is deleted (and the menu entry removed) the error disappears and everything is back to normal.
I’ve been trying to figure this out for more than two weeks now and I must say that I’m at my wits’ end. This is especially difficult to solve since it runs smoothly on my machine.
If some of you could try it and have a look, it would help me a lot.
(you might need to change the extension of the attached file back to .mzp)
Thanks in advance for your time and help.
you have to check that the currently open modpanel object is UVW unwrap modifier before using its interface functions:
on isEnabled do
(
local theObj = selection[1]
local theMod = modPanel.getCurrentObject()
if not iskindof theMod UVWunwrap or theMod.getTVSubObjectMode() != 3 do return false
...
Denis, I’m not sure I’m following.
If it’s the first evaluation of the macro (during installation), install.ms does just that: it creates a temporary editable mesh, adds an unwrap to it, selects it and makes sure that the command panel is the modify panel. And then it evaluates the macro. Otherwise I get an error and the macro is not ‘registered’, which would prevent it from being added to the menu. And that’s not the case.
If it’s after the first installation, the only way to run the macro is from the Edit UVWs dialog. So obviously there is an object selected with an unwrap modifier on it and the modify panel is open.
In all cases the tool works fine. It’s just that error that shows up at startup. And that only on some installations. And even then, as I said in my first post, the tool is there and works fine. For the major part of the people who tried it, no error occurs. It just happens in a few cases and I’m trying to figure out why and what makes it happen.
Did you install it or look at the code?
But maybe I’m not understanding what you’re saying or I didn’t explain the problem well enough.
I have not installed or read the code, but I can say I’ve had similar problems which involved the heap size. try to print a heapsize on startup (before the script runs) and see if the troublesome machines have considerably less memory than the working machines. If necessary you can increase the heap before the script runs (i.e. heapsize+=10000000).
Then again, this may not be the problem at all…
I will definitely try that (I’m ready to try anything at his point)! Thanks Io.
But shouldn’t the error be ‘out of memory’ or something similar, intead of ‘macroscript compile, unknown exception’?
Nope. Setting the default heap size higher didn’t solve the problem.
Any other idea, people?
And how about the 1st problem, the need to drop the .mzp twice?
It’s the exact same file than the one I’ve attached.
Nothing’s encrypted.
why do you create temp mesh and add unwrap? just copy macros, execute it, and createActionItem if it’s necessary (don’t forget menuMan.updateMenuBar()).
If you copy the macro and run it without having an object selected with an unwrap on it, you get an error. Try it.
The menuMan part is not the issue since the menu is registered correctly (see first post).
And why would I want to update the menu bar? The macro is ‘run from the Mapping menu of the Edit UVWs dialog’ (first post again).
The issue is not something that is not working. Everything works fine for all of the 15 or so guys who installed it. But two of them get the error I described at startup.
They do not get the error instead of the macro working.
They get the error and, after clicking the OK button, the macro works fine.
It’s that error I’m trying to identify and get rid of.
it’s why you have to fix the macros code. (see my post above)
on isEnabled do
(
local theObj = selection[1]
local theMod = modPanel.getCurrentObject()
if not iskindof theMod UVWUnwrap or theMod.getTVSubObjectMode() != 3 do return false
... )--end on isEnabled
on execute do
(
rollout rltStraightenUVstrip "Straighten UV Strip"
(
checkBox cbAvU "Average Us"
checkBox cbAvV "Average Vs" across:2
button btnOk "OK" width:90 align:#right
checkBox cbNorm "Normalize" across:2
button btnCancel "Cancel" width:90 align:#right
local theObj
local theMod = modPanel.getCurrentObject()
...
local setpos = if iskindof theMod UVWUnwrap do theMod.setVertexPosition
-- map channel in current unwrap modifier
local mCh = if iskindof theMod UVWUnwrap do theMod.getMapChannel()
...