beuzel
January 12, 2011, 9:34am
1
Hello,
Maya provides transformation information of an object as Transform Attributes with Translate, Rotate and Scale vectors. What I need is the Matrix. Is there any way do display the transformation/rotation matrix for the selected object?
Any help welcome Chris
joojaa
January 12, 2011, 9:39am
2
yes, the data can be querried with getattr and xform.
beuzel
January 12, 2011, 11:55am
3
Hi, Thanks, this prints out a formatted output of the selected object(s):
global proc printMatrix()
{
// get all selected objects
string $sel[] = `ls -sl -l`;
for($obj in $sel)
{
// get object matrix, alternatively use "xform -q -m"
float $matrix[] = `getAttr $obj.matrix`;
print("matrix for '" + $obj + "':\n");
// write matrix to script editor
for ($i=0; $i<16; $i++)
{
// limit to 4 digits after comma
$value = (int)($matrix[$i] * 10000.0) / 10000.0;
// equalize string length
string $valueStr = (string)$value;
int $len = size($valueStr);
do
{
$valueStr = " " + $valueStr;
}
while (size($valueStr) < 8);
print($valueStr);
print(" ");
// line break after 4 values
if ($i % 4 == 3)
{
print("\n");
}
}
}
}
Chris