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)
This commit is contained in:
lijenstina
2017-06-09 23:06:28 +02:00
parent 84baf76f48
commit aa8f255c0e
14 changed files with 1593 additions and 1312 deletions

View File

@ -3,7 +3,11 @@
import bpy
from bpy_extras import object_utils
from itertools import permutations
from math import copysign, pi, sqrt
from math import (
copysign, pi,
sqrt,
)
from bpy.types import Operator
from bpy.props import (
BoolProperty,
EnumProperty,
@ -109,12 +113,12 @@ def round_cube(radius=1.0, arcdiv=4, lindiv=0., size=(0., 0., 0.),
# Sides built left to right bottom up
# xp yp zp xd yd zd
sides = ((0, 2, 1, (-1, 1, 1)), # Y+ Front
(1, 2, 0, (-1, -1, 1)), # X- Left
(0, 2, 1, ( 1, -1, 1)), # Y- Back
(1, 2, 0, ( 1, 1, 1)), # X+ Right
(0, 1, 2, (-1, 1, -1)), # Z- Bottom
(0, 1, 2, (-1, -1, 1))) # Z+ Top
sides = ((0, 2, 1, (-1, 1, 1)), # Y+ Front
(1, 2, 0, (-1, -1, 1)), # X- Left
(0, 2, 1, (1, -1, 1)), # Y- Back
(1, 2, 0, (1, 1, 1)), # X+ Right
(0, 1, 2, (-1, 1, -1)), # Z- Bottom
(0, 1, 2, (-1, -1, 1))) # Z+ Top
# side vertex index table (for sphere)
svit = [[[] for i in range(steps)] for i in range(6)]
@ -325,36 +329,34 @@ def round_cube(radius=1.0, arcdiv=4, lindiv=0., size=(0., 0., 0.),
return verts, faces
class AddRoundCube(bpy.types.Operator, object_utils.AddObjectHelper):
class AddRoundCube(Operator, object_utils.AddObjectHelper):
bl_idname = "mesh.primitive_round_cube_add"
bl_label = "Add Round Cube"
bl_description = (
"Create mesh primitives: Quadspheres, "
"Capsules, Rounded Cuboids, 3D Grids etc"
)
bl_description = ("Create mesh primitives: Quadspheres, "
"Capsules, Rounded Cuboids, 3D Grids etc")
bl_options = {"REGISTER", "UNDO", "PRESET"}
sanity_check_verts = 200000
vert_count = 0
radius = FloatProperty(
name='Radius',
description='Radius of vertices for sphere, capsule or cuboid bevel',
name="Radius",
description="Radius of vertices for sphere, capsule or cuboid bevel",
default=1.0, min=0.0, soft_min=0.01, step=10
)
size = FloatVectorProperty(
name='Size',
description='Size',
name="Size",
description="Size",
subtype='XYZ',
)
arc_div = IntProperty(
name='Arc Divisions',
description='Arc curve divisions, per quadrant; 0=derive from Linear',
name="Arc Divisions",
description="Arc curve divisions, per quadrant, 0=derive from Linear",
default=4, min=1
)
lin_div = FloatProperty(
name='Linear Divisions',
description='Linear unit divisions (Edges/Faces); 0=derive from Arc',
name="Linear Divisions",
description="Linear unit divisions (Edges/Faces), 0=derive from Arc",
default=0.0, min=0.0, step=100, precision=1
)
div_type = EnumProperty(
@ -378,7 +380,8 @@ class AddRoundCube(bpy.types.Operator, object_utils.AddObjectHelper):
def execute(self, context):
if self.arc_div <= 0 and self.lin_div <= 0:
self.report({'ERROR'}, 'Either Arc Divisions or Linear Divisions must be greater than zero!')
self.report({'ERROR'},
"Either Arc Divisions or Linear Divisions must be greater than zero")
return {'CANCELLED'}
if not self.no_limit:
@ -397,8 +400,11 @@ class AddRoundCube(bpy.types.Operator, object_utils.AddObjectHelper):
return {'FINISHED'}
def check(self, context):
self.arcdiv, self.lindiv, self.vert_count = round_cube(self.radius, self.arc_div, self.lin_div,
self.size, self.div_type, self.odd_axis_align, True)
self.arcdiv, self.lindiv, self.vert_count = round_cube(
self.radius, self.arc_div, self.lin_div,
self.size, self.div_type, self.odd_axis_align,
True
)
return True
def invoke(self, context, event):
@ -440,4 +446,3 @@ class AddRoundCube(bpy.types.Operator, object_utils.AddObjectHelper):
col.prop(self, 'location', expand=True)
col = layout.column(align=True)
col.prop(self, 'rotation', expand=True)