def sn_loader(snlite, script_name=None): sv_path = os.path.dirname(sv_get_local_path()[0]) snlite_template_path = os.path.join(sv_path, 'node_scripts', 'SNLite_templates') fullpath = os.path.join(snlite_template_path, script_name) txt = bpy.data.texts.load(fullpath) snlite.script_name = os.path.basename(txt.name) snlite.load()
def sn_loader(snlite, script_name=None): sv_path = os.path.dirname(sv_get_local_path()[0]) snlite_template_path = os.path.join(sv_path, 'node_scripts', 'SNLite_templates') fullpath = os.path.join(snlite_template_path, script_name) txt = bpy.data.texts.load(fullpath) snlite.script_name = os.path.basename(txt.name) snlite.load()
def get_examples_paths(): sv_path = os.path.dirname(sv_get_local_path()[0]) paths = {} dataset_root = Path(sv_path) analyzer_path = dataset_root / 'json_examples' for listed_path in analyzer_path.iterdir(): if listed_path.is_dir(): paths[listed_path.name] = str(listed_path) return paths
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('ViewerNode2') 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[1]) links.new(obj_in_node.outputs[3], vd_node.inputs[2]) elif term == 'objs vd': obj_in_node = nodes.new('SvObjectsNodeMK3') obj_in_node.get_objects_from_scene(operator) vd_node = nodes.new('ViewerNode2') 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[1]) links.new(obj_in_node.outputs[3], vd_node.inputs[2]) elif term == 'zen': full_url_term = 'https://blenderpython.tumblr.com/post/91951323209/zen-of-sverchok' webbrowser.open(full_url_term) elif term == 'sn petal': snlite = nodes.new('SvScriptNodeLite') # set location of snlite based on mouse? sv_path = os.path.dirname(sv_get_local_path()[0]) snlite_template_path = os.path.join(sv_path, 'node_scripts', 'SNLite_templates') fullpath = os.path.join(snlite_template_path, 'petal_sine.py') txt = bpy.data.texts.load(fullpath) snlite.script_name = os.path.basename(txt.name) snlite.load()
from bpy.props import StringProperty, IntVectorProperty, FloatVectorProperty, BoolProperty from sverchok.utils.sv_update_utils import sv_get_local_path from sverchok.utils.snlite_importhelper import (UNPARSABLE, set_autocolor, parse_sockets, are_matched) from sverchok.utils.snlite_utils import vectorize, ddir from sverchok.utils.sv_bmesh_utils import bmesh_from_pydata, pydata_from_bmesh from sverchok.node_tree import SverchCustomTreeNode from sverchok.utils.nodes_mixins.sv_animatable_nodes import SvAnimatableNode from sverchok.data_structure import updateNode, throttled FAIL_COLOR = (0.8, 0.1, 0.1) READY_COLOR = (0, 0.8, 0.95) sv_path = os.path.dirname(sv_get_local_path()[0]) snlite_template_path = os.path.join(sv_path, 'node_scripts', 'SNLite_templates') defaults = [0] * 32 template_categories = ['demo', 'bpy_stuff', 'bmesh', 'utils'] class SNLITE_EXCEPTION(Exception): pass class SV_MT_ScriptNodeLitePyMenu(bpy.types.Menu): bl_label = "SNLite templates" bl_idname = "SV_MT_ScriptNodeLitePyMenu"
StringProperty, EnumProperty, BoolProperty, FloatVectorProperty, IntVectorProperty ) from sverchok.utils.sv_update_utils import sv_get_local_path from sverchok.node_tree import SverchCustomTreeNode from sverchok.data_structure import dataCorrect, updateNode FAIL_COLOR = (0.8, 0.1, 0.1) READY_COLOR = (0, 0.8, 0.95) defaults = list(range(32)) sv_path = os.path.dirname(sv_get_local_path()[0]) sock_dict = { 'v': 'VerticesSocket', 's': 'StringsSocket', 'm': 'MatrixSocket' } def new_output_socket(node, name, stype): socket_type = sock_dict.get(stype) if socket_type: node.outputs.new(socket_type, name) def new_input_socket(node, stype, name, dval):
def openjson_asdict(fname): sv_path = os.path.dirname(sv_get_local_path()[0]) path_to_json = os.path.join(sv_path, "utils", "modules", "vector_font", fname) with open(path_to_json) as d: return ast.literal_eval(''.join(d.readlines()))