Hi,
I am using Maya 2014 on windows 7. I would like to import an image into maya using python. I want the affect to be the same as when I drag an image from the file explorer into the textures tab found in the Hypershade.
What I have so far does not work propelry. It only open the image in Fcheck.
cmds.file('G:\\Dropbox\\3d\projects\\wall\\imgs\\bricks\\diffuse\\diffuse.1002.tif', type='image', i=True, o=False, renameAll=True, mergeNamespacesOnClash=False, namespace='astronauts', pr=True, ra=True)
Just checked the script of dragging an image to texture tab in Hypershader, it actually created and conntect 2 shading nodes, the scripts executed are similar as follow(I just specify the name of shading nodes),
shadingNode -asTexture file -n myfile;
shadingNode -asUtility place2dTexture myPlace2dTexture;
connectAttr -f myPlace2dTexture.coverage myfile.coverage;
connectAttr -f myPlace2dTexture.translateFrame myfile.translateFrame;
connectAttr -f myPlace2dTexture.rotateFrame myfile.rotateFrame;
connectAttr -f myPlace2dTexture.mirrorU myfile.mirrorU;
connectAttr -f myPlace2dTexture.mirrorV myfile.mirrorV;
connectAttr -f myPlace2dTexture.stagger myfile.stagger;
connectAttr -f myPlace2dTexture.wrapU myfile.wrapU;
connectAttr -f myPlace2dTexture.wrapV myfile.wrapV;
connectAttr -f myPlace2dTexture.repeatUV myfile.repeatUV;
connectAttr -f myPlace2dTexture.offset myfile.offset;
connectAttr -f myPlace2dTexture.rotateUV myfile.rotateUV;
connectAttr -f myPlace2dTexture.noiseUV myfile.noiseUV;
connectAttr -f myPlace2dTexture.vertexUvOne myfile.vertexUvOne;
connectAttr -f myPlace2dTexture.vertexUvTwo myfile.vertexUvTwo;
connectAttr -f myPlace2dTexture.vertexUvThree myfile.vertexUvThree;
connectAttr -f myPlace2dTexture.vertexCameraOne myfile.vertexCameraOne;
connectAttr myPlace2dTexture.outUV myfile.uv;
connectAttr myPlace2dTexture.outUvFilterSize myfile.uvFilterSize;
To achieve the samething as UI operation, I think what you need to do is just reference the above script, and executing the similar script, after that, just set the attribute of fileTextureName to the location of your image as follow:
setAttr myfile.fileTextureName -type "string" "C://IMG_20131009_084341.jpg"
I am not Mel expert, but hope it helps:)