From Scripting
string $ImagePath = "C:/Documents and Settings/Nick/My Documents/My Pictures/Image1.jpg";
string $TTArr[1] = PlaceImageAndMaterialOnObject("NP1", "blinn", $ImagePath, "Phon", "FXFile");
global proc string[] PlaceImageAndMaterialOnObject(string $ObjName, string $MatType, string $ImagePath, string $MatPrefixName, string $ContainerFileName) {
//Author Nick Pisca 0001d 2009 SURFACE PHONG,BLINN,LAMB PATH YOUR NAME YOUR NAME
string $TempArr[1];
string $SNA = `shadingNode -asShader $MatType -n $MatPrefixName`;
string $SNASG = `sets -renderable true -noSurfaceShader true -empty -name ($MatPrefixName+"SG")`;
connectAttr -f ($SNA+".outColor") ($SNASG+".surfaceShader");
sets -e -forceElement $SNASG $ObjName;
string $SNF = `shadingNode -asTexture file -n $ContainerFileName`;
string $P2D = `shadingNode -asUtility place2dTexture -n "p2dT#"`;
connectAttr -f ($P2D+".coverage") ($SNF+".coverage");
connectAttr -f ($P2D+".translateFrame") ($SNF+".translateFrame");
connectAttr -f ($P2D+".rotateFrame") ($SNF+".rotateFrame");
connectAttr -f ($P2D+".mirrorU") ($SNF+".mirrorU");
connectAttr -f ($P2D+".mirrorV") ($SNF+".mirrorV");
connectAttr -f ($P2D+".stagger") ($SNF+".stagger");
connectAttr -f ($P2D+".wrapU") ($SNF+".wrapU");
connectAttr -f ($P2D+".wrapV") ($SNF+".wrapV");
connectAttr -f ($P2D+".repeatUV") ($SNF+".repeatUV");
connectAttr -f ($P2D+".offset") ($SNF+".offset");
connectAttr -f ($P2D+".rotateUV") ($SNF+".rotateUV");
connectAttr -f ($P2D+".noiseUV") ($SNF+".noiseUV");
connectAttr -f ($P2D+".vertexUvOne") ($SNF+".vertexUvOne");
connectAttr -f ($P2D+".vertexUvTwo") ($SNF+".vertexUvTwo");
connectAttr -f ($P2D+".vertexUvThree") ($SNF+".vertexUvThree");
connectAttr -f ($P2D+".vertexCameraOne") ($SNF+".vertexCameraOne");
connectAttr ($P2D+".outUV") ($SNF+".uv");
connectAttr ($P2D+".outUvFilterSize") ($SNF+".uvFilterSize");
connectAttr -force ($SNF+".outColor") ($SNA+".color");
setAttr ($SNF+".fileTextureName") -type "string" $ImagePath;
$TempArr[0] = $SNA; $TempArr[1] = $SNF;
return $TempArr;
}