Home Coding, Scripting, Shaders

MEL - Material error

polycounter lvl 8
Offline / Send Message
Pinned
jayantbhatt007 polycounter lvl 8
Hi, this code is modified by bodizz (he gave me the blinn command ) but I want to add lambert material also so I changed in the Blinn material command. After changing the blinn command they both are working as a Lambert command or lambert material how can I make it unique.




proc createMat(){
string $sel[] = `ls -sl`; 
string $myBlinn = `shadingNode -asShader blinn`; 
select -r $sel; 
hyperShade -assign $myBlinn;
}
window;
 
frameLayout -label "jayant";
            
 
flowLayout -columnSpacing 7 -w 50 -h 50;
 
 
symbolButton -w 40 -h 40 -image "blinn.svg" -c "createMat()" ;


 proc createMat(){
string $sel[] = `ls -sl`; 
string $lambert = `shadingNode -asShader lambert`; 
select -r $sel; 
hyperShade -assign $lambert;
}
            
 flowLayout -columnSpacing 7 -w 40 -h 38;
 
 symbolButton -w 40 -h 40 -image "blinn.svg" -c "createMat()" ;
 


 
showWindow;

Replies

  • jayantbhatt007
  • throttlekitty
    Offline / Send Message
    throttlekitty ngon master
    Both your buttons have the same line: " -c "createMat()" ", which means they are both running that command, which only creates a blinn. I made a change to your script to take a name value

    proc createMat(string $name){
    string $sel[] = `ls -sl`; 
    // Use the $name variable to create a material of that type; eg blinn, lambert, surfaceShader, etc.
    string $myMat = `shadingNode -asShader $name`; 
    select -r $sel; 
    hyperShade -assign $myMat;
    }

    Now in your symbolButton lines, change to... -c "createMat("lambert")";
  • Bodizzz
    Offline / Send Message
    Bodizzz polycounter lvl 9
    Hi, this code is modified by bodizz (he gave me the blinn command ) but I want to add lambert material also so I changed in the Blinn material command. After changing the blinn command they both are working as a Lambert command or lambert material how can I make it unique.




    proc createMat(){
    string $sel[] = `ls -sl`; 
    string $myBlinn = `shadingNode -asShader blinn`; 
    select -r $sel; 
    hyperShade -assign $myBlinn;
    }
    window;
     
    frameLayout -label "jayant";
                
     
    flowLayout -columnSpacing 7 -w 50 -h 50;
     
     
    symbolButton -w 40 -h 40 -image "blinn.svg" -c "createMat()" ;


     proc createMat(){
    string $sel[] = `ls -sl`; 
    string $lambert = `shadingNode -asShader lambert`; 
    select -r $sel; 
    hyperShade -assign $lambert;
    }
                
     flowLayout -columnSpacing 7 -w 40 -h 38;
     
     symbolButton -w 40 -h 40 -image "blinn.svg" -c "createMat()" ;
     


     
    showWindow;
    Hi, try this
    proc createBlinn(){
    string $sel[] = `ls -sl`; 
    string $myBlinn = `shadingNode -asShader blinn`; 
    select -r $sel; 
    hyperShade -assign $myBlinn;
    }
    window;
     
    frameLayout -label "jayant";
                
     
    flowLayout -columnSpacing 7 -w 50 -h 50;
     
     
    symbolButton -w 40 -h 40 -image "blinn.svg" -c "createBlinn()" ;
    
    
    proc createLambert(){
    string $sel[] = `ls -sl`; 
    string $lambert = `shadingNode -asShader lambert`; 
    select -r $sel; 
    hyperShade -assign $lambert;
    }
                
     flowLayout -columnSpacing 7 -w 40 -h 38;
     
     symbolButton  -w 40 -h 40  -image "lambert.svg" -c "createLambert()"  ;
     
    
    
     
    showWindow;


  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 8
    Bodizzz said:
    Hi, this code is modified by bodizz (he gave me the blinn command ) but I want to add lambert material also so I changed in the Blinn material command. After changing the blinn command they both are working as a Lambert command or lambert material how can I make it unique.




    proc createMat(){
    string $sel[] = `ls -sl`; 
    string $myBlinn = `shadingNode -asShader blinn`; 
    select -r $sel; 
    hyperShade -assign $myBlinn;
    }
    window;
     
    frameLayout -label "jayant";
                
     
    flowLayout -columnSpacing 7 -w 50 -h 50;
     
     
    symbolButton -w 40 -h 40 -image "blinn.svg" -c "createMat()" ;


     proc createMat(){
    string $sel[] = `ls -sl`; 
    string $lambert = `shadingNode -asShader lambert`; 
    select -r $sel; 
    hyperShade -assign $lambert;
    }
                
     flowLayout -columnSpacing 7 -w 40 -h 38;
     
     symbolButton -w 40 -h 40 -image "blinn.svg" -c "createMat()" ;
     


     
    showWindow;
    Hi, try this
    proc createBlinn(){
    string $sel[] = `ls -sl`; 
    string $myBlinn = `shadingNode -asShader blinn`; 
    select -r $sel; 
    hyperShade -assign $myBlinn;
    }
    window;
     
    frameLayout -label "jayant";
                
     
    flowLayout -columnSpacing 7 -w 50 -h 50;
     
     
    symbolButton -w 40 -h 40 -image "blinn.svg" -c "createBlinn()" ;
    
    
    proc createLambert(){
    string $sel[] = `ls -sl`; 
    string $lambert = `shadingNode -asShader lambert`; 
    select -r $sel; 
    hyperShade -assign $lambert;
    }
                
     flowLayout -columnSpacing 7 -w 40 -h 38;
     
     symbolButton  -w 40 -h 40  -image "lambert.svg" -c "createLambert()"  ;
     
    
    
     
    showWindow;


    sir thanks for your help. Much appreciated It is working fine. :D
  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 8
    Both your buttons have the same line: " -c "createMat()" ", which means they are both running that command, which only creates a blinn. I made a change to your script to take a name value

    proc createMat(string $name){
    string $sel[] = `ls -sl`; 
    // Use the $name variable to create a material of that type; eg blinn, lambert, surfaceShader, etc.
    string $myMat = `shadingNode -asShader $name`; 
    select -r $sel; 
    hyperShade -assign $myMat;
    }

    Now in your symbolButton lines, change to... -c "createMat("lambert")";

    It does nothing when I change it to blinn


    proc createBlinn(string $blinn){
    string $sel[] = `ls -sl`; 
    string $myBlinn = `shadingNode -asShader $blinn`; 
    select -r $sel; 
    hyperShade -assign $myBlinn;
    }
  • throttlekitty
    Offline / Send Message
    throttlekitty ngon master
    Both your buttons have the same line: " -c "createMat()" ", which means they are both running that command, which only creates a blinn. I made a change to your script to take a name value

    proc createMat(string $name){
    string $sel[] = `ls -sl`; 
    // Use the $name variable to create a material of that type; eg blinn, lambert, surfaceShader, etc.
    string $myMat = `shadingNode -asShader $name`; 
    select -r $sel; 
    hyperShade -assign $myMat;
    }

    Now in your symbolButton lines, change to... -c "createMat("lambert")";

    It does nothing when I change it to blinn


    proc createBlinn(string $blinn){
    string $sel[] = `ls -sl`; 
    string $myBlinn = `shadingNode -asShader $blinn`; 
    select -r $sel; 
    hyperShade -assign $myBlinn;
    }
    The goal was to have a single proc command that you can call on to make both materials. Using what I wrote, you'd change these lines in both your buttons.

    symbolButton -w 40 -h 40 -image "blinn.svg" -c "createMat("blinn")" ;
    symbolButton -w 40 -h 40 -image "blinn.svg" -c "createMat("lambert")" ;

    I know this stuff can be hard, but you really need to put a bit more thought into what you're doing.
  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 8
Sign In or Register to comment.