From faf2631b48669a8c8822d3fdedbfded719b7fbb9 Mon Sep 17 00:00:00 2001 From: vanous Date: Tue, 23 Jul 2024 22:17:45 +0200 Subject: [PATCH] Change prints to log info and add mvr filter to logging --- dmx_temp_data.py | 5 +++++ logging.py | 8 +++++++- mvr.py | 12 ++++++------ panels/setup.py | 1 + 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/dmx_temp_data.py b/dmx_temp_data.py index 61b6c678..13a10ee8 100644 --- a/dmx_temp_data.py +++ b/dmx_temp_data.py @@ -123,6 +123,11 @@ def onUpdateLoggingFilter(self, context): default = False, update = onUpdateLoggingFilter) + logging_filter_mvr_import: BoolProperty( + name = _("MVR Import"), + default = False, + update = onUpdateLoggingFilter) + selected_tracker: StringProperty() # to pass data to fixture list selected_tracker_index: IntProperty() # to pass data to fixture list diff --git a/logging.py b/logging.py index d609266a..91352d69 100644 --- a/logging.py +++ b/logging.py @@ -32,6 +32,7 @@ def __init__(self): self.logging_filter_dmx_in = dmx.logging_filter_dmx_in self.logging_filter_mvr_xchange = dmx.logging_filter_mvr_xchange self.logging_filter_fixture = dmx.logging_filter_fixture + self.logging_filter_mvr_import = dmx.logging_filter_mvr_import @staticmethod def enable(level): @@ -72,6 +73,7 @@ def update_filters(): DMX_Log.logging_filter_dmx_in = dmx.logging_filter_dmx_in DMX_Log.logging_filter_mvr_xchange = dmx.logging_filter_mvr_xchange DMX_Log.logging_filter_fixture = dmx.logging_filter_fixture + DMX_Log.logging_filter_mvr_import = dmx.logging_filter_mvr_import for filter in log.filters: log.filters.remove(filter) @@ -88,7 +90,11 @@ def custom_filter(record): if any([x in record.filename for x in ["gdtf", "fixture"]]): return True - return not (DMX_Log.logging_filter_dmx_in or DMX_Log.logging_filter_mvr_xchange or DMX_Log.logging_filter_fixture) + if DMX_Log.logging_filter_mvr_import: + if any([x in record.filename for x in ["mvr"]]): + return True + + return not (DMX_Log.logging_filter_dmx_in or DMX_Log.logging_filter_mvr_xchange or DMX_Log.logging_filter_fixture or DMX_Log.logging_filter_mvr_import) log.addFilter(custom_filter) diff --git a/mvr.py b/mvr.py index 6c943dd1..a3269ada 100644 --- a/mvr.py +++ b/mvr.py @@ -60,7 +60,7 @@ def get_child_list(dmx, mscale, mvr_scene, child_list, layer_index, folder_path, viewlayer.active_layer_collection = viewport for truss_idx, truss_obj in enumerate(child_list.trusses): - print("creating Truss... %s" % truss_obj.name) + DMX_Log.log.info(f"Creating Truss... {truss_obj.name}") if fixture_group is None: group_name = truss_obj.name or "Truss" @@ -124,7 +124,7 @@ def process_mvr_object(context, mvr_scene, mvr_object, mvr_idx, mscale, extracte symdef_id = isinstance(mvr_object, pymvr.Symdef) current_path = os.path.dirname(os.path.realpath(__file__)) folder = os.path.join(current_path, "assets", "models", "mvr") - print("creating %s... %s" % (class_name, name)) + DMX_Log.log.info(f"creating {class_name}... {name}") def add_mvr_object(idx, node, mtx, collect, file=""): node_type = node.__class__.__name__ @@ -139,7 +139,7 @@ def add_mvr_object(idx, node, mtx, collect, file=""): mesh_exist = next((msh for msh in mesh_data if msh.name == mesh_name), False) exist = any(ob.data and ob.data.name == mesh_name for ob in collect.objects) world_matrix = mtx @ Matrix.Scale(scale_factor, 4) - print("adding %s... %s" % (node_type, mesh_name)) + DMX_Log.log.info(f"adding {node_type}... {mesh_name}") if not exist: if mesh_exist: @@ -160,7 +160,7 @@ def add_mvr_object(idx, node, mtx, collect, file=""): create_mvr_props(ob, class_name, obname, mesh_name, uid) if ob.data: ob.data.name = mesh_name - create_mvr_props(ob.data, node_type, obname, uid, item_name) + create_mvr_props(ob.data, node_type, obname, uid, item_name) if len(ob.users_collection) and ob.name in ob.users_collection[0].objects: ob.users_collection[0].objects.unlink(ob) elif ob.name in layer_collect.collection.objects: @@ -225,7 +225,7 @@ def add_mvr_object(idx, node, mtx, collect, file=""): obj_name = '%s - %s %d' % (class_name, mvr_object.name, mvr_idx) else: obj_name = '%s %d' % (class_name, mvr_idx) if mvr_idx >= 1 else class_name - print("creating extra collection", obj_name) + DMX_Log.log.info(f"Updating existing mvr object {obj_name}") active_collect = bpy.data.collections.new(obj_name) create_mvr_props(active_collect, class_name, name, uid) group_collect.children.link(active_collect) @@ -457,7 +457,7 @@ def load_mvr(dmx, file_name): if sym_name in (None, 'None'): sym_name = 'None Layer' auxcollect.children.link(sym_collect) - sym_collect.name = sym_collect.get('MVR Name') + sym_collect.name = sym_collect.get('MVR Name') for laycollect in layer_collect.children: if laycollect.get('MVR Class') is not None: diff --git a/panels/setup.py b/panels/setup.py index ebed5877..886a52f8 100644 --- a/panels/setup.py +++ b/panels/setup.py @@ -331,6 +331,7 @@ def draw(self, context): row.prop(context.window_manager.dmx, "logging_filter_mvr_xchange", toggle=True) row.prop(context.window_manager.dmx, "logging_filter_dmx_in", toggle=True) row.prop(context.window_manager.dmx, "logging_filter_fixture", toggle=True) + row.prop(context.window_manager.dmx, "logging_filter_mvr_import", toggle=True) row = layout.row() layout.operator("dmx.print_logging_path")