Curve tools: Calculate length on multiple curves #104836

Merged
Germano Cavalcante merged 2 commits from sigmike/blender-addons:length_on_multiple_curves into main 2023-08-16 23:12:08 +02:00
2 changed files with 10 additions and 5 deletions

View File

@ -6,7 +6,7 @@ bl_info = {
"name": "Curve Tools", "name": "Curve Tools",
"description": "Adds some functionality for bezier/nurbs curve/surface modeling", "description": "Adds some functionality for bezier/nurbs curve/surface modeling",
"author": "Mackraken, Spivak Vladimir (cwolf3d)", "author": "Mackraken, Spivak Vladimir (cwolf3d)",
"version": (0, 4, 5), "version": (0, 4, 6),
"blender": (2, 80, 0), "blender": (2, 80, 0),
"location": "View3D > Tool Shelf > Edit Tab", "location": "View3D > Tool Shelf > Edit Tab",
"doc_url": "{BLENDER_MANUAL_URL}/addons/add_curve/curve_tools.html", "doc_url": "{BLENDER_MANUAL_URL}/addons/add_curve/curve_tools.html",

View File

@ -52,18 +52,23 @@ class OperatorCurveInfo(bpy.types.Operator):
class OperatorCurveLength(bpy.types.Operator): class OperatorCurveLength(bpy.types.Operator):
bl_idname = "curvetools.operatorcurvelength" bl_idname = "curvetools.operatorcurvelength"
bl_label = "Length" bl_label = "Length"
bl_description = "Calculates the length of the active/selected curve" bl_description = "Calculates the length of the active/selected curves"
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return util.Selected1Curve() return util.Selected1OrMoreCurves()
def execute(self, context): def execute(self, context):
curve = curves.Curve(context.active_object) selCurves = util.GetSelectedCurves()
context.scene.curvetools.CurveLength = curve.length length = 0
for blCurve in selCurves:
curve = curves.Curve(blCurve)
length += curve.length
context.scene.curvetools.CurveLength = length
return {'FINISHED'} return {'FINISHED'}