如何在Maya中获取关键帧的精确数值而非近似值?
Quick Fix: Use the -precision Flag
The default behavior of the keyframe command in MEL rounds output values to two decimal places, which is why you're seeing 2385.11 instead of the full 2385.11010742. To get the unrounded precise value, add the -precision flag and specify a sufficient number of decimal places (like 10, which covers most floating-point precision needs in Maya):
keyframe -q -vc -precision 10 Camera0Node.translateX
This will output the full precision value directly, no rounding applied.
Alternative: Get Values via getAttr at Keyframe Times
If you need more control (like processing multiple keyframes), you can first fetch the keyframe times, then query the attribute's value at each time using getAttr—which returns the raw, unformatted numerical value:
// Retrieve all keyframe times for the attribute float $keyTimes[] = `keyframe -q -tc Camera0Node.translateX`; // Loop through each time and get the precise value for ($time in $keyTimes) { currentTime $time; float $preciseValue = `getAttr Camera0Node.translateX`; print("Keyframe at time " + $time + ": " + $preciseValue + "\n"); }
This method is great if you need to work with each keyframe individually, as it bypasses the keyframe command's default formatting entirely.
内容的提问来源于stack exchange,提问作者William Eguienta

