// =========================================================================== // 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. // =========================================================================== // // Description: // This is a helper script to load fur plugin if not loaded yet. // global proc int furLoadPlugin() { string $soPath, $soName; $soPath = "Fur.so"; $soName = "Fur.so"; if( !`pluginInfo -q -l $soName` ) { if (catch(`loadPlugin $soPath`)) return 0; } return 1; } // Description: // This is script to apply the predefined fur attribute presets. // global proc applyFurPreset(string $preset){ // user must have fur plugin loaded - load it if not (fur auto-loads if // the file requires the plugin so this command should also load it. if( !furLoadPlugin() ) { error ((uiRes("m_applyFurPreset.kFurLoadPluginFail"))); } // get installation path string $envPath = `getenv MAYA_LOCATION`; string $pathToPreset = ($envPath + "/presets/attrPresets/FurDescription/" + $preset + ".mel"); string $shapes[]; //bug 177108 Apply Fur Preset doesn't work on groups HfGetSelectedSurfaceShapes($shapes); // now we know we can return an error if (`size($shapes)` < 1){ error ((uiRes("m_applyFurPreset.kNothingSelected"))); } else{ HfCreateAndAssignHD 0; } for ($shape in $shapes){ // start to build the applyAttrPreset command string $applyAttrPresetCmd = "applyAttrPreset "; // assign new default fur descriptor select -replace $shape; string $testShape = $shape+".instObjGroups"; string $newFurDescription[] = `listConnections -source off -destination on -type FurDescription $testShape`; if (size($newFurDescription) > 0) { // Select the last created FurDescription string $furDescriptionName = $newFurDescription[size($newFurDescription)-1]; // Rename the furDescription with preset name. catch (`rename $furDescriptionName $preset`); $testShape = $shape+".instObjGroups"; $newFurDescription = `listConnections -source off -destination on -type FurDescription $testShape`; $furDescriptionName = $newFurDescription[size($newFurDescription)-1]; // We need to applyAttrPreset in evalDeferred mode otherwise it will create the // problems while undo operation. global string $furCommand = ""; $furCommand = "catch (`" + "applyAttrPreset " + $furDescriptionName + " \"" + $pathToPreset + "\" " + "1" + "`)"; //applyAttrPreset $newFurDescription[0] $pathToPreset 1; evalDeferred $furCommand; // select the fur description in case the user wants to tweak it select -replace $furDescriptionName ; // Rename furFeedback with preset name. string $furFeedbackNode = HfGetFurFeedbackNode($shape, $furDescriptionName); string $parent[] =`listRelatives -parent -path $furFeedbackNode`; string $parentFurNode; if ( size($parent) == 1 ) { $parentFurNode = $parent[0]; } else { $parentFurNode = ""; } if ($parentFurNode != "") { rename $parentFurNode ($preset + "_FurFeedback"); } } } }