5
Group: 'ScriptTemplate'
6
Tooltip: 'Add a new text for editing a mesh'
9
from Blender import Window
15
Name: 'My Mesh Script'
18
Tooltip: 'Put some useful info here'
21
# Add a licence here if you wish to re-distribute, we recommend the GPL
23
from Blender import Scene, Mesh, Window, sys
28
# This function runs out of editmode with a mesh
29
# error cases are alredy checked for
31
# Remove these when writing your own tool
33
print 'vert count', len(me.verts)
34
print 'edge count', len(me.edges)
35
print 'face count', len(me.faces)
39
# Move selected verts on the x axis
46
# Shrink selected faces
57
# Gets the current scene, there can be many scenes in 1 blend file.
58
sce = bpy.data.scenes.active
60
# Get the active object, there can only ever be 1
61
# and the active object is always the editmode object.
62
ob_act = sce.objects.active
64
if not ob_act or ob_act.type != 'Mesh':
65
BPyMessages.Error_NoMeshActive()
69
# Saves the editmode state and go's out of
70
# editmode if its enabled, we cant make
71
# changes to the mesh data while in editmode.
72
is_editmode = Window.EditMode()
75
me = ob_act.getData(mesh=1) # old NMesh api is default
78
# Run the mesh editing function
81
# Restore editmode if it was enabled
82
if is_editmode: Window.EditMode(1)
84
# Timing the script is a good way to be aware on any speed hits when scripting
85
print 'My Script finished in %.2f seconds' % (sys.time()-t)
89
# This lets you can import the script without running it
90
if __name__ == '__main__':
94
new_text = bpy.data.texts.new('mesh_template.py')
95
new_text.write(script_data)
96
bpy.data.texts.active = new_text
b'\\ No newline at end of file'