MEL:
global proc VRaySubdivisionTool(){
if(`window -exists VRaySubdivisionToolUI`){
deleteUI VRaySubdivisionToolUI;
}
window -wh 100 75 -rtf 1 -mxb 0 -title "VraySubTool" VRaySubdivisionToolUI;
columnLayout mainCol;
formLayout -w 150 -h 75 mainForm;
text -l "VRay Subdivision Tool v1.0" mainText;
separator -w 140 topSep;
text -label "Max Subdivisions" intText;
intField -w 55 -value 2 -min 1 -max 50 subCall;
button -label "apply" -w 150 -command vraySmooth procButton;
formLayout -e
-ap mainText "left" 8 0
-ap mainText "top" 5 0
-ap topSep "left" 5 0
-ac topSep "top" 5 mainText
-ap intText "left" 5 0
-ac intText "top" 5 topSep
-ac subCall "left" 5 intText
-ac subCall "top" 2 topSep
-ac procButton "top" 5 subCall
mainForm;
showWindow VRaySubdivisionToolUI;
}
////////////////////////////////////
global proc vraySmooth(){
//Put selected objects transform and shape nodes into arrays
string $a[] = `ls-sl`;
string $y[] = `listRelatives -typ "shape"`;
//define an integer marker to represent array index item
int $x=0;
//query user input from UI
int $subCallValue = `intField -q -v subCall`;
//add subdivision and subdivision quality attributes to each selected obbject
for($each in $a){
vray addAttributesFromGroup (("|"+$a[$x])+("|"+ $y[$x])) vray_subdivision 1;
vrayAddAttr (("|"+$a[$x])+("|"+ $y[$x])) vraySubdivEnable;vrayAddAttr (("|"+$a[$x])+("|"+ $y[$x])) vraySubdivUVsAtBorders;vrayAddAttr (("|"+$a[$x])+("|"+ $y[$x])) vraySubdivUVs;vrayAddAttr (("|"+$a[$x])+("|"+ $y[$x])) vrayStaticSubdiv;
setUITemplate -pst attributeEditorTemplate;
vray addAttributesFromGroup (("|"+$a[$x])+("|"+ $y[$x])) vray_subquality 1;
vrayAddAttr (("|"+$a[$x])+("|"+ $y[$x])) vrayOverrideGlobalSubQual;vrayAddAttr (("|"+$a[$x])+("|"+ $y[$x])) vrayViewDep;vrayAddAttr (("|"+$a[$x])+("|"+ $y[$x])) vrayEdgeLength;vrayAddAttr (("|"+$a[$x])+("|"+ $y[$x])) vrayMaxSubdivs;
setUITemplate -pst attributeEditorTemplate;
// set max subdivisions.
setAttr (($y[$x])+".vrayMaxSubdivs") $subCallValue;
// bump up index marker
$x++;
}}
运行:
VRaySubdivisionTool;
coolOωO
angelina