Friday, 15 June 2012

python - Unable to display all the information except for first selection -



python - Unable to display all the information except for first selection -

i using next code process list of images found in scene, before gathered information, namely tifpath , texpath used in function.

however, illustration in scene, there 3 textures, , hence should seeing 3 sets of tifpath , texpath seeing 1 of them., whereas if running check surshaderout or surshadertex able see 3 textures info.

for example, 3 textures file path follows (in surshadertex): /user_data/testshader/texturetga_01.tga, /user_data/testshader/texturetga_02.tga, /user_data/testshader/texturetga_03.tga

i guess trying why in for statement, able print out 3 results , yet bypass that, printing out single result.

any advices?

surshader = cmds.ls(type = 'surfaceshader') con in surshader: surshaderout = cmds.listconnections('%s.outcolor' % con) surshadertex = cmds.getattr("%s.filetexturename" % surshaderout[0]) path = os.path.dirname(surshadertex) f = surshadertex.split("/")[-1] tifname = os.path.splitext(f)[0] + ".tif" texname = os.path.splitext(f)[0] + ".tex" tifpath = os.path.join(path, tifname) texpath = os.path.join(path, texname) converttext(surshadertex, tifpath, texpath)

only 2 lines part of for loop. rest execute once.

so first runs:

surshader = cmds.ls(type = 'surfaceshader') con in surshader: surshaderout = cmds.listconnections('%s.outcolor' % con) surshadertex = cmds.getattr("%s.filetexturename" % surshaderout[0])

then after loop, 1 surshader, 1 surshaderout, , 1 surshadertex, next executed once:

path = os.path.dirname(surshadertex) f = surshadertex.split("/")[-1] tifname = os.path.splitext(f)[0] + ".tif" texname = os.path.splitext(f)[0] + ".tex" tifpath = os.path.join(path, tifname) texpath = os.path.join(path, texname)

indent same lines above it, , it'll run each element of surshader instead of once.

python list maya

No comments:

Post a Comment