Alternative to usersetup.mel in Maya modules

Hi everyone!

Yesterday I learned that there is another way of executing scripts on start-up besides usersetup.py and usersetup.mel. If you create a Maya Module (for example “TestModule”) and add a mel file in the scripts folder caller “_load.mel” (so “TestModule_load.mel”) it will be execute as on start-up like a usersetup.mel. The Maya BonusTools work that way. I did not find any documentation on that, so I thought I’d share it here and see if anybody else has seen this or might have more info on that.
I already posted this in the Tech-Artist Slack channel and we found that this might be a potential security issue. So I’d thought to post it here as well so it gets some exposure.

Cheers,
Fabian

PS: If that would be an official documented feature I would actually kinda like it, since it would not interfere with the usersetup.mel and would make more sense naming wise inside a Maya module.

4 Likes

Maya modules are the main way that packages (like bonus tools, Bifrost, so many…) are distributed, since each one can have it’s own unique userSetup.mel/.py that don’t conflict with any others.

It’s how I manage my studio’s Maya tools, and makes it easy to fold in anything else from the internets / other studios.

Official Maya docs:
https://help.autodesk.com/view/MAYAUL/2019/ENU/?guid=__developer_Maya_SDK_MERGED_Distributing_Maya_Plug_ins_Maya_module_paths_folders_and_html

I have notes on them here:
http://mayamel.tiddlyspot.com/#[[Understanding%20Maya%20Modules%20and%20Pacakges]]

3 Likes

I think the main purpose of the post was to inform about the seemingly undocumented “feature” of Maya modules to execute a file matching the module_name + _load.mel on startup as userSetup does.
This could be important for security features for example.

3 Likes

Yeah, as someone who has been using maya modules to package up studio code since forever, I had no idea this feature existed.

1 Like

I think the main purpose of the post was to inform about the seemingly undocumented “feature” of Maya modules to execute a file matching the module_name + _load.mel on startup as userSetup does.
This could be important for security features for example.

LOL, I totally missed that: I think I read ‘Maya Module’ (instead of mel script), and my brain went that direction.

I learned something today too! :slight_smile:

1 Like

Hehe, I totally understand :slight_smile:

Some casual testing here suggests that maya 2022+ may be disabling separate userSetups in modules but the xxx_load.py method still works. Not sure how to interpret this but worth knowing.

Moreover the xxx_load.py mehod bypasses the userSetup checksum test: In this example I changed both a userSetup.py (which did not actually execute!) and a xxx_load.py (which did) and the security message only caught the first:

image

2 Likes

As it turns out this functionality was added by Autodesk to support the Autodesk Apps store. Read more about this in the follow blog post: Distributing plug-ins/files on Maya (and 3ds Max) - Around the Corner
This also explains why I found this in the Maya Bonus Tools, since that is distributed via the App store.

1 Like

_ From slack, for archival purposes_

2 Likes