buttonized macroscripts not recognizing defined functions

buttonized macroscripts not recognizing defined functions

kolsen
Advocate Advocate
1,153 Views
2 Replies
Message 1 of 3

buttonized macroscripts not recognizing defined functions

kolsen
Advocate
Advocate

Greetings. I'm developing a series of macro-scriptized steps for solving a problem, and I've hit a wall.

 

Here's the sitch:

I've written a bunch of functions, and I have about 20 functions spread over 4 scripts.

When I run the scripts the functions are listed in the listener, and I can type in any function name in the listener and it works.

Instead of typing in function names, I wrote single-line, temporary scripts that just call the functions. For example:  do_function().

I dragged and dropped each function call to a button, and then I just clicked the button any time I wanted to do a do_function().

It worked fine yesterday, but today, after moving some files around, the system... she no work no more.

 

I had edited the categories of all the resulting MacroScripts and saved them all in the active project folder in a new folder called userMacros. I did a setDir so the MacroScripts would be found. They're found, and I laid them out nicely in a toolbar. BUT, after I run the four scripts that define the functions, when I press the do_function button it throws a messagebox error, and the listener says that do_function is undefined. There is one button that works... it just has the single line clearlistener() in it.  

 

Is it unacceptable to have macroscripts out of the AppData folder? I move around from computer to computer a lot, and it would nice to have portable macroscripts with the project they're needed for.

 

I'm flummoxed, but learning.  Thanks for any help.

 

0 Likes
Accepted solutions (1)
1,154 Views
2 Replies
Replies (2)
Message 2 of 3

kolsen
Advocate
Advocate
Accepted solution

I opened up all the stored single-line do_function() macroscripts in the editor and ran Evaluate All on each of them and now everything's working.

 

That's a relief.

0 Likes
Message 3 of 3

Swordslayer
Advisor
Advisor

If you have a shared library of functions, it should be in a separate file that gets evaluated before any of the macros, i.e. a good place for it is the stdscripts folder (see maxscript reference for details). You don't want to have to evaluate all the files every time you restart max.

0 Likes