Skip to content

Instantly share code, notes, and snippets.

Last active April 25, 2018 02:04
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
preliminary_edge_length addon
bl_info = {
"name": "Edge sum",
"author": "zeffii",
"version": (0, 1, 0),
"blender": (2, 7, 7),
"location": "3d view, N panel",
"description": "Adds edge sum box to Mesh Display.",
"wiki_url": "",
"tracker_url": "",
"category": "3D View"}
# where Adhi suggests the space_view3d_panel_measure import.
import bpy
import bmesh
import space_view3d_panel_measure as pm
def print_details(num_edges, edge_length):
print("number of edges: {0}".format(num_edges))
print("combined length: {0:6f}".format(edge_length))
def get_combined_length(object_reference):
# Get a BMesh representation
bm = bmesh.from_edit_mesh(
selected_edges = [edge for edge in bm.edges if]
num_edges = len(selected_edges)
edge_length = 0
for edge in selected_edges:
edge_length += edge.calc_length()
print_details(num_edges, edge_length)
return round(edge_length, 6)
class SumButton(bpy.types.Operator):
bl_idname = "scene.calculate_length"
bl_label = "Sometype of operator"
bpy.types.Scene.sum_addon_length = bpy.props.StringProperty(name = "")
def execute(self, context):
obj_reference = context.active_object
length = get_combined_length(obj_reference)
uinfo = pm.getUnitsInfo()
length = pm.convertDistance(length, uinfo)
context.scene.sum_addon_length = length
class CopyLength(bpy.types.Operator):
bl_idname = "scene.copy_length"
bl_label = "copy to clipboard"
def execute(self, context):
context.window_manager.clipboard = context.scene.sum_addon_length
def draw_item(self, context):
layout = self.layout
obj = context.object
row = layout.row()
scn = context.scene
# display label and button
if obj:
row.label(text="summed edge length:")
row = layout.row()
split = row.split(percentage=0.50)
col = split.column()
col.prop(scn, 'sum_addon_length')
split = split.split()
col = split.column()
col.operator("scene.calculate_length", text='Sum')
split = split.split()
col = split.column()
col.operator("scene.copy_length", text='Copy')
def register():
def unregister():
if __name__ == "__main__":
Copy link

mazeto commented Mar 3, 2015

Excellent! Just what I was looking for the whole day! Thanks dude!

Copy link

But!!! Dont work in 2.75 and dont calculate summed select area poligons

Copy link

zeffii commented May 9, 2016

@mazeto @Spirit412 What errors are you getting?

Copy link

zeffii commented May 9, 2016

@Spirit412 -- it isn't designed to calculate selected polygon area, but it would be easy to add.

Copy link

thuydtd commented Jun 29, 2016

I cannot install your addon with Blender 2.77
This is my screenshot.
Thank you.


Copy link

I'm getting a similar error as thuydtd. It looks as though 'Edge Length' depended on 'View3D Measure Panel', which was removed because it was broken.

@zeffii, Is there any chance 'Edge Length' will be updated? I've been using it for making accurate measurements of body parts on character meshes, for clothing design.

Copy link

This is not working for 2.77c, is there any chance that this will be updated ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment