From 65a35c8e4b21fd9ffad63dbd9dd3d206edffc919 Mon Sep 17 00:00:00 2001 From: nagadomi Date: Wed, 1 Jul 2020 11:12:06 +0900 Subject: [PATCH] Fix time.clock() error in Python 3.8 --- op_rectify.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/op_rectify.py b/op_rectify.py index e5fc90a..d1b3348 100644 --- a/op_rectify.py +++ b/op_rectify.py @@ -4,6 +4,7 @@ import operator from mathutils import Vector from collections import defaultdict from math import pi +import sys import time from math import radians, hypot @@ -38,7 +39,11 @@ class op(bpy.types.Operator): rectify(self, context) return {'FINISHED'} - +def time_clock(): + if sys.version_info >= (3, 3): + return time.process_time() + else: + return time.clock() precision = 3 @@ -61,7 +66,7 @@ def rectify(self, context): def main(square = False, snapToClosest = False): - startTime = time.clock() + startTime = time_clock() obj = bpy.context.active_object me = obj.data bm = bmesh.from_edit_mesh(me) @@ -310,7 +315,7 @@ def SuccessFinished(me, startTime): #use for backtrack of steps #bpy.ops.ed.undo_push() bmesh.update_edit_mesh(me) - #elapsed = round(time.clock()-startTime, 2) + #elapsed = round(time_clock()-startTime, 2) #if (elapsed >= 0.05): operator.report({'INFO'}, "UvSquares finished, elapsed:", elapsed, "s.") return @@ -634,4 +639,4 @@ def hypotVert(v1, v2): hyp = hypot(v1.x - v2.x, v1.y - v2.y) return hyp -bpy.utils.register_class(op) \ No newline at end of file +bpy.utils.register_class(op)