Notifications
Clear all

[Closed] Can I evaluate MacroScripts on Max Startup?

I think I’ve got a problem with my macro script, or the way my Macro Script is set up. Here is what happening, I have a set of Structures that I’ve built that are assigned as Global Variables, each Struct has a Show function to display a tool set coded with DotNet. Each MyGlobalStructure.show() is call when the MacroScript is run from a toolbar button.

All the Structure scripts are stored in the Scripts>startup folder so they evaluated while 3D Studio Max is loading, the MacroScripts are stored in the usermacros folder.

My issue is that when I restart Max, and click on the MacroScript button from a toolbar, I get:


-- Error occurred in execute(); filename: C:\Users\**********\AppData\Local\Autodesk\3dsMax\2015 - 64bit\ENU\usermacros\MyMacroScript.mcr; position: 192; line: 9
--  Frame:
--   MyGlobalStructure: undefined
--   called in anonymous codeblock
--  Frame:
>> MAXScript MacroScript Error Exception:
-- Unknown property: "show" in undefined <<

The MacroScript is simple:


macroScript MyMacroScript
category:"Category"
ToolTip:"ToolTip"
buttontext:"ButtonText"

(	
	on execute do
	(
		MyGlobalStructure.show()
	)
)

I can type ‘MyGlobalStructure.show()’ into the maxscript listener and it works flawlessly, but not when i use the MacroScript Button. If i evaluate the MacroScript after i restart Max everything works great, but i can’t ask all the artists to evaluate the Macros every time they restart Max.

How do i get the MacroScript to call a function stored in a Global Structure without having to evaluate the Macro every time 3Ds Max loads?

5 Replies

Hi,

Are you actually creating a new struct before that macroscript is being called? there are docs in max that show what order the folders are searched and therefore the files get read in.

I guess im asking where the MyGlobalStructure is being stored and created?

The other option is read in the files yourself from a single “startup” script which is the more common (i believe) way of doing ot because you can guarantee the fileIn order.

Hi broomy,

All the global structures are stored under user>scripts>startup so they evaluate first, I can call each structure without any issue from the command line, they load and talk back and forth just fine.

The Macros are all stored under the user>usermacros folder, Max sees them all and loads them all, but for some odd reason the macro doesn’t run the one line of code to show the plugins that are built using structures.

Everything is being stored under the user directory and in the correct folder according to the 3ds max help documents.

The one execute function is the only function in all the macos, and it’s just to run the show function in my plugins.

Hope that makes since.

Hmmm

A little hard to understand but looking at your first post again try adding

If MyGlobalStructure == undefined then
(
    MyGlobalStructure = MyGlobalStructureStruct() -- or whatever you struct is called
    Print "something ain't right, instanciating struct"
)

In the on execute scope, should make it work but its not great

one other random thought, your struct is a maxscript struct?

Macroscripts are evaluated before startup scripts. See the Startup Scripts topic section of maxscript reference. The Structs have to go to the stdscripts folder.

Sorry for the long delay in responding, but I did manage to figure out how to get my MaxScript Structs to load before the Macros load by creating a new folder under the UserScripts directory, then adding that folder to the System Paths, 3rd Party Plug-Ins. Once set, Max now finds and evaluates all the Struts in the folder I created prior to loading the Macros.


setINISetting ((pathConfig.getDir #MaxData)+”Plugin.UserSettings.ini”) “Directories” “My Key String” ((pathConfig.getDir #userScripts)+”\\MyFolder”)