[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2974] trunk/py/scripts/addons: code cleanup: style and typo - some edits to bypass the comments spell checker.
Campbell Barton
ideasman42 at gmail.com
Wed Feb 8 05:38:53 CET 2012
Revision: 2974
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2974
Author: campbellbarton
Date: 2012-02-08 04:38:51 +0000 (Wed, 08 Feb 2012)
Log Message:
-----------
code cleanup: style and typo - some edits to bypass the comments spell checker.
Modified Paths:
--------------
trunk/py/scripts/addons/add_mesh_BoltFactory/createMesh.py
trunk/py/scripts/addons/io_anim_bvh/import_bvh.py
trunk/py/scripts/addons/rigify/ui.py
Modified: trunk/py/scripts/addons/add_mesh_BoltFactory/createMesh.py
===================================================================
--- trunk/py/scripts/addons/add_mesh_BoltFactory/createMesh.py 2012-02-07 20:42:43 UTC (rev 2973)
+++ trunk/py/scripts/addons/add_mesh_BoltFactory/createMesh.py 2012-02-08 04:38:51 UTC (rev 2974)
@@ -20,7 +20,7 @@
import mathutils
from math import *
-from itertools import *
+from itertools import *
NARROW_UI = 180
MAX_INPUT_NUMBER = 50
@@ -47,14 +47,14 @@
if len(face) != 3 and len(face) != 4:
raise RuntimeError("{0} vertices in face".format(len(face)))
-
+
# rotate indices if the 4th is 0
if len(face) == 4 and face[3] == 0:
face = [face[3], face[0], face[1], face[2]]
if len(face) == 3:
face.append(0)
-
+
l.extend(face)
return l
@@ -76,7 +76,7 @@
new_faces = []
dict_verts = {}
Rounded_Verts = []
-
+
for v in verts:
Rounded_Verts.append([round(v[0],Decimal_Places),round(v[1],Decimal_Places),round(v[2],Decimal_Places)])
@@ -89,12 +89,12 @@
if Rounded_co not in dict_verts:
dict_verts[Rounded_co] = len(dict_verts)
new_verts.append(Real_co)
- if dict_verts[Rounded_co] not in new_face:
+ if dict_verts[Rounded_co] not in new_face:
new_face.append(dict_verts[Rounded_co])
if len(new_face) == 3 or len(new_face) == 4:
new_faces.append(new_face)
- return new_verts,new_faces
+ return new_verts,new_faces
@@ -123,13 +123,13 @@
# * axis (Vector object. (optional)) - The arbitrary axis of rotation used with "R"
#
#Returns: Matrix object.
-# A new rotation matrix.
+# A new rotation matrix.
def Simple_RotationMatrix(angle, matSize, axisFlag):
if matSize != 4 :
print ("Simple_RotationMatrix can only do 4x4")
-
+
q = radians(angle) #make the rotation go clockwise
-
+
if axisFlag == 'x':
matrix = mathutils.Matrix.Rotation(q, 4, 'X')
elif axisFlag == 'y':
@@ -143,7 +143,7 @@
##########################################################################################
##########################################################################################
-## Converter Functions For Bolt Factory
+## Converter Functions For Bolt Factory
##########################################################################################
##########################################################################################
@@ -157,7 +157,7 @@
Bit_Rad = Bit_Dia / 2.0
x = Bit_Rad - Flat_Width_half
y = tan(radians(60))*x
- return float(y)
+ return float(y)
##########################################################################################
@@ -168,11 +168,11 @@
# Returns a list of verts rotated by the given matrix. Used by SpinDup
def Rot_Mesh(verts, matrix):
- Vector = mathutils.Vector
+ from mathutils import Vector
return [(matrix * Vector(v))[:] for v in verts]
-# Returns a list of faces that has there index incremented by offset
+# Returns a list of faces that has there index incremented by offset
def Copy_Faces(faces,offset):
return [[(i + offset) for i in f] for f in faces]
@@ -181,60 +181,60 @@
def SpinDup(VERTS,FACES,DEGREE,DIVISIONS,AXIS):
verts=[]
faces=[]
-
+
if DIVISIONS == 0:
- DIVISIONS = 1
-
+ DIVISIONS = 1
+
step = DEGREE/DIVISIONS # set step so pieces * step = degrees in arc
-
+
for i in range(int(DIVISIONS)):
rotmat = Simple_RotationMatrix(step*i, 4, AXIS) # 4x4 rotation matrix, 30d about the x axis.
Rot = Rot_Mesh(VERTS,rotmat)
- faces.extend(Copy_Faces(FACES,len(verts)))
+ faces.extend(Copy_Faces(FACES,len(verts)))
verts.extend(Rot)
return verts,faces
# Returns a list of verts that have been moved up the z axis by DISTANCE
-def Move_Verts_Up_Z(VERTS,DISTANCE):
+def Move_Verts_Up_Z(VERTS,DISTANCE):
ret = []
for v in VERTS:
ret.append([v[0],v[1],v[2]+DISTANCE])
return ret
-# Returns a list of verts and faces that has been mirrored in the AXIS
+# Returns a list of verts and faces that has been mirrored in the AXIS
def Mirror_Verts_Faces(VERTS,FACES,AXIS,FLIP_POINT =0):
ret_vert = []
ret_face = []
- offset = len(VERTS)
+ offset = len(VERTS)
if AXIS == 'y':
for v in VERTS:
Delta = v[0] - FLIP_POINT
- ret_vert.append([FLIP_POINT-Delta,v[1],v[2]])
+ ret_vert.append([FLIP_POINT-Delta,v[1],v[2]])
if AXIS == 'x':
for v in VERTS:
Delta = v[1] - FLIP_POINT
- ret_vert.append([v[0],FLIP_POINT-Delta,v[2]])
+ ret_vert.append([v[0],FLIP_POINT-Delta,v[2]])
if AXIS == 'z':
for v in VERTS:
Delta = v[2] - FLIP_POINT
- ret_vert.append([v[0],v[1],FLIP_POINT-Delta])
-
+ ret_vert.append([v[0],v[1],FLIP_POINT-Delta])
+
for f in FACES:
fsub = []
for i in range(len(f)):
fsub.append(f[i]+ offset)
fsub.reverse() # flip the order to make norm point out
ret_face.append(fsub)
-
+
return ret_vert,ret_face
-# Returns a list of faces that
-# make up an array of 4 point polygon.
+# Returns a list of faces that
+# make up an array of 4 point polygon.
def Build_Face_List_Quads(OFFSET,COLUM,ROW,FLIP = 0):
Ret =[]
RowStart = 0;
@@ -252,7 +252,7 @@
return Ret
-# Returns a list of faces that makes up a fill pattern for a
+# Returns a list of faces that makes up a fill pattern for a
# circle
def Fill_Ring_Face(OFFSET,NUM,FACE_DOWN = 0):
Ret =[]
@@ -275,7 +275,7 @@
else:
TempFace[0] =Face[C];
if Face[C] == 0:
- TempFace[1] = NUM-1;
+ TempFace[1] = NUM-1;
else:
TempFace[1] = Face[C] - 1;
TempFace[2] = Face[B];
@@ -283,12 +283,12 @@
Ret.append([OFFSET+Face[0],OFFSET+Face[1],OFFSET+Face[2]])
else:
Ret.append([OFFSET+Face[2],OFFSET+Face[1],OFFSET+Face[0]])
-
+
Face[0] = TempFace[0]
Face[1] = TempFace[1]
Face[2] = TempFace[2]
return Ret
-
+
######################################################################################
##########################################################################################
##########################################################################################
@@ -309,16 +309,16 @@
[20,7,6],
[20,8,7],
[20,9,8],
-
+
[20,21,9],
-
+
[21,10,9],
[21,11,10],
[21,12,11],
[21,13,12],
[21,14,13],
[21,15,14],
-
+
[21,22,15],
[22,16,15],
[22,17,16],
@@ -329,62 +329,62 @@
faces.append([OFFSET+i[2],OFFSET+i[1],OFFSET+i[0]])
else:
faces.append([OFFSET+i[0],OFFSET+i[1],OFFSET+i[2]])
-
+
return faces
def Allen_Bit_Dia(FLAT_DISTANCE):
Flat_Radius = (float(FLAT_DISTANCE)/2.0)/cos(radians(30))
return (Flat_Radius * 1.05) * 2.0
-
+
def Allen_Bit_Dia_To_Flat(DIA):
Flat_Radius = (DIA/2.0)/1.05
return (Flat_Radius * cos (radians(30)))* 2.0
-
-
+
+
def Create_Allen_Bit(FLAT_DISTANCE,HEIGHT):
Div = 36
verts = []
faces = []
-
+
Flat_Radius = (float(FLAT_DISTANCE)/2.0)/cos(radians(30))
OUTTER_RADIUS = Flat_Radius * 1.05
Outter_Radius_Height = Flat_Radius * (0.1/5.77)
FaceStart_Outside = len(verts)
Deg_Step = 360.0 /float(Div)
-
+
for i in range(int(Div/2)+1): # only do half and mirror later
x = sin(radians(i*Deg_Step))*OUTTER_RADIUS
y = cos(radians(i*Deg_Step))*OUTTER_RADIUS
verts.append([x,y,0])
-
+
FaceStart_Inside = len(verts)
-
- Deg_Step = 360.0 /float(6)
- for i in range(int(6/2)+1):
+
+ Deg_Step = 360.0 /float(6)
+ for i in range(int(6/2)+1):
x = sin(radians(i*Deg_Step))* Flat_Radius
y = cos(radians(i*Deg_Step))* Flat_Radius
- verts.append([x,y,0-Outter_Radius_Height])
-
+ verts.append([x,y,0-Outter_Radius_Height])
+
faces.extend(Allen_Fill(FaceStart_Outside,0))
-
-
+
+
FaceStart_Bottom = len(verts)
-
- Deg_Step = 360.0 /float(6)
- for i in range(int(6/2)+1):
+
+ Deg_Step = 360.0 /float(6)
+ for i in range(int(6/2)+1):
x = sin(radians(i*Deg_Step))* Flat_Radius
y = cos(radians(i*Deg_Step))* Flat_Radius
- verts.append([x,y,0-HEIGHT])
-
+ verts.append([x,y,0-HEIGHT])
+
faces.extend(Build_Face_List_Quads(FaceStart_Inside,3,1,True))
faces.extend(Fill_Ring_Face(FaceStart_Bottom,4))
-
-
+
+
M_Verts,M_Faces = Mirror_Verts_Faces(verts,faces,'y')
verts.extend(M_Verts)
faces.extend(M_Faces)
-
+
return verts,faces,OUTTER_RADIUS * 2.0
@@ -401,32 +401,32 @@
[1,11,10],
[1,2,11],
[2,12,11],
-
+
[2,3,12],
[3,4,12],
[4,5,12],
[5,6,12],
[6,7,12],
-
+
[7,13,12],
[7,8,13],
[8,14,13],
[8,9,14],
-
-
+
+
[10,11,16,15],
[11,12,16],
[12,13,16],
[13,14,17,16],
[15,16,17,18]
-
-
+
+
]
for i in Lookup:
if FLIP:
if len(i) == 3:
faces.append([OFFSET+i[2],OFFSET+i[1],OFFSET+i[0]])
- else:
+ else:
faces.append([OFFSET+i[3],OFFSET+i[2],OFFSET+i[1],OFFSET+i[0]])
else:
if len(i) == 3:
@@ -441,20 +441,20 @@
Div = 36
verts = []
faces = []
-
+
FLAT_RADIUS = FLAT_DIA * 0.5
OUTTER_RADIUS = FLAT_RADIUS * 1.05
-
+
Flat_Half = float(FLAT_WIDTH)/2.0
-
+
FaceStart_Outside = len(verts)
Deg_Step = 360.0 /float(Div)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list