Circumference / Total length measure Tool


I’m totally new to Python and general coding.
I wanted to take some measurement on more then 1 edges, I used the Measure Panel add-on.
But this would not do my job.
I created this simple script by looking at other scripts and snippets examples and the Blender py gui files.
It takes the selected edges measures them and outputs there sum. I also put in a nice little tool panel with 1 button and the output.
Maybe someone else could use this. Or has some comment, adjustments, better ways to do this please post,.I want to use this tool to measure scanned body’s.

here is the code:

# select edges in edit mode
# outputs: sum of selected edge lenght 
import bpy  
from mathutils import Vector  

#toggle edit/object mode for (selection refresh?) 

#creat needed list
List = []  

#find selected edges
selected_edges = [v for v in if == 1]

#append vertices from selected edges to our lists
for i in selected_edges:   
    List.append([i.vertices[0], i.vertices[1]]) 

#find the distance between 2 vertices in an edge
List2 = []
meshdata =  

for pair in List:  
    vec1 = meshdata[pair[0]].co  
    vec2 = meshdata[pair[1]].co
    dist = (vec1-vec2).length  
print("debugger: 1 = good:",List2.count(dist)) 

#sum of all lenghts
S = sum(List2)


def getSingleObject(context):
    if len(context.selected_objects) == 1:
        return context.selected_objects[0]

    return None

dist =  S
context = bpy.context

if hasattr(bpy.context.scene, "totaal_length"):
    context.scene.totaal_length = dist

texts = [("Dist:")
class ToolsPanel(bpy.types.Panel):
    bl_label = "Circumference Tool"
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS"
    def draw(self, context):
        layout = self.layout
        scene = context.scene
        rd = scene.render
        col = layout.column(align=True)
        col.label(text="Selected edges length:")
        col.prop(context.scene, "totaal_length")
class OBJECT_OT_HelloButton(bpy.types.Operator):
    bl_idname = "hello.hello"
    bl_label = "Measure"
    def execute(self, context):
class OBJECT_OT_HelloButton2(bpy.types.Operator):
    bl_idname = "hello2.hello2"
    bl_label = "Total Length"
    def execute(self, context):

def register():    

    bpy.types.Scene.totaal_length = bpy.props.FloatProperty(
def unregister():


if __name__ == "__main__":

Good script for a beginner. A few remarks, seen as no one else commented yet.

if a bool variable is True

myBool = True
if myBool:
    print("yes, myBool is True")

myBool = False
if not myBool:
    print("no, myBool is False")

it’s only a small thing, but why not be lazy when the syntax prefers it? :slight_smile:

if == 1
# is equivalent to

Thanks for the comment, I really like your scripts actually I copied a part of your randomizing geometry script to measure the edge length.
I study fashion and I’m trying to use Blender as a open design tool, I’m really glad my first attempt to accomplish something with Python worked out. It’s mostly tying together code snippets but, I learned a lot on the way. I think the way I execute the button bpy.ops.script.python_file_run(filepath="") is not the good way. I think I need to use my registered operator. This week I will try out your GL-fillet script it looks real nice.

Thought I recognized some of the style :slight_smile: .That’s what the scripts are for. Pick, Mix, Learn and Improve. Your python_file_run() seems a bit ‘excessive’, but at the very least you experimented, persisted and made.what you wanted. Keep using longform variable/class/operator/etc names, saves headache lateron.

I really need a tool like this ASAP, but I am a blender noob, how do I run this?