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
Showing only changes of commit 9a79de5b3a - Show all commits

View File

@ -52,18 +52,23 @@ class OperatorCurveInfo(bpy.types.Operator):
class OperatorCurveLength(bpy.types.Operator):
bl_idname = "curvetools.operatorcurvelength"
bl_label = "Length"
bl_description = "Calculates the length of the active/selected curve"
bl_description = "Calculates the length of the active/selected curves"
@classmethod
def poll(cls, context):
return util.Selected1Curve()
return util.Selected1OrMoreCurves()
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'}