Fix error in rigify property generation
[blender-addons.git] / curve_tools / fillet.py
blob911d88c4db616ccc75344de3018a9d0eb0dd67fc
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': 'Curve Fillet',
21 'author': 'Spivak Vladimir (cwolf3d)',
22 'version': (0, 0, 1),
23 'blender': (2, 80, 0),
24 'location': 'Curve Tools addon. (N) Panel',
25 'description': 'Various types of fillet (chamfering)',
26 'warning': '', # used for warning icon and text in addons panel
27 'doc_url': '',
28 'tracker_url': '',
29 'category': 'Curve',
33 import bpy
34 from bpy.props import *
35 from bpy_extras import object_utils, view3d_utils
36 from mathutils import *
37 from math import *
39 def click(self, context, event):
40 bpy.ops.object.mode_set(mode = 'EDIT')
41 bpy.context.view_layer.update()
44 def remove_handler(handlers):
45 for handler in handlers:
46 try:
47 bpy.types.SpaceView3D.draw_handler_remove(handler, 'WINDOW')
48 except:
49 pass
50 for handler in handlers:
51 handlers.remove(handler)
54 class Fillet(bpy.types.Operator):
55 bl_idname = "curvetools.fillet"
56 bl_label = "Curve Fillet"
57 bl_description = "Curve Fillet"
58 bl_options = {'REGISTER', 'UNDO'}
60 x: IntProperty(name="x", description="x")
61 y: IntProperty(name="y", description="y")
62 location3D: FloatVectorProperty(name = "",
63 description = "Start location",
64 default = (0.0, 0.0, 0.0),
65 subtype = 'XYZ')
67 handlers = []
69 def execute(self, context):
70 self.report({'INFO'}, "ESC or TAB - cancel")
71 bpy.ops.object.mode_set(mode = 'EDIT')
73 # color change in the panel
74 self.path_color = bpy.context.scene.curvetools.path_color
75 self.path_thickness = bpy.context.scene.curvetools.path_thickness
77 def modal(self, context, event):
78 context.area.tag_redraw()
80 if event.type in {'ESC', 'TAB'}: # Cancel
81 remove_handler(self.handlers)
82 return {'CANCELLED'}
84 if event.type in {'X', 'DEL'}: # Cancel
85 remove_handler(self.handlers)
86 bpy.ops.curve.delete(type='VERT')
87 return {'RUNNING_MODAL'}
89 elif event.alt and event.shift and event.type == 'LEFTMOUSE':
90 click(self, context, event)
92 elif event.alt and not event.shift and event.type == 'LEFTMOUSE':
93 remove_handler(self.handlers)
94 bpy.ops.curve.select_all(action='DESELECT')
95 click(self, context, event)
97 elif event.alt and event.type == 'RIGHTMOUSE':
98 remove_handler(self.handlers)
99 bpy.ops.curve.select_all(action='DESELECT')
100 click(self, context, event)
102 elif event.alt and not event.shift and event.shift and event.type == 'RIGHTMOUSE':
103 click(self, context, event)
105 elif event.type == 'A':
106 remove_handler(self.handlers)
107 bpy.ops.curve.select_all(action='DESELECT')
109 elif event.type == 'MOUSEMOVE': #
110 self.x = event.mouse_x
111 self.y = event.mouse_y
112 region = bpy.context.region
113 rv3d = bpy.context.space_data.region_3d
114 self.location3D = view3d_utils.region_2d_to_location_3d(
115 region,
116 rv3d,
117 (event.mouse_region_x, event.mouse_region_y),
118 (0.0, 0.0, 0.0)
121 return {'PASS_THROUGH'}
123 def invoke(self, context, event):
124 self.execute(context)
125 context.window_manager.modal_handler_add(self)
126 return {'RUNNING_MODAL'}
128 @classmethod
129 def poll(cls, context):
130 return (context.object is not None and
131 context.object.type == 'CURVE')
133 def register():
134 for cls in classes:
135 bpy.utils.register_class(operators)
137 def unregister():
138 for cls in classes:
139 bpy.utils.unregister_class(operators)
141 if __name__ == "__main__":
142 register()
144 operators = [Fillet]