and simple solution to reuse a script, both a Mel or Python script is to place them on a shelf in Maya. You might additionally make variations of a script and put all variations on a shelf in Maya. The principle purpose is while you want a selected script to run, you don’t want the additional time to find it in your laborious drive and run it. You might try this, the straightforward approach, with only one click on, which is to place it on a shelf.
Moreover, since Maya utility runs fully with Mel scripting, you might additionally put each single command that Maya runs or a mix of them on a shelf, for straightforward entry. When you discover for instance that you simply use, like rather a lot, the command: delete historical past, freeze remodel, middle to pivot while you engaged on the modeling course of, you might put all three instructions as one as a Mel script on a shelf in Maya, and reuse it with only one click on.
As you in all probability think about, the time you’re going to save for doing that, it’s is dependent upon your workflow and your wants.
On this article we’re going to discover methods to:
- put a script on Maya shelf
- put variations of a script as a separate command on a shelf in Maya
- combining single instructions as one piece of script and put it on a shelf in Maya
We’re going to use for example a free Python script that it’s generates auto management rig to your chosen joints. You might obtain the Python script from the earlier hyperlink.
Put a script on a shelf in Maya:
So we’ve loaded this superior Python script inside Script Editor in Maya.
To place that script on a shelf:
- a method is to simply spotlight all of the traces of the script within the Script Editor, both by dragging a variety from the left higher nook to the proper down nook or by urgent ctrl + A to robotically choose the entire line of Python codes for you.
- After you spotlight the entire script in Script Editor, drag and drop it into any shelf in Maya.
- Maya with a popup window asks you, what kind of script is that. On this case, is a Python script. So, click on on the Python script choice.
After that, the script has been added to your chosen shelf.
For group functions, it’s a great time to rename your new script on that shelf, so afterward you may determine it simply.
To rename the script icon:
- right-click on the brand new script icon and from the brand new drop-down menu select to edit. The Shelf Editor window seems.
- go to the Cabinets tab and within the part Icon Label put a reputation to your script.
- Click on on the save all cabinets within the left decrease nook to shut the home windows, and is all good to go.
Be aware: You might additionally create an icon and join it with that script (within the icon identify part – Shelf Editor – Cabinets tab). So, it could be extra recognizable for future use.
Put variations of script on a shelf in Maya:
Earlier than we really make variations of this script and put them as a separate script on a shelf, it’s actually essential to know that the script actually does, proper!
This script creates computerized controllers to your chosen joints in Maya and makes the required constrain connection between the joints and the controller. In Maya, there are a lot of kinds of constraints, comparable to a guardian, level, orient, and so forth. If you’re not fairly conversant in constraints in Maya, you may go to the official Autodesk web site for additional info relating to this particular topic.
So, it’s fairly logical if we wish the variation of this script to occur on the constraint kind, proper! It might be on different elements as effectively. However let’s maintain it easy, and simply make the variation of the script occur on the constraints degree solely.
Be aware: in case you are considering how this particular script works, as I’ve already talked about you may go to the auto management rig to your chosen joints for extra info.
Variation of the script:
Let’s say for instance we wish three variations of this particular script on the constrained kind:
- guardian constrain
- level constrain
- orient constrain
The way in which to try this is to vary every time the kind of constraint after which put it on the shelf.
So, on this script, I’ve to vary the final line of code which is, cmds.parentConstraint(ctrl, s, mo=0), for guardian constrain go away it that approach. Spotlight all of the script and drag and drop it on a shelf (rename it correctly, one thing like: C_parent). For level constrain can be: cmds.pointConstraint(ctrl, s, mo=0) and for orient constrain can be: cmds.orientConstraint(ctrl, s, mo=0) accordingly.
#create controls
"""
How you can use:
1. Choose all of the joints you need to add controls to, and execute the script.
"""
import maya.cmds as cmds
sl = cmds.ls(sl=1)
for s in sl:
ctrlName = s.exchange("_jnt", "_ctrl")
ctrl = cmds.circle( nr=(0, 1, 0), r=3, n=ctrlName)[0]
group = cmds.group(ctrl, n=ctrl + "_auto")
offset = cmds.group(group, n=ctrl + "_offset")
cmds.parentConstraint(s, offset, mo=0)
cmds.delete(cmds.parentConstraint(s, offset))
cmds.parentConstraint(ctrl, s, mo=0)
Now each time we need to use a particular kind of constraint for this script, we simply should click on on the particular variation of the script we’ve simply created and put it on the shelf in Maya.
Combining single instructions as one piece of script and placing it on a shelf in Maya:
As I’ve already talked about, Maya runs fully with Mel scripting. Meaning each command in Maya is a Mel script and you’ll confirm it, by opening the Script Editor and operating random instructions in Maya. You’ll discover, Maya interprets these instructions as Mel scripting.
Within the modeling course of in Maya, I discovered myself utilizing these three instructions (delete historical past, freeze remodel, middle to pivot) on a regular basis. Let’s mix the three instructions to be one piece of script and put it on a shelf.
Open up Script Editor, and press all these three instructions (icons) one after the other. The outcome will probably be Maya decoding these instructions as a Mel script. Every line of code, it’s just about self-explanatory, of what it does, proper! Spotlight and duplicate the primary three traces of code and paste them within the Mel part down under.
After that, as soon as once more spotlight these three instructions from the part down under and drag and drop them on a shelf, to create the brand new mixed Mel script command. Congratulation you have got mixed three instructions as one via Mel scripting.