Example #1
0
 def OnNamespaceFilePathSwapped(self, objNS, pOldPath, pNewPath, applyEdits ):
     
     lScene = self.mSys.Scene
     
     if (False == applyEdits):
         
         # do we have any other instances with old path
         anyOtherInstance = False
         for ns in self.mSys.Scene.Namespaces:
             if isinstance(ns, FBFileReference):
                 refPath = ns.ReferenceFilePath
                 if pOldPath == refPath and ns != objNS:
                     anyOtherInstance = True
                     break
         
         if True == anyOtherInstance:
             misc.DisconnectAllShaders(objNS)
             misc.DescriptionDisconnect(objNS)
         else:
             misc.DeleteShadersGraph(objNS, pOldPath)
         
         modelsMask = []
         objNS.RevertRefEdit()
         imp.DoFbxShadersGraphImport(True, 2, objNS, modelsMask)
         
         # holder
         base = os.path.splitext(pNewPath)[0]
         newXml = base + '.xml'
         misc.DescriptionStore(objNS, str(newXml))
         
     else:
         misc.SwapShadersGraph(objNS, str(pOldPath), str(pNewPath))
Example #2
0
    if isUpdated:
        # ask user to reload a shaders graph
        lOption = FBMessageBox(
            "External File Changed",
            "Please choose the following action for Reference: %s!" %
            (filename), "Load", "Merge", "Ignore")

    if lOption <> 3:
        lUndo = FBUndoManager()
        lUndo.Clear()

        modelsMask = []

        edits = ''
        misc.DisconnectAllShaders(lNSObj)
        if lNSObj.GetContentModified(
                FBPlugModificationFlag.kFBContentAllModifiedMask):
            edits = lNSObj.GetRefEdit()

        lNSObj.IsLoaded = False
        lNSObj.IsLoaded = True

        filename = lNSObj.ReferenceFilePath

        base = os.path.splitext(filename)[0]
        xmlname = base + '.xml'

        if lOption == 2:

            imp.DoFbxShadersGraphImport(True, 2, lNSObj, modelsMask)
Example #3
0
 
 if True == objNS.SwapReferenceFilePath( str(pNewPath), applyEdits, applyEdits ):
 
     if False == applyEdits:
     
         # do we have any other instances with old path
         anyOtherInstance = False
         for ns in self.mSys.Scene.Namespaces:
             if isinstance(ns, FBFileReference):
                 refPath = ns.ReferenceFilePath
                 if pOldPath == refPath and ns != objNS:
                     anyOtherInstance = True
                     break
         
         if True == anyOtherInstance:
             misc.DisconnectAllShaders(objNS)
             misc.DescriptionDisconnect(objNS)
         else:
             misc.DeleteShadersGraph(objNS, pOldPath)
         
         modelsMask = []
         objNS.RevertRefEdit()
         imp.DoFbxShadersGraphImport(True, 2, objNS, modelsMask)
         
         # holder
         base = os.path.splitext(pNewPath)[0]
         newXml = base + '.xml'
         misc.DescriptionStore(objNS, str(newXml))
         
     else:
         misc.SwapShadersGraph(objNS, str(pOldPath), str(pNewPath))         
Example #4
0
    def OnTimer( self ):
        for lFilePath, lReload in self.mNSModel.mRefFileReload.items():
            
            if False == os.path.isfile(lFilePath) and True == lReload:
                FBMessageBox( "External File Not Found", "The referenced file '%s' is not found!\nReference goes offline" % ( lFilePath ), "Ok" )
                
                if lFilePath in self.mNSModel.mRefFilePath:
                    for lFileRefName in self.mNSModel.mRefFilePath[lFilePath]:
                        lFileRefObj = FBFindObjectByFullName( 'FileReference::' + lFileRefName )
                        
                        if lFileRefObj is not None:
                            self.mNSModel.RemoveFileFromWatcher( lFileRefObj )
                            lFileRefObj.IsLoaded = False
                                
                    self.mNSModel.mRefFileReload[lFilePath] = False
                
                self.UpdateUI()
                self.UpdateTreeNamespace()
                
            elif lReload:
                FBMessageBox( "External File Changed", "The referenced file '%s' has been changed externally!" % ( lFilePath ), "OK" )
                if lFilePath in self.mNSModel.mRefFilePath:
                    for lFileRefName in self.mNSModel.mRefFilePath[lFilePath]:
                        lNSObj = FBFindObjectByFullName( 'FileReference::' + lFileRefName )
                        lOption = FBMessageBox( "External File Changed", "Please choose the following action for Reference: %s!" % ( lFileRefName ), "Load", "Merge", "Ignore" )
                        
                        if lOption <> 3:
                            lUndo = FBUndoManager()
                            lUndo.Clear()
                            
                            diff = []
                            
                            edits = ''
                            misc.DisconnectAllShaders(lNSObj)
                            if lNSObj.GetContentModified( FBPlugModificationFlag.kFBContentAllModifiedMask ):
                                edits = lNSObj.GetRefEdit()
                            
                            lNSObj.IsLoaded = False
                            lNSObj.IsLoaded = True
                            
                            filename = lNSObj.ReferenceFilePath
                            
                            base = os.path.splitext(filename)[0]
                            xmlname = base + '.xml'
                            
                            if lOption == 2:
                                
                                imp.DoFbxShadersGraphImport(True, 2, lNSObj, diff)
                                if len(edits) > 0:
                                    lNSObj.RevertRefEdit()
                                    lNSObj.ApplyRefEditPyScriptFromString( edits )
                                 
                                imp.LoadShaderGraphConnections(xmlname, xmlname, lNSObj, True)
                                
                            else:
                                modelsMask = []
                                lNSObj.RevertRefEdit()
                                imp.DoFbxShadersGraphImport(True, 2, lNSObj, modelsMask)
                            
                            # store new xml data
                            misc.DescriptionStore(lNSObj)
                            
                    self.mNSModel.mRefFileReload[lFilePath] = False

        self.mNSModel.UpdateFileWatcher()