From e3708b53a97e63478a81b8cde06b3d6abfc48a7a Mon Sep 17 00:00:00 2001 From: satabol Date: Sun, 31 Mar 2024 00:13:29 +0300 Subject: [PATCH 1/4] - Add check if output sockets are connected before execute nodes. - For some nodes did exception if some input sockets are not connected. This show source of problems more precisely. --- nodes/CAD/crop_mesh_2d.py | 4 +- nodes/CAD/edges_intersect_mk3.py | 3 +- nodes/CAD/edges_to_faces_2d.py | 4 +- nodes/CAD/embed mesh.py | 2 + nodes/CAD/merge_mesh_2d.py | 4 +- nodes/CAD/merge_mesh_2d_lite.py | 4 +- nodes/analyzer/chess_selection.py | 2 + nodes/analyzer/distance_pp.py | 2 +- nodes/analyzer/kd_tree_path.py | 2 +- nodes/analyzer/object_insolation.py | 2 + nodes/analyzer/origins.py | 2 + nodes/analyzer/points_inside_mesh.py | 4 +- nodes/analyzer/project_point_to_line.py | 2 + nodes/analyzer/volume.py | 2 + nodes/color/color_in_mk1.py | 2 +- nodes/color/color_input.py | 2 + nodes/color/color_out_mk1.py | 4 +- nodes/curve/ellipse_curve.py | 4 +- nodes/curve/polyline.py | 2 +- nodes/dictionary/dictionary_out.py | 3 ++ nodes/exchange/bezier_in.py | 5 ++- nodes/generator/basic_3pt_arc.py | 2 + nodes/generator/basic_spline.py | 9 +---- nodes/generator/box_mk2.py | 8 ++-- nodes/generator/bricks.py | 2 +- nodes/generator/circle.py | 3 +- nodes/generator/cricket.py | 3 +- nodes/generator/cylinder_mk2.py | 2 +- nodes/generator/formula_shape.py | 2 + nodes/generator/image.py | 5 ++- nodes/generator/line_mk4.py | 6 ++- nodes/generator/ngon.py | 2 + nodes/generator/plane_mk3.py | 7 +--- nodes/generator/random_vector_mk3.py | 4 +- nodes/generator/segment.py | 2 + nodes/generator/sphere.py | 2 + nodes/generator/suzanne.py | 3 +- nodes/generator/torus_mk2.py | 3 +- nodes/generators_extended/box_rounded.py | 2 + nodes/generators_extended/ellipse_mk3.py | 5 +-- nodes/generators_extended/hilbert.py | 2 + nodes/generators_extended/hilbert3d.py | 2 + nodes/generators_extended/hilbert_image.py | 2 + nodes/generators_extended/pentagon_tiler.py | 3 +- nodes/generators_extended/polygon_grid.py | 3 +- nodes/generators_extended/regular_solid.py | 2 +- nodes/generators_extended/ring_mk2.py | 3 +- nodes/generators_extended/smooth_lines.py | 3 +- nodes/generators_extended/spiral_mk2.py | 5 +-- nodes/generators_extended/super_ellipsoid.py | 2 +- nodes/generators_extended/torus_knot_mk2.py | 5 +-- nodes/generators_extended/triangle.py | 3 +- nodes/generators_extended/wfc_texture.py | 4 +- nodes/layout/converter.py | 2 + nodes/list_main/decompose.py | 2 + nodes/list_main/delete_levels.py | 2 + nodes/list_main/func.py | 6 ++- nodes/list_main/index.py | 4 ++ nodes/list_main/join.py | 5 ++- nodes/list_main/length.py | 5 ++- nodes/list_main/match.py | 4 ++ nodes/list_main/statistics.py | 4 ++ nodes/list_main/sum_mk2.py | 4 ++ nodes/list_main/zip.py | 5 +++ nodes/list_masks/calc_mask.py | 3 +- nodes/list_masks/index_to_mask.py | 2 + nodes/list_masks/mask.py | 4 ++ nodes/list_masks/mask_convert.py | 1 - nodes/list_masks/mask_join.py | 4 ++ nodes/list_masks/mask_to_index.py | 4 ++ nodes/list_mutators/combinatorics.py | 12 ++++-- nodes/list_mutators/filter_empty_lists.py | 4 ++ nodes/list_mutators/find_closest.py | 3 ++ nodes/list_mutators/modifier.py | 8 ++-- nodes/list_mutators/multi_cache.py | 2 +- nodes/list_mutators/polygon_sort.py | 2 +- nodes/list_mutators/unique_items.py | 6 ++- nodes/list_struct/flip.py | 5 +++ nodes/list_struct/item.py | 3 ++ nodes/list_struct/item_insert.py | 8 +++- nodes/list_struct/levels.py | 4 ++ nodes/list_struct/numpy_array.py | 2 + nodes/list_struct/repeater.py | 4 ++ nodes/list_struct/reverse.py | 5 +++ nodes/list_struct/shift_mk2.py | 2 +- nodes/list_struct/shuffle.py | 5 +++ nodes/list_struct/slice.py | 5 +++ nodes/list_struct/sort.py | 2 + nodes/list_struct/split.py | 5 +++ nodes/list_struct/start_end.py | 5 +++ nodes/logic/custom_switcher.py | 4 ++ nodes/matrix/apply_and_join.py | 2 + nodes/matrix/euler.py | 2 +- nodes/matrix/interpolation.py | 3 +- nodes/matrix/iterate.py | 7 ++++ nodes/matrix/matrix_deform.py | 2 + nodes/matrix/matrix_in_mk4.py | 2 +- nodes/matrix/matrix_math.py | 4 +- nodes/matrix/matrix_normal.py | 4 +- nodes/matrix/matrix_track_to.py | 6 +-- nodes/matrix/shear.py | 2 +- nodes/network/file_path.py | 3 +- nodes/number/curve_mapper.py | 2 + nodes/number/easing.py | 3 ++ nodes/number/exponential.py | 2 + nodes/number/fibonacci.py | 2 + nodes/number/float_to_int.py | 5 +++ nodes/number/list_input.py | 3 ++ nodes/number/mix_inputs.py | 3 +- nodes/number/mix_numbers.py | 3 +- nodes/number/number_range.py | 5 ++- nodes/number/numbers.py | 4 +- nodes/number/oscillator.py | 4 +- nodes/number/random.py | 2 +- nodes/number/random_num_gen.py | 19 ++++----- nodes/number/range_map.py | 7 +--- nodes/number/scalar_mk4.py | 41 ++++++++++---------- nodes/number/smooth_numbers.py | 18 +++++---- 118 files changed, 332 insertions(+), 157 deletions(-) diff --git a/nodes/CAD/crop_mesh_2d.py b/nodes/CAD/crop_mesh_2d.py index b7afed29d1..01d544eb6c 100644 --- a/nodes/CAD/crop_mesh_2d.py +++ b/nodes/CAD/crop_mesh_2d.py @@ -97,8 +97,10 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'Face index') def process(self): - if not all([sock.is_linked for sock in self.inputs]) and any([sock.is_linked for sock in self.outputs]): + if not any(socket.is_linked for socket in self.outputs): return + if not all([sock.is_linked for sock in self.inputs]): + raise Exception("All input sockets has to be connected") if self.alg_mode == "Blender" and not crop_mesh_delaunay: return diff --git a/nodes/CAD/edges_intersect_mk3.py b/nodes/CAD/edges_intersect_mk3.py index 85c131bce7..f763994098 100644 --- a/nodes/CAD/edges_intersect_mk3.py +++ b/nodes/CAD/edges_intersect_mk3.py @@ -93,7 +93,8 @@ def draw_buttons_ext(self, context, layout): layout.prop(self, 'epsilon') def process(self): - + if not any(socket.is_linked for socket in self.outputs): + return inputs = self.inputs outputs = self.outputs try: diff --git a/nodes/CAD/edges_to_faces_2d.py b/nodes/CAD/edges_to_faces_2d.py index d7ce48ee53..02514134d3 100644 --- a/nodes/CAD/edges_to_faces_2d.py +++ b/nodes/CAD/edges_to_faces_2d.py @@ -53,8 +53,10 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Faces") def process(self): - if not all([soc.is_linked for soc in self.inputs]): + if not any(socket.is_linked for socket in self.outputs): return + if not all([soc.is_linked for soc in self.inputs]): + raise Exception("All input sockets has to be connected") out = [] for vs, es in zip(self.inputs['Verts'].sv_get(), self.inputs['Edges'].sv_get()): out.append(edges_to_faces(vs, es, self.do_intersect, self.fill_holes, self.accuracy)) diff --git a/nodes/CAD/embed mesh.py b/nodes/CAD/embed mesh.py index 77e5f9d715..5883a275ab 100644 --- a/nodes/CAD/embed mesh.py +++ b/nodes/CAD/embed mesh.py @@ -209,6 +209,8 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Faces") self.outputs.new('SvStringsSocket', "Index") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return out = [] for V_A,E_A,F_A,V_B,E_B,F_B,I in zip( self.inputs['VertsA'].sv_get(default=[[]]), diff --git a/nodes/CAD/merge_mesh_2d.py b/nodes/CAD/merge_mesh_2d.py index bb6f1f93c1..f077cebe5a 100644 --- a/nodes/CAD/merge_mesh_2d.py +++ b/nodes/CAD/merge_mesh_2d.py @@ -65,8 +65,10 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'Mask B') def process(self): - if not all([sock.is_linked for sock in self.inputs]): + if not any(socket.is_linked for socket in self.outputs): return + if not all([sock.is_linked for sock in self.inputs]): + raise Exception("All input sockets has to be connected") out = [] for sv_verts_a, sv_faces_a, sv_verts_b, sv_faces_b in zip(self.inputs['Verts A'].sv_get(), self.inputs['Faces A'].sv_get(), diff --git a/nodes/CAD/merge_mesh_2d_lite.py b/nodes/CAD/merge_mesh_2d_lite.py index 9ecbd55287..0171af1f78 100644 --- a/nodes/CAD/merge_mesh_2d_lite.py +++ b/nodes/CAD/merge_mesh_2d_lite.py @@ -87,8 +87,10 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Faces") def process(self): - if not all([sock.is_linked for sock in self.inputs]): + if not any(socket.is_linked for socket in self.outputs): return + if not all([sock.is_linked for sock in self.inputs]): + raise Exception("All input sockets has to be connected") if self.alg_mode == "Blender" and not bl_merge_mesh: return out = [] diff --git a/nodes/analyzer/chess_selection.py b/nodes/analyzer/chess_selection.py index 13eba4f4a8..3566980558 100644 --- a/nodes/analyzer/chess_selection.py +++ b/nodes/analyzer/chess_selection.py @@ -64,6 +64,8 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Face mask") def process(self): + if not any(sock.is_linked for sock in self.outputs): + return if not all([sock.is_linked for sock in self.inputs]): return out = [] diff --git a/nodes/analyzer/distance_pp.py b/nodes/analyzer/distance_pp.py index 78310ac673..6588d77769 100644 --- a/nodes/analyzer/distance_pp.py +++ b/nodes/analyzer/distance_pp.py @@ -29,7 +29,7 @@ class DistancePPNode(SverchCustomTreeNode, bpy.types.Node): ''' Distance Point to Point ''' bl_idname = 'DistancePPNode' - bl_label = 'Distance' + bl_label = 'Distance Point Point' bl_icon = 'OUTLINER_OB_EMPTY' sv_icon = 'SV_DISTANCE' diff --git a/nodes/analyzer/kd_tree_path.py b/nodes/analyzer/kd_tree_path.py index 00753b7c0c..b029a16c43 100644 --- a/nodes/analyzer/kd_tree_path.py +++ b/nodes/analyzer/kd_tree_path.py @@ -100,7 +100,7 @@ def process(self): outputs = self.outputs so = self.outputs si = self.inputs - if not so[0].is_linked and si[0].is_linked: + if not so[0].is_linked: return result = [] diff --git a/nodes/analyzer/object_insolation.py b/nodes/analyzer/object_insolation.py index 9cff2663aa..3bfe33effa 100644 --- a/nodes/analyzer/object_insolation.py +++ b/nodes/analyzer/object_insolation.py @@ -95,6 +95,8 @@ def sv_draw_buttons_ext(self, context, layout): #row.prop(self, "mode2", text="Out Mode") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return o,r,e = self.inputs #dd,o,r,e = self.inputs diff --git a/nodes/analyzer/origins.py b/nodes/analyzer/origins.py index 8ee8099d03..eb4593b361 100644 --- a/nodes/analyzer/origins.py +++ b/nodes/analyzer/origins.py @@ -132,6 +132,8 @@ def sv_init(self, context): self.outputs.new('SvMatrixSocket', "Matrix") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return if not self.inputs['Verts'].is_linked: return if self.mode == MODE.faces and not self.inputs['Faces'].is_linked: diff --git a/nodes/analyzer/points_inside_mesh.py b/nodes/analyzer/points_inside_mesh.py index 7381640e59..f390ff7303 100644 --- a/nodes/analyzer/points_inside_mesh.py +++ b/nodes/analyzer/points_inside_mesh.py @@ -274,7 +274,9 @@ def get_data(self): return main_func, params def process(self): - + if not any(socket.is_linked for socket in self.outputs): + return + if not all(socket.is_linked for socket in self.inputs[:3]): return diff --git a/nodes/analyzer/project_point_to_line.py b/nodes/analyzer/project_point_to_line.py index ccfedfe234..79d4476819 100644 --- a/nodes/analyzer/project_point_to_line.py +++ b/nodes/analyzer/project_point_to_line.py @@ -372,6 +372,8 @@ def draw_buttons_ext(self, context, layout): layout.row().prop(self, 'set_res', toggle=True) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return if not (self.inputs['Vectors_lines'].is_linked and self.inputs['Project_points'].is_linked): return diff --git a/nodes/analyzer/volume.py b/nodes/analyzer/volume.py index 57e32440b0..49889fb4e3 100644 --- a/nodes/analyzer/volume.py +++ b/nodes/analyzer/volume.py @@ -36,6 +36,8 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Volume") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return vertices = self.inputs['Vers'].sv_get(deepcopy=False, default=[]) faces = self.inputs['Pols'].sv_get(deepcopy=False, default=[]) diff --git a/nodes/color/color_in_mk1.py b/nodes/color/color_in_mk1.py index e6ad339885..12fa7d745a 100644 --- a/nodes/color/color_in_mk1.py +++ b/nodes/color/color_in_mk1.py @@ -177,7 +177,7 @@ def sv_init(self, context): def process(self): - if not self.outputs['Colors'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return inputs = self.inputs diff --git a/nodes/color/color_input.py b/nodes/color/color_input.py index 518f96727d..9d12b2d239 100644 --- a/nodes/color/color_input.py +++ b/nodes/color/color_input.py @@ -59,6 +59,8 @@ def draw_buttons_3dpanel(self, layout): row.prop(self, 'color_data', text='') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return if self.use_alpha: color = self.color_data[:] else: diff --git a/nodes/color/color_out_mk1.py b/nodes/color/color_out_mk1.py index e7ac93aaa4..623b5c17a2 100644 --- a/nodes/color/color_out_mk1.py +++ b/nodes/color/color_out_mk1.py @@ -103,8 +103,10 @@ def rclick_menu(self, context, layout): layout.prop_menu_enum(self, "selected_mode", text="Function") # layout.prop(self, 'use_alpha') layout.prop(self, "output_numpy", toggle=True) - def process(self): + def process(self): + if not any(socket.is_linked for socket in self.outputs): + return color_input = self.inputs['Colors'] if color_input.is_linked: abc = self.inputs['Colors'].sv_get(deepcopy=False) diff --git a/nodes/curve/ellipse_curve.py b/nodes/curve/ellipse_curve.py index 740023ec74..93020ab585 100644 --- a/nodes/curve/ellipse_curve.py +++ b/nodes/curve/ellipse_curve.py @@ -83,9 +83,7 @@ def sv_init(self, context): self.update_sockets(context) def process(self): - outputs = self.outputs - # return if no outputs are connected - if not any(s.is_linked for s in outputs): + if not any(socket.is_linked for socket in self.outputs): return major_radius_s = self.inputs['Major Radius'].sv_get(deepcopy=False) diff --git a/nodes/curve/polyline.py b/nodes/curve/polyline.py index cc2b269ba8..95b7824260 100644 --- a/nodes/curve/polyline.py +++ b/nodes/curve/polyline.py @@ -63,7 +63,7 @@ def make_edges(self, vertices, is_cyclic): return curves def process(self): - if not any(o.is_linked for o in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return vertices_s = self.inputs['Vertices'].sv_get(default=[[]]) diff --git a/nodes/dictionary/dictionary_out.py b/nodes/dictionary/dictionary_out.py index e6421efb1b..5c203192c7 100644 --- a/nodes/dictionary/dictionary_out.py +++ b/nodes/dictionary/dictionary_out.py @@ -108,6 +108,9 @@ def process(self): return self.rebuild_output() + + if not any(socket.is_linked for socket in self.outputs): + return out = {key: [] for key in self.inputs['Dict'].sv_get()[0]} for d in self.inputs['Dict'].sv_get(): diff --git a/nodes/exchange/bezier_in.py b/nodes/exchange/bezier_in.py index 6f4db78972..2c977d9405 100644 --- a/nodes/exchange/bezier_in.py +++ b/nodes/exchange/bezier_in.py @@ -156,9 +156,10 @@ def get_curve(self, spline, matrix): return points, segments def process(self): - - if not self.object_names: + if not any(socket.is_linked for socket in self.outputs): return + if not self.object_names: + raise Exception("Empty objects list") curves_out = [] matrices_out = [] diff --git a/nodes/generator/basic_3pt_arc.py b/nodes/generator/basic_3pt_arc.py index 504b5317ea..488eff793b 100644 --- a/nodes/generator/basic_3pt_arc.py +++ b/nodes/generator/basic_3pt_arc.py @@ -132,6 +132,8 @@ def draw_buttons(self, context, layout): pass def process(self): + if not any(socket.is_linked for socket in self.outputs): + return outputs = self.outputs inputs = self.inputs diff --git a/nodes/generator/basic_spline.py b/nodes/generator/basic_spline.py index 57a4171234..cc0e8be24e 100644 --- a/nodes/generator/basic_spline.py +++ b/nodes/generator/basic_spline.py @@ -82,14 +82,9 @@ def draw_buttons_ext(self, context, layout): layout.prop(self, "list_match") def process(self): - outputs = self.outputs - - ''' - - is hnd_edges socket created, means all sockets exist. - - is anything connected to the Verts socket? - ''' - if not (('hnd Edges' in outputs) and (outputs['Verts'].is_linked)): + if not any(socket.is_linked for socket in self.outputs): return + outputs = self.outputs ''' operational scheme: (spline = handle set (k1, ctrl1, ctrl2, k2)) diff --git a/nodes/generator/box_mk2.py b/nodes/generator/box_mk2.py index e83906b27c..27dd0cad59 100644 --- a/nodes/generator/box_mk2.py +++ b/nodes/generator/box_mk2.py @@ -367,12 +367,10 @@ def get_data(self): return list_match_func[self.list_match_global](params) def process(self): - - outputs = self.outputs - - if not any(s.is_linked for s in outputs): + if not any(socket.is_linked for socket in self.outputs): return - + + outputs = self.outputs data_in = self.get_data() verts_out, edges_out, pols_out = [], [], [] diff --git a/nodes/generator/bricks.py b/nodes/generator/bricks.py index 3268ef0acd..243c234b6f 100644 --- a/nodes/generator/bricks.py +++ b/nodes/generator/bricks.py @@ -391,7 +391,7 @@ def build_vertices(self, ulines): return vertex_idx, list(vertices.keys()) def process(self): - if not (self.outputs['Vertices'].is_linked or self.outputs['Centers'].is_linked): + if not any(socket.is_linked for socket in self.outputs): return # inputs diff --git a/nodes/generator/circle.py b/nodes/generator/circle.py index d6a74f7c78..b90aafe813 100644 --- a/nodes/generator/circle.py +++ b/nodes/generator/circle.py @@ -105,7 +105,8 @@ def make_faces(self, Angle, Vertices): return [_list_indexes] def process(self): - + if not any(socket.is_linked for socket in self.outputs): + return # inputs input_socket_names = ['Radius', 'num Verts', 'Degrees'] diff --git a/nodes/generator/cricket.py b/nodes/generator/cricket.py index f4c25f2a00..57044f04c7 100644 --- a/nodes/generator/cricket.py +++ b/nodes/generator/cricket.py @@ -32,8 +32,7 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Faces") def process(self): - # return if no outputs are connected - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return out_verts = [] diff --git a/nodes/generator/cylinder_mk2.py b/nodes/generator/cylinder_mk2.py index 1998c028f2..3dc7316d7b 100644 --- a/nodes/generator/cylinder_mk2.py +++ b/nodes/generator/cylinder_mk2.py @@ -335,7 +335,7 @@ def draw_buttons_ext(self, context, layout): layout.prop(self, "list_match") def process(self): - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return inputs = self.inputs diff --git a/nodes/generator/formula_shape.py b/nodes/generator/formula_shape.py index 4074f7ecf3..611a99b631 100644 --- a/nodes/generator/formula_shape.py +++ b/nodes/generator/formula_shape.py @@ -112,6 +112,8 @@ def draw_buttons(self,context,layout): col.prop(self, 'i_override', text='i') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return # inputs Count = self.inputs['Count'].sv_get()[0][0] Scale = self.inputs['Scale'].sv_get()[0][0] diff --git a/nodes/generator/image.py b/nodes/generator/image.py index 17b1c062f8..f6f5bfe744 100644 --- a/nodes/generator/image.py +++ b/nodes/generator/image.py @@ -81,9 +81,10 @@ def draw_buttons(self, context, layout): row.prop(self, "B", text="B") def process(self): - - if not self.image_pointer: + if not any(socket.is_linked for socket in self.outputs): return + if not self.image_pointer: + raise Exception("No Image. Select image") inputs, outputs = self.inputs, self.outputs diff --git a/nodes/generator/line_mk4.py b/nodes/generator/line_mk4.py index 2cd47c123e..13857c095c 100644 --- a/nodes/generator/line_mk4.py +++ b/nodes/generator/line_mk4.py @@ -323,8 +323,12 @@ def rclick_menu(self, context, layout): layout.prop(self, 'as_numpy') def process(self): - if self.length_mode == LENGTH.step and not self.inputs['Steps'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if self.length_mode == LENGTH.step and not self.inputs['Steps'].is_linked: + raise Exception("If length mode is 'Step' then input socket 'Steps' has to be connected") + if self.length_mode == LENGTH.step_size and not self.inputs['Steps'].is_linked: + raise Exception("If length mode is 'Step+Size' then input socket 'Steps' has to be connected") number, step, size, ors, dirs = [sock.sv_get(deepcopy=False, default=[[None]]) for sock in self.inputs] num_objects = max([len(item) for item in [number, step, size, ors, dirs]]) diff --git a/nodes/generator/ngon.py b/nodes/generator/ngon.py index 354d9771ff..4c62aa9e67 100644 --- a/nodes/generator/ngon.py +++ b/nodes/generator/ngon.py @@ -145,6 +145,8 @@ def draw_buttons_ext(self, context, layout): layout.prop(self, "list_match") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return # inputs radius = self.inputs['Radius'].sv_get()[0] diff --git a/nodes/generator/plane_mk3.py b/nodes/generator/plane_mk3.py index 50f088b3ae..67136c9440 100644 --- a/nodes/generator/plane_mk3.py +++ b/nodes/generator/plane_mk3.py @@ -453,12 +453,9 @@ def get_data(self): return list_match_func[self.list_match_global](params) def process(self): - - outputs = self.outputs - - if not any(s.is_linked for s in outputs): + if not any(socket.is_linked for socket in self.outputs): return - + outputs = self.outputs data_in = self.get_data() verts_out, edges_out, pols_out = [], [], [] diff --git a/nodes/generator/random_vector_mk3.py b/nodes/generator/random_vector_mk3.py index 056e65f8ef..3aaa167234 100644 --- a/nodes/generator/random_vector_mk3.py +++ b/nodes/generator/random_vector_mk3.py @@ -106,10 +106,8 @@ def draw_buttons_ext(self, context, layout): layout.prop(self, 'correct_output') def process(self): - - if not self.outputs['Random'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return - params = [si.sv_get(default=[[]], deepcopy=False) for si in self.inputs] matching_f = list_match_func[self.list_match] diff --git a/nodes/generator/segment.py b/nodes/generator/segment.py index ecf77668c2..0a1e3e9f70 100644 --- a/nodes/generator/segment.py +++ b/nodes/generator/segment.py @@ -190,6 +190,8 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'Edges') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return num_objects = max([len(sock.sv_get(deepcopy=False, default=[])) for sock in self.inputs]) out = [] list_match_f = iter_list_match_func[self.list_match_global] diff --git a/nodes/generator/sphere.py b/nodes/generator/sphere.py index d7b0c909e1..be02a16a99 100644 --- a/nodes/generator/sphere.py +++ b/nodes/generator/sphere.py @@ -177,6 +177,8 @@ def draw_buttons_ext(self, context, layout): layout.prop(self, "list_match") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return # inputs if 'Polygons' not in self.outputs: return diff --git a/nodes/generator/suzanne.py b/nodes/generator/suzanne.py index bc7c857a58..a615864c9c 100644 --- a/nodes/generator/suzanne.py +++ b/nodes/generator/suzanne.py @@ -39,8 +39,7 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Faces") def process(self): - # return if no outputs are connected - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return out_verts = [] diff --git a/nodes/generator/torus_mk2.py b/nodes/generator/torus_mk2.py index 9d7b1f4776..a7c2f93955 100644 --- a/nodes/generator/torus_mk2.py +++ b/nodes/generator/torus_mk2.py @@ -313,8 +313,7 @@ def draw_buttons_ext(self, context, layout): layout.prop(self, "list_match") def process(self): - # return if no outputs are connected - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return # input values lists (single or multi value) diff --git a/nodes/generators_extended/box_rounded.py b/nodes/generators_extended/box_rounded.py index 01d412617e..213c7b5363 100644 --- a/nodes/generators_extended/box_rounded.py +++ b/nodes/generators_extended/box_rounded.py @@ -387,6 +387,8 @@ def draw_buttons(self, context, layout): pass def process(self): + if not any(socket.is_linked for socket in self.outputs): + return inputs = self.inputs outputs = self.outputs sizes = inputs['vector_size'].sv_get()[0] diff --git a/nodes/generators_extended/ellipse_mk3.py b/nodes/generators_extended/ellipse_mk3.py index 04b081f48a..17c50e24f0 100644 --- a/nodes/generators_extended/ellipse_mk3.py +++ b/nodes/generators_extended/ellipse_mk3.py @@ -334,10 +334,9 @@ def make_ellipse(self, a, b, N, phase, rotation, scale, ex, ey): return list_verts, edges, polys, f1, f2 def process(self): - outputs = self.outputs - # return if no outputs are connected - if not any(s.is_linked for s in outputs): + if not any(socket.is_linked for socket in self.outputs): return + outputs = self.outputs # input values lists (single or multi value) inputs = self.inputs diff --git a/nodes/generators_extended/hilbert.py b/nodes/generators_extended/hilbert.py index c0d5477b70..9c85b2a0e3 100644 --- a/nodes/generators_extended/hilbert.py +++ b/nodes/generators_extended/hilbert.py @@ -51,6 +51,8 @@ def draw_buttons(self, context, layout): pass def process(self): + if not any(socket.is_linked for socket in self.outputs): + return level_socket, size_socket = self.inputs verts_socket, edges_socket = self.outputs diff --git a/nodes/generators_extended/hilbert3d.py b/nodes/generators_extended/hilbert3d.py index 5df2468c07..ecd159132f 100644 --- a/nodes/generators_extended/hilbert3d.py +++ b/nodes/generators_extended/hilbert3d.py @@ -69,6 +69,8 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Edges") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return level_socket, size_socket = self.inputs verts_socket, edges_socket = self.outputs diff --git a/nodes/generators_extended/hilbert_image.py b/nodes/generators_extended/hilbert_image.py index eab5c47b2d..ab57ea9fdd 100644 --- a/nodes/generators_extended/hilbert_image.py +++ b/nodes/generators_extended/hilbert_image.py @@ -80,6 +80,8 @@ def draw_buttons(self, context, layout): row.prop(self, "B", text="B") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return level_socket, size_socket, sensitivity_socket = self.inputs verts_socket, edges_socket = self.outputs diff --git a/nodes/generators_extended/pentagon_tiler.py b/nodes/generators_extended/pentagon_tiler.py index f896f118cd..b6b3619d64 100644 --- a/nodes/generators_extended/pentagon_tiler.py +++ b/nodes/generators_extended/pentagon_tiler.py @@ -221,8 +221,7 @@ def pentagon_tiler(self, params): return vert_list, edge_list, poly_list def process(self): - # return if no outputs are connected - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return # input values lists params = [s.sv_get() for s in self.inputs] diff --git a/nodes/generators_extended/polygon_grid.py b/nodes/generators_extended/polygon_grid.py index ae90da443c..cac308442b 100644 --- a/nodes/generators_extended/polygon_grid.py +++ b/nodes/generators_extended/polygon_grid.py @@ -357,8 +357,7 @@ def draw_buttons(self, context, layout): row.prop(self, 'center', toggle=True) def process(self): - # return if no outputs are connected - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return if self.gridType == 'HEXAGON': diff --git a/nodes/generators_extended/regular_solid.py b/nodes/generators_extended/regular_solid.py index 11a9fe5c49..a6f0d71c2f 100644 --- a/nodes/generators_extended/regular_solid.py +++ b/nodes/generators_extended/regular_solid.py @@ -221,7 +221,7 @@ def get_data(self): return match_long_repeat(params) def process(self): - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return verts_out, edges_out, polys_out = [], [], [] diff --git a/nodes/generators_extended/ring_mk2.py b/nodes/generators_extended/ring_mk2.py index acb7066811..b4d5a157c7 100644 --- a/nodes/generators_extended/ring_mk2.py +++ b/nodes/generators_extended/ring_mk2.py @@ -288,8 +288,7 @@ def draw_buttons_ext(self, context, layout): layout.prop(self, 'ring_u') def process(self): - # return if no outputs are connected - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return # list of MAJOR or EXTERIOR radii diff --git a/nodes/generators_extended/smooth_lines.py b/nodes/generators_extended/smooth_lines.py index b0d2cb5f5d..22bafea6e3 100644 --- a/nodes/generators_extended/smooth_lines.py +++ b/nodes/generators_extended/smooth_lines.py @@ -199,8 +199,7 @@ def draw_buttons(self, context, layout): def process(self): - necessary_sockets = [self.inputs["vectors"],] - if not all(s.is_linked for s in necessary_sockets): + if not any(socket.is_linked for socket in self.outputs): return if self.inputs["attributes"].is_linked: diff --git a/nodes/generators_extended/spiral_mk2.py b/nodes/generators_extended/spiral_mk2.py index 1818a60256..3f9eed166e 100644 --- a/nodes/generators_extended/spiral_mk2.py +++ b/nodes/generators_extended/spiral_mk2.py @@ -578,10 +578,9 @@ def draw_buttons_ext(self, context, layout): self.draw_angle_units_buttons(context, layout) def process(self): - outputs = self.outputs - # return if no outputs are connected - if not any(s.is_linked for s in outputs): + if not any(socket.is_linked for socket in self.outputs): return + outputs = self.outputs # input values lists (single or multi value) inputs = self.inputs diff --git a/nodes/generators_extended/super_ellipsoid.py b/nodes/generators_extended/super_ellipsoid.py index e859d2c096..6929e0e49b 100644 --- a/nodes/generators_extended/super_ellipsoid.py +++ b/nodes/generators_extended/super_ellipsoid.py @@ -297,7 +297,7 @@ def draw_buttons_ext(self, context, layout): row.prop(self, "cap_top", text="Cap T", toggle=True) def process(self): - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return inputs = self.inputs diff --git a/nodes/generators_extended/torus_knot_mk2.py b/nodes/generators_extended/torus_knot_mk2.py index e3a7258be2..e666a52799 100644 --- a/nodes/generators_extended/torus_knot_mk2.py +++ b/nodes/generators_extended/torus_knot_mk2.py @@ -383,10 +383,9 @@ def draw_buttons(self, context, layout): layout.prop(self, 'mode', expand=True) def process(self): - outputs = self.outputs - # return if no outputs are connected - if not any(s.is_linked for s in outputs): + if not any(socket.is_linked for socket in self.outputs): return + outputs = self.outputs # input values lists (single or multi value) inputs = self.inputs diff --git a/nodes/generators_extended/triangle.py b/nodes/generators_extended/triangle.py index e9332d6592..7ee1fb6218 100644 --- a/nodes/generators_extended/triangle.py +++ b/nodes/generators_extended/triangle.py @@ -202,8 +202,7 @@ def main_func(self, params): return out_verts, out_edges, out_faces def process(self): - # return if no outputs are connected - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return out_verts = [] diff --git a/nodes/generators_extended/wfc_texture.py b/nodes/generators_extended/wfc_texture.py index 1614ed6eb7..ea04a1f60c 100644 --- a/nodes/generators_extended/wfc_texture.py +++ b/nodes/generators_extended/wfc_texture.py @@ -63,8 +63,10 @@ def draw_buttons_ext(self, context, layout: 'UILayout'): layout.prop(self, 'tries_number') def process(self): - if not self.image_name: + if not any(socket.is_linked for socket in self.outputs): return + if not self.image_name: + raise Exception("No image selected") image = load_image(self.image_name) wave = WaveFunctionCollapse( diff --git a/nodes/layout/converter.py b/nodes/layout/converter.py index e4d538dad9..077210a5a2 100644 --- a/nodes/layout/converter.py +++ b/nodes/layout/converter.py @@ -40,6 +40,8 @@ def sv_init(self, context): self.outputs.new('SvDictionarySocket', 'dict') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return if self.inputs[0].is_linked: out = self.inputs[0].sv_get(deepcopy=False) for s in self.outputs: diff --git a/nodes/list_main/decompose.py b/nodes/list_main/decompose.py index c707717d7e..acbf81a406 100644 --- a/nodes/list_main/decompose.py +++ b/nodes/list_main/decompose.py @@ -81,6 +81,8 @@ def sv_update(self): out.replace_socket(other.bl_idname) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return data = self.inputs['data'].sv_get() result = self.beat(data, self.level) for out, socket in zip(result, self.outputs[:30]): diff --git a/nodes/list_main/delete_levels.py b/nodes/list_main/delete_levels.py index 6849fb4f7d..76ed22c164 100644 --- a/nodes/list_main/delete_levels.py +++ b/nodes/list_main/delete_levels.py @@ -54,6 +54,8 @@ def sv_update(self): changable_sockets(self, inputsocketname, outputsocketname) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return if self.outputs['data'].is_linked: data = self.inputs['data'].sv_get() userlevelb = literal_eval('['+self.Sverch_LisLev+']') diff --git a/nodes/list_main/func.py b/nodes/list_main/func.py index b98edc3dae..592b29e1c2 100644 --- a/nodes/list_main/func.py +++ b/nodes/list_main/func.py @@ -114,7 +114,11 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Function") def process(self): - + if not any(socket.is_linked for socket in self.outputs): + return + if not self.inputs['Data'].is_linked: + raise Exception("Input socket 'Data' has to be connected") + if self.outputs['Function'].is_linked and self.inputs['Data'].is_linked: data = self.inputs['Data'].sv_get() func = func_dict[self.func_] diff --git a/nodes/list_main/index.py b/nodes/list_main/index.py index 60029cbff8..d78c766853 100644 --- a/nodes/list_main/index.py +++ b/nodes/list_main/index.py @@ -49,6 +49,10 @@ def draw_buttons(self, context, layout): col.prop(self,'use_range') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not any(socket.is_linked for socket in self.inputs): + raise Exception("All input sockets has to be connected") data = self.inputs['data'].sv_get(deepcopy=False, default=[]) items = self.inputs['Item'].sv_get(deepcopy=False, default=[]) diff --git a/nodes/list_main/join.py b/nodes/list_main/join.py index f619502290..c924ea0c0d 100644 --- a/nodes/list_main/join.py +++ b/nodes/list_main/join.py @@ -186,9 +186,10 @@ def sv_update(self): self.set_output_socketype([sock.other.bl_idname for sock in self.inputs if sock.is_linked and sock.other]) def process(self): - - if not self.outputs['data'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if not any(socket.is_linked for socket in self.inputs): + raise Exception("Some input sockets has to be connected") slots = [] for socket in self.inputs: diff --git a/nodes/list_main/length.py b/nodes/list_main/length.py index 019610e25a..94f88db3bd 100644 --- a/nodes/list_main/length.py +++ b/nodes/list_main/length.py @@ -36,7 +36,10 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Length") def process(self): - + if not any(socket.is_linked for socket in self.outputs): + return + if not all(socket.is_linked for socket in self.inputs): + raise Exception("All input sockets has to be connected") if 'Length' in self.outputs and self.outputs['Length'].is_linked: if 'Data' in self.inputs and self.inputs['Data'].is_linked: data = self.inputs['Data'].sv_get(deepcopy=False) diff --git a/nodes/list_main/match.py b/nodes/list_main/match.py index e68dcef459..8702992657 100644 --- a/nodes/list_main/match.py +++ b/nodes/list_main/match.py @@ -103,6 +103,10 @@ def sv_update(self): self.outputs[socket.name].replace_socket(from_sock.bl_idname) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not any(socket.is_linked for socket in self.inputs): + raise Exception("Some input sockets has to be connected") # check inputs and that there is at least one output count_inputs = sum(s.is_linked for s in self.inputs) diff --git a/nodes/list_main/statistics.py b/nodes/list_main/statistics.py index bc90cdc4ec..707b4a96c3 100644 --- a/nodes/list_main/statistics.py +++ b/nodes/list_main/statistics.py @@ -426,6 +426,10 @@ def sv_free(self): nvBGL.callback_disable(node_id(self)) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not any(socket.is_linked for socket in self.inputs): + raise Exception("Input socket 'Data' has to be connected") inputs = self.inputs outputs = self.outputs diff --git a/nodes/list_main/sum_mk2.py b/nodes/list_main/sum_mk2.py index 189bc929e4..f47b60e45b 100644 --- a/nodes/list_main/sum_mk2.py +++ b/nodes/list_main/sum_mk2.py @@ -43,6 +43,10 @@ def draw_buttons(self, context, layout): layout.prop(self, "level", text="level") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not any(socket.is_linked for socket in self.inputs): + raise Exception("Input socket 'Data' has to be connected") # достаём два слота - вершины и полики if self.outputs['Sum'].is_linked and self.inputs['Data'].is_linked: data = self.inputs['Data'].sv_get() diff --git a/nodes/list_main/zip.py b/nodes/list_main/zip.py index 9c9d1cc6ce..f3c338500d 100644 --- a/nodes/list_main/zip.py +++ b/nodes/list_main/zip.py @@ -68,6 +68,11 @@ def sv_update(self): def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if len([s for s in self.inputs if s.is_linked])<2: + raise Exception("Minimum two input sockets has to be connected") + if self.outputs['data'].is_linked: slots = [] for socket in self.inputs: diff --git a/nodes/list_masks/calc_mask.py b/nodes/list_masks/calc_mask.py index 66821bf5b9..229c86cedc 100644 --- a/nodes/list_masks/calc_mask.py +++ b/nodes/list_masks/calc_mask.py @@ -53,8 +53,7 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'Mask') def process(self): - - if not any(output.is_linked for output in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return subset_s = self.inputs['Subset'].sv_get(default=[[]]) diff --git a/nodes/list_masks/index_to_mask.py b/nodes/list_masks/index_to_mask.py index b294312105..73bba54d5d 100644 --- a/nodes/list_masks/index_to_mask.py +++ b/nodes/list_masks/index_to_mask.py @@ -84,6 +84,8 @@ def process(self): if 'mask' in self.outputs: self.outputs['mask'].name = 'Mask' + if not any(socket.is_linked for socket in self.outputs): + return index = self.inputs["Index"].sv_get(deepcopy=False, default=[]) mask_size = self.inputs['Mask size'].sv_get(deepcopy=False, default=[None]) data_to_mask = self.inputs['Data masking'].sv_get(deepcopy=False, diff --git a/nodes/list_masks/mask.py b/nodes/list_masks/mask.py index cf5325ceb2..eac2a906ef 100644 --- a/nodes/list_masks/mask.py +++ b/nodes/list_masks/mask.py @@ -121,6 +121,10 @@ def sv_update(self): changable_sockets(self, inputsocketname, outputsocketname) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not all(socket.is_linked for socket in self.inputs): + raise Exception("All input sockets has to be connected") inputs = self.inputs outputs = self.outputs if not any(s.is_linked for s in outputs) and inputs[0].is_linked: diff --git a/nodes/list_masks/mask_convert.py b/nodes/list_masks/mask_convert.py index 93baf122ed..96e18feaba 100644 --- a/nodes/list_masks/mask_convert.py +++ b/nodes/list_masks/mask_convert.py @@ -180,7 +180,6 @@ def sv_init(self, context): self.update_mode(context) def process(self): - if not any(output.is_linked for output in self.outputs): return diff --git a/nodes/list_masks/mask_join.py b/nodes/list_masks/mask_join.py index 3bbca5a22b..376565e757 100644 --- a/nodes/list_masks/mask_join.py +++ b/nodes/list_masks/mask_join.py @@ -68,6 +68,10 @@ def sv_update(self): changable_sockets(self, inputsocketname, outputsocketname) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not all(socket.is_linked for socket in self.inputs): + raise Exception("All input sockets has to be connected") Ouso = self.outputs[0] if Ouso.is_linked: mask = self.inputs['Mask'].sv_get([[1, 0]]) diff --git a/nodes/list_masks/mask_to_index.py b/nodes/list_masks/mask_to_index.py index f994c32515..6e738706d3 100644 --- a/nodes/list_masks/mask_to_index.py +++ b/nodes/list_masks/mask_to_index.py @@ -43,6 +43,10 @@ def sv_init(self, context): def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not all(socket.is_linked for socket in self.inputs): + raise Exception("Input socket 'Mask' has to be connected") inputs = self.inputs outputs = self.outputs if not (any(s.is_linked for s in outputs) and inputs[0].is_linked): diff --git a/nodes/list_mutators/combinatorics.py b/nodes/list_mutators/combinatorics.py index 309578dccd..ab42fd92f3 100644 --- a/nodes/list_mutators/combinatorics.py +++ b/nodes/list_mutators/combinatorics.py @@ -127,11 +127,15 @@ def draw_buttons(self, context, layout): layout.prop(self, "operation", text="") def process(self): - outputs = self.outputs - # return if no outputs are connected - if not any(s.is_linked for s in outputs): + if not any(socket.is_linked for socket in self.outputs): return - + if len([s for s in self.inputs if s.is_linked])==0: + raise Exception("Minimum one input sockets [A,B,...] has to be connected") + if len([s for s in self.inputs if s.is_linked])==1: + if self.inputs["Repeat"].is_linked: + raise Exception("Minimum one input sockets [A,B,...] has to be connected") + + outputs = self.outputs inputs = self.inputs all_AZ_sockets = list(filter(lambda s: s.name in ABC, inputs)) diff --git a/nodes/list_mutators/filter_empty_lists.py b/nodes/list_mutators/filter_empty_lists.py index e85340617f..93d69d7f39 100644 --- a/nodes/list_mutators/filter_empty_lists.py +++ b/nodes/list_mutators/filter_empty_lists.py @@ -36,6 +36,10 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "numpy mask") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not all(socket.is_linked for socket in self.inputs): + raise Exception("Input socket 'Data' has to be connected") sd, m, nm = self.outputs D = self.inputs[0].sv_get() if sd.is_linked: diff --git a/nodes/list_mutators/find_closest.py b/nodes/list_mutators/find_closest.py index cce0e66924..bef21b3a53 100644 --- a/nodes/list_mutators/find_closest.py +++ b/nodes/list_mutators/find_closest.py @@ -49,6 +49,9 @@ def draw_buttons(self, context, layout): layout.prop(self, 'mode', expand=True) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + vals = self.inputs['Values'].sv_get(deepcopy=False) data = self.inputs['Data'].sv_get(deepcopy=False, default=[]) _range = self.inputs['Range'].sv_get(deepcopy=False) diff --git a/nodes/list_mutators/modifier.py b/nodes/list_mutators/modifier.py index 1fbd13f2df..d8789bf482 100644 --- a/nodes/list_mutators/modifier.py +++ b/nodes/list_mutators/modifier.py @@ -131,12 +131,14 @@ def draw_label(self): return self.func_ def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if len([s for s in self.inputs if s.is_linked])<2: + raise Exception("Minimum one input socket has to be connected") + inputs = self.inputs outputs = self.outputs - if not outputs[0].is_linked: - return - unary = (num_inputs[no_space(self.func_)] == 1) f = self.get_f(unary) diff --git a/nodes/list_mutators/multi_cache.py b/nodes/list_mutators/multi_cache.py index 9f39262e37..c444754637 100644 --- a/nodes/list_mutators/multi_cache.py +++ b/nodes/list_mutators/multi_cache.py @@ -98,7 +98,7 @@ def sv_update(self): changable_sockets(self, inputsocketname, outputsocketname) def process(self): - if not self.outputs['Data'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return in_bucket_s = self.inputs['In Bucket'].sv_get()[0] diff --git a/nodes/list_mutators/polygon_sort.py b/nodes/list_mutators/polygon_sort.py index 345c95ad0e..6d6d524b2f 100644 --- a/nodes/list_mutators/polygon_sort.py +++ b/nodes/list_mutators/polygon_sort.py @@ -243,7 +243,7 @@ def draw_buttons(self, context, layout): layout.prop(self, "descending") def process(self): - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return inputs = self.inputs diff --git a/nodes/list_mutators/unique_items.py b/nodes/list_mutators/unique_items.py index 4ad90636d4..af84edd66f 100644 --- a/nodes/list_mutators/unique_items.py +++ b/nodes/list_mutators/unique_items.py @@ -143,9 +143,11 @@ def sv_update(self): changable_sockets(self, inputsocketname, outputsocketname) def process(self): - - if not (self.inputs[0].is_linked and any([s.is_linked for s in self.outputs])): + if not any(socket.is_linked for socket in self.outputs): return + if not any(socket.is_linked for socket in self.inputs): + raise Exception("Input socket 'Data'has to be connected") + data_in = self.inputs[0].sv_get(deepcopy=False) linked_outputs = [s.is_linked for s in self.outputs[1:]] out_lists = recursive_unique_items(data_in, self.level, linked_outputs, self.output_numpy) diff --git a/nodes/list_struct/flip.py b/nodes/list_struct/flip.py index 6c0ba6d0d8..685f52afff 100644 --- a/nodes/list_struct/flip.py +++ b/nodes/list_struct/flip.py @@ -81,6 +81,11 @@ def sv_update(self): changable_sockets(self, inputsocketname, outputsocketname) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not all(socket.is_linked for socket in self.inputs): + raise Exception("Input socket 'Data' has to be connected") + if self.inputs['data'].is_linked and self.outputs['data'].is_linked: outEval = self.inputs['data'].sv_get(deepcopy=False) #outCorr = dataCorrect(outEval) # this is bullshit, as max 3 in levels diff --git a/nodes/list_struct/item.py b/nodes/list_struct/item.py index 3ef0ad5eb3..7cc43551bc 100644 --- a/nodes/list_struct/item.py +++ b/nodes/list_struct/item.py @@ -66,6 +66,9 @@ def sv_update(self): changable_sockets(self, inputsocketname, outputsocketname) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + data = self.inputs['Data'].sv_get(default=[], deepcopy=False) indexes = self.inputs['Index'].sv_get(deepcopy=False) diff --git a/nodes/list_struct/item_insert.py b/nodes/list_struct/item_insert.py index bd02f9c5b3..47f12cc8be 100644 --- a/nodes/list_struct/item_insert.py +++ b/nodes/list_struct/item_insert.py @@ -84,10 +84,14 @@ def sv_update(self): changable_sockets(self, inputsocketname, outputsocketname) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return out_socket = self.outputs[0] si = self.inputs - if not (si['Data'].is_linked and si['Item'].is_linked and out_socket.is_linked): - return + if not (si['Data'].is_linked): + raise Exception("Input socket 'Data' has to be connected") + if not (si['Item'].is_linked): + raise Exception("Input socket 'Item' has to be connected") data = si['Data'].sv_get(deepcopy=False) diff --git a/nodes/list_struct/levels.py b/nodes/list_struct/levels.py index 1985c899b4..4869875946 100644 --- a/nodes/list_struct/levels.py +++ b/nodes/list_struct/levels.py @@ -100,6 +100,10 @@ def sv_update(self): changable_sockets(self, 'Data', ['Data', ]) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not any(socket.is_linked for socket in self.inputs): + raise Exception("Input socket 'Data' has to be connected") data = self.inputs['Data'].sv_get(default=[], deepcopy=False) nesting, descriptions = describe_data_shape_by_level(data, include_numpy_nesting=False) diff --git a/nodes/list_struct/numpy_array.py b/nodes/list_struct/numpy_array.py index 18f34fc209..c5643fac8f 100644 --- a/nodes/list_struct/numpy_array.py +++ b/nodes/list_struct/numpy_array.py @@ -51,6 +51,8 @@ def draw_buttons(self, context, layout): layout.prop(self, "Cust", text="") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return out = self.outputs[0] if out.is_linked: X,Y = self.inputs diff --git a/nodes/list_struct/repeater.py b/nodes/list_struct/repeater.py index c59f0123be..15a07e23d5 100644 --- a/nodes/list_struct/repeater.py +++ b/nodes/list_struct/repeater.py @@ -52,6 +52,10 @@ def sv_update(self): changable_sockets(self, inputsocketname, outputsocketname) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Data"].is_linked): + raise Exception("Input socket 'Data' has to be connected") data = self.inputs['Data'].sv_get(deepcopy=False, default=[]) number = self.inputs['Number'].sv_get(deepcopy=False)[0] diff --git a/nodes/list_struct/reverse.py b/nodes/list_struct/reverse.py index 1d62b44670..970289e628 100644 --- a/nodes/list_struct/reverse.py +++ b/nodes/list_struct/reverse.py @@ -51,6 +51,11 @@ def sv_update(self): changable_sockets(self, inputsocketname, outputsocketname) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["data"].is_linked): + raise Exception("Input socket 'data' has to be connected") + if self.outputs[0].is_linked: data = self.inputs['data'].sv_get(deepcopy=False) output = self.revers(data, self.level) diff --git a/nodes/list_struct/shift_mk2.py b/nodes/list_struct/shift_mk2.py index 1c70dea9b8..4331688126 100644 --- a/nodes/list_struct/shift_mk2.py +++ b/nodes/list_struct/shift_mk2.py @@ -62,7 +62,7 @@ def sv_update(self): changable_sockets(self, inputsocketname, outputsocketname) def process(self): - if not self.outputs["data"].is_linked: + if not any(socket.is_linked for socket in self.outputs): return data = self.inputs['data'].sv_get(deepcopy=False) diff --git a/nodes/list_struct/shuffle.py b/nodes/list_struct/shuffle.py index 94a7ba6333..60988e8c52 100644 --- a/nodes/list_struct/shuffle.py +++ b/nodes/list_struct/shuffle.py @@ -58,6 +58,11 @@ def sv_update(self): changable_sockets(self, inputsocketname, outputsocketname) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["data"].is_linked): + raise Exception("Input socket 'data' has to be connected") + if self.outputs[0].is_linked and self.inputs[0].is_linked: seed = self.inputs['seed'].sv_get(deepcopy=False)[0][0] diff --git a/nodes/list_struct/slice.py b/nodes/list_struct/slice.py index 33c25527a4..0e0e9d4bbd 100644 --- a/nodes/list_struct/slice.py +++ b/nodes/list_struct/slice.py @@ -63,6 +63,11 @@ def sv_update(self): changable_sockets(self, inputsocketname, outputsocketname) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Data"].is_linked): + raise Exception("Input socket 'Data' has to be connected") + data = self.inputs['Data'].sv_get(deepcopy=False) start = self.inputs['Start'].sv_get(deepcopy=False)[0] stop = self.inputs['Stop'].sv_get(deepcopy=False)[0] diff --git a/nodes/list_struct/sort.py b/nodes/list_struct/sort.py index b53104c69c..8c3f5053ee 100644 --- a/nodes/list_struct/sort.py +++ b/nodes/list_struct/sort.py @@ -73,6 +73,8 @@ def migrate_from(self, old_node): self.level = 4-old_node.level def process(self): + if not any(socket.is_linked for socket in self.outputs): + return if not self.outputs['data'].is_linked and not self.newsock: return self.newsock = False diff --git a/nodes/list_struct/split.py b/nodes/list_struct/split.py index 61a5a3e09c..f15641ed13 100644 --- a/nodes/list_struct/split.py +++ b/nodes/list_struct/split.py @@ -72,6 +72,11 @@ def sv_update(self): changable_sockets(self, inputsocketname, outputsocketname) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Data"].is_linked): + raise Exception("Input socket 'Data' has to be connected") + if self.outputs['Split'].is_linked: data = self.inputs['Data'].sv_get(deepcopy=False) sizes = self.inputs['Split'].sv_get(deepcopy=False)[0] diff --git a/nodes/list_struct/start_end.py b/nodes/list_struct/start_end.py index 9e2b1413ba..7c88bb0b77 100644 --- a/nodes/list_struct/start_end.py +++ b/nodes/list_struct/start_end.py @@ -54,6 +54,11 @@ def sv_update(self): changable_sockets(self, inputsocketname, outputsocketname) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Data"].is_linked): + raise Exception("Input socket 'Data' has to be connected") + if self.inputs['Data'].is_linked: data = self.inputs['Data'].sv_get(deepcopy=False) diff --git a/nodes/logic/custom_switcher.py b/nodes/logic/custom_switcher.py index 671e5519b4..99224c1e8f 100644 --- a/nodes/logic/custom_switcher.py +++ b/nodes/logic/custom_switcher.py @@ -92,6 +92,10 @@ def draw_buttons_3dpanel(self, layout, in_menu=None): col.prop(self, "user_list", toggle=True, index=i, text=val.name) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Data"].is_linked): + raise Exception("Input socket 'Data' has to be connected") # Storing names of items if self.inputs['Data'].is_linked: data = self.inputs['Data'].sv_get() diff --git a/nodes/matrix/apply_and_join.py b/nodes/matrix/apply_and_join.py index b18a8b1852..c012d5c36e 100644 --- a/nodes/matrix/apply_and_join.py +++ b/nodes/matrix/apply_and_join.py @@ -172,6 +172,8 @@ def rclick_menu(self, context, layout): layout.prop_menu_enum(self, "implementation", text="Implementation") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return vertices = self.inputs['Vertices'].sv_get(default=[], deepcopy=False) edges = self.inputs['Edges'].sv_get(default=[], deepcopy=False) faces = self.inputs['Faces'].sv_get(default=[], deepcopy=False) diff --git a/nodes/matrix/euler.py b/nodes/matrix/euler.py index a98eae34a6..e405abbd14 100644 --- a/nodes/matrix/euler.py +++ b/nodes/matrix/euler.py @@ -90,7 +90,7 @@ def rclick_menu(self, context, layout): layout.prop(self, "flat_output", text="Flat Output", expand=False) def process(self): - if not self.outputs['Matrix'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return inputs = self.inputs params = [s.sv_get() for s in inputs] diff --git a/nodes/matrix/interpolation.py b/nodes/matrix/interpolation.py index 93c9bfdadf..b82063f214 100644 --- a/nodes/matrix/interpolation.py +++ b/nodes/matrix/interpolation.py @@ -50,8 +50,7 @@ def sv_init(self, context): self.outputs.new('SvMatrixSocket', "C") def process(self): - # inputs - if not self.outputs['C'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return id_mat = [Matrix.Identity(4)] A = self.inputs['A'].sv_get(default=id_mat) diff --git a/nodes/matrix/iterate.py b/nodes/matrix/iterate.py index df1f5554b2..17077ee235 100644 --- a/nodes/matrix/iterate.py +++ b/nodes/matrix/iterate.py @@ -125,6 +125,13 @@ def sv_init(self, context): self.outputs.new('SvMatrixSocket', 'Matrices') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Matrix"].is_linked): + raise Exception("Input socket 'Matrix' has to be connected") + if not (self.inputs["Vertices"].is_linked): + raise Exception("Input socket 'Vertices' has to be connected") + # inputs if not self.inputs['Matrix'].is_linked: return diff --git a/nodes/matrix/matrix_deform.py b/nodes/matrix/matrix_deform.py index 2235ba9169..b5b550a281 100644 --- a/nodes/matrix/matrix_deform.py +++ b/nodes/matrix/matrix_deform.py @@ -37,6 +37,8 @@ def sv_init(self, context): self.outputs.new('SvMatrixSocket', "Matrix") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return O,L,S,R,A = self.inputs Om = self.outputs[0] if Om.is_linked: diff --git a/nodes/matrix/matrix_in_mk4.py b/nodes/matrix/matrix_in_mk4.py index 0ce7378025..b1b1b9539c 100644 --- a/nodes/matrix/matrix_in_mk4.py +++ b/nodes/matrix/matrix_in_mk4.py @@ -219,7 +219,7 @@ def rclick_menu(self, context, layout): layout.prop(self, "flat_output", text="Flat Output", expand=False) def process(self): - if not self.outputs['Matrices'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return inputs = self.inputs diff --git a/nodes/matrix/matrix_math.py b/nodes/matrix/matrix_math.py index 8187a87356..dd901552a8 100644 --- a/nodes/matrix/matrix_math.py +++ b/nodes/matrix/matrix_math.py @@ -240,9 +240,9 @@ def sv_update(self): inputs.remove(inputs[-1]) def process(self): - outputs = self.outputs - if not any(s.is_linked for s in outputs): + if not any(socket.is_linked for socket in self.outputs): return + outputs = self.outputs data_in = [] # collect the inputs from the connected sockets for s in filter(lambda s: s.is_linked, self.inputs): diff --git a/nodes/matrix/matrix_normal.py b/nodes/matrix/matrix_normal.py index 9ee865dd0a..418207dde1 100644 --- a/nodes/matrix/matrix_normal.py +++ b/nodes/matrix/matrix_normal.py @@ -93,9 +93,9 @@ def rclick_menu(self, context, layout): layout.prop(self, "flat_output", text="Flat Output", expand=False) def process(self): - Ma = self.outputs[0] - if not Ma.is_linked: + if not any(socket.is_linked for socket in self.outputs): return + L, N = self.inputs T, U = self.track, self.up loc = L.sv_get() diff --git a/nodes/matrix/matrix_track_to.py b/nodes/matrix/matrix_track_to.py index e56bc55127..6bb8af22b4 100644 --- a/nodes/matrix/matrix_track_to.py +++ b/nodes/matrix/matrix_track_to.py @@ -191,11 +191,9 @@ def matrix_track_to(self, params, mT, mU, orthogonalize, gates): return matrix_list, x_list, y_list, z_list def process(self): - outputs = self.outputs - - # return if no outputs are connected - if not any(s.is_linked for s in outputs): + if not any(socket.is_linked for socket in self.outputs): return + outputs = self.outputs # input values lists inputs = self.inputs diff --git a/nodes/matrix/shear.py b/nodes/matrix/shear.py index 758c9e611d..1ca65d209c 100644 --- a/nodes/matrix/shear.py +++ b/nodes/matrix/shear.py @@ -57,7 +57,7 @@ def draw_buttons(self, context, layout): layout.prop(self, "plane_", text="Shear plane:", expand=True) def process(self): - if not self.outputs['Matrix'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return # inputs diff --git a/nodes/network/file_path.py b/nodes/network/file_path.py index 7b0af70a2c..ab2b9dd7d4 100644 --- a/nodes/network/file_path.py +++ b/nodes/network/file_path.py @@ -91,8 +91,7 @@ def set_data(self, dirname, files): self.files_num = len(files) def process(self): - # return if no outputs are connected - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return directory = self.directory if self.files: diff --git a/nodes/number/curve_mapper.py b/nodes/number/curve_mapper.py index 67a5a8b1a5..2dbd35750c 100644 --- a/nodes/number/curve_mapper.py +++ b/nodes/number/curve_mapper.py @@ -100,6 +100,8 @@ def _get_curve_node_name(self): return 'RGB Curves'+n_id def process(self): + if not any(socket.is_linked for socket in self.outputs): + return inputs = self.inputs outputs = self.outputs curve_node_name = self._get_curve_node_name() diff --git a/nodes/number/easing.py b/nodes/number/easing.py index db40273d06..39c837d348 100644 --- a/nodes/number/easing.py +++ b/nodes/number/easing.py @@ -254,6 +254,9 @@ def generate_graph_geom(self, config): return geom def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + p = self.inputs['Float'].sv_get() n_id = node_id(self) diff --git a/nodes/number/exponential.py b/nodes/number/exponential.py index a281423cbd..1d1ae82eb1 100644 --- a/nodes/number/exponential.py +++ b/nodes/number/exponential.py @@ -114,6 +114,8 @@ def draw_buttons(self, context, layout): layout.prop(self, "mode", expand=True) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return # inputs x0 = self.inputs['X0'].sv_get()[0] alpha = self.inputs['Alpha'].sv_get()[0] diff --git a/nodes/number/fibonacci.py b/nodes/number/fibonacci.py index 8c3fb9edcf..d90f956b23 100644 --- a/nodes/number/fibonacci.py +++ b/nodes/number/fibonacci.py @@ -77,6 +77,8 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Sequence") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return # inputs x1 = self.inputs['X1'].sv_get()[0] x2 = self.inputs['X2'].sv_get()[0] diff --git a/nodes/number/float_to_int.py b/nodes/number/float_to_int.py index 17b10185ba..02e1a00d32 100644 --- a/nodes/number/float_to_int.py +++ b/nodes/number/float_to_int.py @@ -37,6 +37,11 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "int") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["float"].is_linked): + raise Exception("Input socket 'float' has to be connected") + Number = self.inputs['float'].sv_get() if self.outputs['int'].is_linked: result = self.inte(Number) diff --git a/nodes/number/list_input.py b/nodes/number/list_input.py index 7b363161e8..4a3f06f801 100644 --- a/nodes/number/list_input.py +++ b/nodes/number/list_input.py @@ -140,6 +140,9 @@ def draw_buttons_3dpanel(self, layout, in_menu=None): row.scale_x = 0.8 def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if self.outputs[0].is_linked: if self.mode == 'int_list': data = listinput_getI_needed(self) diff --git a/nodes/number/mix_inputs.py b/nodes/number/mix_inputs.py index 827e8961bd..9ff6357afb 100644 --- a/nodes/number/mix_inputs.py +++ b/nodes/number/mix_inputs.py @@ -343,8 +343,7 @@ def update_sockets(self): self.outputs[0].replace_socket(new_socket_type, self.mode.title()) def process(self): - # return if no outputs are connected - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return # input values lists (single or multi value) diff --git a/nodes/number/mix_numbers.py b/nodes/number/mix_numbers.py index e727451977..cb37744a1c 100644 --- a/nodes/number/mix_numbers.py +++ b/nodes/number/mix_numbers.py @@ -229,8 +229,7 @@ def draw_buttons_ext(self, context, layout): def process(self): - # return if no outputs are connected - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return # input values lists (single or multi value) diff --git a/nodes/number/number_range.py b/nodes/number/number_range.py index 0c47343de9..122d62e2e7 100644 --- a/nodes/number/number_range.py +++ b/nodes/number/number_range.py @@ -209,10 +209,11 @@ def migrate_from(self, old_node): self.range_mode = "RANGE_STEP" def process(self): + if not any(socket.is_linked for socket in self.outputs): + return inputs = self.inputs outputs = self.outputs - if not outputs[0].is_linked: - return + matching_f = list_match_func[self.list_match] params = [s.sv_get() for s in inputs] if self.number_mode == 'int': diff --git a/nodes/number/numbers.py b/nodes/number/numbers.py index 57f4ff9707..a139938295 100644 --- a/nodes/number/numbers.py +++ b/nodes/number/numbers.py @@ -168,7 +168,9 @@ def draw_label(self): def process(self): - + if not any(socket.is_linked for socket in self.outputs): + return + if not self.inputs[0].is_linked: prop_name = self.get_prop_name() self.outputs[0].sv_set([[getattr(self, prop_name)]]) diff --git a/nodes/number/oscillator.py b/nodes/number/oscillator.py index 1d8a7e38c2..186e19101a 100644 --- a/nodes/number/oscillator.py +++ b/nodes/number/oscillator.py @@ -175,7 +175,9 @@ def update_sockets(self): def process(self): - + if not any(socket.is_linked for socket in self.outputs): + return + if self.outputs[0].is_linked: if self.current_op == 'Custom' and not self.inputs["Wave"].is_linked: return diff --git a/nodes/number/random.py b/nodes/number/random.py index e8f9272dc0..f07fe083bf 100755 --- a/nodes/number/random.py +++ b/nodes/number/random.py @@ -44,7 +44,7 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Random") def process(self): - if not self.outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return Coun = self.inputs['Count'].sv_get()[0] diff --git a/nodes/number/random_num_gen.py b/nodes/number/random_num_gen.py index 0475d2ffdc..aa8f4949bf 100644 --- a/nodes/number/random_num_gen.py +++ b/nodes/number/random_num_gen.py @@ -298,21 +298,22 @@ def produce_range(self, *params): return result def process(self): + if not any(socket.is_linked for socket in self.outputs): + return inputs = self.inputs outputs = self.outputs mode = self.type_selected_mode - if outputs['Value'].is_linked: - if mode == 'Int': - params = [inputs[i].sv_get()[0] for i in range(4)] - if self.weighted and inputs[4].is_linked: - params.append(inputs[4].sv_get()) + if mode == 'Int': + params = [inputs[i].sv_get()[0] for i in range(4)] + if self.weighted and inputs[4].is_linked: + params.append(inputs[4].sv_get()) - elif mode == 'Float': - params = [inputs[i].sv_get()[0] for i in range(len(inputs)) if not inputs[i].hide] + elif mode == 'Float': + params = [inputs[i].sv_get()[0] for i in range(len(inputs)) if not inputs[i].hide] - out = [self.produce_range(*args) for args in zip(*match_long_repeat(params))] - outputs['Value'].sv_set(out) + out = [self.produce_range(*args) for args in zip(*match_long_repeat(params))] + outputs['Value'].sv_set(out) def register(): diff --git a/nodes/number/range_map.py b/nodes/number/range_map.py index 465708315a..606c5a00ef 100644 --- a/nodes/number/range_map.py +++ b/nodes/number/range_map.py @@ -141,12 +141,9 @@ def rclick_menu(self, context, layout): layout.prop(self, "output_numpy", expand=False) def process(self): - inputs = self.inputs - outputs = self.outputs - - # no outputs, end early. - if not outputs['Value'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + inputs = self.inputs params = [si.sv_get(default=[[]], deepcopy=False) for si in inputs] matching_f = list_match_func[self.list_match] diff --git a/nodes/number/scalar_mk4.py b/nodes/number/scalar_mk4.py index 1533bc4c20..95b7c2b6e3 100644 --- a/nodes/number/scalar_mk4.py +++ b/nodes/number/scalar_mk4.py @@ -256,28 +256,29 @@ def update_sockets(self): self.outputs[0].replace_socket("SvStringsSocket", "sin( x )") def process(self): - + if not any(socket.is_linked for socket in self.outputs): + return + self.ensure_enums_have_no_space(enums=["current_op"]) - if self.outputs[0].is_linked: - current_func = func_from_mode(self.current_op) - params = [si.sv_get(default=[[]], deepcopy=False) for si in self.inputs] - matching_f = list_match_func[self.list_match] - desired_levels = [2 for p in params] - - if self.current_op in ['GCD', 'ROUND-N']: - result = recurse_fxy(params[0], params[1], current_func) - elif self.current_op == 'SINCOS': - ops = [np.sin, self.list_match, self.output_numpy] - result = recurse_f_level_control(params, ops, math_numpy, matching_f, desired_levels) - ops2 = [np.cos, self.list_match, self.output_numpy] - result2 = recurse_f_level_control(params, ops2, math_numpy, matching_f, desired_levels) - self.outputs[1].sv_set(result2) - else: - ops = [current_func, self.list_match, self.output_numpy] - result = recurse_f_level_control(params, ops, math_numpy, matching_f, desired_levels) - - self.outputs[0].sv_set(result) + current_func = func_from_mode(self.current_op) + params = [si.sv_get(default=[[]], deepcopy=False) for si in self.inputs] + matching_f = list_match_func[self.list_match] + desired_levels = [2 for p in params] + + if self.current_op in ['GCD', 'ROUND-N']: + result = recurse_fxy(params[0], params[1], current_func) + elif self.current_op == 'SINCOS': + ops = [np.sin, self.list_match, self.output_numpy] + result = recurse_f_level_control(params, ops, math_numpy, matching_f, desired_levels) + ops2 = [np.cos, self.list_match, self.output_numpy] + result2 = recurse_f_level_control(params, ops2, math_numpy, matching_f, desired_levels) + self.outputs[1].sv_set(result2) + else: + ops = [current_func, self.list_match, self.output_numpy] + result = recurse_f_level_control(params, ops, math_numpy, matching_f, desired_levels) + + self.outputs[0].sv_set(result) def ensure_enums_have_no_space(self, enums=None): """ diff --git a/nodes/number/smooth_numbers.py b/nodes/number/smooth_numbers.py index f5f361c27c..a23384b016 100644 --- a/nodes/number/smooth_numbers.py +++ b/nodes/number/smooth_numbers.py @@ -99,17 +99,19 @@ def sv_init(self, context): def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Value"].is_linked): + raise Exception("Input socket 'Value' has to be connected") - if self.outputs[0].is_linked: + params = [si.sv_get(default=[[]], deepcopy=False) for si in self.inputs] + matching_f = list_match_func[self.list_match] - params = [si.sv_get(default=[[]], deepcopy=False) for si in self.inputs] - matching_f = list_match_func[self.list_match] + desired_levels = [2, 2, 2] + ops = [self.cyclic, self.output_numpy] + result = recurse_f_level_control(params, ops, smooth_numbers, matching_f, desired_levels) - desired_levels = [2, 2, 2] - ops = [self.cyclic, self.output_numpy] - result = recurse_f_level_control(params, ops, smooth_numbers, matching_f, desired_levels) - - self.outputs[0].sv_set(result) + self.outputs[0].sv_set(result) classes = [SvSmoothNumbersNode] From a6f3310bb26ee6778443d6c80b13d7410f7f0944 Mon Sep 17 00:00:00 2001 From: satabol Date: Sun, 31 Mar 2024 21:55:03 +0300 Subject: [PATCH 2/4] - Add check if output sockets are connected before execute nodes. - fix uvtexture (did not use object selected from drop-down list. Now this node can use object from drop-down list) --- nodes/object_nodes/armature_analyzer.py | 5 +++ nodes/pulga_physics/pulga_align_force.py | 4 +- nodes/pulga_physics/pulga_angle_force.py | 5 ++- nodes/pulga_physics/pulga_attraction_force.py | 3 +- .../pulga_attractors_force_mk2.py | 6 ++- nodes/pulga_physics/pulga_boundaries_force.py | 13 ++++-- nodes/pulga_physics/pulga_collision_force.py | 4 +- nodes/pulga_physics/pulga_drag_force.py | 4 +- nodes/pulga_physics/pulga_fit_force.py | 4 +- nodes/pulga_physics/pulga_inflate_force.py | 6 ++- nodes/pulga_physics/pulga_obstacle_force.py | 4 +- nodes/pulga_physics/pulga_physics_lite.py | 7 ++- nodes/pulga_physics/pulga_physics_solver.py | 12 ++--- nodes/pulga_physics/pulga_pin_force.py | 8 +++- nodes/pulga_physics/pulga_random_force.py | 4 +- nodes/pulga_physics/pulga_springs_force.py | 6 ++- nodes/pulga_physics/pulga_timed_force.py | 6 ++- nodes/pulga_physics/pulga_vector_force.py | 3 +- nodes/pulga_physics/pulga_vortex_force.py | 3 +- nodes/quaternion/quaternion_in_mk2.py | 2 +- nodes/quaternion/quaternion_math.py | 8 ++-- nodes/quaternion/quaternion_out_mk2.py | 4 +- nodes/quaternion/rotation_difference.py | 3 ++ nodes/scene/FCurve_in.py | 2 + nodes/scene/cache.py | 5 +++ nodes/scene/collection_picker_mk1.py | 4 ++ nodes/scene/curve_in.py | 5 +++ nodes/scene/get_objects_data.py | 8 ++-- nodes/scene/objects_in_lite.py | 6 ++- nodes/scene/particles_MK2.py | 3 ++ nodes/scene/selection_grabber_lite.py | 8 +++- nodes/scene/timer.py | 3 +- nodes/scene/uv_texture.py | 44 ++++++++++++------- nodes/script/formula_mk5.py | 6 ++- nodes/script/mesh_eval.py | 3 +- nodes/script/multi_exec.py | 3 ++ nodes/script/numexpr_node.py | 8 +++- nodes/script/profile_mk3.py | 2 +- nodes/solid/bound_box.py | 4 +- nodes/solid/center_of_mass.py | 2 + nodes/solid/chamfer_solid.py | 2 + nodes/solid/extrude_face.py | 2 + nodes/solid/face_area.py | 2 + nodes/solid/fillet_solid.py | 2 + nodes/solid/general_fuse.py | 2 + nodes/solid/hollow_solid.py | 2 + nodes/solid/import_solid.py | 2 + nodes/solid/is_closed.py | 2 + nodes/solid/make_compound.py | 2 +- nodes/solid/mesh_to_solid.py | 4 ++ nodes/solid/mirror_solid.py | 4 ++ nodes/solid/offset_solid.py | 2 + nodes/solid/points_inside_solid.py | 4 ++ nodes/solid/polygon_face.py | 4 ++ nodes/solid/projection_trim_face.py | 4 ++ nodes/solid/refine.py | 2 + nodes/solid/revolve_face.py | 4 +- nodes/solid/ruled_solid.py | 4 ++ nodes/solid/slice_solid.py | 4 ++ nodes/solid/solid_area.py | 2 + nodes/solid/solid_boolean.py | 8 ++++ nodes/solid/solid_edges.py | 2 + nodes/solid/solid_faces.py | 2 + nodes/solid/solid_from_faces.py | 2 + nodes/solid/solid_section.py | 4 ++ nodes/solid/solid_select.py | 5 ++- nodes/solid/solid_to_mesh_mk2.py | 2 + nodes/solid/solid_vertices.py | 2 + nodes/solid/solid_volume.py | 2 + nodes/solid/solidify_face.py | 2 + nodes/solid/split_solid.py | 4 ++ nodes/solid/sweep_face.py | 4 ++ nodes/solid/transform_solid.py | 4 ++ nodes/solid/wire_face.py | 2 + 74 files changed, 259 insertions(+), 82 deletions(-) diff --git a/nodes/object_nodes/armature_analyzer.py b/nodes/object_nodes/armature_analyzer.py index a248ae6fac..5d2fd890ea 100644 --- a/nodes/object_nodes/armature_analyzer.py +++ b/nodes/object_nodes/armature_analyzer.py @@ -40,7 +40,12 @@ def sv_init(self, context): self.outputs.new('SvObjectSocket', "Armature Object") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return armobj, selm = self.inputs + if armobj.is_linked==False: + raise Exception("Input socket 'Armature Object' has to be connected") + head, Cent, tail, Norm, lng, matr, obj = self.outputs armat = [ob.data.bones for ob in armobj.sv_get()] if selm.is_linked: diff --git a/nodes/pulga_physics/pulga_align_force.py b/nodes/pulga_physics/pulga_align_force.py index f871a7830a..8443beecf8 100644 --- a/nodes/pulga_physics/pulga_align_force.py +++ b/nodes/pulga_physics/pulga_align_force.py @@ -63,9 +63,9 @@ def draw_buttons(self, context, layout): layout.prop(self, 'mode') def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + strength = self.inputs["Strength"].sv_get(deepcopy=False) decay = self.inputs["Decay"].sv_get(deepcopy=False) max_distance = self.inputs["Max. Distance"].sv_get(deepcopy=False) diff --git a/nodes/pulga_physics/pulga_angle_force.py b/nodes/pulga_physics/pulga_angle_force.py index db83a62be8..b41ca22057 100644 --- a/nodes/pulga_physics/pulga_angle_force.py +++ b/nodes/pulga_physics/pulga_angle_force.py @@ -63,9 +63,10 @@ def sv_init(self, context): def draw_buttons(self, context, layout): layout.prop(self, 'mode') def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Edge_Pol"].is_linked): + raise Exception(f"Input socket '{self.inputs['Edge_Pol'].label}' has to be connected") springs_in = self.inputs["Edge_Pol"].sv_get(deepcopy=False) stiffness_in = self.inputs["Stiffness"].sv_get(deepcopy=False) lengths_in = self.inputs["Angle"].sv_get(deepcopy=False) diff --git a/nodes/pulga_physics/pulga_attraction_force.py b/nodes/pulga_physics/pulga_attraction_force.py index 4576773d2e..a5b901d721 100644 --- a/nodes/pulga_physics/pulga_attraction_force.py +++ b/nodes/pulga_physics/pulga_attraction_force.py @@ -68,8 +68,7 @@ def draw_buttons(self, context, layout): layout.prop(self, 'stop_on_collide') def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return strength = self.inputs["Strength"].sv_get(deepcopy=False) decay = self.inputs["Decay"].sv_get(deepcopy=False) diff --git a/nodes/pulga_physics/pulga_attractors_force_mk2.py b/nodes/pulga_physics/pulga_attractors_force_mk2.py index c1c90e054e..1919349b7e 100644 --- a/nodes/pulga_physics/pulga_attractors_force_mk2.py +++ b/nodes/pulga_physics/pulga_attractors_force_mk2.py @@ -73,9 +73,11 @@ def draw_buttons(self, context, layout): layout.prop(self, 'mode') def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Location"].is_linked): + raise Exception(f"Input socket '{self.inputs['Location'].label or self.inputs['Location'].identifier}' has to be connected") + loc = self.inputs["Location"].sv_get(deepcopy=False) strength = self.inputs["Strength"].sv_get(deepcopy=False) max_distance = self.inputs["Max. Distance"].sv_get(deepcopy=False) diff --git a/nodes/pulga_physics/pulga_boundaries_force.py b/nodes/pulga_physics/pulga_boundaries_force.py index b94a95a6e5..f69d7d9eb1 100644 --- a/nodes/pulga_physics/pulga_boundaries_force.py +++ b/nodes/pulga_physics/pulga_boundaries_force.py @@ -100,10 +100,12 @@ def draw_buttons(self, context, layout): layout.prop(self, 'mode') def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + if self.mode == 'Box': + if not (self.inputs["Bounding Box"].is_linked): + raise Exception(f"Input socket '{self.inputs['Bounding Box'].label or self.inputs['Bounding Box'].identifier}' has to be connected") b_box = self.inputs["Bounding Box"].sv_get(deepcopy=False) forces_out = [] @@ -134,7 +136,9 @@ def process(self): for force in zip_long_repeat(center, radius): forces_out.append(SvBoundingPlaneSurfaceForce(*force)) elif 'Mesh' in self.mode: - + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + verts = self.inputs["Vertices"].sv_get(deepcopy=False) polygons = self.inputs["Polygons"].sv_get(deepcopy=False) volume = self.mode == "Mesh_(Volume)" @@ -144,6 +148,9 @@ def process(self): elif 'Solid' in self.mode: input_name = 'Solid' if self.mode in ['Solid_(Surface)', 'Solid_(Volume)'] else 'Solid Face' + if not (self.inputs[input_name].is_linked): + raise Exception(f"Input socket '{self.inputs[input_name].label or self.inputs[input_name].identifier}' has to be connected") + solid = self.inputs[input_name].sv_get(deepcopy=False) volume = self.mode == "Solid_(Volume)" forces_out = [] diff --git a/nodes/pulga_physics/pulga_collision_force.py b/nodes/pulga_physics/pulga_collision_force.py index c2ebb2325d..d7681f9b16 100644 --- a/nodes/pulga_physics/pulga_collision_force.py +++ b/nodes/pulga_physics/pulga_collision_force.py @@ -54,9 +54,9 @@ def draw_buttons(self, context, layout): layout.prop(self, 'mode') def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + forces_in = self.inputs["Strength"].sv_get(deepcopy=False) forces_out = [] diff --git a/nodes/pulga_physics/pulga_drag_force.py b/nodes/pulga_physics/pulga_drag_force.py index 3ded0e269b..785d6b8721 100644 --- a/nodes/pulga_physics/pulga_drag_force.py +++ b/nodes/pulga_physics/pulga_drag_force.py @@ -50,9 +50,9 @@ def sv_init(self, context): def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + magnitude = self.inputs["Magnitude"].sv_get(deepcopy=False) exponent = self.inputs["Exponent"].sv_get(deepcopy=False) diff --git a/nodes/pulga_physics/pulga_fit_force.py b/nodes/pulga_physics/pulga_fit_force.py index 096b46478e..8fee9aa8b5 100644 --- a/nodes/pulga_physics/pulga_fit_force.py +++ b/nodes/pulga_physics/pulga_fit_force.py @@ -64,9 +64,9 @@ def draw_buttons(self, context, layout): layout.prop(self, 'algorithm') def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + forces_in = self.inputs["Magnitude"].sv_get(deepcopy=False) min_rad_in = self.inputs["Min Radius"].sv_get(deepcopy=False) max_rad_in = self.inputs["Max Radius"].sv_get(deepcopy=False) diff --git a/nodes/pulga_physics/pulga_inflate_force.py b/nodes/pulga_physics/pulga_inflate_force.py index 4dc02d18f3..0a0b199ff2 100644 --- a/nodes/pulga_physics/pulga_inflate_force.py +++ b/nodes/pulga_physics/pulga_inflate_force.py @@ -48,9 +48,11 @@ def sv_init(self, context): self.outputs.new('SvPulgaForceSocket', "Force") def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Polygons"].is_linked): + raise Exception(f"Input socket '{self.inputs['Polygons'].label or self.inputs['Polygons'].identifier}' has to be connected") + pols_in = self.inputs["Polygons"].sv_get(deepcopy=False) force_in = self.inputs["Magnitude"].sv_get(deepcopy=False) diff --git a/nodes/pulga_physics/pulga_obstacle_force.py b/nodes/pulga_physics/pulga_obstacle_force.py index 57e4daf388..682597d6be 100644 --- a/nodes/pulga_physics/pulga_obstacle_force.py +++ b/nodes/pulga_physics/pulga_obstacle_force.py @@ -51,9 +51,9 @@ def sv_init(self, context): self.outputs.new('SvPulgaForceSocket', "Force") def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + magnitude = self.inputs["Vertices"].sv_get(deepcopy=False) pols = self.inputs["Pols"].sv_get(deepcopy=False) absorption = self.inputs["Absorption"].sv_get(deepcopy=False) diff --git a/nodes/pulga_physics/pulga_physics_lite.py b/nodes/pulga_physics/pulga_physics_lite.py index 68d0817f7a..8bc6d43849 100644 --- a/nodes/pulga_physics/pulga_physics_lite.py +++ b/nodes/pulga_physics/pulga_physics_lite.py @@ -505,12 +505,15 @@ def get_global_cache(self): return data, past, from_file def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Initial_Pos"].is_linked): + raise Exception(f"Input socket '{self.inputs['Initial_Pos'].label or self.inputs['Initial_Pos'].identifier}' has to be connected") + '''main node function called every update''' si = self.inputs so = self.outputs - if not any(socket.is_linked for socket in so): - return if not si['Initial_Pos'].is_linked: return diff --git a/nodes/pulga_physics/pulga_physics_solver.py b/nodes/pulga_physics/pulga_physics_solver.py index 1fd9ea1465..77c29f0aa6 100644 --- a/nodes/pulga_physics/pulga_physics_solver.py +++ b/nodes/pulga_physics/pulga_physics_solver.py @@ -284,15 +284,17 @@ def get_global_cache(self): return data, past, from_file def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Initial_Pos"].is_linked): + raise Exception(f"Input socket '{self.inputs['Initial_Pos'].label or self.inputs['Initial_Pos'].identifier}' has to be connected") + if not (self.inputs["Forces"].is_linked): + raise Exception(f"Input socket '{self.inputs['Forces'].label or self.inputs['Forces'].identifier}' has to be connected") + '''main node function called every update''' si = self.inputs so = self.outputs - if not any(socket.is_linked for socket in so): - return - - if not si['Initial_Pos'].is_linked or not si['Forces'].is_linked: - return verts_out = [] rads_out = [] diff --git a/nodes/pulga_physics/pulga_pin_force.py b/nodes/pulga_physics/pulga_pin_force.py index 36da0e217f..b6bb1fc018 100644 --- a/nodes/pulga_physics/pulga_pin_force.py +++ b/nodes/pulga_physics/pulga_pin_force.py @@ -48,9 +48,13 @@ def sv_init(self, context): self.outputs.new('SvPulgaForceSocket', "Force") def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Pins"].is_linked): + raise Exception(f"Input socket '{self.inputs['Pins'].label or self.inputs['Pins'].identifier}' has to be connected") + if not (self.inputs["Pins Goal"].is_linked): + raise Exception(f"Input socket '{self.inputs['Pins Goal'].label or self.inputs['Pins Goal'].identifier}' has to be connected") + # indices, pin_type, pins_goal_pos,use_pins_goal pins_in = self.inputs["Pins"].sv_get(deepcopy=False) pin_type = self.inputs["Pin Type"].sv_get(deepcopy=False) diff --git a/nodes/pulga_physics/pulga_random_force.py b/nodes/pulga_physics/pulga_random_force.py index 2f24e6d15f..61faa489cb 100644 --- a/nodes/pulga_physics/pulga_random_force.py +++ b/nodes/pulga_physics/pulga_random_force.py @@ -52,9 +52,9 @@ def sv_init(self, context): self.outputs.new('SvPulgaForceSocket', "Force") def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + forces_in = self.inputs["Magnitude"].sv_get(deepcopy=False) random_variation = self.inputs["Variation"].sv_get(deepcopy=False) random_seed = self.inputs["Seed"].sv_get(deepcopy=False) diff --git a/nodes/pulga_physics/pulga_springs_force.py b/nodes/pulga_physics/pulga_springs_force.py index c296b88d45..f1d161c61a 100644 --- a/nodes/pulga_physics/pulga_springs_force.py +++ b/nodes/pulga_physics/pulga_springs_force.py @@ -56,9 +56,11 @@ def sv_init(self, context): self.outputs.new('SvPulgaForceSocket', "Force") def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Springs"].is_linked): + raise Exception(f"Input socket '{self.inputs['Springs'].label or self.inputs['Springs'].identifier}' has to be connected") + springs_in = self.inputs["Springs"].sv_get(deepcopy=False) stiffness_in = self.inputs["Stiffness"].sv_get(deepcopy=False) lengths_in = self.inputs["Length"].sv_get(deepcopy=False) diff --git a/nodes/pulga_physics/pulga_timed_force.py b/nodes/pulga_physics/pulga_timed_force.py index bb206ea50b..ecacefabc5 100644 --- a/nodes/pulga_physics/pulga_timed_force.py +++ b/nodes/pulga_physics/pulga_timed_force.py @@ -48,9 +48,11 @@ def sv_init(self, context): def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Force"].is_linked): + raise Exception(f"Input socket '{self.inputs['Force'].label or self.inputs['Force'].identifier}' has to be connected") + forces_in = self.inputs["Force"].sv_get(deepcopy=False) start_in = self.inputs["Start"].sv_get(deepcopy=False) end_in = self.inputs["End"].sv_get(deepcopy=False) diff --git a/nodes/pulga_physics/pulga_vector_force.py b/nodes/pulga_physics/pulga_vector_force.py index 0148fba6ec..00869985c6 100644 --- a/nodes/pulga_physics/pulga_vector_force.py +++ b/nodes/pulga_physics/pulga_vector_force.py @@ -62,8 +62,7 @@ def draw_buttons(self, context, layout): layout.prop(self, "mass_proportional") def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return forces_in = self.inputs["Force"].sv_get(deepcopy=False) diff --git a/nodes/pulga_physics/pulga_vortex_force.py b/nodes/pulga_physics/pulga_vortex_force.py index f2a0fd46ae..e695d25e2d 100644 --- a/nodes/pulga_physics/pulga_vortex_force.py +++ b/nodes/pulga_physics/pulga_vortex_force.py @@ -70,8 +70,7 @@ def sv_init(self, context): def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return loc = self.inputs["Location"].sv_get(deepcopy=False) diff --git a/nodes/quaternion/quaternion_in_mk2.py b/nodes/quaternion/quaternion_in_mk2.py index 9a1a305d90..9806a71e76 100644 --- a/nodes/quaternion/quaternion_in_mk2.py +++ b/nodes/quaternion/quaternion_in_mk2.py @@ -165,7 +165,7 @@ def draw_buttons_ext(self, context, layout): self.draw_angle_units_buttons(context, layout) def process(self): - if not self.outputs['Quaternions'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return inputs = self.inputs diff --git a/nodes/quaternion/quaternion_math.py b/nodes/quaternion/quaternion_math.py index 0387a1ed70..079c074739 100644 --- a/nodes/quaternion/quaternion_math.py +++ b/nodes/quaternion/quaternion_math.py @@ -218,17 +218,17 @@ def get_operation(self): return lambda q: q.magnitude def process(self): - outputs = self.outputs - if not any(s.is_linked for s in outputs): + if not any(socket.is_linked for socket in self.outputs): return - + + outputs = self.outputs inputs = self.inputs all_AZ_sockets = list(filter(lambda s: s.name in ABC, inputs)) connected_AZ_sockets = list(filter(lambda s: s.is_linked, all_AZ_sockets)) if len(connected_AZ_sockets) == 0: - return + raise Exception("Some input sockets has to be connected") # collect the quaternion inputs from all connected AZ sockets I = [s.sv_get(default=id_quat) for s in connected_AZ_sockets] diff --git a/nodes/quaternion/quaternion_out_mk2.py b/nodes/quaternion/quaternion_out_mk2.py index 14bce51e7c..5219ecca56 100644 --- a/nodes/quaternion/quaternion_out_mk2.py +++ b/nodes/quaternion/quaternion_out_mk2.py @@ -122,10 +122,10 @@ def draw_buttons_ext(self, context, layout): self.draw_angle_units_buttons(context, layout) def process(self): - outputs = self.outputs - if not any(s.is_linked for s in outputs): + if not any(socket.is_linked for socket in self.outputs): return + outputs = self.outputs input_Q = self.inputs['Quaternions'].sv_get() quaternion_list = [Quaternion(q) for q in input_Q] diff --git a/nodes/quaternion/rotation_difference.py b/nodes/quaternion/rotation_difference.py index bb94eb9c6c..10cea54fd4 100644 --- a/nodes/quaternion/rotation_difference.py +++ b/nodes/quaternion/rotation_difference.py @@ -59,6 +59,9 @@ def sv_init(self, context): self.outputs.new('SvQuaternionSocket', 'Quaternions') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + max_len = max([len(sock.sv_get(deepcopy=False)) for sock in self.inputs]) inputs = [iter_last(sock.sv_get(default=False)) for sock in self.inputs] out = [get_quaternion(v1, v2) for i, v1, v2 in zip(range(max_len), *inputs)] diff --git a/nodes/scene/FCurve_in.py b/nodes/scene/FCurve_in.py index 7ddf7c607b..8a7aedd935 100644 --- a/nodes/scene/FCurve_in.py +++ b/nodes/scene/FCurve_in.py @@ -109,6 +109,8 @@ def evaluate(self, frames): def process(self): + if not any(socket.is_linked for socket in self.outputs): + return """ - if no input is given then the node will use current frame in bpy.context.scene - if input is given, behaviour depends on 2 things: diff --git a/nodes/scene/cache.py b/nodes/scene/cache.py index ad72a49483..919b535c1d 100644 --- a/nodes/scene/cache.py +++ b/nodes/scene/cache.py @@ -50,6 +50,11 @@ def sv_update(self): changable_sockets(self, "Data", ["Data"]) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Data"].is_linked): + raise Exception(f"Input socket '{self.inputs['Data'].label or self.inputs['Data'].identifier}' has to be connected") + n_id = self.node_id data = self.node_dict.get(n_id) if not data: diff --git a/nodes/scene/collection_picker_mk1.py b/nodes/scene/collection_picker_mk1.py index a4cdbc640e..7747c05408 100644 --- a/nodes/scene/collection_picker_mk1.py +++ b/nodes/scene/collection_picker_mk1.py @@ -60,6 +60,10 @@ def sv_draw_buttons(self, context, layout): layout.prop(self, "sort_object"); def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not self.collection: + raise Exception(f"Collection not selected. Select collection") found_objects = [] if self.collection: diff --git a/nodes/scene/curve_in.py b/nodes/scene/curve_in.py index 4393caf61d..1c8215d43d 100644 --- a/nodes/scene/curve_in.py +++ b/nodes/scene/curve_in.py @@ -178,6 +178,11 @@ def get_objects(self): def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["objects"].is_linked): + raise Exception(f"Input socket '{self.inputs['objects'].label or self.inputs['objects'].identifier}' has to be connected") + _out = self.outputs objects = self.get_objects() diff --git a/nodes/scene/get_objects_data.py b/nodes/scene/get_objects_data.py index 557229718b..28f17d4ec4 100644 --- a/nodes/scene/get_objects_data.py +++ b/nodes/scene/get_objects_data.py @@ -373,11 +373,13 @@ def get_materials_from_bmesh(self, bm): return [face.material_index for face in bm.faces[:]] def process(self): - + if not any(socket.is_linked for socket in self.outputs): + return + objs = self.inputs[0].sv_get(default=[[]]) if not self.object_names and not objs[0]: - - return + raise Exception("No objects. Check selection or connect input socket 'Objects'") + data_objects = bpy.data.objects outputs = self.outputs diff --git a/nodes/scene/objects_in_lite.py b/nodes/scene/objects_in_lite.py index 339e522f60..7bebd2faad 100644 --- a/nodes/scene/objects_in_lite.py +++ b/nodes/scene/objects_in_lite.py @@ -124,7 +124,11 @@ def pass_data_to_sockets(self): socket.sv_set([mesh_data[socket.name]]) def process(self): - + if not any(socket.is_linked for socket in self.outputs): + return + if not self.obj_name: + raise Exception("No selected objects.") + if not hash(self) in self.node_dict: if self.obj_name and bpy.data.objects.get(self.obj_name): self.dget(self.obj_name) diff --git a/nodes/scene/particles_MK2.py b/nodes/scene/particles_MK2.py index a557eb71b2..82d68b7ef8 100644 --- a/nodes/scene/particles_MK2.py +++ b/nodes/scene/particles_MK2.py @@ -45,6 +45,9 @@ def sv_init(self, context): self.outputs.new('SvVerticesSocket', "outVelocity") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + O, V, L, S = self.inputs outL, outV = self.outputs diff --git a/nodes/scene/selection_grabber_lite.py b/nodes/scene/selection_grabber_lite.py index c01879d31e..4f9030a70b 100644 --- a/nodes/scene/selection_grabber_lite.py +++ b/nodes/scene/selection_grabber_lite.py @@ -31,9 +31,13 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Face Mask") def process(self): - objects = self.inputs['Object'].sv_get() - if not objects: + if not any(socket.is_linked for socket in self.outputs): return + if not self.inputs['Object'].object_ref_pointer: + raise Exception("No object selected. Select object or connect input socket 'Object'.") + + objects = self.inputs['Object'].sv_get() + include_vertex = self.outputs["Vertex Mask"].is_linked include_edges = self.outputs["Edge Mask"].is_linked diff --git a/nodes/scene/timer.py b/nodes/scene/timer.py index 746add19ac..88d58ac88b 100644 --- a/nodes/scene/timer.py +++ b/nodes/scene/timer.py @@ -498,8 +498,7 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Loop") def process(self): - # return if no outputs are connected - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return # input values lists (single or multi value) diff --git a/nodes/scene/uv_texture.py b/nodes/scene/uv_texture.py index a40561fa08..4ea9f7e0c0 100644 --- a/nodes/scene/uv_texture.py +++ b/nodes/scene/uv_texture.py @@ -41,18 +41,28 @@ def sv_init(self, context): def avail_objects(self, context): items = [('','','')] + objects = [] if self.inputs and self.inputs[0].is_linked: objects = self.inputs[0].sv_get() + else: + objects = [self.inputs['Object'].object_ref_pointer] + + if objects: items = [(obj.name, obj.name, '') for obj in objects] return items @keep_enum_reference def avail_uvs(self, context): items = [('','','')] + obj = None if self.inputs and self.inputs[0].is_linked: obj = bpy.data.objects[self.objects] - if obj.data.uv_layers: - items = [(p.name, p.name, "") for p in obj.data.uv_layers] + else: + obj = self.inputs['Object'].object_ref_pointer + + if obj and obj.data.uv_layers: + items = [(p.name, p.name, "") for p in obj.data.uv_layers] + return items objects: EnumProperty(items=avail_objects, name="Objects", @@ -110,20 +120,22 @@ def UV(self, object, uv): return [vertices_new], [polygons_new] def process(self): - if self.inputs and self.inputs[0].is_linked: - obj = bpy.data.objects[self.objects] - if not self.uv: - print ('!!! for node:',self.name,'!!! object',self.objects,'have no UV') - if self.outputs and self.outputs[0].is_linked: - self.outputs[0].sv_set([[]]) - return - uv = self.uv - v,p = self.UV(obj,uv) - - if self.outputs and self.outputs[0].is_linked: - self.outputs[0].sv_set(v) - if self.outputs and self.outputs[1].is_linked: - self.outputs[1].sv_set(p) + if not any(socket.is_linked for socket in self.outputs): + return + if not self.inputs['Object'].object_ref_pointer: + if not self.inputs['Object'].is_linked: + raise Exception("No object selected. Select object or connect input socket 'Object'.") + + obj = bpy.data.objects[self.objects] + if not self.uv: + raise Exception("Not selected uv in object. Select UV or test if object has UV.") + uv = self.uv + v,p = self.UV(obj,uv) + + if self.outputs and self.outputs[0].is_linked: + self.outputs[0].sv_set(v) + if self.outputs and self.outputs[1].is_linked: + self.outputs[1].sv_set(p) def register(): diff --git a/nodes/script/formula_mk5.py b/nodes/script/formula_mk5.py index c55e23e430..b5d03949c7 100644 --- a/nodes/script/formula_mk5.py +++ b/nodes/script/formula_mk5.py @@ -289,10 +289,12 @@ def all_inputs_connected(self): def migrate_from(self, old_node): self.output_dimensions = old_node.dimensions - def process(self): - if not self.outputs[0].is_linked: + def process(self): + if not any(socket.is_linked for socket in self.outputs): return + if self.inputs and not any(socket.is_linked for socket in self.inputs): + raise Exception("All input sockets has to be connected") # if the user specifies a variable, they must also link a value into that socket, this will prevent Exception self.ui_message = "" diff --git a/nodes/script/mesh_eval.py b/nodes/script/mesh_eval.py index 2f73f0705f..53848c8dbb 100644 --- a/nodes/script/mesh_eval.py +++ b/nodes/script/mesh_eval.py @@ -493,8 +493,7 @@ def groups_to_masks(self, groups, size): return result def process(self): - - if not self.outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return sync_pointer_and_stored_name(self, "file_pointer", "filename") diff --git a/nodes/script/multi_exec.py b/nodes/script/multi_exec.py index 74deeb02f5..bcea67a792 100644 --- a/nodes/script/multi_exec.py +++ b/nodes/script/multi_exec.py @@ -230,6 +230,9 @@ def sv_init(self, context): self.width = 289 def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + v1, v2, v3 = self.inputs V1, V2, V3 = v1.sv_get(0), v2.sv_get(0), v3.sv_get(0) out = [] diff --git a/nodes/script/numexpr_node.py b/nodes/script/numexpr_node.py index 650700688f..32a98996d0 100644 --- a/nodes/script/numexpr_node.py +++ b/nodes/script/numexpr_node.py @@ -25,6 +25,7 @@ class SvNumExprNode(SverchCustomTreeNode, bpy.types.Node): """ bl_idname = 'SvNumExprNode' bl_label = 'Num Expression node' + bl_icon = 'CON_TRANSFORM_CACHE' sv_icon = 'SV_FORMULA' sv_dependencies = ['numexpr'] @@ -145,9 +146,12 @@ def sv_init(self, context): self.debug("It seems there is some problem in ordering sockets") def process(self): - if not self.expression: - self.outputs[0].sv_set([]) + if not any(socket.is_linked for socket in self.outputs): return + + if not self.expression: + raise Exception("Expression is empty. Write expression.") + if invalid_names := self.get('invalid_names'): raise NameError(f"{invalid_names=}") inp_vars = [s.sv_get(deepcopy=False) for s in self.inputs] diff --git a/nodes/script/profile_mk3.py b/nodes/script/profile_mk3.py index fce6894009..963e415242 100644 --- a/nodes/script/profile_mk3.py +++ b/nodes/script/profile_mk3.py @@ -620,7 +620,7 @@ def process(self): if text: self.file_pointer = text - if not any(o.is_linked for o in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return sync_pointer_and_stored_name(self, "file_pointer", "filename") diff --git a/nodes/solid/bound_box.py b/nodes/solid/bound_box.py index 4a37a9335b..3584194fd8 100644 --- a/nodes/solid/bound_box.py +++ b/nodes/solid/bound_box.py @@ -75,8 +75,10 @@ def sv_init(self, context): self.update_sockets(context) def process(self): - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") solids_in = self.inputs['Solid'].sv_get() diff --git a/nodes/solid/center_of_mass.py b/nodes/solid/center_of_mass.py index 8009b738c9..0b0fa42252 100644 --- a/nodes/solid/center_of_mass.py +++ b/nodes/solid/center_of_mass.py @@ -32,6 +32,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") solids_in = self.inputs['Solid'].sv_get() diff --git a/nodes/solid/chamfer_solid.py b/nodes/solid/chamfer_solid.py index bfb0bff6c3..fdc514b03d 100644 --- a/nodes/solid/chamfer_solid.py +++ b/nodes/solid/chamfer_solid.py @@ -43,6 +43,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not self.inputs["Solid"].is_linked: + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") solids_in = self.inputs[0].sv_get() distance_a_s = self.inputs[1].sv_get()[0] diff --git a/nodes/solid/extrude_face.py b/nodes/solid/extrude_face.py index a72b172a9c..b6118d9b4e 100644 --- a/nodes/solid/extrude_face.py +++ b/nodes/solid/extrude_face.py @@ -48,6 +48,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["SolidFace"].is_linked): + raise Exception(f"Input socket '{self.inputs['SolidFace'].label or self.inputs['SolidFace'].identifier}' has to be connected") face_surfaces_s = self.inputs['SolidFace'].sv_get() face_surfaces_s = ensure_nesting_level(face_surfaces_s, 2, data_types=(SvSurface,)) diff --git a/nodes/solid/face_area.py b/nodes/solid/face_area.py index c8e84d3f17..1b1933299d 100644 --- a/nodes/solid/face_area.py +++ b/nodes/solid/face_area.py @@ -32,6 +32,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["SolidFace"].is_linked): + raise Exception(f"Input socket '{self.inputs['SolidFace'].label or self.inputs['SolidFace'].identifier}' has to be connected") faces_in = self.inputs['SolidFace'].sv_get() diff --git a/nodes/solid/fillet_solid.py b/nodes/solid/fillet_solid.py index e9d0b16412..5b83f657b7 100644 --- a/nodes/solid/fillet_solid.py +++ b/nodes/solid/fillet_solid.py @@ -40,6 +40,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") solids_in = self.inputs[0].sv_get() radius_start_s = self.inputs[1].sv_get()[0] diff --git a/nodes/solid/general_fuse.py b/nodes/solid/general_fuse.py index 9c6db31ab8..09e6f90e51 100644 --- a/nodes/solid/general_fuse.py +++ b/nodes/solid/general_fuse.py @@ -190,6 +190,8 @@ def _process(self, solids, include_idxs, exclude_idxs): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solids"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solids'].label or self.inputs['Solids'].identifier}' has to be connected") solids_in = self.inputs['Solids'].sv_get() input_level = get_data_nesting_level(solids_in, data_types=(Part.Shape,)) diff --git a/nodes/solid/hollow_solid.py b/nodes/solid/hollow_solid.py index e13b01bf0f..83ee3b346c 100644 --- a/nodes/solid/hollow_solid.py +++ b/nodes/solid/hollow_solid.py @@ -88,6 +88,8 @@ def make_solid(self, solid, thickness, mask): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") solids_s = self.inputs['Solid'].sv_get() input_level = get_data_nesting_level(solids_s, data_types=(Part.Shape,)) diff --git a/nodes/solid/import_solid.py b/nodes/solid/import_solid.py index f7535fa9d4..7676482bd0 100644 --- a/nodes/solid/import_solid.py +++ b/nodes/solid/import_solid.py @@ -25,6 +25,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["File Path"].is_linked): + raise Exception(f"Input socket '{self.inputs['File Path'].label or self.inputs['File Path'].identifier}' has to be connected") files = self.inputs[0].sv_get()[0] diff --git a/nodes/solid/is_closed.py b/nodes/solid/is_closed.py index 52bfbb626e..307b665d65 100644 --- a/nodes/solid/is_closed.py +++ b/nodes/solid/is_closed.py @@ -32,6 +32,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") solids_in = self.inputs['Solid'].sv_get() diff --git a/nodes/solid/make_compound.py b/nodes/solid/make_compound.py index 7c7da36857..d3666d4324 100644 --- a/nodes/solid/make_compound.py +++ b/nodes/solid/make_compound.py @@ -38,7 +38,7 @@ def process(self): if not self.outputs['Compound'].is_linked: return if not any(sock.is_linked for sock in self.inputs): - return + raise Exception("Some input sockets has to be connected") solids_s = self.inputs['Solids'].sv_get(default=[[None]]) curves_s = self.inputs['Curves'].sv_get(default=[[None]]) diff --git a/nodes/solid/mesh_to_solid.py b/nodes/solid/mesh_to_solid.py index 5f88896118..9676ff9430 100644 --- a/nodes/solid/mesh_to_solid.py +++ b/nodes/solid/mesh_to_solid.py @@ -86,6 +86,10 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") + if not (self.inputs["Faces"].is_linked): + raise Exception(f"Input socket '{self.inputs['Faces'].label or self.inputs['Faces'].identifier}' has to be connected") verts_s = self.inputs[0].sv_get(deepcopy=False) faces_s = self.inputs[1].sv_get(deepcopy=False) diff --git a/nodes/solid/mirror_solid.py b/nodes/solid/mirror_solid.py index 6085706404..a1e3b6ace1 100644 --- a/nodes/solid/mirror_solid.py +++ b/nodes/solid/mirror_solid.py @@ -36,6 +36,10 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") + if not (self.inputs["Matrix"].is_linked): + raise Exception(f"Input socket '{self.inputs['Matrix'].label or self.inputs['Matrix'].identifier}' has to be connected") solids_in = self.inputs[0].sv_get() matrixes = self.inputs[1].sv_get() diff --git a/nodes/solid/offset_solid.py b/nodes/solid/offset_solid.py index 81d5f0b7b9..cb86757077 100644 --- a/nodes/solid/offset_solid.py +++ b/nodes/solid/offset_solid.py @@ -65,6 +65,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") solids_in = self.inputs[0].sv_get(deepcopy=False) offsets = self.inputs[1].sv_get(deepcopy=False)[0] diff --git a/nodes/solid/points_inside_solid.py b/nodes/solid/points_inside_solid.py index 56c1c45175..432c1dedf1 100644 --- a/nodes/solid/points_inside_solid.py +++ b/nodes/solid/points_inside_solid.py @@ -48,6 +48,10 @@ def draw_buttons(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") solids_in = self.inputs[0].sv_get() points = self.inputs[1].sv_get() diff --git a/nodes/solid/polygon_face.py b/nodes/solid/polygon_face.py index de436ae8fd..a9fa6a00fd 100644 --- a/nodes/solid/polygon_face.py +++ b/nodes/solid/polygon_face.py @@ -65,6 +65,10 @@ def make_faces(self, verts, face_idxs): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + if not (self.inputs["Faces"].is_linked): + raise Exception(f"Input socket '{self.inputs['Faces'].label or self.inputs['Faces'].identifier}' has to be connected") verts_s = self.inputs['Vertices'].sv_get() verts_s = ensure_nesting_level(verts_s, 3) diff --git a/nodes/solid/projection_trim_face.py b/nodes/solid/projection_trim_face.py index 0343b822ef..6c272a5c1a 100644 --- a/nodes/solid/projection_trim_face.py +++ b/nodes/solid/projection_trim_face.py @@ -151,6 +151,10 @@ def cut(self, face_surface, sv_curves, point, vector): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Surface"].is_linked): + raise Exception(f"Input socket '{self.inputs['Surface'].label or self.inputs['Surface'].identifier}' has to be connected") + if not (self.inputs["Cut"].is_linked): + raise Exception(f"Input socket '{self.inputs['Cut'].label or self.inputs['Cut'].identifier}' has to be connected") surface_s = self.inputs['Surface'].sv_get() surface_s = ensure_nesting_level(surface_s, 2, data_types=(SvSurface,)) diff --git a/nodes/solid/refine.py b/nodes/solid/refine.py index db91028c19..2bc816c82d 100644 --- a/nodes/solid/refine.py +++ b/nodes/solid/refine.py @@ -32,6 +32,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") solids_in = self.inputs['Solid'].sv_get() diff --git a/nodes/solid/revolve_face.py b/nodes/solid/revolve_face.py index c4a1cb14ef..de2bb6d458 100644 --- a/nodes/solid/revolve_face.py +++ b/nodes/solid/revolve_face.py @@ -56,7 +56,9 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["SolidFace"].is_linked): + raise Exception(f"Input socket '{self.inputs['SolidFace'].label or self.inputs['SolidFace'].identifier}' has to be connected") + face_surfaces_s = self.inputs['SolidFace'].sv_get() face_surfaces_s = ensure_nesting_level(face_surfaces_s, 2, data_types=(SvSurface,)) angle_s = self.inputs['Angle'].sv_get() diff --git a/nodes/solid/ruled_solid.py b/nodes/solid/ruled_solid.py index b729031444..a28fec37d4 100644 --- a/nodes/solid/ruled_solid.py +++ b/nodes/solid/ruled_solid.py @@ -175,6 +175,10 @@ def make_solid(self, face1, face2): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["SolidFace1"].is_linked): + raise Exception(f"Input socket '{self.inputs['SolidFace1'].label or self.inputs['SolidFace1'].identifier}' has to be connected") + if not (self.inputs["SolidFace2"].is_linked): + raise Exception(f"Input socket '{self.inputs['SolidFace2'].label or self.inputs['SolidFace2'].identifier}' has to be connected") face1_surfaces_s = self.inputs['SolidFace1'].sv_get() face1_surfaces_s = ensure_nesting_level(face1_surfaces_s, 2, data_types=(SvSurface,)) diff --git a/nodes/solid/slice_solid.py b/nodes/solid/slice_solid.py index 41d7a0c80e..808cc1c954 100644 --- a/nodes/solid/slice_solid.py +++ b/nodes/solid/slice_solid.py @@ -43,6 +43,10 @@ def draw_buttons(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") + if not (self.inputs["Matrix"].is_linked): + raise Exception(f"Input socket '{self.inputs['Matrix'].label or self.inputs['Matrix'].identifier}' has to be connected") solids_in = self.inputs[0].sv_get(deepcopy=False) matrixes = self.inputs[1].sv_get(deepcopy=False) diff --git a/nodes/solid/solid_area.py b/nodes/solid/solid_area.py index 6cbab380d5..2f0103606a 100644 --- a/nodes/solid/solid_area.py +++ b/nodes/solid/solid_area.py @@ -34,6 +34,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") solids_in = self.inputs['Solid'].sv_get() diff --git a/nodes/solid/solid_boolean.py b/nodes/solid/solid_boolean.py index e35b73546c..a45e81c973 100644 --- a/nodes/solid/solid_boolean.py +++ b/nodes/solid/solid_boolean.py @@ -161,6 +161,9 @@ def process(self): face_masks_out = [] face_srcs_out = [] if self.nest_objs: + if not (self.inputs["Solids"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solids'].label or self.inputs['Solids'].identifier}' has to be connected") + solids_in = self.inputs['Solids'].sv_get() #level = get_data_nesting_level(solids_in, data_types=(Part.Shape,)) solids_in = ensure_nesting_level(solids_in, 2, data_types=(Part.Shape,)) @@ -174,6 +177,11 @@ def process(self): face_srcs_out.append(result.face_map) else: + if not (self.inputs["Solid A"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid A'].label or self.inputs['Solid A'].identifier}' has to be connected") + if not (self.inputs["Solid B"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid B'].label or self.inputs['Solid B'].identifier}' has to be connected") + solids_a_in = self.inputs['Solid A'].sv_get() solids_b_in = self.inputs['Solid B'].sv_get() level_a = get_data_nesting_level(solids_a_in, data_types=(Part.Shape,)) diff --git a/nodes/solid/solid_edges.py b/nodes/solid/solid_edges.py index 49e5f7694e..1e23aa9b18 100644 --- a/nodes/solid/solid_edges.py +++ b/nodes/solid/solid_edges.py @@ -46,6 +46,8 @@ def draw_buttons_ext(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") solids = self.inputs['Solid'].sv_get() diff --git a/nodes/solid/solid_faces.py b/nodes/solid/solid_faces.py index df45188926..36b0a1e60f 100644 --- a/nodes/solid/solid_faces.py +++ b/nodes/solid/solid_faces.py @@ -53,6 +53,8 @@ def draw_buttons_ext(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") solids = self.inputs['Solid'].sv_get() diff --git a/nodes/solid/solid_from_faces.py b/nodes/solid/solid_from_faces.py index b9b8089302..9bcfef23fe 100644 --- a/nodes/solid/solid_from_faces.py +++ b/nodes/solid/solid_from_faces.py @@ -81,6 +81,8 @@ def make_solid(self, surfaces): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["SolidFaces"].is_linked): + raise Exception(f"Input socket '{self.inputs['SolidFaces'].label or self.inputs['SolidFaces'].identifier}' has to be connected") face_surfaces_s = self.inputs['SolidFaces'].sv_get() input_level = get_data_nesting_level(face_surfaces_s, data_types=(SvSurface,)) diff --git a/nodes/solid/solid_section.py b/nodes/solid/solid_section.py index 9bfe3ca0ec..c9212c47ed 100644 --- a/nodes/solid/solid_section.py +++ b/nodes/solid/solid_section.py @@ -56,6 +56,10 @@ def make_section(self, shapes): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Shape A"].is_linked): + raise Exception(f"Input socket '{self.inputs['Shape A'].label or self.inputs['Shape A'].identifier}' has to be connected") + if not (self.inputs["Shape B"].is_linked): + raise Exception(f"Input socket '{self.inputs['Shape B'].label or self.inputs['Shape B'].identifier}' has to be connected") sections_out = [] diff --git a/nodes/solid/solid_select.py b/nodes/solid/solid_select.py index e81e0646b6..e5e027b1fd 100644 --- a/nodes/solid/solid_select.py +++ b/nodes/solid/solid_select.py @@ -461,12 +461,15 @@ def calc_mask(self, solid, tool, precision, direction, center, percent, radius): return vertex_mask, edge_mask, face_mask def process(self): - if not any(output.is_linked for output in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") solid_s = self.inputs['Solid'].sv_get() if self.criteria_type in {'SOLID_DISTANCE', 'SOLID_INSIDE'}: + if not (self.inputs["Tool"].is_linked): + raise Exception(f"Input socket '{self.inputs['Tool'].label or self.inputs['Tool'].identifier}' has to be connected") tool_s = self.inputs['Tool'].sv_get() tool_s = ensure_nesting_level(tool_s, 2, data_types=(Part.Shape,)) else: diff --git a/nodes/solid/solid_to_mesh_mk2.py b/nodes/solid/solid_to_mesh_mk2.py index 3ce588241e..9126ae0bf2 100644 --- a/nodes/solid/solid_to_mesh_mk2.py +++ b/nodes/solid/solid_to_mesh_mk2.py @@ -251,6 +251,8 @@ def lenient_mesher(self): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs[self['shape_type']].is_linked): + raise Exception(f"Input socket '{self.inputs[self['shape_type']].label or self.inputs[self['shape_type']].identifier}' has to be connected") if self.mode == 'Basic': verts, faces = self.basic_mesher() diff --git a/nodes/solid/solid_vertices.py b/nodes/solid/solid_vertices.py index 0a0e8e2330..f686a4311c 100644 --- a/nodes/solid/solid_vertices.py +++ b/nodes/solid/solid_vertices.py @@ -21,6 +21,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") solids = self.inputs[0].sv_get() diff --git a/nodes/solid/solid_volume.py b/nodes/solid/solid_volume.py index a33149cf34..ed77b0f099 100644 --- a/nodes/solid/solid_volume.py +++ b/nodes/solid/solid_volume.py @@ -33,6 +33,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") solids_in = self.inputs['Solid'].sv_get() diff --git a/nodes/solid/solidify_face.py b/nodes/solid/solidify_face.py index 8ddb8103e6..530c5d18ef 100644 --- a/nodes/solid/solidify_face.py +++ b/nodes/solid/solidify_face.py @@ -63,6 +63,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["SolidFace"].is_linked): + raise Exception(f"Input socket '{self.inputs['SolidFace'].label or self.inputs['SolidFace'].identifier}' has to be connected") face_surfaces_s = self.inputs['SolidFace'].sv_get() face_surfaces_s = ensure_nesting_level(face_surfaces_s, 2, data_types=(SvSurface,)) diff --git a/nodes/solid/split_solid.py b/nodes/solid/split_solid.py index 74725d77d3..6cd2950561 100644 --- a/nodes/solid/split_solid.py +++ b/nodes/solid/split_solid.py @@ -55,6 +55,10 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") + if not (self.inputs["SolidFace"].is_linked): + raise Exception(f"Input socket '{self.inputs['SolidFace'].label or self.inputs['SolidFace'].identifier}' has to be connected") face_surfaces_s = self.inputs['SolidFace'].sv_get() face_surfaces_s = ensure_nesting_level(face_surfaces_s, 3, data_types=(SvSurface,)) diff --git a/nodes/solid/sweep_face.py b/nodes/solid/sweep_face.py index 9423883e06..6a05aa8d5e 100644 --- a/nodes/solid/sweep_face.py +++ b/nodes/solid/sweep_face.py @@ -82,6 +82,10 @@ def make_solid(self, face, path): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Profile"].is_linked): + raise Exception(f"Input socket '{self.inputs['Profile'].label or self.inputs['Profile'].identifier}' has to be connected") + if not (self.inputs["Path"].is_linked): + raise Exception(f"Input socket '{self.inputs['Path'].label or self.inputs['Path'].identifier}' has to be connected") face_surface_s = self.inputs['Profile'].sv_get() face_surface_s = ensure_nesting_level(face_surface_s, 2, data_types=(SvSurface,)) diff --git a/nodes/solid/transform_solid.py b/nodes/solid/transform_solid.py index ff4955c4b2..37b0c2ee7a 100644 --- a/nodes/solid/transform_solid.py +++ b/nodes/solid/transform_solid.py @@ -32,6 +32,10 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") + if not (self.inputs["Matrix"].is_linked): + raise Exception(f"Input socket '{self.inputs['Matrix'].label or self.inputs['Matrix'].identifier}' has to be connected") solids_in = self.inputs[0].sv_get() matrixes = self.inputs[1].sv_get() diff --git a/nodes/solid/wire_face.py b/nodes/solid/wire_face.py index b10aaf7c4d..3bcfe4fd66 100644 --- a/nodes/solid/wire_face.py +++ b/nodes/solid/wire_face.py @@ -63,6 +63,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Edges"].is_linked): + raise Exception(f"Input socket '{self.inputs['Edges'].label or self.inputs['Edges'].identifier}' has to be connected") tolerance = 10 ** (-self.accuracy) From ba6a775592b9ef1da99658bc09f9f5d8019d12c5 Mon Sep 17 00:00:00 2001 From: satabol Date: Sun, 31 Mar 2024 23:28:27 +0300 Subject: [PATCH 3/4] - - Add check if output sockets are connected before execute nodes (Spacial). --- nodes/spatial/concave_hull.py | 2 ++ nodes/spatial/convex_hull_mk2.py | 28 +++++++++++++----------- nodes/spatial/delaunay_2d.py | 7 +++--- nodes/spatial/delaunay_2d_cdt.py | 4 +++- nodes/spatial/delaunay_3d_mk2.py | 2 ++ nodes/spatial/field_random_probe.py | 6 +++++ nodes/spatial/homogenous_vector_field.py | 3 ++- nodes/spatial/lloyd2d.py | 5 +++-- nodes/spatial/lloyd3d.py | 3 ++- nodes/spatial/lloyd_on_mesh.py | 7 +++++- nodes/spatial/lloyd_on_sphere.py | 3 ++- nodes/spatial/lloyd_solid.py | 7 ++++-- nodes/spatial/lloyd_solid_face.py | 5 ++++- nodes/spatial/populate_solid.py | 4 ++++ nodes/spatial/populate_surface.py | 4 ++++ nodes/spatial/random_points_on_mesh.py | 9 +++++++- nodes/spatial/voronoi3d.py | 2 ++ nodes/spatial/voronoi_2d.py | 10 ++++----- nodes/spatial/voronoi_on_mesh_mk2.py | 9 ++++++-- nodes/spatial/voronoi_on_solid_mk2.py | 6 ++++- nodes/spatial/voronoi_on_surface.py | 5 ++++- nodes/spatial/voronoi_sphere.py | 2 ++ 22 files changed, 95 insertions(+), 38 deletions(-) diff --git a/nodes/spatial/concave_hull.py b/nodes/spatial/concave_hull.py index bec14d02c4..13118df964 100644 --- a/nodes/spatial/concave_hull.py +++ b/nodes/spatial/concave_hull.py @@ -58,6 +58,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") vertices_s = self.inputs['Vertices'].sv_get() alpha_s = self.inputs['Alpha'].sv_get() diff --git a/nodes/spatial/convex_hull_mk2.py b/nodes/spatial/convex_hull_mk2.py index 801dd9fe6a..c5cd1b8a3d 100644 --- a/nodes/spatial/convex_hull_mk2.py +++ b/nodes/spatial/convex_hull_mk2.py @@ -137,23 +137,25 @@ def draw_buttons(self, context, layout): frow2.prop(self, 'sort_edges', text='Topo Sort', toggle=True) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") - if self.inputs['Vertices'].is_linked: + verts = self.inputs['Vertices'].sv_get() + verts_out = [] + polys_out = [] - verts = self.inputs['Vertices'].sv_get() - verts_out = [] - polys_out = [] + for v_obj in verts: + res = make_hull(v_obj, self) + if not res: + return - for v_obj in verts: - res = make_hull(v_obj, self) - if not res: - return + verts_out.append(res[0]) + polys_out.append(res[1]) - verts_out.append(res[0]) - polys_out.append(res[1]) - - self.outputs['Vertices'].sv_set(verts_out) - self.outputs['Polygons'].sv_set(polys_out) + self.outputs['Vertices'].sv_set(verts_out) + self.outputs['Polygons'].sv_set(polys_out) def register(): diff --git a/nodes/spatial/delaunay_2d.py b/nodes/spatial/delaunay_2d.py index 8843831bb7..75fd4a3a60 100644 --- a/nodes/spatial/delaunay_2d.py +++ b/nodes/spatial/delaunay_2d.py @@ -36,11 +36,10 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Polygons") def process(self): - - if not self.inputs['Vertices'].is_linked: - return - if not self.outputs['Polygons'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") tris_out = [] points_in = [] diff --git a/nodes/spatial/delaunay_2d_cdt.py b/nodes/spatial/delaunay_2d_cdt.py index 61fbfa7acb..40f5c379a1 100644 --- a/nodes/spatial/delaunay_2d_cdt.py +++ b/nodes/spatial/delaunay_2d_cdt.py @@ -86,8 +86,10 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Face data") def process(self): - if not self.inputs['Verts'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") out = [] for v, e, f, fd in zip(self.inputs['Verts'].sv_get(), diff --git a/nodes/spatial/delaunay_3d_mk2.py b/nodes/spatial/delaunay_3d_mk2.py index 7d945b9c97..9206b8e949 100644 --- a/nodes/spatial/delaunay_3d_mk2.py +++ b/nodes/spatial/delaunay_3d_mk2.py @@ -300,6 +300,8 @@ def is_too_long(self, verts, idxs, threshold): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") vertices_s = self.inputs['Vertices'].sv_get() volume_threshold_s = self.inputs['PlanarThreshold'].sv_get() diff --git a/nodes/spatial/field_random_probe.py b/nodes/spatial/field_random_probe.py index 37adc09147..0b161f4f31 100644 --- a/nodes/spatial/field_random_probe.py +++ b/nodes/spatial/field_random_probe.py @@ -139,12 +139,18 @@ def get_bounds(self, vertices): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Field"].is_linked): + raise Exception(f"Input socket '{self.inputs['Field'].label or self.inputs['Field'].identifier}' has to be connected") + if not (self.inputs["Bounds"].is_linked): + raise Exception(f"Input socket '{self.inputs['Bounds'].label or self.inputs['Bounds'].identifier}' has to be connected") if self.proportional and not self.inputs['Field'].is_linked: raise SvNoDataError(socket=self.inputs['Field'], node=self) fields_s = self.inputs['Field'].sv_get(default=[[None]]) if self.distance_mode == 'FIELD': + if not (self.inputs["RadiusField"].is_linked): + raise Exception(f"Input socket '{self.inputs['RadiusField'].label or self.inputs['RadiusField'].identifier}' has to be connected") radius_s = self.inputs['RadiusField'].sv_get() else: radius_s = [[None]] diff --git a/nodes/spatial/homogenous_vector_field.py b/nodes/spatial/homogenous_vector_field.py index e7c9a474b0..a81e5ec377 100644 --- a/nodes/spatial/homogenous_vector_field.py +++ b/nodes/spatial/homogenous_vector_field.py @@ -140,8 +140,9 @@ def rclick_menu(self, context, layout): layout.prop(self, "output_numpy", toggle=True) def process(self): - if not self.outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + params = match_long_repeat([s.sv_get(deepcopy=False)[0] for s in self.inputs]) get_faces = 'faces' in self.outputs and self.outputs['faces'].is_linked get_edges = 'edges' in self.outputs and self.outputs['edges'].is_linked diff --git a/nodes/spatial/lloyd2d.py b/nodes/spatial/lloyd2d.py index 1b0e1be6b8..d6cf3f6948 100644 --- a/nodes/spatial/lloyd2d.py +++ b/nodes/spatial/lloyd2d.py @@ -61,9 +61,10 @@ def draw_buttons_ext(self, context, layout): layout.prop(self, "clip", text="Clipping") def process(self): - - if not self.outputs['Vertices'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") verts_in = self.inputs['Vertices'].sv_get() iterations_in = self.inputs['Iterations'].sv_get() diff --git a/nodes/spatial/lloyd3d.py b/nodes/spatial/lloyd3d.py index f0792c77bc..774400a76e 100644 --- a/nodes/spatial/lloyd3d.py +++ b/nodes/spatial/lloyd3d.py @@ -63,9 +63,10 @@ def draw_buttons(self, context, layout): layout.prop(self, "bounds_mode", text='') def process(self): - if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Sites"].is_linked): + raise Exception(f"Input socket '{self.inputs['Sites'].label or self.inputs['Sites'].identifier}' has to be connected") sites_in = self.inputs['Sites'].sv_get() clipping_in = self.inputs['Clipping'].sv_get() diff --git a/nodes/spatial/lloyd_on_mesh.py b/nodes/spatial/lloyd_on_mesh.py index 798f9db390..41a9be26c3 100644 --- a/nodes/spatial/lloyd_on_mesh.py +++ b/nodes/spatial/lloyd_on_mesh.py @@ -63,9 +63,14 @@ def sv_init(self, context): self.outputs.new('SvVerticesSocket', "Sites") def process(self): - if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + if not (self.inputs["Faces"].is_linked): + raise Exception(f"Input socket '{self.inputs['Faces'].label or self.inputs['Faces'].identifier}' has to be connected") + if not (self.inputs["Sites"].is_linked): + raise Exception(f"Input socket '{self.inputs['Sites'].label or self.inputs['Sites'].identifier}' has to be connected") verts_in = self.inputs['Vertices'].sv_get() faces_in = self.inputs['Faces'].sv_get() diff --git a/nodes/spatial/lloyd_on_sphere.py b/nodes/spatial/lloyd_on_sphere.py index a8b734e07f..fcde0bd9b1 100644 --- a/nodes/spatial/lloyd_on_sphere.py +++ b/nodes/spatial/lloyd_on_sphere.py @@ -46,9 +46,10 @@ def sv_init(self, context): self.outputs.new('SvVerticesSocket', "Sites") def process(self): - if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Sites"].is_linked): + raise Exception(f"Input socket '{self.inputs['Sites'].label or self.inputs['Sites'].identifier}' has to be connected") center_in = self.inputs['Center'].sv_get() radius_in = self.inputs['Radius'].sv_get() diff --git a/nodes/spatial/lloyd_solid.py b/nodes/spatial/lloyd_solid.py index 89e683ed30..9ba37a6abe 100644 --- a/nodes/spatial/lloyd_solid.py +++ b/nodes/spatial/lloyd_solid.py @@ -83,10 +83,13 @@ def sv_init(self, context): self.update_sockets(context) def process(self): - if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") + if not (self.inputs["Sites"].is_linked): + raise Exception(f"Input socket '{self.inputs['Sites'].label or self.inputs['Sites'].identifier}' has to be connected") + solid_in = self.inputs['Solid'].sv_get() sites_in = self.inputs['Sites'].sv_get() iterations_in = self.inputs['Iterations'].sv_get() diff --git a/nodes/spatial/lloyd_solid_face.py b/nodes/spatial/lloyd_solid_face.py index 1e603eccd4..27af248467 100644 --- a/nodes/spatial/lloyd_solid_face.py +++ b/nodes/spatial/lloyd_solid_face.py @@ -51,9 +51,12 @@ def sv_init(self, context): self.outputs.new('SvVerticesSocket', "UVPoints") def process(self): - if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["SolidFace"].is_linked): + raise Exception(f"Input socket '{self.inputs['SolidFace'].label or self.inputs['SolidFace'].identifier}' has to be connected") + if not (self.inputs["Sites"].is_linked): + raise Exception(f"Input socket '{self.inputs['Sites'].label or self.inputs['Sites'].identifier}' has to be connected") surface_in = self.inputs['SolidFace'].sv_get() sites_in = self.inputs['Sites'].sv_get() diff --git a/nodes/spatial/populate_solid.py b/nodes/spatial/populate_solid.py index 90b9c4be36..9444c74cc5 100644 --- a/nodes/spatial/populate_solid.py +++ b/nodes/spatial/populate_solid.py @@ -218,6 +218,8 @@ def check(uv, vert): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") if self.proportional and not self.inputs['Field'].is_linked: raise SvNoDataError(socket=self.inputs['Field'], node=self) @@ -232,6 +234,8 @@ def process(self): mask_s = self.inputs['FaceMask'].sv_get(default=[[[True]]]) seed_s = self.inputs['Seed'].sv_get() if self.distance_mode == 'FIELD': + if not (self.inputs["RadiusField"].is_linked): + raise Exception(f"Input socket '{self.inputs['RadiusField'].label or self.inputs['RadiusField'].identifier}' has to be connected") radius_s = self.inputs['RadiusField'].sv_get() else: radius_s = [[None]] diff --git a/nodes/spatial/populate_surface.py b/nodes/spatial/populate_surface.py index c9d8d27471..2c1496501f 100644 --- a/nodes/spatial/populate_surface.py +++ b/nodes/spatial/populate_surface.py @@ -113,6 +113,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") if self.proportional and not self.inputs['Field'].is_linked: raise SvNoDataError(socket=self.inputs['Field'], node=self) @@ -125,6 +127,8 @@ def process(self): field_max_s = self.inputs['FieldMax'].sv_get() min_r_s = self.inputs['MinDistance'].sv_get() if self.distance_mode == 'FIELD': + if not (self.inputs["RadiusField"].is_linked): + raise Exception(f"Input socket '{self.inputs['RadiusField'].label or self.inputs['RadiusField'].identifier}' has to be connected") radius_s = self.inputs['RadiusField'].sv_get() else: radius_s = [[None]] diff --git a/nodes/spatial/random_points_on_mesh.py b/nodes/spatial/random_points_on_mesh.py index cd6c03b894..2f76b34732 100644 --- a/nodes/spatial/random_points_on_mesh.py +++ b/nodes/spatial/random_points_on_mesh.py @@ -442,8 +442,15 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'Face index') def process(self): - if not all([self.inputs['Verts'].is_linked, self.inputs['Faces'].is_linked]): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") + if not (self.inputs["Faces"].is_linked): + raise Exception(f"Input socket '{self.inputs['Faces'].label or self.inputs['Faces'].identifier}' has to be connected") + + # if not all([self.inputs['Verts'].is_linked, self.inputs['Faces'].is_linked]): + # return props = NodeProperties(self.proportional, self.mode, diff --git a/nodes/spatial/voronoi3d.py b/nodes/spatial/voronoi3d.py index 7e51025f12..97c01f7002 100644 --- a/nodes/spatial/voronoi3d.py +++ b/nodes/spatial/voronoi3d.py @@ -200,6 +200,8 @@ def clip_mesh(self, bounds, vertices, edges, faces, fill=False, iterate=None): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") vertices_s = self.inputs['Vertices'].sv_get() clipping_s = self.inputs['Clipping'].sv_get() diff --git a/nodes/spatial/voronoi_2d.py b/nodes/spatial/voronoi_2d.py index 3db20b0476..ccc631065d 100644 --- a/nodes/spatial/voronoi_2d.py +++ b/nodes/spatial/voronoi_2d.py @@ -111,13 +111,11 @@ def draw_buttons_ext(self, context, layout): layout.prop(self, 'ordered_faces') def process(self): - - if not self.inputs['Vertices'].is_linked: - return - - if not self.outputs['Vertices'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + points_in = self.inputs['Vertices'].sv_get() if 'MaxSides' in self.inputs: max_sides_in = self.inputs['MaxSides'].sv_get() diff --git a/nodes/spatial/voronoi_on_mesh_mk2.py b/nodes/spatial/voronoi_on_mesh_mk2.py index 384d8f29db..7bc8a62a11 100644 --- a/nodes/spatial/voronoi_on_mesh_mk2.py +++ b/nodes/spatial/voronoi_on_mesh_mk2.py @@ -112,10 +112,15 @@ def draw_buttons_ext(self, context, layout): layout.prop(self, 'accuracy') def process(self): - if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + if not (self.inputs["Faces"].is_linked): + raise Exception(f"Input socket '{self.inputs['Faces'].label or self.inputs['Faces'].identifier}' has to be connected") + if not (self.inputs["Sites"].is_linked): + raise Exception(f"Input socket '{self.inputs['Sites'].label or self.inputs['Sites'].identifier}' has to be connected") + verts_in = self.inputs['Vertices'].sv_get(deepcopy=False) faces_in = self.inputs['Faces'].sv_get(deepcopy=False) sites_in = self.inputs['Sites'].sv_get(deepcopy=False) diff --git a/nodes/spatial/voronoi_on_solid_mk2.py b/nodes/spatial/voronoi_on_solid_mk2.py index a355150c08..7acc5768ec 100644 --- a/nodes/spatial/voronoi_on_solid_mk2.py +++ b/nodes/spatial/voronoi_on_solid_mk2.py @@ -88,9 +88,13 @@ def draw_buttons_ext(self, context, layout): layout.prop(self, 'accuracy') def process(self): - if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Solid"].is_linked): + raise Exception(f"Input socket '{self.inputs['Solid'].label or self.inputs['Solid'].identifier}' has to be connected") + if not (self.inputs["Sites"].is_linked): + raise Exception(f"Input socket '{self.inputs['Sites'].label or self.inputs['Sites'].identifier}' has to be connected") + solid_in = self.inputs['Solid'].sv_get() sites_in = self.inputs['Sites'].sv_get() diff --git a/nodes/spatial/voronoi_on_surface.py b/nodes/spatial/voronoi_on_surface.py index 50523702b0..c01d1f28bb 100644 --- a/nodes/spatial/voronoi_on_surface.py +++ b/nodes/spatial/voronoi_on_surface.py @@ -184,9 +184,12 @@ def invert_points(pts): return uv_verts, verts, edges, faces def process(self): - if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Surface"].is_linked): + raise Exception(f"Input socket '{self.inputs['Surface'].label or self.inputs['Surface'].identifier}' has to be connected") + if not (self.inputs["UVPoints"].is_linked): + raise Exception(f"Input socket '{self.inputs['UVPoints'].label or self.inputs['UVPoints'].identifier}' has to be connected") surface_in = self.inputs['Surface'].sv_get() uvpoints_in = self.inputs['UVPoints'].sv_get() diff --git a/nodes/spatial/voronoi_sphere.py b/nodes/spatial/voronoi_sphere.py index 8a2c503204..baf4efa901 100644 --- a/nodes/spatial/voronoi_sphere.py +++ b/nodes/spatial/voronoi_sphere.py @@ -42,6 +42,8 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") vertices_s = self.inputs['Vertices'].sv_get() radius_s = self.inputs['Radius'].sv_get() From 33ea7c26b76384acd2067dd26d0444dc7586ccf0 Mon Sep 17 00:00:00 2001 From: satabol Date: Tue, 2 Apr 2024 01:58:19 +0300 Subject: [PATCH 4/4] - Add check if output sockets are connected before execute nodes (CAD, Analyzer, Color, Curve, field, generator, lists, matrix, modifier_change, modifier_make, Number, Pulga, Surface, svg, transforms, vector). --- nodes/CAD/edges_to_faces_2d.py | 1 + nodes/CAD/embed mesh.py | 1 + nodes/CAD/merge_mesh_2d.py | 1 + nodes/CAD/merge_mesh_2d_lite.py | 1 + nodes/analyzer/bbox_aligned.py | 7 +- nodes/analyzer/bvh_overlap_polys.py | 3 + nodes/analyzer/chess_selection.py | 9 +- nodes/analyzer/deformation.py | 3 + nodes/analyzer/diameter.py | 6 +- nodes/analyzer/distance_line_line.py | 10 +- nodes/analyzer/distance_point_line.py | 10 +- nodes/analyzer/distance_point_plane.py | 9 +- nodes/analyzer/distance_pp.py | 1 + nodes/analyzer/edge_angles.py | 9 +- nodes/analyzer/intersect_circle_circle.py | 4 +- nodes/analyzer/intersect_line_sphere.py | 7 +- nodes/analyzer/intersect_plane_plane.py | 5 +- nodes/analyzer/kd_tree_MK2.py | 7 +- nodes/analyzer/kd_tree_edges.py | 7 +- nodes/analyzer/kd_tree_path.py | 8 +- nodes/analyzer/linear_approx.py | 2 + nodes/analyzer/linked_verts.py | 12 ++ nodes/analyzer/mesh_filter.py | 1 - nodes/analyzer/origins.py | 15 +- nodes/analyzer/points_inside_mesh.py | 9 +- nodes/analyzer/project_point_to_line.py | 8 +- nodes/analyzer/raycaster_lite.py | 5 +- nodes/analyzer/volume.py | 5 + nodes/color/color_in_mk1.py | 2 +- nodes/color/color_input.py | 1 + nodes/color/color_mix.py | 16 +- nodes/color/color_out_mk1.py | 1 + nodes/color/formula_color.py | 25 +-- nodes/color/texture_evaluate_mk2.py | 8 +- nodes/curve/bezier_spline.py | 1 + nodes/curve/catmull_rom.py | 2 +- nodes/curve/cubic_spline.py | 2 +- nodes/curve/length_parameter.py | 3 +- nodes/curve/length_rebuild.py | 3 +- nodes/dictionary/dictionary_in.py | 3 +- nodes/exchange/FCStd_read.py | 2 +- nodes/exchange/FCStd_read_mod.py | 2 +- nodes/exchange/approx_subd_to_nurbs.py | 1 + nodes/field/mesh_surface_field.py | 1 - nodes/field/minimal_sfield.py | 1 - nodes/field/minimal_vfield.py | 1 - nodes/field/voronoi_field.py | 1 - nodes/generator/basic_3pt_arc.py | 5 +- nodes/generator/basic_spline.py | 1 + nodes/generator/circle.py | 1 + nodes/generator/formula_shape.py | 1 + nodes/generator/ngon.py | 1 + nodes/generator/plane_mk3.py | 1 + nodes/generator/random_vector_mk3.py | 1 + nodes/generator/segment.py | 1 + nodes/generator/sphere.py | 1 + nodes/generators_extended/box_rounded.py | 1 + nodes/generators_extended/ellipse_mk3.py | 1 + nodes/generators_extended/hilbert.py | 1 + nodes/generators_extended/hilbert3d.py | 1 + nodes/generators_extended/hilbert_image.py | 1 + nodes/generators_extended/pentagon_tiler.py | 1 + nodes/generators_extended/spiral_mk2.py | 1 + nodes/generators_extended/torus_knot_mk2.py | 1 + nodes/generators_extended/wfc_texture.py | 1 + nodes/layout/converter.py | 1 + nodes/list_main/decompose.py | 1 + nodes/list_main/delete_levels.py | 8 +- nodes/list_main/func.py | 17 +- nodes/list_main/index.py | 1 + nodes/list_main/length.py | 1 + nodes/list_main/match.py | 1 + nodes/list_main/statistics.py | 1 + nodes/list_main/sum_mk2.py | 1 + nodes/list_masks/index_to_mask.py | 1 + nodes/list_masks/mask.py | 1 + nodes/list_masks/mask_join.py | 12 +- nodes/list_masks/mask_to_index.py | 3 +- nodes/list_mutators/filter_empty_lists.py | 1 + nodes/list_struct/item_insert.py | 1 + nodes/list_struct/levels.py | 1 + nodes/list_struct/numpy_array.py | 1 + nodes/list_struct/repeater.py | 1 + nodes/logic/custom_switcher.py | 1 + nodes/matrix/apply_and_join.py | 1 + nodes/matrix/euler.py | 1 + nodes/matrix/input.py | 3 + nodes/matrix/interpolation.py | 1 + nodes/matrix/matrix_deform.py | 1 + nodes/matrix/matrix_math.py | 1 + nodes/matrix/matrix_track_to.py | 1 + nodes/matrix/shear.py | 1 + nodes/modifier_change/bevel.py | 13 +- nodes/modifier_change/delete_loose.py | 8 +- .../modifier_change/dissolve_mesh_elements.py | 5 + nodes/modifier_change/edge_boom.py | 4 +- nodes/modifier_change/edge_split.py | 5 + nodes/modifier_change/edgenet_to_paths.py | 3 +- nodes/modifier_change/extrude_multi_alt.py | 6 +- nodes/modifier_change/extrude_region.py | 5 +- nodes/modifier_change/extrude_separate.py | 14 +- .../modifier_change/extrude_separate_lite.py | 5 +- nodes/modifier_change/flat_geometry.py | 26 +-- nodes/modifier_change/flip_normals.py | 7 +- nodes/modifier_change/follow_active_quads.py | 8 +- nodes/modifier_change/holes_fill.py | 9 +- nodes/modifier_change/inset_faces.py | 7 +- nodes/modifier_change/limited_dissolve.py | 4 +- nodes/modifier_change/limited_dissolve_mk2.py | 3 + nodes/modifier_change/make_monotone.py | 3 + nodes/modifier_change/merge_by_distance.py | 6 +- nodes/modifier_change/mesh_beautify.py | 3 +- nodes/modifier_change/mesh_separate.py | 3 +- nodes/modifier_change/objects_along_edge.py | 19 +- nodes/modifier_change/offset.py | 5 +- nodes/modifier_change/opensubdivision.py | 7 + .../planar_edgenet_to_polygons.py | 10 +- nodes/modifier_change/polygons_boom.py | 3 + .../modifier_change/polygons_to_edges_mk2.py | 2 +- nodes/modifier_change/recalc_normals.py | 8 +- nodes/modifier_change/rigid_origami.py | 8 +- .../separate_parts_to_indexes.py | 6 +- nodes/modifier_change/split_mesh_elements.py | 3 + nodes/modifier_change/subdivide_mk2.py | 3 + nodes/modifier_change/triangulate.py | 10 +- nodes/modifier_change/vertices_mask.py | 74 +++---- nodes/modifier_make/bevel_curve.py | 2 +- nodes/modifier_make/clip_verts.py | 2 +- nodes/modifier_make/contour2D.py | 8 +- nodes/modifier_make/csg_booleanMK2.py | 3 + nodes/modifier_make/dual_mesh.py | 2 +- nodes/modifier_make/edges_adaptative.py | 2 +- nodes/modifier_make/fractal_curve.py | 2 +- nodes/modifier_make/framework.py | 2 +- nodes/modifier_make/join_tris.py | 6 +- nodes/modifier_make/lathe.py | 9 +- nodes/modifier_make/matrix_tube.py | 3 +- nodes/modifier_make/offset_line.py | 10 +- nodes/modifier_make/pipe_tubes.py | 37 ++-- nodes/modifier_make/solidify_mk2.py | 9 +- nodes/modifier_make/sweep_modulator.py | 3 + nodes/modifier_make/unsubdivide.py | 7 + nodes/modifier_make/uv_connect.py | 44 +++-- nodes/modifier_make/wafel.py | 4 +- nodes/modifier_make/wireframe.py | 10 +- nodes/network/file_path.py | 1 + nodes/number/curve_mapper.py | 1 + nodes/number/exponential.py | 1 + nodes/number/fibonacci.py | 1 + nodes/number/number_range.py | 1 + nodes/number/oscillator.py | 23 ++- nodes/number/random_num_gen.py | 1 + nodes/number/range_map.py | 1 + nodes/object_nodes/armature_analyzer.py | 1 + nodes/pulga_physics/pulga_angle_force.py | 1 + nodes/pulga_physics/pulga_attraction_force.py | 1 + nodes/scene/FCurve_in.py | 1 + nodes/surface/apply_field_to_surface.py | 2 +- nodes/surface/minimal_surface.py | 1 - nodes/surface/nurbs_surface.py | 3 + nodes/svg/circle_svg.py | 4 +- nodes/svg/dimensions_svg_mk2.py | 4 +- nodes/svg/fill_stroke_mk2.py | 4 +- nodes/svg/group_svg.py | 4 +- nodes/svg/mesh_svg.py | 3 +- nodes/svg/path_svg_mk2.py | 4 +- nodes/svg/pattern_svg.py | 3 +- nodes/svg/text_svg.py | 4 +- nodes/text/datetime_strings.py | 4 +- nodes/text/shape.py | 5 + nodes/text/string_tools.py | 27 +-- nodes/transforms/align_mesh_by_mesh.py | 3 +- nodes/transforms/apply.py | 4 +- nodes/transforms/barycentric_transform.py | 5 +- nodes/transforms/bend_along_path.py | 2 - nodes/transforms/bend_along_surface.py | 2 - nodes/transforms/cast.py | 8 +- nodes/transforms/deform.py | 3 +- nodes/transforms/formula_deform_mk2.py | 25 +-- nodes/transforms/mirror_mk2.py | 6 +- nodes/transforms/move_mk3.py | 10 +- nodes/transforms/noise_displace.py | 9 +- nodes/transforms/randomize.py | 5 +- nodes/transforms/rotate_mk3.py | 9 +- nodes/transforms/scale_mk3.py | 10 +- nodes/transforms/symmetrize.py | 6 +- nodes/transforms/texture_displace_mk2.py | 9 +- nodes/transforms/transform_mesh.py | 4 +- nodes/transforms/transform_select.py | 3 +- nodes/vector/attractor.py | 2 + nodes/vector/axis_input_mk2.py | 6 +- nodes/vector/drop.py | 7 +- nodes/vector/fractal.py | 7 +- nodes/vector/interpolation_mk2.py | 60 +++--- nodes/vector/interpolation_stripes.py | 183 +++++++++--------- nodes/vector/lerp.py | 3 +- nodes/vector/math_mk3.py | 7 +- nodes/vector/noise_mk3.py | 9 +- nodes/vector/turbulence.py | 9 +- nodes/vector/variable_lacunarity.py | 9 +- nodes/vector/vector_in.py | 3 +- nodes/vector/vector_out.py | 36 ++-- nodes/vector/vector_polar_in.py | 3 +- nodes/vector/vector_rewire.py | 5 + nodes/vector/vertices_delete_doubles.py | 5 + nodes/vector/vertices_sort.py | 49 +++-- 206 files changed, 858 insertions(+), 573 deletions(-) diff --git a/nodes/CAD/edges_to_faces_2d.py b/nodes/CAD/edges_to_faces_2d.py index 02514134d3..9fd71ba34a 100644 --- a/nodes/CAD/edges_to_faces_2d.py +++ b/nodes/CAD/edges_to_faces_2d.py @@ -57,6 +57,7 @@ def process(self): return if not all([soc.is_linked for soc in self.inputs]): raise Exception("All input sockets has to be connected") + out = [] for vs, es in zip(self.inputs['Verts'].sv_get(), self.inputs['Edges'].sv_get()): out.append(edges_to_faces(vs, es, self.do_intersect, self.fill_holes, self.accuracy)) diff --git a/nodes/CAD/embed mesh.py b/nodes/CAD/embed mesh.py index 5883a275ab..e259dd0fad 100644 --- a/nodes/CAD/embed mesh.py +++ b/nodes/CAD/embed mesh.py @@ -211,6 +211,7 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + out = [] for V_A,E_A,F_A,V_B,E_B,F_B,I in zip( self.inputs['VertsA'].sv_get(default=[[]]), diff --git a/nodes/CAD/merge_mesh_2d.py b/nodes/CAD/merge_mesh_2d.py index f077cebe5a..66d91b0df2 100644 --- a/nodes/CAD/merge_mesh_2d.py +++ b/nodes/CAD/merge_mesh_2d.py @@ -69,6 +69,7 @@ def process(self): return if not all([sock.is_linked for sock in self.inputs]): raise Exception("All input sockets has to be connected") + out = [] for sv_verts_a, sv_faces_a, sv_verts_b, sv_faces_b in zip(self.inputs['Verts A'].sv_get(), self.inputs['Faces A'].sv_get(), diff --git a/nodes/CAD/merge_mesh_2d_lite.py b/nodes/CAD/merge_mesh_2d_lite.py index 0171af1f78..5ec41bb324 100644 --- a/nodes/CAD/merge_mesh_2d_lite.py +++ b/nodes/CAD/merge_mesh_2d_lite.py @@ -91,6 +91,7 @@ def process(self): return if not all([sock.is_linked for sock in self.inputs]): raise Exception("All input sockets has to be connected") + if self.alg_mode == "Blender" and not bl_merge_mesh: return out = [] diff --git a/nodes/analyzer/bbox_aligned.py b/nodes/analyzer/bbox_aligned.py index b6869a40be..320874bd8c 100644 --- a/nodes/analyzer/bbox_aligned.py +++ b/nodes/analyzer/bbox_aligned.py @@ -81,16 +81,17 @@ def sv_init(self, context): self.update_sockets(context) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + inputs = self.inputs - Vertices = inputs["Vertices"].sv_get(default=None) + Vertices = inputs["Vertices"].sv_get() Matrixes = inputs["Matrix"].sv_get(default=-1) if Matrixes==-1: Matrixes = [None] Factors = inputs["Factor"].sv_get() outputs = self.outputs - if not any( [o.is_linked for o in outputs]): - return lst_bba_vertices = [] lst_bba_edges = [] diff --git a/nodes/analyzer/bvh_overlap_polys.py b/nodes/analyzer/bvh_overlap_polys.py index 3b1dde7655..4c0274421a 100644 --- a/nodes/analyzer/bvh_overlap_polys.py +++ b/nodes/analyzer/bvh_overlap_polys.py @@ -54,6 +54,9 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'OverlapPoly(B)') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + btr = BVHTree.FromPolygons V1, P1, V2, P2 = [i.sv_get()[0] for i in self.inputs] outIndA, outIndB, Pover1, Pover2 = self.outputs diff --git a/nodes/analyzer/chess_selection.py b/nodes/analyzer/chess_selection.py index 3566980558..39f08ed4c9 100644 --- a/nodes/analyzer/chess_selection.py +++ b/nodes/analyzer/chess_selection.py @@ -64,10 +64,13 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Face mask") def process(self): - if not any(sock.is_linked for sock in self.outputs): - return - if not all([sock.is_linked for sock in self.inputs]): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") + if not (self.inputs["Faces"].is_linked): + raise Exception(f"Input socket '{self.inputs['Faces'].label or self.inputs['Faces'].identifier}' has to be connected") + out = [] for v, f in zip(self.inputs['Verts'].sv_get(), self.inputs['Faces'].sv_get()): out.append(get_selection(v, f)) diff --git a/nodes/analyzer/deformation.py b/nodes/analyzer/deformation.py index f44ada6560..e5d3058d59 100644 --- a/nodes/analyzer/deformation.py +++ b/nodes/analyzer/deformation.py @@ -217,6 +217,9 @@ def ready(self): return ready def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + '''main node function called every update''' so = self.outputs if not self.ready(): diff --git a/nodes/analyzer/diameter.py b/nodes/analyzer/diameter.py index 92f472c2dd..414c1bc69a 100644 --- a/nodes/analyzer/diameter.py +++ b/nodes/analyzer/diameter.py @@ -40,10 +40,10 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'Diameter') def process(self): - if not self.inputs['Vertices'].is_linked: - return - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") any_direction = not self.inputs['Direction'].is_linked diff --git a/nodes/analyzer/distance_line_line.py b/nodes/analyzer/distance_line_line.py index 2c2484fc47..f181685d30 100644 --- a/nodes/analyzer/distance_line_line.py +++ b/nodes/analyzer/distance_line_line.py @@ -77,12 +77,16 @@ def get_data(self): return list_match_func[self.list_match_global]([s.sv_get(default=[[]], deepcopy=False) for s in si]) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Verts Line A"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts Line A'].label or self.inputs['Verts Line A'].identifier}' has to be connected") + if not (self.inputs["Verts Line B"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts Line B'].label or self.inputs['Verts Line B'].identifier}' has to be connected") + '''main node function called every update''' so = self.outputs si = self.inputs - if not (any(s.is_linked for s in so) and all(s.is_linked for s in si)): - return - result = [[] for socket in so] gates = [socket.is_linked for socket in so] diff --git a/nodes/analyzer/distance_point_line.py b/nodes/analyzer/distance_point_line.py index 2cd0dfee18..b1c356c847 100644 --- a/nodes/analyzer/distance_point_line.py +++ b/nodes/analyzer/distance_point_line.py @@ -168,12 +168,16 @@ def get_data(self): return list_match_func[self.list_match_global]([s.sv_get(default=[[]], deepcopy=False) for s in si]) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + if not (self.inputs["Verts Line"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts Line'].label or self.inputs['Verts Line'].identifier}' has to be connected") + '''main node function called every update''' so = self.outputs si = self.inputs - if not (any(s.is_linked for s in so) and all(s.is_linked for s in si[:2])): - return - result = [[] for socket in so] gates = [socket.is_linked for socket in so] diff --git a/nodes/analyzer/distance_point_plane.py b/nodes/analyzer/distance_point_plane.py index 9527b9489c..725861fbc0 100644 --- a/nodes/analyzer/distance_point_plane.py +++ b/nodes/analyzer/distance_point_plane.py @@ -201,11 +201,16 @@ def get_data(self): return list_match_func[self.list_match_global]([sckt.sv_get(default=[[]], deepcopy=False) for sckt in si]) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") + if not (self.inputs["Verts Plane"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts Plane'].label or self.inputs['Verts Plane'].identifier}' has to be connected") + '''main node function called every update''' so = self.outputs si = self.inputs - if not (any(s.is_linked for s in so) and all(s.is_linked for s in si[:2])): - return result = [[] for socket in so] gates = [socket.is_linked for socket in so] diff --git a/nodes/analyzer/distance_pp.py b/nodes/analyzer/distance_pp.py index 6588d77769..5e736d07cf 100644 --- a/nodes/analyzer/distance_pp.py +++ b/nodes/analyzer/distance_pp.py @@ -76,6 +76,7 @@ def rclick_menu(self, context, layout): def process(self): if not self.outputs['distances'].is_linked: return + inputs = self.inputs if inputs['vertices1'].is_linked and inputs['vertices2'].is_linked: prop1_ = self.inputs['vertices1'].sv_get() diff --git a/nodes/analyzer/edge_angles.py b/nodes/analyzer/edge_angles.py index ab0d8ae71d..9eab74f7e0 100644 --- a/nodes/analyzer/edge_angles.py +++ b/nodes/analyzer/edge_angles.py @@ -101,10 +101,13 @@ def is_degenerated(self, edge): return (edge.is_wire or edge.is_boundary) def process(self): - - if not self.outputs['Angles'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + if not (self.inputs["Edges"].is_linked or self.inputs["Polygons"].is_linked): + raise Exception(f"Input socket '{self.inputs['Edges'].label or self.inputs['Edges'].identifier}' or '{self.inputs['Polygons'].label or self.inputs['Polygons'].identifier}' has to be connected") + vertices_s = self.inputs['Vertices'].sv_get(default=[[]]) edges_s = self.inputs['Edges'].sv_get(default=[[]]) faces_s = self.inputs['Polygons'].sv_get(default=[[]]) diff --git a/nodes/analyzer/intersect_circle_circle.py b/nodes/analyzer/intersect_circle_circle.py index e6405b2ef8..711e6425e0 100644 --- a/nodes/analyzer/intersect_circle_circle.py +++ b/nodes/analyzer/intersect_circle_circle.py @@ -196,10 +196,10 @@ def get_data(self): return list_match_func[self.list_match_global]([s.sv_get(default=[[]]) for s in si]) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return '''main node function called every update''' so = self.outputs - if not any(s.is_linked for s in so): - return result = [[], [], []] gates = [] diff --git a/nodes/analyzer/intersect_line_sphere.py b/nodes/analyzer/intersect_line_sphere.py index 5b78aa7910..b86e53e647 100644 --- a/nodes/analyzer/intersect_line_sphere.py +++ b/nodes/analyzer/intersect_line_sphere.py @@ -210,11 +210,14 @@ def get_data(self): return list_match_func[self.list_match_global]([s.sv_get(default=[[]], deepcopy=False) for s in inputs]) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") + '''main node function called every update''' outputs = self.outputs inputs = self.inputs - if not (any(s.is_linked for s in outputs) and inputs[0].is_linked): - return result = [[] for socket in outputs] gates = [socket.is_linked for socket in outputs] diff --git a/nodes/analyzer/intersect_plane_plane.py b/nodes/analyzer/intersect_plane_plane.py index b037226153..b6ed049826 100644 --- a/nodes/analyzer/intersect_plane_plane.py +++ b/nodes/analyzer/intersect_plane_plane.py @@ -127,11 +127,12 @@ def get_data(self): def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + '''main node function called every update''' so = self.outputs si = self.inputs - if not (any(s.is_linked for s in so)): - return result = [[] for socket in so] gates = [socket.is_linked for socket in so] diff --git a/nodes/analyzer/kd_tree_MK2.py b/nodes/analyzer/kd_tree_MK2.py index bdf367e37e..8fe028edd5 100644 --- a/nodes/analyzer/kd_tree_MK2.py +++ b/nodes/analyzer/kd_tree_MK2.py @@ -79,11 +79,14 @@ def sv_init(self, context): so.new('SvStringsSocket', 'distance') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["insert"].is_linked): + raise Exception(f"Input socket '{self.inputs['insert'].label or self.inputs['insert'].identifier}' has to be connected") + '''main node function called every update''' si = self.inputs so = self.outputs - if not (any(s.is_linked for s in so) and si[0].is_linked): - return V1, V2, N, R = mlr([i.sv_get() for i in si]) out = [] Co, ind, dist = so diff --git a/nodes/analyzer/kd_tree_edges.py b/nodes/analyzer/kd_tree_edges.py index 0bbc90755d..9cc9806893 100644 --- a/nodes/analyzer/kd_tree_edges.py +++ b/nodes/analyzer/kd_tree_edges.py @@ -88,11 +88,14 @@ def process(self): raise DependencyError(f'Current mode="{self.mode}" requires scipy' f' library to be installed') + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") + inputs = self.inputs outputs = self.outputs - if not inputs['Verts'].is_linked or not outputs['Edges'].is_linked: - return params = [inputs['Verts'].sv_get(deepcopy=False)] match = list_match_func[self.list_match] diff --git a/nodes/analyzer/kd_tree_path.py b/nodes/analyzer/kd_tree_path.py index b029a16c43..5bf651fae2 100644 --- a/nodes/analyzer/kd_tree_path.py +++ b/nodes/analyzer/kd_tree_path.py @@ -95,13 +95,15 @@ def get_data(self): return list_match_func[self.list_match_global]([s.sv_get(default=[[]]) for s in si]) def process(self): - + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") + inputs = self.inputs outputs = self.outputs so = self.outputs si = self.inputs - if not so[0].is_linked: - return result = [] group = self.get_data() diff --git a/nodes/analyzer/linear_approx.py b/nodes/analyzer/linear_approx.py index 86fb8cac7d..bc2cb16fdd 100644 --- a/nodes/analyzer/linear_approx.py +++ b/nodes/analyzer/linear_approx.py @@ -70,6 +70,8 @@ def draw_buttons(self, context, layout): def process(self): if not any(output.is_linked for output in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") vertices_s = self.inputs['Vertices'].sv_get(default=[[]]) diff --git a/nodes/analyzer/linked_verts.py b/nodes/analyzer/linked_verts.py index 6e9bfd0eef..ae22c81e0c 100644 --- a/nodes/analyzer/linked_verts.py +++ b/nodes/analyzer/linked_verts.py @@ -141,6 +141,18 @@ def ready(self): return ready def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if self.outputs["Verts"].is_linked: + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") + if not (self.inputs["Edges"].is_linked): + raise Exception(f"Input socket '{self.inputs['Edges'].label or self.inputs['Edges'].identifier}' has to be connected") + + if self.outputs["Verts Id"].is_linked: + if not (self.inputs["Edges"].is_linked): + raise Exception(f"Input socket '{self.inputs['Edges'].label or self.inputs['Edges'].identifier}' has to be connected") + '''main node function called every update''' so = self.outputs si = self.inputs diff --git a/nodes/analyzer/mesh_filter.py b/nodes/analyzer/mesh_filter.py index 7cc63807ff..27b9bbd440 100644 --- a/nodes/analyzer/mesh_filter.py +++ b/nodes/analyzer/mesh_filter.py @@ -260,7 +260,6 @@ def sv_init(self, context): self.set_submode(context) def process(self): - if not any(output.is_linked for output in self.outputs): return diff --git a/nodes/analyzer/origins.py b/nodes/analyzer/origins.py index eb4593b361..1274650aac 100644 --- a/nodes/analyzer/origins.py +++ b/nodes/analyzer/origins.py @@ -134,12 +134,15 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return - if not self.inputs['Verts'].is_linked: - return - if self.mode == MODE.faces and not self.inputs['Faces'].is_linked: - return - if self.mode == MODE.edges and not any([self.inputs[n].is_linked for n in ['Edges', 'Faces']]): - return + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") + + if self.mode == MODE.faces: + if not self.inputs['Faces'].is_linked: + raise Exception(f"Input socket '{self.inputs['Faces'].label or self.inputs['Faces'].identifier}' has to be connected") + if self.mode == MODE.edges: + if not any([self.inputs[n].is_linked for n in ['Edges', 'Faces']]): + raise Exception(f"Input socket '{self.inputs['Edges'].label or self.inputs['Edges'].identifier}' or '{self.inputs['Faces'].label or self.inputs['Faces'].identifier}' has to be connected") out = [] for v, e, f in zip(*[sock.sv_get(deepcopy=False, default=iter_last([None])) for sock in self.inputs]): diff --git a/nodes/analyzer/points_inside_mesh.py b/nodes/analyzer/points_inside_mesh.py index f390ff7303..621a35e280 100644 --- a/nodes/analyzer/points_inside_mesh.py +++ b/nodes/analyzer/points_inside_mesh.py @@ -276,10 +276,13 @@ def get_data(self): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['verts'].label or self.inputs['verts'].identifier}' has to be connected") + if not (self.inputs["faces"].is_linked): + raise Exception(f"Input socket '{self.inputs['faces'].label or self.inputs['faces'].identifier}' has to be connected") + if not (self.inputs["points"].is_linked): + raise Exception(f"Input socket '{self.inputs['points'].label or self.inputs['points'].identifier}' has to be connected") - if not all(socket.is_linked for socket in self.inputs[:3]): - return - main_func, params = self.get_data() mask = [] diff --git a/nodes/analyzer/project_point_to_line.py b/nodes/analyzer/project_point_to_line.py index 79d4476819..90510ee7ef 100644 --- a/nodes/analyzer/project_point_to_line.py +++ b/nodes/analyzer/project_point_to_line.py @@ -374,9 +374,11 @@ def draw_buttons_ext(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return - if not (self.inputs['Vectors_lines'].is_linked and self.inputs['Project_points'].is_linked): - return - + if not (self.inputs["Vectors_lines"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vectors_lines'].label or self.inputs['Vectors_lines'].identifier}' has to be connected") + if not (self.inputs["Project_points"].is_linked): + raise Exception(f"Input socket '{self.inputs['Project_points'].label or self.inputs['Project_points'].identifier}' has to be connected") + v_lines = self.inputs['Vectors_lines'].sv_get() p_points = self.inputs['Project_points'].sv_get() if self.set_res: diff --git a/nodes/analyzer/raycaster_lite.py b/nodes/analyzer/raycaster_lite.py index d23e98f580..4fe0824fbb 100644 --- a/nodes/analyzer/raycaster_lite.py +++ b/nodes/analyzer/raycaster_lite.py @@ -78,10 +78,11 @@ def svmesh_to_bvh_lists(v, f, all_tris, epsilon, safe_check): yield bvh_tree_from_polygons(vertices, polygons, all_triangles=all_tris, epsilon=epsilon, safe_check=safe_check) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + L, N, I, D, S = self.outputs RL = [] - if not any([s.is_linked for s in self.outputs]): - return vert_in, face_in, start_in, direction_in = C([sock.sv_get(deepcopy=False) for sock in self.inputs]) for bvh, st, di in zip(*[self.svmesh_to_bvh_lists(vert_in, face_in, self.all_triangles, self.epsilon, self.safe_check), start_in, direction_in]): diff --git a/nodes/analyzer/volume.py b/nodes/analyzer/volume.py index 49889fb4e3..7d4f328e98 100644 --- a/nodes/analyzer/volume.py +++ b/nodes/analyzer/volume.py @@ -38,6 +38,11 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vers"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vers'].label or self.inputs['Vers'].identifier}' has to be connected") + if not (self.inputs["Pols"].is_linked): + raise Exception(f"Input socket '{self.inputs['Pols'].label or self.inputs['Pols'].identifier}' has to be connected") + vertices = self.inputs['Vers'].sv_get(deepcopy=False, default=[]) faces = self.inputs['Pols'].sv_get(deepcopy=False, default=[]) diff --git a/nodes/color/color_in_mk1.py b/nodes/color/color_in_mk1.py index 12fa7d745a..5e6a7699bb 100644 --- a/nodes/color/color_in_mk1.py +++ b/nodes/color/color_in_mk1.py @@ -176,9 +176,9 @@ def sv_init(self, context): onew('SvColorSocket', "Colors") def process(self): - if not any(socket.is_linked for socket in self.outputs): return + inputs = self.inputs i0_g = inputs[0].sv_get() diff --git a/nodes/color/color_input.py b/nodes/color/color_input.py index 9d12b2d239..42c6113abc 100644 --- a/nodes/color/color_input.py +++ b/nodes/color/color_input.py @@ -61,6 +61,7 @@ def draw_buttons_3dpanel(self, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if self.use_alpha: color = self.color_data[:] else: diff --git a/nodes/color/color_mix.py b/nodes/color/color_mix.py index 8dae890ce9..564f039c39 100644 --- a/nodes/color/color_mix.py +++ b/nodes/color/color_mix.py @@ -272,17 +272,17 @@ def sv_init(self, context): def process(self): + if not any(socket.is_linked for socket in self.outputs): + return - if self.outputs[0].is_linked: + params = [si.sv_get(default=[[]], deepcopy=False) for si in self.inputs] + matching_f = list_match_func[self.list_match] - params = [si.sv_get(default=[[]], deepcopy=False) for si in self.inputs] - matching_f = list_match_func[self.list_match] + desired_levels = [2, 3, 3] + ops = [self.current_op, self.list_match, self.clamp_output, self.output_numpy] + result = recurse_f_level_control(params, ops, color_mix, matching_f, desired_levels) - desired_levels = [2, 3, 3] - ops = [self.current_op, self.list_match, self.clamp_output, self.output_numpy] - result = recurse_f_level_control(params, ops, color_mix, matching_f, desired_levels) - - self.outputs[0].sv_set(result) + self.outputs[0].sv_set(result) classes = [SvColorMixNode] diff --git a/nodes/color/color_out_mk1.py b/nodes/color/color_out_mk1.py index 623b5c17a2..93d522f4af 100644 --- a/nodes/color/color_out_mk1.py +++ b/nodes/color/color_out_mk1.py @@ -107,6 +107,7 @@ def rclick_menu(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + color_input = self.inputs['Colors'] if color_input.is_linked: abc = self.inputs['Colors'].sv_get(deepcopy=False) diff --git a/nodes/color/formula_color.py b/nodes/color/formula_color.py index ae6470f2e5..894695b2b6 100644 --- a/nodes/color/formula_color.py +++ b/nodes/color/formula_color.py @@ -51,19 +51,22 @@ def draw_buttons(self, context, layout): split.split().prop(self, "Mode"+element, text='') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + Io, Io2 = self.inputs Oo = self.outputs[0] - if Oo.is_linked: - V = Io.sv_get() - if Io2.is_linked: - str = "for Enum,Val2L in zip(enumerate(V), V2): \n I,L = Enum \n Pfin = [] \n for Enum2, col2 in zip(enumerate(L), safc(L, Val2L)): \n i, (r, g, b, a) = Enum2 \n (R, G, B, A) = col2 \n Pfin.append(({n.ModeR},{n.ModeG},{n.ModeB},{n.ModeA})) \n fin.append(Pfin)" - fin = [] - V2 = Io2.sv_get() - exec(str.format(n=self)) - Oo.sv_set(fin) - else: - exec_string = "Oo.sv_set([[({n.ModeR},{n.ModeG},{n.ModeB},{n.ModeA}) for i, (r, g, b, a) in enumerate(L)] for I, L in enumerate(V)])" - exec(exec_string.format(n=self)) + + V = Io.sv_get() + if Io2.is_linked: + str = "for Enum,Val2L in zip(enumerate(V), V2): \n I,L = Enum \n Pfin = [] \n for Enum2, col2 in zip(enumerate(L), safc(L, Val2L)): \n i, (r, g, b, a) = Enum2 \n (R, G, B, A) = col2 \n Pfin.append(({n.ModeR},{n.ModeG},{n.ModeB},{n.ModeA})) \n fin.append(Pfin)" + fin = [] + V2 = Io2.sv_get() + exec(str.format(n=self)) + Oo.sv_set(fin) + else: + exec_string = "Oo.sv_set([[({n.ModeR},{n.ModeG},{n.ModeB},{n.ModeA}) for i, (r, g, b, a) in enumerate(L)] for I, L in enumerate(V)])" + exec(exec_string.format(n=self)) def register(): diff --git a/nodes/color/texture_evaluate_mk2.py b/nodes/color/texture_evaluate_mk2.py index dfdf974406..cc682ef5c0 100644 --- a/nodes/color/texture_evaluate_mk2.py +++ b/nodes/color/texture_evaluate_mk2.py @@ -170,10 +170,12 @@ def migrate_from(self, old_node): self.texture_pointer = self.get_bpy_data_from_name(old_node.name_texture, bpy.data.textures) def process(self): - inputs, outputs = self.inputs, self.outputs - - if not outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + + inputs, outputs = self.inputs, self.outputs result = [] diff --git a/nodes/curve/bezier_spline.py b/nodes/curve/bezier_spline.py index dfd95200d3..0e39b53f17 100644 --- a/nodes/curve/bezier_spline.py +++ b/nodes/curve/bezier_spline.py @@ -83,6 +83,7 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + start_s = self.inputs['Start'].sv_get() end_s = self.inputs['End'].sv_get() knot1_s = self.inputs[CONTROL1_SOCKET].sv_get() diff --git a/nodes/curve/catmull_rom.py b/nodes/curve/catmull_rom.py index 6754c46613..b92d7676f4 100644 --- a/nodes/curve/catmull_rom.py +++ b/nodes/curve/catmull_rom.py @@ -68,7 +68,7 @@ def sv_init(self, context): self.update_sockets(context) def process(self): - if not any(o.is_linked for o in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return vertices_s = self.inputs['Vertices'].sv_get( default=[[]]) diff --git a/nodes/curve/cubic_spline.py b/nodes/curve/cubic_spline.py index 61e0e94b47..7b2b44abcf 100644 --- a/nodes/curve/cubic_spline.py +++ b/nodes/curve/cubic_spline.py @@ -43,7 +43,7 @@ def build_spline(self, path): return spline def process(self): - if not any(o.is_linked for o in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return vertices_s = self.inputs['Vertices'].sv_get(default=[[]]) diff --git a/nodes/curve/length_parameter.py b/nodes/curve/length_parameter.py index 14d411301c..6d5310132d 100644 --- a/nodes/curve/length_parameter.py +++ b/nodes/curve/length_parameter.py @@ -162,8 +162,7 @@ def prepare_lengths(self, total_length, segment_length): return np.arange(0.0, total_length, step = segment_length) def process(self): - - if not any((s.is_linked for s in self.outputs)): + if not any(socket.is_linked for socket in self.outputs): return need_eval = self.outputs['Vertices'].is_linked diff --git a/nodes/curve/length_rebuild.py b/nodes/curve/length_rebuild.py index 1f1b3993a4..db8cbb330b 100644 --- a/nodes/curve/length_rebuild.py +++ b/nodes/curve/length_rebuild.py @@ -74,8 +74,7 @@ def draw_label(self): return label def process(self): - - if not any((s.is_linked for s in self.outputs)): + if not any(socket.is_linked for socket in self.outputs): return curves_s = self.inputs['Curve'].sv_get() diff --git a/nodes/dictionary/dictionary_in.py b/nodes/dictionary/dictionary_in.py index 011eb2aba0..9e1ef18795 100644 --- a/nodes/dictionary/dictionary_in.py +++ b/nodes/dictionary/dictionary_in.py @@ -103,8 +103,7 @@ def validate_names(self): self.alert[int(sock.prop_name.rsplit('_', 1)[-1])] = False def process(self): - - if not any((sock.links for sock in self.inputs)): + if not any(socket.is_linked for socket in self.outputs): return self.validate_names() diff --git a/nodes/exchange/FCStd_read.py b/nodes/exchange/FCStd_read.py index 3f1b34aa9d..dbe93da7b1 100644 --- a/nodes/exchange/FCStd_read.py +++ b/nodes/exchange/FCStd_read.py @@ -121,7 +121,7 @@ def process(self): if not any(socket.is_linked for socket in self.outputs): return if not self.inputs['File Path'].is_linked: - return + raise Exception(f"Input socket '{self.inputs['File Path'].label or self.inputs['File Path'].identifier}' has to be connected") if self.read_update: self.read_FCStd(self) diff --git a/nodes/exchange/FCStd_read_mod.py b/nodes/exchange/FCStd_read_mod.py index 17cb852f8d..f1c52020fe 100644 --- a/nodes/exchange/FCStd_read_mod.py +++ b/nodes/exchange/FCStd_read_mod.py @@ -197,7 +197,7 @@ def process(self): if not any(socket.is_linked for socket in self.outputs): return if not self.inputs['File Path'].is_linked: - return + raise Exception(f"Input socket '{self.inputs['File Path'].label or self.inputs['File Path'].identifier}' has to be connected") if self.read_update: self.read_FCStd(self) diff --git a/nodes/exchange/approx_subd_to_nurbs.py b/nodes/exchange/approx_subd_to_nurbs.py index 7f1ed3f72e..f9214cca2b 100644 --- a/nodes/exchange/approx_subd_to_nurbs.py +++ b/nodes/exchange/approx_subd_to_nurbs.py @@ -71,6 +71,7 @@ def Approximate(self,node): def process(self): if not any(socket.is_linked for socket in self.outputs): return + try: self.inputs['Subd Obj'].sv_get()[0] except: diff --git a/nodes/field/mesh_surface_field.py b/nodes/field/mesh_surface_field.py index 57937e4a1c..d2588dfb42 100644 --- a/nodes/field/mesh_surface_field.py +++ b/nodes/field/mesh_surface_field.py @@ -84,7 +84,6 @@ def sv_init(self, context): self.outputs.new('SvScalarFieldSocket', "Field") def process(self): - if not any(socket.is_linked for socket in self.outputs): return diff --git a/nodes/field/minimal_sfield.py b/nodes/field/minimal_sfield.py index f09ec4f3c9..1e8b02c7ef 100644 --- a/nodes/field/minimal_sfield.py +++ b/nodes/field/minimal_sfield.py @@ -52,7 +52,6 @@ def draw_buttons(self, context, layout): layout.prop(self, "function") def process(self): - if not any(socket.is_linked for socket in self.outputs): return diff --git a/nodes/field/minimal_vfield.py b/nodes/field/minimal_vfield.py index 36c4e9c7d5..a2792c71e5 100644 --- a/nodes/field/minimal_vfield.py +++ b/nodes/field/minimal_vfield.py @@ -65,7 +65,6 @@ def draw_buttons(self, context, layout): layout.prop(self, "function") def process(self): - if not any(socket.is_linked for socket in self.outputs): return diff --git a/nodes/field/voronoi_field.py b/nodes/field/voronoi_field.py index eb2c7ef8d1..96efdff4e8 100644 --- a/nodes/field/voronoi_field.py +++ b/nodes/field/voronoi_field.py @@ -51,7 +51,6 @@ def sv_init(self, context): self.outputs.new('SvVectorFieldSocket', "VField") def process(self): - if not any(socket.is_linked for socket in self.outputs): return diff --git a/nodes/generator/basic_3pt_arc.py b/nodes/generator/basic_3pt_arc.py index 488eff793b..e7cdeb171c 100644 --- a/nodes/generator/basic_3pt_arc.py +++ b/nodes/generator/basic_3pt_arc.py @@ -134,6 +134,7 @@ def draw_buttons(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + outputs = self.outputs inputs = self.inputs @@ -141,8 +142,8 @@ def process(self): - is Edges socket created, means all sockets exist. - is anything connected to the Verts socket? ''' - if not all([outputs['Verts'].is_linked, inputs['arc_pts'].is_linked]): - return + if not inputs['arc_pts'].is_linked: + raise Exception(f"Input socket '{self.inputs['arc_pts'].label or self.inputs['arc_pts'].identifier}' has to be connected") ''' operational scheme: diff --git a/nodes/generator/basic_spline.py b/nodes/generator/basic_spline.py index cc0e8be24e..c7db990adc 100644 --- a/nodes/generator/basic_spline.py +++ b/nodes/generator/basic_spline.py @@ -84,6 +84,7 @@ def draw_buttons_ext(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + outputs = self.outputs ''' diff --git a/nodes/generator/circle.py b/nodes/generator/circle.py index b90aafe813..087c4622c3 100644 --- a/nodes/generator/circle.py +++ b/nodes/generator/circle.py @@ -107,6 +107,7 @@ def make_faces(self, Angle, Vertices): def process(self): if not any(socket.is_linked for socket in self.outputs): return + # inputs input_socket_names = ['Radius', 'num Verts', 'Degrees'] diff --git a/nodes/generator/formula_shape.py b/nodes/generator/formula_shape.py index 611a99b631..561fae0a84 100644 --- a/nodes/generator/formula_shape.py +++ b/nodes/generator/formula_shape.py @@ -114,6 +114,7 @@ def draw_buttons(self,context,layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + # inputs Count = self.inputs['Count'].sv_get()[0][0] Scale = self.inputs['Scale'].sv_get()[0][0] diff --git a/nodes/generator/ngon.py b/nodes/generator/ngon.py index 4c62aa9e67..edac6abfdd 100644 --- a/nodes/generator/ngon.py +++ b/nodes/generator/ngon.py @@ -147,6 +147,7 @@ def draw_buttons_ext(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + # inputs radius = self.inputs['Radius'].sv_get()[0] diff --git a/nodes/generator/plane_mk3.py b/nodes/generator/plane_mk3.py index 67136c9440..035bda6a33 100644 --- a/nodes/generator/plane_mk3.py +++ b/nodes/generator/plane_mk3.py @@ -455,6 +455,7 @@ def get_data(self): def process(self): if not any(socket.is_linked for socket in self.outputs): return + outputs = self.outputs data_in = self.get_data() diff --git a/nodes/generator/random_vector_mk3.py b/nodes/generator/random_vector_mk3.py index 3aaa167234..c59b884454 100644 --- a/nodes/generator/random_vector_mk3.py +++ b/nodes/generator/random_vector_mk3.py @@ -108,6 +108,7 @@ def draw_buttons_ext(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + params = [si.sv_get(default=[[]], deepcopy=False) for si in self.inputs] matching_f = list_match_func[self.list_match] diff --git a/nodes/generator/segment.py b/nodes/generator/segment.py index 0a1e3e9f70..eca6afa387 100644 --- a/nodes/generator/segment.py +++ b/nodes/generator/segment.py @@ -192,6 +192,7 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + num_objects = max([len(sock.sv_get(deepcopy=False, default=[])) for sock in self.inputs]) out = [] list_match_f = iter_list_match_func[self.list_match_global] diff --git a/nodes/generator/sphere.py b/nodes/generator/sphere.py index be02a16a99..bffde73ab6 100644 --- a/nodes/generator/sphere.py +++ b/nodes/generator/sphere.py @@ -179,6 +179,7 @@ def draw_buttons_ext(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + # inputs if 'Polygons' not in self.outputs: return diff --git a/nodes/generators_extended/box_rounded.py b/nodes/generators_extended/box_rounded.py index 213c7b5363..6fd2390521 100644 --- a/nodes/generators_extended/box_rounded.py +++ b/nodes/generators_extended/box_rounded.py @@ -389,6 +389,7 @@ def draw_buttons(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + inputs = self.inputs outputs = self.outputs sizes = inputs['vector_size'].sv_get()[0] diff --git a/nodes/generators_extended/ellipse_mk3.py b/nodes/generators_extended/ellipse_mk3.py index 17c50e24f0..79738e47b2 100644 --- a/nodes/generators_extended/ellipse_mk3.py +++ b/nodes/generators_extended/ellipse_mk3.py @@ -336,6 +336,7 @@ def make_ellipse(self, a, b, N, phase, rotation, scale, ex, ey): def process(self): if not any(socket.is_linked for socket in self.outputs): return + outputs = self.outputs # input values lists (single or multi value) diff --git a/nodes/generators_extended/hilbert.py b/nodes/generators_extended/hilbert.py index 9c85b2a0e3..aae23c59a2 100644 --- a/nodes/generators_extended/hilbert.py +++ b/nodes/generators_extended/hilbert.py @@ -53,6 +53,7 @@ def draw_buttons(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + level_socket, size_socket = self.inputs verts_socket, edges_socket = self.outputs diff --git a/nodes/generators_extended/hilbert3d.py b/nodes/generators_extended/hilbert3d.py index ecd159132f..47fc4979e0 100644 --- a/nodes/generators_extended/hilbert3d.py +++ b/nodes/generators_extended/hilbert3d.py @@ -71,6 +71,7 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + level_socket, size_socket = self.inputs verts_socket, edges_socket = self.outputs diff --git a/nodes/generators_extended/hilbert_image.py b/nodes/generators_extended/hilbert_image.py index ab57ea9fdd..cf0954796d 100644 --- a/nodes/generators_extended/hilbert_image.py +++ b/nodes/generators_extended/hilbert_image.py @@ -82,6 +82,7 @@ def draw_buttons(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + level_socket, size_socket, sensitivity_socket = self.inputs verts_socket, edges_socket = self.outputs diff --git a/nodes/generators_extended/pentagon_tiler.py b/nodes/generators_extended/pentagon_tiler.py index b6b3619d64..844aba8401 100644 --- a/nodes/generators_extended/pentagon_tiler.py +++ b/nodes/generators_extended/pentagon_tiler.py @@ -223,6 +223,7 @@ def pentagon_tiler(self, params): def process(self): if not any(socket.is_linked for socket in self.outputs): return + # input values lists params = [s.sv_get() for s in self.inputs] params = list_match_func[self.list_match_global](params) diff --git a/nodes/generators_extended/spiral_mk2.py b/nodes/generators_extended/spiral_mk2.py index 3f9eed166e..25e7f51645 100644 --- a/nodes/generators_extended/spiral_mk2.py +++ b/nodes/generators_extended/spiral_mk2.py @@ -580,6 +580,7 @@ def draw_buttons_ext(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + outputs = self.outputs # input values lists (single or multi value) diff --git a/nodes/generators_extended/torus_knot_mk2.py b/nodes/generators_extended/torus_knot_mk2.py index e666a52799..63cc9ccf47 100644 --- a/nodes/generators_extended/torus_knot_mk2.py +++ b/nodes/generators_extended/torus_knot_mk2.py @@ -385,6 +385,7 @@ def draw_buttons(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + outputs = self.outputs # input values lists (single or multi value) diff --git a/nodes/generators_extended/wfc_texture.py b/nodes/generators_extended/wfc_texture.py index ea04a1f60c..74ca896319 100644 --- a/nodes/generators_extended/wfc_texture.py +++ b/nodes/generators_extended/wfc_texture.py @@ -65,6 +65,7 @@ def draw_buttons_ext(self, context, layout: 'UILayout'): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if not self.image_name: raise Exception("No image selected") diff --git a/nodes/layout/converter.py b/nodes/layout/converter.py index 077210a5a2..1a398bf90f 100644 --- a/nodes/layout/converter.py +++ b/nodes/layout/converter.py @@ -42,6 +42,7 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + if self.inputs[0].is_linked: out = self.inputs[0].sv_get(deepcopy=False) for s in self.outputs: diff --git a/nodes/list_main/decompose.py b/nodes/list_main/decompose.py index acbf81a406..aaf5416ab9 100644 --- a/nodes/list_main/decompose.py +++ b/nodes/list_main/decompose.py @@ -83,6 +83,7 @@ def sv_update(self): def process(self): if not any(socket.is_linked for socket in self.outputs): return + data = self.inputs['data'].sv_get() result = self.beat(data, self.level) for out, socket in zip(result, self.outputs[:30]): diff --git a/nodes/list_main/delete_levels.py b/nodes/list_main/delete_levels.py index 76ed22c164..224de1f112 100644 --- a/nodes/list_main/delete_levels.py +++ b/nodes/list_main/delete_levels.py @@ -56,10 +56,10 @@ def sv_update(self): def process(self): if not any(socket.is_linked for socket in self.outputs): return - if self.outputs['data'].is_linked: - data = self.inputs['data'].sv_get() - userlevelb = literal_eval('['+self.Sverch_LisLev+']') - self.outputs['data'].sv_set(preobrazovatel(data, userlevelb)) + + data = self.inputs['data'].sv_get() + userlevelb = literal_eval('['+self.Sverch_LisLev+']') + self.outputs['data'].sv_set(preobrazovatel(data, userlevelb)) def register(): diff --git a/nodes/list_main/func.py b/nodes/list_main/func.py index 592b29e1c2..58dd98ff9f 100644 --- a/nodes/list_main/func.py +++ b/nodes/list_main/func.py @@ -119,17 +119,16 @@ def process(self): if not self.inputs['Data'].is_linked: raise Exception("Input socket 'Data' has to be connected") - if self.outputs['Function'].is_linked and self.inputs['Data'].is_linked: - data = self.inputs['Data'].sv_get() - func = func_dict[self.func_] - numpy_func = numpy_func_dict[self.func_] + data = self.inputs['Data'].sv_get() + func = func_dict[self.func_] + numpy_func = numpy_func_dict[self.func_] - if not self.level: - out = [func(data)] - else: - out = self.count(data, self.level, func, numpy_func) + if not self.level: + out = [func(data)] + else: + out = self.count(data, self.level, func, numpy_func) - self.outputs['Function'].sv_set([out] if self.wrap else out) + self.outputs['Function'].sv_set([out] if self.wrap else out) def count(self, data, level, func, numpy_func): out = [] diff --git a/nodes/list_main/index.py b/nodes/list_main/index.py index d78c766853..4e12916cce 100644 --- a/nodes/list_main/index.py +++ b/nodes/list_main/index.py @@ -53,6 +53,7 @@ def process(self): return if not any(socket.is_linked for socket in self.inputs): raise Exception("All input sockets has to be connected") + data = self.inputs['data'].sv_get(deepcopy=False, default=[]) items = self.inputs['Item'].sv_get(deepcopy=False, default=[]) diff --git a/nodes/list_main/length.py b/nodes/list_main/length.py index 94f88db3bd..e6b132e1c3 100644 --- a/nodes/list_main/length.py +++ b/nodes/list_main/length.py @@ -40,6 +40,7 @@ def process(self): return if not all(socket.is_linked for socket in self.inputs): raise Exception("All input sockets has to be connected") + if 'Length' in self.outputs and self.outputs['Length'].is_linked: if 'Data' in self.inputs and self.inputs['Data'].is_linked: data = self.inputs['Data'].sv_get(deepcopy=False) diff --git a/nodes/list_main/match.py b/nodes/list_main/match.py index 8702992657..4cead6d447 100644 --- a/nodes/list_main/match.py +++ b/nodes/list_main/match.py @@ -107,6 +107,7 @@ def process(self): return if not any(socket.is_linked for socket in self.inputs): raise Exception("Some input sockets has to be connected") + # check inputs and that there is at least one output count_inputs = sum(s.is_linked for s in self.inputs) diff --git a/nodes/list_main/statistics.py b/nodes/list_main/statistics.py index 707b4a96c3..40ec789952 100644 --- a/nodes/list_main/statistics.py +++ b/nodes/list_main/statistics.py @@ -430,6 +430,7 @@ def process(self): return if not any(socket.is_linked for socket in self.inputs): raise Exception("Input socket 'Data' has to be connected") + inputs = self.inputs outputs = self.outputs diff --git a/nodes/list_main/sum_mk2.py b/nodes/list_main/sum_mk2.py index f47b60e45b..ee220796d0 100644 --- a/nodes/list_main/sum_mk2.py +++ b/nodes/list_main/sum_mk2.py @@ -47,6 +47,7 @@ def process(self): return if not any(socket.is_linked for socket in self.inputs): raise Exception("Input socket 'Data' has to be connected") + # достаём два слота - вершины и полики if self.outputs['Sum'].is_linked and self.inputs['Data'].is_linked: data = self.inputs['Data'].sv_get() diff --git a/nodes/list_masks/index_to_mask.py b/nodes/list_masks/index_to_mask.py index 73bba54d5d..80ee219442 100644 --- a/nodes/list_masks/index_to_mask.py +++ b/nodes/list_masks/index_to_mask.py @@ -86,6 +86,7 @@ def process(self): if not any(socket.is_linked for socket in self.outputs): return + index = self.inputs["Index"].sv_get(deepcopy=False, default=[]) mask_size = self.inputs['Mask size'].sv_get(deepcopy=False, default=[None]) data_to_mask = self.inputs['Data masking'].sv_get(deepcopy=False, diff --git a/nodes/list_masks/mask.py b/nodes/list_masks/mask.py index eac2a906ef..417bf9bbc8 100644 --- a/nodes/list_masks/mask.py +++ b/nodes/list_masks/mask.py @@ -125,6 +125,7 @@ def process(self): return if not all(socket.is_linked for socket in self.inputs): raise Exception("All input sockets has to be connected") + inputs = self.inputs outputs = self.outputs if not any(s.is_linked for s in outputs) and inputs[0].is_linked: diff --git a/nodes/list_masks/mask_join.py b/nodes/list_masks/mask_join.py index 376565e757..3c7d511939 100644 --- a/nodes/list_masks/mask_join.py +++ b/nodes/list_masks/mask_join.py @@ -72,15 +72,15 @@ def process(self): return if not all(socket.is_linked for socket in self.inputs): raise Exception("All input sockets has to be connected") + Ouso = self.outputs[0] - if Ouso.is_linked: - mask = self.inputs['Mask'].sv_get([[1, 0]]) - data_t = self.inputs['Data True'].sv_get() - data_f = self.inputs['Data False'].sv_get() + mask = self.inputs['Mask'].sv_get([[1, 0]]) + data_t = self.inputs['Data True'].sv_get() + data_f = self.inputs['Data False'].sv_get() - data_out = self.get_level(mask, data_t, data_f, self.level-1) + data_out = self.get_level(mask, data_t, data_f, self.level-1) - Ouso.sv_set(data_out) + Ouso.sv_set(data_out) def apply_choice_mask(self, mask, data_t, data_f): out = [] diff --git a/nodes/list_masks/mask_to_index.py b/nodes/list_masks/mask_to_index.py index 6e738706d3..fdcf281ab0 100644 --- a/nodes/list_masks/mask_to_index.py +++ b/nodes/list_masks/mask_to_index.py @@ -47,10 +47,9 @@ def process(self): return if not all(socket.is_linked for socket in self.inputs): raise Exception("Input socket 'Mask' has to be connected") + inputs = self.inputs outputs = self.outputs - if not (any(s.is_linked for s in outputs) and inputs[0].is_linked): - return mask = inputs['Mask'].sv_get(default=[[1, 0]]) diff --git a/nodes/list_mutators/filter_empty_lists.py b/nodes/list_mutators/filter_empty_lists.py index 93d69d7f39..77bf140ea5 100644 --- a/nodes/list_mutators/filter_empty_lists.py +++ b/nodes/list_mutators/filter_empty_lists.py @@ -40,6 +40,7 @@ def process(self): return if not all(socket.is_linked for socket in self.inputs): raise Exception("Input socket 'Data' has to be connected") + sd, m, nm = self.outputs D = self.inputs[0].sv_get() if sd.is_linked: diff --git a/nodes/list_struct/item_insert.py b/nodes/list_struct/item_insert.py index 47f12cc8be..b7ffbc79c5 100644 --- a/nodes/list_struct/item_insert.py +++ b/nodes/list_struct/item_insert.py @@ -86,6 +86,7 @@ def sv_update(self): def process(self): if not any(socket.is_linked for socket in self.outputs): return + out_socket = self.outputs[0] si = self.inputs if not (si['Data'].is_linked): diff --git a/nodes/list_struct/levels.py b/nodes/list_struct/levels.py index 4869875946..dff5cf9291 100644 --- a/nodes/list_struct/levels.py +++ b/nodes/list_struct/levels.py @@ -104,6 +104,7 @@ def process(self): return if not any(socket.is_linked for socket in self.inputs): raise Exception("Input socket 'Data' has to be connected") + data = self.inputs['Data'].sv_get(default=[], deepcopy=False) nesting, descriptions = describe_data_shape_by_level(data, include_numpy_nesting=False) diff --git a/nodes/list_struct/numpy_array.py b/nodes/list_struct/numpy_array.py index c5643fac8f..34489b87e1 100644 --- a/nodes/list_struct/numpy_array.py +++ b/nodes/list_struct/numpy_array.py @@ -53,6 +53,7 @@ def draw_buttons(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + out = self.outputs[0] if out.is_linked: X,Y = self.inputs diff --git a/nodes/list_struct/repeater.py b/nodes/list_struct/repeater.py index 15a07e23d5..b903c8aeb4 100644 --- a/nodes/list_struct/repeater.py +++ b/nodes/list_struct/repeater.py @@ -56,6 +56,7 @@ def process(self): return if not (self.inputs["Data"].is_linked): raise Exception("Input socket 'Data' has to be connected") + data = self.inputs['Data'].sv_get(deepcopy=False, default=[]) number = self.inputs['Number'].sv_get(deepcopy=False)[0] diff --git a/nodes/logic/custom_switcher.py b/nodes/logic/custom_switcher.py index 99224c1e8f..371b8e7754 100644 --- a/nodes/logic/custom_switcher.py +++ b/nodes/logic/custom_switcher.py @@ -96,6 +96,7 @@ def process(self): return if not (self.inputs["Data"].is_linked): raise Exception("Input socket 'Data' has to be connected") + # Storing names of items if self.inputs['Data'].is_linked: data = self.inputs['Data'].sv_get() diff --git a/nodes/matrix/apply_and_join.py b/nodes/matrix/apply_and_join.py index c012d5c36e..eed121822e 100644 --- a/nodes/matrix/apply_and_join.py +++ b/nodes/matrix/apply_and_join.py @@ -174,6 +174,7 @@ def rclick_menu(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + vertices = self.inputs['Vertices'].sv_get(default=[], deepcopy=False) edges = self.inputs['Edges'].sv_get(default=[], deepcopy=False) faces = self.inputs['Faces'].sv_get(default=[], deepcopy=False) diff --git a/nodes/matrix/euler.py b/nodes/matrix/euler.py index e405abbd14..eeeaee77ab 100644 --- a/nodes/matrix/euler.py +++ b/nodes/matrix/euler.py @@ -92,6 +92,7 @@ def rclick_menu(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + inputs = self.inputs params = [s.sv_get() for s in inputs] mats = [] diff --git a/nodes/matrix/input.py b/nodes/matrix/input.py index 29d62482f5..e02b4e525d 100644 --- a/nodes/matrix/input.py +++ b/nodes/matrix/input.py @@ -51,6 +51,9 @@ def draw_buttons(self, context, layout): row.prop(self, 'matrix', text='', index=j) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if self.outputs['Matrix'].is_linked: self.outputs[0].sv_set([self.matrix]) diff --git a/nodes/matrix/interpolation.py b/nodes/matrix/interpolation.py index b82063f214..dc8bc0cb7b 100644 --- a/nodes/matrix/interpolation.py +++ b/nodes/matrix/interpolation.py @@ -52,6 +52,7 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + id_mat = [Matrix.Identity(4)] A = self.inputs['A'].sv_get(default=id_mat) B = self.inputs['B'].sv_get(default=id_mat) diff --git a/nodes/matrix/matrix_deform.py b/nodes/matrix/matrix_deform.py index b5b550a281..580c5ca255 100644 --- a/nodes/matrix/matrix_deform.py +++ b/nodes/matrix/matrix_deform.py @@ -39,6 +39,7 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + O,L,S,R,A = self.inputs Om = self.outputs[0] if Om.is_linked: diff --git a/nodes/matrix/matrix_math.py b/nodes/matrix/matrix_math.py index dd901552a8..1d11e3dcd9 100644 --- a/nodes/matrix/matrix_math.py +++ b/nodes/matrix/matrix_math.py @@ -242,6 +242,7 @@ def sv_update(self): def process(self): if not any(socket.is_linked for socket in self.outputs): return + outputs = self.outputs data_in = [] # collect the inputs from the connected sockets diff --git a/nodes/matrix/matrix_track_to.py b/nodes/matrix/matrix_track_to.py index 6bb8af22b4..329c7ae0a9 100644 --- a/nodes/matrix/matrix_track_to.py +++ b/nodes/matrix/matrix_track_to.py @@ -193,6 +193,7 @@ def matrix_track_to(self, params, mT, mU, orthogonalize, gates): def process(self): if not any(socket.is_linked for socket in self.outputs): return + outputs = self.outputs # input values lists diff --git a/nodes/matrix/shear.py b/nodes/matrix/shear.py index 1ca65d209c..a6f2b88527 100644 --- a/nodes/matrix/shear.py +++ b/nodes/matrix/shear.py @@ -59,6 +59,7 @@ def draw_buttons(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + # inputs factor1 = self.inputs['Factor1'].sv_get() diff --git a/nodes/modifier_change/bevel.py b/nodes/modifier_change/bevel.py index 1346e048bd..7f0a64c64b 100644 --- a/nodes/modifier_change/bevel.py +++ b/nodes/modifier_change/bevel.py @@ -205,12 +205,15 @@ def create_geom(self, bm, mask): return geom def process(self): - - if not (self.inputs[0].is_linked and (self.inputs[2].is_linked or self.inputs[1].is_linked)): - return - if not any(self.outputs[name].is_linked for name in ['Vertices', 'Edges', 'Polygons', 'NewPolys']): + if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs[0].is_linked): + raise Exception(f"Input socket '{self.inputs[0].label or self.inputs[0].identifier}' has to be connected") + if not (self.inputs[1].is_linked): + raise Exception(f"Input socket '{self.inputs[1].label or self.inputs[1].identifier}' has to be connected") + if not (self.inputs[2].is_linked): + raise Exception(f"Input socket '{self.inputs[2].label or self.inputs[2].identifier}' has to be connected") + verts_out = [] edges_out = [] faces_out = [] diff --git a/nodes/modifier_change/delete_loose.py b/nodes/modifier_change/delete_loose.py index 729b770967..2bd9711160 100644 --- a/nodes/modifier_change/delete_loose.py +++ b/nodes/modifier_change/delete_loose.py @@ -40,13 +40,17 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'VertsMask') def process(self): - # older versions of this node do not have a vertsmask socket. This upgrades them silently if not self.outputs.get('VertsMask'): self.outputs.new('SvStringsSocket', 'VertsMask') - if not (all([s.is_linked for s in self.inputs]) and any([s.is_linked for s in self.outputs])): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + if not (self.inputs["PolyEdge"].is_linked): + raise Exception(f"Input socket '{self.inputs['PolyEdge'].label or self.inputs['PolyEdge'].identifier}' has to be connected") + verts = self.inputs['Vertices'].sv_get(deepcopy=False) poly_edge = self.inputs['PolyEdge'].sv_get(deepcopy=False) verts_out = [] diff --git a/nodes/modifier_change/dissolve_mesh_elements.py b/nodes/modifier_change/dissolve_mesh_elements.py index 2cdbd59ac1..075724cc0e 100644 --- a/nodes/modifier_change/dissolve_mesh_elements.py +++ b/nodes/modifier_change/dissolve_mesh_elements.py @@ -58,6 +58,11 @@ def draw_mask_socket_modes(self, socket, context, layout): layout.prop(self, 'mask_mode', expand=True, text='') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") + verts = self.inputs['Verts'].sv_get(deepcopy=False, default=[]) edges = self.inputs['Edges'].sv_get(deepcopy=False, default=[]) faces = self.inputs['Faces'].sv_get(deepcopy=False, default=[]) diff --git a/nodes/modifier_change/edge_boom.py b/nodes/modifier_change/edge_boom.py index 3b8910d043..acf0296057 100644 --- a/nodes/modifier_change/edge_boom.py +++ b/nodes/modifier_change/edge_boom.py @@ -91,8 +91,10 @@ def draw_buttons(self, context, layout): layout.prop(self, 'sort') def process(self): - if not self.inputs['Vertices'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") vertices_s = self.inputs['Vertices'].sv_get(deepcopy=False) edges_s = self.inputs['Edges'].sv_get(default=[[]], deepcopy=False) diff --git a/nodes/modifier_change/edge_split.py b/nodes/modifier_change/edge_split.py index f4c2bf8784..b1f8d4671a 100644 --- a/nodes/modifier_change/edge_split.py +++ b/nodes/modifier_change/edge_split.py @@ -69,6 +69,11 @@ def draw_buttons(self, context, layout): layout.prop(self, 'mode') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + verts = self.inputs['Vertices'].sv_get(default=[]) edges = self.inputs['Edges'].sv_get(default=[]) faces = self.inputs['Faces'].sv_get(default=[]) diff --git a/nodes/modifier_change/edgenet_to_paths.py b/nodes/modifier_change/edgenet_to_paths.py index 3d519d8531..380b24cf93 100644 --- a/nodes/modifier_change/edgenet_to_paths.py +++ b/nodes/modifier_change/edgenet_to_paths.py @@ -207,8 +207,9 @@ def sv_init(self, context): def process(self): - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + verts = self.inputs[0].sv_get(deepcopy=False) edges = self.inputs[1].sv_get(deepcopy=False) verts_out = [] diff --git a/nodes/modifier_change/extrude_multi_alt.py b/nodes/modifier_change/extrude_multi_alt.py index 16654782e2..6a287d57d3 100644 --- a/nodes/modifier_change/extrude_multi_alt.py +++ b/nodes/modifier_change/extrude_multi_alt.py @@ -271,7 +271,11 @@ def draw_buttons(self, context, layout): draw_ui(self, context, layout) def process(self): - + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['verts'].label or self.inputs['verts'].identifier}' has to be connected") + # bmesh operations verts = self.inputs['verts'].sv_get() faces = self.inputs['faces'].sv_get() diff --git a/nodes/modifier_change/extrude_region.py b/nodes/modifier_change/extrude_region.py index 5cffaf3896..5aac5c53a4 100644 --- a/nodes/modifier_change/extrude_region.py +++ b/nodes/modifier_change/extrude_region.py @@ -165,9 +165,10 @@ def get_out_mask(self, bm, extruded_faces, extruded_verts): return mask def process(self): - # inputs - if not self.inputs['Vertices'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") vertices_s = self.inputs['Vertices'].sv_get(deepcopy=False) edges_s = self.inputs['Edges'].sv_get(default=[[]], deepcopy=False) diff --git a/nodes/modifier_change/extrude_separate.py b/nodes/modifier_change/extrude_separate.py index 1cea84f8ba..5a4a0f62cf 100644 --- a/nodes/modifier_change/extrude_separate.py +++ b/nodes/modifier_change/extrude_separate.py @@ -153,17 +153,17 @@ def get_out_mask(self, bm, extruded_faces): return mask def process(self): - + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + if not (self.inputs["Polygons"].is_linked): + raise Exception(f"Input socket '{self.inputs['Polygons'].label or self.inputs['Polygons'].identifier}' has to be connected") + inputs = self.inputs outputs = self.outputs - if not (inputs['Vertices'].is_linked and inputs['Polygons'].is_linked): - return - if not any(socket.is_linked for socket in outputs): - return - need_mask_out = 'Mask' in outputs and outputs['Mask'].is_linked - vector_in = self.scale_socket_type vertices_s = inputs['Vertices'].sv_get(deepcopy=False) diff --git a/nodes/modifier_change/extrude_separate_lite.py b/nodes/modifier_change/extrude_separate_lite.py index a8f25295ab..992f38e564 100644 --- a/nodes/modifier_change/extrude_separate_lite.py +++ b/nodes/modifier_change/extrude_separate_lite.py @@ -66,9 +66,10 @@ def sv_internal_links(self): ] def process(self): - outputs = self.outputs - if not outputs['Vertices'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + + outputs = self.outputs IVerts, IFaces, IMask, Imatr = self.inputs vertices_s = IVerts.sv_get() faces_s = IFaces.sv_get() diff --git a/nodes/modifier_change/flat_geometry.py b/nodes/modifier_change/flat_geometry.py index 97f2641458..e3e66d0efb 100644 --- a/nodes/modifier_change/flat_geometry.py +++ b/nodes/modifier_change/flat_geometry.py @@ -102,18 +102,22 @@ def draw_buttons(self, context, layout): layout.prop(self, 'projection_mode') def process(self): - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return - if self.inputs['Vertices'].is_linked: - verts_in = self.inputs['Vertices'].sv_get(deepcopy=False) - plane_in = self.inputs['Plane Matrix'].sv_get(deepcopy=False) - if self.projection_mode == 'Orthographic': - verts_out, z_coord_out = ortho_projection(verts_in, plane_in) - else: - verts_out, z_coord_out = perspective_projection(verts_in, plane_in, 2) - - self.outputs['Vertices'].sv_set(verts_out) - self.outputs['Z coord'].sv_set(z_coord_out) + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + if not (self.inputs["Plane Matrix"].is_linked): + raise Exception(f"Input socket '{self.inputs['Plane Matrix'].label or self.inputs['Plane Matrix'].identifier}' has to be connected") + + verts_in = self.inputs['Vertices'].sv_get(deepcopy=False) + plane_in = self.inputs['Plane Matrix'].sv_get(deepcopy=False) + if self.projection_mode == 'Orthographic': + verts_out, z_coord_out = ortho_projection(verts_in, plane_in) + else: + verts_out, z_coord_out = perspective_projection(verts_in, plane_in, 2) + + self.outputs['Vertices'].sv_set(verts_out) + self.outputs['Z coord'].sv_set(z_coord_out) diff --git a/nodes/modifier_change/flip_normals.py b/nodes/modifier_change/flip_normals.py index 27063dfeb3..007ba6991f 100644 --- a/nodes/modifier_change/flip_normals.py +++ b/nodes/modifier_change/flip_normals.py @@ -93,9 +93,12 @@ def draw_buttons(self, context, layout): r2.prop(self, "selected_mode", expand=True) def process(self): - - if not any(self.outputs[idx].is_linked for idx in range(3)): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + if not (self.inputs["Polygons"].is_linked): + raise Exception(f"Input socket '{self.inputs['Polygons'].label or self.inputs['Polygons'].identifier}' has to be connected") vertices_s = self.inputs['Vertices'].sv_get(default=[[]], deepcopy=False) edges_s = self.inputs['Edges'].sv_get(default=[[]], deepcopy=False) diff --git a/nodes/modifier_change/follow_active_quads.py b/nodes/modifier_change/follow_active_quads.py index d409082ad9..699f1303f1 100644 --- a/nodes/modifier_change/follow_active_quads.py +++ b/nodes/modifier_change/follow_active_quads.py @@ -297,9 +297,13 @@ def sv_internal_links(self): ] def process(self): - if not all([sock.is_linked for sock in list(self.inputs)[:2]]): + if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") + if not (self.inputs["Faces"].is_linked): + raise Exception(f"Input socket '{self.inputs['Faces'].label or self.inputs['Faces'].identifier}' has to be connected") + in1 = [sock.sv_get(deepcopy=False) for sock in [self.inputs[n] for n in ('Verts', 'Faces')]] in2 = [chain(sock.sv_get(deepcopy=False), cycle([sock.sv_get(deepcopy=False)[-1]])) if sock.is_linked else diff --git a/nodes/modifier_change/holes_fill.py b/nodes/modifier_change/holes_fill.py index 125bf2ddc9..6c032a9f26 100644 --- a/nodes/modifier_change/holes_fill.py +++ b/nodes/modifier_change/holes_fill.py @@ -69,10 +69,13 @@ def sv_internal_links(self): ] def process(self): - - if not (self.inputs['vertices'].is_linked and self.inputs['edges'].is_linked): + if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['vertices'].label or self.inputs['vertices'].identifier}' has to be connected") + if not (self.inputs["edges"].is_linked): + raise Exception(f"Input socket '{self.inputs['edges'].label or self.inputs['edges'].identifier}' has to be connected") + verts = dataCorrect(self.inputs['vertices'].sv_get(deepcopy=False)) edges = dataCorrect(self.inputs['edges'].sv_get(deepcopy=False)) sides = self.inputs['Sides'].sv_get(deepcopy=False)[0] diff --git a/nodes/modifier_change/inset_faces.py b/nodes/modifier_change/inset_faces.py index 69edf6761f..8deb3fcdc7 100644 --- a/nodes/modifier_change/inset_faces.py +++ b/nodes/modifier_change/inset_faces.py @@ -383,8 +383,13 @@ def draw_mask_socket(self, socket, context, layout): layout.label(text=socket.name) def process(self): - if not all([sock.is_linked for sock in [self.inputs['Verts'], self.inputs['Faces']]]): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") + if not (self.inputs["Faces"].is_linked): + raise Exception(f"Input socket '{self.inputs['Faces'].label or self.inputs['Faces'].identifier}' has to be connected") + inputs = self.inputs params = [s.sv_get(deepcopy=False, default=[[]]) for s in self.inputs] max_len = max(map(len, params)) diff --git a/nodes/modifier_change/limited_dissolve.py b/nodes/modifier_change/limited_dissolve.py index e2dab104f6..ace5b4497a 100644 --- a/nodes/modifier_change/limited_dissolve.py +++ b/nodes/modifier_change/limited_dissolve.py @@ -49,8 +49,10 @@ def draw_buttons(self, context, layout): layout.prop(self, "use_dissolve_boundaries") def process(self): - if not self.outputs['Verts'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") verts = self.inputs['Verts'].sv_get(deepcopy=False) edges = self.inputs['Edges'].sv_get(default=[[]], deepcopy=False) diff --git a/nodes/modifier_change/limited_dissolve_mk2.py b/nodes/modifier_change/limited_dissolve_mk2.py index 45a39aaf60..1da35620b4 100644 --- a/nodes/modifier_change/limited_dissolve_mk2.py +++ b/nodes/modifier_change/limited_dissolve_mk2.py @@ -64,6 +64,9 @@ def draw_buttons(self, context, layout): layout.prop(self, "delimit") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + BML, Verts, Edges, Polys, vermask, edgmask, angllim = self.inputs o1,o2,o3,o4,o5 = self.outputs angle = angllim.sv_get()[0] diff --git a/nodes/modifier_change/make_monotone.py b/nodes/modifier_change/make_monotone.py index c6e564ec16..9b0f676bf7 100644 --- a/nodes/modifier_change/make_monotone.py +++ b/nodes/modifier_change/make_monotone.py @@ -45,6 +45,9 @@ def draw_buttons_ext(self, context, layout): layout.prop(self, 'accuracy') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + verts = self.inputs['Polygon'].sv_get() mesh = [] if self.inputs['Hole vectors'].is_linked and self.inputs['Hole polygons'].is_linked: diff --git a/nodes/modifier_change/merge_by_distance.py b/nodes/modifier_change/merge_by_distance.py index e3947a9301..3bc3d0861c 100644 --- a/nodes/modifier_change/merge_by_distance.py +++ b/nodes/modifier_change/merge_by_distance.py @@ -122,11 +122,11 @@ def draw_buttons(self, context, layout): pass def process(self): - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return - if not self.inputs['Vertices'].is_linked: - return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") verts = Vector_generate(self.inputs['Vertices'].sv_get(deepcopy=False)) polys = self.inputs['PolyEdge'].sv_get(default=[[]], deepcopy=False) diff --git a/nodes/modifier_change/mesh_beautify.py b/nodes/modifier_change/mesh_beautify.py index 49246b0fc6..44e185245b 100644 --- a/nodes/modifier_change/mesh_beautify.py +++ b/nodes/modifier_change/mesh_beautify.py @@ -42,8 +42,7 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'Faces') def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return in_verts = self.inputs['Verts'].sv_get(deepcopy=False) diff --git a/nodes/modifier_change/mesh_separate.py b/nodes/modifier_change/mesh_separate.py index c5d77ad8cb..8a75f59992 100644 --- a/nodes/modifier_change/mesh_separate.py +++ b/nodes/modifier_change/mesh_separate.py @@ -41,8 +41,9 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'Poly Egde') def process(self): - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + verts = self.inputs['Vertices'].sv_get(deepcopy=False) poly = self.inputs['Poly Egde'].sv_get(deepcopy=False) verts_out = [] diff --git a/nodes/modifier_change/objects_along_edge.py b/nodes/modifier_change/objects_along_edge.py index d82c5e23ce..15523cefd7 100644 --- a/nodes/modifier_change/objects_along_edge.py +++ b/nodes/modifier_change/objects_along_edge.py @@ -251,18 +251,25 @@ def draw_buttons_ext(self, context, layout): layout.prop(self, "apply_matrices") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + # VerticesR & EdgesR or Vertex1 & Vertex2 are necessary anyway # to define recipient edge if self.input_mode == "edge": - if not (self.inputs['VerticesR'].is_linked and self.inputs['EdgesR'].is_linked): - return + if not (self.inputs["VerticesR"].is_linked): + raise Exception(f"Input socket '{self.inputs['VerticesR'].label or self.inputs['VerticesR'].identifier}' has to be connected") + if not (self.inputs["EdgesR"].is_linked): + raise Exception(f"Input socket '{self.inputs['EdgesR'].label or self.inputs['EdgesR'].identifier}' has to be connected") elif self.input_mode == "fixed": - if not (self.inputs['Vertex1'].is_linked and self.inputs['Vertex2'].is_linked): - return + if not (self.inputs["Vertex1"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertex1'].label or self.inputs['Vertex1'].identifier}' has to be connected") + if not (self.inputs["Vertex2"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertex2'].label or self.inputs['Vertex2'].identifier}' has to be connected") # Input vertices are used now to define count of objects. # Theoretically it is possible to not use them in "Count" mode. - if not self.inputs['Vertices'].is_linked: - return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") vertices_s = self.inputs['Vertices'].sv_get(default=[[]]) vertices_s = Vector_generate(vertices_s) diff --git a/nodes/modifier_change/offset.py b/nodes/modifier_change/offset.py index 723b006984..f31129efa8 100644 --- a/nodes/modifier_change/offset.py +++ b/nodes/modifier_change/offset.py @@ -71,9 +71,10 @@ def sv_internal_links(self): ] def process(self): - - if not (self.outputs['Vers'].is_linked and self.inputs['Vers'].is_linked): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vers"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vers'].label or self.inputs['Vers'].identifier}' has to be connected") vertices = Vector_generate(self.inputs['Vers'].sv_get(deepcopy=False)) faces = self.inputs['Pols'].sv_get(deepcopy=False) diff --git a/nodes/modifier_change/opensubdivision.py b/nodes/modifier_change/opensubdivision.py index c269f7712e..6fdc58e600 100755 --- a/nodes/modifier_change/opensubdivision.py +++ b/nodes/modifier_change/opensubdivision.py @@ -68,6 +68,13 @@ def sv_init(self,context): def process(self): if not enable_module: raise Exception("The dependent library is not installed (pyOpenSubdiv).") + + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + if not (self.inputs["Faces"].is_linked): + raise Exception(f"Input socket '{self.inputs['Faces'].label or self.inputs['Faces'].identifier}' has to be connected") vert_sets = self.inputs['Vertices'].sv_get(default=[],deepcopy=False) edges = [] diff --git a/nodes/modifier_change/planar_edgenet_to_polygons.py b/nodes/modifier_change/planar_edgenet_to_polygons.py index a10b9b2020..109db42bd1 100644 --- a/nodes/modifier_change/planar_edgenet_to_polygons.py +++ b/nodes/modifier_change/planar_edgenet_to_polygons.py @@ -351,13 +351,13 @@ def sv_internal_links(self): return [(self.inputs[0], self.outputs[0])] def process(self): - - if not (self.inputs['Vers'].is_linked or self.inputs['Edgs'].is_linked): - return - if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["Vers"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vers'].label or self.inputs['Vers'].identifier}' has to be connected") + if not (self.inputs["Edgs"].is_linked): + raise Exception(f"Input socket '{self.inputs['Edgs'].label or self.inputs['Edgs'].identifier}' has to be connected") + verts_in = self.inputs['Vers'].sv_get() edges_in = self.inputs['Edgs'].sv_get() verts_out = [] diff --git a/nodes/modifier_change/polygons_boom.py b/nodes/modifier_change/polygons_boom.py index bbc38caa9a..6ea9809cd1 100644 --- a/nodes/modifier_change/polygons_boom.py +++ b/nodes/modifier_change/polygons_boom.py @@ -36,6 +36,9 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'edg_pol') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + # inputs vertices = self.inputs['vertices'].sv_get(deepcopy=False) edgs_pols = self.inputs['edg_pol'].sv_get(deepcopy=False) diff --git a/nodes/modifier_change/polygons_to_edges_mk2.py b/nodes/modifier_change/polygons_to_edges_mk2.py index 283df4e54e..4f3fed9013 100644 --- a/nodes/modifier_change/polygons_to_edges_mk2.py +++ b/nodes/modifier_change/polygons_to_edges_mk2.py @@ -62,7 +62,7 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "edgs").label = 'Edges' def process(self): - if not self.outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return polygons_ = self.inputs['pols'].sv_get(deepcopy=False) diff --git a/nodes/modifier_change/recalc_normals.py b/nodes/modifier_change/recalc_normals.py index e7f7d6fc2b..26230c6100 100644 --- a/nodes/modifier_change/recalc_normals.py +++ b/nodes/modifier_change/recalc_normals.py @@ -50,10 +50,12 @@ def draw_buttons(self, context, layout): layout.prop(self, "invert") def process(self): - if not (self.inputs['Vertices'].is_linked and self.inputs['Polygons'].is_linked): - return - if not (any(self.outputs[name].is_linked for name in ['Vertices', 'Edges', 'Polygons'])): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + if not (self.inputs["Polygons"].is_linked): + raise Exception(f"Input socket '{self.inputs['Polygons'].label or self.inputs['Polygons'].identifier}' has to be connected") vertices_s = self.inputs['Vertices'].sv_get(default=[[]], deepcopy=False) edges_s = self.inputs['Edges'].sv_get(default=[[]], deepcopy=False) diff --git a/nodes/modifier_change/rigid_origami.py b/nodes/modifier_change/rigid_origami.py index 3d5453e049..38ea0556ee 100644 --- a/nodes/modifier_change/rigid_origami.py +++ b/nodes/modifier_change/rigid_origami.py @@ -63,14 +63,14 @@ def process(self): if not any(socket.is_linked for socket in self.outputs): return - if not self.inputs['Fold edge indices'].is_linked \ - or not self.inputs['Fold edge angles'].is_linked: - return - verts_in = self.inputs['Vertices'].sv_get() edges_in = self.inputs['Edges'].sv_get() faces_in = self.inputs['Faces'].sv_get() + if not self.inputs['Fold edge indices'].is_linked \ + or not self.inputs['Fold edge angles'].is_linked: + raise Exception(f"Input socket '{self.inputs['Fold edge indices'].label or self.inputs['Fold edge indices'].identifier}' or '{self.inputs['Fold edge angles'].label or self.inputs['Fold edge angles'].identifier}' has to be connected") + fold_edge_indices = self.inputs['Fold edge indices'].sv_get() fold_edge_angles = self.inputs['Fold edge angles'].sv_get() diff --git a/nodes/modifier_change/separate_parts_to_indexes.py b/nodes/modifier_change/separate_parts_to_indexes.py index 6cd850ea01..2ea301c3cd 100644 --- a/nodes/modifier_change/separate_parts_to_indexes.py +++ b/nodes/modifier_change/separate_parts_to_indexes.py @@ -128,8 +128,12 @@ def sv_init(self, context): sv_internal_links = [] def process(self): - if not (self.inputs['Verts'].is_linked and (self.inputs['Edges'].is_linked or self.inputs['Faces'].is_linked)): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") + if not (self.inputs['Edges'].is_linked or self.inputs['Faces'].is_linked): + raise Exception(f"Input socket '{self.inputs['Edges'].label or self.inputs['Edges'].identifier}' or '{self.inputs['Faces'].label or self.inputs['Faces'].identifier}' has to be connected") out = [] for v, e, f in zip(*[sock.sv_get(deepcopy=False) if sock.is_linked else cycle([None]) for sock in self.inputs]): diff --git a/nodes/modifier_change/split_mesh_elements.py b/nodes/modifier_change/split_mesh_elements.py index 27658b77e5..ae51f1bcc9 100644 --- a/nodes/modifier_change/split_mesh_elements.py +++ b/nodes/modifier_change/split_mesh_elements.py @@ -142,6 +142,9 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'FaceData') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + vertices = self.inputs['Vertices'].sv_get(deepcopy=False, default=[]) edges = self.inputs['Edges'].sv_get(deepcopy=False, default=[]) faces = self.inputs['Faces'].sv_get(deepcopy=False, default=[]) diff --git a/nodes/modifier_change/subdivide_mk2.py b/nodes/modifier_change/subdivide_mk2.py index 50a5833f0a..4aac969cf3 100644 --- a/nodes/modifier_change/subdivide_mk2.py +++ b/nodes/modifier_change/subdivide_mk2.py @@ -270,6 +270,9 @@ def dont_process(self): return not (any(s.is_linked for s in outputs) and all(s.is_linked for s in inputs[:2])) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + inputs, outputs = self.inputs, self.outputs if self.dont_process(): diff --git a/nodes/modifier_change/triangulate.py b/nodes/modifier_change/triangulate.py index fdfa6eaf2a..098945a7f6 100644 --- a/nodes/modifier_change/triangulate.py +++ b/nodes/modifier_change/triangulate.py @@ -77,11 +77,13 @@ def draw_buttons(self, context, layout): layout.prop(self, "ngon_mode") def process(self): - if not (self.inputs['Vertices'].is_linked and self.inputs['Polygons'].is_linked): + if not any(socket.is_linked for socket in self.outputs): return - if not (any(self.outputs[name].is_linked for name in ['Vertices', 'Edges', 'Polygons', 'NewEdges', 'NewPolys'])): - return - + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + if not (self.inputs["Polygons"].is_linked): + raise Exception(f"Input socket '{self.inputs['Polygons'].label or self.inputs['Polygons'].identifier}' has to be connected") + vertices_s = self.inputs['Vertices'].sv_get(default=[[]], deepcopy=False) edges_s = self.inputs['Edges'].sv_get(default=[[]], deepcopy=False) faces_s = self.inputs['Polygons'].sv_get(default=[[]], deepcopy=False) diff --git a/nodes/modifier_change/vertices_mask.py b/nodes/modifier_change/vertices_mask.py index 473df3837c..1c77283594 100644 --- a/nodes/modifier_change/vertices_mask.py +++ b/nodes/modifier_change/vertices_mask.py @@ -48,42 +48,46 @@ def sv_internal_links(self): ] def process(self): - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return - if self.inputs['Vertices'].is_linked and self.inputs['Poly Egde'].is_linked: - verts = self.inputs['Vertices'].sv_get(deepcopy=False) - poly = self.inputs['Poly Egde'].sv_get(deepcopy=False) - verts = dataCorrect(verts) - poly = dataCorrect(poly) - self.inputs['Mask'].sv_get(default=[[1, 0]]) - - verts_out = [] - poly_edge_out = [] - - if self.inputs['Mask'].is_linked: - mask = self.inputs['Mask'].sv_get(deepcopy=False) - else: - mask = [[1, 0]] - - for ve, pe, ma in zip(verts, poly, repeat_last(mask)): - current_mask = islice(cycle(ma), len(ve)) - vert_index = [i for i, m in enumerate(current_mask) if m] - if len(vert_index) < len(ve): - index_set = set(vert_index) - vert_dict = {j: i for i, j in enumerate(vert_index)} - new_vert = [ve[i] for i in vert_index] - is_ss = index_set.issuperset - new_pe = [[vert_dict[n] for n in fe] - for fe in pe if is_ss(fe)] - verts_out.append(new_vert) - poly_edge_out.append(new_pe) - - else: # no reprocessing needed - verts_out.append(ve) - poly_edge_out.append(pe) - - self.outputs['Vertices'].sv_set(verts_out) - self.outputs['Poly Egde'].sv_set(poly_edge_out) + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + if not (self.inputs["Poly Egde"].is_linked): + raise Exception(f"Input socket '{self.inputs['Poly Egde'].label or self.inputs['Poly Egde'].identifier}' has to be connected") + + verts = self.inputs['Vertices'].sv_get(deepcopy=False) + poly = self.inputs['Poly Egde'].sv_get(deepcopy=False) + verts = dataCorrect(verts) + poly = dataCorrect(poly) + self.inputs['Mask'].sv_get(default=[[1, 0]]) + + verts_out = [] + poly_edge_out = [] + + if self.inputs['Mask'].is_linked: + mask = self.inputs['Mask'].sv_get(deepcopy=False) + else: + mask = [[1, 0]] + + for ve, pe, ma in zip(verts, poly, repeat_last(mask)): + current_mask = islice(cycle(ma), len(ve)) + vert_index = [i for i, m in enumerate(current_mask) if m] + if len(vert_index) < len(ve): + index_set = set(vert_index) + vert_dict = {j: i for i, j in enumerate(vert_index)} + new_vert = [ve[i] for i in vert_index] + is_ss = index_set.issuperset + new_pe = [[vert_dict[n] for n in fe] + for fe in pe if is_ss(fe)] + verts_out.append(new_vert) + poly_edge_out.append(new_pe) + + else: # no reprocessing needed + verts_out.append(ve) + poly_edge_out.append(pe) + + self.outputs['Vertices'].sv_set(verts_out) + self.outputs['Poly Egde'].sv_set(poly_edge_out) def register(): diff --git a/nodes/modifier_make/bevel_curve.py b/nodes/modifier_make/bevel_curve.py index e62bd96991..2d3e00d6f0 100644 --- a/nodes/modifier_make/bevel_curve.py +++ b/nodes/modifier_make/bevel_curve.py @@ -358,7 +358,7 @@ def make_bevel(self, curve, bevel_verts, bevel_edges, bevel_faces, taper, twist, return mesh def process(self): - if not any(o.is_linked for o in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return curves_s = self.inputs['Curve'].sv_get(default=[[]]) diff --git a/nodes/modifier_make/clip_verts.py b/nodes/modifier_make/clip_verts.py index 494322edde..6652196a79 100644 --- a/nodes/modifier_make/clip_verts.py +++ b/nodes/modifier_make/clip_verts.py @@ -44,7 +44,7 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'Faces') def process(self): - if not any((s.is_linked for s in self.outputs)): + if not any(socket.is_linked for socket in self.outputs): return verts_s = self.inputs['Vertices'].sv_get() diff --git a/nodes/modifier_make/contour2D.py b/nodes/modifier_make/contour2D.py index b072ddbb65..76d559dc1c 100644 --- a/nodes/modifier_make/contour2D.py +++ b/nodes/modifier_make/contour2D.py @@ -688,12 +688,10 @@ def generate_outlines(self, output_lists, params): output_lists[1].append(edges_out) def process(self): - - inputs, outputs = self.inputs, self.outputs - if not outputs['Vertices'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return - - + + inputs, outputs = self.inputs, self.outputs output_lists = [[], []] _ = [self.generate_outlines(output_lists, params) for params in zip(*self.get_inputs())] diff --git a/nodes/modifier_make/csg_booleanMK2.py b/nodes/modifier_make/csg_booleanMK2.py index 99017f9418..f3deaa4927 100644 --- a/nodes/modifier_make/csg_booleanMK2.py +++ b/nodes/modifier_make/csg_booleanMK2.py @@ -116,6 +116,9 @@ def draw_buttons(self, context, layout): col.prop(self, "out_last", toggle=True) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + OutV, OutP = self.outputs if not OutV.is_linked: return diff --git a/nodes/modifier_make/dual_mesh.py b/nodes/modifier_make/dual_mesh.py index b4c1155511..6b4cbe5749 100644 --- a/nodes/modifier_make/dual_mesh.py +++ b/nodes/modifier_make/dual_mesh.py @@ -50,7 +50,7 @@ def sv_internal_links(self): ] def process(self): - if not any((s.is_linked for s in self.outputs)): + if not any(socket.is_linked for socket in self.outputs): return verts_s = self.inputs['Vertices'].sv_get() diff --git a/nodes/modifier_make/edges_adaptative.py b/nodes/modifier_make/edges_adaptative.py index 402f7d8851..7db170f979 100644 --- a/nodes/modifier_make/edges_adaptative.py +++ b/nodes/modifier_make/edges_adaptative.py @@ -47,7 +47,7 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'Edges') def process(self): - if not all(s.is_linked for s in self.inputs): + if not any(socket.is_linked for socket in self.outputs): return versR = Vector_generate(self.inputs['VersR'].sv_get()) diff --git a/nodes/modifier_make/fractal_curve.py b/nodes/modifier_make/fractal_curve.py index e16610ee7d..6e99fe6187 100644 --- a/nodes/modifier_make/fractal_curve.py +++ b/nodes/modifier_make/fractal_curve.py @@ -156,7 +156,7 @@ def sv_internal_links(self): return [(self.inputs['Vertices'], self.outputs[0])] def process(self): - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return curves = Vector_generate(self.inputs['Vertices'].sv_get()) diff --git a/nodes/modifier_make/framework.py b/nodes/modifier_make/framework.py index 1196d31636..394666b304 100644 --- a/nodes/modifier_make/framework.py +++ b/nodes/modifier_make/framework.py @@ -258,7 +258,7 @@ def is_same_edge(self, v1, v2, e1, e2): return is_in_segment(e1, e2, v1) or is_in_segment(e1, e2, v2) def process(self): - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return verts_in = self.inputs['Vertices'].sv_get() diff --git a/nodes/modifier_make/join_tris.py b/nodes/modifier_make/join_tris.py index 1943d12873..1dbb8c63d4 100644 --- a/nodes/modifier_make/join_tris.py +++ b/nodes/modifier_make/join_tris.py @@ -85,8 +85,12 @@ def draw_buttons(self, context, layout): col.prop(self, 'shape_threshold', text='shape') def process(self): - if not self.outputs['Polygons'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + if not (self.inputs["Polygons"].is_linked): + raise Exception(f"Input socket '{self.inputs['Polygons'].label or self.inputs['Polygons'].identifier}' has to be connected") verts = self.inputs['Vertices'].sv_get() faces = self.inputs['Polygons'].sv_get() diff --git a/nodes/modifier_make/lathe.py b/nodes/modifier_make/lathe.py index d0ede24907..7e4bbf9f3d 100644 --- a/nodes/modifier_make/lathe.py +++ b/nodes/modifier_make/lathe.py @@ -75,14 +75,11 @@ def draw_buttons(self, context, layout): row = layout.row(align=True) row.prop(self, "remove_doubles", text="merge") - def nothing_to_process(self): - if not (self.inputs['Verts'].links and self.outputs['Verts'].links): - return True - def process(self): - - if self.nothing_to_process(): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") inputs = self.inputs diff --git a/nodes/modifier_make/matrix_tube.py b/nodes/modifier_make/matrix_tube.py index 347f0136f2..6b14c38c10 100644 --- a/nodes/modifier_make/matrix_tube.py +++ b/nodes/modifier_make/matrix_tube.py @@ -48,8 +48,9 @@ def sv_internal_links(self): return [(self.inputs['Vertices'], self.outputs['Vertices'])] def process(self): - if not self.outputs['Vertices'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + vertices = Vector_generate(self.inputs['Vertices'].sv_get()) matrices = Matrix_generate(self.inputs['Matrices'].sv_get()) verts_out, edges_out, faces_out = self.make_tube(matrices, vertices) diff --git a/nodes/modifier_make/offset_line.py b/nodes/modifier_make/offset_line.py index 6bd733b7a1..f6f76a1453 100644 --- a/nodes/modifier_make/offset_line.py +++ b/nodes/modifier_make/offset_line.py @@ -208,13 +208,13 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "VersMask") def process(self): - - if not all(socket.is_linked for socket in self.inputs[:2]): - raise SvNotFullyConnected(self, sockets=["Vers", "Edgs"]) - if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["Vers"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vers'].label or self.inputs['Vers'].identifier}' has to be connected") + if not (self.inputs["Edgs"].is_linked): + raise Exception(f"Input socket '{self.inputs['Edgs'].label or self.inputs['Edgs'].identifier}' has to be connected") + verts_in = self.inputs['Vers'].sv_get() edges_in = self.inputs['Edgs'].sv_get() shifter = self.inputs['Offset'].sv_get() diff --git a/nodes/modifier_make/pipe_tubes.py b/nodes/modifier_make/pipe_tubes.py index 3c37c622aa..8cb68ba016 100644 --- a/nodes/modifier_make/pipe_tubes.py +++ b/nodes/modifier_make/pipe_tubes.py @@ -62,24 +62,25 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', "Pols") def process(self): - - if self.outputs['Vers'].is_linked and self.inputs['Vers'].is_linked: - Vecs = self.inputs['Vers'].sv_get() - Edgs = self.inputs['Edgs'].sv_get() - #Nsides = max(self.inputs['Sides'].sv_get()[0][0], 4) - Shape = self.shape - Cup = self.cup_fill - #Diameter = self.inputs['Diameter'].sv_get()[0][0] - Diameter = 1.0 - Size = self.inputs['Size'].sv_get()[0] - #Offset = self.inputs['Offset'].sv_get()[0][0] - #Extrude = self.inputs['Extrude'].sv_get()[0][0] - outv, outp = self.Do_vecs(Vecs,Edgs,Diameter,Shape,Size,Cup) #Nsides,Offset,Extrude) - - if self.outputs['Vers'].is_linked: - self.outputs['Vers'].sv_set(outv) - if self.outputs['Pols'].is_linked: - self.outputs['Pols'].sv_set(outp) + if not any(socket.is_linked for socket in self.outputs): + return + + Vecs = self.inputs['Vers'].sv_get() + Edgs = self.inputs['Edgs'].sv_get() + #Nsides = max(self.inputs['Sides'].sv_get()[0][0], 4) + Shape = self.shape + Cup = self.cup_fill + #Diameter = self.inputs['Diameter'].sv_get()[0][0] + Diameter = 1.0 + Size = self.inputs['Size'].sv_get()[0] + #Offset = self.inputs['Offset'].sv_get()[0][0] + #Extrude = self.inputs['Extrude'].sv_get()[0][0] + outv, outp = self.Do_vecs(Vecs,Edgs,Diameter,Shape,Size,Cup) #Nsides,Offset,Extrude) + + if self.outputs['Vers'].is_linked: + self.outputs['Vers'].sv_set(outv) + if self.outputs['Pols'].is_linked: + self.outputs['Pols'].sv_set(outp) def Do_vecs(self, Vecs,Edgs,Diameter,Shape,Size,Cup): #Offset,Extrude): diff --git a/nodes/modifier_make/solidify_mk2.py b/nodes/modifier_make/solidify_mk2.py index bdd40f50e3..8d3184a1af 100644 --- a/nodes/modifier_make/solidify_mk2.py +++ b/nodes/modifier_make/solidify_mk2.py @@ -199,11 +199,12 @@ def draw_buttons_ext(self, context, layout): self.draw_buttons(context, layout) def process(self): - if not any((s.is_linked for s in self.outputs)): - return - - if not (self.inputs['Vertices'].is_linked and self.inputs['Polygons'].is_linked): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + if not (self.inputs["Polygons"].is_linked): + raise Exception(f"Input socket '{self.inputs['Polygons'].label or self.inputs['Polygons'].identifier}' has to be connected") verts = self.inputs['Vertices'].sv_get(deepcopy=False) edges = self.inputs['Edges'].sv_get(deepcopy=False, default=[[]]) diff --git a/nodes/modifier_make/sweep_modulator.py b/nodes/modifier_make/sweep_modulator.py index ffb4b9d728..68aa70d2ea 100644 --- a/nodes/modifier_make/sweep_modulator.py +++ b/nodes/modifier_make/sweep_modulator.py @@ -177,6 +177,9 @@ def mix(self, verts_a, verts_b, factors, divider=0): def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + """ [ ] provide virtual Shape index shifting, - shifts the vertices in-situ of A or B to match the other diff --git a/nodes/modifier_make/unsubdivide.py b/nodes/modifier_make/unsubdivide.py index 01d4a502fd..01e890518d 100644 --- a/nodes/modifier_make/unsubdivide.py +++ b/nodes/modifier_make/unsubdivide.py @@ -65,6 +65,13 @@ def sv_internal_links(self): def draw_buttons_ext(self, context, layout): layout.prop(self, 'show_bmesh_list') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Vert"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vert'].label or self.inputs['Vert'].identifier}' has to be connected") + if not (self.inputs["Poly"].is_linked): + raise Exception(f"Input socket '{self.inputs['Poly'].label or self.inputs['Poly'].identifier}' has to be connected") + bmL, V, P, mask, Iterate = self.inputs Val = bmL.sv_get([]) diff --git a/nodes/modifier_make/uv_connect.py b/nodes/modifier_make/uv_connect.py index 66b496c36b..68924c73d2 100644 --- a/nodes/modifier_make/uv_connect.py +++ b/nodes/modifier_make/uv_connect.py @@ -236,26 +236,30 @@ def sv_update(self): multi_socket(self, min=1) def process(self): - if self.inputs[0].is_linked: - slots = [socket.sv_get() for socket in self.inputs if socket.is_linked] - lol = levelsOflist(slots) - if lol == 4: - one, two = self.connect(slots, self.dir_check, self.cicl_check_U, self.cicl_check_V, lol, self.polygons, self.slice_check, self.cap_U, self.cap_V) - elif lol == 5: - one = [] - two = [] - for slo in slots: - for s in slo: - result = self.connect([s], self.dir_check, self.cicl_check_U, self.cicl_check_V, lol, self.polygons, self.slice_check, self.cap_U, self.cap_V) - one.extend(result[0]) - two.extend(result[1]) - else: - return - - if self.outputs['vertices'].is_linked: - self.outputs['vertices'].sv_set(one) - if self.outputs['data'].is_linked: - self.outputs['data'].sv_set(two) + if not any(socket.is_linked for socket in self.outputs): + return + if not any(socket.is_linked for socket in self.inputs): + raise Exception(f"Input sockets 'vertices' has to be connected") + + slots = [socket.sv_get() for socket in self.inputs if socket.is_linked] + lol = levelsOflist(slots) + if lol == 4: + one, two = self.connect(slots, self.dir_check, self.cicl_check_U, self.cicl_check_V, lol, self.polygons, self.slice_check, self.cap_U, self.cap_V) + elif lol == 5: + one = [] + two = [] + for slo in slots: + for s in slo: + result = self.connect([s], self.dir_check, self.cicl_check_U, self.cicl_check_V, lol, self.polygons, self.slice_check, self.cap_U, self.cap_V) + one.extend(result[0]) + two.extend(result[1]) + else: + return + + if self.outputs['vertices'].is_linked: + self.outputs['vertices'].sv_set(one) + if self.outputs['data'].is_linked: + self.outputs['data'].sv_set(two) def register(): diff --git a/nodes/modifier_make/wafel.py b/nodes/modifier_make/wafel.py index 5882fd7b93..68563eaea3 100644 --- a/nodes/modifier_make/wafel.py +++ b/nodes/modifier_make/wafel.py @@ -220,7 +220,9 @@ def get_coplanar(self,vec, loc_cont, norm_cont,vec_cont): def process(self): - + if not any(socket.is_linked for socket in self.outputs): + return + if 'vecLine' in self.inputs and \ 'vecPlane' in self.inputs and \ 'edgPlane' in self.inputs: diff --git a/nodes/modifier_make/wireframe.py b/nodes/modifier_make/wireframe.py index 1428d5b890..12faf1faae 100644 --- a/nodes/modifier_make/wireframe.py +++ b/nodes/modifier_make/wireframe.py @@ -100,10 +100,14 @@ def draw_buttons(self, context, layout): layout.prop(self, 'replace', text="Replace") def process(self): - inputs, outputs = self.inputs, self.outputs - - if not all(s.is_linked for s in [inputs['vertices'], inputs['polygons']]): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['vertices'].label or self.inputs['vertices'].identifier}' has to be connected") + if not (self.inputs["polygons"].is_linked): + raise Exception(f"Input socket '{self.inputs['polygons'].label or self.inputs['polygons'].identifier}' has to be connected") + + inputs, outputs = self.inputs, self.outputs poly_or_edge_linked = (outputs['edges'].is_linked or outputs['polygons'].is_linked) if not (outputs['vertices'].is_linked and poly_or_edge_linked): diff --git a/nodes/network/file_path.py b/nodes/network/file_path.py index ab2b9dd7d4..7df6d073d5 100644 --- a/nodes/network/file_path.py +++ b/nodes/network/file_path.py @@ -93,6 +93,7 @@ def set_data(self, dirname, files): def process(self): if not any(socket.is_linked for socket in self.outputs): return + directory = self.directory if self.files: files = [] diff --git a/nodes/number/curve_mapper.py b/nodes/number/curve_mapper.py index 2dbd35750c..6298cdbbfe 100644 --- a/nodes/number/curve_mapper.py +++ b/nodes/number/curve_mapper.py @@ -102,6 +102,7 @@ def _get_curve_node_name(self): def process(self): if not any(socket.is_linked for socket in self.outputs): return + inputs = self.inputs outputs = self.outputs curve_node_name = self._get_curve_node_name() diff --git a/nodes/number/exponential.py b/nodes/number/exponential.py index 1d1ae82eb1..23a06e6fca 100644 --- a/nodes/number/exponential.py +++ b/nodes/number/exponential.py @@ -116,6 +116,7 @@ def draw_buttons(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + # inputs x0 = self.inputs['X0'].sv_get()[0] alpha = self.inputs['Alpha'].sv_get()[0] diff --git a/nodes/number/fibonacci.py b/nodes/number/fibonacci.py index d90f956b23..be896e5191 100644 --- a/nodes/number/fibonacci.py +++ b/nodes/number/fibonacci.py @@ -79,6 +79,7 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + # inputs x1 = self.inputs['X1'].sv_get()[0] x2 = self.inputs['X2'].sv_get()[0] diff --git a/nodes/number/number_range.py b/nodes/number/number_range.py index 122d62e2e7..290dd39552 100644 --- a/nodes/number/number_range.py +++ b/nodes/number/number_range.py @@ -211,6 +211,7 @@ def migrate_from(self, old_node): def process(self): if not any(socket.is_linked for socket in self.outputs): return + inputs = self.inputs outputs = self.outputs diff --git a/nodes/number/oscillator.py b/nodes/number/oscillator.py index 186e19101a..89d4be4801 100644 --- a/nodes/number/oscillator.py +++ b/nodes/number/oscillator.py @@ -177,18 +177,17 @@ def update_sockets(self): def process(self): if not any(socket.is_linked for socket in self.outputs): return - - if self.outputs[0].is_linked: - if self.current_op == 'Custom' and not self.inputs["Wave"].is_linked: - return - params = [si.sv_get(default=[[]], deepcopy=False) for si in self.inputs[:6]] - matching_f = list_match_func[self.list_match] - spline_func = CubicSpline if self.wave_interp_mode == 'SPL' else LinearSpline - desired_levels = [2, 2, 2, 2, 2, 3] - ops = [self.current_op, spline_func, self.knot_mode, self.list_match, self.output_numpy] - result = recurse_f_level_control(params, ops, oscillator, matching_f, desired_levels) - - self.outputs[0].sv_set(result) + + if self.current_op == 'Custom' and not self.inputs["Wave"].is_linked: + return + params = [si.sv_get(default=[[]], deepcopy=False) for si in self.inputs[:6]] + matching_f = list_match_func[self.list_match] + spline_func = CubicSpline if self.wave_interp_mode == 'SPL' else LinearSpline + desired_levels = [2, 2, 2, 2, 2, 3] + ops = [self.current_op, spline_func, self.knot_mode, self.list_match, self.output_numpy] + result = recurse_f_level_control(params, ops, oscillator, matching_f, desired_levels) + + self.outputs[0].sv_set(result) classes = [SvOscillatorNode] diff --git a/nodes/number/random_num_gen.py b/nodes/number/random_num_gen.py index aa8f4949bf..864fac4dc2 100644 --- a/nodes/number/random_num_gen.py +++ b/nodes/number/random_num_gen.py @@ -300,6 +300,7 @@ def produce_range(self, *params): def process(self): if not any(socket.is_linked for socket in self.outputs): return + inputs = self.inputs outputs = self.outputs mode = self.type_selected_mode diff --git a/nodes/number/range_map.py b/nodes/number/range_map.py index 606c5a00ef..df52ab70b3 100644 --- a/nodes/number/range_map.py +++ b/nodes/number/range_map.py @@ -143,6 +143,7 @@ def rclick_menu(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + inputs = self.inputs params = [si.sv_get(default=[[]], deepcopy=False) for si in inputs] diff --git a/nodes/object_nodes/armature_analyzer.py b/nodes/object_nodes/armature_analyzer.py index 5d2fd890ea..2d7ca37f2f 100644 --- a/nodes/object_nodes/armature_analyzer.py +++ b/nodes/object_nodes/armature_analyzer.py @@ -42,6 +42,7 @@ def sv_init(self, context): def process(self): if not any(socket.is_linked for socket in self.outputs): return + armobj, selm = self.inputs if armobj.is_linked==False: raise Exception("Input socket 'Armature Object' has to be connected") diff --git a/nodes/pulga_physics/pulga_angle_force.py b/nodes/pulga_physics/pulga_angle_force.py index b41ca22057..d4595c42b5 100644 --- a/nodes/pulga_physics/pulga_angle_force.py +++ b/nodes/pulga_physics/pulga_angle_force.py @@ -67,6 +67,7 @@ def process(self): return if not (self.inputs["Edge_Pol"].is_linked): raise Exception(f"Input socket '{self.inputs['Edge_Pol'].label}' has to be connected") + springs_in = self.inputs["Edge_Pol"].sv_get(deepcopy=False) stiffness_in = self.inputs["Stiffness"].sv_get(deepcopy=False) lengths_in = self.inputs["Angle"].sv_get(deepcopy=False) diff --git a/nodes/pulga_physics/pulga_attraction_force.py b/nodes/pulga_physics/pulga_attraction_force.py index a5b901d721..39c59ce715 100644 --- a/nodes/pulga_physics/pulga_attraction_force.py +++ b/nodes/pulga_physics/pulga_attraction_force.py @@ -70,6 +70,7 @@ def draw_buttons(self, context, layout): def process(self): if not any(socket.is_linked for socket in self.outputs): return + strength = self.inputs["Strength"].sv_get(deepcopy=False) decay = self.inputs["Decay"].sv_get(deepcopy=False) max_distance = self.inputs["Max Distance"].sv_get(deepcopy=False) diff --git a/nodes/scene/FCurve_in.py b/nodes/scene/FCurve_in.py index 8a7aedd935..3951880d3b 100644 --- a/nodes/scene/FCurve_in.py +++ b/nodes/scene/FCurve_in.py @@ -111,6 +111,7 @@ def evaluate(self, frames): def process(self): if not any(socket.is_linked for socket in self.outputs): return + """ - if no input is given then the node will use current frame in bpy.context.scene - if input is given, behaviour depends on 2 things: diff --git a/nodes/surface/apply_field_to_surface.py b/nodes/surface/apply_field_to_surface.py index c1f894a010..c0e9153838 100644 --- a/nodes/surface/apply_field_to_surface.py +++ b/nodes/surface/apply_field_to_surface.py @@ -55,8 +55,8 @@ def process(self): if not any(socket.is_linked for socket in self.outputs): return - surface_s = self.inputs['Surface'].sv_get() field_s = self.inputs['Field'].sv_get() + surface_s = self.inputs['Surface'].sv_get() coeff_s = self.inputs['Coefficient'].sv_get() surface_out = [] diff --git a/nodes/surface/minimal_surface.py b/nodes/surface/minimal_surface.py index bdeff14092..d93e7d63b5 100644 --- a/nodes/surface/minimal_surface.py +++ b/nodes/surface/minimal_surface.py @@ -140,7 +140,6 @@ def distance(v1, v2): return np.array(us), np.array(vs) def process(self): - if not any(socket.is_linked for socket in self.outputs): return diff --git a/nodes/surface/nurbs_surface.py b/nodes/surface/nurbs_surface.py index 46cd77907d..603d3e2c79 100644 --- a/nodes/surface/nurbs_surface.py +++ b/nodes/surface/nurbs_surface.py @@ -135,6 +135,9 @@ def draw_buttons(self, context, layout): row.prop(self, 'is_cyclic_v', toggle=True) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + vertices_s = self.inputs['ControlPoints'].sv_get() has_weights = self.inputs['Weights'].is_linked weights_s = self.inputs['Weights'].sv_get(default = [[1.0]]) diff --git a/nodes/svg/circle_svg.py b/nodes/svg/circle_svg.py index 851952d302..88340d8eae 100644 --- a/nodes/svg/circle_svg.py +++ b/nodes/svg/circle_svg.py @@ -103,9 +103,9 @@ def draw_buttons(self, context, layout): layout.prop(self, "ungroup") def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + params_in = [s.sv_get(deepcopy=False) for s in self.inputs[:4]] params_in.append(self.inputs['Fill / Stroke'].sv_get(deepcopy=False, default=[[None]])) get_curves = self.outputs['Curves'].is_linked diff --git a/nodes/svg/dimensions_svg_mk2.py b/nodes/svg/dimensions_svg_mk2.py index 581de2f88a..290f8516ac 100644 --- a/nodes/svg/dimensions_svg_mk2.py +++ b/nodes/svg/dimensions_svg_mk2.py @@ -273,9 +273,9 @@ def draw_buttons(self, context, layout): layout.prop(self, "user_font") def process(self): - - if not self.outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + params_in = [s.sv_get(deepcopy=False) for s in self.inputs[:7]] texts_out = [] params_in.append(self.inputs['Text Fill / Stroke'].sv_get(deepcopy=False, default=[[None]])) diff --git a/nodes/svg/fill_stroke_mk2.py b/nodes/svg/fill_stroke_mk2.py index 429fe7dafa..6643b1c57f 100644 --- a/nodes/svg/fill_stroke_mk2.py +++ b/nodes/svg/fill_stroke_mk2.py @@ -204,9 +204,9 @@ def get_data(self): return mlr([fill, stroke, stroke_width, dash_pattern]) def process(self): - - if not self.outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + params_in = [s.sv_get(deepcopy=False, default=[[None]]) for s in self.inputs] params_in = self.get_data() diff --git a/nodes/svg/group_svg.py b/nodes/svg/group_svg.py index 397b6fd30b..ed229e35a0 100644 --- a/nodes/svg/group_svg.py +++ b/nodes/svg/group_svg.py @@ -49,9 +49,9 @@ def draw_buttons(self, context, layout): layout.prop(self, 'group_name') def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + objs_in = self.inputs['SVG Objects'].sv_get(deepcopy=False) locs_in = self.inputs['Offset'].sv_get(deepcopy=False, default=None) if locs_in: diff --git a/nodes/svg/mesh_svg.py b/nodes/svg/mesh_svg.py index e03b0994ed..48e3f676d5 100644 --- a/nodes/svg/mesh_svg.py +++ b/nodes/svg/mesh_svg.py @@ -221,8 +221,7 @@ def draw_buttons(self,context,layout): layout.prop(self, 'invert_sort') def process(self): - - if not self.outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return verts_in = self.inputs['Vertices'].sv_get(deepcopy=True) diff --git a/nodes/svg/path_svg_mk2.py b/nodes/svg/path_svg_mk2.py index a15c263c49..1824f8278c 100644 --- a/nodes/svg/path_svg_mk2.py +++ b/nodes/svg/path_svg_mk2.py @@ -189,9 +189,9 @@ def draw_buttons(self, context, layout): layout.prop(self, "cyclic", expand=True) def process(self): - - if not self.outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if self.mode == "CURVE": curves_in = self.inputs['Curve'].sv_get(deepcopy=False) atts_in = self.inputs['Fill / Stroke'].sv_get(deepcopy=False, default=[[None]]) diff --git a/nodes/svg/pattern_svg.py b/nodes/svg/pattern_svg.py index 8e811f7c34..c9b5970427 100644 --- a/nodes/svg/pattern_svg.py +++ b/nodes/svg/pattern_svg.py @@ -89,8 +89,7 @@ def draw_buttons(self, context, layout): layout.prop(self, 'pattern_name') def process(self): - - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return objs_in = self.inputs['SVG Objects'].sv_get(deepcopy=False, default=None) diff --git a/nodes/svg/text_svg.py b/nodes/svg/text_svg.py index 37ebcaae03..47515ff072 100644 --- a/nodes/svg/text_svg.py +++ b/nodes/svg/text_svg.py @@ -133,9 +133,9 @@ def draw_buttons(self, context, layout): layout.prop(self, "weight", expand=True) def process(self): - - if not self.outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + params_in = [s.sv_get(deepcopy=False) for s in self.inputs[:4]] texts_out = [] params_in.append(self.inputs['Fill / Stroke'].sv_get(deepcopy=False, default=[[None]])) diff --git a/nodes/text/datetime_strings.py b/nodes/text/datetime_strings.py index 4c45c35904..08145b6710 100644 --- a/nodes/text/datetime_strings.py +++ b/nodes/text/datetime_strings.py @@ -110,7 +110,9 @@ def sub_ordinal(self, value): return f / seconds_in_day def process(self): - + if not any(socket.is_linked for socket in self.outputs): + return + V1 = self.inputs["times"].sv_get() V2 = self.inputs["time offset"].sv_get() diff --git a/nodes/text/shape.py b/nodes/text/shape.py index c888729a25..03bd57d38e 100644 --- a/nodes/text/shape.py +++ b/nodes/text/shape.py @@ -48,6 +48,11 @@ def process(self): self.outputs['Text Out'].sv_set(self.text) else: self.text = "No data" + + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Data"].is_linked): + raise Exception(f"Input socket '{self.inputs['Data'].label or self.inputs['Data'].identifier}' has to be connected") def sv_copy(self, node): diff --git a/nodes/text/string_tools.py b/nodes/text/string_tools.py index 6a9ace16f3..b6bc1490a6 100644 --- a/nodes/text/string_tools.py +++ b/nodes/text/string_tools.py @@ -286,20 +286,21 @@ def update_sockets(self): self.outputs.new('SvStringsSocket', 'Out') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return - if self.outputs[0].is_linked: - current_func = func_from_mode(self.current_op) - params = [si.sv_get(default=[[]], deepcopy=False) for si in self.inputs] - matching_f = list_match_func[self.list_match] - desired_levels = [2 if self.current_op=='join_all' else 1]*len(params) - inputs_signature = self.sockets_signature.split(' ')[0] - ops = [current_func, inputs_signature] - if self.current_op == 'to_string': - depth = levels_of_list_or_np(params[0]) - desired_levels= [max(depth-self.level + 1, 1)] - result = recurse_f_level_control(params, ops, string_tools, matching_f, desired_levels) - - self.outputs[0].sv_set(result) + current_func = func_from_mode(self.current_op) + params = [si.sv_get(default=[[]], deepcopy=False) for si in self.inputs] + matching_f = list_match_func[self.list_match] + desired_levels = [2 if self.current_op=='join_all' else 1]*len(params) + inputs_signature = self.sockets_signature.split(' ')[0] + ops = [current_func, inputs_signature] + if self.current_op == 'to_string': + depth = levels_of_list_or_np(params[0]) + desired_levels= [max(depth-self.level + 1, 1)] + result = recurse_f_level_control(params, ops, string_tools, matching_f, desired_levels) + + self.outputs[0].sv_set(result) classes = [SvStringsToolsNode] register, unregister = bpy.utils.register_classes_factory(classes) diff --git a/nodes/transforms/align_mesh_by_mesh.py b/nodes/transforms/align_mesh_by_mesh.py index e7d4d159b6..d4bfc3369c 100644 --- a/nodes/transforms/align_mesh_by_mesh.py +++ b/nodes/transforms/align_mesh_by_mesh.py @@ -75,8 +75,9 @@ def draw_move_sock(self, socket, context, layout): layout.prop(self, 'align_moved_mesh', expand=True) def process(self): - if not self.inputs['Move mesh'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if not self.axis: self.outputs['Verts'].sv_set(self.inputs['Move mesh'].sv_get()) self.outputs['Move vector'].sv_set([[(0, 0, 0)]]) diff --git a/nodes/transforms/apply.py b/nodes/transforms/apply.py index 9cf0f76018..f32883679e 100644 --- a/nodes/transforms/apply.py +++ b/nodes/transforms/apply.py @@ -50,9 +50,9 @@ def rclick_menu(self, context, layout): layout.prop(self, "output_numpy", expand=False) def process(self): - if not self.inputs['Vectors'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return - + vertices = self.inputs['Vectors'].sv_get(deepcopy=False) matrices = self.inputs['Matrixes'].sv_get(deepcopy=False, default=[]) diff --git a/nodes/transforms/barycentric_transform.py b/nodes/transforms/barycentric_transform.py index 75cb5d1d82..20a5de716a 100644 --- a/nodes/transforms/barycentric_transform.py +++ b/nodes/transforms/barycentric_transform.py @@ -160,11 +160,12 @@ def get_data(self): def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + '''main node function called every update''' outputs = self.outputs inputs = self.inputs - if not (outputs[0].is_linked and all(s.is_linked for s in inputs[:1] + inputs[2:])): - return result = [[], []] out_numpy = self.output_numpy diff --git a/nodes/transforms/bend_along_path.py b/nodes/transforms/bend_along_path.py index 29732906df..300aaf56cf 100644 --- a/nodes/transforms/bend_along_path.py +++ b/nodes/transforms/bend_along_path.py @@ -158,8 +158,6 @@ def get_matrix(self, tangent, scale): def process(self): if not any(socket.is_linked for socket in self.outputs): return - if not self.inputs['Vertices'].is_linked: - return vertices_s = self.inputs['Vertices'].sv_get() paths = self.inputs['Path'].sv_get() diff --git a/nodes/transforms/bend_along_surface.py b/nodes/transforms/bend_along_surface.py index 21f0e4890d..d39daf6355 100644 --- a/nodes/transforms/bend_along_surface.py +++ b/nodes/transforms/bend_along_surface.py @@ -169,8 +169,6 @@ def get_uv(self, vertices): def process(self): if not any(socket.is_linked for socket in self.outputs): return - if not self.inputs['Vertices'].is_linked: - return vertices_s = self.inputs['Vertices'].sv_get() vertices_s = ensure_nesting_level(vertices_s, 4) diff --git a/nodes/transforms/cast.py b/nodes/transforms/cast.py index a21abbe0a3..c66d61656c 100644 --- a/nodes/transforms/cast.py +++ b/nodes/transforms/cast.py @@ -276,13 +276,11 @@ def draw_label(self): return self.label or self.name + ' to ' + self.cast_mode.title() def process(self): - inputs, outputs = self.inputs, self.outputs - - if not outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return - + + inputs, outputs = self.inputs, self.outputs result = [] - params = [si.sv_get(default=[[]], deepcopy=False) for si in inputs] matching_f = list_match_func[self.list_match] diff --git a/nodes/transforms/deform.py b/nodes/transforms/deform.py index 2e047d6c2a..c8dda56b71 100644 --- a/nodes/transforms/deform.py +++ b/nodes/transforms/deform.py @@ -146,9 +146,10 @@ def taper(self, mins, maxs, low_limit, hi_limit, factor, vertex): return Vector((x*scale, y*scale, z)) def process(self): - if not any(output.is_linked for output in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") vertices_s = self.inputs['Vertices'].sv_get(default=[[]]) origins = self.inputs['Origin'].sv_get(default=[Matrix()]) diff --git a/nodes/transforms/formula_deform_mk2.py b/nodes/transforms/formula_deform_mk2.py index d228ff7b08..86c9704664 100644 --- a/nodes/transforms/formula_deform_mk2.py +++ b/nodes/transforms/formula_deform_mk2.py @@ -46,19 +46,22 @@ def draw_buttons(self, context, layout): split.split().prop(self, "Mode"+element, text='') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + Io, Io2 = self.inputs Oo = self.outputs[0] - if Oo.is_linked: - V = Io.sv_get() - if Io2.is_linked: - str = "for Enum,Val2L in zip(enumerate(V), V2): \n I,L = Enum \n Pfin = [] \n for Enum2, vert2 in zip(enumerate(L), safc(L, Val2L)): \n i, (x, y, z) = Enum2 \n (X, Y, Z) = vert2 \n Pfin.append(({n.ModeX},{n.ModeY},{n.ModeZ})) \n fin.append(Pfin)" - fin = [] - V2 = Io2.sv_get() - exec(str.format(n=self)) - Oo.sv_set(fin) - else: - exec_string = "Oo.sv_set([[({n.ModeX},{n.ModeY},{n.ModeZ}) for i, (x, y, z) in enumerate(L)] for I, L in enumerate(V)])" - exec(exec_string.format(n=self)) + + V = Io.sv_get() + if Io2.is_linked: + str = "for Enum,Val2L in zip(enumerate(V), V2): \n I,L = Enum \n Pfin = [] \n for Enum2, vert2 in zip(enumerate(L), safc(L, Val2L)): \n i, (x, y, z) = Enum2 \n (X, Y, Z) = vert2 \n Pfin.append(({n.ModeX},{n.ModeY},{n.ModeZ})) \n fin.append(Pfin)" + fin = [] + V2 = Io2.sv_get() + exec(str.format(n=self)) + Oo.sv_set(fin) + else: + exec_string = "Oo.sv_set([[({n.ModeX},{n.ModeY},{n.ModeZ}) for i, (x, y, z) in enumerate(L)] for I, L in enumerate(V)])" + exec(exec_string.format(n=self)) def register(): diff --git a/nodes/transforms/mirror_mk2.py b/nodes/transforms/mirror_mk2.py index cb52f2a32f..9ef2d5c570 100644 --- a/nodes/transforms/mirror_mk2.py +++ b/nodes/transforms/mirror_mk2.py @@ -197,8 +197,10 @@ def draw_buttons(self, context, layout): layout.prop(self, "plane", expand=True) def process(self): - if not self.outputs['Vertices'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") vertices = self.inputs['Vertices'].sv_get(default=[]) vert_A = self.inputs['Vert A'].sv_get(default=[[[0.0, 0.0, 0.0]]]) @@ -220,6 +222,8 @@ def process(self): points = [mirror_axis_point_and_direction(v, a, d) for v, a, d in zip(*parameters)] self.outputs['Vertices'].sv_set(points) elif self.mode == 'PLANE_M': + if not (self.inputs["Plane"].is_linked): + raise Exception(f"Input socket '{self.inputs['Plane'].label or self.inputs['Plane'].identifier}' has to be connected") parameters = match_long_repeat([vertices, plane]) points = [mirror_plane_matrix(v, p) for v, p in zip(*parameters)] self.outputs['Vertices'].sv_set(points) diff --git a/nodes/transforms/move_mk3.py b/nodes/transforms/move_mk3.py index 0f01d13b73..14feeebd5a 100644 --- a/nodes/transforms/move_mk3.py +++ b/nodes/transforms/move_mk3.py @@ -102,13 +102,13 @@ def migrate_from(self, old_node): self.strength = old_node.mult_ def process(self): - inputs, outputs = self.inputs, self.outputs - - if not outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + + inputs, outputs = self.inputs, self.outputs result = [] - params = [si.sv_get(default=[[]], deepcopy=False) for si in inputs] matching_f = list_match_func[self.list_match] diff --git a/nodes/transforms/noise_displace.py b/nodes/transforms/noise_displace.py index 991813bf5d..9f5aa2fc23 100644 --- a/nodes/transforms/noise_displace.py +++ b/nodes/transforms/noise_displace.py @@ -266,13 +266,14 @@ def rclick_menu(self, context, layout): def process(self): - inputs, outputs = self.inputs, self.outputs - - if not outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") - result = [] + inputs, outputs = self.inputs, self.outputs + result = [] params = [si.sv_get(default=[[]], deepcopy=False) for si in inputs[:4]] params.append(inputs[4].sv_get(default=[Matrix()], deepcopy=False)) diff --git a/nodes/transforms/randomize.py b/nodes/transforms/randomize.py index 3f7635fc53..1c2b9a7179 100644 --- a/nodes/transforms/randomize.py +++ b/nodes/transforms/randomize.py @@ -81,9 +81,10 @@ def rclick_menu(self, context, layout): layout.prop(self, "output_numpy", toggle=True) def process(self): - # inputs - if not (self.inputs['Vertices'].is_linked and self.outputs['Vertices'].is_linked): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") vertices = self.inputs['Vertices'].sv_get(deepcopy=False) random_x = self.inputs['RandomX'].sv_get(deepcopy=False)[0] diff --git a/nodes/transforms/rotate_mk3.py b/nodes/transforms/rotate_mk3.py index 748be986d4..e09ca577b4 100644 --- a/nodes/transforms/rotate_mk3.py +++ b/nodes/transforms/rotate_mk3.py @@ -279,11 +279,12 @@ def migrate_props_pre_relink(self, old_node): self.update_sockets() def process(self): - inputs, outputs = self.inputs, self.outputs - - if not outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + + inputs, outputs = self.inputs, self.outputs matching_f = list_match_func[self.list_match] ops = [self.list_match, self.output_numpy] inputs_used = ['Vertices', 'Centers'] + modes_dict[self.mode][1] diff --git a/nodes/transforms/scale_mk3.py b/nodes/transforms/scale_mk3.py index 1188a8ca21..3a80bc8a7f 100644 --- a/nodes/transforms/scale_mk3.py +++ b/nodes/transforms/scale_mk3.py @@ -106,13 +106,13 @@ def rclick_menu(self, context, layout): layout.prop_menu_enum(self, "list_match", text="List Match") def process(self): - inputs, outputs = self.inputs, self.outputs - - if not outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + + inputs, outputs = self.inputs, self.outputs result = [] - params = [si.sv_get(default=[[]], deepcopy=False) for si in inputs] matching_f = list_match_func[self.list_match] diff --git a/nodes/transforms/symmetrize.py b/nodes/transforms/symmetrize.py index 536e25183c..f3c19ebc13 100644 --- a/nodes/transforms/symmetrize.py +++ b/nodes/transforms/symmetrize.py @@ -116,10 +116,10 @@ def apply_matrix(verts, matrix): return verts def process(self): - if not (self.inputs['Vertices'].is_linked): - return - if not (any(output.is_linked for output in self.outputs)): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") vertices_s = self.inputs['Vertices'].sv_get(default=[[]]) edges_s = self.inputs['Edges'].sv_get(default=[[]]) diff --git a/nodes/transforms/texture_displace_mk2.py b/nodes/transforms/texture_displace_mk2.py index dd237104d1..d7c70c2a10 100644 --- a/nodes/transforms/texture_displace_mk2.py +++ b/nodes/transforms/texture_displace_mk2.py @@ -194,11 +194,12 @@ def migrate_from(self, old_node): self.texture_pointer = self.get_bpy_data_from_name(old_node.name_texture, bpy.data.textures) def process(self): - inputs, outputs = self.inputs, self.outputs - - if not outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + + inputs, outputs = self.inputs, self.outputs result = [] params = [si.sv_get(default=[[]], deepcopy=False) for si in inputs[:4]] diff --git a/nodes/transforms/transform_mesh.py b/nodes/transforms/transform_mesh.py index 9f7dca7f43..3c10b26d39 100644 --- a/nodes/transforms/transform_mesh.py +++ b/nodes/transforms/transform_mesh.py @@ -563,8 +563,10 @@ def draw_direction_socket(self, socket, context, layout): socket.draw_property(col, self, 'direction') def process(self): - if not self.inputs['Verts'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Verts"].is_linked): + raise Exception(f"Input socket '{self.inputs['Verts'].label or self.inputs['Verts'].identifier}' has to be connected") verts = self.inputs['Verts'].sv_get(deepcopy=False) edges = self.inputs['Edges'].sv_get(deepcopy=False, default=cycle([None])) diff --git a/nodes/transforms/transform_select.py b/nodes/transforms/transform_select.py index f01c996111..e108d3a486 100644 --- a/nodes/transforms/transform_select.py +++ b/nodes/transforms/transform_select.py @@ -150,8 +150,7 @@ def process_poly_edge(self, polys_linked, input_polys, input_mask): return poly_edge_true, poly_edge_false, poly_edge_other def process(self): - # return if no outputs are connected - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return params, input_polys, polys_linked = self.get_data() diff --git a/nodes/vector/attractor.py b/nodes/vector/attractor.py index 005c899d90..2a747441e8 100644 --- a/nodes/vector/attractor.py +++ b/nodes/vector/attractor.py @@ -201,6 +201,8 @@ def to_plane(self, amplitude, coefficient, vertex, centers, direction): def process(self): if not any(output.is_linked for output in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") vertices_s = self.inputs['Vertices'].sv_get(default=[[]]) centers = self.inputs['Center'].sv_get(default=[[]])[0] diff --git a/nodes/vector/axis_input_mk2.py b/nodes/vector/axis_input_mk2.py index 29cdf12380..5880554784 100644 --- a/nodes/vector/axis_input_mk2.py +++ b/nodes/vector/axis_input_mk2.py @@ -57,9 +57,11 @@ def draw_label(self): return str('[{0}, {1}, {2}]'.format(*self.get_axis())) def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + vec_out = self.outputs[0] - if vec_out.is_linked: - vec_out.sv_set([[list(self.get_axis())]]) + vec_out.sv_set([[list(self.get_axis())]]) def register(): diff --git a/nodes/vector/drop.py b/nodes/vector/drop.py index ba159bf455..5fd35e92b0 100644 --- a/nodes/vector/drop.py +++ b/nodes/vector/drop.py @@ -42,9 +42,12 @@ def sv_init(self, context): self.outputs.new('SvVerticesSocket', "Vectors") def process(self): - # inputs - if not self.inputs['Matrixes'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vectors"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vectors'].label or self.inputs['Vectors'].identifier}' has to be connected") + if not (self.inputs["Matrixes"].is_linked): + raise Exception(f"Input socket '{self.inputs['Matrixes'].label or self.inputs['Matrixes'].identifier}' has to be connected") vecs_ = self.inputs['Vectors'].sv_get() vecs = Vector_generate(vecs_) diff --git a/nodes/vector/fractal.py b/nodes/vector/fractal.py index 1cc010daac..64339ab4a2 100644 --- a/nodes/vector/fractal.py +++ b/nodes/vector/fractal.py @@ -147,11 +147,10 @@ def draw_buttons(self, context, layout): layout.prop(self, 'noise_type', text="Type") def process(self): - inputs, outputs = self.inputs, self.outputs - - if not outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return - + + inputs, outputs = self.inputs, self.outputs _seed = inputs['Seed'].sv_get()[0][0] wrapped_fractal_function = fractal_f[self.fractal_type] diff --git a/nodes/vector/interpolation_mk2.py b/nodes/vector/interpolation_mk2.py index 442f5282a4..1d1b95be09 100644 --- a/nodes/vector/interpolation_mk2.py +++ b/nodes/vector/interpolation_mk2.py @@ -161,39 +161,39 @@ def interpol(self, verts, t_ins): def process(self): - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + + verts = self.inputs['Vertices'].sv_get() + verts = dataCorrect(verts) + t_ins_x = self.inputs['IntervalX'].sv_get() + t_ins_y = self.inputs['IntervalY'].sv_get() + + if self.regime == 'P' and self.direction == 'U': + self.direction = 'UV' + if self.defgrid: + t_ins_x = [[i/10 for i in range(11)]] + t_ins_y = [[i/10 for i in range(11)]] + if self.regime == 'G': + vertsX = self.interpol(verts, t_ins_x) + if self.direction == 'UV': + verts_T = np.swapaxes(np.array(vertsX),0,1).tolist() + verts_out = self.interpol(verts_T, t_ins_y) - if self.inputs['Vertices'].is_linked: - verts = self.inputs['Vertices'].sv_get() - verts = dataCorrect(verts) - t_ins_x = self.inputs['IntervalX'].sv_get() - t_ins_y = self.inputs['IntervalY'].sv_get() - - if self.regime == 'P' and self.direction == 'U': - self.direction = 'UV' - if self.defgrid: - t_ins_x = [[i/10 for i in range(11)]] - t_ins_y = [[i/10 for i in range(11)]] - if self.regime == 'G': - vertsX = self.interpol(verts, t_ins_x) - if self.direction == 'UV': - verts_T = np.swapaxes(np.array(vertsX),0,1).tolist() - verts_out = self.interpol(verts_T, t_ins_y) - - else: - verts_out = vertsX else: - verts_out_ = [] - for x,y in zip(t_ins_x[0],t_ins_y[0]): - vertsX = self.interpol(verts, [[x]]) - verts_T = np.swapaxes(np.array(vertsX),0,1).tolist() - vertsY = self.interpol(verts_T, [[y]]) - verts_out_.extend(vertsY) - - verts_out = [[i[0] for i in verts_out_]] - self.outputs['Vertices'].sv_set(verts_out) - + verts_out = vertsX + else: + verts_out_ = [] + for x,y in zip(t_ins_x[0],t_ins_y[0]): + vertsX = self.interpol(verts, [[x]]) + verts_T = np.swapaxes(np.array(vertsX),0,1).tolist() + vertsY = self.interpol(verts_T, [[y]]) + verts_out_.extend(vertsY) + + verts_out = [[i[0] for i in verts_out_]] + self.outputs['Vertices'].sv_set(verts_out) def register(): bpy.utils.register_class(SvInterpolationNodeMK2) diff --git a/nodes/vector/interpolation_stripes.py b/nodes/vector/interpolation_stripes.py index 4a19c12759..711317c6e5 100644 --- a/nodes/vector/interpolation_stripes.py +++ b/nodes/vector/interpolation_stripes.py @@ -205,100 +205,99 @@ def distance(self, x, y): return vec.length def process(self): - if not any(s.is_linked for s in self.outputs): + if not any(socket.is_linked for socket in self.outputs): return - if self.inputs['Vertices'].is_linked: - verts = self.inputs['Vertices'].sv_get() - verts = dataCorrect(verts) - attrs = self.inputs['Attractor'].sv_get() - attrs = dataCorrect(attrs) - if not self.inputs['IntervalX'].is_linked: - t_ins_x = [[i/10 for i in range(0,11)]] - else: - t_ins_x = self.inputs['IntervalX'].sv_get() - if not self.inputs['IntervalY'].is_linked: - t_ins_y = [[i/10 for i in range(0,11)]] - else: - t_ins_y = self.inputs['IntervalY'].sv_get() - factor = self.factor - scale = self.scale - minimum = self.minimum - maximum = self.maximum - operations = self.operations - func = vector_out[operations] - - # initial interpolation - vertsX = self.interpol(verts, t_ins_x) - verts_T = np.swapaxes(np.array(vertsX),0,1).tolist() - verts_int = self.interpol(verts_T, t_ins_y) - - # calculating distances with maximum one - dists = [] - verts_int, attrs = match_long_repeat([verts_int, attrs]) - for overts, oattrs in zip(verts_int,attrs): - overts, oattrs = match_long_repeat([overts, oattrs]) - dists_ = [] - for v, a in zip(overts,oattrs): - dists_.append(self.distance(v,a)) - dists.append(dists_) - dists_np = np.array(dists) - maxidist = dists_np.max() - - # normalize distances to coefficients for every vertex - # can be extended with formula evaluation... next step - #factor = eval(self.factor) - # vector-output - - try: - #dists_normalized = dists_np/(maxidist*len(t_ins_y)) - dists_normalized = func(dists_np,maxidist,t_ins_y,factor,scale,minimum,maximum) - #print(dists_normalized) - except ZeroDivisionError: - print ("division by zero!") - return - #except: - # print('stripes cannot calc function') - # return - - # calculate vertex moving coefficient - # simmetrically mirrored - t_ins_y_np = np.array(t_ins_y).repeat(len(dists_normalized),0) - a = np.roll(t_ins_y_np,1,1) - b = np.roll(t_ins_y_np,-1,1) - c = t_ins_y_np-(t_ins_y_np-a)*dists_normalized/2 - d = t_ins_y_np+(b-t_ins_y_np)*dists_normalized/2 - - # replacing first-last for both mirrors - c[:,0] = t_ins_y_np[:,0] - d[:,-1] = t_ins_y_np[:,-1] - t_ins_y_mins = c.tolist() - t_ins_y_plus = d.tolist() - - # secondary interpolation - # processing sliced stripes - vertsY_mins = self.interpol(verts_int, t_ins_y_mins) - vertsY_plus = self.interpol(verts_int, t_ins_y_plus) - verts_T_mins = np.swapaxes(np.array(vertsY_mins),0,1).tolist() - verts_T_plus = np.swapaxes(np.array(vertsY_plus),0,1).tolist() - verts_X_mins = self.interpol(verts_T_mins, t_ins_x) - verts_X_plus = self.interpol(verts_T_plus, t_ins_x) - - # zipping for UVconnect node to "eat" this - # mirrors on left and right side from initial interpolation - verts_out = [[M,P] for M,P in zip(verts_X_mins,verts_X_plus)] - vm,vp = verts_X_mins[1:],verts_X_plus[:-1] - #print('mnis----------',verts_X_mins[0]) - verts_inner_out = [[M,P] for M,P in zip(vm,vp)] - - if self.outputs['vStripesOut'].is_linked: - self.outputs['vStripesOut'].sv_set(verts_out) - if self.outputs['vStripesIn'].is_linked: - self.outputs['vStripesIn'].sv_set(verts_inner_out) - if self.outputs['vShape'].is_linked: - self.outputs['vShape'].sv_set(verts_int) - if self.outputs['sCoefs'].is_linked: - self.outputs['sCoefs'].sv_set(dists_normalized.tolist()) + verts = self.inputs['Vertices'].sv_get() + verts = dataCorrect(verts) + attrs = self.inputs['Attractor'].sv_get() + attrs = dataCorrect(attrs) + if not self.inputs['IntervalX'].is_linked: + t_ins_x = [[i/10 for i in range(0,11)]] + else: + t_ins_x = self.inputs['IntervalX'].sv_get() + if not self.inputs['IntervalY'].is_linked: + t_ins_y = [[i/10 for i in range(0,11)]] + else: + t_ins_y = self.inputs['IntervalY'].sv_get() + factor = self.factor + scale = self.scale + minimum = self.minimum + maximum = self.maximum + operations = self.operations + func = vector_out[operations] + + # initial interpolation + vertsX = self.interpol(verts, t_ins_x) + verts_T = np.swapaxes(np.array(vertsX),0,1).tolist() + verts_int = self.interpol(verts_T, t_ins_y) + + # calculating distances with maximum one + dists = [] + verts_int, attrs = match_long_repeat([verts_int, attrs]) + for overts, oattrs in zip(verts_int,attrs): + overts, oattrs = match_long_repeat([overts, oattrs]) + dists_ = [] + for v, a in zip(overts,oattrs): + dists_.append(self.distance(v,a)) + dists.append(dists_) + dists_np = np.array(dists) + maxidist = dists_np.max() + + # normalize distances to coefficients for every vertex + # can be extended with formula evaluation... next step + #factor = eval(self.factor) + # vector-output + + try: + #dists_normalized = dists_np/(maxidist*len(t_ins_y)) + dists_normalized = func(dists_np,maxidist,t_ins_y,factor,scale,minimum,maximum) + #print(dists_normalized) + except ZeroDivisionError: + print ("division by zero!") + return + #except: + # print('stripes cannot calc function') + # return + + # calculate vertex moving coefficient + # simmetrically mirrored + t_ins_y_np = np.array(t_ins_y).repeat(len(dists_normalized),0) + a = np.roll(t_ins_y_np,1,1) + b = np.roll(t_ins_y_np,-1,1) + c = t_ins_y_np-(t_ins_y_np-a)*dists_normalized/2 + d = t_ins_y_np+(b-t_ins_y_np)*dists_normalized/2 + + # replacing first-last for both mirrors + c[:,0] = t_ins_y_np[:,0] + d[:,-1] = t_ins_y_np[:,-1] + t_ins_y_mins = c.tolist() + t_ins_y_plus = d.tolist() + + # secondary interpolation + # processing sliced stripes + vertsY_mins = self.interpol(verts_int, t_ins_y_mins) + vertsY_plus = self.interpol(verts_int, t_ins_y_plus) + verts_T_mins = np.swapaxes(np.array(vertsY_mins),0,1).tolist() + verts_T_plus = np.swapaxes(np.array(vertsY_plus),0,1).tolist() + verts_X_mins = self.interpol(verts_T_mins, t_ins_x) + verts_X_plus = self.interpol(verts_T_plus, t_ins_x) + + # zipping for UVconnect node to "eat" this + # mirrors on left and right side from initial interpolation + verts_out = [[M,P] for M,P in zip(verts_X_mins,verts_X_plus)] + vm,vp = verts_X_mins[1:],verts_X_plus[:-1] + #print('mnis----------',verts_X_mins[0]) + verts_inner_out = [[M,P] for M,P in zip(vm,vp)] + + if self.outputs['vStripesOut'].is_linked: + self.outputs['vStripesOut'].sv_set(verts_out) + if self.outputs['vStripesIn'].is_linked: + self.outputs['vStripesIn'].sv_set(verts_inner_out) + if self.outputs['vShape'].is_linked: + self.outputs['vShape'].sv_set(verts_int) + if self.outputs['sCoefs'].is_linked: + self.outputs['sCoefs'].sv_set(dists_normalized.tolist()) def register(): diff --git a/nodes/vector/lerp.py b/nodes/vector/lerp.py index 3c4ccb530c..60e6df6d0a 100644 --- a/nodes/vector/lerp.py +++ b/nodes/vector/lerp.py @@ -63,8 +63,9 @@ def draw_buttons(self, context, layout): layout.prop(self, 'process_mode', text='Evaluate', expand=True) def process(self): - if not self.outputs['EvPoint'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + VerticesA = self.inputs[1].sv_get() VerticesB = self.inputs[2].sv_get() factor = self.inputs['Factor'].sv_get() diff --git a/nodes/vector/math_mk3.py b/nodes/vector/math_mk3.py index 5bc3ab5b7f..719d415d74 100644 --- a/nodes/vector/math_mk3.py +++ b/nodes/vector/math_mk3.py @@ -194,14 +194,13 @@ def update_sockets(self): s.prop_name = f'v3_input_{idx}' if t_in == 'v' else 'amount' def process(self): - self.ensure_enums_have_no_space(enums=["current_op"]) - inputs, outputs = self.inputs, self.outputs - - if not outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + inputs, outputs = self.inputs, self.outputs + func = self.implementation_func_dict[self.implementation][0].get(self.current_op)[1] num_inputs = len(inputs) diff --git a/nodes/vector/noise_mk3.py b/nodes/vector/noise_mk3.py index 2a237faca5..0d2b194a7b 100644 --- a/nodes/vector/noise_mk3.py +++ b/nodes/vector/noise_mk3.py @@ -169,11 +169,12 @@ def rclick_menu(self, context, layout): layout.prop(self, "output_numpy", toggle=True) def process(self): - inputs, outputs = self.inputs, self.outputs - - if not (outputs[0].is_linked and inputs[0].is_linked): + if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + + inputs, outputs = self.inputs, self.outputs out = [] verts = inputs['Vertices'].sv_get(deepcopy=False) noise_matrix = inputs['Noise Matrix'].sv_get(deepcopy=False, default=[]) diff --git a/nodes/vector/turbulence.py b/nodes/vector/turbulence.py index fb2f09523b..1469be3861 100755 --- a/nodes/vector/turbulence.py +++ b/nodes/vector/turbulence.py @@ -95,11 +95,12 @@ def draw_buttons(self, context, layout): layout.prop(self, 'noise_type', text="Type") def process(self): - inputs, outputs = self.inputs, self.outputs - - if not outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + + inputs, outputs = self.inputs, self.outputs tfunc = turbulence_f[self.out_mode] verts = inputs['Vertices'].sv_get(deepcopy=False) diff --git a/nodes/vector/variable_lacunarity.py b/nodes/vector/variable_lacunarity.py index 2b3149d163..9219d2ec3d 100644 --- a/nodes/vector/variable_lacunarity.py +++ b/nodes/vector/variable_lacunarity.py @@ -70,11 +70,12 @@ def draw_buttons(self, context, layout): layout.prop(self, 'noise_type2', text="Type") def process(self): - inputs, outputs = self.inputs, self.outputs - - if not outputs[0].is_linked: + if not any(socket.is_linked for socket in self.outputs): return - + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + + inputs, outputs = self.inputs, self.outputs out = [] verts = inputs['Vertices'].sv_get(deepcopy=False) _seed = inputs['Seed'].sv_get()[0][0] diff --git a/nodes/vector/vector_in.py b/nodes/vector/vector_in.py index a3414d842e..f954750b03 100644 --- a/nodes/vector/vector_in.py +++ b/nodes/vector/vector_in.py @@ -127,8 +127,9 @@ def rclick_menu(self, context, layout): get_cursor.treename = self.id_data.name def process(self): - if not self.outputs['Vectors'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + inputs = self.inputs X_ = inputs['X'].sv_get() Y_ = inputs['Y'].sv_get() diff --git a/nodes/vector/vector_out.py b/nodes/vector/vector_out.py index 74cc830cc4..5ae2da6239 100644 --- a/nodes/vector/vector_out.py +++ b/nodes/vector/vector_out.py @@ -63,23 +63,27 @@ def rclick_menu(self, context, layout): layout.prop(self, "output_numpy", toggle=True) def process(self): - if self.inputs['Vectors'].is_linked and any(s.is_linked for s in self.outputs): - xyz = self.inputs['Vectors'].sv_get(deepcopy=False) + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Vectors"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vectors'].label or self.inputs['Vectors'].identifier}' has to be connected") + + xyz = self.inputs['Vectors'].sv_get(deepcopy=False) - data = dataCorrect_np(xyz) - X, Y, Z = [], [], [] - if self.output_numpy: - unpack_func = unpack_np if isinstance(data[0], ndarray) else unpack_list_to_np - else: - unpack_func = unpack_list - for obj in data: - x_, y_, z_ = unpack_func(obj) - X.append(x_) - Y.append(y_) - Z.append(z_) - for i, name in enumerate(['X', 'Y', 'Z']): - if self.outputs[name].is_linked: - self.outputs[name].sv_set([X, Y, Z][i]) + data = dataCorrect_np(xyz) + X, Y, Z = [], [], [] + if self.output_numpy: + unpack_func = unpack_np if isinstance(data[0], ndarray) else unpack_list_to_np + else: + unpack_func = unpack_list + for obj in data: + x_, y_, z_ = unpack_func(obj) + X.append(x_) + Y.append(y_) + Z.append(z_) + for i, name in enumerate(['X', 'Y', 'Z']): + if self.outputs[name].is_linked: + self.outputs[name].sv_set([X, Y, Z][i]) def register(): diff --git a/nodes/vector/vector_polar_in.py b/nodes/vector/vector_polar_in.py index 2dfb43af4f..18d0bada2f 100644 --- a/nodes/vector/vector_polar_in.py +++ b/nodes/vector/vector_polar_in.py @@ -125,8 +125,9 @@ def rclick_menu(self, context, layout): layout.prop(self, "output_numpy", toggle=True) def process(self): - if not self.outputs['Vectors'].is_linked: + if not any(socket.is_linked for socket in self.outputs): return + inputs = self.inputs rhoss = inputs['rho'].sv_get(deepcopy=False) phiss = inputs['phi'].sv_get(deepcopy=False) diff --git a/nodes/vector/vector_rewire.py b/nodes/vector/vector_rewire.py index 95e701d03b..8917d35f6d 100644 --- a/nodes/vector/vector_rewire.py +++ b/nodes/vector/vector_rewire.py @@ -83,6 +83,11 @@ def draw_label(self): def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Vectors"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vectors'].label or self.inputs['Vectors'].identifier}' has to be connected") + vectors_in = self.inputs[0] scalar_in = self.inputs[1] vectors_out = self.outputs[0] diff --git a/nodes/vector/vertices_delete_doubles.py b/nodes/vector/vertices_delete_doubles.py index c0876e79d8..bddc67d812 100644 --- a/nodes/vector/vertices_delete_doubles.py +++ b/nodes/vector/vertices_delete_doubles.py @@ -40,6 +40,11 @@ def sv_init(self, context): self.outputs.new('SvVerticesSocket', "vers") def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["vers"].is_linked): + raise Exception(f"Input socket '{self.inputs['vers'].label or self.inputs['vers'].identifier}' has to be connected") + vers = self.inputs['vers'].sv_get() # Process data levs = levelsOflist(vers) diff --git a/nodes/vector/vertices_sort.py b/nodes/vector/vertices_sort.py index b193898d67..27591b1ade 100644 --- a/nodes/vector/vertices_sort.py +++ b/nodes/vector/vertices_sort.py @@ -243,6 +243,11 @@ def sv_init(self, context): self.outputs.new('SvStringsSocket', 'Item order') def process(self): + if not any(socket.is_linked for socket in self.outputs): + return + if not (self.inputs["Vertices"].is_linked): + raise Exception(f"Input socket '{self.inputs['Vertices'].label or self.inputs['Vertices'].identifier}' has to be connected") + verts = self.inputs['Vertices'].sv_get() if self.inputs['PolyEdge'].is_linked: @@ -427,27 +432,29 @@ def f(axis, q): item_order.append([i[-1] for i in s_v]) if self.mode == 'CONNEX': - if self.inputs['PolyEdge'].is_linked: - edges = self.inputs['PolyEdge'].sv_get() - for v, p in zip(verts, edges): - pols = [] - if len(p[0]) > 2: - pols = [p[:]] - p = polygons_to_edges([p], True)[0] - - vect_new, pol_edge_new, index_new = sort_vertices_by_connexions(v, p, self.limit_mode) - if len(pols) > 0: - new_pols = [] - for pol in pols[0]: - new_pol = [] - for i in pol: - new_pol.append(index_new.index(i)) - new_pols.append(new_pol) - pol_edge_new = [new_pols] - - verts_out.append(vect_new) - poly_edge_out.append(pol_edge_new) - item_order.append(index_new) + if not (self.inputs["PolyEdge"].is_linked): + raise Exception(f"Input socket '{self.inputs['PolyEdge'].label or self.inputs['PolyEdge'].identifier}' has to be connected") + + edges = self.inputs['PolyEdge'].sv_get() + for v, p in zip(verts, edges): + pols = [] + if len(p[0]) > 2: + pols = [p[:]] + p = polygons_to_edges([p], True)[0] + + vect_new, pol_edge_new, index_new = sort_vertices_by_connexions(v, p, self.limit_mode) + if len(pols) > 0: + new_pols = [] + for pol in pols[0]: + new_pol = [] + for i in pol: + new_pol.append(index_new.index(i)) + new_pols.append(new_pol) + pol_edge_new = [new_pols] + + verts_out.append(vect_new) + poly_edge_out.append(pol_edge_new) + item_order.append(index_new) if vert_output: self.outputs['Vertices'].sv_set(verts_out)