def verbose_macro_handler(cls, operator, context, term): cls.ensure_nodetree(operator, context) tree = context.space_data.edit_tree nodes, links = tree.nodes, tree.links if term == 'obj vd': obj_in_node = nodes.new('SvObjInLite') obj_in_node.dget() vd_node = nodes.new('SvVDExperimental') vd_node.location = obj_in_node.location.x + 180, obj_in_node.location.y links.new(obj_in_node.outputs[0], vd_node.inputs[0]) links.new(obj_in_node.outputs[2], vd_node.inputs[2]) links.new(obj_in_node.outputs[3], vd_node.inputs[3]) elif term == 'objs vd': obj_in_node = nodes.new('SvObjectsNodeMK3') obj_in_node.get_objects_from_scene(operator) vd_node = nodes.new('SvVDExperimental') vd_node.location = obj_in_node.location.x + 180, obj_in_node.location.y links.new(obj_in_node.outputs[0], vd_node.inputs[0]) links.new(obj_in_node.outputs[2], vd_node.inputs[2]) links.new(obj_in_node.outputs[3], vd_node.inputs[3]) elif term == 'zen': full_url_term = 'https://gist.github.com/zeffii/d843b985b0db97af56dfa9c30cd54712' webbrowser.open(full_url_term) elif 'snl' in term: file = term.split(' ')[1] snlite = nodes.new('SvScriptNodeLite') snlite.location = context.space_data.cursor_location sn_loader(snlite, script_name=file) elif term == 'monad info': x, y = context.space_data.cursor_location[:] monad_info = nodes.new('SvMonadInfoNode') monad_info.location = x, y elif "join" in term: join_macros(context, operator, term, nodes, links) elif "math" in term: math_macros(context, operator, term, nodes, links) return {'FINISHED'} elif "switch" in term: switch_macros(context, operator, term, nodes, links) return {'FINISHED'} elif 'output numpy' in term: #stop processing to avoid one update per property previous_state = tree.sv_process tree.sv_process = False state_ = term.split(' ')[2] state = state_ == 'True' for node in nodes: # most of cases if hasattr(node, 'output_numpy'): node.output_numpy = state # line node if hasattr(node, 'as_numpy'): node.as_numpy = state # box node if hasattr(node, 'out_np'): for i in range(len(node.out_np)): node.out_np[i] = state # vector in if hasattr(node, 'implementation'): try: node.implementation = 'NumPy' if state else 'Python' except TypeError: pass # establish previous processing state tree.sv_process = previous_state tree.update() elif term == 'gp +': gp_macro_one(context, operator, term, nodes, links) elif term == 'gp + 2': gp_macro_two(context, operator, term, nodes, links)
def verbose_macro_handler(cls, operator, context, term): cls.ensure_nodetree(operator, context) tree = context.space_data.edit_tree nodes, links = tree.nodes, tree.links if term == 'obj vd': obj_in_node = nodes.new('SvObjInLite') obj_in_node.dget() vd_node = nodes.new('SvVDExperimental') vd_node.location = obj_in_node.location.x + 180, obj_in_node.location.y links.new(obj_in_node.outputs[0], vd_node.inputs[0]) links.new(obj_in_node.outputs[2], vd_node.inputs[2]) links.new(obj_in_node.outputs[3], vd_node.inputs[3]) elif term == 'objs vd': obj_in_node = nodes.new('SvObjectsNodeMK3') obj_in_node.get_objects_from_scene(operator) vd_node = nodes.new('SvVDExperimental') vd_node.location = obj_in_node.location.x + 180, obj_in_node.location.y links.new(obj_in_node.outputs[0], vd_node.inputs[0]) links.new(obj_in_node.outputs[2], vd_node.inputs[2]) links.new(obj_in_node.outputs[3], vd_node.inputs[3]) elif term == 'zen': full_url_term = 'https://gist.github.com/zeffii/d843b985b0db97af56dfa9c30cd54712' webbrowser.open(full_url_term) elif 'snl' in term: file = term.split(' ')[1] snlite = nodes.new('SvScriptNodeLite') snlite.location = context.space_data.cursor_location sn_loader(snlite, script_name=file) elif term == 'monad info': x, y = context.space_data.cursor_location[:] monad_info = nodes.new('SvMonadInfoNode') monad_info.location = x, y elif "join" in term: join_macros(context, operator, term, nodes, links) elif "math" in term: math_macros(context, operator, term, nodes, links) return {'FINISHED'} elif "switch" in term: switch_macros(context, operator, term, nodes, links) return {'FINISHED'} elif 'output numpy' in term: #stop processing to avoid one update per property previous_state = tree.sv_process tree.sv_process = False state_ = term.split(' ')[2] state = state_ == 'True' for node in nodes: # most of cases if hasattr(node, 'output_numpy'): node.output_numpy = state # line node if hasattr(node, 'as_numpy'): node.as_numpy = state # box node if hasattr(node, 'out_np'): for i in range(len(node.out_np)): node.out_np[i] = state # vector in if hasattr(node, 'implementation'): try: node.implementation = 'NumPy' if state else 'Python' except TypeError: pass # establish previous processing state tree.sv_process = previous_state tree.update() elif term == 'gp +': needed_nodes = [ ['SvGetAssetPropertiesMK2', (0.00, 0.00)], ['SvPathLengthMk2Node', (250, 55)], ['SvScalarMathNodeMK4', (430, 115)], ['Float2IntNode', (600, 50)], ['SvGenNumberRange', (720, 90)], ['SvInterpolationNodeMK3', (880, 40)], ['LineConnectNodeMK2', (1060, -40)], ['SvVDExperimental', (1245, 50)], ] made_nodes = [] x, y = context.space_data.cursor_location[:] for node_bl_idname, node_location in needed_nodes: n = nodes.new(node_bl_idname) n.location = node_location[0] + x, node_location[1] + y made_nodes.append(n) # ID Selector made_nodes[ 0].Mode = 'grease_pencils' # the rest must be user driven links.new(made_nodes[0].outputs[0], made_nodes[1].inputs[0]) # Scalar Math node made_nodes[2].current_op = 'MUL' made_nodes[2].y_ = 2.5 links.new(made_nodes[1].outputs[1], made_nodes[2].inputs[0]) # snlite-> math links.new(made_nodes[2].outputs[0], made_nodes[3].inputs[0]) # math -> float # Float2Int node # made_nodes[3] links.new(made_nodes[3].outputs[0], made_nodes[4].inputs[2]) # Float range made_nodes[4].range_mode = 'RANGE_COUNT' made_nodes[4].stop_float = 1.0 links.new(made_nodes[4].outputs[0], made_nodes[5].inputs[1]) # Vector Interpolate made_nodes[5] links.new(made_nodes[0].outputs[0], made_nodes[5].inputs[0]) links.new(made_nodes[5].outputs[0], made_nodes[6].inputs[0]) # UV connect made_nodes[6].polygons = 'Edges' made_nodes[6].slice_check = False made_nodes[6].dir_check = 'U_dir' # Viewer Draw made_nodes[7] links.new(made_nodes[6].outputs[0], made_nodes[7].inputs[0]) links.new(made_nodes[6].outputs[1], made_nodes[7].inputs[1])
def verbose_macro_handler(cls, operator, context, term): cls.ensure_nodetree(operator, context) tree = context.space_data.edit_tree nodes, links = tree.nodes, tree.links if term == 'obj vd': obj_in_node = nodes.new('SvObjInLite') obj_in_node.dget() vd_node = nodes.new('SvViewerDrawMk4') vd_node.location = obj_in_node.location.x + 180, obj_in_node.location.y links.new(obj_in_node.outputs[0], vd_node.inputs[0]) links.new(obj_in_node.outputs[2], vd_node.inputs[2]) links.new(obj_in_node.outputs[4], vd_node.inputs[3]) elif term == 'objs vd': obj_in_node = nodes.new('SvGetObjectsData') obj_in_node.get_objects_from_scene(operator) vd_node = nodes.new('SvViewerDrawMk4') vd_node.location = obj_in_node.location.x + 180, obj_in_node.location.y # this macro could detect specifically if the node found edges or faces or both... links.new(obj_in_node.outputs[0], vd_node.inputs[0]) links.new(obj_in_node.outputs[2], vd_node.inputs[2]) links.new(obj_in_node.outputs[8], vd_node.inputs[3]) elif 'hotswap' in term: swap_vd_mv(context, operator, term, nodes, links) return elif term == 'nuke python++': bpy.ops.script.reload() elif term == 'zen': full_url_term = 'https://gist.github.com/zeffii/d843b985b0db97af56dfa9c30cd54712' webbrowser.open(full_url_term) elif 'snl' in term: file = term.split(' ')[1] snlite = nodes.new('SvScriptNodeLite') snlite.location = context.space_data.cursor_location sn_loader(snlite, script_name=file) elif "join" in term: join_macros(context, operator, term, nodes, links) elif "math" in term: math_macros(context, operator, term, nodes, links) return elif "switch" in term: switch_macros(context, operator, term, nodes, links) return elif 'output numpy' in term: state_ = term.split(' ')[2] state = state_ == 'True' for node in nodes: # most of cases if hasattr(node, 'output_numpy'): node.output_numpy = state # line node if hasattr(node, 'as_numpy'): node.as_numpy = state # box node if hasattr(node, 'out_np'): for i in range(len(node.out_np)): node.out_np[i] = state # vector in if hasattr(node, 'implementation'): try: node.implementation = 'NumPy' if state else 'Python' except TypeError: pass elif term == 'gp +': gp_macro_one(context, operator, term, nodes, links) elif term == 'gp + 2': gp_macro_two(context, operator, term, nodes, links) elif term == 'url': bpy.ops.node.sv_load_archived_blend_url() elif term == 'blend 2 zip': bpy.ops.node.blend_to_archive(archive_ext="zip")
def verbose_macro_handler(cls, operator, context, term): cls.ensure_nodetree(operator, context) tree = context.space_data.edit_tree nodes, links = tree.nodes, tree.links if term == 'obj vd': obj_in_node = nodes.new('SvObjInLite') obj_in_node.dget() vd_node = nodes.new('SvViewerDrawMk4') vd_node.location = obj_in_node.location.x + 180, obj_in_node.location.y links.new(obj_in_node.outputs[0], vd_node.inputs[0]) links.new(obj_in_node.outputs[2], vd_node.inputs[2]) links.new(obj_in_node.outputs[4], vd_node.inputs[3]) elif term == 'objs vd': obj_in_node = nodes.new('SvGetObjectsData') obj_in_node.get_objects_from_scene(operator) vd_node = nodes.new('SvViewerDrawMk4') vd_node.location = obj_in_node.location.x + 180, obj_in_node.location.y # this macro could detect specifically if the node found edges or faces or both... links.new(obj_in_node.outputs[0], vd_node.inputs[0]) links.new(obj_in_node.outputs[2], vd_node.inputs[2]) links.new(obj_in_node.outputs[8], vd_node.inputs[3]) elif term == "objs socket to data": objdata_macro_one(context, operator, term, nodes, links) elif term == "3dcursor_to_vector_in": MOUSE_X, MOUSE_Y = context.space_data.cursor_location cursor = context.scene.cursor.location node = nodes.new("GenVectorsNode") node.location = MOUSE_X, MOUSE_Y node.x_, node.y_, node.z_ = tuple(cursor) elif term == "3dcursor_to_matrix": def flattened(matrix): return list(matrix[0]) + list(matrix[1]) + list( matrix[2]) + list(matrix[3]) MOUSE_X, MOUSE_Y = context.space_data.cursor_location matrix = context.scene.cursor.matrix node = nodes.new("SvMatrixValueIn") # "SvMatrixInNodeMK4") node.location = MOUSE_X, MOUSE_Y node.matrix = flattened(matrix.transposed()) elif term == 'rndcol': # all locations will be relative to cursor MOUSE_X, MOUSE_Y = context.space_data.cursor_location # add nodes to layout NUM = nodes.new("SvNumberNode") RR = nodes.new('NodeReroute') RND_0 = nodes.new('SvRndNumGen') RND_1 = nodes.new('SvRndNumGen') RND_2 = nodes.new('SvRndNumGen') COL = nodes.new('SvColorsInNodeMK1') # set locations COL.location = MOUSE_X + 140, MOUSE_Y + 40 RND_0.location.x = MOUSE_X - 40 RND_0.location.y = MOUSE_Y + 40 RND_1.location.x = MOUSE_X - 40 RND_1.location.y = MOUSE_Y RND_2.location.x = MOUSE_X - 40 RND_2.location.y = MOUSE_Y - 40 RR.location = MOUSE_X - 110, MOUSE_Y NUM.location = MOUSE_X - 280, MOUSE_Y + 20 # configure nodes set_node_props(NUM, {'selected_mode': 'int', 'int_': 30}) set_node_props(RND_0, { 'type_selected_mode': 'Float', 'seed': 20, 'hide': True }) set_node_props(RND_1, { 'type_selected_mode': 'Float', 'seed': 30, 'hide': True }) set_node_props(RND_2, { 'type_selected_mode': 'Float', 'seed': 40, 'hide': True }) # link nodes links.new(NUM.outputs[0], RR.inputs[0]) links.new(RR.outputs[0], RND_0.inputs[0]) links.new(RR.outputs[0], RND_1.inputs[0]) links.new(RR.outputs[0], RND_2.inputs[0]) links.new(RND_0.outputs[0], COL.inputs[0]) links.new(RND_1.outputs[0], COL.inputs[1]) links.new(RND_2.outputs[0], COL.inputs[2]) elif 'hotswap' in term: swap_vd_mv(context, operator, term, nodes, links) return elif term == 'nuke python++': bpy.ops.script.reload() elif term == 'zen': full_url_term = 'https://gist.github.com/zeffii/d843b985b0db97af56dfa9c30cd54712' webbrowser.open(full_url_term) elif 'snl' in term: file = term.split(' ')[1] snlite = nodes.new('SvScriptNodeLite') snlite.location = context.space_data.cursor_location sn_loader(snlite, script_name=file) elif "join" in term: join_macros(context, operator, term, nodes, links) elif "math" in term: math_macros(context, operator, term, nodes, links) return elif "switch" in term: switch_macros(context, operator, term, nodes, links) return elif 'output numpy' in term: state_ = term.split(' ')[2] state = state_ == 'True' for node in nodes: # most of cases if hasattr(node, 'output_numpy'): node.output_numpy = state # line node if hasattr(node, 'as_numpy'): node.as_numpy = state # box node if hasattr(node, 'out_np'): for i in range(len(node.out_np)): node.out_np[i] = state # vector in if hasattr(node, 'implementation'): try: node.implementation = 'NumPy' if state else 'Python' except TypeError: pass elif term == 'gp +': gp_macro_one(context, operator, term, nodes, links) elif term == 'gp + 2': gp_macro_two(context, operator, term, nodes, links) elif term == 'url': bpy.ops.node.sv_load_archived_blend_url() elif term == 'blend 2 zip': bpy.ops.node.blend_to_archive(archive_ext="zip")