Skip to content

Commit

Permalink
- Add check if output sockets are connected before execute nodes (CAD…
Browse files Browse the repository at this point in the history
…, Analyzer, Color, Curve, field, generator, lists, matrix, modifier_change, modifier_make, Number, Pulga, Surface, svg, transforms, vector).
  • Loading branch information
satabol committed Apr 1, 2024
1 parent ba6a775 commit 33ea7c2
Show file tree
Hide file tree
Showing 206 changed files with 858 additions and 573 deletions.
1 change: 1 addition & 0 deletions nodes/CAD/edges_to_faces_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions nodes/CAD/embed mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[[]]),
Expand Down
1 change: 1 addition & 0 deletions nodes/CAD/merge_mesh_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions nodes/CAD/merge_mesh_2d_lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
7 changes: 4 additions & 3 deletions nodes/analyzer/bbox_aligned.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
3 changes: 3 additions & 0 deletions nodes/analyzer/bvh_overlap_polys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions nodes/analyzer/chess_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 3 additions & 0 deletions nodes/analyzer/deformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
6 changes: 3 additions & 3 deletions nodes/analyzer/diameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 7 additions & 3 deletions nodes/analyzer/distance_line_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
10 changes: 7 additions & 3 deletions nodes/analyzer/distance_point_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
9 changes: 7 additions & 2 deletions nodes/analyzer/distance_point_plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions nodes/analyzer/distance_pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 6 additions & 3 deletions nodes/analyzer/edge_angles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[[]])
Expand Down
4 changes: 2 additions & 2 deletions nodes/analyzer/intersect_circle_circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
7 changes: 5 additions & 2 deletions nodes/analyzer/intersect_line_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 3 additions & 2 deletions nodes/analyzer/intersect_plane_plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 5 additions & 2 deletions nodes/analyzer/kd_tree_MK2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions nodes/analyzer/kd_tree_edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
8 changes: 5 additions & 3 deletions nodes/analyzer/kd_tree_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions nodes/analyzer/linear_approx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[[]])

Expand Down
12 changes: 12 additions & 0 deletions nodes/analyzer/linked_verts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion nodes/analyzer/mesh_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 9 additions & 6 deletions nodes/analyzer/origins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down
9 changes: 6 additions & 3 deletions nodes/analyzer/points_inside_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
8 changes: 5 additions & 3 deletions nodes/analyzer/project_point_to_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions nodes/analyzer/raycaster_lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down
Loading

0 comments on commit 33ea7c2

Please sign in to comment.