From 08ce2d5ceeb63888d1c9508b003d41bdf124b93b Mon Sep 17 00:00:00 2001 From: Swann Martinez Date: Thu, 8 Aug 2019 18:12:13 +0200 Subject: [PATCH] feat: started to handle dependency --- __init__.py | 2 +- libs/replication | 2 +- operators.py | 20 ++++++++++++++++++-- ui.py | 1 + 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index 4469a19..4163c07 100644 --- a/__init__.py +++ b/__init__.py @@ -211,7 +211,7 @@ def register(): bpy.types.WindowManager.session = bpy.props.PointerProperty( type=SessionProps) - + bpy.types.ID.uuid = bpy.props.StringProperty(default="") bpy.context.window_manager.session.load() save_session_config(bpy.context.window_manager.session,bpy.context) operators.register() diff --git a/libs/replication b/libs/replication index 69df1e1..212dca0 160000 --- a/libs/replication +++ b/libs/replication @@ -1 +1 @@ -Subproject commit 69df1e1f4962151079fff5017038d7f9acd1afef +Subproject commit 212dca0825568427ef409a7a9236044ad6f7782b diff --git a/operators.py b/operators.py index 79f0c0e..8168fbb 100644 --- a/operators.py +++ b/operators.py @@ -64,6 +64,23 @@ context = None # client_data[0][1]['active_objects'] = [] # client.set(client_key, client_data[0][1]) +def add_datablock(datablock): + global client + child=None + + if hasattr(datablock,"data"): + child = add_datablock(datablock.data) + + if datablock.uuid and client.exist(datablock.uuid) : + return datablock.uuid + else: + new_uuid = client.add(datablock,childs=child) + datablock.uuid = new_uuid + return new_uuid + + + + # TODO: cleanup def init_supported_datablocks(supported_types_id): global client @@ -71,8 +88,7 @@ def init_supported_datablocks(supported_types_id): for type_id in supported_types_id: if hasattr(bpy.data,type_id): for item in getattr(bpy.data,type_id): - print(item) - client.add(item) + add_datablock(item) # def default_tick(): diff --git a/ui.py b/ui.py index a45acb6..b9a744d 100644 --- a/ui.py +++ b/ui.py @@ -199,6 +199,7 @@ class SESSION_PT_outliner(bpy.types.Panel): # Property area # area_msg = row.box() client_keys = operators.client.list() + client_keys = operators.client.list() if client_keys and len(client_keys) > 0: col = layout.column(align=True) for item in sorted(client_keys, key=get_client_key):