3D정보모음/스크립트 낙서

멜 스크립트 낙서창

roamek 2020. 8. 19. 12:11

1.  레이어 속성 정리  

 

setLayerTo all".visibility" 1;
setLayerTo all".displayType" 0;

 

2. 4분활 전 화면 바운딩 박스로 정리

 

modelEditor -edit -displayAppearance boundingBox modelPanel1;
modelEditor -edit -displayAppearance boundingBox modelPanel2;
modelEditor -edit -displayAppearance boundingBox modelPanel3;
modelEditor -edit -displayAppearance boundingBox modelPanel4;

 

3. 레퍼런스 에디터 셀렉트 스크립트(단축키로 설정하면 편함)

 

referenceEdSelectCB;

 

4.Import 와 그 이후 레이어 속성(아래는 예시) - AMBL 매트를 임포트하고 FG를 끄기

 

file -import -type "mayaAscii" -rpr "AMBL_Matte" "Z:/KFP/Maya_KFP/Tools/AMBL_Matte.ma";

renderLayerEditorSettingsOverride RenderLayerTab "Matt" 1;

editRenderLayerAdjustment "miDefaultOptions.finalGather";
setAttr "miDefaultOptions.finalGather" 0;

 

5. 선택한 레이어

 

select `ls`;

 

6. 선택한 오브젝트들에 대한 속성 제어(아래는 예시) - 선택한 오브젝트들의 FG Cast를 오버라이드 하면서 꺼주기

 

string $objects[] = `ls -sl`;
string $currentObject;
for ( $currentObject in $objects )
{
   editRenderLayerAdjustment $currentObject.miFinalGatherCast;
   setAttr ($currentObject +".miFinalGatherCast")0;
};

 

7. 선택한 오브젝트의 toggle Axis 변환 (Object World Component)

 

string $sel[] =`ls -sl`;    
        for ($thisObj in $sel){ 
            int $contextAxisManip = `manipMoveContext -q -mode Move`;
            if ($contextAxisManip == 0) 
            {
                manipMoveContext -e -mode 2 Move;
            }
            if ($contextAxisManip == 2) 
            {
                manipMoveContext -e -mode 10 Move;
            }
            else if  ($contextAxisManip == 10)
         {
                manipMoveContext -e -mode 0 Move;
            }
            else
         {
                manipMoveContext -e -mode 2 Move;
            }
            
        };

 

 

 

0.표를 이용한 레이어 네이밍 한번에 정리하는 스크립트

 

global proc File_name_pass()

{
if (`window -ex "File_name_pass"`) 
     deleteUI File_name_pass;

window  -title "File_name_pass V1.0^" -w 350 -h 550 "File_name_pass";
  
     columnLayout -cat left 1 -rowSpacing 5 -columnWidth 100 -adj 1;
     paneLayout -configuration "vertical4" -ps 1 20 50 -ps 2  20 50 -ps 3  20 50 -ps 4  40 50 -w 200 -h 150;
     
     textScrollList -h 100 -w 100 -ams false  "sceneScrollList"; 
     textScrollList -h 100 -w 100 -ams false  "cutScrollList";
     textScrollList -h 100 -w 100 -ams false  "PassScrollList"; 
     textScrollList -h 100 -w 100 -ams false  "SPassScrollList";

     setParent ..;
    rowColumnLayout  -numberOfColumns 2 
     -columnWidth 1 150
     -columnWidth 2 350;

     button -l "ReLoad" -h 25 -c "File_name_pass"; 
     button -l "Apply"  -h 25 -c  PassBrowser;
     setParent ..;
////Creat by.cart7587////


PassName();

showWindow "File_name_pass";
window -e -w 500 -h 215 "File_name_pass";

}

