diff --git a/ui/nodeview_rclick_menu.py b/ui/nodeview_rclick_menu.py index 1aefb1fd38369db1e53c41434322ee2c13fd1e2c..688131e8d6c7ca1d1a571206672a6001951fdd69 100644 --- a/ui/nodeview_rclick_menu.py +++ b/ui/nodeview_rclick_menu.py @@ -10,6 +10,7 @@ import bpy from sverchok.utils.sv_node_utils import frame_adjust from sverchok.menu import draw_add_node_operator from sverchok.ui.presets import node_supports_presets +from sverchok.core.sockets import SvCurveSocket, SvSurfaceSocket, SvStringsSocket sv_tree_types = {'SverchCustomTreeType', 'SverchGroupTreeType'} supported_mesh_viewers = {'SvBmeshViewerNodeMK2', 'ViewerNode2'} @@ -39,12 +40,13 @@ def valid_active_node(nodes): def has_outputs(node): return node and len(node.outputs) -def get_verts_edge_poly_output_sockets(node): +def get_output_sockets_map(node): """ because of inconsistent socket naming, we will use pattern matching (ignoring capitalization) - - verts: verts, vers, vertices, vectors, vecs (ve) + - verts: verts, vers, vertices, vectors, vecs (ver, vec) - edges: edges, edgs, edgpol (edg) - faces: faces, poly, pols, edgpol, (pol, fac) + For curves and surfaces checks if they belong to the corresponding class > generally the first 3 outputs of a node will contain these > generally if a node outputs polygons, it won't be necessary to connect edges @@ -58,12 +60,14 @@ def get_verts_edge_poly_output_sockets(node): got_verts = False got_edges = False got_faces = False - + got_curves = False + got_surface = False # we can surely use regex for this, but for now this will work. for socket in node.outputs: + socket_name = socket.name.lower() - if not got_verts and 've' in socket_name: + if not got_verts and ('ver' in socket_name or 'vec' in socket_name): output_map['verts'] = socket.name got_verts = True @@ -71,10 +75,18 @@ def get_verts_edge_poly_output_sockets(node): output_map['edges'] = socket.name got_edges = True - elif not got_faces and ('face' in socket_name or 'pol' in socket_name): + elif not got_faces and ('face' in socket_name or 'pol' in socket_name) and isinstance(socket, SvStringsSocket): output_map['faces'] = socket.name got_faces = True + elif not got_curves and isinstance(socket, SvCurveSocket): + output_map['curve'] = socket.name + got_curves = True + + elif not got_surface and isinstance(socket, SvSurfaceSocket): + output_map['surface'] = socket.name + got_surface = True + return output_map def offset_node_location(existing_node, new_node, offset): @@ -85,7 +97,7 @@ def add_connection(tree, bl_idname_new_node, offset): nodes = tree.nodes links = tree.links - output_map = get_verts_edge_poly_output_sockets(nodes.active) + output_map = get_output_sockets_map(nodes.active) existing_node = nodes.active @@ -126,7 +138,26 @@ def add_connection(tree, bl_idname_new_node, offset): links.new(outputs[output_map['faces']], inputs[2]) if 'edges' in output_map: links.new(outputs[output_map['edges']], inputs[1]) - + elif 'curve' in output_map: + + eval_node = nodes.new('SvExEvalCurveNode') + offset_node_location(existing_node, eval_node, offset) + frame_adjust(existing_node, eval_node) + offset_node_location(eval_node, new_node, offset) + frame_adjust(eval_node, new_node) + links.new(outputs[output_map['curve']], eval_node.inputs[0]) + links.new(eval_node.outputs[0], inputs[0]) + links.new(eval_node.outputs[1], inputs[1]) + + elif 'surface' in output_map: + eval_node = nodes.new('SvExEvalSurfaceNode') + offset_node_location(existing_node, eval_node, offset) + frame_adjust(existing_node, eval_node) + offset_node_location(eval_node, new_node, offset) + frame_adjust(eval_node, new_node) + links.new(outputs[output_map['surface']], eval_node.inputs[0]) + links.new(eval_node.outputs[0], inputs[0]) + links.new(eval_node.outputs[1], inputs[1]) tree.sv_process = previous_state tree.update() # existing_node.process_node(None) diff --git a/ui/sv_temporal_viewers.py b/ui/sv_temporal_viewers.py index 7cb72d89376acd470c64d960473cbaecf8895660..dfca233abe256839e04be6d3a02021d73106e625 100644 --- a/ui/sv_temporal_viewers.py +++ b/ui/sv_temporal_viewers.py @@ -19,7 +19,7 @@ import bpy from bpy.types import Operator -from sverchok.ui.nodeview_rclick_menu import get_verts_edge_poly_output_sockets +from sverchok.ui.nodeview_rclick_menu import get_output_sockets_map from sverchok.utils.sv_node_utils import frame_adjust sv_tree_types = {'SverchCustomTreeType', 'SverchGroupTreeType'} @@ -33,7 +33,7 @@ def add_temporal_viewer_draw(tree, nodes, links, existing_node, cut_links): previous_state = tree.sv_process tree.sv_process = False bl_idname_new_node = 'SvVDExperimental' - output_map = get_verts_edge_poly_output_sockets(existing_node) + output_map = get_output_sockets_map(existing_node) try: new_node = nodes['Temporal Viewer'] if cut_links or ('verts' in output_map and 'faces' in output_map): diff --git a/ui/sv_vep_connector.py b/ui/sv_vep_connector.py index 7aa9e65c41b82e2dd92d12879afed69be40a3005..d338aa763323140ae8db51d1b0b5658b383638ca 100644 --- a/ui/sv_vep_connector.py +++ b/ui/sv_vep_connector.py @@ -18,7 +18,7 @@ # ##### END GPL LICENSE BLOCK ##### import bpy -from sverchok.ui.nodeview_rclick_menu import get_verts_edge_poly_output_sockets +from sverchok.ui.nodeview_rclick_menu import get_output_sockets_map from sverchok.utils.sv_node_utils import frame_adjust sv_tree_types = {'SverchCustomTreeType', 'SverchGroupTreeType'}