diff options
author | lijenstina <lijenstina@gmail.com> | 2017-06-10 00:06:28 +0300 |
---|---|---|
committer | lijenstina <lijenstina@gmail.com> | 2017-06-10 00:06:28 +0300 |
commit | aa8f255c0eaf31b2665d6adf0569da4892d8d1a4 (patch) | |
tree | c2bfef22a0c8b3329d45e93f8722b2e2f3884c90 /add_mesh_extra_objects/add_mesh_beam_builder.py | |
parent | 84baf76f48e023eafde8d567490b7b0ba901e9fb (diff) |
Add Mesh Extra Objects: Update, Fix crash with Wall Factory
Bumped version to 0.3.2
Wall Factory:
Fix crash with Wall Factory when openings and slots
are enabled (unorderable types: opening() < opening())
with the repeat option on as the sort function compared
stored classes instead of the numerical values
Fix the module not working properly after (F8) reload
Cleanup - consistent prop definitions
Remove star imports
Small UI reorganization to save vertical space
The code will probably need some further refactor
as the usage of globals is not so clear
add_mesh_triangles:
cleanup, remove unused vars add missing GPL notice,
some UI tweaks, add tooltip
add_mesh_pyramid: indentation cleanup
add_mesh_beam_builder: add an option to snap to cursor
add_mesh_teapot: use defs instead of assigning lambdas (E731)
Diffstat (limited to 'add_mesh_extra_objects/add_mesh_beam_builder.py')
-rw-r--r-- | add_mesh_extra_objects/add_mesh_beam_builder.py | 230 |
1 files changed, 128 insertions, 102 deletions
diff --git a/add_mesh_extra_objects/add_mesh_beam_builder.py b/add_mesh_extra_objects/add_mesh_beam_builder.py index 8297f9ae..cacde06a 100644 --- a/add_mesh_extra_objects/add_mesh_beam_builder.py +++ b/add_mesh_extra_objects/add_mesh_beam_builder.py @@ -1,16 +1,16 @@ # GPL # "author": revolt_randy, Jambay -# Create "Beam" primitives. Based on original script by revolt_randy. -# @todo: track 3D cursor for location. +# Create "Beam" primitives. Based on original script by revolt_randy import bpy +from bpy.types import Operator from bpy.props import ( + BoolProperty, EnumProperty, FloatProperty, IntProperty, ) -from bpy_extras import object_utils # ##################### @@ -310,12 +310,14 @@ def create_L_beam(sRef): verts_back_temp = [] # Create front vertices by calculation - verts_front_temp = [(-x_off, -y_off, z_off), - (-(x_off - thick), -y_off, z_off), - (-(x_off - thick), -y_off, -(z_off - thick)), - (x_off, -y_off, -(z_off - thick)), - (x_off, -y_off, -z_off), - (-x_off, -y_off, -z_off)] + verts_front_temp = [ + (-x_off, -y_off, z_off), + (-(x_off - thick), -y_off, z_off), + (-(x_off - thick), -y_off, -(z_off - thick)), + (x_off, -y_off, -(z_off - thick)), + (x_off, -y_off, -z_off), + (-x_off, -y_off, -z_off) + ] # Adjust taper vert_outside = verts_front_temp[0] @@ -329,12 +331,14 @@ def create_L_beam(sRef): verts_front_temp[3] = [vert_inside[0], vert_inside[1], vert_taper] # Create back vertices by calculation - verts_back_temp = [(-x_off, y_off, z_off), - (-(x_off - thick), y_off, z_off), - (-(x_off - thick), y_off, -(z_off - thick)), - (x_off, y_off, -(z_off - thick)), - (x_off, y_off, -z_off), - (-x_off, y_off, -z_off)] + verts_back_temp = [ + (-x_off, y_off, z_off), + (-(x_off - thick), y_off, z_off), + (-(x_off - thick), y_off, -(z_off - thick)), + (x_off, y_off, -(z_off - thick)), + (x_off, y_off, -z_off), + (-x_off, y_off, -z_off) + ] # Adjust taper vert_outside = verts_back_temp[0] @@ -394,16 +398,18 @@ def create_T_beam(sRef): verts_back_temp = [] # Create front vertices - verts_front_temp = [(-x_off, -y_off, z_off), - (-thick_off, -y_off, z_off), - (thick_off, -y_off, z_off), - (x_off, -y_off, z_off), - (x_off, -y_off, z_off - thick), - (thick_off, -y_off, z_off - thick), - (thick_off, -y_off, -z_off), - (-thick_off, -y_off, -z_off), - (-thick_off, -y_off, z_off - thick), - (-x_off, -y_off, z_off - thick)] + verts_front_temp = [ + (-x_off, -y_off, z_off), + (-thick_off, -y_off, z_off), + (thick_off, -y_off, z_off), + (x_off, -y_off, z_off), + (x_off, -y_off, z_off - thick), + (thick_off, -y_off, z_off - thick), + (thick_off, -y_off, -z_off), + (-thick_off, -y_off, -z_off), + (-thick_off, -y_off, z_off - thick), + (-x_off, -y_off, z_off - thick) + ] # Adjust taper vert_outside = verts_front_temp[0] @@ -429,16 +435,18 @@ def create_T_beam(sRef): verts_front_temp[7] = [vert_taper, vert_inside[1], vert_inside[2]] # Create fack vertices by calculation - verts_back_temp = [(-x_off, y_off, z_off), - (-thick_off, y_off, z_off), - (thick_off, y_off, z_off), - (x_off, y_off, z_off), - (x_off, y_off, z_off - thick), - (thick_off, y_off, z_off - thick), - (thick_off, y_off, -z_off), - (-thick_off, y_off, -z_off), - (-thick_off, y_off, z_off - thick), - (-x_off, y_off, z_off - thick)] + verts_back_temp = [ + (-x_off, y_off, z_off), + (-thick_off, y_off, z_off), + (thick_off, y_off, z_off), + (x_off, y_off, z_off), + (x_off, y_off, z_off - thick), + (thick_off, y_off, z_off - thick), + (thick_off, y_off, -z_off), + (-thick_off, y_off, -z_off), + (-thick_off, y_off, z_off - thick), + (-x_off, y_off, z_off - thick) + ] # Adjust taper vert_outside = verts_back_temp[0] @@ -514,22 +522,24 @@ def create_I_beam(sRef): verts_back_temp = [] # Create front vertices by calculation - verts_front_temp = [(-x_off, -y_off, z_off), - (-thick_off, -y_off, z_off), - (thick_off, -y_off, z_off), - (x_off, -y_off, z_off), - (x_off, -y_off, z_off - thick), - (thick_off, -y_off, z_off - thick), - (thick_off, -y_off, -z_off + thick), - (x_off, -y_off, -z_off + thick), - (x_off, -y_off, -z_off), - (thick_off, -y_off, -z_off), - (-thick_off, -y_off, -z_off), - (-x_off, -y_off, -z_off), - (-x_off, -y_off, -z_off + thick), - (-thick_off, -y_off, -z_off + thick), - (-thick_off, -y_off, z_off - thick), - (-x_off, -y_off, z_off - thick)] + verts_front_temp = [ + (-x_off, -y_off, z_off), + (-thick_off, -y_off, z_off), + (thick_off, -y_off, z_off), + (x_off, -y_off, z_off), + (x_off, -y_off, z_off - thick), + (thick_off, -y_off, z_off - thick), + (thick_off, -y_off, -z_off + thick), + (x_off, -y_off, -z_off + thick), + (x_off, -y_off, -z_off), + (thick_off, -y_off, -z_off), + (-thick_off, -y_off, -z_off), + (-x_off, -y_off, -z_off), + (-x_off, -y_off, -z_off + thick), + (-thick_off, -y_off, -z_off + thick), + (-thick_off, -y_off, z_off - thick), + (-x_off, -y_off, z_off - thick) + ] # Adjust taper vert_outside = verts_front_temp[0] @@ -553,22 +563,24 @@ def create_I_beam(sRef): verts_front_temp[12] = [vert_inside[0], vert_inside[1], vert_taper] # Create back vertices by calculation - verts_back_temp = [(-x_off, y_off, z_off), - (-thick_off, y_off, z_off), - (thick_off, y_off, z_off), - (x_off, y_off, z_off), - (x_off, y_off, z_off - thick), - (thick_off, y_off, z_off - thick), - (thick_off, y_off, -z_off + thick), - (x_off, y_off, -z_off + thick), - (x_off, y_off, -z_off), - (thick_off, y_off, -z_off), - (-thick_off, y_off, -z_off), - (-x_off, y_off, -z_off), - (-x_off, y_off, -z_off + thick), - (-thick_off, y_off, -z_off + thick), - (-thick_off, y_off, z_off - thick), - (-x_off, y_off, z_off - thick)] + verts_back_temp = [ + (-x_off, y_off, z_off), + (-thick_off, y_off, z_off), + (thick_off, y_off, z_off), + (x_off, y_off, z_off), + (x_off, y_off, z_off - thick), + (thick_off, y_off, z_off - thick), + (thick_off, y_off, -z_off + thick), + (x_off, y_off, -z_off + thick), + (x_off, y_off, -z_off), + (thick_off, y_off, -z_off), + (-thick_off, y_off, -z_off), + (-x_off, y_off, -z_off), + (-x_off, y_off, -z_off + thick), + (-thick_off, y_off, -z_off + thick), + (-thick_off, y_off, z_off - thick), + (-x_off, y_off, z_off - thick) + ] # Adjust taper vert_outside = verts_back_temp[0] @@ -662,63 +674,77 @@ def addBeamObj(sRef, context): bpy.ops.transform.rotate(value=1.570796, constraint_axis=[False, True, False]) bpy.ops.object.transform_apply(location=False, rotation=True, scale=False) + if sRef.Cursor: + if beamObj.select is True: + # we also have to check if we're considered to be in 3D View (view3d) + if bpy.ops.view3d.snap_selected_to_cursor.poll(): + bpy.ops.view3d.snap_selected_to_cursor() + else: + sRef.Cursor = False + # ###################### # Create a beam primitive. # # UI functions and object creation. -class addBeam(bpy.types.Operator): +class addBeam(Operator): bl_idname = "mesh.add_beam" 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" - ) + items=( + ('0', "Box Profile", "Square Beam"), + ("1", "U Profile", "U Profile Beam"), + ("2", "C Profile", "C Profile Beam"), + ("3", "L Profile", "L Profile Beam"), + ("4", "I Profile", "I Profile Beam"), + ("5", "T Profile", "T Profile Beam") + ), + description="Beam form" + ) beamZ = FloatProperty( - name="Height", - min=0.01, max=100, - default=1 - ) + name="Height", + min=0.01, max=100, + default=1 + ) beamX = FloatProperty( - name="Width", - min=0.01, max=100, - default=.5 - ) + name="Width", + min=0.01, max=100, + default=.5 + ) beamY = FloatProperty( - name="Depth", - min=0.01, - max=100, - default=2 - ) + name="Depth", + min=0.01, + max=100, + default=2 + ) beamW = FloatProperty( - name="Thickness", - min=0.01, max=1, - default=0.1 - ) + name="Thickness", + min=0.01, max=1, + default=0.1 + ) edgeA = IntProperty( - name="Taper", - min=0, max=100, - default=0, - description="Angle beam edges" - ) + name="Taper", + min=0, max=100, + default=0, + description="Angle beam edges" + ) + Cursor = BoolProperty( + name="Use 3D Cursor", + default=False, + description="Draw the beam where the 3D Cursor is" + ) def draw(self, context): layout = self.layout box = layout.box() - row = box.row() - row.prop(self, "Type", text="") + split = box.split(percentage=0.85, align=True) + split.prop(self, "Type", text="") + split.prop(self, "Cursor", text="", icon="CURSOR") box.prop(self, "beamZ") box.prop(self, "beamX") |