// a function to be called when the button gets clicked.
proc highPolyPreview() {
string $sel[] = `ls -sl`;
string $shape[] = `listRelatives -type mesh $sel`;
int $currentCrease = `getAttr ($shape[0]+".smoothLevel")`;
// TURN ON
if ($currentCrease == 0 || $currentCrease == 2)
{
for ($i=0; $i<(size($shape)); $i++)
{
if ($sel[$i]==""){break;}
select $sel[$i];
polySelectConstraint -m 3 -t 0x8000 -sm 1; // to get hard edges
polyCrease -value 3.0;
displaySmoothness -divisionsU 3 -divisionsV 3 -pointsWire 16 -pointsShaded 4 -polygonObject 3;
setAttr ($shape[$i]+".smoothLevel") 4;
polySelectConstraint -sm 0; // turn off edge smoothness constraint
select $sel;
}
}
//TURN OFF
//Toggle off high poly preview
else
{
for ($i=0; $i<(size($shape)); $i++)
{
if ($sel[$i]==""){break;}
select $sel[$i];
displaySmoothness -divisionsU 0 -divisionsV 0 -pointsWire 4 -pointsShaded 1 -polygonObject 1;
PolyRemoveAllCrease;
setAttr ($shape[$i]+".smoothLevel") 2;
select $sel;
}
}
}
// a function to be called when the button gets clicked.
proc finalizeMesh() {
//EXPORT
file -force -options "v=0" -typ "mayaBinary" -pr -es "Documents/temp.mb";
string $sel[] = `ls -sl`;
for ($x in $sel)
{
select $x;
polySelectConstraint -m 3 -t 0x8000 -sm 1; // to get hard edges
polyBevel3 -fraction 0.5 -offsetAsFraction 1 -autoFit 1 -depth 1 -mitering 0 -miterAlong 0 -chamfer 0 -segments 1 -worldSpace 1 -smoothingAngle 30 -subdivideNgons 1 -mergeVertices 1 -mergeVertexTolerance 0.0001 -miteringAngle 180 -angleTolerance 180 ;
polySelectConstraint -sm 0; // turn off edge smoothness constraint
}
}
proc revertMesh() {
ls -sl;
delete;
ls -sl;
delete;
//IMPORT
file -import -type "mayaBinary" -rpr "temp" -options "v=0" -pr -loadReferenceDepth "all" "Documents/temp.mb";
}
// create a window
window;
if (`window -exists autoHighPoly`) deleteUI autoHighPoly;
window -title "autoHighPoly" -widthHeight 300 194 autoHighPoly;
if (`windowPref -exists autoHighPoly`) windowPref -remove autoHighPoly;
showWindow autoHighPoly;
// define the layout of controls added
// to the window.
columnLayout;
columnLayout -adjustableColumn true;
setParent ..;
columnLayout -h 62 -cat "both" 0 -cal "center" -cw 300;
// create a button
button -label "Preview" -h 60 -w 300 -command "highPolyPreview" ;
setParent ..;
columnLayout -h 62 -cat "both" 0 -cal "center" -cw 300;
// create a button
button -label "Finalize" -h 60 -w 300 -command "finalizeMesh" ;
setParent ..;
columnLayout -cat "both" 0 -cal "center" -cw 300;
// create a button
button -label "Revert " -h 60 -w 300 -command "revertMesh" ;
// show the window we last created
showWindow autoHighPoly;
Replies
(Max script)
But as a feedback when pressing finalize i am getting this error :
// Error: line 57: Invalid flag '-depth'
but thanks a lot for the script <span></span>
Code below.
// a function to be called when the button gets clicked.
proc highPolyPreview() {
string $sel[] = `ls -sl`;
string $shape[] = `listRelatives -type mesh $sel`;
int $currentCrease = `getAttr ($shape[0]+".smoothLevel")`;
// TURN ON
if ($currentCrease == 0 || $currentCrease == 2)
{
for ($i=0; $i<(size($shape)); $i++)
{
if ($sel[$i]==""){break;}
select $sel[$i];
polySelectConstraint -m 3 -t 0x8000 -sm 1; // to get hard edges
polyCrease -value 3.0;
displaySmoothness -divisionsU 3 -divisionsV 3 -pointsWire 16 -pointsShaded 4 -polygonObject 3;
setAttr ($shape[$i]+".smoothLevel") 4;
polySelectConstraint -sm 0; // turn off edge smoothness constraint
select $sel;
}
}
//TURN OFF
//Toggle off high poly preview
else
{
for ($i=0; $i<(size($shape)); $i++)
{
if ($sel[$i]==""){break;}
select $sel[$i];
displaySmoothness -divisionsU 0 -divisionsV 0 -pointsWire 4 -pointsShaded 1 -polygonObject 1;
PolyRemoveAllCrease;
setAttr ($shape[$i]+".smoothLevel") 2;
select $sel;
}
}
}
// a function to be called when the button gets clicked.
proc finalizeMesh() {
//EXPORT
file -force -options "v=0" -typ "mayaBinary" -pr -es "Documents/temp.mb";
string $sel[] = `ls -sl`;
polySelectConstraint -m 3 -t 0x8000 -sm 1; // to get hard edges
//polyBevel -fraction 0.5 -offsetAsFraction 1 -autoFit 1 -depth 1 -mitering 0 -miterAlong 0 -chamfer 0 -segments 1 -worldSpace 1 -smoothingAngle 30 -subdivideNgons 1 -mergeVertices 1 -mergeVertexTolerance 0.0001 -miteringAngle 180 -angleTolerance 180 ; NEW MAYA CALL, BELOW LINE IS OLD MAYA CALL
polyBevel -com 0 -fraction 0.5 -offsetAsFraction 1 -autoFit 1 -segments 1 -worldSpace 1 -uvAssignment 0 -smoothingAngle 30 -fillNgons 1 -mergeVertices 1 -mergeVertexTolerance 0.0001 -miteringAngle 180 -angleTolerance 180 -ch 1;
polySelectConstraint -sm 0; // turn off edge smoothness constraint
displaySmoothness -divisionsU 0 -divisionsV 0 -pointsWire 4 -pointsShaded 1 -polygonObject 1; //turning off smooth display function
polySoftEdge -a 180 -ch 1;
}
proc revertMesh() {
ls -sl;
delete;
ls -sl;
delete;
//IMPORT
file -import -type "mayaBinary" -rpr "temp" -options "v=0" -pr -loadReferenceDepth "all" "Documents/temp.mb";
}
// create a window
window;
if (`window -exists autoHighPoly`) deleteUI autoHighPoly;
window -title "autoHighPoly" -widthHeight 300 194 autoHighPoly;
if (`windowPref -exists autoHighPoly`) windowPref -remove autoHighPoly;
showWindow autoHighPoly;
// define the layout of controls added
// to the window.
columnLayout;
columnLayout -adjustableColumn true;
setParent ..;
columnLayout -h 62 -cat "both" 0 -cal "center" -cw 300;
// create a button
button -label "Preview" -h 60 -w 300 -command "highPolyPreview" ;
setParent ..;
columnLayout -h 62 -cat "both" 0 -cal "center" -cw 300;
// create a button
button -label "Finalize" -h 60 -w 300 -command "finalizeMesh" ;
setParent ..;
columnLayout -cat "both" 0 -cal "center" -cw 300;
// create a button
button -label "Revert " -h 60 -w 300 -command "revertMesh" ;
// show the window we last created
showWindow autoHighPoly;
Try this for finalizing multiple meshes:
This could be amazing.....if we had control over that.
Ideas?
Some feedback:
Issues
- Pressing 'Revert' on a 'Preview' mesh (that's not been 'Finalized') will cause problems.
- Pressing 'Revert' when 'Isolate Selection' is enabled: The reverted mesh will not be automatically loaded into the current isolated selection. The user will have to toggle out of isolate selection in order to see the mesh again.
Suggestions
- Make the 'Preview' button function even if the user is in component mode (automatically convert selection to mesh before running the 'Preview' operation?)
- Add 'Bevel Size' input setting to the UI
- Add 'Smooth Resolution' input setting to the UI (allow for control of smooth mesh divisons on finalized meshes)
- Add 'display hard edges colour' toggle button to the UI
Cheers
The bevel options are only available in maya 2016.5 or higher