~ubuntu-branches/ubuntu/maverick/blender/maverick

« back to all changes in this revision

Viewing changes to release/scripts/scripttemplate_text_plugin.py

  • Committer: Bazaar Package Importer
  • Author(s): Khashayar Naderehvandi, Khashayar Naderehvandi, Alessio Treglia
  • Date: 2009-01-22 16:53:59 UTC
  • mfrom: (14.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090122165359-v0996tn7fbit64ni
Tags: 2.48a+dfsg-1ubuntu1
[ Khashayar Naderehvandi ]
* Merge from debian experimental (LP: #320045), Ubuntu remaining changes:
  - Add patch correcting header file locations.
  - Add libvorbis-dev and libgsm1-dev to Build-Depends.
  - Use avcodec_decode_audio2() in source/blender/src/hddaudio.c

[ Alessio Treglia ]
* Add missing previous changelog entries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!BPY
 
2
"""
 
3
Name: 'Text Plugin'
 
4
Blender: 246
 
5
Group: 'ScriptTemplate'
 
6
Tooltip: 'Add a new text for writing a text plugin'
 
7
"""
 
8
 
 
9
from Blender import Window
 
10
import bpy
 
11
 
 
12
script_data = \
 
13
'''#!BPY
 
14
"""
 
15
Name: 'My Plugin Script'
 
16
Blender: 246
 
17
Group: 'TextPlugin'
 
18
Shortcut: 'Ctrl+Alt+U'
 
19
Tooltip: 'Put some useful info here'
 
20
"""
 
21
 
 
22
# Add a licence here if you wish to re-distribute, we recommend the GPL
 
23
 
 
24
from Blender import Window, sys
 
25
import BPyTextPlugin, bpy
 
26
 
 
27
def my_script_util(txt):
 
28
        # This function prints out statistical information about a script
 
29
        
 
30
        desc = BPyTextPlugin.get_cached_descriptor(txt)
 
31
        print '---------------------------------------'
 
32
        print 'Script Name:', desc.name
 
33
        print 'Classes:', len(desc.classes)
 
34
        print '  ', desc.classes.keys()
 
35
        print 'Functions:', len(desc.defs)
 
36
        print '  ', desc.defs.keys()
 
37
        print 'Variables:', len(desc.vars)
 
38
        print '  ', desc.vars.keys()
 
39
 
 
40
def main():
 
41
        
 
42
        # Gets the active text object, there can be many in one blend file.
 
43
        txt = bpy.data.texts.active
 
44
        
 
45
        # Silently return if the script has been run with no active text
 
46
        if not txt:
 
47
                return 
 
48
        
 
49
        # Text plug-ins should run quickly so we time it here
 
50
        Window.WaitCursor(1)
 
51
        t = sys.time()
 
52
        
 
53
        # Run our utility function
 
54
        my_script_util(txt)
 
55
        
 
56
        # Timing the script is a good way to be aware on any speed hits when scripting
 
57
        print 'Plugin script finished in %.2f seconds' % (sys.time()-t)
 
58
        Window.WaitCursor(0)
 
59
        
 
60
 
 
61
# This lets you import the script without running it
 
62
if __name__ == '__main__':
 
63
        main()
 
64
'''
 
65
 
 
66
new_text = bpy.data.texts.new('textplugin_template.py')
 
67
new_text.write(script_data)
 
68
bpy.data.texts.active = new_text
 
69
Window.RedrawAll()