[Bf-extensions-cvs] [84da70d] master: update mesh building objects: T48327

meta-androcto noreply at git.blender.org
Tue May 17 10:37:28 CEST 2016


Commit: 84da70d2eb4f3cc6ed70a449d4b779007658ec28
Author: meta-androcto
Date:   Tue May 17 18:37:03 2016 +1000
Branches: master
https://developer.blender.org/rBAC84da70d2eb4f3cc6ed70a449d4b779007658ec28

update mesh building objects: T48327

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

M	add_mesh_building_objects/__init__.py
M	add_mesh_building_objects/add_mesh_beam_builder.py

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

diff --git a/add_mesh_building_objects/__init__.py b/add_mesh_building_objects/__init__.py
index a0a5164..b13deb1 100644
--- a/add_mesh_building_objects/__init__.py
+++ b/add_mesh_building_objects/__init__.py
@@ -59,7 +59,7 @@ class INFO_MT_mesh_objects_add(bpy.types.Menu):
     def draw(self, context):
         layout = self.layout
         layout.operator_context = 'INVOKE_REGION_WIN'
-        layout.menu("INFO_MT_mesh_beambuilder_add",
+        layout.operator("mesh.add_beam",
             text="Beam Builder")
         layout.operator("mesh.add_say3d_balcony",
             text="Balcony")
diff --git a/add_mesh_building_objects/add_mesh_beam_builder.py b/add_mesh_building_objects/add_mesh_beam_builder.py
index 0240ef7..3f7cf28 100644
--- a/add_mesh_building_objects/add_mesh_beam_builder.py
+++ b/add_mesh_building_objects/add_mesh_beam_builder.py
@@ -1,647 +1,372 @@
-# ##### 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 is free software; you may redistribute it, and/or modify it,
+# under the terms of the GNU General Public License.
 #
-#  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 (http://www.gnu.org/licenses/) 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.
-#
-# ##### END GPL LICENSE BLOCK #####
+# ***** END GPL LICENSE BLOCK *****
 '''
-bl_info = {
-    "name": "Beam Builder",
-    "description": "Creates various types of beams.",
-    "author": "revolt_randy",
-    "version": (0, 1, 3),
-    "blender": (2, 60, 0),
-    "location": "View3D > Add > Mesh",
-    "warning": "Currently under development.",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
-        "Scripts/Add_Mesh/BeamBuilder",
-    "tracker_url": "https://developer.blender.org/Taid=26911",
-    "category": "Add Mesh"}
+Create "Beam" primitives. Based on original script by revolt_randy.
 '''
+# Author(s): revolt_randy, Jambay
 #
-# Creates a rectangluar, 'C', 'L', 'T', or 'I' - type beam.
-#
-
-# Version History
-#
-# v0.1 - Script only generates a multi-sided mesh object,
-#           initial release for testing. 3/12/11
-#
-# v0.1.1 - Added 'C'-type beam, updated to work with
-#           api r35499. 3/13/11
-#
-# v0.1.2 - Totally changed the way beams are created, size
-#           is now calculated based off width, length, & height
-#           (x,y,z). Added ability to taper beams as well.
-#           Add 'L' - type beam
-#           Add 'T' - type beam
-#           Add 'I' - type beam
-#
-# v0.1.3 - Updated to work with api r41226, including using object_utils.py -
-#           part of blender's bpy_extras scripts. This is what handles
-#           the 'align to view', 'location', & 'rotation' options in the
-#           toolshelf when creating mesh. Added wiki & tracker url. Fixed
-#           a few bugs & fixed some debug prints that were still printing
-#           to console.
+# @todo: track 3D cursor for location.
 #
+################################################################################
 
 import bpy
-
+from bpy.props import BoolProperty, EnumProperty, FloatProperty, FloatVectorProperty, IntProperty
 from bpy_extras import object_utils
 
 
-def create_mesh (self, context, name, verts, faces, debug):
-    # Creates mesh and object
-    # name - name of object to create
-    # verts - a list of vertex tuples
-    # faces - a list of face tuples
-    # debug - debug flag - if true prints data to console
-
-    # Actually create mesh and object
-    mesh = bpy.data.meshes.new(name)
-
-    # add verts & faces to object
-    mesh.from_pydata(verts, [], faces)
-    mesh.update(calc_edges=True)
-
-    if debug:
-        print("create_mesh function called and finished")
-
-    return object_utils.object_data_add(context, mesh, operator=None)
-
-
-def recalc_normals(debug):
-    # Recalculate normals
-    # parts of this script creates faces that are backwards or
-    # have thier normals facing the wrong way, so recalculate them
-    # debug - debug flag - if true prints data to console
+########################################
+#
+# Create vertices for end of mesh
+#
+# y_off - verts y-axis origin
+#
+# returns:
+#  endVs - x,y,z list
+#
+def beamEndVs(sRef, y_off):
+    thick = sRef.beamW * 2
+
+    if sRef.Type == '2':  # swap width and height for C shape
+        bEndX2 = sRef.beamZ / 2
+        bEndXInr = ((sRef.beamZ - thick) / 2)
+        bEndZ2 = sRef.beamX / 2
+        bEndZInr = ((sRef.beamX - thick) / 2)
+    else:
+        bEndX2 = sRef.beamX / 2
+        bEndXInr = ((sRef.beamX - thick) / 2)
+        bEndZ2 = sRef.beamZ / 2
+        bEndZInr = ((sRef.beamZ - thick) / 2)
 
+    endVs = []
 
-    if bpy.context.mode != 'EDIT_MESH':
-        bpy.ops.object.editmode_toggle()
-        # Recalcuate normals
-        bpy.ops.mesh.normals_make_consistent()
-        bpy.ops.object.editmode_toggle()
-        if debug:
-            print("\nObjectMode")
-    else:
-        bpy.ops.mesh.normals_make_consistent()
-        if debug:
-            print("\nEditMode")
+    # outer ...
+    endVs.append((bEndX2, y_off, bEndZ2))
+    endVs.append((-bEndX2, y_off, bEndZ2))
+    endVs.append((-bEndX2, y_off, -bEndZ2))
+    endVs.append((bEndX2, y_off, -bEndZ2))
+    # innner ...
+    endVs.append((bEndXInr, y_off, bEndZInr))
+    endVs.append((-bEndXInr, y_off, bEndZInr))
+    endVs.append((-bEndXInr, y_off, -bEndZInr))
+    endVs.append((bEndXInr, y_off, -bEndZInr))
 
-    return
+    return endVs
 
 
-def create_end_faces(verts_list, thick, debug):
-    # Create End Faces
-    # verts_list - list of vertices
-    # thick - if true object is hollow, so construct loop of end faces
-    #           instead of a solid end face
-    # debug - if true prints values from this function to console
+########################################
+#
+# Create End Faces
+#
+# verts_list - list of vertices
+#
+# returns:
+#  beamFs, a list of tuples defining the end faces.
+#
+def beamEndFaces(verts_list):
 
-    # returns:
-    # faces - a list of tuples defining the end faces
+    beamFs = []
 
-    faces = []
+    num_of_verts = int(len(verts_list) / 2)
 
-    num_of_verts = len(verts_list)
-    faces_temp = []
-
-    sides = 4 # sides - number of sides to mesh *added because of code re-write
-
-    if thick:
-        # has thickness, so build end faces
-        num_of_verts = int(num_of_verts / 2)
-
-        # Create a list of the front faces
-        for index in range(num_of_verts):
-            if index == (num_of_verts - 1):
-                faces_temp.append(verts_list[index])
-                faces_temp.append(verts_list[index-index])
-                faces_temp.append(verts_list[index+1])
-                faces_temp.append(verts_list[index*2+1])
-            else:
-                faces_temp.append(verts_list[index])
-                faces_temp.append(verts_list[index+1])
-                faces_temp.append(verts_list[index+num_of_verts+1])
-                faces_temp.append(verts_list[index+num_of_verts])
-
-            faces.append(tuple(faces_temp))
-            faces_temp = []
-    else:
-        #this code may not be needed, depends upon rewrite...
-        if sides > 4:
-            # more than 4 sides, so replace last list item (center vert) with first list item
-            # for looping and building faces
-            center_vert = verts_list[num_of_verts - 1]
-            verts_list[num_of_verts - 1] = verts_list[0]
-
-            for index in range(int(num_of_verts - 1)):
-                faces_temp.append(verts_list[index])
-                faces_temp.append(verts_list[index + 1])
-                faces_temp.append(center_vert)
-                faces.append(tuple(faces_temp))
-                faces_temp = []
+    # Create list of faces
+    for index in range(num_of_verts):
+        faces_temp = []
 
+        if index == (num_of_verts - 1):
+            faces_temp.append(verts_list[index])
+            faces_temp.append(verts_list[index - index])
+            faces_temp.append(verts_list[index + 1])
+            faces_temp.append(verts_list[index * 2 + 1])
         else:
-            # create 1 end face
-            for index in range(num_of_verts):
-                faces_temp.append(verts_list[index])
-            faces.append(tuple(faces_temp))
-
-    # print debug info to console
-    if debug:
-        print("\ncreate_end_faces Function Starts")
-        print("\n End Face Verts list :", verts_list)
-        print("\n End Faces: ", faces)
-        print("\ncreate_end_faces Function Ends\n\n")
+            faces_temp.append(verts_list[index])
+            faces_temp.append(verts_list[index + 1])
+            faces_temp.append(verts_list[index + num_of_verts + 1])
+            faces_temp.append(verts_list[index + num_of_verts])
 
-    return faces
+        beamFs.append(tuple(faces_temp))
 
+    return beamFs
 
-def create_side_faces(front_verts, back_verts, debug):
-    # Create side faces - simple bridging of front_verts & back_verts vertices,
-    #                     both front_verts & back_verts must be ordered in same direction
-    #                     with respect to y-axis
-    # front_verts - a list of front face vertices
-    # back_verts - a list of back face vertices
-    # debug - if true prints values from this function to console
 
-    # returns:
-    

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list