1 # SPDX-FileCopyrightText: 2019-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
6 'name': 'Curve Fillet',
7 'author': 'Spivak Vladimir (cwolf3d)',
10 'location': 'Curve Tools addon. (N) Panel',
11 'description': 'Various types of fillet (chamfering)',
12 'warning': '', # used for warning icon and text in addons panel
20 from bpy
.props
import *
21 from bpy_extras
import object_utils
, view3d_utils
22 from mathutils
import *
25 def click(self
, context
, event
):
26 bpy
.ops
.object.mode_set(mode
= 'EDIT')
27 bpy
.context
.view_layer
.update()
30 def remove_handler(handlers
):
31 for handler
in handlers
:
33 bpy
.types
.SpaceView3D
.draw_handler_remove(handler
, 'WINDOW')
36 for handler
in handlers
:
37 handlers
.remove(handler
)
40 class Fillet(bpy
.types
.Operator
):
41 bl_idname
= "curvetools.fillet"
42 bl_label
= "Curve Fillet"
43 bl_description
= "Curve Fillet"
44 bl_options
= {'REGISTER', 'UNDO'}
46 x
: IntProperty(name
="x", description
="x")
47 y
: IntProperty(name
="y", description
="y")
48 location3D
: FloatVectorProperty(name
= "",
49 description
= "Start location",
50 default
= (0.0, 0.0, 0.0),
55 def execute(self
, context
):
56 self
.report({'INFO'}, "ESC or TAB - cancel")
57 bpy
.ops
.object.mode_set(mode
= 'EDIT')
59 # color change in the panel
60 self
.path_color
= bpy
.context
.scene
.curvetools
.path_color
61 self
.path_thickness
= bpy
.context
.scene
.curvetools
.path_thickness
63 def modal(self
, context
, event
):
64 context
.area
.tag_redraw()
66 if event
.type in {'ESC', 'TAB'}: # Cancel
67 remove_handler(self
.handlers
)
70 if event
.type in {'X', 'DEL'}: # Cancel
71 remove_handler(self
.handlers
)
72 bpy
.ops
.curve
.delete(type='VERT')
73 return {'RUNNING_MODAL'}
75 elif event
.alt
and event
.shift
and event
.type == 'LEFTMOUSE':
76 click(self
, context
, event
)
78 elif event
.alt
and not event
.shift
and event
.type == 'LEFTMOUSE':
79 remove_handler(self
.handlers
)
80 bpy
.ops
.curve
.select_all(action
='DESELECT')
81 click(self
, context
, event
)
83 elif event
.alt
and event
.type == 'RIGHTMOUSE':
84 remove_handler(self
.handlers
)
85 bpy
.ops
.curve
.select_all(action
='DESELECT')
86 click(self
, context
, event
)
88 elif event
.alt
and not event
.shift
and event
.shift
and event
.type == 'RIGHTMOUSE':
89 click(self
, context
, event
)
91 elif event
.type == 'A':
92 remove_handler(self
.handlers
)
93 bpy
.ops
.curve
.select_all(action
='DESELECT')
95 elif event
.type == 'MOUSEMOVE': #
96 self
.x
= event
.mouse_x
97 self
.y
= event
.mouse_y
98 region
= bpy
.context
.region
99 rv3d
= bpy
.context
.space_data
.region_3d
100 self
.location3D
= view3d_utils
.region_2d_to_location_3d(
103 (event
.mouse_region_x
, event
.mouse_region_y
),
107 return {'PASS_THROUGH'}
109 def invoke(self
, context
, event
):
110 self
.execute(context
)
111 context
.window_manager
.modal_handler_add(self
)
112 return {'RUNNING_MODAL'}
115 def poll(cls
, context
):
116 return (context
.object is not None and
117 context
.object.type == 'CURVE')
121 bpy
.utils
.register_class(operators
)
125 bpy
.utils
.unregister_class(operators
)
127 if __name__
== "__main__":