I am working with blender 2.78, and I want to export the edge lengths of a mesh to a file text, but I don't know how to do it with Blender. I will explain more, I have a bunny wavefront, and I did display the edge length using the Transform panel. Then what I want to know is there a way to export those lengths in a text file for example. I searched on the net and I found that I can use the NeuroMorph Measurement Tools, I did add the tool but it seems that it exports just the area and volume but not what I want. NeuroMorph Measurement Tools

It is obvious that we can just compute the lengths based on coordinates of vertices and faces stored in the .obj file, and take into account the repetition of edges between tow adjacent faces (the thing that I haven't think about how to implement it yet on Matlab). But if it is possible to get it from blender directly it would be great.

It might be a simple way but I am pretty new with blender and I don't find the way.


1 Answer 1


You can use this script, tested on happy.ply for performance test (6 seconds on my laptop):

import bpy
import time

#Calc the length between 2 vertices given by vertex index
def CalcLength( obj, vertices ):
    v1 = obj.data.vertices[vertices[0]] #Get the first
    v2 = obj.data.vertices[vertices[1]] #Get the second
    return (v1.co - v2.co).length #Calculate the length from their coordinates

#In object mode
obj = bpy.context.object #selected object
#obj = bpy.data.objects['name'] #or by name

fileName = "c:\\tmp\\exemple.txt" #Your file name

file = open( fileName, 'w+' ) #Open a file (will create or erase an existing one

startTime = time.time()

    #Write to the file the length of each edge
    file.write( '\n'.join([str(CalcLength(obj, e.vertices)) for e in obj.data.edges] ) )

executionTime = time.time() - startTime
print( executionTime )

Here is the file so you can look at the setting:

  • $\begingroup$ thank you so much for help, it works great. Thank you a lot. $\endgroup$
    – J.Hr
    Apr 3, 2017 at 10:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .