This Addon will remove all Vertexgroups from an selected Object, wich are not used by any Modifiers. There is the possibilty to define a Tag to keep Vertexgroups.
If you find any Bugs let us know.
installation : save as phyton text data ( .py) install as usual with Blenders Addonmanager.
Addon location : Properties editor > Object Data ( name is : “remove unused vertexgroups” )
bl_info ={
"name": "Remove Unused Vertex Groups",
"author": " ScriptmasterScrotum and Dust ",
"categroie":"Object",
"version":(1,0),
"location":"Properties Editor > Object Data",
"description": "remove vertexgroups wich are not assigned to a modifier, a tag u can define by yourself can be used to keep vertexgroups wich are not assigned to a modifier. The tag just have to be inside the name of the Vetrexgroup",
"warning": "make sure to save before use this Addon",
"wiki_url":"",
"category":"Object"
}
import bpy
from bpy.props import StringProperty
class removeUnusedVertex(bpy.types.Panel):
bl_label = 'remove unused vertexgroups'
bl_idname = "object.removeunasignedvertexgroupsmenu"
bl_space_type= 'PROPERTIES'
bl_region_type='WINDOW'
bl_context='data'
def draw(self, context):
scene=context.scene
layout = self.layout
row = layout.row()
row.prop(scene,"string_input")
layout.label(text=' please save your projekt befor you use this plugin ')
layoutBox = layout.box()
layoutBox.operator("object.removeunasignedvertexgrpups")
class testClass(bpy.types.Operator):
""" removes all vertexgroups that are not assigned to a modifier (status 2.78c) vertexgroups containing the 'keep inside Tag' in their names will not removed"""
bl_idname="object.removeunasignedvertexgrpups"
bl_label = "remove vertexgroups not used by modifiers"
bl_options = {'REGISTER','UNDO'}
def execute(self, context):
# her is where the vertexgroups will be removed
activeObject = bpy.context.object
ObjModifier = activeObject.modifiers
ObjVertexgroups = activeObject.vertex_groups
DeleteVertexgroup=True;
for Vertexgroups in ObjVertexgroups:
actualVertexGroup= Vertexgroups
DeleteVertexgroup=True
if context.scene.string_input in actualVertexGroup.name:
continue
for actualModifier in ObjModifier:
if DeleteVertexgroup==False :
break
try:
if(not (actualModifier.vertex_group is None)):
if actualModifier.vertex_group == actualVertexGroup.name:
DeleteVertexgroup=False
break
except AttributeError:
pass
try:
if(not (actualModifier.mask_vertex_group is None)):
if actualModifier.mask_vertex_group == actualVertexGroup.name:
DeleteVertexgroup=False
break
except AttributeError:
pass
if actualModifier.type == 'ARMATURE':
if not (actualModifier.object==None):
for bone in actualModifier.object.data.bones:
if bone.name == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.type=='SOFT_BODY':
if actualModifier.settings.vertex_group_mass == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.settings.vertex_group_goal == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.settings.vertex_group_spring == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.type =='VERTEX_WEIGHT_MIX':
if actualModifier.vertex_group_b==actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.vertex_group_a==actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.type == 'CLOTH':
if actualModifier.settings.vertex_group_shrink == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.settings.vertex_group_mass == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.settings.vertex_group_structural_stiffness == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.settings.vertex_group_bending == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.collision_settings.vertex_group_self_collisions == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.type == 'SMOKE':
if actualModifier.flow_settings.density_vertex_group == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.type == 'PARTICLE_SYSTEM':
if actualModifier.particle_system.vertex_group_density == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.particle_system.vertex_group_velocity == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.particle_system.vertex_group_length == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.particle_system.vertex_group_clump == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.particle_system.vertex_group_kink == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.particle_system.vertex_group_roughness_1 == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.particle_system.vertex_group_roughness_2 == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.particle_system.vertex_group_roughness_end == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.particle_system.vertex_group_size == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.particle_system.vertex_group_tangent == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.particle_system.vertex_group_rotation == actualVertexGroup.name:
DeleteVertexgroup=False
break
if actualModifier.particle_system.vertex_group_field == actualVertexGroup.name:
DeleteVertexgroup=False
break
if DeleteVertexgroup==False:
continue
print("remove : "+ actualVertexGroup.name )
ObjVertexgroups.remove(actualVertexGroup)
#end romving vertexgroups
return {'FINISHED'}
def register():
bpy.utils.register_module(__name__)
bpy.types.Scene.string_input= bpy.props.StringProperty(
name="keep inside Tag",
description="vertexgroups containing this string will not removed",
default="###",
subtype ='NONE'
)
def unregister():
del bpy.types.Scene.string_input
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()