Last active
May 21, 2023 19:14
-
-
Save p2or/48349f188f49072c1d41170d02773a24 to your computer and use it in GitHub Desktop.
Groups by Vert count #Blender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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