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.
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.
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 email@example.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.