Grrrr Python

I needed a simple script to add a feature to blender that I need when I rig meshes.
I need to be able to delete vertex groups that are not locked.
The current choice is to delete them all. I want to keep ones I locked and delete ones not locked.
So far I have this:

import bpy
##get vertex groups

obj = bpy.context.object

for group in obj.vertex_groups:
#set current group to active
bpy.ops.object.vertex_group_select()
If VertexGroup.lock_weight== False:
bpy.ops.object.vertex group remove(group)

I can not get the correct code to test if the group is locked or not. If it is not locked, I want to delete it.

What am I missing? Oops won’t let me indent.

See if this works

import bpy


obj = bpy.context.active_object

for group in obj.vertex_groups:
    if group.lock_weight == True:
        bpy.ops.object.vertex_group_remove(all=False, all_unlocked=True)

Getting a line 8 all_unocked unrecognizable?

I changed for active object. Post pic of error, I ran that 100 times with no error in blender 2.79

I’m getting this error. I’m using ver 2.78c

Attachments


Have no idea. Here is a sreenshot before and after I run the script and you can see there is no error.

Edit: I just tried 2.78a. It must be a new feature for 2.79 ,cause I do get the error in 2.78a

Before


After


Aha. Let me load it tomorrow and try it. What a big timeshare if I can get it working.

2.79 Blender works with the script. Thanks so much.