-
Notifications
You must be signed in to change notification settings - Fork 4
Create Project Specific Maya Tools Scripts
There may be times where you want to add a project-specific script to your Maya project shelf. This is easy to do, but you'll need three things:
- The .py script
- An icon for the script
- A JSON file that references your created scripts
Let's start with the .py script. This can be anything you want your custom tool to do when clicked, including, but not limited to, DCCPipe functions. For example, refer to input_tool.py below:
from pipe.gui import quick_dialogs as qd
def run():
input = qd.input("Say hi!")
qd.info("You said: " + str(input))
This script will request user input when clicked, and output the string in a DCCPipe window. Note that the body of the script is within a function. It is essential that your script is within a function, although you can name it whatever you want.
Next, you'll need an icon. Below is a sample icon called test.png that I am using in this demo:
Finally, you'll need the JSON file so that DCCPipe knows you've added tools and loads those tools for you. Create a file called maya_scripts.json. Copy and paste the JSON below into your file:
{
"scripts": [
{
"name":"customTool",
"description":"This is what my custom tool does",
"icon":"test.png",
"label":"cust",
"function":"input_tool.run()"
}
]
}
Refer to the following guide for changing the second column of the JSON file:
- name: The name of your tool
- description: A description of your tool
- icon: The icon to use in the shelf for your tool
- label: The short string (<8 characters) to overlay on the icon in the shelf. Can be blank.
- function: The name of your python script and main function. e.g.: name_of_script_file.main_function()
If you want to add additional tools, follow the example below:
"scripts": [
{
"name":"customTool",
"description":"This is what my custom tool does",
"icon":"test.png",
"label":"cust",
"function":"input_tool.run()"
},
{
"name":"customTool2",
"description":"This is what my custom tool 2 does",
"icon":"test2.png",
"label":"cust2",
"function":"input_tool2.run()"
}
]
Now that you have your script, icon and JSON file, place all three in the tools directory of your production folder: dccpipe/production/tools/
Now, next time you start up Maya, your scripts will load in as part of the shelf as well.
See pages to the right for more docs.