I have several vertex groups separated on my 3D model and I would like to export the spreadsheet that reflects the x,y, and z data along with the vertex groups data. I have already been able to export only the x,y, and z data as a .csv file using a code I found on here. However, I haven’t been able to find any solutions to export the table shown below of the vertex groups. In this example listed below, I would want to export the area of the table with ‘Ears’, ‘Mouth’, ‘Eyes’, and ‘Face’ as a .csv file as well with the vertices.
The code that I have tried from Blender artists iceythe Kaoi can be found at: How do I Export an Object's Vertex Positions? - #16 by KickAir_8P
- I was to successfully export the vertices themselves in csv form but not the corresponding vertex group information.
- ^^ The table I would like to export
import bpy
import os
def write_verts():
obj = bpy.context.object
if obj is None or obj.type != "MESH":
return
# Output geometry
obj_eval = obj.evaluated_get(bpy.context.view_layer.depsgraph)
filepath = "vertices.csv"
with open(filepath, "w") as file:
# Write the header, pos x | pos y | pos z
file.write("pos x,pos y,pos z\n")
for v in obj_eval.data.vertices:
# ":.3f" means to use 3 fixed digits after the decimal point.
file.write(f",".join(f"{c:.3f}" for c in v.co) + "\n")
print(f"File was written to {os.path.join(os.getcwd(), filepath)}")
if __name__ == "__main__":
write_verts()
- ^^The code from iceythe Kaoi that I have used.