Texture not showing on mesh and on render

Texture not showing on mesh and on render

Anonymous
Not applicable
920 Views
2 Replies
Message 1 of 3

Texture not showing on mesh and on render

Anonymous
Not applicable

Hey people,

version: maya 2018.3 Windows10
I am having an issue where I want to map a image sequence onto my object but somewhere it decides not to apply the actual texture. I have to do this exact action below to fix it but am wondering if I can't do that code wise.
Using python but I can work with MEL a bit.

 

issueFileNode01.pngissueFileNode02.png

 

 #Search for img
imgPath = cmds.fileDialog2(fileMode=1, fileFilter="*.tif")
img = imgPath[0]
textureName = img.split('/')
textureName = textureName[len(textureName)-1]
textureName = textureName.split('.')[0]
print textureName
#create a shader
shader=cmds.shadingNode("surfaceShader",asShader=True,name="imgSequenceShader")
#a file texture node
file_node=cmds.shadingNode("file",asTexture=True ,name="imgSequence")
# a shading group
shading_group= cmds.sets(renderable=True,noSurfaceShader=True,empty=True)
#connect shader to sg surface shader
cmds.connectAttr('%s.outColor' %shader ,'%s.surfaceShader' %shading_group)
#connect file texture node to shader's color
cmds.connectAttr('%s.outColor' %file_node,'%s.outColor' %shader)

cmds.setAttr('imgSequence.useFrameExtension' ,1)
#a UV node
uv_node=cmds.shadingNode("uvChooser",asUtility =True ,name="UV")
#connect UV node to file node
cmds.connectAttr('%s.outUv' %uv_node,'%s.uvCoord' %file_node)

cmds.setAttr( '%s.fileTextureName' % file_node, img, type = "string")

If this is fixed my script is flawless so it would be a big favor you do for me!

 Greetings,

Matthias Willemen

0 Likes
921 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

I fixed it , I just had to reload the textures using this code!

from maya import cmds

#set up all the shadernodes and assign it to the mesh before

#reload the textures files = cmds.ls(type='file') for file in files: fileName = cmds.getAttr(file+'.fileTextureName') cmds.setAttr(file+'%s.fileTextureName' , type = fileName)
0 Likes
Message 3 of 3

Anonymous
Not applicable

Apparently I was wrong, still having the same issue..

0 Likes