Relation, A Look Into Maya’s Connections

In Maya, and almost every other 3d application, tremendous needs for a true, smooth and quick connections could be always felt. In Maya, regardless of its company (Autodesk), since brains are individual and group people and not the brand behind it, these needs are highly responded. One can smoothly saunter through its relative places. In this article I’m going to explore some of its features in bringing forth various instruments to pace out the process.

 

A. Introduction

B. Methods and Instruments

1. Expressions

2. Maya Embedded Language

3. Connection Editor

4. Hyper Shade

5. Constraints

6. Key Frames

C. Unwrap The Engine

 

Maya, let’s relate it to its history (of course I don’t mean Maya Civilization which was invaded aggressively centuries ago), has mainly three head categories for its connecting workflow.

The first one, if broadly name it, slips into language. Linguistic approach that you have through Maya’s options. Two vastly used parts are active within this single field. Expression and MEL. Expression, and offspring of MEL, not exactly the same, but using its rule, and the MEL itself which stands for Maya Embedded Language. Second category belongs to GUI. Connection Editor and Hypershade are in this group. The third group includes Constraint and Set Driven Key Frames, in this group simple keyframing is also exisiting. But I’m not going to talk about it, since it could be explained within Driven Key Frames. This third category, also, relates to GUI, but it differs also from the task-related view.

Expression are highly satisfying when you’ll use them. according to Maya’s own Help documentation, Expressions are:

You can use an expression to animate any keyable, unlocked object attribute for any frame range. You can also use an expression to control per particle or per object attributes. Per particle attributes control each particle of a particle object individually. Per object attributes control all particles of a particle object collectively. ( User Guide > Scripting > MEL and Expressions > Animation expressions > )

 

However this definition may not be adequate for its full understanding, but let’s give you an example. If you have a sphere called “ball” and a cube which is called “cube”, and you want to move cube in X  axis whenever balls moves in Y axis. With following line, added to expression attribute of “cube.tx” you can achieve this effect.

cube.tx = ball.ty;

Expressions also are of high importance, since as you see in previous paragraph, you mention the name of the attribute which means you have a direct and immediate access to it without any specific command needed to be used. Follwing definition can tell you how MEL relates into Maya:

The entire Maya graphical user interface (GUI) is written and controlled using MEL, the Maya Embedded Language. The creation, editing, and deletion of all the graphical user interface elements is done using the MEL language. It then follows that you too can control the Maya interface by using MEL. In fact you can entirely replace the standard Maya interface by using your own MEL scripts. There is often a need for specialized customization of parts of Maya’s interface. For instance, you may want to develop a particular interface that allows animators to set keys without their having to learn the Channel Box or other Graph Editor. You can also hide or remove a lot of the Maya interface elements to reduce the complexity of the interface for certain users (Gould, 2).

 

It’s very easy to work with MEL, it allows you to connect many attributes once to many other attributes. To give you an instance, assume that there are fifty objects, and you need to connect their scale to fifty locators. How much time would be consumed using the regular process of connecting them? If you use MEL you can quickly finalize you process. Let’s say that if you want to uncover how fast it would be, or how faster, you first need to examine the whole process. Connection of fifty plus fifty other object which end up in one hundred hungry object for connection is not a quick-be-done task. Nevertheless, MEL, being handy and capable, decrease the time you need to spend upon it.

In  MEL, you need to call for an attribute, a job which you would not need to employ in Expressions. For instance, you want to connect sphere.scaleZ to locator.translateY; this script is what you need:

//

connectAttr sphere.scaleZ locator.translateY;

//

However if you want to get their attributes for whatever you purpose might be, you need:

//

getAttr sphere.scaleZ;

//

As I have already mentioned, MEL is the most reliable friend in Maya’s environment whom you can trust always. Fifty objects example can recall you how fast it would be. MEL, because of its alliterative likeness with Maya, retrospectively remembers me of Indian Ethical Civilization and Development.

Connection Editor, is a window where you can connect attributes using a GUI. According to Maya’s documentation, Connection Editor is:

The Connection Editor provides node network information in a side-by-side layout where you can view two connected nodes in a node network. This editor is useful for fine-tuning a shading network.  You can quickly and easily traverse from node to node and show a node’s outputs or inputs to facilitate connections, meaning you can make connections in either direction in a node network.

Connection Editor is also useful for animation, and rigging process. It allows you to connect the attribute easily, and its advantage is that you can select amongst many different attributes that you have. You can access this window under the menu Window, and then General Editor, Connection Editor. But as the documentation has already mentioned, it’s great for shading network in Maya.

Constraints are an animation tool which help you connect object’s position, rotation and scale most notably. there are other constraint options such as Pole Vector which is used in cooperation with IK Handle. I don’t want to make details about them, but to give about them an overall explanation. For instance, Point Constraint deals with positional attributes. If you parent constraint object A to object B, the movement of the object A forces the object B to move with. It has options which can give you offset, and also it has an option for each parent node, weight attribute. If you enter the value 0.5 into weight field, with every unit movement of the object A, object B will move half-unit. And if you change it to 0.25, with every unit movement of the object A, object B will move four times slower than object A. Constraint are inevitably used in every serious workflow, they are great. However, simultaneously, with  pointConstrainting object A to B, and weighting it  0.25, we can equalize it within Expression:

