Beispiel #1
0
 def saveTextureList(self, *args, **kwargs):
   ''' write an xml file with a list of the scenes textures and timestamps '''
   fileNodes = pm.ls(type='file')
   sceneName = path.getSceneName()
   xmlFileName = sceneName+'_textureList'
   
   doc = Document()
   textureList = doc.createElement('textureList')
   textureList.setAttribute('sceneName', sceneName)
   doc.appendChild(textureList)
   
   for node in fileNodes:
     fileTextureName = pm.getAttr(node+'.fileTextureName')
     if os.path.isfile(fileTextureName):
       time = os.path.getmtime(fileTextureName)
       
       textureNode = doc.createElement('textureNode')
       textureNode.setAttribute('nodeName', node)
       textureList.appendChild(textureNode)
       
       texturePath = doc.createElement('path')
       texturePath.appendChild(doc.createTextNode(fileTextureName) )
       textureNode.appendChild(texturePath)
       
       textureTime = doc.createElement('time')   
       textureTime.appendChild(doc.createTextNode(str(time) ) )
       textureNode.appendChild(textureTime)
     
   f = open(self.settingsPath+xmlFileName+'.xml', 'w+')
   #f.write(doc.toprettyxml(indent='    ') ) #This is super slow !!!!!
   doc.writexml(f)
   f.close()
    def saveTextureList(self, *args, **kwargs):
        ''' write an xml file with a list of the scenes textures and timestamps '''
        fileNodes = pm.ls(type='file')
        sceneName = path.getSceneName()
        xmlFileName = sceneName + '_textureList'

        doc = Document()
        textureList = doc.createElement('textureList')
        textureList.setAttribute('sceneName', sceneName)
        doc.appendChild(textureList)

        for node in fileNodes:
            fileTextureName = pm.getAttr(node + '.fileTextureName')
            if os.path.isfile(fileTextureName):
                time = os.path.getmtime(fileTextureName)

                textureNode = doc.createElement('textureNode')
                textureNode.setAttribute('nodeName', node)
                textureList.appendChild(textureNode)

                texturePath = doc.createElement('path')
                texturePath.appendChild(doc.createTextNode(fileTextureName))
                textureNode.appendChild(texturePath)

                textureTime = doc.createElement('time')
                textureTime.appendChild(doc.createTextNode(str(time)))
                textureNode.appendChild(textureTime)

        f = open(self.settingsPath + xmlFileName + '.xml', 'w+')
        #f.write(doc.toprettyxml(indent='    ') ) #This is super slow !!!!!
        doc.writexml(f)
        f.close()
Beispiel #3
0
  def reloadChangedTextures(self, *args, **kwargs):
    ''' '''
    fileNodes = pm.ls(type='file')
    sceneName = path.getSceneName()
    xmlFileName = sceneName+'_textureList'
    
    if os.path.exists(self.settingsPath+xmlFileName+'.xml'):
      textureList = xml.dom.minidom.parse(self.settingsPath+xmlFileName+'.xml')

      for node in fileNodes:    
        fileTextureName = pm.getAttr(node+'.fileTextureName')
          
        for nodeStored in textureList.getElementsByTagName('textureNode'):
          nodeNameStored = nodeStored.getAttribute('nodeName')
          if node == nodeNameStored:
            time = os.path.getmtime(fileTextureName)
            
            timeList = nodeStored.getElementsByTagName('time')
            timeNode = timeList[0]
            timeChild = timeNode.firstChild
            timeStored= timeChild.data
            
            if str(time) != timeStored:
              self.reloadTexture(node)         
        
      self.saveTextureList()
    else:
      self.saveTextureList()
      self.reloadTextures()
    def reloadChangedTextures(self, *args, **kwargs):
        ''' '''
        fileNodes = pm.ls(type='file')
        sceneName = path.getSceneName()
        xmlFileName = sceneName + '_textureList'

        if os.path.exists(self.settingsPath + xmlFileName + '.xml'):
            textureList = xml.dom.minidom.parse(self.settingsPath +
                                                xmlFileName + '.xml')

            for node in fileNodes:
                fileTextureName = pm.getAttr(node + '.fileTextureName')

                for nodeStored in textureList.getElementsByTagName(
                        'textureNode'):
                    nodeNameStored = nodeStored.getAttribute('nodeName')
                    if node == nodeNameStored:
                        time = os.path.getmtime(fileTextureName)

                        timeList = nodeStored.getElementsByTagName('time')
                        timeNode = timeList[0]
                        timeChild = timeNode.firstChild
                        timeStored = timeChild.data

                        if str(time) != timeStored:
                            self.reloadTexture(node)

            self.saveTextureList()
        else:
            self.saveTextureList()
            self.reloadTextures()