Home Technical Talk

Maya Interactive Boolean Tool - Exposing Maya's Procedural Booleans

polycounter lvl 3
Offline / Send Message
Pinned
Sean_P polycounter lvl 3
Hey guys, after seeing a thread about revealing the input object for a Boolean in Maya, i realised that Maya had procedural Booleans under the hood (athough not 100% bulletproof).  So I went to work making a script that i would love to use, and that others could use.

This script doesn't add any new functionality to Maya it just exposes existing functionality and makes it easier to use.


Tips and tricks:

Select an object to toggle it's visibility if you accidently deselect the object, select nothing and hit toggle visibility to make everything visible again.

If there are ngons and quadify is pressed, it will only affect the ngons, if there aren't and ngons it will affect the whole mesh.

Quadify with apply a triangulation and then a quadrangulate , this can be used during the Boolean operations but to avoid bugs, best to use at the end.

If you extrude a face on the object you are using to cut/intersect/combine the geometry will disappear until you move the face, then it will come back.

When using Union the cage is harder to select and not that visible because the object is still there i find it easier to select the object and then use shift select the get the cage and deselect the object.

The Boolean objects will not render in the scene only the geometry created.





I have created two different types of interfaces, one horizontal display window and a vertical display window.  Just copy and paste the preferred into a shelf button and it's all yours, alternatively you can copy for single click and the other for double click.

Horizontal Window Layout


$window = `window -title "Interactive Bool Tool" -s off -widthHeight 320 95 -tb on -mnb off -mxb off <br>-tlc 185 310`;<br>//moditfy the values for flag -tlc to change where the window is located<br><br>//window setup<br>&nbsp;&nbsp;&nbsp;&nbsp; formLayout -numberOfDivisions 55 myForm;<br>&nbsp;&nbsp;&nbsp;&nbsp; string $command = ("deleteUI " + $window);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iconTextButton -h 55 -w&nbsp; 100 -style "iconAndTextVertical" -i1 "polyBooleansDifference.png" -label "Difference" -bgc .3 .3 .3 -command "DiffComm" myBtn1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iconTextButton -h 55 -w&nbsp; 100 -style "iconAndTextVertical" -i1 "polyBooleansIntersection.png"&nbsp; -label "Intersection" -bgc .3 .3 .3 -command "InterComm" myBtn2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iconTextButton -h 55 -w&nbsp; 100 -style "iconAndTextVertical" -i1 "polyBooleansUnion.png" -label "Union" -command "UnioComm" -bgc .3 .3 .3 myBtn3;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iconTextButton -h 25 -w&nbsp; 155 -style "iconAndTextHorizontal" -i1 "WireFrame.png"-label "Toggle Visibility" -bgc .3 .3 .3&nbsp; -command "VisTogCom" myBtn4;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iconTextButton -h 25 -w&nbsp; 150 -style "iconAndTextHorizontal" -i1 "polyQuad.png" -label "Quadify" -bgc .3 .3 .3 -command "TriQuad" myBtn5;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; formLayout -edit<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn1 "top" 5&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn1 "left" 5<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn2 "top" 5<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn2 "left" 110<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn3 "top" 5<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn3 "left" 215<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn4 "top" 65&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn4 "left" 160<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn5 "top" 65&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn5 "left" 5<br><br>&nbsp;&nbsp;&nbsp;&nbsp; myForm;&nbsp; <br>&nbsp;showWindow;<br><br><br>//difference procedure<br>proc DiffComm () {<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; string $selection[] = `ls -os`;<br>&nbsp;&nbsp;&nbsp; //calculate size of selection for loop operation below<br>&nbsp;&nbsp;&nbsp; int $selectionsize = `size($selection)`;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //boolean operation<br>&nbsp;&nbsp;&nbsp; polyCBoolOp -op 2 -ch 1 -preserveColor 0 -classification 1 -name $selection[0];<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //loop that goes through the objects used to cut into geometry and change <br>&nbsp;&nbsp;&nbsp; //attributes so they are visible<br>&nbsp;&nbsp;&nbsp; for($L = 1; $L < $selectionsize; $L++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string $getshape[] = `ls -dag $selection[$L]`;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //these are the attributes which reveal the geometry<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[1]+".visibility") 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".intermediateObject") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //these settings make the object a wireframe<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideEnabled") 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideShading") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //this setting removes the boolean objects from rendering in the scene<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".primaryVisibility") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //this sets the color index value of the wireframe, change the colours here if you want<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideColor") 21;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>}<br><br>//intersection procedure<br>proc InterComm () {<br>&nbsp;&nbsp;&nbsp; string $selection[] = `ls -os`;<br>&nbsp;&nbsp;&nbsp; int $selectionsize = `size($selection)`;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; polyCBoolOp -op 3 -ch 1 -preserveColor 0 -classification 1 -name $selection[0];<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //loop similar to the difference protocol although all objects will be effected <br>&nbsp;&nbsp;&nbsp; for($L = 0; $L < $selectionsize; $L++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string $getshape[] = `ls -dag $selection[$L]`;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[1]+".visibility") 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".intermediateObject") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideEnabled") 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideShading") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".primaryVisibility") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideColor") 18;<br>}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>}<br>//union<br>proc UnioComm () {<br>&nbsp;&nbsp;&nbsp; string $selection[] = `ls -os`;<br>&nbsp;&nbsp;&nbsp; int $selectionsize = `size($selection)`;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; polyCBoolOp -op 1 -ch 1 -preserveColor 0 -classification 1 -name $selection[0];<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; for($L = 0; $L < $selectionsize; $L++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string $getshape[] = `ls -dag $selection[$L]`;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[1]+".visibility") 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".intermediateObject") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideEnabled") 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideShading") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".primaryVisibility") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideColor") 16;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>}<br><br><br>//toggle visibility<br>proc VisTogCom () {<br>&nbsp;&nbsp;&nbsp; string $selection[] = `ls -os`;<br>&nbsp;&nbsp;&nbsp; int $selectionsize = `size($selection)`;<br>&nbsp;&nbsp;&nbsp; string $listofobjectsinscene[] =`ls -g`;<br>&nbsp;&nbsp;&nbsp; int $selectionsize2 = `size($listofobjectsinscene)`;<br>&nbsp;&nbsp;&nbsp; //an if statement for if nothing is selected to make all visible<br>&nbsp;&nbsp;&nbsp; if ($selection[0]==""){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for($Lo = 0; $Lo < $selectionsize2; $Lo++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($listofobjectsinscene[$Lo]+".visibility") 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp; <br>}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //a loop to toggle visibility for selected<br>&nbsp;&nbsp;&nbsp; for($L = 0; $L < $selectionsize; $L++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string $getshape[] = `ls -dag $selection[$L]`;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int $checkforvis = `getAttr ($getshape[1]+".visibility")`;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($checkforvis==1){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[1]+".visibility") 0;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($checkforvis==0){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[1]+".visibility") 1;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br>}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>}&nbsp;&nbsp; <br><br><br><br><br>proc TriQuad () {<br>&nbsp;&nbsp;&nbsp; //a procedure that checks if there are ngons and will try to turn them into quads otherwise will turn the whole mesh into quads<br>&nbsp;&nbsp;&nbsp; string $reselect[] =`ls -sl`;<br>&nbsp;&nbsp;&nbsp; string $ngonq[] = `polyCleanupArgList 3 { "0","2","0","0","1","0","0","0","0","1e-005","0","1e-005","0","1e-005","0","1","1" }`;<br>&nbsp;&nbsp;&nbsp; int $selectionsize = `size($ngonq)`;<br>&nbsp;&nbsp;&nbsp; if ($selectionsize==0){<br>&nbsp;&nbsp;&nbsp; select -r $reselect[0] ;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; polyTriangulate -ch 1;<br>&nbsp;&nbsp;&nbsp; polyQuad&nbsp; -a 30 -kgb 1 -ktb 1 -khe 1 -ws 1 -ch 1;<br>&nbsp;&nbsp;&nbsp; select -r $reselect[0] ; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>}


Vertical Window Layout


$window = `window -title "IBT" -s off -widthHeight 120 280 -tbm on -mnb off -mxb off <br>-tlc 280 50 `;<br>//moditfy the values for flag -tlc to change where the window is located<br>//window setup<br>&nbsp;&nbsp;&nbsp;&nbsp; formLayout -numberOfDivisions 55 myForm;<br>&nbsp;&nbsp;&nbsp;&nbsp; string $command = ("deleteUI " + $window);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iconTextButton -h 55 -w&nbsp; 110 -style "iconAndTextVertical" -i1 "polyBooleansDifference.png" -label "Difference" -bgc .3 .3 .3 -command "DiffComm" myBtn1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iconTextButton -h 55 -w&nbsp; 110 -style "iconAndTextVertical" -i1 "polyBooleansIntersection.png"&nbsp; -label "Intersection" -bgc .3 .3 .3 -command "InterComm" myBtn2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iconTextButton -h 55 -w&nbsp; 110 -style "iconAndTextVertical" -i1 "polyBooleansUnion.png" -label "Union" -command "UnioComm" -bgc .3 .3 .3 myBtn3;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iconTextButton -h 30 -w&nbsp; 110 -style "iconAndTextHorizontal" -i1 "polyQuad.png" -label "Quadify" -bgc .3 .3 .3 -command "TriQuad" myBtn4;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iconTextButton -h 55 -w&nbsp; 110 -style "iconAndTextVertical" -i1 "WireFrame.png"-label "Toggle Visibility" -bgc .3 .3 .3&nbsp; -command "VisTogCom" myBtn5;<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; formLayout -edit<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn1 "top" 5&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn1 "left" 5<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn2 "top" 65<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn2 "left" 5<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn3 "top" 125<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn3 "left" 5<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn4 "top" 185&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn4 "left" 5<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn5 "top" 220&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -attachForm myBtn5 "left" 5<br><br>&nbsp;&nbsp;&nbsp;&nbsp; myForm;&nbsp; <br>&nbsp;showWindow;<br><br>//difference procedure<br>proc DiffComm () {<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; string $selection[] = `ls -os`;<br>&nbsp;&nbsp;&nbsp; //calculate size of selection for loop operation below<br>&nbsp;&nbsp;&nbsp; int $selectionsize = `size($selection)`;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //boolean operation<br>&nbsp;&nbsp;&nbsp; polyCBoolOp -op 2 -ch 1 -preserveColor 0 -classification 1 -name $selection[0];<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //loop that goes through the objects used to cut into geometry and change <br>&nbsp;&nbsp;&nbsp; //attributes so they are visible<br>&nbsp;&nbsp;&nbsp; for($L = 1; $L < $selectionsize; $L++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string $getshape[] = `ls -dag $selection[$L]`;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //these are the attributes which reveal the geometry<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[1]+".visibility") 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".intermediateObject") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //these settings make the object a wireframe<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideEnabled") 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideShading") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //this setting removes the boolean objects from rendering in the scene<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".primaryVisibility") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //this sets the color index value of the wireframe, change the colours here if you want<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideColor") 21;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>}<br><br>//intersection procedure<br>proc InterComm () {<br>&nbsp;&nbsp;&nbsp; string $selection[] = `ls -os`;<br>&nbsp;&nbsp;&nbsp; int $selectionsize = `size($selection)`;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; polyCBoolOp -op 3 -ch 1 -preserveColor 0 -classification 1 -name $selection[0];<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; //loop similar to the difference protocol although all objects will be effected <br>&nbsp;&nbsp;&nbsp; for($L = 0; $L < $selectionsize; $L++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string $getshape[] = `ls -dag $selection[$L]`;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[1]+".visibility") 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".intermediateObject") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideEnabled") 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideShading") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".primaryVisibility") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideColor") 18;<br>}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>}<br>//union<br>proc UnioComm () {<br>&nbsp;&nbsp;&nbsp; string $selection[] = `ls -os`;<br>&nbsp;&nbsp;&nbsp; int $selectionsize = `size($selection)`;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; polyCBoolOp -op 1 -ch 1 -preserveColor 0 -classification 1 -name $selection[0];<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; for($L = 0; $L < $selectionsize; $L++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string $getshape[] = `ls -dag $selection[$L]`;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[1]+".visibility") 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".intermediateObject") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideEnabled") 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideShading") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".primaryVisibility") 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[2]+".overrideColor") 16;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>}<br><br><br>//toggle visibility<br>proc VisTogCom () {<br>&nbsp;&nbsp;&nbsp; string $selection[] = `ls -os`;<br>&nbsp;&nbsp;&nbsp; int $selectionsize = `size($selection)`;<br>&nbsp;&nbsp;&nbsp; string $listofobjectsinscene[] =`ls -g`;<br>&nbsp;&nbsp;&nbsp; int $selectionsize2 = `size($listofobjectsinscene)`;<br>&nbsp;&nbsp;&nbsp; //an if statement for if nothing is selected to make all visible<br>&nbsp;&nbsp;&nbsp; if ($selection[0]==""){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for($Lo = 0; $Lo < $selectionsize2; $Lo++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($listofobjectsinscene[$Lo]+".visibility") 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp; <br>}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //a loop to toggle visibility for selected<br>&nbsp;&nbsp;&nbsp; for($L = 0; $L < $selectionsize; $L++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string $getshape[] = `ls -dag $selection[$L]`;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int $checkforvis = `getAttr ($getshape[1]+".visibility")`;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($checkforvis==1){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[1]+".visibility") 0;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($checkforvis==0){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setAttr ($getshape[1]+".visibility") 1;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br>}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>}&nbsp;&nbsp; <br><br><br><br><br>proc TriQuad () {<br>&nbsp;&nbsp;&nbsp; //a procedure that checks if there are ngons and will try to turn them into quads otherwise will turn the whole mesh into quads<br>&nbsp;&nbsp;&nbsp; string $reselect[] =`ls -sl`;<br>&nbsp;&nbsp;&nbsp; string $ngonq[] = `polyCleanupArgList 3 { "0","2","0","0","1","0","0","0","0","1e-005","0","1e-005","0","1e-005","0","1","1" }`;<br>&nbsp;&nbsp;&nbsp; int $selectionsize = `size($ngonq)`;<br>&nbsp;&nbsp;&nbsp; if ($selectionsize==0){<br>&nbsp;&nbsp;&nbsp; select -r $reselect[0] ;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; polyTriangulate -ch 1;<br>&nbsp;&nbsp;&nbsp; polyQuad&nbsp; -a 30 -kgb 1 -ktb 1 -khe 1 -ws 1 -ch 1;<br>&nbsp;&nbsp;&nbsp; select -r $reselect[0] ; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>}









Replies

Sign In or Register to comment.