Skip to content

Commit

Permalink
Change prints to log info and add mvr filter to logging
Browse files Browse the repository at this point in the history
  • Loading branch information
vanous committed Jul 23, 2024
1 parent 2f126a6 commit faf2631
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
5 changes: 5 additions & 0 deletions dmx_temp_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down
12 changes: 6 additions & 6 deletions mvr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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__
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions panels/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit faf2631

Please sign in to comment.