Notifications
Clear all

[Closed] macroscript icon

Hi. I have created a mzp package containing a macroscript, a scriptfile and the icon files. Installing the mzp works fine and the script can be used immediately. Unfortunately max doesn’t find the icon files until the next restart. So draging the macro onto a toolbar will produce an empty square button. I find this rather ugly. Is there a way to force max to reevaluate the ui/icons folder, or to tell my script to search for the icon itself? what is the correct workflow here? help appreciated.

5 Replies
colorMan.reinitIcons()

Thanks for the info Bobo. Very handy that this can be done without restarting 3ds max.

Is there a way of reloading macroscripts in a similar kind of way after installing one?

Example:
Install macroscript into maxRoot/UI/Macroscripts directory.
Somehow run the macroscript.
Macroscript is now available in customise>customise UI.

I have tried to do this with a fileIn, but it has a negative side effect of copying the macroscript to a new file in the userMacros directory. Is there any way around this? Ideally I’d like to be able to install a scripted tool with a macroscript for ui access and not require 3ds max to be restarted to see it in the customise ui options.

Thanks for any help.
Tim

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

There is a page in the Help discussing MacroScripts for New or Casual users. Read it!

The copying of the file to the userMacros folder is NOT a negative effect. It is the way it works! You should NEVER EVER put your scripts there, nor under ui/macroscripts. Max is supposed to manage these.

When you write your own MacroScript, store its definition in an .MS file somewhere else. When you press Ctrl+E or perform fileIn(), any MacroScript() definition in the .MS file will produce a new .MCR file with prefix the Category and suffix the Name of the script in the Usermacros folder. This ensures that next time you launch Max, the MCR files will be loaded at the right time during the booting process even if the .MS file is not loaded automatically. In fact, your .MS file should typically NOT be in a startup folder. Now if you want to update those .MCRs in the middle of the Max session, open the source .MS file from whatever non-startup folder you stored it in, make your changes and press Ctrl+E and your .MCRs will be updated again. NEVER edit the actual .MCRs in the Usermacros folder, because if you ever run the source .MS file again, they will be overwritten!
If you download a new version of the .MS source from the internet for example, running that file using MAXScript>Run Script, drag&drop into Max or filein() will also update the respective .MCR files it makes…

It might sound convoluted, but it works really well once you understand how it works.

BEWARE: If there is an error in your macroscript, MAXScript might open the .MCR file from Usermacros and not the real MS source. Be careful where you fix the error – if you fix it in the .MCR in Usermacros, the changes could be lost if you ever run the MS source again!

Also note that opening an shipping MacroScript (stored in ui\macroscripts) for editing will make a copy into \Usermacros because on Vista and Win7, the Program Files folders are locked for saving. Since Usermacros MCRs are loaded after the shipping macros, your modified copy will always override the shipping version.

Found it, there’s a huge amount of documentation on it that I somehow missed


macros.load()

Cheers

Thanks again Bobo. This all makes really good sense.

I do have one question though regarding installing/uninstalling custom tools written in maxscript.

When I drop a mzp into the viewport and press install from the UI it creates, it copies over a few .ms files. If I understand correctly I am meant to evaluate the macroscript instead of copying it over to usermacros? This will place the macroscript in the usermacros directory, and then that macroscript can be used to load any required scripts if it they have not been previously loaded.

When I drop the same mzp into the viewport and press uninstall from the UI, what is the best way to uninstall the mcr file that was previously created by the filein? Will it’s name always be consistent (ie category name then macroscript name) so I can find it via a doesFileExist string comparison?

Thanks for any help.
Tim