diff --git a/extrusion/profile_extrude.py b/extrusion/profile_extrude.py index 678d28d..645d8d4 100644 --- a/extrusion/profile_extrude.py +++ b/extrusion/profile_extrude.py @@ -131,6 +131,7 @@ def do_invoke(self, context, event): self.extrusion_length_input_stream = new_stream() self.offset_input_stream = new_stream() + self.edit_mode = context.mode == 'EDIT_MESH' self.target_object = context.active_object @@ -160,7 +161,7 @@ def do_invoke(self, context, event): @classmethod def poll(cls, context): - if context.mode == 'OBJECT' and context.object is not None: + if context.mode in {'OBJECT', 'EDIT_MESH'} and context.object is not None: return len(context.selected_objects) == 1 and context.active_object.type == 'MESH' @@ -222,14 +223,24 @@ def add_smooth_shading(self, context): if not get_preferences().enable_auto_smooth: return + return_to_edit = False + if self.edit_mode: + bpy.ops.object.mode_set(mode='OBJECT') + return_to_edit = True + if bpy.app.version >= (4, 1, 0): self.smoothing = add_smooth_by_angle(self.target_object) + if return_to_edit: + bpy.ops.object.mode_set(mode='EDIT') return bpy.ops.object.shade_smooth() self.target_object.data.use_auto_smooth = True self.target_object.data.auto_smooth_angle = radians(float(get_preferences().default_smoothing_angle)) + if return_to_edit: + bpy.ops.object.mode_set(mode='EDIT') + def add_weighting_modifier(self, context): offset = new_modifier(self.target_object, mod_weighting, 'DISPLACE', rectify=True) diff --git a/extrusion/screw.py b/extrusion/screw.py index a32e950..f2d56a3 100644 --- a/extrusion/screw.py +++ b/extrusion/screw.py @@ -151,6 +151,7 @@ def do_invoke(self, context, event): self.dirty = False self.target_object = context.active_object self.object_type = self.target_object.type + self.edit_mode = context.mode == 'EDIT_MESH' self.axis = 2 # X (0), Y (1), Z (2) self.offset_axis = 1 # X (0), Y (1), Z (2) @@ -194,7 +195,7 @@ def do_invoke(self, context, event): @classmethod def poll(cls, context): - if context.mode == 'OBJECT' and context.active_object is not None: + if context.mode in {'OBJECT', 'EDIT_MESH'} and context.active_object is not None: return len(context.selected_objects) == 1 and context.active_object.type in ['MESH', 'CURVE'] @@ -238,14 +239,24 @@ def add_smooth_shading(self, context): if not get_preferences().enable_auto_smooth: return + return_to_edit = False + if self.edit_mode: + bpy.ops.object.mode_set(mode='OBJECT') + return_to_edit = True + if bpy.app.version >= (4, 1, 0): add_smooth_by_angle(self.target_object) + if return_to_edit: + bpy.ops.object.mode_set(mode='EDIT') return bpy.ops.object.shade_smooth() self.target_object.data.use_auto_smooth = True self.target_object.data.auto_smooth_angle = radians(float(get_preferences().default_smoothing_angle)) + if return_to_edit: + bpy.ops.object.mode_set(mode='EDIT') + def add_displace_modifier(self, context): displace = new_modifier(self.target_object, mod_displace, 'DISPLACE', rectify=True) diff --git a/replicate/mirror.py b/replicate/mirror.py index 64bc638..0774adf 100644 --- a/replicate/mirror.py +++ b/replicate/mirror.py @@ -104,6 +104,7 @@ def do_invoke(self, context, event): remove_modifiers_starting_with(context.selected_objects, 'Mirror —') return {'FINISHED'} + self.edit_mode = context.mode == 'EDIT_MESH' self.geometry_mode = event.alt self.early_apply = event.shift self.geometry_ready = False @@ -119,6 +120,10 @@ def do_invoke(self, context, event): self.report({'ERROR_INVALID_INPUT'}, "The mirror across selected geometry feature cannot be used on curves") return {'CANCELLED'} + if self.edit_mode and self.geometry_mode: + self.report({'ERROR_INVALID_INPUT'}, "The mirror across selected geometry feature cannot be used in edit mode") + return {'CANCELLED'} + if len(context.selected_objects) >= 2: self.reference_objs = [obj for obj in context.selected_objects if obj != context.active_object] self.mirror_obj = context.active_object @@ -153,6 +158,9 @@ def poll(cls, context): if len(context.selected_objects) >= 2 and context.active_object is not None: return all(obj.type in ['MESH', 'CURVE'] for obj in context.selected_objects if obj.name != context.active_object.name) + if context.mode == 'EDIT_MESH': + return len(context.selected_objects) == 1 and context.active_object is not None and context.active_object.type in ['MESH', 'CURVE'] + def set_selection_mode(self, context): bpy.ops.mesh.select_all(action='DESELECT') @@ -344,6 +352,9 @@ def operate(self, context): def select_reference_objs(self, context): + if self.edit_mode: + return + bpy.ops.object.select_all(action='DESELECT') for obj in self.reference_objs: obj.select_set(True) diff --git a/sketch/circularize.py b/sketch/circularize.py index faf289c..04be13e 100644 --- a/sketch/circularize.py +++ b/sketch/circularize.py @@ -99,6 +99,7 @@ def do_invoke(self, context, event): self.dirty = False self.segments = 2 + self.edit_mode = context.mode == 'EDIT_MESH' self.segments_input_stream = new_stream() self.width_input_stream = new_stream() @@ -129,7 +130,7 @@ def do_invoke(self, context, event): @classmethod def poll(cls, context): - if context.mode == 'OBJECT' and context.active_object is not None: + if context.mode in {'OBJECT', 'EDIT_MESH'} and context.active_object is not None: return len(context.selected_objects) == 1 and context.active_object.type == 'MESH' @@ -159,14 +160,24 @@ def add_smooth_shading(self, context): if not get_preferences().enable_auto_smooth: return + return_to_edit = False + if self.edit_mode: + bpy.ops.object.mode_set(mode='OBJECT') + return_to_edit = True + if bpy.app.version >= (4, 1, 0): add_smooth_by_angle(self.target_object) + if return_to_edit: + bpy.ops.object.mode_set(mode='EDIT') return bpy.ops.object.shade_smooth() self.target_object.data.use_auto_smooth = True self.target_object.data.auto_smooth_angle = radians(float(get_preferences().default_smoothing_angle)) + if return_to_edit: + bpy.ops.object.mode_set(mode='EDIT') + def add_bevel_modifier(self, context): bevel = new_modifier(self.target_object, mod_bevel, 'BEVEL', rectify=False)