Maya plugin
Maya plugins are quite modular, and my favorite way of packaging Maya tools.
Pros¶
- Plugins manage their own startup code, allowing you to avoid using
userSetup.py, which always runs on startup. - Plugins can be enabled or disabled per user, letting you toggle the startup code more easily compared to Maya modules.
Cons¶
Maya plugins don’t support:
- A plugin can only be a single .py file, because the plugin folder is not in the Python path.
It can’t be a Python package, or a zip file.
If you want to include additional files, I recommend to distribute them as a Python module in the scripts folder, and import them from the plugin. You can also set them as a dependency, see Maya plugin template.
- There is no native support for dependencies on:
- other Maya plugins. (However using plugget this is possible)
- Python packages (a custom solution can be seen in Maya plugin template)
You can depend on another package, e.g. import numpy, but installing the plugin won’t auto install the numpy dependency.
Instead, you can use a Maya module to vendor multiple Maya plugins or python packages.
However, I recommend to not use more than 1 Maya module per project, and package your tools in plugins instead.
Notes¶
- Since plugins are not importable, they live in their own namespace, and can have the same name as a importable Python module
- Maya plugin path is not added to sys.path
- invalid plugins without a init plugin method still show up in the plugin manager
- You could release 1 plugin, and 1 folder to the plugin path. And then edit
sys.pathto import the folder. But you might as well put that folder inscriptsinstead.
ideally a plugin is self contained
- it adds itself to the menu
- since a plugin is a single file, it aims to avoids dependencies that don’t ship with Maya for easy manual install.
but if we write more complex python code this is not reasonable, e.g. pymel, numpy, …
Extend ideas¶
- how to handle plugin dependencies?
- if you depend on other plugins, you can use run_after_load / deferred load to ensure they are available?
- TODO sample
Low prio¶
- how to control startup load order of plugins
Maya - how to enable-disable plugins
Backlinks¶
- Maya tool
- see Maya plugin
- Maya module
- Maya quick launcher
- Distributing plug-ins & files on Maya (and 3ds Max) - 2013
- Maya plugin template
- usersetup
- [!warning]
- Plugins are more modular than modules
- A cleaner solution is to package your tool in a Maya plugin using the Maya plugin template. It’s more modular, can be enabled/disabled per user in Maya unlike Maya modules. And dependencies can be pip installed, so you can keep them up to date, and avoid duplication.
- Maya run on startup
- various solutions to run code on Maya startup
- a Maya plugin can auto load on startup, which then runs the plugin code.
- Maya created controls - dev log
- But I realize I have 2 files, and a Maya plugin only supports a single Python file.
I use my Maya module template to make a new repo.
- But I realize I have 2 files, and a Maya plugin only supports a single Python file.
- Maya Pip Qt plugin
- A Maya plugin to add pip qt to the menu.
- Pyblish Maya plugin
- Maya ApplicationPackage startup code
- my Maya projects
- see Maya tool and Maya plugin
- Maya module manager
- Maya Simple exporter
