Monday, November 29, 2021

User Set Up Code

I learned about user set up scripts when I took my first python class in CGMA.  The very concept of what this script really does and how powerful it is went right over my head.  I was a total beginner at scripting at the time.  When I was at FIEA working on my very first artist proof tool, which was my controller generator tool, I wanted it to have it's own shelf and to be able to update every time I open maya.  With this in mind I went back to my CGMA class and looked at how a user set up code works and then I began making my own one.  

My user set up code is not a script I show in it's own demo reel since it is very much a back end pipeline script and it is something I want to continue to grow and add more custom tools and shelves.  The user set up script is multiple scripts working together to allow me to have the ability to:

  • Have my tools update every time I open Autodesk Maya
  • Create a custom shelf that I can store all my custom tools in
  • Create a drop down menu that I can use to also access different tools and keep my tools organized
  • Have tools not disappear when resetting maya preferences. 
  • Easy to update my scripts to add more custom shelves and drop down menu options
So what do my scripts do?  Well, this is a quick break down of what they do and how they talk to one another.  

Two of my scripts are in a folder that I keep in a safe place and I label it something so that others would know to not touch that folder.  The reason for this is because if that folder or any of the scripts in that folder are moved, the user set up code will break.  

Do Not Touch Folder

So what's in this folder?  This folder holds all my scripts for my custom tools.  Any tool that I create and want to add to my user set up code will be added to this folder.  My other script that is in this folder is my script that creates both my shelf and drop down menu.  It also checks to make sure that I don't have duplicate windows open in maya and it connects my custom tool to both the drop down menu and the shelf.  It also adds a custom icon for my tools.  

Gif of Autodesk Maya 2022 Custom Shelf and Drop Down Menu

So what is my other script?  The script that does the magic of bringing my tools, shelves, and drop down menus is the script called the userSetup.py.  This code is placed in the maya application folder in the script folder for version of maya currently being used.  This file needs to be called userSetup because maya will look for this name and bring all of my scripts into the program. The userSetup script I created looks for my folder my tools and menu scripts are in and creates a new environment variable.  It then imports my menu and shelf.

These series of scripts is something I want to work on more to add my new custom tools and continue to learn about scripting in maya. 

No comments:

Post a Comment

Scaling Your Controllers when they are Connected

 Sometimes when you are working on a rig, you may need to go back and adjust your controllers size a little bit.  This is possible without b...