Skip to content
Benjamin Nelson DeMann edited this page Aug 24, 2017 · 3 revisions

Basic Overview of the Tools and How to Create Them

Maya

All of the Maya tools are located in maya-tools/. When project_maya.sh launches Maya, Maya will look in the maya-tools/shelf/shelf.json for how to make the Maya shelf for the BYU tools.

To add a tool to Maya:

  1. Add an icon in the shelf/icons directory. It will need to be a 33x33 .xpm icon file.
    • The light-gray for the icon image is 0x969696
    • The dark gray for the icon background is 0x343434
  2. Add a python script into the shelf/scripts directory.
    • Follow the examples of other scripts. The inspire_quote.py demonstrates a fairly simple script that can be used as a starting point.
    • The most important thing is that you have a go() function. This is what the shelf tool in Maya will call when the user pressed the button.
  3. Follow the pattern in shelf.json to add another button to the shelf. Make sure to add the path to your icon and script into the new button. Most unfortunately Maya needs to be restarted every time you change your script. So have fun with that!

Houdini

For Houdini the shelf is make by houdini-tools/toolbar/byu_tools.shelf. Each tool has it's own shelf folder in that directory.

To add a tool to Houdini:

  1. Write a python script for your tool and save it in houdini-tools/
  2. Make your_tool.shelf file following the examples of the other .shelf files. This file should reference the script you made.
  3. Add <memberTool name="your_tool"/> to byu_tools.shelf.

Mari

Overview

Menu Creation and Manipulation

In the mari-tools directory there is an init.py file and a menu.py file. I presume that both of them are called on start up. However I can't figure out what the init.py is supposed to be doing and it seems to have no effect. I assume that it would make a shelf and some tools in that shelf. But I can't find where it it putting it or even if it is putting it somewhere. For right now I have been just making a menu for all of the tools because it is dead simple.

If you head over to menu.py you will find where we make the menu. First you import the module you need. Next you create a button for it using the mari.actions.create(name, script) function. You can do anything for the script but for the sake of consistency with Maya we have elected to have a go() function that will run the script. Finally you add the button to the menu you use the mari.menus.addAction(button, path/to/the/menu_item). If you are putting the tool into the BYU Tools menu then the path is "MainWindow/&BYU Tools/Your Tool Name." Make sure you have and ampersand before BYU; this allows users to press Alt+B to pull up the menu. And putting it before the Y would make the shortcut be Alt+Y. It's kind of a fun trick. It's all pretty straight forward once you get into the menu.py.

Make a Mari Tool

Now as for making tools for Mari, it's kind of annoying. They have some pretty good documentation but I have found it difficult to navigate. And the scripting window leaves some things to be desired. But it's manageable. To make matters worse searching for examples on Google yields few results. Here is the work flow that I have found to be most helpful.

The first thing to keep in mind is that Mari works differently then all the other software we use. The idea of having a file that you are working from is mostly none existant. All of the projects exist kind of ethereally in the Mari cache. And so when you are scripting you have access to all of the projects that are currently loaded into the user's Mari cache. As far as moving projects around (as for checkout and publish) you can export a project and it will give you a bunch of folders. Or you can archive the project which just give you an mra (Mari Archive) file. This option seemed neater so we use archives.

Script Examples in the Documentation

Next we dig into the documentation. If you click on the Python menu and then click on Documentation it will open up a browser and give you the documentation. Amoung the first few things in the table of contents are some mari.examples. These are really helpful. If you look back in Mari in the Python menu under the examples sub menu you will find all of the examples that you can run and see how they are supposed to look. You can then dig through the source code by looking in Python->Examples->Open Examples Folder or if you look at one of the mari.examples in the documentation then you should be able to find a link to the source code for each example. If you can find an example that is doing kind of what you want then you can copy and tweak it. Not too bad.

Python Console

The Python console is a little annoying to use but its essential to figuring out how the mari module works. One of the great things it has is that it can bring up all of the functions that you can call on a variable. So if you can get to an object then the Python Console can help you see what all of the functions are or what type it is. Before jumping into a the .py file for a script I like getting a good proof of concept in the console since it's pretty good at helping me see all of my options.

It can also help you get further into the documentation. For example you will see a lot in the example mari.projects or mari.geo and if you don't know what those are you can do type(mari.projects) into the Python Console and it will tell you that mari.projects is a ProjectManager and mari.geo is a GeoManager. You can then look in the documentation for more info on that class. I have found this to be a good method for quickly finding the class and therefore the documentation entry for an unfamiliar class. If you dig around the documentation long enough I'm sure you would find it in there but with no search feature it's a little hard to figure out where things are at first glance, especially if you are just starting off in Python.

Making Your Tools

From here it should be pretty straight forward to make a new tool for Mari. Just save your script into the mari-tools/scripts directory and Mari will have it loaded in and ready to import and use.

Nuke

Nuke will use nuke-tools/menu.py to generate the menu for the BYU-tools.

To add a tool to Nuke:

  1. Make a 33x33 .svg icon and add it to nuke-tools/icons/
  2. Make a python script and add it to nuke-tools/scripts/
  3. In menu.py add m.addCommand("Your Tool", 'yourScript.go()', icon="yourIcon.xpm")

Project Browser

The Project Browser give a way to easily create and manage all of the assets. Here you can make assignments and set due dates.