~ubuntu-branches/ubuntu/lucid/blender/lucid

« back to all changes in this revision

Viewing changes to release/scripts/scripttemplate_text_plugin.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2009-08-06 22:32:19 UTC
  • mfrom: (1.2.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090806223219-8z4eej1u8levu4pz
Tags: 2.49a+dfsg-0ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/control: Build-depend on python-2.6 rather than python-2.5.
  - debian/misc/*.desktop: Add Spanish translation to .desktop 
    files.
  - debian/pyversions: 2.6.
  - debian/rules: Clean *.o of source/blender/python/api2_2x/
* New upstream release (LP: #382153).
* Refreshed patches:
  - 01_sanitize_sys.patch
  - 02_tmp_in_HOME
  - 10_use_systemwide_ftgl
  - 70_portability_platform_detection
* Removed patches merged upstream:
  - 30_fix_python_syntax_warning
  - 90_ubuntu_ffmpeg_52_changes

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()
 
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()