[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3798] contrib/py/scripts/addons: merge beam builder into add_mesh_cad_objects/
Brendon Murphy
meta.androcto1 at gmail.com
Mon Oct 1 02:42:59 CEST 2012
Revision: 3798
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3798
Author: meta-androcto
Date: 2012-10-01 00:42:58 +0000 (Mon, 01 Oct 2012)
Log Message:
-----------
merge beam builder into add_mesh_cad_objects/
Modified Paths:
--------------
contrib/py/scripts/addons/add_mesh_cad_objects/__init__.py
Added Paths:
-----------
contrib/py/scripts/addons/add_mesh_cad_objects/add_mesh_beam_builder.py
Removed Paths:
-------------
contrib/py/scripts/addons/add_mesh_beam_builder.py
Deleted: contrib/py/scripts/addons/add_mesh_beam_builder.py
===================================================================
--- contrib/py/scripts/addons/add_mesh_beam_builder.py 2012-10-01 00:16:13 UTC (rev 3797)
+++ contrib/py/scripts/addons/add_mesh_beam_builder.py 2012-10-01 00:42:58 UTC (rev 3798)
@@ -1,1477 +0,0 @@
-# ##### 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 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.
-#
-# 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 #####
-
-bl_info = {
- "name": "Beam Builder",
- "description": "Creates various types of beams.",
- "author": "revolt_randy",
- "version": (0, 1, 3),
- "blender": (2, 6, 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://projects.blender.org/tracker/index.php?func=detail&aid=26911",
- "category": "Add Mesh"}
-
-#
-# 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.
-#
-
-import bpy
-
-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=self)
-
-
-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
-
-
- 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")
-
- return
-
-
-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
-
- # returns:
- # faces - a list of tuples defining the end faces
-
- faces = []
-
- 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 = []
-
- 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")
-
- return faces
-
-
-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:
- # new_faces - a list of tuples defining the faces bridged between front_verts & back_verts
-
- # Number of faces to create
- num_of_faces = (len(front_verts))
- new_faces = []
-
- # add first value to end of lists for looping
- front_verts.append(front_verts[0])
- back_verts.append(back_verts[0])
-
- # Build the new_faces list with tuples defining each face
- for index in range(num_of_faces):
- facestemp = (front_verts[index], front_verts[index+1], back_verts[index+1], back_verts[index])
- new_faces.append(facestemp)
-
- # print debug info to console
- if debug:
- print("\ncreate_side_faces Function Starts")
- print("\n Number of faces to create: ", num_of_faces)
- print("\n New faces :", new_faces)
- print("\ncreate_side_faces Function Ends\n\n")
-
- return new_faces
-
-
-def calc_end_verts(size, y_off, thick, debug):
- # Calculates vertex location for end of mesh
-
- # size - tuple of x,y,z dimensions of mesh to create
- # y_off - y offset, lets function know where to create verts on y-axis
- # thick - thickness, if not zero this is the thickness of a hollow mesh
- # with the inner faces inset from size dimensions
- # debug - if true prints values from this function to console
-
- # returns:
- # verts - a list of tuples of the x,y,z location of each vertex
-
- verts = []
-
- if debug:
- print ("\ncalc_end_verts Function Starts\n")
- print("\nsize = ",size)
- print("y_off = ",y_off)
-
- # Create vertices by calculation
- x_pos = 0 + size[0]/2
- z_pos = 0 + size[2]/2
- verts.append((x_pos, y_off, z_pos))
-
- x_pos = 0 - size[0]/2
- z_pos = 0 + size[2]/2
- verts.append((x_pos, y_off, z_pos))
-
- x_pos = 0 - size[0]/2
- z_pos = 0 - size[2]/2
- verts.append((x_pos, y_off, z_pos))
-
- x_pos = 0 + size[0]/2
- z_pos = 0 - size[2]/2
- verts.append((x_pos, y_off, z_pos))
-
- if thick:
- # has thickness, so calculate inside vertices
- #### not too sure about this, but it does work the way the
- #### solidify modifier works, so leaving as is for now
- x_pos = size[0] - (thick * 2)
- z_pos = size[2] - (thick * 2)
- size = (x_pos, y_off, z_pos)
-
- # Create vertices by calculation
- x_pos = 0 + size[0]/2
- z_pos = 0 + size[2]/2
- verts.append((x_pos, y_off, z_pos))
-
- x_pos = 0 - size[0]/2
- z_pos = 0 + size[2]/2
- verts.append((x_pos, y_off, z_pos))
-
- x_pos = 0 - size[0]/2
- z_pos = 0 - size[2]/2
- verts.append((x_pos, y_off, z_pos))
-
- x_pos = 0 + size[0]/2
- z_pos = 0 - size[2]/2
- verts.append((x_pos, y_off, z_pos))
-
- if debug:
- print ("verts :", verts)
- print ("\ncalc_end_verts Function Ends.\n\n")
-
- return verts
-
-
-def adjust_c_beam_verts(verts, taper, debug):
- # Adjusts verts produced to correct c beam shape
- # verts - a list of tuples of vertex locations for one end of beam
- # taper - % to taper outside verts by
- # debug - if true values are printed to console for debugging
-
- # returns:
- # verts - the corrected list of tuples of the adjustec vertex locations
-
- # This function corrects vertex locations to properly shape the
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list