~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to release/scripts/scripttemplate_object_edit.py

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!BPY
 
2
"""
 
3
Name: 'Object Editing'
 
4
Blender: 243
 
5
Group: 'ScriptTemplate'
 
6
Tooltip: 'Add a new text for editing selected objects'
 
7
"""
 
8
 
 
9
from Blender import Window
 
10
import bpy
 
11
 
 
12
script_data = \
 
13
'''#!BPY
 
14
"""
 
15
Name: 'My Object Script'
 
16
Blender: 244
 
17
Group: 'Object'
 
18
Tooltip: 'Put some useful info here'
 
19
"""
 
20
 
 
21
# Add a licence here if you wish to re-distribute, we recommend the GPL
 
22
 
 
23
from Blender import Window, sys
 
24
import bpy
 
25
 
 
26
def my_object_util(sce):
 
27
        
 
28
        # Remove these when writing your own tool
 
29
        print 'Blend object count', len(bpy.data.objects)
 
30
        print 'Scene object count', len(sce.objects)
 
31
        
 
32
        # context means its selected, in the view layer and not hidden.
 
33
        print 'Scene context count', len(sce.objects.context)
 
34
        
 
35
        # Examples
 
36
        
 
37
        # Move context objects on the x axis
 
38
        """
 
39
        for ob in sce.objects.context:
 
40
                ob.LocX += 1
 
41
        """
 
42
        
 
43
        # Copy Objects, does not copy object data
 
44
        """
 
45
        # Store the current contetx
 
46
        context = list(sce.objects.context)
 
47
        # de-select all
 
48
        sce.objects.selected = []
 
49
        
 
50
        for ob in context:
 
51
                ob_copy = ob.copy()
 
52
                sce.objects.link(ob_copy)       # the copy is not added to a scene
 
53
                ob_copy.sel = True
 
54
        """
 
55
 
 
56
def main():
 
57
        
 
58
        # Gets the current scene, there can be many scenes in 1 blend file.
 
59
        sce = bpy.data.scenes.active
 
60
        
 
61
        Window.WaitCursor(1)
 
62
        t = sys.time()
 
63
        
 
64
        # Run the object editing function
 
65
        my_object_util(sce)
 
66
        
 
67
        # Timing the script is a good way to be aware on any speed hits when scripting
 
68
        print 'My Script finished in %.2f seconds' % (sys.time()-t)
 
69
        Window.WaitCursor(0)
 
70
        
 
71
        
 
72
# This lets you can import the script without running it
 
73
if __name__ == '__main__':
 
74
        main()
 
75
 
 
76
'''
 
77
 
 
78
new_text = bpy.data.texts.new('object_template.py')
 
79
new_text.write(script_data)
 
80
bpy.data.texts.active = new_text
 
81
Window.RedrawAll()
 
 
b'\\ No newline at end of file'