global proc PassName()
{
    string $ScenefolderList[] = { "01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22"};
    string $CutfolderList[] = { "001","002","003","004","005","006","007","008","009","010","011","012","013","014","015","016","017","018","019","020","021","022","023","024","025","026","027","028","029","030","031","032","033","034","035","036","037","038","039","040","041","042","043","044","045","046","047","048","049","050","051","052","053","054","055","056","057","058","059","060","061","062","063","064","065","066","067","068","069","070","071","072","073","074","075","076","077","078","079","080","081","082","083","084","085","086","087","088","089","090","091","092","093","094","095","096","097","098","099","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115","116","117","118","119","120","121","122","123","124","125","126","127","128","129","130","131","132","133","134","135","136","137","138","139","140","141","142","143","144","145","146","147","148","149","150","151","152","153","154","155","156","157","158","159","160","161","162","163","164","165","166","167","168","169","170" };
    string $folderList[] = { "Char","BG","Fx" };
    string $SfolderList[] = { "%l_v001/KF_%l_v001_CP.%4n.%e","%l_v001/KF_%l_<RenderPass>_v001_CP.%4n.%e"};
    
         for($s = 0 ; $s < size($ScenefolderList) ; $s++){
   textScrollList -edit -append $ScenefolderList[$s]   "sceneScrollList";                
         }
         for($c = 0 ; $c < size($CutfolderList) ; $c++){
   textScrollList -edit -append $CutfolderList[$c]   "cutScrollList";                
         }
         for($j = 0 ; $j < size($folderList) ; $j++){
   textScrollList -edit -append $folderList[$j]   "PassScrollList";                
         }
         for($k = 0 ; $k < size($SfolderList) ; $k++){
   textScrollList -edit -append $SfolderList[$k]  "SPassScrollList";         
         }

}

global proc PassBrowser()
 {
  string $Pscene[] = `textScrollList -query -selectItem "sceneScrollList"`;
     string $Pcut[] = `textScrollList -query -selectItem "cutScrollList"`;
     string $Pfirst[] = `textScrollList -query -selectItem "PassScrollList"`;
     string $PSecond[] = `textScrollList -query -selectItem "SPassScrollList"`;
     
     string $scene = $Pscene[0];
     string $cut =  $Pcut[0];
     string $first = $Pfirst[0];
     string $second =  $PSecond[0];
     
     setAttr -type "string" defaultRenderGlobals.imageFilePrefix ( $scene+"/" + $cut+ "/Comp/"+$first+ "/"+$second);


}

File_name_pass();

 

- 브이레이 렌더패스 기준으로 수정합시다!

 

8.쉐이더 상호간 서로 링크시키기

 

connectAttr -f AMB.outValue AMB_shader.outColor;

 

9.UI닫기

 

deleteUI connectWind

 

10.속성 컨트롤 가능한 윈도우창

 

// create a sphere and a shading node

$sphere = `sphere`;

$phong = `shadingNode -asShader phong`;

 

// create a window to hold the controls

window -title "Attribute Controls";

columnLayout;

 

 

// attach a colour control to the phong colour

attrColorSliderGrp -at ($phong+".color");

 

 

// attach a field group to the scale attribute

  attrFieldGrp -attribute ($sphere[0] + ".scale");

 

 

// attach a float slider to the translate X of the sphere

attrFieldSliderGrp -min -10.0 -max 10.0 -at ($sphere[0]+".tx");

 

 

showWindow;

 

 

 

 11.Mel Script 개인 UI 만들기

 


string $KNF_reNaming_n = "RE_NAMING"; //윈도우 이름을 정하고 변수 선언

if(`window -exists $KNF_reNaming_n`) //RE_NAMING 이란 윈도우가 있으면 창을 닫는다
deleteUI $KNF_reNaming_n;

window -t "Re Naming MEL" $KNF_reNaming_n; //윈도우 타이틀


string $form = `formLayout`; //레이아웃 변수 선언


string $KNF_reN_textField = `textFieldGrp -label "Input String : " -text "" reNaming_UI`; //텍스트 필드


string $KNF_reN_radioButtonGrpA = `radioButtonGrp -numberOfRadioButtons 4
       -cc KNF_ccOptionMenu
       -labelArray4 "Re Name" "Replace" "Add prefix" "Add postfix" -sl 1 KNF_reN_radioButtonGrp1`; //라디오버튼 그룹

string $KNF_reN_buttonA = `button -h 30 -w 250 -label "EXCUTE" -c KNF_reN_Excute`; //버튼

string $KNF_reN_buttonB = `button -h 30 -w 250 -label "CANCLE" -command ("deleteUI -window " + $KNF_reNaming_n)`; //버튼

string $KNF_reN_checkBoxA = `checkBox -label "AutoGroup(Just Rename in BF)"  -align "left" -enable 0 -v 0 KNF_reN_checkboxAUI`; //체크박스
string $KNF_reN_checkBoxB = `checkBox -label "Fix Padding Number"   -align "left" -cc KNF_reN_ccCheckboxB -v 1 KNF_reN_checkboxBUI`; //체크박스
string $KNF_reN_intSliderA = `intSliderGrp -field true -minValue 3 -maxValue 8 -value 3 -enable 1 KNF_reN_intSliderAUI`; //슬라이드 바