objectA.translateX = objectB.translateX * .25;

Here we can see the interconnection of the Maya’s various abilities, such as what we see in equalization of the Constraint using Expressions.

The last part deals with Key Framing. It connects an attribute to a relative change of it during the time within the Time Line. Set Driven Key is another type of Key Framing, but not in accordance with another attribute and not the time. For instance you connect objectA.tx to objectB.ty, and key it with both attributes set to 0. The you set objectA.tx to 10 and objectB.ty to 50, and again key it. This makes the objectB to move 5 unit with one unit movement of objectA. Again you can see that programming it with both MEL and Expression is possible.

In what I have written, the attempt was to uncover a very small part of Maya without tending to be cliche about explanations. Pictures are not used, since I aimed a theoretical representation of content.

 

Maya’s Documentation

Gould, David. Complete Maya Programming: An Extensive Guide to MEL and C++

Mostafa Talebi

mostafatalebi@rocketmail.com

Set Driven Keyframes in Maya

(High Quality) (1600 * 900)
In this lesson, I will present you two Set Driven Keyframes in two different ways.
You can also take a look at my article at side section of the blog, under the Article category to read an article which is called “Relations, A look into Maya’s connection workflow.”
You can Download the text file here

Download the MT Set Driven Keyframes Here

Download MT Parenting Facilitator Here

Introducing Set Driven Key Frames in Maya

In this tutorial I will examine how Set Driven Key Frames in Maya works, and basically, for people who are not familiar with the task, provide them with an example to learn it.

You can download the text file here

You can download the MT Set Driven Keyframes Plugin Here

and Download the MT Parenting Facilitator Here

artixel.wordpress.com

mostafatalebi@rocketmail.com

Tips: Use an if-statement before UI creation

Hello everybody. Today I’m going you to share with you a tips about writing UI in MEL.

 

When you write an UI in MEL, and let’s say, you add a button to the window, and eventually execute it, your UI, if there be no syntactical mistake, will pop up. Then you need to add another button, regularly you close the window and add your textual line and rerun the script.

If you don’t close your window, and apply changes and call your script for an execution, you will see an error which reads:

// Error: line 1: Object’s name ‘testWindow’ is not unique. //

This error is very common that sometime it might transform your health into a headache.

The most common interlude of this error is in non-displayed windows. What do I mean?

If you execute the following code, your window will not popup, while the declaration of the window has happened, and only the button creation has encountered a problem, a syntactical problem.Try this code:

//

window -t “This is a test window” testWindow;

button testButton -w 100; // Note that this line is syntactically wrong, and errs.

showWindow mm;

//

In our button line, the second line is meant, we have made a wrong syntax which is unknown to Maya; therefore, Maya doesn’t understand it and breaks the execution process, which will result in no displaying of the UI.

But Maya has made a space in his memory allocation, and registered there a window with the node’s name “testWindow which will collide with recreation of the same window having the same name applied, if you change the name of your window everything calms down and your process comes routine, but is it really possible each time you change your window node’s name?

If you tell Maya if such name already exists, please delete, and the naturally Maya if the case be true will do that.

//

if (`window -exists testWindow`)

{

deleteUI testWindow;

}

//

Just place this script before any window declaration in any script, and then change the name in conditional statement to your window’s name.

our script will look like this:

if (`window -exists testWindow`)

{

deleteUI testWindow;

}

window -t “This is a test window” testWindow;

button testButton -w 100; // Note that this line is syntactically wrong, and errs.

showWindow testWindow;

//

 

 

I hope this tip come to be useful.

mostafatalebi@rocketmail.com

artixel.wordpress.com

The Assignment Statement and Variable

The Assignment Statement

An assignment statement is most important element is the singular equal sign = . After evaluation of an assignment statement, the variable on the left side of the equal sign is set to the value on the right side. Assignment is not limited to being used during declaration. In fact, we are able to set the value of a variable at anytime after declaration and can do so repeatedly. Whenever possible, reuse variables to save on memory usage, seen in Example 4.10.

Example 4.10: Re-declaring a variable value.

    float $tempFloat = 3.48;
    $tempFloat = 3.21212;

Note that when we reassign a new value to the variable $tempFloat, we do not re-declare its type as a float.

The humble assignment statement is the basis for all data gathering within MEL. In Chapter 3, MEL Basics, we learned that most commands contain an aspect called a return value . By putting a MEL command on the right side of the = in an assignment statement, we can capture that return value and assign it to a variable. In order to capture the return value, we enclose the command within single left-hand quotes (`). In Example 4.11, we capture the value of the translate X value of an object called ball, and store that value in a float variable called $translateX.

Example 4.11: Capturing the value returned by the getAttr statement.

    float $translateX = `getAttr ball.translateX` ;

When we use an assignment statement to capture the return value of a command, it is important to assign it to a variable that can actually hold that data. For many beginning scripters, the most frustrating aspect of this comes with array variables when they want to catch only one item. A perfect example is building a selection list when we have only one object selected, seen in Example 4.12.

Example 4.12: Attempting to assign captured data to the wrong type of variable.

    string $object = `ls selected` ;
//ERROR : Cannot cast data of type string[] to string.

The command ls always returns a string array, even if that array is empty or has just one object in it. Data return types for each command can be found within the documentation for that command.

 

Source:

http://flylib.com/books/en/3.244.1.17/1/