fix: scene cleaning
This commit is contained in:
parent
82022c9e4d
commit
504dd77405
@ -38,6 +38,14 @@ from replication.constants import (STATE_ACTIVE, STATE_AUTH,
|
|||||||
STATE_LOBBY,
|
STATE_LOBBY,
|
||||||
CONNECTING)
|
CONNECTING)
|
||||||
|
|
||||||
|
CLEARED_DATABLOCKS = ['actions', 'armatures', 'cache_files', 'cameras',
|
||||||
|
'collections', 'curves', 'filepath', 'fonts',
|
||||||
|
'grease_pencils', 'images', 'lattices', 'libraries',
|
||||||
|
'lightprobes', 'lights', 'linestyles', 'masks',
|
||||||
|
'materials', 'meshes', 'metaballs', 'movieclips',
|
||||||
|
'node_groups', 'objects', 'paint_curves', 'particles',
|
||||||
|
'scenes', 'shape_keys', 'sounds', 'speakers', 'texts',
|
||||||
|
'textures', 'volumes', 'worlds']
|
||||||
|
|
||||||
def find_from_attr(attr_name, attr_value, list):
|
def find_from_attr(attr_name, attr_value, list):
|
||||||
for item in list:
|
for item in list:
|
||||||
@ -101,23 +109,25 @@ def get_state_str(state):
|
|||||||
|
|
||||||
|
|
||||||
def clean_scene():
|
def clean_scene():
|
||||||
to_delete = [f for f in dir(bpy.data) if f not in ['brushes', 'palettes']]
|
for type_name in CLEARED_DATABLOCKS:
|
||||||
for type_name in to_delete:
|
sub_collection_to_avoid = [
|
||||||
try:
|
bpy.data.linestyles.get('LineStyle'),
|
||||||
sub_collection_to_avoid = [bpy.data.linestyles['LineStyle'], bpy.data.materials['Dots Stroke']]
|
bpy.data.materials.get('Dots Stroke')
|
||||||
type_collection = getattr(bpy.data, type_name)
|
]
|
||||||
items_to_remove = [i for i in type_collection if i not in sub_collection_to_avoid]
|
|
||||||
for item in items_to_remove:
|
type_collection = getattr(bpy.data, type_name)
|
||||||
try:
|
items_to_remove = [i for i in type_collection if i not in sub_collection_to_avoid]
|
||||||
type_collection.remove(item)
|
for item in items_to_remove:
|
||||||
except:
|
try:
|
||||||
continue
|
type_collection.remove(item)
|
||||||
except:
|
logging.info(item.name)
|
||||||
continue
|
except:
|
||||||
|
continue
|
||||||
|
|
||||||
# Clear sequencer
|
# Clear sequencer
|
||||||
bpy.context.scene.sequence_editor_clear()
|
bpy.context.scene.sequence_editor_clear()
|
||||||
|
|
||||||
|
|
||||||
def get_selected_objects(scene, active_view_layer):
|
def get_selected_objects(scene, active_view_layer):
|
||||||
return [obj.uuid for obj in scene.objects if obj.select_get(view_layer=active_view_layer)]
|
return [obj.uuid for obj in scene.objects if obj.select_get(view_layer=active_view_layer)]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user