Change Hardware Texture Channel with MEL...how?!?

What's the MEL Command to change a material's Hardware Texture Channel? (eg: to "Ambient Color" when It's set to "Color")

I've got a material ("wall") with a file texture for Color and a different texture for Ambient Color. I'm continually toggling the hardware display from one to the other. I'm doing it manually by going into the Attribute editor but I want it as a MEL command so I can assign it to a hot-key.

I've fiddled around with the commands spewed out of Script Editor and got this:

AEhardwareTextureChannelCB "ambientColor" wall.message;
AEhardwareTextureChangedCB "ambientColor" wall.message;

Which sometimes seems to successfully switch the texture to ambient color and:

AEhardwareTextureChannelCB "color" wall.message;
AEhardwareTextureChangedCB "color" wall.message;

obviously enough which switches back to color. However, I don't really know what these lines mean and sometimes they just don't do anything at all...?

can anyone enlighten me..?

I'm still using Maya 3.01 BTW.

:nathaN

Yeah, I ran into a similar issue with this previously. I find myself constantly flipping the hardware texturing to highest from default to deal with alpha channels making things in the viewport transparent. More recently, I wrote a script that was producing a texture with an alpha channel and I wanted automate that switch.

I followed a similar process as you have begun. The script window spits out those AE commands. Those are calling scripts of the same name which can be dug up in your scripts (or maybe others) directory. I found what I was looking for in there - that is, the real code that flips the switch. All I remember now is that it was real obnoxious. It was an obscene amount of code to do something that seemed it should be relatively simple. So I said screw it.

Sorry I couldn't help more.

--JeffD

I couldn't agree more about the crazy steps maya goes through to change something that should really be nothing more than a simple attr. I had to tackle this problem once and here is the MEL that I came up with...

string $curMaterials[]; // the materials to change
int $texQuality ; // the qualty setting (default, high...)
for($i=0;$i {
string $texture[]=listConnections -type file($curMaterials[$i]+".color");
string $hasAttr[]=listAttr -string resolution $texture[0];
if(size($hasAttr) < 1) {
addAttr -ln resolution -at long -dv 32 $texture[0];
}
switch ($texQuality) {
case 1:
// Default
string $buffer[]=listAttr -string resolution $texture[0];
int $hasResolutionAttr = (size($buffer) !=0);
if($hasResolutionAttr){
deleteAttr -at resolution $texture[0];
string $messagePlug[]=listConnections -type materialInfo $curMaterials[$i];
string $connections[]=listConnections -c 1 ($messagePlug[0]+".texture");
for($q=size($connections);$q>0;$q-=2)
{
disconnectAttr ($connections[$q-1]+".message") $connections[$q-2];
}
connectAttr ($texture[0]+".message") ($messagePlug[0]+".texture[0]");
}
break;
case 2:
// Low
setAttr ($texture[0]+".resolution") 32;
break;
case 3:
// Medium
setAttr ($texture[0]+".resolution") 64;
break;
case 4:
// High
setAttr ($texture[0]+".resolution") 128;
break;
case 5:
// Highest
setAttr ($texture[0]+".resolution") 256;
break;
default:
error "Unable to determine textureQuality...";
break;
}
}

I know this doesn't help with the orignal question...sorry

--g

Well maya is very modular and the underlying code is there sometimes just to make sure all conditions are met... And that its easy to implement further if needed. But sometimes simple switches are realy wacky.