0

I am trying to update linked rigs in blends files. It works fine, but it seems not to care about updating all connected data (rigs have linked models). I need to use function bpy.ops.outliner.lib_operation(type='RESOLVE') but if I saw what operation it makes it would be better to use them in our workflow

def updateAssets():
    print('\n============================================')
    # Loop through all the linked blend files
    scene_path = bpy.data.filepath
    resolved_path = ''
    linked = bpy.data.libraries
    updated = []
    if linked:
        for lib in linked:
            #print(lib)
            # Check if the blend file is actually linked
            #Print the file path of the linked blend file
        if 'Rigging' in lib.filepath:
            print("Linked blend file:", lib.filepath)

            filepath = lib.filepath
            resolved_path = resolvePath(scene_path,lib.filepath)
            if resolved_path:
                print('[RESOLVED]: '+resolved_path[0])
                latest = getLatest(resolved_path[0],resolved_path[1])
                print('[latets]: '+latest[0])
                if latest[1]:
                    up_version = update(lib.filepath,latest[0])
                    lib.filepath = up_version                    #!!!!!!!!!!!!!!!!!!!!!!
                    print('\n\t>>>>>[UPDATE]: '+up_version)
                    updated.append('>:   '+latest[0])
            # Get the collections from this library
            with bpy.data.libraries.load(filepath) as (data_from, data_to):
                # get the collections from the linked library
                collections = data_from.collections

            # Loop through the collections and print their names
            for col in collections:
                print("   ", col)
        updated = list(set(updated))                            
        #Shows a message box with a specific message 
        if updated:
            ShowMessageBox(updated,"--UPDATIN_ASSETS--", "PLUS") 
        else:
            updated = ["","ALL_UPTO DATE"]
            ShowMessageBox( updated,"--UPDATING_ASSETS--") 
else:
    ShowMessageBox([],' no assets linked', "ERROR")  
bpy.context.view_layer.update()

#updateAssets()

Maybe it doesn't work fine is because I only look at rigging paths but sometimes last rig has not last model so I needed to update just rigging package, but was hoping for correct model.

Duarte Farrajota Ramos
  • 59,425
  • 39
  • 130
  • 187
  • What is your question then? – Lukasz-40sth Aug 07 '23 at 17:55
  • When it comes to finding the operator's source code, this might be useful. Dunno if Blender have tools to recursively update linked libraries. After all, to update linked data from data itself linked, it would require to make a new file for that first level linked data with the updated linked data, ... I haven't heard of anything like this in vanilla Blender yet. – L0Lock Aug 07 '23 at 19:01
  • my question was how to get to source code of blender function that is bind to outliner operation and to see what it does and use it my way in python code. I have problem now that rig version 5 should have model v5 but it keeps v4 in scene because I updated linked rig file. I need to refresh all connections to that linked rig file, because v5 in itself has model v5. – tomas mikulak Aug 08 '23 at 08:46

0 Answers0