hey all you great coders, is there a script out there that can find vertices that isnt part of a vertex group and makes them selected.
Ok, I’m no expert(just started learning python 4-5 days ago), but I think I can point you in the right direction. You would need to get the active selected objects with “Blender.Object.GetSelected()”. Then pick the one you want out of the list, do checking for meshes, etc. Then get the mesh data for it “blah.getData(mesh=1)”. Then you would use getVertGroupNames(), and if it returns a blank value, then all the verts are ungrouped so select them all. If not a blank value you would pass all returned names to a loop that goes through them all to check the verts in the groups.
EDIT: Ok, I figured out how to select vertices. You go OUT of editmode, set the verts[blah].sel=1, and then go IN to editmode.
I updated the code, but it still doesn’t check to see if a vert is in a group, just give me some time. It also doesn’t have the imports yet.
Maybe someone that is actually good at python can fill in the rest. I have absolutely no idea on how to see if a vert is in many groups. I’d be able to check one group, but I don’t see a way to iterate through them all and just get the ones in no group.
If you figure this out on your own, please tell me what you did.
I started making some example code, but I’m lost on how to just get the ones that aren’t in the list. Here it is anyways:
Blender.Window.EditMode(0) selected=Blender.Object.GetSelected() object=selected mesh=object.getData(mesh=1) verts = [v for v in mesh.verts] toselect= groups=mesh.getVertGroupNames() if len(groups)>0: for group in groups: vertsingroup=mesh.getVertsFromGroup(group) #do something here, I don't know else: for v in verts: v.sel=0 toselect.append(v.index) for j in range(len(toselect)): verts[toselect[j]].sel=1 Blender.Window.EditMode(1)
Maybe someone can help me help you.
one way to go about it is to convert vertexgroups to sets and then do set operations on them. For example:
groups= for name in me.getVertGroupNames(): groups.append(set(me.getVertsFromGroup(name))) allverts=set([v.index for v in me.verts]) for s in groups: allverts -= s for i in s: me.verts[i].sel=1
By creating a set of the indices of all verts we can simply eliminate any vertex that is in a vertex group by substracting from the set. In the end all that remains has no associated vertex group so we sel them. The added advantage is that set operations in Python are really fast, so this is effecient for large meshes as well. Please note that this code is not tested so may contain a typo or two.
as i am not a python scripter like you amazing guys, i have hit a error with your script Varkenvarken, i copied the script into the blender text editor and ran it and got a
NameError: name 'me' is not defined
am i doing it right
He didn’t give you a full script. You need to set up me as the object you want and use getData() on it.
Plus I think it wouldn’t work anyways. I tried completing it, but it still selects all the verts:
Blender.Window.EditMode(0) selected=Blender.Object.GetSelected() object=selected me=object.getData() groups= for name in me.getVertGroupNames(): groups.append(set(me.getVertsFromGroup(name))) allverts=set([v.index for v in me.verts]) for v in allverts: me.verts[v].sel=0 for s in groups: allverts -= s for i in s: me.verts[i].sel=1 Blender.Window.EditMode(1)
Here, it may not be elegant, but it works. As it was written, varkenvarken’s script was selecting the verts that were a part of a group, so instead, I made all of the verts be selected, and then deselected the verts in the group.
Here’s the complete code:
import Blender as b obj = b.Object.GetSelected() me = obj.getData(mesh = True) groups= for name in me.getVertGroupNames(): groups.append(set(me.getVertsFromGroup(name))) allverts = set([v.index for v in me.verts]) for vert in me.verts: vert.sel = 1 for s in groups: allverts = allverts - s for i in s: me.verts[i].sel = 0