diff --git a/PathExtrude.py b/PathExtrude.py index 1da8fd2..c1156d7 100644 --- a/PathExtrude.py +++ b/PathExtrude.py @@ -1,4 +1,4 @@ -# Polygon Path Extrusion Tool - Version 3.3 +# Polygon Path Extrusion Tool - Version 3.4 bl_info = {'name':'Path Extrude','category':'Object','blender':(2,80,0)} @@ -189,7 +189,29 @@ def findNextVertex(edgeList, vertexIndex, lastVertex): cos = np.dot(initial_normal,average_list[0]) if bpy.app.version[0] == 2 and bpy.app.version[1] == 90: bpy.ops.transform.rotate(value=math.acos(cos), orient_matrix=-1*orientMatrix) - else: + elif bpy.app.version[0] == 2 and bpy.app.version[1] == 92: + if -1*orient_vectorz[0] > 0: + zRotation = math.atan(-1*orient_vectorz[1]/orient_vectorz[0]) + elif -1*orient_vectorz[0] < 0: + zRotation = math.pi + math.atan(-1*orient_vectorz[1]/orient_vectorz[0]) + elif orient_vectorz[1] > 0: + zRotation = math.pi/2 + elif orient_vectorz[1] < 0: + zRotation = -1*math.pi/2 + else: + zRotation = 0 + if orient_vectorz[0] != 0 or orient_vectorz[1] != 0: + yRotation = math.atan(orient_vectorz[2]/math.sqrt(orient_vectorz[0]**2 + orient_vectorz[1]**2)) + elif orient_vectorz[2] > 0: + yRotation = math.pi/2 + else: + yRotation = -1*math.pi/2 + bpy.ops.transform.rotate(value= -1*zRotation, orient_axis = 'Z') + bpy.ops.transform.rotate(value= yRotation, orient_axis = 'Y') + bpy.ops.transform.rotate(value= math.acos(cos), orient_axis = 'X') + bpy.ops.transform.rotate(value= -1*yRotation, orient_axis = 'Y') + bpy.ops.transform.rotate(value= zRotation, orient_axis = 'Z') + else: bpy.ops.transform.rotate(value=math.acos(cos), orient_matrix=orientMatrix) if np.dot(average_list[0],normalized_differences[1]) != 0: factor0 = abs(1/np.dot(average_list[0],normalized_differences[1])) @@ -238,6 +260,28 @@ def findNextVertex(edgeList, vertexIndex, lastVertex): (orient_vectorx[2],orient_vectory[2],orient_vectorz[2]))) if bpy.app.version[0] == 2 and bpy.app.version[1] == 90: bpy.ops.transform.rotate(value=math.acos(cos), orient_matrix=-1*orientMatrix) + elif bpy.app.version[0] == 2 and bpy.app.version[1] == 92: + if -1*orient_vectorz[0] > 0: + zRotation = math.atan(-1*orient_vectorz[1]/orient_vectorz[0]) + elif -1*orient_vectorz[0] < 0: + zRotation = math.pi + math.atan(-1*orient_vectorz[1]/orient_vectorz[0]) + elif orient_vectorz[1] > 0: + zRotation = math.pi/2 + elif orient_vectorz[1] < 0: + zRotation = -1*math.pi/2 + else: + zRotation = 0 + if orient_vectorz[0] != 0 or orient_vectorz[1] != 0: + yRotation = math.atan(orient_vectorz[2]/math.sqrt(orient_vectorz[0]**2 + orient_vectorz[1]**2)) + elif orient_vectorz[2] > 0: + yRotation = math.pi/2 + else: + yRotation = -1*math.pi/2 + bpy.ops.transform.rotate(value= -1*zRotation, orient_axis = 'Z') + bpy.ops.transform.rotate(value= yRotation, orient_axis = 'Y') + bpy.ops.transform.rotate(value= math.acos(cos), orient_axis = 'X') + bpy.ops.transform.rotate(value= -1*yRotation, orient_axis = 'Y') + bpy.ops.transform.rotate(value= zRotation, orient_axis = 'Z') else: bpy.ops.transform.rotate(value=math.acos(cos), orient_matrix=orientMatrix) bpy.ops.transform.resize(value=(1/factor_list[i-1],1,1), orient_matrix=orientMatrix)