Skip to content

Instantly share code, notes, and snippets.

@p2or
Last active May 21, 2023 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save p2or/48349f188f49072c1d41170d02773a24 to your computer and use it in GitHub Desktop.
Save p2or/48349f188f49072c1d41170d02773a24 to your computer and use it in GitHub Desktop.
Groups by Vert count #Blender
import bpy
data = {}
for obj in bpy.data.objects: # bpy.context.selected_objects
if obj.type == 'MESH':
data.setdefault(len(obj.data.vertices), []).append(obj)
for key, value in data.items():
group_name = "{} Vertices".format(key)
if group_name not in bpy.data.groups:
bpy.ops.group.create(name=group_name)
grp = bpy.data.groups.get(group_name)
for obj in value:
if len(obj.users_group) == 0:
grp.objects.link(obj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment