[Bf-extensions-cvs] [2635488f] master: mesh_edge_roundifier: update correct 279 version from mesh extra tools to 2.8

meta-androcto noreply at git.blender.org
Sun Jun 2 06:11:05 CEST 2019


Commit: 2635488f223f68aa653b2d8fb41e891db43bfb65
Author: meta-androcto
Date:   Sun Jun 2 14:10:41 2019 +1000
Branches: master
https://developer.blender.org/rBAC2635488f223f68aa653b2d8fb41e891db43bfb65

mesh_edge_roundifier: update correct 279 version from mesh extra tools to 2.8

===================================================================

M	mesh_tools/mesh_edge_roundifier.py

===================================================================

diff --git a/mesh_tools/mesh_edge_roundifier.py b/mesh_tools/mesh_edge_roundifier.py
index dce883ab..704a260d 100644
--- a/mesh_tools/mesh_edge_roundifier.py
+++ b/mesh_tools/mesh_edge_roundifier.py
@@ -1,71 +1,59 @@
-# ***** BEGIN GPL LICENSE BLOCK *****
+# ##### BEGIN GPL LICENSE BLOCK #####
 #
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
 #
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
 #
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
-# GNU General Public License for more details.
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ***** END GPL LICENCE BLOCK *****
+# ##### END GPL LICENSE BLOCK #####
 
 bl_info = {
     "name": "Edge Roundifier",
     "category": "Mesh",
-    'author': 'Piotr Komisarczyk (komi3D), PKHG, ported to 2.8 by Titus',
-    'version': (1, 0, 1),
-    'blender': (2, 80, 0),
-    'location': 'SPACE > Edge Roundifier or CTRL-E > Edge Roundifier or Tools > Addons > Edge Roundifier',
-    'description': 'Mesh editing script allowing edge rounding',
-    'wiki_url': '',
-    'tracker_url': '',
-    'category': 'Mesh'
+    "author": "Piotr Komisarczyk (komi3D), PKHG",
+    "version": (1, 0, 2),
+    "blender": (2, 80, 0),
+    "location": "SPACE > Edge Roundifier or CTRL-E > "
+                "Edge Roundifier or Tools > Addons > Edge Roundifier",
+    "description": "Mesh editing script allowing edge rounding",
+    "wiki_url": "",
+    "category": "Mesh"
 }
 
-import bmesh
 import bpy
-import bpy.props
-import imp
-from math import sqrt, acos, asin, pi, radians, degrees, sin, acos
-from mathutils import Vector, Euler, Matrix, Quaternion
-import types
-
+import bmesh
+from bpy.types import Operator
+from bpy.props import (
+        BoolProperty,
+        FloatProperty,
+        EnumProperty,
+        IntProperty,
+        )
+from math import (
+        sqrt, acos, pi,
+        radians, degrees, sin,
+        )
+from mathutils import (
+        Vector, Euler,
+        Quaternion,
+        )
 
 # CONSTANTS
-two_pi = 2 * pi #PKHG>??? maybe other constantly used values too???
+two_pi = 2 * pi
 XY = "XY"
 XZ = "XZ"
 YZ = "YZ"
 SPIN_END_THRESHOLD = 0.001
 LINE_TOLERANCE = 0.0001
-
-
-# variable controlling all print functions
-#PKHG>??? to be replaced, see debugPrintNew ;-)
-debug = True
-
-def debugPrint(*text):
-    if debug:
-        for t in text:
-            print(text)
-
-
-
-############# for debugging PKHG ################
-def debugPrintNew(debug,*text):
-    if debug:
-        tmp = [el for el in text]
-        for row in tmp:
-            print(row)
-
 d_XABS_YABS = False
 d_Edge_Info = False
 d_Plane = False
@@ -76,28 +64,39 @@ d_LineAB = False
 d_Selected_edges = False
 d_Rotate_Around_Spin_Center = False
 
+# Enable debug prints
+DEBUG = False
+
+
+# for debugging PKHG #
+def debugPrintNew(debugs, *text):
+    if DEBUG and debugs:
+        tmp = [el for el in text]
+        for row in tmp:
+            print(row)
 
 
-####################### Geometry and math calcualtion methods #####################
+# Geometry and math calculation methods #
 
 class CalculationHelper:
+
     def __init__(self):
