Home Coding, Scripting, Shaders

Maya checker error Assigning default material #MEL

polycounter lvl 8
Offline / Send Message
Pinned
jayantbhatt007 polycounter lvl 8

Hi suppose in my scene I have 3 polycubes and I have assigned 3 different materials.

Polycube1 = Blue

Polycube2 = Red

Polycube3 = Green

 

Now  When I' assigned checker shader to my all polycube it's assigning but when I delete it, it's assigning the Maya default Lambert, not those blue, red and green shader which I previously assigned.

 

Shift + Left mouse button  and click on checker button it will tile the checker)

Alt + Left mouse button  and click on checker button it will delete the checker)

 

 

//Command starts from here

 

 

<p>string $window = `window -title "Long Name"<br>-iconName "Short Name"<br>-widthHeight 200 55`;<br>columnLayout -adjustableColumn true;<br>symbolButton -w 35 -h 55 -image "checker.svg" -c "Tiling()";<br><br>setParent ..;<br>showWindow $window;</p><p>//Checker Comand</p><p><br>global proc uvcheck(){</p><p><br>string $selectobj[]=`ls -sl`;<br>if(catch(`select "UV_Checker"`)){<br>string $localusername =`internalVar -userPrefDir`;<br>modelEditor -e -displayTextures true modelPanel4;<br>// Result: modelPanel4 //<br>updateModelPanelBar MayaWindow|formLayout1|viewPanes|modelPanel4|modelPanel4|modelPanel4;<br>modelEditor -edit -displayAppearance smoothShaded -activeOnly false modelPanel4;<br>// Result: modelPanel4 //<br>updateModelPanelBar MayaWindow|formLayout1|viewPanes|modelPanel4|modelPanel4|modelPanel4;</p><p>string $select[]=`ls -sl`;<br>if (size($select)<=0){print("select one or more object please ");confirmDialog -t"Select Error...."<br>-m" Select One or more Object Please "<br>-button "Close"<br>-cancelButton "Close" -dismissString "Close";}else{<br>select -cl;<br>shadingNode -asShader -n "UV_Checker" lambert;<br>shadingNode -asTexture -n "UV_Checker_map" file;<br>shadingNode -asUtility -n "UV_Checker_2dTexture" place2dTexture;<br>connectAttr -f UV_Checker_2dTexture.coverage UV_Checker_map.coverage;<br>connectAttr -f UV_Checker_2dTexture.translateFrame UV_Checker_map.translateFrame;<br>connectAttr -f UV_Checker_2dTexture.rotateFrame UV_Checker_map.rotateFrame;<br>connectAttr -f UV_Checker_2dTexture.mirrorU UV_Checker_map.mirrorU;<br>connectAttr -f UV_Checker_2dTexture.mirrorV UV_Checker_map.mirrorV;<br>connectAttr -f UV_Checker_2dTexture.stagger UV_Checker_map.stagger;<br>connectAttr -f UV_Checker_2dTexture.wrapU UV_Checker_map.wrapU;<br>connectAttr -f UV_Checker_2dTexture.wrapV UV_Checker_map.wrapV;<br>connectAttr -f UV_Checker_2dTexture.repeatUV UV_Checker_map.repeatUV;<br>connectAttr -f UV_Checker_2dTexture.offset UV_Checker_map.offset;<br>connectAttr -f UV_Checker_2dTexture.rotateUV UV_Checker_map.rotateUV;<br>connectAttr -f UV_Checker_2dTexture.noiseUV UV_Checker_map.noiseUV;<br>connectAttr -f UV_Checker_2dTexture.vertexUvOne UV_Checker_map.vertexUvOne;<br>connectAttr -f UV_Checker_2dTexture.vertexUvTwo UV_Checker_map.vertexUvTwo;<br>connectAttr -f UV_Checker_2dTexture.vertexUvThree UV_Checker_map.vertexUvThree;<br>connectAttr -f UV_Checker_2dTexture.vertexCameraOne UV_Checker_map.vertexCameraOne;<br>connectAttr UV_Checker_2dTexture.outUV UV_Checker_map.uv;<br>connectAttr UV_Checker_2dTexture.outUvFilterSize UV_Checker_map.uvFilterSize;<br>setAttr -type "string" UV_Checker_map.fileTextureName ("" + $localusername + "/icons/3D_Ghost_Script/UV_Checker.tga");<br>connectAttr -force UV_Checker_map.outColor UV_Checker.color;<br>select -cl;<br>select -add $select;<br>hyperShade -assign UV_Checker;<br>}<br><br><br><br>}else{<br>select $selectobj;<br>hyperShade -assign UV_Checker;}</p><p>}</p><p>//It will delete your uv checker map</p><p>global proc deleteuvcheck(){</p><p>hyperShade -objects UV_Checker;<br>sets -e -forceElement initialShadingGroup;</p><p>select -r UV_Checker UV_Checker_map UV_Checker_2dTexture ;<br>delete;<br>}</p><p>&nbsp;</p><p><br>global proc Tiling()</p><p>{</p><p><br>int $mods = `getModifiers`;<br>int $getModifierPressed = `getModifiers`;<br>if ( $getModifierPressed == 0)<br>{<br>uvcheck();<br>inViewMessage -smg "Checker Assigned" -pos topCenter -bkc 0x00000000 -fade;<br><br>}<br><br>if (($mods / 1) % 2)</p><p>{<br>cycCheckerSize();<br><br>}<br><br>if (($mods / 4) % 2)</p><p>{<br>deleteuvcheck();<br>inViewMessage -smg "Delete" -pos topCenter -bkc 0x00000000 -fade;</p><p>}</p><p><br>}</p><p><br>proc cycCheckerSize()<br>{<br>int $curRptNm = `getAttr UV_Checker_2dTexture.repeatU`;<br>if($curRptNm == 1)<br>{<br>setAttr "UV_Checker_2dTexture.repeatU" 2;<br>setAttr "UV_Checker_2dTexture.repeatV" 2;<br>inViewMessage -smg "Tiling 2k" -pos topCenter -bkc 0x00000000 -fade;<br>}else if($curRptNm == 2)<br>{<br>setAttr "UV_Checker_2dTexture.repeatU" 4;<br>setAttr "UV_Checker_2dTexture.repeatV" 4;<br>inViewMessage -smg "Tiling 4K" -pos topCenter -bkc 0x00000000 -fade;<br>}else if($curRptNm == 4)<br>{<br>setAttr "UV_Checker_2dTexture.repeatU" 8;<br>setAttr "UV_Checker_2dTexture.repeatV" 8;<br>inViewMessage -smg "Tiling 8K" -pos topCenter -bkc 0x00000000 -fade;<br><span>}else if($curRptNm ==&nbsp;<img alt="smiling_face_with_sunglasses" src="https://autodesk.i.lithium.com/html/emoticons/1f60e.png"></span><br>{<br>setAttr "UV_Checker_2dTexture.repeatU" 16;<br>setAttr "UV_Checker_2dTexture.repeatV" 16;<br>inViewMessage -smg "Tiling 16K" -pos topCenter -bkc 0x00000000 -fade;<br>}else if($curRptNm == 16)<br><br>{<br>setAttr "UV_Checker_2dTexture.repeatU" 32;<br>setAttr "UV_Checker_2dTexture.repeatV" 32;<br>inViewMessage -smg "Tiling 32K" -pos topCenter -bkc 0x00000000 -fade;<br>}else if($curRptNm == 32)<br><br>{<br>setAttr "UV_Checker_2dTexture.repeatU" 1;<br>setAttr "UV_Checker_2dTexture.repeatV" 1;<br>inViewMessage -smg "Tiling 1K" -pos topCenter -bkc 0x00000000 -fade;<br>}else if($curRptNm != 1 && $curRptNm != 2 && $curRptNm != 4 && $curRptNm != 8 && $curRptNm != 16 && $curRptNm != 32)<br><br><br>{<br>setAttr "UV_Checker_2dTexture.repeatU" 1;<br>setAttr "UV_Checker_2dTexture.repeatV" 1;<br>}<br>}</p>

Sign In or Register to comment.