Home Coding, Scripting, Shaders

create blinn material button - MEL

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

Hi I want to create a button for blinn material using MEL. As you can see in the image. Just I want to add only blinn material rest off them I will create it by myself. 

Thanks

 

 

Replies

  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    you want : shadingNode -asShader blinn;
  • jayantbhatt007
    Options
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    yes, sir but how can I assign a button to this command line. I tried but I couldn't do it.


  • oglu
    Options
    Offline / Send Message
    oglu polycount lvl 666
    i would use the shift+t shortcut.
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
  • jayantbhatt007
    Options
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    oglu said:
    i would use the shift+t shurtcut...
    here is my script I want to assign that blinn material in my script also as you can see in the image.


    // delete window if it exists
    if ( `window -exists jayantsWindow` ) {
          deleteUI jayantsWindow;
    }

    // create a window with a menu bar

    window -title "3DGhost" -menuBar true -w 220 -h 200 jayantsWindow;
    // two frame layouts will be laid out in a columna
    columnLayout;
    // create a collapsible frame layout
    frameLayout -collapsable true -label "Shapes";
    {




    // create a tearOff menu
    menu -label "File" -tearOff true;
    // add the menu items
    menuItem -label "New" -command "NewScene";
    menuItem -label "Open" -command "OpenScene";
    menuItem -label "Save" -command "SaveScene";
    menuItem -divider true -command "SaveScene";
    menuItem -label "Quit" -command "quit";
    // add a help menu
    menu -label "Help" -helpMenu true;
    menuItem -label "Help" -command "Help";
    // add a help menu
    menu -label "Credit" -helpMenu true;
    menuItem -label "Jayant bhatt";

    // add the other controls
    flowLayout -columnSpacing 1 -w 220 -h 40;
        // create three symbol buttons with related mel command
    symbolButton -image "cube.xpm" -command "polyCube";
    symbolButton -image "sphere.xpm" -command "CreatePolygonSphere";
    symbolButton -image "plane.xpm" -command "CreatePolygonPlane";
    symbolButton -image "cylinder.xpm" -command "CreatePolygonCylinder";
    symbolButton -image "circle.xpm" -command "CreateNURBSCircle";
    symbolButton -image "text.xpm" -command "CreatePolygonType";
    setParent ..;
    setParent ..;
    // three frame layouts will be laid out in a column
    columnLayout;
    // create a collapsible frame layout
    frameLayout -collapsable true -label "Options";
    // define the layout of controls added 
    // to the window.
    columnLayout;
    // add the other controls
    flowLayout -columnSpacing 1 -w 220 -h 40;
    // create a couple of buttons
    symbolButton -image "CenterPivot.png" -command "CenterPivot";
    symbolButton -image "multiCut_NEX32.png" -command "dR_multiCutTool";
    symbolButton -image "polyCircularize.png" -command "PolyCircularize";
    symbolButton -image "detach.png" -command "DetachComponent";
    symbolButton -w 35 -h 35 -image "addCreateGeneric_100.png" -command "CombinePolygons";
    symbolButton -w 35 -h 35 -image "mergeConnections.png" -command "CombinePolygons";
                        
                        setParent ..;
                       setParent ..;
                       setParent ..;
                       
                       

    // create a collapsible frame layout
    frameLayout -collapsable true -label "Constraint";
    // add the other controls
    flowLayout -columnSpacing 5 -w 220 -h 40;


    symbolButton -w 30 -h 30 -image "edges_NEX.png" -command "toolPropertyShow";

    symbolButton -w 30 -h 30 -image "hyper_s_ON.png" -command "manipMoveSetXformConstraint edge";

    symbolButton -w 30 -h 30 -image "hyper_s_OFF.png" -command "manipMoveSetXformConstraint none";


                       setParent ..;
                       setParent ..;
                       setParent ..;                
            
                       
                       

                  



                     
    showWindow jayantsWindow;
    }

  • oglu
    Options
    Offline / Send Message
    oglu polycount lvl 666
    Obscura said:
    oglu said:
    ...

    im hunted now.
    :smile:
  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    Just that command will create a material without a shading group. You want to create a new shading group and add the material to it. 

    shadingNode -asUtility shadingEngine<br>connectAttr (blinn.outColor) (blinnSG.surfaceShader);<br><div>sets -e -forceElement blinnSG;</div>
    That's the general idea.
    You'll need to make the above code work properly by using variables. 
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    oglu said:
    im hunted now.
    :smile:

  • jayantbhatt007
    Options
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    Just that command will create a material without a shading group. You want to create a new shading group and add the material to it. 

    shadingNode -asUtility shadingEngine<br>connectAttr (blinn.outColor) (blinnSG.surfaceShader);<br><div>sets -e -forceElement blinnSG;</div>
    That's the general idea.
    You'll need to make the above code work properly by using variables. 
    // Error: Line 2.52: Invalid use of Maya object "blinnSG.surfaceShader".
  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    Just that command will create a material without a shading group. You want to create a new shading group and add the material to it. 

    shadingNode -asUtility shadingEngine<br>connectAttr (blinn.outColor) (blinnSG.surfaceShader);<br><div>sets -e -forceElement blinnSG;</div>
    That's the general idea.
    You'll need to make the above code work properly by using variables. 
    // Error: Line 2.52: Invalid use of Maya object "blinnSG.surfaceShader".
    I
    Yes I know it's not working code like that. Eg that line should probably look more like:

    connectAttr ($myBlinn + ".outColor") ($myBlinnSG + ".surfaceShader");

    but if I told you exactly how to do it you'd never learn anything ;-)
  • jayantbhatt007
    Options
    Offline / Send Message
    jayantbhatt007 polycounter lvl 5
    Just that command will create a material without a shading group. You want to create a new shading group and add the material to it. 

    shadingNode -asUtility shadingEngine<br>connectAttr (blinn.outColor) (blinnSG.surfaceShader);<br><div>sets -e -forceElement blinnSG;</div>
    That's the general idea.
    You'll need to make the above code work properly by using variables. 
    // Error: Line 2.52: Invalid use of Maya object "blinnSG.surfaceShader".
    I
    Yes I know it's not working code like that. Eg that line should probably look more like:

    connectAttr ($myBlinn + ".outColor") ($myBlinnSG + ".surfaceShader");

    but if I told you exactly how to do it you'd never learn anythinH

    Hahaha I really love your trick... :)
    thanks for your help. 
    I'm super noob.
Sign In or Register to comment.