// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // Procedure Name: // doExportAtom // // Description: // This mel script is used to export a .atom file and optionally // an offline (.editMA) file containing animation and other drivers // of selected objects in the scene. // // Input Arguments: // $version: The version of this option box. Used to know how to // interpret the $args array. Currently supported versions are: // Version 1: Maya 2013 // $options[0]: .atom file name // // global proc doExportAtom(int $version, string $options[]) { string $filename = $options[0]; // Enable file command support for channels, constraints and // expressions so that the file command does not temporarily // disconnect them (even if we do not export them, we may want to // bake them) // int $chnlOpt = `file -q -chn`; int $conOpt = `file -q -constraints`; int $expOpt = `file -q -expressions`; file -chn 1; file -constraints 1; file -expressions 1; // Check whether we should create an offline file to store // constraints or setDrivenKey info // int $sdk = exportAnimGetSDK(); int $con = exportAnimGetConstraint(); int $history = exportAnimGetHistory(); string $exportEditsFile; if ($sdk || $con) { int $hierarchy = exportAnimGetHierarchy(); string $sel[]; if ($hierarchy) { $sel = `ls -sl`; select -hierarchy; } if ($con) { // deselect constraints or they won't be exported if (!$hierarchy) $sel = `ls -sl`; select -d `ls -sl -type constraint`; } $exportEditsFile = dirname($filename); $exportEditsFile += ("/" + basename($filename,".atom")); $exportEditsFile += ".editMA"; string $exportCmd = ("exportEdits -f -type \"editMA\" -selected "); if ($sdk) { $exportCmd += ("-includeSetDrivenKeys "); } if ($con) { $exportCmd += ("-includeConstraints "); } $exportCmd += ("\""+$exportEditsFile+"\""); if (catchQuiet(`eval $exportCmd`)) { $exportEditsFile = ""; } if ($hierarchy || $con) { // Restore the selection // select -r $sel; } } // Generate the export atom command // string $cmd = "file -force -options \"precision=8"; if (size($exportEditsFile) > 0) { $cmd += (";exportEdits="+$exportEditsFile); } if (! `exists animExportGetCommand`) { source "exportAnimSharedOptions"; } $cmd += animExportGetCommand(); $cmd += ("\" -ch "+$history+" "); $cmd += "-typ \"atomExport\" -es "; $cmd += ("\""+$filename+"\""); evalEcho $cmd; // Restore the file options to their previous values // file -chn $chnlOpt; file -constraints $conOpt; file -expressions $expOpt; }