2D Texture Node Not Working #Mel

polycounter lvl 3
Offline / Send Message
Pinned
jayantbhatt007 polycounter lvl 3
Hi, I'm just trying to create a blinn material in which it has the attached 2D texture. I got some mel line but it seems like they are not connecting to the blinn material. Here is the command so far

string $myBlinn = `shadingNode -asShader blinn`;
hyperShade -assign $myBlinn;
string $selection[] = `ls -sl`; 
defaultNavigation -createNew -destination ($selection[0]+".color");
createNewOverride(($selection[0]+".color"), true);
createRenderNode -allWithTexturesUp  ($selection[0]+".color") "";
createRenderNodeCB -as2DTexture "" file ($selection[0]+".color");
shadingNode -asUtility place2dTexture;
 

Replies

  • throttlekitty
    Offline / Send Message
    throttlekitty Polycount Sponsor
    Not sure what you're setting up with the navigation and override lines, here's a simpler go at it:

    string $myBlinn = `shadingNode -asShader blinn`;
    hyperShade -assign $myBlinn;
    string $myFile = `createRenderNodeCB -as2DTexture "" file ("")`;
    connectAttr ($myFile+".outColor") ($selection[0]+".color");
  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 3
    Hi thank you so much it's creating the material but not assigning to the selected object Why?
  • throttlekitty
    Offline / Send Message
    throttlekitty Polycount Sponsor
    Right, because creating the blinn makes it the current selection. Try this:

    string $mySel[] = `ls -sl`;
    string $myBlinn = `shadingNode -asShader blinn`;
    hyperShade -assign $myBlinn $mySel;
    string $myFile = `createRenderNodeCB -as2DTexture "" file ("")`;
    connectAttr ($myFile+".outColor") ($myBlinn+".color");
  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 3
    Hi thank you so much this is what I wanted :)


    string $mySel[] = `ls -sl`;
    string $myBlinn = `shadingNode -asShader blinn`;
    string $myFile = `createRenderNodeCB -as2DTexture "" file ("")`;
    connectAttr ($myFile+".outColor") ($myBlinn+".color");
    select $myFile;
    AEfileTextureBrowser ("AEassignTextureCB " + $myFile + ".fileTextureName") $myFile image;
    select -r $mySel; 
    hyperShade -assign $myBlinn $mySel;

  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 3
    Right, because creating the blinn makes it the current selection. Try this:

    string $mySel[] = `ls -sl`;
    string $myBlinn = `shadingNode -asShader blinn`;
    hyperShade -assign $myBlinn $mySel;
    string $myFile = `createRenderNodeCB -as2DTexture "" file ("")`;
    connectAttr ($myFile+".outColor") ($myBlinn+".color");
    Hi small error came I restarted maya and run this new script it does something (Didn't assign the material to the selected object as I expected  ) But again when I run this command it worked perfectly why?


    string $mySel[] = `ls -sl`;
    string $myBlinn = `shadingNode -asShader blinn`;
    string $myFile = `createRenderNodeCB -as2DTexture "" file ("")`;
    setAttr ($myBlinn + ".specularRollOff")0.2;
    connectAttr ($myFile+".outColor") ($myBlinn+".color");
    select $myFile;
    AEfileTextureBrowser ("AEassignTextureCB " + $myFile + ".fileTextureName") $myFile image;
    select -r $mySel; 
    hyperShade -assign $myBlinn $mySel;



  • Panupat
    Offline / Send Message
    Panupat polycounter lvl 12
    The last line will not work. You need to do:

    select $mySel;
    hyperShade -assign $myBlinn;

  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 3
    Panupat said:
    The last line will not work. You need to do:

    select $mySel;
    hyperShade -assign $myBlinn;

    Still the same issue any idea?
  • haiddasalami
    Offline / Send Message
    haiddasalami polycounter lvl 10
    you probably need to source "AEfileTemplate" as that may get sourced somewhere else which is why it works the second time around. (C:\Program Files\Autodesk\Maya\scripts\AETemplates\AEfileTemplate.mel). Probably better to use filedialog or filebrowserdialog to do the UI for selecting a texture rather than dealing with mel files hidden.
  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 3
    you probably need to source "AEfileTemplate" as that may get sourced somewhere else which is why it works the second time around. (C:\Program Files\Autodesk\Maya\scripts\AETemplates\AEfileTemplate.mel). Probably better to use filedialog or filebrowserdialog to do the UI for selecting a texture rather than dealing with mel files hidden.
    hi seems a bit complex for me. Hi, I got this file dialog command but it's not showing images on my desktop why?


    string $singleFilter = "image";
    string $result[] = `fileDialog2 -fileFilter $singleFilter -dialogStyle 1`;
  • Panupat
    Offline / Send Message
    Panupat polycounter lvl 12
    what error message were you getting?
    Panupat said:
    The last line will not work. You need to do:

    select $mySel;
    hyperShade -assign $myBlinn;

    Still the same issue any idea?

    Any error message you can post here?
  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 3
    Panupat said:
    what error message were you getting?
    Panupat said:
    The last line will not work. You need to do:

    select $mySel;
    hyperShade -assign $myBlinn;

    Still the same issue any idea?

    Any error message you can post here?
    in another version of Maya I'm getting this error cannot find AEfileTemplate procedure. I think @haiddasalami is right I have load texture through file dialog which I don't know.
  • haiddasalami
    Offline / Send Message
    haiddasalami polycounter lvl 10
    Just add source "AEfileTemplate" at the top of your script should work. Don't have Maya on me ATM so can't  say what's wrong with the filedialog
  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 3
    Just add source "AEfileTemplate" at the top of your script should work. Don't have Maya on me ATM so can't  say what's wrong with the filedialog
    Hi thank you so much today I know the meaning of source.
Sign In or Register to comment.