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 #####
20 'name': 'Curve Fillet',
21 'author': 'Spivak Vladimir (cwolf3d)',
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
34 from bpy
.props
import *
35 from bpy_extras
import object_utils
, view3d_utils
36 from mathutils
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
:
47 bpy
.types
.SpaceView3D
.draw_handler_remove(handler
, 'WINDOW')
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),
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
)
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(
117 (event
.mouse_region_x
, event
.mouse_region_y
),
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'}
129 def poll(cls
, context
):
130 return (context
.object is not None and
131 context
.object.type == 'CURVE')
135 bpy
.utils
.register_class(operators
)
139 bpy
.utils
.unregister_class(operators
)
141 if __name__
== "__main__":