get fileTextureName for current frame?

get fileTextureName for current frame?

Anonymous
Not applicable
391 Views
1 Reply
Message 1 of 2

get fileTextureName for current frame?

Anonymous
Not applicable
So currently i have a script thats using this code to get the texture file name from texture node:

cmds.getAttr('node_name.fileTextureName')


But i need to get it for the current frame of animated texture names too now and i was wondering if there was a clever way to do that rather than some horrible string arithmetic.

Thanks
jt
0 Likes
392 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
So I made a function to read the fileTextureName attrib and return the name of the texture with the correct frame number. It could be more clever but hey ho...


def getFileTextureName(file_node):

maya_file_texture_name = cmds.getAttr(file_node + '.fileTextureName')

if cmds.getAttr(file_node + '.useFrameExtension'):
if
file_texture_name = maya_file_texture_name.split('.')
frame_ofset = cmds.getAttr(file_node + '.frameOffset')
current_frame = cmds.currentTime(q=True)
frame_padding = len(file_texture_name)
frame_number = str(int(current_frame + frame_ofset)).zfill(5)

maya_file_texture_name = (file_texture_name + '.' + frame_number + '.' + file_texture_name)

return maya_file_texture_name


Let me know if anyone has any improvements

jt
0 Likes