Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2007-02-21 14:17:17 +0300
committerCampbell Barton <ideasman42@gmail.com>2007-02-21 14:17:17 +0300
commitf71458b90483e33923e706e1b6aa6612dd0fd425 (patch)
tree7850f63e7ee8bb4462d7125041434fa35c358a8a /release
parent6831c0453371f7b90428686e74b485f76620cf9d (diff)
adding menu slot Armature
adding menu slot ScriptTemplate new script scripttemplate_mesh_edit is a template for an editmesh script. The function Text makeCurrent() is a dummy until I can get it working when the script runs from a menu.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/armature_symmetry.py4
-rw-r--r--release/scripts/scripttemplate_mesh_edit.py93
2 files changed, 95 insertions, 2 deletions
diff --git a/release/scripts/armature_symmetry.py b/release/scripts/armature_symmetry.py
index 1e4484d0efc..b4b3e54516c 100644
--- a/release/scripts/armature_symmetry.py
+++ b/release/scripts/armature_symmetry.py
@@ -3,8 +3,8 @@
"""
Name: 'Armature Symmetry'
Blender: 242
-Group: 'Animation'
-Tooltip: 'Make an Armature symetrical'
+Group: 'Armature'
+Tooltip: 'Make an Armature symmetrical'
"""
__author__ = "Campbell Barton"
diff --git a/release/scripts/scripttemplate_mesh_edit.py b/release/scripts/scripttemplate_mesh_edit.py
new file mode 100644
index 00000000000..ca8077e3865
--- /dev/null
+++ b/release/scripts/scripttemplate_mesh_edit.py
@@ -0,0 +1,93 @@
+#!BPY
+"""
+Name: 'Mesh Editing'
+Blender: 243
+Group: 'ScriptTemplate'
+Tooltip: 'Add a new text for editing a mesh'
+"""
+
+from Blender import Text, Window
+
+script_data = '''
+#!BPY
+"""
+Name: 'My Mesh Script'
+Blender: 243
+Group: 'Mesh'
+Tooltip: 'Put some useful info here'
+"""
+
+# Add a licence here if you wish to re-distribute, we recommend the GPL
+
+from Blender import Scene, Mesh, Window, sys
+import BPyMessages
+
+def my_mesh_util(me):
+ # This function runs out of editmode with a mesh
+ # error cases are alredy checked for
+
+ # Remove these when writing your own tool
+ print me.name
+ print 'vert count', len(me.verts)
+ print 'edge count', len(me.edges)
+ print 'face count', len(me.faces)
+
+ # Examples
+
+ # Move selected verts on the x axis
+ """
+ for v in me.verts:
+ if v.sel:
+ v.co.x += 1.0
+ """
+
+ # Shrink selected faces
+ """
+ for f in me.faces:
+ if f.sel:
+ c = f.cent
+ for v in f:
+ v.co = (c+v.co)/2
+ """
+
+def main():
+
+ # Gets the current scene, there can be many scenes in 1 blend file.
+ sce = Scene.GetCurrent()
+
+ # Get the active object, there can only ever be 1
+ # and the active object is always the editmode object.
+ ob_act = sce.objects.active
+
+ if not ob_act or ob_act.type != 'Mesh':
+ BPyMessages.Error_NoMeshActive()
+ return
+
+
+ # Saves the editmode state and go's out of
+ # editmode if its enabled, we cant make
+ # changes to the mesh data while in editmode.
+ is_editmode = Window.EditMode()
+ if is_editmode: Window.EditMode(1)
+
+ Window.WaitCursor(1)
+ me = ob_act.getData(mesh=1)
+ t = sys.time()
+
+ # Run the mesh editing function
+ my_mesh_util(me)
+
+ # Timing the script is a good way to be aware on any speed hits when scripting
+ print 'My Script finished in %.2f seconds' % (sys.time()-t)
+ Window.WaitCursor(0)
+
+
+# This lets you can import the script without running it
+if __name__ == '__main__':
+ main()
+'''
+
+new_text = Text.New('mesh_template.py')
+new_text.write(script_data)
+new_text.makeCurrent()
+Window.RedrawAll() \ No newline at end of file