Skip to content

Instantly share code, notes, and snippets.

@mijinco0
Last active April 26, 2026 12:55
Show Gist options
  • Select an option

  • Save mijinco0/887ddd446bbc46d195f477166381d99e to your computer and use it in GitHub Desktop.

Select an option

Save mijinco0/887ddd446bbc46d195f477166381d99e to your computer and use it in GitHub Desktop.
dump all vertex group weights of Blender mesh objects to CSV.
# MIT License
#
# Copyright (c) 2026 nobiru
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the “Software”), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# dump all vertex group weights of Blender mesh objects to CSV.
# format: collection_name, object_name, vert_index, vert_group_name, vert_group_weight, weight_zero_flag
import sys
import csv
import bpy
WEIGHT_ZERO = "_WeightZero_"
def main():
dump_weights("weights.csv")
def dump_weights(fpath = None):
f = sys.stdout
if fpath:
try:
f = open(fpath, "w", newline = "", encoding = "utf-8")
except:
f = sys.stdout
writer = csv.writer(f);
writer.writerow(["collection", "object", "v.index", "group", "weight"])
for c in bpy.data.collections:
for o in c.objects:
if o.type != 'MESH':
continue
for v in o.data.vertices:
if v.groups:
for g in v.groups:
gname = o.vertex_groups[g.group].name
wz = WEIGHT_ZERO if (g.weight == 0 and len(v.groups) == 1) else ""
writer.writerow([c.name, o.name, v.index, gname, g.weight, wz])
else:
writer.writerow([c.name, o.name, v.index, "None", "None", WEIGHT_ZERO])
if f is not sys.stdout:
f.close()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment