Merge branch 'master' into blender2.8
[blender-addons.git] / mesh_extra_tools / mesh_fastloop.py
blob0bfcc40510b3e59c67575357cff25811b0f49e08
1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
19 bl_info = {
20 "name": "Fast Loop",
21 "description": "Add loops fast",
22 "author": "Andy Davies (metalliandy)",
23 "version": (0, 1, 7),
24 "blender": (2, 5, 6),
25 "location": "Tool Shelf",
26 "warning": "",
27 "wiki_url": "",
28 "category": "Mesh"
31 """
32 About this script:-
33 This script enables the fast creation of multiple loops on a mesh
35 Usage:-
36 1)Click the FastLoop button on the Tool Shelf to activate the tool
37 2)Hover over the mesh in the general area where you would like a loop to be added
38 (shown by a highlight on the mesh)
39 3)Click once to confirm the loop placement
40 4)place the loop and then slide to fine tune its position
41 5)Repeat 1-4 if needed
42 6)Press Esc. twice to exit the tool
44 Related Links:-
45 http://blenderartists.org/forum/showthread.php?t=206989
46 http://www.metalliandy.com
48 Thanks to:-
49 Bartius Crouch (Crouch) - http://sites.google.com/site/bartiuscrouch/
50 Dealga McArdle (zeffii) - http://www.digitalaphasia.com
52 Version history:-
53 v0.16 - Amended script for compatibility with recent API changes
54 v0.15 - Amended script meta information and button rendering code for
55 compatibility with recent API changes
56 v0.14 - Modal operator
57 v0.13 - Initial revision
58 """
60 import bpy
61 from bpy.types import Operator
62 from bpy.props import BoolProperty
65 class OBJECT_OT_FastLoop(Operator):
66 bl_idname = "object_ot.fastloop"
67 bl_label = "FastLoop"
68 bl_description = ("Create multiple edge loops in succession\n"
69 "Runs modal until ESC is pressed twice")
71 active = BoolProperty(
72 name="active",
73 default=False
76 @classmethod
77 def poll(cls, context):
78 return bpy.ops.mesh.loopcut_slide.poll()
80 def modal(self, context, event):
81 if event.type == 'ESC':
82 context.area.header_text_set(None)
83 return {'CANCELLED'}
85 elif event.type == 'LEFTMOUSE' and event.value == 'RELEASE':
86 self.active = False
88 if not self.active:
89 self.active = True
90 bpy.ops.mesh.loopcut_slide('INVOKE_DEFAULT')
91 context.area.header_text_set("Press ESC twice to stop FastLoop")
93 return {'RUNNING_MODAL'}
95 def invoke(self, context, event):
96 context.window_manager.modal_handler_add(self)
98 return {'RUNNING_MODAL'}
101 def register():
102 bpy.utils.register_module(__name__)
103 pass
106 def unregister():
107 bpy.utils.unregister_module(__name__)
108 pass
111 if __name__ == "__main__":
112 register()