unitCorrection Node

Contents


User's Guide

A number of Maya's nodes contain incorrectly typed attributes. For example, the arcLength attribute of the arcLengthDimension node is a double when it should really be doubleLinear because it is a measure of distance.

These broken attributes generally have no effect on your scene so long as you continue to work in Maya's default units. However, as soon as you switch to non-default units (for example, using feet as your linear units instead of centimeters) then they can start causing problems because Maya ends up doing the wrong unit conversions on them. (For more information on how unit conversion works in Maya, see the attached essay.)

The unitCorrection node provides a way of correcting for these errors by converting the type of an attribute without changing its value. By comparison, Maya's unitConversion node changes the value according to a calculated conversion factor for the two types.

How you use the unitCorrection node depends upon whether you are reading from or writing to the broken attribute. If you are reading, then you connect the broken attribute to the unitCorrection node's input attribute which has the closest type to that of the broken attribute. You then read the value from the unitCorrection node's output attribute which has the closest type to that which the broken attribute should have.

Conversely, if you are writing to the broken attribute, then you connect it to the output attribute which most closely matches its type, then write values to the unitCorrection node's input attribute which most closely matches the type that the broken attribute should be.

For example, let's say that you want to connect an arcLengthDimension node's arcLength attribute to a sphere's rotateX. If you just do the connection straight up, then Maya will insert a unitConversion node into the connection to convert from double to doubleAngle. If your preferred linear units are set to anything other than centimeters, this will produce an incorrect result.

To avoid this problem, you first connect the arcLength attribute to the doubleIn attribute of a unitCorrection node (because the arcLength is incorrectly defined to be double), then connect the unitCorrection node's linearOut attribute to the sphere's rotateX (because arcLength should be defined to be doubleLinear).

    sphere;
    // Result: nurbsSphere1 makeNurbSphere1 //

    createNode -name "arc1" arcLengthDimension;
    // Result: arc1 //

    createNode unitCorrection;
    // Result: unitCorrection1 //

    connectAttr arc1.arcLength unitCorrection1.doubleIn;
    connectAttr unitCorrection1.linearOut nurbsSphere1.rotateX;

Note that in the example above we connected the sphere's rotateX to the unitCorrection node's linearOut attribute, even though rotateX is an angular value. This is because the output attribute must be selected based on the type that arcLength should have been, regardless of where we subsequently send that value. Since arcLength should have been typed as doubleLinear, we connected to the linearOut attribute. Maya will then insert a unitConversion node in that connection to convert the doubleLinear value to a doubleAngle value and this conversion will produce correct results no matter what your preferred linear or angular units are set to.

Time

The internal units used by Maya for time are not available from within MEL or the API, so the unitCorrection node uses milliseconds (i.e. thousandths of a second). For example, if your current frame rate is 24fps then a time value of 24 would represent one second, or 1,000 milliseconds. So if you set a unitCorrection node's timeIn attribute to 24, you would see a value of 1000 appear on its doubleOut attribute.


Attribute Reference

attribute editor

Long (Short) Name Type Default
Value
Description
inputType (it) enum Connected (0) When converting input values to output values, the unitCorrection node can only work with a single input value. This attribute tells the node which input value to use.

Valid values are:

AE Name Value Description
Connected 0 Takes the value from whichever of the input attributes has an incoming connection. If more than one input attribute has an incoming connection, the behaviour is undefined (i.e. don't do it!).
Note that this setting corresponds to the unitCorrection node's normal behaviour prior to version 1.1.
Angle 1 Takes the value from the angleIn attribute.
Linear 2 Takes the value from the linearIn attribute.
Time 3 Takes the value from the timeIn attribute.
Double 4 Takes the value from the doubleIn attribute.

angleIn (ai) doubleAngle 0.0 If you want to read a value from a broken attribute and it is defined to be an angular type, connect the broken attribute to angleIn, then read the value from the appropriate Out attribute.

If you want to write a new value to a broken attribute and it should be defined as an angular type, connect the appropriate Out attribute to the broken attribute then write the new value to angleIn.

linearIn (li) doubleLinear 0.0 If you want to read a value from a broken attribute and it is defined to be a linear type, connect the broken attribute to linearIn, then read the value from the appropriate Out attribute.

If you want to write a new value to a broken attribute and it should be defined as a linear type, connect the appropriate Out attribute to the broken attribute then write the new value to linearIn.

timeIn (ti) time 0.0 If you want to read a value from a broken attribute and it is defined to be a time type, connect the broken attribute to timeIn, then read the value from the appropriate Out attribute.

If you want to write a new value to a broken attribute and it should be defined as a time type, connect the appropriate Out attribute to the broken attribute then write the new value to timeIn.

doubleIn (di) double 0.0 If you want to read a value from a broken attribute and it is defined to be a unitless type (double, integer, enum, etc), connect the broken attribute to doubleIn, then read the value from the appropriate Out attribute.

If you want to write a new value to a broken attribute and it should be defined as a unitless type, connect the appropriate Out attribute to the broken attribute then write the new value to doubleIn.

angleOut (ao) doubleAngle 0.0 If you want to write a new value to a broken attribute and it is defined to be an angular type, connect angleOut to the broken attribute then write the new value to the appropriate In attribute.

If you want to read a value from a broken attribute and it should be defined as an angular type, connect the broken attribute to the appropriate In attribute and read the value from angleOut.

linearOut (lo) doubleLinear 0.0 If you want to write a new value to a broken attribute and it is defined to be a linear type, connect linearOut to the broken attribute then write the new value to the appropriate In attribute.

If you want to read a value from a broken attribute and it should be defined as a linear type, connect the broken attribute to the appropriate In attribute and read the value from linearOut.

timeOut (to) time 0.0 If you want to write a new value to a broken attribute and it is defined to be a time type, connect timeOut to the broken attribute then write the new value to the appropriate In attribute.

If you want to read a value from a broken attribute and it should be defined as a time type, connect the broken attribute to the appropriate In attribute and read the value from timeOut.

doubleOut (do) double 0.0 If you want to write a new value to a broken attribute and it is defined to be a unitless type (double, integer, enum, etc), connect doubleOut to the broken attribute then write the new value to the appropriate In attribute.

If you want to read a value from a broken attribute and it should be defined as a unitless type, connect the broken attribute to the appropriate In attribute and read the value from doubleOut.


Support & Copyright Information

The unitCorrection node and its associated materials, which are collectively referred to as "this product", are copyright Gooroos Software, 1999-2004.

Gooroos Software provides this product as-is and assumes no liability for its use. You may freely redistribute it, but only in complete and unmodified form.

If you have any questions or problems with this product, please send email to support@gooroos.com. Because this product is made freely available, we cannot guarantee you a response, but we will try to get back to you as time permits.

For more information on Gooroos Software and our other products, please visit our web-site at www.gooroos.com.


Downloads

Plugin
Version
Maya
Version
Platform Size
1.2.36.5 (beta)Linux 27K Download
1.2.36.5 (beta)WinXP 505K Download
1.2.36.0Linux 27K Download
1.2.36.0WinXP 505K Download
1.2.35.0Linux 27K Download
1.2.35.0Win2000 277K Download
1.2.24.5Linux 71K Download
1.2.24.5Win2000 269K Download

Installation Instructions

Return to Products