Skip to content

Instantly share code, notes, and snippets.

Forked from anonymous/
Last active August 29, 2015 14:00
Show Gist options
  • Save zeffii/11328164 to your computer and use it in GitHub Desktop.
Save zeffii/11328164 to your computer and use it in GitHub Desktop.
import bpy
import os
from bpy.props import EnumProperty, StringProperty
def get_template_path():
sv_path = os.path.dirname(os.path.realpath(__file__))
script_dir = "node_script_templates"
return os.path.join(sv_path, script_dir)
def get_templates():
path = get_template_path()
return [(t, t, "") for t in next(os.walk(path))[2]]
class SvScriptLoader(bpy.types.Operator):
""" Load Scripts into TextEditor """
bl_idname = "node.script_template"
bl_label = "Sverchok script template"
bl_options = {'REGISTER', 'UNDO'}
# from object in
script_path = StringProperty(name='script path')
def execute(self, context):
path = get_template_path()
file_to_load = os.path.join(path, self.script_path), internal=True)
return {'FINISHED'}
class SvTextSubMenu(bpy.types.Menu):
bl_idname = "TEXT_MT_templates_submenu"
bl_label = "Sv NodeScripts"
bl_options = {'REGISTER', 'UNDO'}
def draw(self, context):
layout = self.layout
m = get_templates()
t = "node.script_template"
for name, p ,_ in m:
layout.operator(t, text=name).script_path = p
def menu_draw(self, context):"TEXT_MT_templates_submenu")
def register():
def unregister():
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment