#!BPY """ Name: 'Template Completion | Tab' Blender: 246 Group: 'TextPlugin' Shortcut: 'Tab' Tooltip: 'Completes templates based on the text preceding the cursor' """ # Only run if we have the required modules try: import bpy from BPyTextPlugin import * from Blender import Text except ImportError: OK = False else: OK = True templates = { 'ie': 'if ${1:cond}:\n' '\t${2}\n' 'else:\n' '\t${3}\n', 'iei': 'if ${1:cond}:\n' '\t${2}\n' 'elif:\n' '\t${3}\n' 'else:\n' '\t${4}\n', 'def': 'def ${1:name}(${2:params}):\n' '\t"""(${2}) - ${3:comment}"""\n' '\t${4}', 'cls': 'class ${1:name}(${2:parent}):\n' '\t"""${3:docs}"""\n' '\t\n' '\tdef __init__(self, ${4:params}):\n' '\t\t"""Creates a new ${1}"""\n' '\t\t${5}' } def main(): txt = bpy.data.texts.active if not txt: return row, c = txt.getCursorPos() line = txt.asLines()[row] indent=0 while indent