fix(rcf): collection children loading
This commit is contained in:
12
helpers.py
12
helpers.py
@ -172,7 +172,7 @@ def load_collection(target=None, data=None, create=False):
|
||||
# Load other meshes metadata
|
||||
# dump_anything.load(target, data)
|
||||
|
||||
# load objects into collection
|
||||
# link objects
|
||||
for object in data["objects"]:
|
||||
target.objects.link(bpy.data.objects[object])
|
||||
|
||||
@ -180,9 +180,15 @@ def load_collection(target=None, data=None, create=False):
|
||||
if object not in data["objects"]:
|
||||
target.objects.unlink(bpy.data.objects[object])
|
||||
|
||||
# Link childrens
|
||||
for collection in data["children"]:
|
||||
if collection not in target.children.keys():
|
||||
target.children.link(
|
||||
bpy.data.collections[collection])
|
||||
|
||||
target.id = data['id']
|
||||
except:
|
||||
print("Collection loading error")
|
||||
except Exception as e:
|
||||
print("Collection loading error: {}".format(e))
|
||||
|
||||
|
||||
def load_scene(target=None, data=None, create=False):
|
||||
|
17
operators.py
17
operators.py
@ -40,7 +40,7 @@ def client_list_callback(scene, context):
|
||||
global client_keys
|
||||
|
||||
items = []
|
||||
|
||||
if client_keys:
|
||||
for k in client_keys:
|
||||
if 'Client' in k[0]:
|
||||
name = k[1]
|
||||
@ -48,6 +48,7 @@ def client_list_callback(scene, context):
|
||||
|
||||
return items
|
||||
|
||||
|
||||
def clean_scene(elements=SUPPORTED_DATABLOCKS):
|
||||
for datablock in elements:
|
||||
datablock_ref = getattr(bpy.data, datablock)
|
||||
@ -104,14 +105,14 @@ def update_selected_object(context):
|
||||
|
||||
if len(selected_objects) > 0:
|
||||
|
||||
for obj in context.selected_objects:
|
||||
if obj.name not in client_data[0][1]['active_objects']:
|
||||
for obj in selected_objects:
|
||||
if obj not in client_data[0][1]['active_objects']:
|
||||
client_data[0][1]['active_objects'] = selected_objects
|
||||
|
||||
client_instance.set(client_key,client_data[0][1])
|
||||
break
|
||||
|
||||
elif client_data[0][1]['active_objects']:
|
||||
elif client_data and client_data[0][1]['active_objects']:
|
||||
client_data[0][1]['active_objects'] = []
|
||||
client_instance.set(client_key,client_data[0][1])
|
||||
|
||||
@ -144,6 +145,7 @@ def update_selected_object(context):
|
||||
|
||||
# return False
|
||||
|
||||
|
||||
def update_rights():
|
||||
|
||||
C = bpy.context
|
||||
@ -156,6 +158,7 @@ def update_rights():
|
||||
else:
|
||||
D.objects[obj.name].hide_select = True
|
||||
|
||||
|
||||
def init_datablocks():
|
||||
global client_instance
|
||||
|
||||
@ -527,7 +530,7 @@ def ordered(updates):
|
||||
for item in updates.items():
|
||||
if item[1].id.bl_rna.name in SUPPORTED_TYPES:
|
||||
uplist.append((SUPPORTED_TYPES.index(
|
||||
item[1].id.bl_rna.name), item[1].id.bl_rna.name, item[1].id.name))
|
||||
item[1].id.bl_rna.name), item[1].id.bl_rna.name, item[1].id.name,item[1].id ))
|
||||
|
||||
uplist.sort(key=itemgetter(0))
|
||||
return uplist
|
||||
@ -553,7 +556,7 @@ def depsgraph_update(scene):
|
||||
username = bpy.context.scene.session_settings.username
|
||||
update_selected_object(bpy.context)
|
||||
|
||||
selected_objects = helpers.get_selected_objects(scene)
|
||||
# selected_objects = helpers.get_selected_objects(scene)
|
||||
|
||||
|
||||
|
||||
@ -579,6 +582,7 @@ def depsgraph_update(scene):
|
||||
# data = client_instance.get(key)
|
||||
|
||||
# if data:
|
||||
# if update[3].id == username:
|
||||
# # Queue update
|
||||
# client_instance.set(key)
|
||||
# else:
|
||||
@ -586,7 +590,6 @@ def depsgraph_update(scene):
|
||||
# print("new")
|
||||
# client_instance.add(key)
|
||||
|
||||
if hasattr(bpy.context, 'selected_objects'):
|
||||
selected_objects = helpers.get_selected_objects(scene)
|
||||
if len(selected_objects) > 0:
|
||||
for updated_data in updates:
|
||||
|
Reference in New Issue
Block a user