Oops, typo in rev. 15664 caused error
authorIan Thompson <quornian@googlemail.com>
Mon, 21 Jul 2008 11:21:49 +0000 (11:21 +0000)
committerIan Thompson <quornian@googlemail.com>
Mon, 21 Jul 2008 11:21:49 +0000 (11:21 +0000)
release/scripts/bpymodules/BPyTextPlugin.py
release/scripts/scripttemplate_text_plugin.py [new file with mode: 0644]

index 1df095b8b35b10c1405a47c01b6f55b51d199c06..e39d67aacee0434eed575f88283b1e7ac560776f 100644 (file)
@@ -350,7 +350,7 @@ def parse_text(txt):
                                        close = line.find(')', end[1])
                                        var_type = dict
                                if var_type and close+1 < len(line):
-                                       if line[close]+1 != ' ' and line[close+1] != '\t':
+                                       if line[close+1] != ' ' and line[close+1] != '\t':
                                                var_type = None
                                cls_vars[var_name] = VarDesc(var_name, var_type, start[0])
                                var1_step = 0
diff --git a/release/scripts/scripttemplate_text_plugin.py b/release/scripts/scripttemplate_text_plugin.py
new file mode 100644 (file)
index 0000000..4ae5627
--- /dev/null
@@ -0,0 +1,69 @@
+#!BPY
+"""
+Name: 'Text Plugin'
+Blender: 246
+Group: 'ScriptTemplate'
+Tooltip: 'Add a new text for writing a text plugin'
+"""
+
+from Blender import Window
+import bpy
+
+script_data = \
+'''#!BPY
+"""
+Name: 'My Plugin Script'
+Blender: 246
+Group: 'TextPlugin'
+Shortcut: 'Ctrl+Alt+U'
+Tooltip: 'Put some useful info here'
+"""
+
+# Add a licence here if you wish to re-distribute, we recommend the GPL
+
+from Blender import Window, sys
+import BPyTextPlugin, bpy
+
+def my_script_util(txt):
+       # This function prints out statistical information about a script
+       
+       desc = BPyTextPlugin.get_cached_descriptor(txt)
+       print '---------------------------------------'
+       print 'Script Name:', desc.name
+       print 'Classes:', len(desc.classes)
+       print '  ', desc.classes.keys()
+       print 'Functions:', len(desc.defs)
+       print '  ', desc.defs.keys()
+       print 'Variables:', len(desc.vars)
+       print '  ', desc.vars.keys()
+
+def main():
+       
+       # Gets the active text object, there can be many in one blend file.
+       txt = bpy.data.texts.active
+       
+       # Silently return if the script has been run with no active text
+       if not txt:
+               return 
+       
+       # Text plug-ins should run quickly so we time it here
+       Window.WaitCursor(1)
+       t = sys.time()
+       
+       # Run our utility function
+       my_script_util(txt)
+       
+       # Timing the script is a good way to be aware on any speed hits when scripting
+       print 'Plugin script finished in %.2f seconds' % (sys.time()-t)
+       Window.WaitCursor(0)
+       
+
+# This lets you import the script without running it
+if __name__ == '__main__':
+       main()
+'''
+
+new_text = bpy.data.texts.new('textplugin_template.py')
+new_text.write(script_data)
+bpy.data.texts.active = new_text
+Window.RedrawAll()