Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix 5098. Some nodes generate exceptions if output sockets are not connected #5099

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion nodes/CAD/crop_mesh_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion nodes/CAD/edges_intersect_mk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion nodes/CAD/edges_to_faces_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ 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))
Expand Down
3 changes: 3 additions & 0 deletions nodes/CAD/embed mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ 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=[[]]),
Expand Down
5 changes: 4 additions & 1 deletion nodes/CAD/merge_mesh_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ 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(),
Expand Down
5 changes: 4 additions & 1 deletion nodes/CAD/merge_mesh_2d_lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ 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 = []
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
7 changes: 6 additions & 1 deletion nodes/analyzer/chess_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,13 @@ def sv_init(self, context):
self.outputs.new('SvStringsSocket', "Face mask")

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 (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
3 changes: 2 additions & 1 deletion nodes/analyzer/distance_pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down 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 and si[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
2 changes: 2 additions & 0 deletions nodes/analyzer/object_insolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions nodes/analyzer/origins.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,17 @@ def sv_init(self, context):
self.outputs.new('SvMatrixSocket', "Matrix")

def process(self):
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']]):
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 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
Loading
Loading