diff options
author | Martin Buerbaum <martin.buerbaum@gmx.at> | 2010-04-20 01:08:57 +0400 |
---|---|---|
committer | Martin Buerbaum <martin.buerbaum@gmx.at> | 2010-04-20 01:08:57 +0400 |
commit | 64585a4c7302af0792bf8fa01e7c5da3f76300e8 (patch) | |
tree | 4ccfdf606fe618bbde9daf698f3c3f7513fdb7e5 /add_mesh_gears.py | |
parent | b796cafc8b11629a010c93b710ff3bb0a0c6bb00 (diff) |
* Version 2.4.1
* createFaces can now create fan/star like faces.
Diffstat (limited to 'add_mesh_gears.py')
-rw-r--r-- | add_mesh_gears.py | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/add_mesh_gears.py b/add_mesh_gears.py index 476011ba..502fb684 100644 --- a/add_mesh_gears.py +++ b/add_mesh_gears.py @@ -23,7 +23,7 @@ bl_addon_info = { 'name': 'Add Mesh: Gears', 'author': 'Michel J. Anders (varkenvarken)', - 'version': '2.4', + 'version': '2.4.1', 'blender': (2, 5, 3), 'location': 'View3D > Add > Mesh > Gears ', 'description': 'Adds a mesh Gear to the Add Mesh menu', @@ -194,37 +194,69 @@ def create_mesh_object(context, verts, edges, faces, name, edit): # A very simple "bridge" tool. # Connects two equally long vertex rows with faces. -# Returns a list of the new faces (list of lists) +# Returns a list of the new faces (list of lists) # # vertIdx1 ... First vertex list (list of vertex indices). # vertIdx2 ... Second vertex list (list of vertex indices). # closed ... Creates a loop (first & last are closed). # flipped ... Invert the normal of the face(s). +# +# Note: You can set vertIdx1 to a single vertex index to create +# a fan/star of faces. +# Note: If both vertex idx list are the same length they have +# to have at least 2 vertices. def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False): faces = [] - if (len(vertIdx1) != len(vertIdx2)) or (len(vertIdx1) < 2): + if not vertIdx1 or not vertIdx2: + return None + + if len(vertIdx1) < 2 and len(vertIdx2) < 2: return None - total = len(vertIdx1) + fan = False + if (len(vertIdx1) != len(vertIdx2)): + if (len(vertIdx1) == 1 and len(vertIdx2) > 1): + fan = True + else: + return None + + total = len(vertIdx2) if closed: # Bridge the start with the end. if flipped: - faces.append([vertIdx1[0], vertIdx2[0], - vertIdx2[total - 1], vertIdx1[total - 1]]) + face = [ + vertIdx1[0], + vertIdx2[0], + vertIdx2[total - 1]] + if not fan: + face.append(vertIdx1[total - 1]) + faces.append(face) + else: - faces.append([vertIdx2[0], vertIdx1[0], - vertIdx1[total - 1], vertIdx2[total - 1]]) + face = [vertIdx2[0], vertIdx1[0]] + if not fan: + face.append(vertIdx1[total - 1]) + face.append(vertIdx2[total - 1]) + faces.append(face) # Bridge the rest of the faces. for num in range(total - 1): if flipped: - faces.append([vertIdx2[num], vertIdx1[num], - vertIdx1[num + 1], vertIdx2[num + 1]]) + if fan: + face = [vertIdx2[num], vertIdx1[0], vertIdx2[num + 1]] + else: + face = [vertIdx2[num], vertIdx1[num], + vertIdx1[num + 1], vertIdx2[num + 1]] + faces.append(face) else: - faces.append([vertIdx1[num], vertIdx2[num], - vertIdx2[num + 1], vertIdx1[num + 1]]) + if fan: + face = [vertIdx1[0], vertIdx2[num], vertIdx2[num + 1]] + else: + face = [vertIdx1[num], vertIdx2[num], + vertIdx2[num + 1], vertIdx1[num + 1]] + faces.append(face) return faces |