This is cool. Thanks for sharing. I have a tool that does it in mel and I've been meaning to convert it to python for a while now. I shall try this soon and post anything worth while. Nice work.
On Mar 20, 6:06 am, Alexander Mirgorodsky <[email protected]> wrote: > Hi Martin! I think is what I understood You. > Below I give snipets from my render-toolkit code. > It only extracts because this toolkit complikated and renderman-aimed. > But I hope it will come across you on the right ideas. > So if we really want geting info from selected obj then: > > 1. Getting list shading engines: > def getsListShadingEngines(currentObj): > sgConections = mc.listConnections(currentObj,t="shadingEngine", d=1) > if sgConections != None: > ##remove duplicates from list > inicSgConnections =[ u for u in sgConections if u not in locals()['_[1]'] ] > return inicSgConnections > > 2. Finding shaders connected to shading engine: > > def rpExportMetaDataSG(currentObj, currentSG, time): > mayaShadersList = [] > co_shader_strings = "" # Its may co-shader special variable, in your case > its may be ane variable > shaderStringContent = " > if mc.connectionInfo( (currentSG+".surfaceShader"), isDestination=True) == > 1: > mayaShadersList = mc.listConnections((currentSG+".surfaceShader")) > ##!!!!!Check -If Not Connect > currentMayaShader = mayaShadersList[0] > shaderType = mc.nodeType(currentMayaShader) > #print currentMayaShader > > # Ok Martin - we know maya shader BUT if this "layer shader" or other > specific shaders like "useBackground" > > if shaderType == "layeredShader": > layerShadersConnection = mc.listConnections(currentMayaShader,t="lambert") > layerShadersConnection += mc.listConnections(currentMayaShader,t="blinn") > ..................................... > unicLayerShadersConnection = [ u for u in layerShadersConnection if u not in > locals()['_[1]'] ] > countLayers = len(unicLayerShadersConnection)-1 > while countLayers >=0: > co_shader_strings = #// MARTIN, NEXT YOUR CODE FOR working with > unicLayerShadersConnection[countLayers] > ......... > countLayers -= 1 > > elif shaderType == "useBackground": > shaderStringContent = # In this case Your procedure for getting connected > slots in useBackgound shaders > > ##elif shaderType == ##"Other specific"###: > > else: > shaderStringContent = ### Your procedure for finding connected slots in > current shader > > return shaderStringContent #My procedure return string - but your code can > return list of texture(file) nodes and file places on storage. > > 3. Example for working with finded(in consruction above) surface shader > > def mMainShaderAttrs(currentMayaShader,time): > surfaceColorContent = '' > if mc.connectionInfo((currentMayaShader+'.color'), isDestination=1): > listColorTextures = mc.listConnections(currentMayaShader+'.color') > if str(mc.nodeType(listColorTextures[0])) == 'file': > mayaColorTextureFile = mc.getAttr(listColorTextures[0]+'.fileTextureName', > time=time) > ................................. > > PS. I use time attribute as I work with animated shader attributes. You can > remove "time" - flag > > Alex Mirgorodsky. > Shading TD/ Lighting TD > Renovatio Entertainment. > > On Fri, Mar 18, 2011 at 6:57 PM, [email protected] < > > > > [email protected]> wrote: > > Hi > > Alexander, > > > Basically what I am trying to do is to get a list of all of the > > textures in my scene. > > From time to time I see people working on scenes where they are > > pulling textures from different locations. I want to make a tool that > > will gather the location of every texture in my scene. > > > Here is a little bit of my sudo code. > > > def Textures( listOfTexturesFilePaths=[], destinationDir: > > ''' > > Parameter Example: > > listOfTexturesFilePaths = [ 'c:/temp/water.tga', 'c:/temp/ > > textures/ground.tga', 'c:/temp/textures/stuff.tga' ] > > destinationDir = 'c:/newLocation' > > ''' > > > # look at import os > > > pass > > > # Do the copy of the maya file and patch it to the new textures > > > Hope this makes a lot of sense and thanks for your help. > > > Martin > > > On Mar 18, 5:00 am, Alexander Mirgorodsky <[email protected]> wrote: > > > Hi Martin! > > > Do You mean by word "object" > > > If this is geometry object that it does not store this information. > > > You can find it by going througр the chain "geometryShape -> Shading > > Engine > > > -> Shader(Surface, Displace, Volumetric etc) > > > ->Color(Float)Attribute->TextureNode->FileName"). > > > Can You explain the details of your problem? > > > > Alex Mirgorodsky. > > > Shading TD/ Lighting TD > > > Renovation Entertainment. > > > > On Fri, Mar 18, 2011 at 9:50 AM, [email protected] < > > > > [email protected]> wrote: > > > > Does anyone know the name of the command or the way that I can get the > > > > full path of the textures from a selected object? > > > > > Thanks, > > > > -m > > > > > -- > > > >http://groups.google.com/group/python_inside_maya > > > -- > >http://groups.google.com/group/python_inside_maya -- http://groups.google.com/group/python_inside_maya
