From 29b17386b8ef867e7235aa5490ccd41d0cf3fa7d Mon Sep 17 00:00:00 2001 From: zeffii Date: Sun, 30 Apr 2017 20:18:17 +0200 Subject: [PATCH 1/4] supress warning --- nodes/text/stethoscope_mk2.py | 8 +++++--- utils/sv_IO_monad_helpers.py | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/nodes/text/stethoscope_mk2.py b/nodes/text/stethoscope_mk2.py index 80028a566..44967b2a3 100644 --- a/nodes/text/stethoscope_mk2.py +++ b/nodes/text/stethoscope_mk2.py @@ -158,9 +158,11 @@ class SvStethoscopeNodeMK2(bpy.types.Node, SverchCustomTreeNode): def update(self): if not ("Data" in self.inputs): return - if not self.inputs[0].other: - nvBGL.callback_disable(node_id(self)) - + try: + if not self.inputs[0].other: + nvBGL.callback_disable(node_id(self)) + except: + print('stethoscope update holdout (not a problem)') def register(): diff --git a/utils/sv_IO_monad_helpers.py b/utils/sv_IO_monad_helpers.py index c9a1ec3c3..281577d1b 100644 --- a/utils/sv_IO_monad_helpers.py +++ b/utils/sv_IO_monad_helpers.py @@ -69,9 +69,9 @@ def unpack_monad(nodes, node_ref): cls_ref = monad.update_cls() node = nodes.new(cls_ref.bl_idname) - cls_dict = params.get('cls_dict') - node.input_template = cls_dict['input_template'] - node.output_template = cls_dict['output_template'] + # cls_dict = params.get('cls_dict') + # node.input_template = cls_dict['input_template'] + # node.output_template = cls_dict['output_template'] return node else: -- GitLab From 6db834979560360d3111e8c992e0aa47b4355f9a Mon Sep 17 00:00:00 2001 From: zeffii Date: Mon, 1 May 2017 12:02:02 +0200 Subject: [PATCH 2/4] add try except in different location --- nodes/text/stethoscope_mk2.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/nodes/text/stethoscope_mk2.py b/nodes/text/stethoscope_mk2.py index 44967b2a3..fea0deaf7 100644 --- a/nodes/text/stethoscope_mk2.py +++ b/nodes/text/stethoscope_mk2.py @@ -117,13 +117,12 @@ class SvStethoscopeNodeMK2(bpy.types.Node, SverchCustomTreeNode): if self.activate and inputs[0].is_linked: - # get scale - scale = 1.0 - with sv_preferences() as prefs: - try: + try: + with sv_preferences() as prefs: scale = prefs.stethoscope_view_scale - except: - scale = 1.0 + except: + # print('did not find preferences - you need to save user preferences') + scale = 1.0 # gather vertices from input data = inputs[0].sv_get(deepcopy=False) -- GitLab From b21ab8156e8bc8007ee8da83fdd82024a93eeecd Mon Sep 17 00:00:00 2001 From: zeffii Date: Mon, 1 May 2017 14:04:15 +0200 Subject: [PATCH 3/4] add safer addon lookup --- utils/context_managers.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/utils/context_managers.py b/utils/context_managers.py index 1fd653196..71b0ec101 100644 --- a/utils/context_managers.py +++ b/utils/context_managers.py @@ -1,7 +1,5 @@ import bpy -from sverchok.data_structure import SVERCHOK_NAME as addon_name - -import bpy +import sverchok from sverchok.data_structure import SVERCHOK_NAME as addon_name from contextlib import contextmanager @@ -28,6 +26,7 @@ def hard_freeze(self): yield self self.id_data.unfreeze(hard=True) + @contextmanager def sv_preferences(): ''' @@ -38,10 +37,12 @@ def sv_preferences(): with sv_preferences() as prefs: print(prefs.) ''' - addon = bpy.context.user_preferences.addons.get(addon_name) + # by using svercok.__name__ we increase likelyhood that the addon preferences will correspond + addon = bpy.context.user_preferences.addons.get(sverchok.__name__) if addon and hasattr(addon, "preferences"): yield addon.preferences + @contextmanager def new_input(node, ident, name): ''' -- GitLab From 7c55f52b5d156ba6dcac8bb30fbe178ee9f262c1 Mon Sep 17 00:00:00 2001 From: zeffii Date: Mon, 1 May 2017 20:00:39 +0200 Subject: [PATCH 4/4] add manual multiplier --- nodes/text/stethoscope_mk2.py | 10 +++++++++- settings.py | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/nodes/text/stethoscope_mk2.py b/nodes/text/stethoscope_mk2.py index fea0deaf7..e6ecec6ad 100644 --- a/nodes/text/stethoscope_mk2.py +++ b/nodes/text/stethoscope_mk2.py @@ -40,6 +40,9 @@ def high_contrast_color(c): L = 0.2126 * (c.r**g) + 0.7152 * (c.g**g) + 0.0722 * (c.b**g) return [(.1, .1, .1), (.95, .95, .95)][int(L < 0.5)] +def adjust_location(_x, _y, location_theta): + return _x * location_theta, _y * location_theta + class SvStethoscopeNodeMK2(bpy.types.Node, SverchCustomTreeNode): bl_idname = 'SvStethoscopeNodeMK2' @@ -120,9 +123,11 @@ class SvStethoscopeNodeMK2(bpy.types.Node, SverchCustomTreeNode): try: with sv_preferences() as prefs: scale = prefs.stethoscope_view_scale + location_theta = prefs.stethoscope_view_xy_multiplier except: # print('did not find preferences - you need to save user preferences') scale = 1.0 + location_theta = 1.0 # gather vertices from input data = inputs[0].sv_get(deepcopy=False) @@ -139,10 +144,13 @@ class SvStethoscopeNodeMK2(bpy.types.Node, SverchCustomTreeNode): # # implement another nvBGL parses for gfx processed_data = data + _x, _y = (self.location + Vector((self.width + 20, 0))) + location = adjust_location(_x, _y, location_theta) + draw_data = { 'tree_name': self.id_data.name[:], 'content': processed_data, - 'location': (self.location + Vector((self.width + 20, 0)))[:], + 'location': location, 'color': self.text_color[:], 'scale' : float(scale), 'mode': self.selected_mode[:], diff --git a/settings.py b/settings.py index 06d85e7f2..587cb1c3d 100644 --- a/settings.py +++ b/settings.py @@ -139,6 +139,8 @@ class SverchokPreferences(AddonPreferences): stethoscope_view_scale = FloatProperty( default=1.0, min=0.01, step=0.01, description='default stethoscope scale') + stethoscope_view_xy_multiplier = FloatProperty( + default=1.0, min=0.01, step=0.01, description='default stethoscope scale') def draw(self, context): @@ -155,7 +157,12 @@ class SverchokPreferences(AddonPreferences): col.prop(self, "over_sized_buttons") col.prop(self, "enable_live_objin", text='Enable Live Object-In') row_sub1 = col.row().split(0.5) - row_sub1.prop(self, 'stethoscope_view_scale', text='stethoscope scale') + box_sub1 = row_sub1.box() + box_sub1_col = box_sub1.column(align=True) + box_sub1_col.label('stethoscope mk2 settings') + box_sub1_col.prop(self, 'stethoscope_view_scale', text='scale') + box_sub1_col.prop(self, 'stethoscope_view_xy_multiplier', text='xy multiplier') + col.separator() col.label(text="Sverchok node theme settings") -- GitLab