Created
June 29, 2022 23:04
-
-
Save rrazgriz/28e735324e1555b21ba81ddf68b4c2fe to your computer and use it in GitHub Desktop.
Blender: Find Unweighted Vertices
This file contains hidden or 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
# by Razgriz | |
# Select Unweighted Vertices on a Mesh | |
# | |
# To Use: | |
# Open Scripting Workspace (tab at top) | |
# Create a new script | |
# Paste script content in text editor | |
# Select Object in object mode | |
# Run script | |
import bpy | |
object = bpy.context.active_object.data | |
verts = object.vertices | |
color_map_collection = object.vertex_colors | |
unweighted_verts = [] | |
# Loop across polygons and verts | |
for poly in object.polygons: | |
for idx in poly.loop_indices: | |
v = object.loops[idx].vertex_index | |
if len(verts[v].groups) == 0: | |
unweighted_verts.append(verts[v].index) | |
if len(unweighted_verts) > 0: | |
print("Unweighted Verts Found") | |
bpy.ops.object.mode_set(mode = 'EDIT') | |
bpy.ops.mesh.select_mode(type="VERT") | |
bpy.ops.mesh.select_all(action = 'DESELECT') | |
bpy.ops.object.mode_set(mode = 'OBJECT') | |
for vid in unweighted_verts: | |
object.vertices[vid].select = True | |
bpy.ops.object.mode_set(mode = 'EDIT') | |
for area in bpy.context.screen.areas: # zoom to selected | |
if area.type == 'VIEW_3D': | |
ctx = bpy.context.copy() | |
ctx['area'] = area | |
ctx['region'] = area.regions[-1] | |
bpy.ops.view3d.view_selected(ctx) # points view | |
else: | |
print("No Unweighted Verts Found") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment