// =========================================================================== // 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. // =========================================================================== global proc int poseInterpolatorImportPoses(string $filePath, int $shape) { if (endsWith($filePath, ".pose") == 0) { string $warningMessage = getPluginResource("poseInterpolator", "kNotAPoseFile"); $warningMessage = `format -stringArg $filePath $warningMessage`; warning ($warningMessage); return -1; } if ($shape) { // Import shape files first before import poseInterpolator file. // to clear the selection list in the scene, // since blendShape cmd is based on selection, if there are objects selected, // which will be used as base and target shapes and these selected objects // may not be our expected bases. select -cl; string $inFolderName = dirname($filePath); string $inFileBaseName = basename($filePath, ".pose"); string $bsFilePattern = $inFileBaseName + ".*.shp"; string $bsFiles[] = `getFileList -folder $inFolderName -fs $bsFilePattern`; $inFolderName = fromNativePath($inFolderName); for ($bsFile in $bsFiles) { // one blendShape exported file contains only one blendShape // to get the blendShape node name $bsName = stringRemovePrefix($bsFile, $inFileBaseName); $bsName = stringRemovePrefix($bsName, "."); $bsName = basename($bsName, ".shp"); if (endsWith($inFolderName, "/")) $bsFile = $inFolderName + $bsFile; else $bsFile = $inFolderName + "/" + $bsFile; // check if there is a blendShape node in the scene // having the same name, if (objExists($bsName)) { // edit mode, to edit this node without creating a new one. blendShape -edit -import $bsFile $bsName; } else { // create mode, it creates new blendShape node. blendShape -import $bsFile -name $bsName; int $wc = `blendShape -q -wc $bsName`; if ($wc == 0) { // fail to import tgt. string $attrDFO = $bsName + ".dfo"; int $dfo = `getAttr $attrDFO`; delete $bsName; if ($dfo == 0) { blendShape -before -import $bsFile -name $bsName; } else { blendShape -frontOfChain -import $bsFile -name $bsName; } } } } } // TODO: one problem found is that // this scrip will return and end, no poseInterpolator importing will even begin. // when blendShape command fail for whatever reason. // import the poseInterpolators and their poses. poseInterpolator -im $filePath; return 1; }