From 973e85bda9243b6e8c3fd190ea3c30620e78cdb0 Mon Sep 17 00:00:00 2001
From: Patrick-White-4 <patrick-white-4@noreply.localhost>
Date: Tue, 1 Aug 2023 13:41:10 +0200
Subject: [PATCH] Extra objects: Fix TypeError when torus knot added

TypeError is thrown when `torus knot object +` added with `7*6` preset.
`torus_res` is an IntProperty, and after python 3.10, implicit conversion
from float to int is not happening. Cast division value explicity to int to
fix the problem.

Pull Request: https://projects.blender.org/blender/blender-addons/pulls/104810
---
 add_curve_extra_objects/add_curve_torus_knots.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/add_curve_extra_objects/add_curve_torus_knots.py b/add_curve_extra_objects/add_curve_torus_knots.py
index 891754c5f..cc30d9b53 100644
--- a/add_curve_extra_objects/add_curve_torus_knots.py
+++ b/add_curve_extra_objects/add_curve_torus_knots.py
@@ -698,7 +698,7 @@ class torus_knot_plus(Operator, AddObjectHelper):
                 print("Approximate average TK length = %.2f" % avgTKLen)
 
             # x N factor = control points per unit length
-            self.torus_res = max(3, avgTKLen / links * 8)
+            self.torus_res = max(3, int(avgTKLen / links) * 8)
 
         # update align matrix
         self.align_matrix = align_matrix(self, context)
-- 
GitLab