-        '''
+        """
         Constructor
-        '''
+        """
     def getLineCoefficientsPerpendicularToVectorInPoint(self, point, vector, plane):
         x, y, z = point
         xVector, yVector, zVector = vector
         destinationPoint = (x + yVector, y - xVector, z)
         if plane == 'YZ':
-            destinationPoint = (x , y + zVector, z - yVector)
+            destinationPoint = (x, y + zVector, z - yVector)
         if plane == 'XZ':
             destinationPoint = (x + zVector, y, z - xVector)
         return self.getCoefficientsForLineThrough2Points(point, destinationPoint, plane)
 
     def getQuadraticRoots(self, coef):
         if len(coef) != 3:
-            return NaN
+            return None  # Replaced NaN with None
         else:
             a, b, c = coef
             delta = b ** 2 - 4 * a * c
@@ -106,7 +105,7 @@ class CalculationHelper:
                 return (x, x)
             elif delta < 0:
                 return None
-            else :
+            else:
                 x1 = (-b - sqrt(delta)) / (2 * a)
                 x2 = (-b + sqrt(delta)) / (2 * a)
                 return (x1, x2)
@@ -127,8 +126,8 @@ class CalculationHelper:
 
         # Further calculations the same as for XY plane
         xabs = abs(x2 - x1)
-        yabs = abs(y2 - y1) 
-        debugPrintNew(d_XABS_YABS, "XABS = " + str( xabs)+ " YABS = " + str(yabs))
+        yabs = abs(y2 - y1)
+        debugPrintNew(d_XABS_YABS, "XABS = " + str(xabs) + " YABS = " + str(yabs))
 
         if xabs <= LINE_TOLERANCE:
             return None  # this means line x = edgeCenterX
@@ -151,7 +150,7 @@ class CalculationHelper:
         h = (B ** 2) - 2 * b * B - (radius ** 2) + (a ** 2) + (b ** 2)
         coef = [f, g, h]
         roots = self.getQuadraticRoots(coef)
-        if roots != None:
+        if roots is not None:
             x1 = roots[0]
             x2 = roots[1]
             point1 = [x1, A * x1 + B]
@@ -160,7 +159,8 @@ class CalculationHelper:
         else:
             return None
 
-    def getLineCircleIntersectionsWhenXPerpendicular(self, edgeCenter, circleMidPoint, radius, plane):
+    def getLineCircleIntersectionsWhenXPerpendicular(self, edgeCenter,
+                                                     circleMidPoint, radius, plane):
         # (x - a)**2 + (y - b)**2 = r**2 - circle equation
         # x = xValue - line equation
         # f * x**2 + g * x + h = 0 - quadratic equation
@@ -176,7 +176,7 @@ class CalculationHelper:
         h = (a ** 2) + (b ** 2) + (xValue ** 2) - 2 * a * xValue - (radius ** 2)
         coef = [f, g, h]
         roots = self.getQuadraticRoots(coef)
-        if roots != None:
+        if roots is not None:
             y1 = roots[0]
             y2 = roots[1]
             point1 = [xValue, y1]
@@ -190,17 +190,17 @@ class CalculationHelper:
         distance1 = (Vector(point1) - Vector(point2)).length
         distance2 = (Vector(point2) - Vector(point3)).length
         cos = distance1 / distance2
-        
+
         if abs(cos) > 1:  # prevents Domain Error
             cos = round(cos)
-        
+
         alpha = acos(cos)
         return (alpha, degrees(alpha))
 
     # get two of three coordinates used for further calculation of spin center
-    #PKHG>nice if rescriction to these 3 types or planes is to be done
-    #komi3D> from 0.0.2 there is a restriction. In future I would like Edge Roundifier to work on
-    #komi3D> Normal and View coordinate systems. That would be great... 
+    # PKHG>nice if rescriction to these 3 types or planes is to be done
+    # komi3D> from 0.0.2 there is a restriction. In future I would like Edge
+    # komi3D> Roundifier to work on Normal and View coordinate systems
     def getCircleMidPointOnPlane(self, V1, plane):
         X = V1[0]
         Y = V1[1]
@@ -211,7 +211,6 @@ class CalculationHelper:
             X = V1[1]
             Y = V1[2]
         return [X, Y]
-        
 
     def getEdgeReference(self, edge, edgeCenter, plane):
         vert1 = edge.verts[1].co
@@ -223,155 +222,280 @@ class CalculationHelper:
             orthoVector = Vector((V[0], V[2], -V[1]))
         refPoint = edgeCenter + orthoVector
         return refPoint
-        
-        
-########################################################
-################# SELECTION METHODS ####################
+
+
+# Selection Methods #
 
 class SelectionHelper:
+
     def selectVertexInMesh(self, mesh, vertex):
-        bpy.ops.object.mode_set(mode = "OBJECT")
+        bpy.ops.object.mode_set(mode="OBJECT")
         for v in mesh.vertices:
             if v.co == vertex:
                 v.select = True
                 break
 
-        bpy.ops.object.mode_set(mode = "EDIT")
+        bpy.ops.object.mode_set(mode="EDIT")
 
     def getSelectedVertex(self, mesh):
-        bpy.ops.object.mode_set(mode = "OBJECT")
+        bpy.ops.object.mode_set(mode="OBJECT")
         for v in mesh.vertices:
-            if v.select == True :
-                bpy.ops.object.mode_set(mode = "EDIT")
+            if v.select is True:
+                bpy.ops.object.mode_set(mode="EDIT")
                 return v
 
-        bpy.ops.object.mode_set(mode = "EDIT")
+        bpy.ops.object.mode_set(mode="EDIT")
         return None
 
     def refreshMesh(self, bm, mesh):
-        bpy.ops.object.mode_set(mode = 'OBJECT')
+        bpy.ops.object.mode_set(mode='OBJECT')
         bm.to_mesh(mesh)
-        bpy.ops.object.mode_set(mode = 'EDIT')
-
+        bpy.ops.object.mode_set(mode='EDIT')
 
 
-###################################################################################
+# Operator
 
-class EdgeRoundifier(bpy.types.Operator):
-    """Edge Roundifier"""  # blender will use this as a tooltip for menu items and buttons.
-    bl_idname = "mesh.edge_roundifier"  # unique identifier for buttons and menu items to reference.
-    bl_label = "Edge Roundifier"  # display name in the interface.
-    bl_option

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list