View Full Version : Assigning texture
rainingkeon 09-28-2007, 05:02 PM Having problem with assigning the texture using mel...
AEassigntextureCB... that's what i used..
however sometimes maya will say the procedure is not found. I know is becos sourcing of the script... however i have no idea how to solve it...
anyone pls help me with this??
|
|
Gnimmel
09-28-2007, 06:36 PM
You can simply use setAttr to set a file texture, but remember this is a string so you have to set the type.
e.g.
setAttr -type "string" file1.fileTextureName "MyTexture.jpg";
Richard
strarup
10-24-2007, 11:15 AM
Hi,
well... it might be because of case sensitivity... the cmd is AEassignTextureCB with a "big" T at Texture...
which would be my first guess why it doesn't work...
however if that isn't the case... you can e.g. try this...
first find out which shader is on the object... and find out of it has an file node connected to it...
in this case I just assume for lazyness sake that the object only has one shader assigned...
otherwise an UI could be build for this to get multiple shaders from an object shown in a list to choose from...
e.g. take a look at the doDaMakeSelectFacesFromShaderOnObjWindow example here... :)
http://forums.cgsociety.org/showthread.php?f=89&t=553699
a solution using AEassignTextureCB cmd....
proc daTexAssignTesto()
{
string $daSel[] = `ls -sl -l`;
string $daObj[] = `listRelatives -s -typ mesh $daSel[0]`;
string $daShadersOnObj[] = `listConnections -type "shadingEngine" -et 1 -s 0 -d 1 $daObj[0]`;
string $daShaderType = nodeType(`connectionInfo -sfd ($daShadersOnObj[0]+".surfaceShader")`);
string $daShader[] = `listConnections -t $daShaderType $daShadersOnObj[0]`;
string $daShaderFile[]= `listConnections -t file $daShader[0]`;
if((`size $daShaderFile[0]`) > 0)
{
AEfileTextureBrowser ("AEassignTextureCB "+$daShaderFile[0]+".fileTextureName");
}
else if((`size $daShaderFile[0]`) == 0)
{
$daShaderFile[0] = `createNode "file"`;
connectAttr -f ($daShaderFile[0]+".outColor") ($daShader[0]+".color");
AEfileTextureBrowser ("AEassignTextureCB "+$daShaderFile[0]+".fileTextureName");
}
}
daTexAssignTesto;
using a filebrowser and the setAttr -type "string" file1.fileTextureName "MyTexture.jpg";
which Richard mentions... :)
[/code]
proc doDaAssignTexTest( )
{
if ( (`window -exists assignDaTexThingieUI`) == true ) deleteUI assignDaTexThingieUI;
window -title "Open up your Texture file and assign it..." -wh 400 48 assignDaTexThingieUI;
columnLayout -adjustableColumn true;
textFieldButtonGrp
-cw 1 96 -label "File Path" -buttonLabel "Get it"
-bc "string $daPath = `fileDialog`;textFieldButtonGrp -e -text $daPath daTexFilepath02;doDaAssignTexFile($daPath)"
daTexFilepath02;
setParent..;
showWindow assignDaTexThingieUI;
}
doDaAssignTexTest;
proc doDaAssignTexFile(string $daPath)
{
string $tokenPart1[], $tokenPart2[];
tokenize ($daPath, ".", $tokenPart1);
tokenize ($tokenPart1[0], "/", $tokenPart2);
string $daExtension = $tokenPart1[1];
int $daTexIndex = size($tokenPart2)-1;
string $daTexFile = $tokenPart2[$daTexIndex];
string $daTexFolder = `substitute ($daTexFile+"."+$daExtension) $daPath ""`;
string $daSel[] = `ls -sl -l`;
string $daObj[] = `listRelatives -s -typ mesh $daSel[0]`;
string $daShadersOnObj[] = `listConnections -type "shadingEngine" -et 1 -s 0 -d 1 $daObj[0]`;
string $daShaderType = nodeType(`connectionInfo -sfd ($daShadersOnObj[0]+".surfaceShader")`);
string $daShader[] = `listConnections -t $daShaderType $daShadersOnObj[0]`;
string $daShaderFile[]= `listConnections -t file $daShader[0]`;
if((`size $daShaderFile[0]`) > 0)
{
setAttr -type "string" ($daShaderFile[0]+".fileTextureName") ($daTexFile+"."+$daExtension);
}
else if((`size $daShaderFile[0]`) == 0)
{
$daShaderFile[0] = `createNode "file"`;
connectAttr -f ($daShaderFile[0]+".outColor") ($daShader[0]+".color");
setAttr -type "string" ($daShaderFile[0]+".fileTextureName") ($daTexFile+"."+$daExtension);
}
}
[/code]
however no error handling has been implemented... but hopefully you can use it anyway... :)
regards
Strarup
CGTalk Moderation
10-24-2007, 11:15 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.