Skip to content

Commit

Permalink
Update PathExtrude.py
Browse files Browse the repository at this point in the history
Add patch for Blender 2.92
  • Loading branch information
nolanyee authored May 30, 2021
1 parent 0010f80 commit f9a186f
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions PathExtrude.py
Original file line number Diff line number Diff line change
@@ -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)}

Expand Down Expand Up @@ -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]))
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f9a186f

Please sign in to comment.