From 9436961b66327d19b933ee5716c581c4d831b75b Mon Sep 17 00:00:00 2001 From: zeffii Date: Sat, 21 Jan 2017 21:25:32 +0100 Subject: [PATCH 01/16] first commit of vector mix io node --- nodes/vertex/vector_mix_io.py | 99 +++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 nodes/vertex/vector_mix_io.py diff --git a/nodes/vertex/vector_mix_io.py b/nodes/vertex/vector_mix_io.py new file mode 100644 index 000000000..bc77882e1 --- /dev/null +++ b/nodes/vertex/vector_mix_io.py @@ -0,0 +1,99 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +import bpy +from bpy.props import FloatProperty, EnumProperty + +from sverchok.node_tree import SverchCustomTreeNode +from sverchok.data_structure import dataCorrect + + +mode_options = [(n, n, '', idx) for idx, n in enumerate("XYZ")] + +class SvVectorMixIO(bpy.types.Node, SverchCustomTreeNode): + ''' Vectors out ''' + bl_idname = 'SvVectorMixIO' + bl_label = 'Vector Mix I/O' + bl_icon = 'OUTLINER_OB_EMPTY' + + selected_mode = EnumProperty( + items=mode_options, + description="offers....", + default="X", update=updateNode + ) + + co_value = FloatProperty( + default=0.0, update=updateNode + ) + + def sv_init(self, context): + self.inputs.new('VerticesSocket', "Vectors") + self.outputs.new('StringsSocket', "co replace").prop_name = 'co_value' + self.outputs.new('VerticesSocket', "Vectors") + + def draw_buttons(self, context, layout): + layout.prop(self, 'selected_mode', expand=True) + + def process(self): + vectors_out = self.outputs[0] + vectors_in, co_replace_in = self.inputs + + if not all(vectors_out.is_linked, vectors_in.is_linked): + return + + xyz = vectors_in.sv_get() + co_replace = co_replace_in.sv_get() + + # data = dataCorrect(xyz) + # X, Y, Z = [], [], [] + # for obj in data: + # x_, y_, z_ = (list(x) for x in zip(*obj)) + # X.append(x_) + # Y.append(y_) + # Z.append(z_) + + self.outputs['Vectors'].sv_set(series_vec) + + def process2(self): + if not self.outputs['Vectors'].is_linked: + return + inputs = self.inputs + X_ = inputs['X'].sv_get() + Y_ = inputs['Y'].sv_get() + Z_ = inputs['Z'].sv_get() + series_vec = [] + max_obj = max(map(len, (X_, Y_, Z_))) + fullList(X_, max_obj) + fullList(Y_, max_obj) + fullList(Z_, max_obj) + for i in range(max_obj): + + max_v = max(map(len, (X_[i], Y_[i], Z_[i]))) + fullList(X_[i], max_v) + fullList(Y_[i], max_v) + fullList(Z_[i], max_v) + series_vec.append(list(zip(X_[i], Y_[i], Z_[i]))) + + + +def register(): + bpy.utils.register_class(SvVectorsMixIO) + + +def unregister(): + bpy.utils.unregister_class(SvVectorsMixIO) -- GitLab From 1cde44e5f096c2b17ec3559bc58d82a58de2decd Mon Sep 17 00:00:00 2001 From: zeffii Date: Sat, 21 Jan 2017 22:17:55 +0100 Subject: [PATCH 02/16] add index from enum --- nodes/vertex/vector_mix_io.py | 42 ++++++++++++++++------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/nodes/vertex/vector_mix_io.py b/nodes/vertex/vector_mix_io.py index bc77882e1..b2d3ba007 100644 --- a/nodes/vertex/vector_mix_io.py +++ b/nodes/vertex/vector_mix_io.py @@ -21,7 +21,7 @@ from bpy.props import FloatProperty, EnumProperty from sverchok.node_tree import SverchCustomTreeNode from sverchok.data_structure import dataCorrect - +from sverchok.data_structure import updateNode mode_options = [(n, n, '', idx) for idx, n in enumerate("XYZ")] @@ -43,7 +43,7 @@ class SvVectorMixIO(bpy.types.Node, SverchCustomTreeNode): def sv_init(self, context): self.inputs.new('VerticesSocket', "Vectors") - self.outputs.new('StringsSocket', "co replace").prop_name = 'co_value' + self.inputs.new('StringsSocket', "co replace").prop_name = 'co_value' self.outputs.new('VerticesSocket', "Vectors") def draw_buttons(self, context, layout): @@ -55,10 +55,12 @@ class SvVectorMixIO(bpy.types.Node, SverchCustomTreeNode): if not all(vectors_out.is_linked, vectors_in.is_linked): return - + xyz = vectors_in.sv_get() co_replace = co_replace_in.sv_get() + index = ['XYZ'].find(self.selected_mode) + series_vec = [] # data = dataCorrect(xyz) # X, Y, Z = [], [], [] # for obj in data: @@ -69,31 +71,25 @@ class SvVectorMixIO(bpy.types.Node, SverchCustomTreeNode): self.outputs['Vectors'].sv_set(series_vec) - def process2(self): - if not self.outputs['Vectors'].is_linked: - return - inputs = self.inputs - X_ = inputs['X'].sv_get() - Y_ = inputs['Y'].sv_get() - Z_ = inputs['Z'].sv_get() - series_vec = [] - max_obj = max(map(len, (X_, Y_, Z_))) - fullList(X_, max_obj) - fullList(Y_, max_obj) - fullList(Z_, max_obj) - for i in range(max_obj): + # def process2(self): + + # max_obj = max(map(len, (X_, Y_, Z_))) + # fullList(X_, max_obj) + # fullList(Y_, max_obj) + # fullList(Z_, max_obj) + # for i in range(max_obj): - max_v = max(map(len, (X_[i], Y_[i], Z_[i]))) - fullList(X_[i], max_v) - fullList(Y_[i], max_v) - fullList(Z_[i], max_v) - series_vec.append(list(zip(X_[i], Y_[i], Z_[i]))) + # max_v = max(map(len, (X_[i], Y_[i], Z_[i]))) + # fullList(X_[i], max_v) + # fullList(Y_[i], max_v) + # fullList(Z_[i], max_v) + # series_vec.append(list(zip(X_[i], Y_[i], Z_[i]))) def register(): - bpy.utils.register_class(SvVectorsMixIO) + bpy.utils.register_class(SvVectorMixIO) def unregister(): - bpy.utils.unregister_class(SvVectorsMixIO) + bpy.utils.unregister_class(SvVectorMixIO) -- GitLab From 3542e7ebba2ef8fdb99c9a8ccff548e0a89a0f34 Mon Sep 17 00:00:00 2001 From: zeffii Date: Sun, 22 Jan 2017 11:54:40 +0100 Subject: [PATCH 03/16] revises new node into rewire node --- nodes/vertex/vector_mix_io.py | 95 ---------------------------------- nodes/vertex/vector_rewire.py | 97 +++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 95 deletions(-) delete mode 100644 nodes/vertex/vector_mix_io.py create mode 100644 nodes/vertex/vector_rewire.py diff --git a/nodes/vertex/vector_mix_io.py b/nodes/vertex/vector_mix_io.py deleted file mode 100644 index b2d3ba007..000000000 --- a/nodes/vertex/vector_mix_io.py +++ /dev/null @@ -1,95 +0,0 @@ -# ##### BEGIN GPL LICENSE BLOCK ##### -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# ##### END GPL LICENSE BLOCK ##### - -import bpy -from bpy.props import FloatProperty, EnumProperty - -from sverchok.node_tree import SverchCustomTreeNode -from sverchok.data_structure import dataCorrect -from sverchok.data_structure import updateNode - -mode_options = [(n, n, '', idx) for idx, n in enumerate("XYZ")] - -class SvVectorMixIO(bpy.types.Node, SverchCustomTreeNode): - ''' Vectors out ''' - bl_idname = 'SvVectorMixIO' - bl_label = 'Vector Mix I/O' - bl_icon = 'OUTLINER_OB_EMPTY' - - selected_mode = EnumProperty( - items=mode_options, - description="offers....", - default="X", update=updateNode - ) - - co_value = FloatProperty( - default=0.0, update=updateNode - ) - - def sv_init(self, context): - self.inputs.new('VerticesSocket', "Vectors") - self.inputs.new('StringsSocket', "co replace").prop_name = 'co_value' - self.outputs.new('VerticesSocket', "Vectors") - - def draw_buttons(self, context, layout): - layout.prop(self, 'selected_mode', expand=True) - - def process(self): - vectors_out = self.outputs[0] - vectors_in, co_replace_in = self.inputs - - if not all(vectors_out.is_linked, vectors_in.is_linked): - return - - xyz = vectors_in.sv_get() - co_replace = co_replace_in.sv_get() - index = ['XYZ'].find(self.selected_mode) - - series_vec = [] - # data = dataCorrect(xyz) - # X, Y, Z = [], [], [] - # for obj in data: - # x_, y_, z_ = (list(x) for x in zip(*obj)) - # X.append(x_) - # Y.append(y_) - # Z.append(z_) - - self.outputs['Vectors'].sv_set(series_vec) - - # def process2(self): - - # max_obj = max(map(len, (X_, Y_, Z_))) - # fullList(X_, max_obj) - # fullList(Y_, max_obj) - # fullList(Z_, max_obj) - # for i in range(max_obj): - - # max_v = max(map(len, (X_[i], Y_[i], Z_[i]))) - # fullList(X_[i], max_v) - # fullList(Y_[i], max_v) - # fullList(Z_[i], max_v) - # series_vec.append(list(zip(X_[i], Y_[i], Z_[i]))) - - - -def register(): - bpy.utils.register_class(SvVectorMixIO) - - -def unregister(): - bpy.utils.unregister_class(SvVectorMixIO) diff --git a/nodes/vertex/vector_rewire.py b/nodes/vertex/vector_rewire.py new file mode 100644 index 000000000..75faa5e4d --- /dev/null +++ b/nodes/vertex/vector_rewire.py @@ -0,0 +1,97 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +import bpy +from bpy.props import EnumProperty + +from sverchok.node_tree import SverchCustomTreeNode +from sverchok.data_structure import dataCorrect +from sverchok.data_structure import updateNode + +options = 'X Y Z -1 0 1'.split(' ') +mode_options = [(n, n, '', idx) for idx, n in enumerate(options)] + +class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): + ''' Rewire components of a vector''' + bl_idname = 'SvVectorRewire' + bl_label = 'Vector Rewire' + bl_icon = 'OUTLINER_OB_EMPTY' + + selected_mode_from = EnumProperty( + items=mode_options, + description="offers....", + default="X", update=updateNode + ) + + selected_mode_to = EnumProperty( + items=mode_options, + description="offers....", + default="Z", update=updateNode + ) + + def sv_init(self, context): + self.inputs.new('VerticesSocket', "Vectors") + self.outputs.new('VerticesSocket', "Vectors") + + def draw_buttons(self, context, layout): + row = layout.row(align=True) + row.prop(self, 'selected_mode_from', text='') + row.label(icon='ARROW_LEFTRIGHT') + row.prop(self, 'selected_mode_to', text='') + + def process(self): + vectors_out = self.outputs[0] + vectors_in = self.inputs[0] + + if not all([vectors_out.is_linked, vectors_in.is_linked]): + return + + xyz = vectors_in.sv_get() + + index_from = options.index(self.selected_mode_from) + index_to = options.index(self.selected_mode_to) + switching = (index_from, index_to) + sorted_tuple = tuple(sorted(switching)) + + # for instance X->X , return unprocessed + if len(set(switching)) == 1: + vectors_out.sv_set(xyz) + return + + rewire_dict = {(0, 1): (1, 0, 2), (0, 2): (2, 1, 0), (1, 2): (0, 2, 1)} + + series_vec = [] + for obj in xyz: + + # handles xy xz yx yz zx zy + if sorted_tuple in rewire_dict.keys(): + x, y, z = rewire_dict.get(sorted_tuple) + coords = ([v[x], v[y], v[z]] for v in obj) + series_vec.append(list(coords)) + continue + + + vectors_out.sv_set(series_vec) + + +def register(): + bpy.utils.register_class(SvVectorRewire) + + +def unregister(): + bpy.utils.unregister_class(SvVectorRewire) -- GitLab From ecc4743d1ffdadab5072a55614b01ec73dbc1fa6 Mon Sep 17 00:00:00 2001 From: zeffii Date: Sun, 22 Jan 2017 21:34:12 +0100 Subject: [PATCH 04/16] commits vagrant code --- nodes/vertex/vector_rewire.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nodes/vertex/vector_rewire.py b/nodes/vertex/vector_rewire.py index 75faa5e4d..4ec82140c 100644 --- a/nodes/vertex/vector_rewire.py +++ b/nodes/vertex/vector_rewire.py @@ -66,13 +66,13 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): index_from = options.index(self.selected_mode_from) index_to = options.index(self.selected_mode_to) switching = (index_from, index_to) - sorted_tuple = tuple(sorted(switching)) # for instance X->X , return unprocessed if len(set(switching)) == 1: vectors_out.sv_set(xyz) return + sorted_tuple = tuple(sorted(switching)) rewire_dict = {(0, 1): (1, 0, 2), (0, 2): (2, 1, 0), (1, 2): (0, 2, 1)} series_vec = [] @@ -84,6 +84,8 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): coords = ([v[x], v[y], v[z]] for v in obj) series_vec.append(list(coords)) continue + else: + if 3 in switching vectors_out.sv_set(series_vec) -- GitLab From a3cbd229d08c5910a17b2a37d2a2451aaa1bcdcd Mon Sep 17 00:00:00 2001 From: zeffii Date: Sun, 22 Jan 2017 22:20:30 +0100 Subject: [PATCH 05/16] adds constants --- nodes/vertex/vector_rewire.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/nodes/vertex/vector_rewire.py b/nodes/vertex/vector_rewire.py index 4ec82140c..836011ff7 100644 --- a/nodes/vertex/vector_rewire.py +++ b/nodes/vertex/vector_rewire.py @@ -24,7 +24,9 @@ from sverchok.data_structure import dataCorrect from sverchok.data_structure import updateNode options = 'X Y Z -1 0 1'.split(' ') +options2 = 'X Y Z'.split(' ') mode_options = [(n, n, '', idx) for idx, n in enumerate(options)] +mode_options2 = [(n, n, '', idx) for idx, n in enumerate(options2)] class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): ''' Rewire components of a vector''' @@ -39,7 +41,7 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): ) selected_mode_to = EnumProperty( - items=mode_options, + items=mode_options2, description="offers....", default="Z", update=updateNode ) @@ -73,7 +75,7 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): return sorted_tuple = tuple(sorted(switching)) - rewire_dict = {(0, 1): (1, 0, 2), (0, 2): (2, 1, 0), (1, 2): (0, 2, 1)} + rewire_dict = {(0, 1): (1, 0, 2), (0, 2): (2, 1, 0), (1, 2): (0, 2, 1)} series_vec = [] for obj in xyz: @@ -84,8 +86,15 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): coords = ([v[x], v[y], v[z]] for v in obj) series_vec.append(list(coords)) continue - else: - if 3 in switching + elif switching[0] in {3, 4, 5}: + value = {3: -1, 4: 0, 5: 1}.get(switching[0]) + if switching[1] == 0: + coords = ([value, v[1], v[2]] for v in obj) + elif switching[1] == 1: + coords = ([v[0], value, v[2]] for v in obj) + else: # 2 + coords = ([v[0], v[1], value] for v in obj) + series_vec.append(list(coords)) vectors_out.sv_set(series_vec) -- GitLab From a8a7cdf2fb23ba0a66b6383b6619e1a766f51fa7 Mon Sep 17 00:00:00 2001 From: zeffii Date: Mon, 23 Jan 2017 16:10:58 +0100 Subject: [PATCH 06/16] add scalar socket --- nodes/vertex/vector_rewire.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/nodes/vertex/vector_rewire.py b/nodes/vertex/vector_rewire.py index 836011ff7..80c77b509 100644 --- a/nodes/vertex/vector_rewire.py +++ b/nodes/vertex/vector_rewire.py @@ -23,7 +23,7 @@ from sverchok.node_tree import SverchCustomTreeNode from sverchok.data_structure import dataCorrect from sverchok.data_structure import updateNode -options = 'X Y Z -1 0 1'.split(' ') +options = 'X Y Z -1 0 1 Scalar'.split(' ') options2 = 'X Y Z'.split(' ') mode_options = [(n, n, '', idx) for idx, n in enumerate(options)] mode_options2 = [(n, n, '', idx) for idx, n in enumerate(options2)] @@ -44,10 +44,13 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): items=mode_options2, description="offers....", default="Z", update=updateNode - ) + ) + + scalar = FloatProperty(default=0.0, update=updateNode) def sv_init(self, context): self.inputs.new('VerticesSocket', "Vectors") + self.inputs.new('StringsSocket', "Scalar").prop_name = "scalar" self.outputs.new('VerticesSocket', "Vectors") def draw_buttons(self, context, layout): @@ -57,8 +60,9 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): row.prop(self, 'selected_mode_to', text='') def process(self): - vectors_out = self.outputs[0] vectors_in = self.inputs[0] + scalar_in = self.inputs[1] + vectors_out = self.outputs[0] if not all([vectors_out.is_linked, vectors_in.is_linked]): return @@ -80,13 +84,14 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): series_vec = [] for obj in xyz: - # handles xy xz yx yz zx zy if sorted_tuple in rewire_dict.keys(): + # handles xy xz yx yz zx zy x, y, z = rewire_dict.get(sorted_tuple) coords = ([v[x], v[y], v[z]] for v in obj) series_vec.append(list(coords)) - continue + elif switching[0] in {3, 4, 5}: + # handles -1 0 1 -> xyz value = {3: -1, 4: 0, 5: 1}.get(switching[0]) if switching[1] == 0: coords = ([value, v[1], v[2]] for v in obj) @@ -96,6 +101,12 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): coords = ([v[0], v[1], value] for v in obj) series_vec.append(list(coords)) + else switching[0] == 6: + # handles socket s. -> xyz + scalar_data = scalar_in.sv_get() + if isinstance(scalar_data, list) and len(scalar_data) > 0: + + vectors_out.sv_set(series_vec) -- GitLab From 716f8ff4d943244a4c58c05d47bc3f8ae696edf1 Mon Sep 17 00:00:00 2001 From: zeffii Date: Mon, 23 Jan 2017 16:45:29 +0100 Subject: [PATCH 07/16] add full yielder --- nodes/vertex/vector_rewire.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/nodes/vertex/vector_rewire.py b/nodes/vertex/vector_rewire.py index 80c77b509..00771620b 100644 --- a/nodes/vertex/vector_rewire.py +++ b/nodes/vertex/vector_rewire.py @@ -82,7 +82,7 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): rewire_dict = {(0, 1): (1, 0, 2), (0, 2): (2, 1, 0), (1, 2): (0, 2, 1)} series_vec = [] - for obj in xyz: + for idx, obj in enumerate(xyz): if sorted_tuple in rewire_dict.keys(): # handles xy xz yx yz zx zy @@ -104,8 +104,27 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): else switching[0] == 6: # handles socket s. -> xyz scalar_data = scalar_in.sv_get() - if isinstance(scalar_data, list) and len(scalar_data) > 0: - + if not (isinstance(scalar_data, list) and len(scalar_data) > 0): + continue + + max_major_index = len(scalar_data)-1 + + # this will yield until no longer called + def next_value(idx, data): + idx = -1 if idx > max_major_index else idx + for d in data[idx]: + yield d + yield data[idx][-1] + + yield_value = next_value(idx, scalar_data) + + if switching[1] == 0: + coords = ([next(yield_value), v[1], v[2]] for v in obj) + elif switching[1] == 1: + coords = ([v[0], next(yield_value), v[2]] for v in obj) + else: # 2 + coords = ([v[0], v[1], next(yield_value)] for v in obj) + vectors_out.sv_set(series_vec) -- GitLab From 4ca0733cf43fa7f1dc838a1b1aa07ea24a121fdf Mon Sep 17 00:00:00 2001 From: zeffii Date: Mon, 23 Jan 2017 21:42:32 +0100 Subject: [PATCH 08/16] add endless yielding --- nodes/vertex/vector_rewire.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/nodes/vertex/vector_rewire.py b/nodes/vertex/vector_rewire.py index 00771620b..3ea2f59a3 100644 --- a/nodes/vertex/vector_rewire.py +++ b/nodes/vertex/vector_rewire.py @@ -17,8 +17,7 @@ # ##### END GPL LICENSE BLOCK ##### import bpy -from bpy.props import EnumProperty - +from bpy.props import EnumProperty, FloatProperty from sverchok.node_tree import SverchCustomTreeNode from sverchok.data_structure import dataCorrect from sverchok.data_structure import updateNode @@ -101,20 +100,21 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): coords = ([v[0], v[1], value] for v in obj) series_vec.append(list(coords)) - else switching[0] == 6: + elif switching[0] == 6: + print('am here') # handles socket s. -> xyz scalar_data = scalar_in.sv_get() if not (isinstance(scalar_data, list) and len(scalar_data) > 0): + print('showing here') continue - max_major_index = len(scalar_data)-1 - # this will yield until no longer called def next_value(idx, data): - idx = -1 if idx > max_major_index else idx - for d in data[idx]: + midx = -1 if idx > len(data)-1 else idx + for d in data[midx]: yield d - yield data[idx][-1] + while True: + yield data[midx][-1] yield_value = next_value(idx, scalar_data) @@ -124,7 +124,7 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): coords = ([v[0], next(yield_value), v[2]] for v in obj) else: # 2 coords = ([v[0], v[1], next(yield_value)] for v in obj) - + series_vec.append(list(coords)) vectors_out.sv_set(series_vec) -- GitLab From 274a71fd4290e200be95af9119c40dbb56d62380 Mon Sep 17 00:00:00 2001 From: zeffii Date: Mon, 23 Jan 2017 21:44:02 +0100 Subject: [PATCH 09/16] add SvVectorRewire to index.md --- index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/index.md b/index.md index 3fe0e03ab..33c06d507 100644 --- a/index.md +++ b/index.md @@ -151,6 +151,7 @@ SvInterpolationNodeMK3 SvVertSortNode SvNoiseNodeMK2 + SvVectorRewire svAxisInputNode SvAxisInputNodeMK2 -- GitLab From ced997e7a3d88eed30f7a799dc873615da4c802c Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 24 Jan 2017 10:57:00 +0100 Subject: [PATCH 10/16] remove -1 0 1 modes in favour of Scalar --- nodes/list_main/func.py | 6 +++--- nodes/vertex/vector_rewire.py | 15 ++------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/nodes/list_main/func.py b/nodes/list_main/func.py index 80673a9cd..7ce6ff30e 100644 --- a/nodes/list_main/func.py +++ b/nodes/list_main/func.py @@ -62,12 +62,12 @@ class ListFuncNode(bpy.types.Node, SverchCustomTreeNode): "MIN": min, "MAX": max, "AVR": self.avr, - "SUM": sum, - #"ACC": acc + "SUM": sum + #, "ACC": acc } if 'Function' in self.outputs and self.outputs['Function'].is_linked: if 'Data' in self.inputs and self.inputs['Data'].is_linked: - data = self.inputs['Data'].sv_get + data = self.inputs['Data'].sv_get() func = func_dict[self.func_] if not self.level: diff --git a/nodes/vertex/vector_rewire.py b/nodes/vertex/vector_rewire.py index 3ea2f59a3..bb697858b 100644 --- a/nodes/vertex/vector_rewire.py +++ b/nodes/vertex/vector_rewire.py @@ -22,7 +22,7 @@ from sverchok.node_tree import SverchCustomTreeNode from sverchok.data_structure import dataCorrect from sverchok.data_structure import updateNode -options = 'X Y Z -1 0 1 Scalar'.split(' ') +options = 'X Y Z Scalar'.split(' ') options2 = 'X Y Z'.split(' ') mode_options = [(n, n, '', idx) for idx, n in enumerate(options)] mode_options2 = [(n, n, '', idx) for idx, n in enumerate(options2)] @@ -89,18 +89,7 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): coords = ([v[x], v[y], v[z]] for v in obj) series_vec.append(list(coords)) - elif switching[0] in {3, 4, 5}: - # handles -1 0 1 -> xyz - value = {3: -1, 4: 0, 5: 1}.get(switching[0]) - if switching[1] == 0: - coords = ([value, v[1], v[2]] for v in obj) - elif switching[1] == 1: - coords = ([v[0], value, v[2]] for v in obj) - else: # 2 - coords = ([v[0], v[1], value] for v in obj) - series_vec.append(list(coords)) - - elif switching[0] == 6: + elif switching[0] == 3: print('am here') # handles socket s. -> xyz scalar_data = scalar_in.sv_get() -- GitLab From d71aee2a8aa2b56476105d0a90775d3d20caa8ea Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 24 Jan 2017 11:41:28 +0100 Subject: [PATCH 11/16] doc changes --- docs/nodes/vertex/vertex_index.rst | 3 ++- nodes/vertex/vector_rewire.py | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/nodes/vertex/vertex_index.rst b/docs/nodes/vertex/vertex_index.rst index 5297c1c17..dc01a2d92 100644 --- a/docs/nodes/vertex/vertex_index.rst +++ b/docs/nodes/vertex/vertex_index.rst @@ -11,7 +11,8 @@ Vector interpolation_mk3 line_evaluate math - noise + noise_mk2 + vector_rewire vector_in vector_out vector_polar_in diff --git a/nodes/vertex/vector_rewire.py b/nodes/vertex/vector_rewire.py index bb697858b..911ed9138 100644 --- a/nodes/vertex/vector_rewire.py +++ b/nodes/vertex/vector_rewire.py @@ -90,11 +90,9 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): series_vec.append(list(coords)) elif switching[0] == 3: - print('am here') # handles socket s. -> xyz scalar_data = scalar_in.sv_get() if not (isinstance(scalar_data, list) and len(scalar_data) > 0): - print('showing here') continue # this will yield until no longer called -- GitLab From 2700be2767518bbea83f6512bb5a300505fe1668 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 24 Jan 2017 11:47:28 +0100 Subject: [PATCH 12/16] conflict mitigation --- nodes/list_main/func.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodes/list_main/func.py b/nodes/list_main/func.py index 7ce6ff30e..388be1e0b 100644 --- a/nodes/list_main/func.py +++ b/nodes/list_main/func.py @@ -37,7 +37,7 @@ class ListFuncNode(bpy.types.Node, SverchCustomTreeNode): ("MIN", "Minimum", "", 1), ("MAX", "Maximum", "", 2), ("AVR", "Average", "", 3), - ("SUM", "Sum", "", 4), + ("SUM", "Sum", "", 4) #("ACC", "Accumulate", "", 5), ] func_ = EnumProperty(name="Function", description="Function choice", -- GitLab From 8ee1eec12325ca8913dbb73c1f01395cfba34298 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 24 Jan 2017 11:48:47 +0100 Subject: [PATCH 13/16] conflict mitigation 2 --- docs/nodes/vertex/vector_rewire.rst | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 docs/nodes/vertex/vector_rewire.rst diff --git a/docs/nodes/vertex/vector_rewire.rst b/docs/nodes/vertex/vector_rewire.rst new file mode 100644 index 000000000..d73b23edf --- /dev/null +++ b/docs/nodes/vertex/vector_rewire.rst @@ -0,0 +1,27 @@ +Vector Rewire +============= + +Functionality +------------- + +Use this node to swap Vector components, for instance pass X to Y (and Y to X ). Or completely filter out a component by switching to the Scalar option. it will default to *0.0* when the Scalar socket is unconnected, when connected it will replace the component with the values from the socket. If the content of the Scalar input lists don't match the length of the Vectors list, the node will repeat the last value in the list or sublist (expected Sverchok behaviour). + +.. image:: https://cloud.githubusercontent.com/assets/619340/22211977/3bb60a64-e18f-11e6-82ca-5afac681b195.png + :alt: with vector rewire + + +Inputs +------ + +**Vectors** - Any list of Vector/Vertex lists +**Scalar** - value or series of values, will auto repeat last valid value to match Vector count. + + +Outputs +------- + +**Vector** - Vertex or series of vertices + + + + -- GitLab From e0211b1f51e0bc92db26aa4e297db2adfbb51365 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 24 Jan 2017 11:49:05 +0100 Subject: [PATCH 14/16] conflict mitigation 3 --- nodes/list_main/func.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodes/list_main/func.py b/nodes/list_main/func.py index 388be1e0b..d6d2d83be 100644 --- a/nodes/list_main/func.py +++ b/nodes/list_main/func.py @@ -63,7 +63,7 @@ class ListFuncNode(bpy.types.Node, SverchCustomTreeNode): "MAX": max, "AVR": self.avr, "SUM": sum - #, "ACC": acc + #"ACC": acc } if 'Function' in self.outputs and self.outputs['Function'].is_linked: if 'Data' in self.inputs and self.inputs['Data'].is_linked: -- GitLab From fba4e1e6d7ccc9037275ff3ad82be7bae2844aa0 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 24 Jan 2017 11:50:50 +0100 Subject: [PATCH 15/16] conflict mitigation 4 --- nodes/list_main/func.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nodes/list_main/func.py b/nodes/list_main/func.py index d6d2d83be..26304c1bb 100644 --- a/nodes/list_main/func.py +++ b/nodes/list_main/func.py @@ -63,7 +63,6 @@ class ListFuncNode(bpy.types.Node, SverchCustomTreeNode): "MAX": max, "AVR": self.avr, "SUM": sum - #"ACC": acc } if 'Function' in self.outputs and self.outputs['Function'].is_linked: if 'Data' in self.inputs and self.inputs['Data'].is_linked: -- GitLab From 7efabe30edfb5dfdc55318d1efbd616528c5cc9d Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 24 Jan 2017 11:59:06 +0100 Subject: [PATCH 16/16] correct comment --- nodes/vertex/vector_rewire.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodes/vertex/vector_rewire.py b/nodes/vertex/vector_rewire.py index 911ed9138..e6414af4b 100644 --- a/nodes/vertex/vector_rewire.py +++ b/nodes/vertex/vector_rewire.py @@ -84,7 +84,7 @@ class SvVectorRewire(bpy.types.Node, SverchCustomTreeNode): for idx, obj in enumerate(xyz): if sorted_tuple in rewire_dict.keys(): - # handles xy xz yx yz zx zy + # handles xy xz yz (all xyz combos) x, y, z = rewire_dict.get(sorted_tuple) coords = ([v[x], v[y], v[z]] for v in obj) series_vec.append(list(coords)) -- GitLab