Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Python - import image?

1 REPLY 1
Reply
Message 1 of 2
larmannjan
1243 Views, 1 Reply

Python - import image?

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)

 

1 REPLY 1
Message 2 of 2
zhong_wu
in reply to: larmannjan

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:)


John Wu
Developer Technical Services
Autodesk Developer Network


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report