diff --git a/oscurart_tools/__init__.py b/oscurart_tools/__init__.py index b5bcaae98795de274d7a3aa7b49b989555500ffa..4986ef824f74dc1f52a1b42f0eaa6ddfc78e9e1f 100644 --- a/oscurart_tools/__init__.py +++ b/oscurart_tools/__init__.py @@ -41,6 +41,7 @@ from oscurart_tools.mesh import overlap_uvs from oscurart_tools.mesh import overlap_island from oscurart_tools.mesh import select_doubles from oscurart_tools.mesh import shapes_to_objects +from oscurart_tools.mesh import remove_modifiers from oscurart_tools.object import distribute from oscurart_tools.object import selection from oscurart_tools.object import search_and_select @@ -48,6 +49,7 @@ from oscurart_tools.mesh import apply_linked_meshes from oscurart_tools.render import render_tokens from oscurart_tools.render import batch_maker + from bpy.types import ( AddonPreferences, Panel, @@ -110,6 +112,7 @@ class VIEW3D_MT_object_oscurarttools(Menu): layout = self.layout layout.operator("object.distribute_osc") + layout.operator("mesh.remove_modifiers") layout.operator("object.search_and_select_osc") layout.operator("object.shape_key_to_objects_osc") layout.operator("mesh.apply_linked_meshes") @@ -142,7 +145,8 @@ classes = ( shapes_to_objects.ShapeToObjects, search_and_select.SearchAndSelectOt, apply_linked_meshes.ApplyLRT, - batch_maker.oscBatchMaker + batch_maker.oscBatchMaker, + remove_modifiers.RemoveModifiers ) def register(): diff --git a/oscurart_tools/mesh/remove_modifiers.py b/oscurart_tools/mesh/remove_modifiers.py new file mode 100644 index 0000000000000000000000000000000000000000..186588ce4dc6051056f54b1c604ee188401c245a --- /dev/null +++ b/oscurart_tools/mesh/remove_modifiers.py @@ -0,0 +1,47 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# <pep8 compliant> + +import bpy + + +def funcRemoveModifiers(self,context): + for ob in bpy.context.selected_objects: + if ob.type == "MESH": + for mod in ob.modifiers: + ob.modifiers.remove(mod) + +class RemoveModifiers(bpy.types.Operator): + """Remove all mesh modifiers""" + bl_idname = "mesh.remove_modifiers" + bl_label = "Remove Modifiers" + bl_options = {"REGISTER", "UNDO"} + + @classmethod + def poll(cls, context): + return (context.view_layer.objects.active is not None and + context.view_layer.objects.active.type == 'MESH') + + + def execute(self, context): + funcRemoveModifiers(self,context) + return {'FINISHED'} + + +