optionMenu -label "Name Type :" -cc KNF_ccOptionMenu KNF_whichNameType; //옵션메뉴
menuItem -label "Done";
menuItem -label "geo";
menuItem -label "shp";
menuItem -label "lgt";
menuItem -label "anm";
menuItem -label "bon";
menuItem -label "cam";
menuItem -label "grp";
menuItem -label "con";
menuItem -label "msc";



string $fgtextA = `text -label "By Kyounan 5:36pm, 17/06/10" -align "left" -font "smallPlainLabelFont"`; //텍스트
string $fgtextB = `text -label "V 0.3.0"         -align "right" -font "smallPlainLabelFont"`; //텍스트
string $fgseparatorA = `separator`; //분할라인

//여기서 부터가 윈도우에 배치

formLayout -edit
-attachForm  $KNF_reN_textField "top" 10
-attachForm  $KNF_reN_textField "left" 1

-attachForm  KNF_whichNameType "top" 10
-attachControl KNF_whichNameType "left" 10 $KNF_reN_textField



-attachControl $KNF_reN_radioButtonGrpA "top" 10 $KNF_reN_textField
-attachForm  $KNF_reN_radioButtonGrpA "left" 70



-attachControl $KNF_reN_buttonA "top" 10 $KNF_reN_radioButtonGrpA
-attachForm  $KNF_reN_buttonA "left" 20


-attachControl $KNF_reN_buttonB "top" 10 $KNF_reN_buttonA
-attachForm  $KNF_reN_buttonB "left" 20

-attachControl $KNF_reN_checkBoxA "top" 10 $KNF_reN_radioButtonGrpA
-attachControl $KNF_reN_checkBoxA "left" 20 $KNF_reN_buttonA

-attachControl $KNF_reN_checkBoxB "top" 5 $KNF_reN_checkBoxA
-attachControl $KNF_reN_checkBoxB "left" 20 $KNF_reN_buttonA

-attachControl $KNF_reN_intSliderA "top" 5 $KNF_reN_checkBoxB
-attachForm  $KNF_reN_intSliderA "right" 20


-attachForm  $fgtextA   "bottom" 2
-attachForm  $fgtextA   "left"  5
-attachForm  $fgtextB   "bottom" 2
-attachForm  $fgtextB   "right"  5
-attachForm  $fgseparatorA  "bottom" 20
-attachForm  $fgseparatorA  "left"  5
-attachForm  $fgseparatorA  "right"  5
$form;
//여기까지가 윈도우 배치

showWindow $KNF_reNaming_n; //윈도우 표시

window -e -wh 550 180 $KNF_reNaming_n; //윈도우 창 크기 설정





위의 코드를 실행 하면 다음과 같은 윈도우가 생성이 됩니다.


제가 mel 을 이용하여 UI 를 만들때 가장 쉽다고 생각 되는 부분이 formLayout 을
이용하여 작성 하는 것인데요..

윈도우 배치 부분만을 설명을 드리면
제일 마지막 줄에서 윈도우 크기를 지정을 하고 그 안에 적절하게 배치 될 수 있게
-attachControl, -attachForm 플래그를 사용하여 작성하는 방법입니다.


길어 보이지만 상당히 간단 합니다.

-attachForm 은 윈도우에 붙인다는 뜻으로

-attachForm  $KNF_reN_textField "top" 10 의 경우

$KNF_reN_textField 에 해당하는 아이템을 윈도우의 top을 기준으로 10픽셀을 띄우고
배치 한다는 뜻입니다.

-attachControl 은 윈도우가 아닌 해당 아이템을 다른 아이템을 기준으로 붙인다는뜻으로

-attachControl $KNF_reN_radioButtonGrpA "top" 10 $KNF_reN_textField

$KNF_reN_radioButtonGrpA 에 해당하는 아이템을 $KNF_reN_textField 에 해당하는 아이템
을 기준으로 10픽셀을 띄우고 배치 하라는 의미 입니다.

즉, $KNF_reN_textField 에 해당하는 아이템 밑에 10픽셀의 공간을 두고 배치하게 됩니다.


위 코드를 실행 해보고 formlayout 부분을 확인 하면 쉽게 알 수 있을것입니다.