Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlijenstina <lijenstina@gmail.com>2016-12-30 22:33:05 +0300
committerlijenstina <lijenstina@gmail.com>2016-12-30 22:33:05 +0300
commitc86080a455579a8c770545e33b95513b43e1a43b (patch)
tree6c392b16b914aa3264b373022602e57ad493e7d7 /add_mesh_extra_objects/add_mesh_beam_builder.py
parentc95e86bcef654c0686d3cf4d52446ff9ff8c819f (diff)
Add mesh extra objects: Update to version 0.3.1
General Pep8 cleanup Removed unused variables and imports Removed a panel from add_empty_as_parent Standardized the property definitions across all the scripts Moved scene props from third_domes_panel_271 to init for proper removal Added a Enum prop for mesh type in teapot Fixed a small issue with Geodesic domes self.reports (problem with value fields message spam) Fixed props names in Geodesic domes Consistent tooltips Reorganized menus: Mechanical Menu including Pipe joints, Mesh gear Added separators
Diffstat (limited to 'add_mesh_extra_objects/add_mesh_beam_builder.py')
-rw-r--r--add_mesh_extra_objects/add_mesh_beam_builder.py163
1 files changed, 81 insertions, 82 deletions
diff --git a/add_mesh_extra_objects/add_mesh_beam_builder.py b/add_mesh_extra_objects/add_mesh_beam_builder.py
index 3f7cf285..9bbe1e25 100644
--- a/add_mesh_extra_objects/add_mesh_beam_builder.py
+++ b/add_mesh_extra_objects/add_mesh_beam_builder.py
@@ -1,38 +1,26 @@
-################################################################################
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# 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 (http://www.gnu.org/licenses/) for more details.
-#
-# ***** END GPL LICENSE BLOCK *****
-'''
-Create "Beam" primitives. Based on original script by revolt_randy.
-'''
-# Author(s): revolt_randy, Jambay
-#
+# GPL # "author": revolt_randy, Jambay
+
+# Create "Beam" primitives. Based on original script by revolt_randy.
# @todo: track 3D cursor for location.
-#
-################################################################################
+
import bpy
-from bpy.props import BoolProperty, EnumProperty, FloatProperty, FloatVectorProperty, IntProperty
+from bpy.props import (
+ EnumProperty,
+ FloatProperty,
+ IntProperty,
+ )
from bpy_extras import object_utils
-########################################
-#
+# #####################
# 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
@@ -63,15 +51,14 @@ def beamEndVs(sRef, y_off):
return endVs
-########################################
-#
+# #####################
# Create End Faces
#
# verts_list - list of vertices
#
# returns:
# beamFs, a list of tuples defining the end faces.
-#
+
def beamEndFaces(verts_list):
beamFs = []
@@ -98,8 +85,7 @@ def beamEndFaces(verts_list):
return beamFs
-########################################
-#
+# #####################
# Bridge vertices to create side faces.
#
# front_verts - front face vertices
@@ -109,7 +95,7 @@ def beamEndFaces(verts_list):
#
# returns:
# sideFaces, a list of the bridged faces
-#
+
def beamSides(front_verts, back_verts):
sideFaces = []
@@ -127,14 +113,13 @@ def beamSides(front_verts, back_verts):
return sideFaces
-####################################################
-#
+# #####################
# Creates a box beam
#
# returns:
# beamVs - x, y, z, location of each vertice
# beamFs - vertices that make up each face
-#
+
def create_beam(sRef):
frontVs = []
@@ -190,15 +175,14 @@ def create_beam(sRef):
return beamVs, beamFs
-########################################
-#
+# #####################
# Taper/angle faces of beam.
# inner vert toward outer vert
# based on percentage of taper.
#
# returns:
# adVert - the calculated vertex
-#
+
def beamSlant(sRef, outV, inV):
bTaper = 100 - sRef.edgeA
@@ -209,15 +193,14 @@ def beamSlant(sRef, outV, inV):
return adVert
-########################################
-#
+# #####################
# Modify location to shape beam.
#
# verts - tuples for one end of beam
#
# returns:
# verts - modified tuples for beam shape.
-#
+
def beamSquareEnds(sRef, verts):
# match 5th & 6th z locations to 1st & 2nd
@@ -235,7 +218,7 @@ def beamSquareEnds(sRef, verts):
return verts
-########################################
+# #####################
#
# Create U shaped beam
# Shared with C shape - see beamEndVs
@@ -244,7 +227,7 @@ def beamSquareEnds(sRef, verts):
# returns:
# beamVs - vertice x, y, z, locations
# beamFs - face vertices
-#
+
def create_u_beam(sRef):
# offset vertices from center
@@ -308,12 +291,11 @@ def create_u_beam(sRef):
return beamVs, beamFs
-###################################
-#
+# #####################
# returns:
# verts_final - x, y, z, location of each vertice
# faces_final - vertices that make up each face
-#
+
def create_L_beam(sRef):
thick = sRef.beamW
@@ -392,12 +374,11 @@ def create_L_beam(sRef):
return verts_final, faces_final
-###################################
-#
+# #####################
# returns:
# verts_final - a list of tuples of the x, y, z, location of each vertice
# faces_final - a list of tuples of the vertices that make up each face
-#
+
def create_T_beam(sRef):
thick = sRef.beamW
@@ -513,12 +494,11 @@ def create_T_beam(sRef):
return verts_final, faces_final
-###################################
-#
+# #####################
# returns:
# verts_final - a list of tuples of the x, y, z, location of each vertice
# faces_final - a list of tuples of the vertices that make up each face
-#
+
def create_I_beam(sRef):
thick = sRef.beamW
@@ -645,10 +625,10 @@ def create_I_beam(sRef):
return verts_final, faces_final
-################################################################################
+# ######################
#
# Generate beam object.
-#
+
def addBeamObj(sRef, context):
verts = []
faces = []
@@ -683,56 +663,75 @@ def addBeamObj(sRef, context):
bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)
-################################################################################
-#
+# ######################
# Create a beam primitive.
#
# UI functions and object creation.
-#
+
class addBeam(bpy.types.Operator):
bl_idname = "mesh.add_beam"
- bl_description = "Beam Builder"
bl_label = "Beam Builder"
+ bl_description = "Create beam meshes of various profiles"
bl_options = {'REGISTER', 'UNDO'}
- Type = EnumProperty(items=(
- ('0', "Box", "Square Beam"),
- ("1", "U", "U Beam"),
- ("2", "C", "C Beam"),
- ("3", "L", "L Beam"),
- ("4", "I", "T Beam"),
- ("5", "T", "I Beam")
- ),
- description="Beam form.")
-
- beamZ = FloatProperty(name="Height", min=0.01, max=100, default=1)
- beamX = FloatProperty(name="Width", min=0.01, max=100, default=.5)
- beamY = FloatProperty(name="Depth", min=0.01, max=100, default=2)
- beamW = FloatProperty(name="Thickness", min=0.01, max=1, default=0.1)
-
- edgeA = IntProperty(name="Taper", min=0, max=100, default=0, description="Angle beam edges.")
+ Type = EnumProperty(
+ items=(
+ ('0', "Box", "Square Beam"),
+ ("1", "U", "U Beam"),
+ ("2", "C", "C Beam"),
+ ("3", "L", "L Beam"),
+ ("4", "I", "T Beam"),
+ ("5", "T", "I Beam")
+ ),
+ description="Beam form."
+ )
+ beamZ = FloatProperty(
+ name="Height",
+ min=0.01, max=100,
+ default=1
+ )
+ beamX = FloatProperty(
+ name="Width",
+ min=0.01, max=100,
+ default=.5
+ )
+ beamY = FloatProperty(
+ name="Depth",
+ min=0.01,
+ max=100,
+ default=2
+ )
+ beamW = FloatProperty(
+ name="Thickness",
+ min=0.01, max=1,
+ default=0.1
+ )
+ edgeA = IntProperty(
+ name="Taper",
+ min=0, max=100,
+ default=0,
+ description="Angle beam edges"
+ )
- ########################################
def draw(self, context):
layout = self.layout
box = layout.box()
row = box.row()
- row.prop(self, 'Type', text='')
+ row.prop(self, "Type", text="")
- box.prop(self, 'beamZ')
- box.prop(self, 'beamX')
- box.prop(self, 'beamY')
- box.prop(self, 'beamW')
+ box.prop(self, "beamZ")
+ box.prop(self, "beamX")
+ box.prop(self, "beamY")
+ box.prop(self, "beamW")
if self.Type != '0':
- box.prop(self, 'edgeA')
+ box.prop(self, "edgeA")
- ########################################
def execute(self, context):
if bpy.context.mode == "OBJECT":
addBeamObj(self, context)
return {'FINISHED'}
- else:
- self.report({'WARNING'}, "Option only valid in Object mode")
- return {'CANCELLED'}
+
+ self.report({'WARNING'}, "Option only valid in Object mode")
+ return {'CANCELLED'}