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>2017-06-10 00:06:28 +0300
committerlijenstina <lijenstina@gmail.com>2017-06-10 00:06:28 +0300
commitaa8f255c0eaf31b2665d6adf0569da4892d8d1a4 (patch)
treec2bfef22a0c8b3329d45e93f8722b2e2f3884c90
parent84baf76f48e023eafde8d567490b7b0ba901e9fb (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)
-rw-r--r--add_mesh_extra_objects/Blocks.py279
-rw-r--r--add_mesh_extra_objects/Wallfactory.py1026
-rw-r--r--add_mesh_extra_objects/__init__.py168
-rw-r--r--add_mesh_extra_objects/add_mesh_beam_builder.py230
-rw-r--r--add_mesh_extra_objects/add_mesh_gears.py238
-rw-r--r--add_mesh_extra_objects/add_mesh_gemstones.py125
-rw-r--r--add_mesh_extra_objects/add_mesh_honeycomb.py74
-rw-r--r--add_mesh_extra_objects/add_mesh_menger_sponge.py48
-rw-r--r--add_mesh_extra_objects/add_mesh_pyramid.py152
-rw-r--r--add_mesh_extra_objects/add_mesh_round_brilliant.py150
-rw-r--r--add_mesh_extra_objects/add_mesh_round_cube.py53
-rw-r--r--add_mesh_extra_objects/add_mesh_star.py5
-rw-r--r--add_mesh_extra_objects/add_mesh_teapot.py19
-rw-r--r--add_mesh_extra_objects/add_mesh_triangles.py356
14 files changed, 1602 insertions, 1321 deletions
diff --git a/add_mesh_extra_objects/Blocks.py b/add_mesh_extra_objects/Blocks.py
index f798cf52..bade30d0 100644
--- a/add_mesh_extra_objects/Blocks.py
+++ b/add_mesh_extra_objects/Blocks.py
@@ -1,4 +1,4 @@
-# GPL # "author":
+# GPL # "authors": dudecon, jambay
# Module notes:
#
@@ -8,87 +8,150 @@
# auto-clip wall edge to SMALL for radial and domes.
# unregister doesn't release all references.
# repeat for opening doesn't distribute evenly when radialized - see wrap around
-# note above.
+# note above.
# if opening width == indent*2 the edge blocks fail (row of blocks cross opening).
# if openings overlap fills inverse with blocks - see h/v slots.
# Negative grout width creates a pair of phantom blocks, seperated by grout
-# width, inside the edges.
-# if block width variance is 0, and edging is on, right edge blocks create a "vertical seam".
+# width, inside the edges.
+# if block width variance is 0, and edging is on, right edge blocks create a "vertical seam"
import bpy
from random import random
-from math import fmod, sqrt, sin, cos, atan, pi as PI
+from math import (
+ fmod, sqrt,
+ sin, cos, atan,
+ pi as PI,
+ )
+
+# Set to True to enable debug_prints
+DEBUG = False
# A few constants
SMALL = 0.000000000001
-NOTZERO = 0.01 # for values that must be != 0; see UI options/variables - sort of a bug to be fixed.
+# for values that must be != 0; see UI options/variables - sort of a bug to be fixed
+NOTZERO = 0.01
-# global variables
+# Global variables
# General masonry Settings
-settings = {'w': 1.2, 'wv': 0.3, 'h': .6, 'hv': 0.3, 'd': 0.3, 'dv': 0.1,
- 'g': 0.1, 'gv': 0.07, 'gd': 0.01, 'gdv': 0.0, 'b': 0, 'bv': 0,
- 'f': 0.0, 'fv': 0.0, 't': 0.0, 'sdv': 0.1, 'hwt': 0.5, 'aln': 0,
- 'wm': 0.8, 'hm': 0.3, 'dm': 0.1,
- 'woff': 0.0, 'woffv': 0.0, 'eoff': 0.3, 'eoffv': 0.0, 'rwhl': 1,
- 'hb': 0, 'ht': 0, 'ge': 0, 'physics': 0}
-# 'w':width 'wv':widthVariation
-# 'h':height 'hv':heightVariation
-# 'd':depth 'dv':depthVariation
-# 'g':grout 'gv':groutVariation 'gd':groutDepth 'gdv':groutDepthVariation
-# 'b':bevel 'bv':bevelVariation
-# 'f':flawSize 'fv':flawSizeVariation 'ff':flawFraction
-# 't':taper
-# 'sdv':subdivision(distance or angle)
-# 'hwt':row height effect on block widths in the row (0=no effect,
-# 1=1:1 relationship, negative values allowed, 0.5 works well)
-# 'aln':alignment(0=none, 1=rows w/features, 2=features w/rows)
-# (currently un-used)
-# 'wm':width minimum 'hm':height minimum 'dm':depth minimum
-# 'woff':row start offset(fraction of width)
-# 'woffv':width offset variation(fraction of width)
-# 'eoff':edge offset 'eoffv':edge offset variation
-# 'rwhl':row height lock(1 is all blocks in row have same height)
-# 'hb':bottom row height 'ht': top row height 'ge': grout the edges
-# 'physics': set up for physics
+# ------------------------
+settings = {
+ 'w': 1.2, 'wv': 0.3, 'h': .6, 'hv': 0.3, 'd': 0.3, 'dv': 0.1,
+ 'g': 0.1, 'gv': 0.07, 'gd': 0.01, 'gdv': 0.0, 'b': 0, 'bv': 0,
+ 'f': 0.0, 'fv': 0.0, 't': 0.0, 'sdv': 0.1, 'hwt': 0.5, 'aln': 0,
+ 'wm': 0.8, 'hm': 0.3, 'dm': 0.1,
+ 'woff': 0.0, 'woffv': 0.0, 'eoff': 0.3, 'eoffv': 0.0, 'rwhl': 1,
+ 'hb': 0, 'ht': 0, 'ge': 0, 'physics': 0
+ }
+"""
+ settings DOCUMENTATION:
+ 'w':width 'wv':widthVariation
+ 'h':height 'hv':heightVariation
+ 'd':depth 'dv':depthVariation
+ 'g':grout 'gv':groutVariation 'gd':groutDepth 'gdv':groutDepthVariation
+ 'b':bevel 'bv':bevelVariation
+ 'f':flawSize 'fv':flawSizeVariation 'ff':flawFraction
+ 't':taper
+ 'sdv':subdivision(distance or angle)
+ 'hwt':row height effect on block widths in the row (0=no effect,
+ 1=1:1 relationship, negative values allowed, 0.5 works well)
+ 'aln':alignment(0=none, 1=rows w/features, 2=features w/rows)
+ (currently unused)
+ 'wm':width minimum 'hm':height minimum 'dm':depth minimum
+ 'woff':row start offset(fraction of width)
+ 'woffv':width offset variation(fraction of width)
+ 'eoff':edge offset 'eoffv':edge offset variation
+ 'rwhl':row height lock(1 is all blocks in row have same height)
+ 'hb':bottom row height 'ht': top row height 'ge': grout the edges
+ 'physics': set up for physics
+"""
# dims = area of wall (face)
-dims = {'s': 0, 'e': PI * 3 / 2, 'b': 0.1, 't': 12.3} # radial
-# 's':start x or theta 'e':end x or theta 'b':bottom z or r 't':top z or r
-# 'w' = e-s and h = t-b; calculated to optimize for various operations/usages
-# dims = {'s':-12, 'e':15, 'w':27, 'b':-15., 't':15., 'h':30}
-# dims = {'s':-bayDim/2, 'e':bayDim/2, 'b':-5., 't':10.} # bay settings?
-
+# ------------------------
+dims = {
+ 's': 0, 'e': PI * 3 / 2, 'b': 0.1, 't': 12.3
+ } # radial
+"""
+ dims DOCUMENTATION:
+ 's':start x or theta 'e':end x or theta 'b':bottom z or r 't':top z or r
+ 'w' = e-s and h = t-b; calculated to optimize for various operations/usages
+ dims = {'s':-12, 'e':15, 'w':27, 'b':-15., 't':15., 'h':30}
+ dims = {'s':-bayDim/2, 'e':bayDim/2, 'b':-5., 't':10.} # bay settings?
+"""
+
+# ------------------------
radialized = 0 # Radiating from one point - round/disc; instead of square
-slope = 0 # Warp/slope; curved over like a vaulted tunnel
+slope = 0 # Warp/slope; curved over like a vaulted tunnel
+
# 'bigblock': merge adjacent blocks into single large blocks
-bigBlock = 0 # Merge blocks
+bigBlock = 0 # Merge blocks
-# Gaps in blocks for various apertures.
+
+# Gaps in blocks for various apertures
+# ------------------------
# openingSpecs = []
-openingSpecs = [{'w': 0.5, 'h': 0.5, 'x': 0.8, 'z': 2.7, 'rp': 1, 'b': 0.0,
- 'v': 0, 'vl': 0, 't': 0, 'tl': 0}]
-# 'w': opening width, 'h': opening height,
-# 'x': horizontal position, 'z': vertical position,
-# 'rp': make multiple openings, with a spacing of x,
-# 'b': bevel the opening, inside only, like an arrow slit.
-# 'v': height of the top arch, 'vl':height of the bottom arch,
-# 't': thickness of the top arch, 'tl': thickness of the bottom arch
-
-# Add blocks to make platforms.
+openingSpecs = [
+ {'w': 0.5, 'h': 0.5, 'x': 0.8, 'z': 2.7, 'rp': 1, 'b': 0.0,
+ 'v': 0, 'vl': 0, 't': 0, 'tl': 0}
+ ]
+"""
+ openingSpecs DOCUMENTATION:
+ 'w': opening width, 'h': opening height,
+ 'x': horizontal position, 'z': vertical position,
+ 'rp': make multiple openings, with a spacing of x,
+ 'b': bevel the opening, inside only, like an arrow slit.
+ 'v': height of the top arch, 'vl':height of the bottom arch,
+ 't': thickness of the top arch, 'tl': thickness of the bottom arch
+"""
+
+# Add blocks to make platforms
+# ------------------------
shelfExt = 0
-shelfSpecs = {'w': 0.5, 'h': 0.5, 'd': 0.3, 'x': 0.8, 'z': 2.7}
-# 'w': block width, 'h': block height, 'd': block depth (shelf size; offset from wall)
-# 'x': horizontal start position, 'z': vertical start position
-# Add blocks to make steps.
+shelfSpecs = {
+ 'w': 0.5, 'h': 0.5, 'd': 0.3, 'x': 0.8, 'z': 2.7
+ }
+"""
+ shelfSpecs DOCUMENTATION:
+ 'w': block width, 'h': block height, 'd': block depth (shelf size; offset from wall)
+ 'x': horizontal start position, 'z': vertical start position
+"""
+
+# Add blocks to make steps
+# ------------------------
stepMod = 0
-stepSpecs = {'x': 0.0, 'z': -10, 'w': 10.0, 'h': 10.0,
- 'v': 0.7, 't': 1.0, 'd': 1.0}
-# 'x': horizontal start position, 'z': vertical start position,
-# 'w': step area width, 'h': step area height,
-# 'v': riser height, 't': tread width, 'd': block depth (step size; offset from wall)
+
+stepSpecs = {
+ 'x': 0.0, 'z': -10, 'w': 10.0, 'h': 10.0,
+ 'v': 0.7, 't': 1.0, 'd': 1.0
+ }
+"""
+ stepSpecs DOCUMENTATION:
+ 'x': horizontal start position, 'z': vertical start position,
+ 'w': step area width, 'h': step area height,
+ 'v': riser height, 't': tread width, 'd': block depth (step size; offset from wall)
+"""
+stepLeft = 0
+shelfBack = 0
+stepOnly = 0
+stepBack = 0
+
+
+# switchable prints
+def debug_prints(func="", text="Message", var=None):
+ global DEBUG
+ if DEBUG:
+ print("\n[{}]\nmessage: {}".format(func, text))
+ if var:
+ print("Error: ", var)
+
+
+# pass variables just like for the regular prints
+def debug_print_vars(*args, **kwargs):
+ global DEBUG
+ if DEBUG:
+ print(*args, **kwargs)
# easier way to get to the random function
@@ -126,6 +189,7 @@ def test(TestN=13):
't': float(t), 'tl': float(tl)}]
return dims, openingSpecs
+
# dims, openingSpecs = test(15)
@@ -290,7 +354,8 @@ def MakeABlock(bounds, segsize, vll=0, Offsets=None, FaceExclude=[],
def MakeAKeystone(xpos, width, zpos, ztop, zbtm, thick, bevel, vll=0, FaceExclude=[], xBevScl=1):
__doc__ = """\
- MakeAKeystone returns lists of points and faces to be made into a square cornered keystone, with optional bevels.
+ MakeAKeystone returns lists of points and faces to be made into a
+ square cornered keystone, with optional bevels.
xpos: x position of the centerline
width: x width of the keystone at the widest point (discounting bevels)
zpos: z position of the widest point
@@ -299,7 +364,8 @@ def MakeAKeystone(xpos, width, zpos, ztop, zbtm, thick, bevel, vll=0, FaceExclud
thick: thickness
bevel: the amount to raise the back vertex to account for arch beveling
vll: the number of vertexes already in the mesh. len(mesh.verts) should give this number
- faceExclude: list of faces to exclude from the faces list. 0:left, 1:right, 2:bottom, 3:top, 4:back, 5:front
+ faceExclude: list of faces to exclude from the faces list.
+ 0:left, 1:right, 2:bottom, 3:top, 4:back, 5:front
xBevScl: how much to divide the end (+- x axis) bevel dimensions.
Set to current average radius to compensate for angular distortion on curved blocks
"""
@@ -427,6 +493,7 @@ class opening:
# ht is the z position; s is the side: 1 for right, -1 for left
# if the height passed is above or below the opening, return None
def edgeS(self, ht, s):
+
# set the row radius: 1 for standard wall (flat)
if radialized:
if slope:
@@ -496,6 +563,7 @@ class opening:
# get the top or bottom of the opening
# ht is the x position; s is the side: 1 for top, -1 for bottom
def edgeV(self, ht, s):
+
dist = abs(self.x - ht)
def radialAdjust(dist, sideVal):
@@ -556,9 +624,11 @@ class opening:
else:
return self.z - self.h / 2 - self.vl + self.rl - circVal
- # and this never happens - but, leave it as failsafe :)
- print("got all the way out of the edgeV! Not good!")
- print("opening x = ", self.x, ", opening z = ", self.z)
+ # and this never happens - but, leave it as failsafe :)
+ debug_prints(func="opening.EdgeV",
+ text="Got all the way out of the edgeV! Not good!")
+ debug_print_vars("opening x = ", self.x, ", opening z = ", self.z)
+
return 0.0
def edgeBev(self, ht):
@@ -618,11 +688,9 @@ class opening:
# class for the whole wall boundaries; a sub-class of "opening"
-
-class OpeningInv(opening):
+class openingInvert(opening):
# this is supposed to switch the sides of the opening
# so the wall will properly enclose the whole wall.
- # We'll see if it works.
def edgeS(self, ht, s):
return opening.edgeS(self, ht, -s)
@@ -776,8 +844,10 @@ def arch(ra, rt, x, z, archStart, archEnd, bevel, bevAngle, vll):
else:
ThisOffset = offsets
- geom = MakeABlock([divs[i] + grt, divs[i + 1] - grt, ArchInner, ArchOuter, DepthBack, DepthFront],
- subdivision, len(avlist) + vll, ThisOffset, [], None, ra)
+ geom = MakeABlock(
+ [divs[i] + grt, divs[i + 1] - grt, ArchInner, ArchOuter, DepthBack, DepthFront],
+ subdivision, len(avlist) + vll, ThisOffset, [], None, ra
+ )
avlist += geom[0]
aflist += geom[1]
@@ -929,6 +999,7 @@ def rowProcessing(row, Thesketch, WallBoundaries):
# initially just the left and right edge of the wall
edgetop = [[dims['s'] + row.EdgeOffset / r1 + edgrt, WallBoundaries],
[dims['e'] + row.EdgeOffset / r1 - edgrt, WallBoundaries]]
+
# Same as edgetop, but for the bottms of the rows
edgebtm = [[dims['s'] + row.EdgeOffset / r1 + edgrt, WallBoundaries],
[dims['e'] + row.EdgeOffset / r1 - edgrt, WallBoundaries]]
@@ -959,9 +1030,17 @@ def rowProcessing(row, Thesketch, WallBoundaries):
# We want to make the walls in order, so sort the intersects.
# This is where you would want to remove edge points that are out of order
- # so that you don't get the "oddity where overlapping openings create blocks inversely" problem
- edgetop.sort()
- edgebtm.sort()
+ # so that you don't get the "oddity where overlapping openings
+ # create blocks inversely" problem
+
+ # Note: sort ended up comparing function pointers
+ # if both Openings and Slots were enabled with Repeats in one of them
+ try:
+ edgetop.sort(key=lambda x: x[0])
+ edgebtm.sort(key=lambda x: x[0])
+ except Exception as ex:
+ debug_prints(func="rowProcessing",
+ text="Sorting has failed", var=ex)
# these two loops trim the edges to the limits of the wall.
# This way openings extending outside the wall don't enlarge the wall.
@@ -1232,7 +1311,7 @@ def plan(Thesketch, oldrows=0):
z = (dims['t'] + dims['b']) / 2
w = (dims['e'] - dims['s'])
h = (dims['t'] - dims['b'])
- WallBoundaries = OpeningInv(x, z, w, h)
+ WallBoundaries = openingInvert(x, z, w, h)
# Go over each row in the list, set up edge blocks and block sections
for rownum in range(len(rows)):
@@ -1348,7 +1427,8 @@ def archGeneration(hole, vlist, flist, sideSign):
flist += aflist
# remove "debug note" once bevel is finalized.
else:
- print("keystone was too narrow - " + str(Wdth))
+ debug_prints(func="archGeneration",
+ text="Keystone was too narrow - " + str(Wdth))
else: # only one arc - curve not peak.
# bottom (sideSign -1) arch has poorly sized blocks...
@@ -1409,8 +1489,11 @@ def archGeneration(hole, vlist, flist, sideSign):
# Do some stuff to incorporate bev here
bevelBlockOffsets(offsets, bev, -1)
- avlist, aflist = MakeABlock([x - xstart - width, x - xstart - woffset, btmSide, topSide,
- - depth / 2, depth / 2], subdivision, len(vlist), Offsets=offsets, xBevScl=1)
+ avlist, aflist = MakeABlock(
+ [x - xstart - width, x - xstart - woffset, btmSide, topSide,
+ -depth / 2, depth / 2], subdivision, len(vlist),
+ Offsets=offsets, xBevScl=1
+ )
# top didn't use radialized in prev version;
# just noting for clarity - may need to revise for "sideSign == 1"
@@ -1439,8 +1522,11 @@ def archGeneration(hole, vlist, flist, sideSign):
# Do some stuff to incorporate bev here
bevelBlockOffsets(offsets, bev, 1)
- avlist, aflist = MakeABlock([x + xstart + woffset, x + xstart + width, btmSide, topSide,
- -depth / 2, depth / 2], subdivision, len(vlist), Offsets=offsets, xBevScl=1)
+ avlist, aflist = MakeABlock(
+ [x + xstart + woffset, x + xstart + width, btmSide, topSide,
+ -depth / 2, depth / 2], subdivision, len(vlist),
+ Offsets=offsets, xBevScl=1
+ )
# top didn't use radialized in prev version;
# just noting for clarity - may need to revise for "sideSign == 1"
@@ -1544,11 +1630,19 @@ def build(Aplan):
# - this way no gaps between platform and wall face due to wall block depth.
wallDepth = settings['d'] / 2 # offset by wall depth so step depth matches UI setting :)
if shelfBack: # place blocks on backside of wall
- ShelfOffsets = [[0, ShelfThk / 2, 0], [0, wallDepth, 0], [0, ShelfThk / 2, 0], [0, wallDepth, 0],
- [0, ShelfThk / 2, 0], [0, wallDepth, 0], [0, ShelfThk / 2, 0], [0, wallDepth, 0]]
+ ShelfOffsets = [
+ [0, ShelfThk / 2, 0], [0, wallDepth, 0],
+ [0, ShelfThk / 2, 0], [0, wallDepth, 0],
+ [0, ShelfThk / 2, 0], [0, wallDepth, 0],
+ [0, ShelfThk / 2, 0], [0, wallDepth, 0]
+ ]
else:
- ShelfOffsets = [[0, -wallDepth, 0], [0, -ShelfThk / 2, 0], [0, -wallDepth, 0], [0, -ShelfThk / 2, 0],
- [0, -wallDepth, 0], [0, -ShelfThk / 2, 0], [0, -wallDepth, 0], [0, -ShelfThk / 2, 0]]
+ ShelfOffsets = [
+ [0, -wallDepth, 0], [0, -ShelfThk / 2, 0],
+ [0, -wallDepth, 0], [0, -ShelfThk / 2, 0],
+ [0, -wallDepth, 0], [0, -ShelfThk / 2, 0],
+ [0, -wallDepth, 0], [0, -ShelfThk / 2, 0]
+ ]
# Add blocks for each "shelf row" in area
while ShelfBtm < ShelfTop:
@@ -1591,11 +1685,19 @@ def build(Aplan):
# Also, will work fine as stand-alone if not used with wall (try block depth 0 and see what happens).
wallDepth = settings['d'] / 2
if stepBack: # place blocks on backside of wall
- StepOffsets = [[0, StepThk / 2, 0], [0, wallDepth, 0], [0, StepThk / 2, 0], [0, wallDepth, 0],
- [0, StepThk / 2, 0], [0, wallDepth, 0], [0, StepThk / 2, 0], [0, wallDepth, 0]]
+ StepOffsets = [
+ [0, StepThk / 2, 0], [0, wallDepth, 0],
+ [0, StepThk / 2, 0], [0, wallDepth, 0],
+ [0, StepThk / 2, 0], [0, wallDepth, 0],
+ [0, StepThk / 2, 0], [0, wallDepth, 0]
+ ]
else:
- StepOffsets = [[0, -wallDepth, 0], [0, -StepThk / 2, 0], [0, -wallDepth, 0], [0, -StepThk / 2, 0],
- [0, -wallDepth, 0], [0, -StepThk / 2, 0], [0, -wallDepth, 0], [0, -StepThk / 2, 0]]
+ StepOffsets = [
+ [0, -wallDepth, 0], [0, -StepThk / 2, 0],
+ [0, -wallDepth, 0], [0, -StepThk / 2, 0],
+ [0, -wallDepth, 0], [0, -StepThk / 2, 0],
+ [0, -wallDepth, 0], [0, -StepThk / 2, 0]
+ ]
# Add steps for each "step row" in area (neg width is interesting but prevented)
while StepBtm < StepTop and StepWide > 0:
@@ -1645,7 +1747,8 @@ def build(Aplan):
else:
r1 = 1
- geom = MakeABlock([x - w / 2, x + w / 2, z - h / 2, z + h / 2, -d / 2, d / 2], settings['sdv'], len(vlist),
+ geom = MakeABlock([x - w / 2, x + w / 2, z - h / 2, z + h / 2, -d / 2, d / 2],
+ settings['sdv'], len(vlist),
corners, None, settings['b'] + rndd() * settings['bv'], r1)
vlist += geom[0]
flist += geom[1]
diff --git a/add_mesh_extra_objects/Wallfactory.py b/add_mesh_extra_objects/Wallfactory.py
index a58b9f5a..41957b22 100644
--- a/add_mesh_extra_objects/Wallfactory.py
+++ b/add_mesh_extra_objects/Wallfactory.py
@@ -1,4 +1,4 @@
-# ***** BEGIN GPL LICENSE BLOCK *****
+# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you may redistribute it, and/or
# modify it, under the terms of the GNU General Public License
@@ -19,22 +19,43 @@
#
# or go online at: http://www.gnu.org/licenses/ to view license options.
#
-# ***** END GPL LICENCE BLOCK *****
+# ##### END GPL LICENCE BLOCK #####
-# This module contains the UI definition, display, and processing (create mesh)
-# functions.
-# The routines to generate the vertices for the wall are found in the "Blocks" module.
+# authors: dudecon, jambay
+
+# This module contains the UI definition, display,
+# and processing (create mesh) functions.
+# The routines to generate the vertices for the wall
+# are found in the "Blocks" module.
import bpy
+from bpy.types import Operator
from bpy.props import (
BoolProperty,
FloatProperty,
)
-from add_mesh_extra_objects.Blocks import *
+from .Blocks import (
+ NOTZERO, PI,
+ dims,
+ settings,
+ shelfSpecs,
+ stepSpecs,
+ createWall,
+ radialized,
+ slope,
+ openingSpecs,
+ bigBlock,
+ shelfExt,
+ stepMod,
+ stepLeft,
+ shelfBack,
+ stepOnly,
+ stepBack,
+ )
-class add_mesh_wallb(bpy.types.Operator):
+class add_mesh_wallb(Operator):
bl_idname = "mesh.wall_add"
bl_label = "Add a Masonry Wall"
bl_description = "Create a block (masonry) wall mesh"
@@ -46,402 +67,407 @@ class add_mesh_wallb(bpy.types.Operator):
# only create object when True
# False allows modifying several parameters without creating object
ConstructTog = BoolProperty(
- name="Construct",
- description="Generate the object",
- default=True
- )
- # need to modify so radial makes a tower (normal); want "flat" setting to make disk (alternate)
+ name="Construct",
+ description="Generate the object",
+ default=True
+ )
+ # need to modify so radial makes a tower (normal);
+ # want "flat" setting to make disk (alternate)
# make the wall circular - if not sloped it's a flat disc
RadialTog = BoolProperty(
- name="Radial",
- description="Make masonry radial",
- default=False
- )
+ name="Radial",
+ description="Make masonry radial",
+ default=False
+ )
# curve the wall - if radial creates dome.
SlopeTog = BoolProperty(
- name="Curved",
- description="Make masonry sloped, or curved",
- default=False
- )
+ name="Curved",
+ description="Make masonry sloped, or curved",
+ default=False
+ )
# need to review defaults and limits for all of these UI objects
# wall area/size
WallStart = FloatProperty(
- name="Start",
- description="Left side, or start angle",
- default=-10.0,
- min=-100, max=100.0
- )
+ name="Start",
+ description="Left side, or start angle",
+ default=-10.0,
+ min=-100, max=100.0
+ )
WallEnd = FloatProperty(
- name="End",
- description="Right side, or end angle",
- default=10.0,
- min=0.0, max=100.0
- )
+ name="End",
+ description="Right side, or end angle",
+ default=10.0,
+ min=0.0, max=100.0
+ )
WallBottom = FloatProperty(
- name="Bottom",
- description="Lower height or radius",
- default=0.0,
- min=-100, max=100
- )
+ name="Bottom",
+ description="Lower height or radius",
+ default=0.0,
+ min=-100, max=100
+ )
WallTop = FloatProperty(
- name="Top",
- description="Upper height or radius",
- default=15.0,
- min=0.0, max=100.0
- )
+ name="Top",
+ description="Upper height or radius",
+ default=15.0,
+ min=0.0, max=100.0
+ )
EdgeOffset = FloatProperty(
- name="Edging",
- description="Block staggering on wall sides",
- default=0.6, min=0.0, max=100.0
- )
+ name="Edging",
+ description="Block staggering on wall sides",
+ default=0.6, min=0.0, max=100.0
+ )
# block sizing
Width = FloatProperty(
- name="Width",
- description="Average width of each block",
- default=1.5,
- min=0.01, max=100.0
- )
+ name="Width",
+ description="Average width of each block",
+ default=1.5,
+ min=0.01, max=100.0
+ )
WidthVariance = FloatProperty(
- name="Variance",
- description="Random variance of block width",
- default=0.5,
- min=0.0, max=100.0
- )
+ name="Variance",
+ description="Random variance of block width",
+ default=0.5,
+ min=0.0, max=100.0
+ )
WidthMinimum = FloatProperty(
- name="Minimum",
- description="Absolute minimum block width",
- default=0.5,
- min=0.01, max=100.0
- )
+ name="Minimum",
+ description="Absolute minimum block width",
+ default=0.5,
+ min=0.01, max=100.0
+ )
Height = FloatProperty(
- name="Height",
- description="Average Height of each block",
- default=0.7,
- min=0.01, max=100.0
- )
+ name="Height",
+ description="Average Height of each block",
+ default=0.7,
+ min=0.01, max=100.0
+ )
HeightVariance = FloatProperty(
- name="Variance",
- description="Random variance of block Height",
- default=0.3,
- min=0.0, max=100.0
- )
+ name="Variance",
+ description="Random variance of block Height",
+ default=0.3,
+ min=0.0, max=100.0
+ )
HeightMinimum = FloatProperty(
- name="Minimum",
- description="Absolute minimum block Height",
- default=0.25,
- min=0.01, max=100.0
- )
+ name="Minimum",
+ description="Absolute minimum block Height",
+ default=0.25,
+ min=0.01, max=100.0
+ )
Depth = FloatProperty(
- name="Depth",
- description="Average Depth of each block",
- default=2.0,
- min=0.01, max=100.0
- )
+ name="Depth",
+ description="Average Depth of each block",
+ default=2.0,
+ min=0.01, max=100.0
+ )
DepthVariance = FloatProperty(
- name="Variance",
- description="Random variance of block Depth",
- default=0.1,
- min=0.0, max=100.0
- )
+ name="Variance",
+ description="Random variance of block Depth",
+ default=0.1,
+ min=0.0, max=100.0
+ )
DepthMinimum = FloatProperty(
- name="Minimum",
- description="Absolute minimum block Depth",
- default=1.0,
- min=0.01, max=100.0
- )
+ name="Minimum",
+ description="Absolute minimum block Depth",
+ default=1.0,
+ min=0.01, max=100.0
+ )
MergeBlock = BoolProperty(
- name="Merge Blocks",
- description="Make big blocks (merge closely adjoining blocks)",
- default=False
- )
+ name="Merge Blocks",
+ description="Make big blocks (merge closely adjoining blocks)",
+ default=False
+ )
# edging for blocks
Grout = FloatProperty(
- name="Thickness",
- description="Distance between blocks",
- default=0.1,
- min=-10.0, max=10.0
- )
+ name="Thickness",
+ description="Distance between blocks",
+ default=0.1,
+ min=-10.0, max=10.0
+ )
GroutVariance = FloatProperty(
- name="Variance",
- description="Random variance of block Grout",
- default=0.03,
- min=0.0, max=100.0)
+ name="Variance",
+ description="Random variance of block Grout",
+ default=0.03,
+ min=0.0, max=100.0
+ )
GroutDepth = FloatProperty(
- name="Depth",
- description="Grout Depth from the face of the blocks",
- default=0.1,
- min=0.0001, max=10.0
- )
+ name="Depth",
+ description="Grout Depth from the face of the blocks",
+ default=0.1,
+ min=0.0001, max=10.0
+ )
GroutDepthVariance = FloatProperty(
- name="Variance",
- description="Random variance of block Grout Depth",
- default=0.03,
- min=0.0, max=100.0
- )
+ name="Variance",
+ description="Random variance of block Grout Depth",
+ default=0.03,
+ min=0.0, max=100.0
+ )
GroutEdge = BoolProperty(
- name="Edging",
- description="Grout perimiter",
- default=False
- )
+ name="Edging",
+ description="Grout perimiter",
+ default=False
+ )
# properties for openings
Opening1Tog = BoolProperty(
- name="Opening(s)",
- description="Make windows or doors",
- default=True
- )
+ name="Opening(s)",
+ description="Make windows or doors",
+ default=True
+ )
Opening1Width = FloatProperty(
- name="Width",
- description="The Width of opening 1",
- default=2.5,
- min=0.01, max=100.0
- )
+ name="Width",
+ description="The Width of the first opening",
+ default=2.5,
+ min=0.01, max=100.0
+ )
Opening1Height = FloatProperty(
- name="Height",
- description="The Height of opening 1",
- default=3.5,
- min=0.01, max=100.0
- )
+ name="Height",
+ description="The Height of the first opening",
+ default=3.5,
+ min=0.01, max=100.0
+ )
Opening1X = FloatProperty(
- name="Indent",
- description="The x position or spacing of opening 1",
- default=5.0,
- min=-100, max=100.0
- )
+ name="Indent",
+ description="The x position or spacing of the first opening",
+ default=5.0,
+ min=-100, max=100.0
+ )
Opening1Z = FloatProperty(
- name="Bottom",
- description="The z position of opening 1",
- default=5.0,
- min=-100, max=100.0
- )
+ name="Bottom",
+ description="The z position of the First opening",
+ default=5.0,
+ min=-100, max=100.0
+ )
Opening1Repeat = BoolProperty(
- name="Repeat",
- description="make multiple openings, with spacing X1",
- default=False
- )
+ name="Repeat",
+ description="make multiple openings, with spacing X1",
+ default=False
+ )
Opening1TopArchTog = BoolProperty(
- name="Top Arch",
- description="Add an arch to the top of opening 1",
- default=True
- )
+ name="Top Arch",
+ description="Add an arch to the top of the first opening",
+ default=True
+ )
Opening1TopArch = FloatProperty(
- name="Curve",
- description="Height of the arch on the top of the opening",
- default=2.5,
- min=0.001, max=100.0
- )
+ name="Curve",
+ description="Height of the arch on the top of the opening",
+ default=2.5,
+ min=0.001, max=100.0
+ )
Opening1TopArchThickness = FloatProperty(
- name="Thickness",
- description="Thickness of the arch on the top of the opening",
- default=0.75,
- min=0.001, max=100.0
- )
+ name="Thickness",
+ description="Thickness of the arch on the top of the opening",
+ default=0.75,
+ min=0.001, max=100.0
+ )
Opening1BtmArchTog = BoolProperty(
- name="Bottom Arch",
- description="Add an arch to the bottom of opening 1",
- default=False
- )
+ name="Bottom Arch",
+ description="Add an arch to the bottom of opening 1",
+ default=False
+ )
Opening1BtmArch = FloatProperty(
- name="Curve",
- description="Height of the arch on the bottom of the opening",
- default=1.0,
- min=0.01, max=100.0
- )
+ name="Curve",
+ description="Height of the arch on the bottom of the opening",
+ default=1.0,
+ min=0.01, max=100.0
+ )
Opening1BtmArchThickness = FloatProperty(
- name="Thickness",
- description="Thickness of the arch on the bottom of the opening",
- default=0.5,
- min=0.01, max=100.0
- )
+ name="Thickness",
+ description="Thickness of the arch on the bottom of the opening",
+ default=0.5,
+ min=0.01, max=100.0
+ )
Opening1Bevel = FloatProperty(
- name="Bevel",
- description="Angle block face",
- default=0.25,
- min=-10.0, max=10.0
- )
+ name="Bevel",
+ description="Angle block face",
+ default=0.25,
+ min=-10.0, max=10.0
+ )
# openings on top of wall
CrenelTog = BoolProperty(
- name="Crenels",
- description="Make openings along top of wall",
- default=False
- )
+ name="Crenels",
+ description="Make openings along top of wall",
+ default=False
+ )
CrenelXP = FloatProperty(
- name="Width %",
- description="Gap width in wall based % of wall width",
- default=0.25,
- min=0.10, max=1.0
- )
+ name="Width",
+ description="Gap width in wall based the percentage of wall width",
+ default=0.25,
+ min=0.10, max=1.0,
+ subtype="PERCENTAGE"
+ )
CrenelZP = FloatProperty(
- name="Height %",
- description="Crenel Height as % of wall height",
- default=0.10,
- min=0.10, max=1.0
- )
+ name="Height",
+ description="Crenel Height as the percentage of wall height",
+ default=0.10,
+ min=0.10, max=1.0,
+ subtype="PERCENTAGE"
+ )
# narrow openings in wall.
# need to prevent overlap with arch openings - though inversion is an interesting effect.
SlotTog = BoolProperty(
- name="Slots",
- description="Make narrow openings in wall",
- default=False
- )
- SlotRpt = BoolProperty(name="Repeat",
- description="Repeat slots along wall",
- default=False
- )
+ name="Slots",
+ description="Make narrow openings in wall",
+ default=False
+ )
+ SlotRpt = BoolProperty(
+ name="Repeat",
+ description="Repeat slots along wall",
+ default=False
+ )
SlotWdg = BoolProperty(
- name="Wedged (n/a)",
- description="Bevel edges of slots",
- default=False
- )
+ name="Wedged (n/a)",
+ description="Bevel edges of slots",
+ default=False
+ )
SlotX = FloatProperty(
- name="Indent",
- description="The x position or spacing of slots",
- default=0.0, min=-100, max=100.0
- )
+ name="Indent",
+ description="The x position or spacing of slots",
+ default=0.0, min=-100, max=100.0
+ )
SlotGap = FloatProperty(
- name="Opening",
- description="The opening size of slots",
- default=0.5, min=0.10, max=100.0
- )
+ name="Opening",
+ description="The opening size of slots",
+ default=0.5, min=0.10, max=100.0
+ )
SlotV = BoolProperty(
- name="Vertical",
- description="Vertical slots",
- default=True
- )
+ name="Vertical",
+ description="Vertical slots",
+ default=True
+ )
SlotVH = FloatProperty(
- name="Height",
- description="Height of vertical slot",
- default=3.5,
- min=0.10, max=100.0
- )
+ name="Height",
+ description="Height of vertical slot",
+ default=3.5,
+ min=0.10, max=100.0
+ )
SlotVBtm = FloatProperty(
- name="Bottom",
- description="Z position for slot",
- default=5.00,
- min=-100.0, max=100.0
- )
+ name="Bottom",
+ description="Z position for slot",
+ default=5.00,
+ min=-100.0, max=100.0
+ )
SlotH = BoolProperty(
- name="Horizontal",
- description="Horizontal slots",
- default=False
- )
+ name="Horizontal",
+ description="Horizontal slots",
+ default=False
+ )
SlotHW = FloatProperty(
- name="Width",
- description="Width of horizontal slot",
- default=2.5,
- min=0.10, max=100.0
- )
+ name="Width",
+ description="Width of horizontal slot",
+ default=2.5,
+ min=0.10, max=100.0
+ )
# this should offset from VBtm... maybe make a % like crenels?
SlotHBtm = FloatProperty(
- name="Bottom",
- description="Z position for horizontal slot",
- default=5.50,
- min=-100.0, max=100.0
- )
+ name="Bottom",
+ description="Z position for horizontal slot",
+ default=5.50,
+ min=-100.0, max=100.0
+ )
# properties for shelf (extend blocks in area)
ShelfTog = BoolProperty(
- name="Shelf",
- description="Add blocks in area by depth to make shelf/platform",
- default=False
- )
+ name="Shelf",
+ description="Add blocks in area by depth to make shelf/platform",
+ default=False
+ )
ShelfX = FloatProperty(
- name="Left",
- description="The x position of Shelf",
- default=-5.00,
- min=-100, max=100.0
- )
+ name="Left",
+ description="The x position of Shelf",
+ default=-5.00,
+ min=-100, max=100.0
+ )
ShelfZ = FloatProperty(
- name="Bottom",
- description="The z position of Shelf",
- default=10.0,
- min=-100, max=100.0
- )
+ name="Bottom",
+ description="The z position of Shelf",
+ default=10.0,
+ min=-100, max=100.0
+ )
ShelfH = FloatProperty(
- name="Height",
- description="The Height of Shelf area",
- default=1.0,
- min=0.01, max=100.0
- )
+ name="Height",
+ description="The Height of Shelf area",
+ default=1.0,
+ min=0.01, max=100.0
+ )
ShelfW = FloatProperty(
- name="Width",
- description="The Width of shelf area",
- default=5.0,
- min=0.01, max=100.0
- )
+ name="Width",
+ description="The Width of shelf area",
+ default=5.0,
+ min=0.01, max=100.0
+ )
ShelfD = FloatProperty(
- name="Depth",
- description="Depth of each block for shelf (from cursor + 1/2 wall depth)",
- default=2.0,
- min=0.01, max=100.0
- )
+ name="Depth",
+ description="Depth of each block for shelf (from cursor + 1/2 wall depth)",
+ default=2.0,
+ min=0.01, max=100.0
+ )
ShelfBack = BoolProperty(
- name="Backside",
- description="Shelf on backside of wall",
- default=False
- )
+ name="Backside",
+ description="Shelf on backside of wall",
+ default=False
+ )
# properties for steps (extend blocks in area, progressive width)
StepTog = BoolProperty(
- name="Steps",
- description="Add blocks in area by depth with progressive width to make steps",
- default=False
- )
+ name="Steps",
+ description="Add blocks in area by depth with progressive width to make steps",
+ default=False
+ )
StepX = FloatProperty(
- name="Left",
- description="The x position of steps",
- default=-9.00,
- min=-100, max=100.0
- )
+ name="Left",
+ description="The x position of steps",
+ default=-9.00,
+ min=-100, max=100.0
+ )
StepZ = FloatProperty(
- name="Bottom",
- description="The z position of steps",
- default=0.0,
- min=-100, max=100.0
- )
+ name="Bottom",
+ description="The z position of steps",
+ default=0.0,
+ min=-100, max=100.0
+ )
StepH = FloatProperty(
- name="Height",
- description="The Height of step area",
- default=10.0,
- min=0.01, max=100.0
- )
+ name="Height",
+ description="The Height of step area",
+ default=10.0,
+ min=0.01, max=100.0
+ )
StepW = FloatProperty(
- name="Width",
- description="The Width of step area",
- default=8.0,
- min=0.01, max=100.0
- )
+ name="Width",
+ description="The Width of step area",
+ default=8.0,
+ min=0.01, max=100.0
+ )
StepD = FloatProperty(
- name="Depth",
- description="Depth of each block for steps (from cursor + 1/2 wall depth)",
- default=1.0,
- min=0.01, max=100.0
- )
+ name="Depth",
+ description="Depth of each block for steps (from cursor + 1/2 wall depth)",
+ default=1.0,
+ min=0.01, max=100.0
+ )
StepV = FloatProperty(
- name="Riser",
- description="Height of each step",
- default=0.70,
- min=0.01, max=100.0
- )
+ name="Riser",
+ description="Height of each step",
+ default=0.70,
+ min=0.01, max=100.0
+ )
StepT = FloatProperty(
- name="Tread",
- description="Width of each step",
- default=1.0,
- min=0.01, max=100.0
- )
+ name="Tread",
+ description="Width of each step",
+ default=1.0,
+ min=0.01, max=100.0
+ )
StepLeft = BoolProperty(
- name="High Left",
- description="Height left; else Height right",
- default=False
- )
+ name="Direction",
+ description="If checked, flip steps direction towards the -X axis",
+ default=False
+ )
StepOnly = BoolProperty(
- name="No Blocks",
- description="Steps only, no supporting blocks",
- default=False
- )
+ name="Steps Only",
+ description="Steps only, no supporting blocks",
+ default=False
+ )
StepBack = BoolProperty(
- name="Backside",
- description="Steps on backside of wall",
- default=False
- )
+ name="Backside",
+ description="Steps on backside of wall",
+ default=False
+ )
# Display the toolbox options
def draw(self, context):
@@ -453,104 +479,152 @@ class add_mesh_wallb(bpy.types.Operator):
# Wall area (size/position)
box = layout.box()
box.label(text="Wall Size (area)")
- box.prop(self, "WallStart")
- box.prop(self, "WallEnd")
- box.prop(self, "WallBottom")
- box.prop(self, "WallTop")
+
+ col = box.column(align=True)
+ col.prop(self, "WallStart")
+ col.prop(self, "WallEnd")
+
+ col = box.column(align=True)
+ col.prop(self, "WallBottom")
+ col.prop(self, "WallTop")
box.prop(self, "EdgeOffset")
# Wall block sizing
box = layout.box()
- box.label(text='Block Sizing')
- box.prop(self, 'MergeBlock')
- # add checkbox for "fixed" sizing (ignore variance) a.k.a. bricks.
- box.prop(self, "Width")
- box.prop(self, "WidthVariance")
- box.prop(self, "WidthMinimum")
- box.prop(self, "Height")
- box.prop(self, "HeightVariance")
- box.prop(self, "HeightMinimum")
- box.prop(self, "Depth")
- box.prop(self, "DepthVariance")
- box.prop(self, "DepthMinimum")
+ box.label(text="Block Sizing")
+ box.prop(self, "MergeBlock")
+
+ # add checkbox for "fixed" sizing (ignore variance) a.k.a. bricks
+ col = box.column(align=True)
+ col.prop(self, "Width")
+ col.prop(self, "WidthVariance")
+ col.prop(self, "WidthMinimum")
+
+ col = box.column(align=True)
+ col.prop(self, "Height")
+ col.prop(self, "HeightVariance")
+ col.prop(self, "HeightMinimum")
+
+ col = box.column(align=True)
+ col.prop(self, "Depth")
+ col.prop(self, "DepthVariance")
+ col.prop(self, "DepthMinimum")
# grout settings
box = layout.box()
box.label(text="Grout")
- box.prop(self, "Grout")
- box.prop(self, "GroutVariance")
- box.prop(self, "GroutDepth")
- box.prop(self, "GroutDepthVariance")
+
+ col = box.column(align=True)
+ col.prop(self, "Grout")
+ col.prop(self, "GroutVariance")
+
+ col = box.column(align=True)
+ col.prop(self, "GroutDepth")
+ col.prop(self, "GroutDepthVariance")
# Wall shape modifiers
box = layout.box()
box.label(text="Wall Shape")
- box.prop(self, "RadialTog")
- box.prop(self, "SlopeTog")
+ row = box.row(align=True)
+ row.prop(self, "RadialTog", toggle=True)
+ row.prop(self, "SlopeTog", toggle=True)
# Openings (doors, windows; arched)
box = layout.box()
box.prop(self, 'Opening1Tog')
- if self.properties.Opening1Tog:
- box.prop(self, "Opening1Width")
- box.prop(self, "Opening1Height")
- box.prop(self, "Opening1X")
- box.prop(self, "Opening1Z")
- box.prop(self, "Opening1Bevel")
- box.prop(self, "Opening1Repeat")
- box.prop(self, "Opening1TopArchTog")
- box.prop(self, "Opening1TopArch")
- box.prop(self, "Opening1TopArchThickness")
- box.prop(self, "Opening1BtmArchTog")
- box.prop(self, "Opening1BtmArch")
- box.prop(self, "Opening1BtmArchThickness")
+ if self.Opening1Tog:
+ col = box.column(align=True)
+ col.prop(self, "Opening1Width")
+ col.prop(self, "Opening1Height")
+ col.prop(self, "Opening1X")
+ col.prop(self, "Opening1Z")
+ col.prop(self, "Opening1Bevel")
+
+ box.prop(self, "Opening1Repeat", toggle=True)
+
+ sub_box = box.box()
+ sub_box.prop(self, "Opening1TopArchTog")
+ if self.Opening1TopArchTog:
+ col = sub_box.column(align=True)
+ col.prop(self, "Opening1TopArch")
+ col.prop(self, "Opening1TopArchThickness")
+
+ sub_box = box.box()
+ sub_box.prop(self, "Opening1BtmArchTog")
+ if self.Opening1BtmArchTog:
+ col = sub_box.column(align=True)
+ col.prop(self, "Opening1BtmArch")
+ col.prop(self, "Opening1BtmArchThickness")
# Slots (narrow openings)
box = layout.box()
- box.prop(self, 'SlotTog')
- if self.properties.SlotTog:
- box.prop(self, "SlotX")
- box.prop(self, "SlotGap")
- box.prop(self, "SlotRpt")
- box.prop(self, "SlotV")
- box.prop(self, "SlotVH")
- box.prop(self, "SlotVBtm")
- box.prop(self, "SlotH")
- box.prop(self, "SlotHW")
- box.prop(self, "SlotHBtm")
+ box.prop(self, "SlotTog")
+ if self.SlotTog:
+ col = box.column(align=True)
+ col.prop(self, "SlotX")
+ col.prop(self, "SlotGap")
+
+ box.prop(self, "SlotRpt", toggle=True)
+
+ sub_box = box.box()
+ sub_box.prop(self, "SlotV")
+ if self.SlotV:
+ col = sub_box.column(align=True)
+ col.prop(self, "SlotVH")
+ col.prop(self, "SlotVBtm")
+
+ sub_box = box.box()
+ sub_box.prop(self, "SlotH")
+ if self.SlotH:
+ col = sub_box.column(align=True)
+ col.prop(self, "SlotHW")
+ col.prop(self, "SlotHBtm")
# Crenels, gaps in top of wall
box = layout.box()
box.prop(self, "CrenelTog")
- if self.properties.CrenelTog:
- box.prop(self, "CrenelXP")
- box.prop(self, "CrenelZP")
+ if self.CrenelTog:
+ col = box.column(align=True)
+ col.prop(self, "CrenelXP")
+ col.prop(self, "CrenelZP")
# Shelfing (protrusions)
box = layout.box()
box.prop(self, 'ShelfTog')
- if self.properties.ShelfTog:
- box.prop(self, "ShelfX")
- box.prop(self, "ShelfZ")
- box.prop(self, "ShelfH")
- box.prop(self, "ShelfW")
- box.prop(self, "ShelfD")
+ if self.ShelfTog:
+ col = box.column(align=True)
+ col.prop(self, "ShelfX")
+ col.prop(self, "ShelfZ")
+
+ col = box.column(align=True)
+ col.prop(self, "ShelfW")
+ col.prop(self, "ShelfH")
+ col.prop(self, "ShelfD")
+
box.prop(self, "ShelfBack")
# Steps
box = layout.box()
box.prop(self, 'StepTog')
- if self.properties.StepTog:
- box.prop(self, "StepX")
- box.prop(self, "StepZ")
- box.prop(self, "StepH")
- box.prop(self, "StepW")
- box.prop(self, "StepD")
- box.prop(self, "StepV")
- box.prop(self, "StepT")
- box.prop(self, "StepLeft")
- box.prop(self, "StepOnly")
- box.prop(self, "StepBack")
+ if self.StepTog:
+ col = box.column(align=True)
+ col.prop(self, "StepX")
+ col.prop(self, "StepZ")
+
+ col = box.column(align=True)
+ col.prop(self, "StepH")
+ col.prop(self, "StepW")
+ col.prop(self, "StepD")
+
+ col = box.column(align=True)
+ col.prop(self, "StepV")
+ col.prop(self, "StepT")
+
+ col = box.column(align=True)
+ row = col.row(align=True)
+ row.prop(self, "StepLeft", toggle=True)
+ row.prop(self, "StepOnly", toggle=True)
+ col.prop(self, "StepBack", toggle=True)
# Respond to UI - get the properties set by user.
# Check and process UI settings to generate masonry
@@ -568,56 +642,57 @@ class add_mesh_wallb(bpy.types.Operator):
global stepBack
# Create the wall when enabled (skip regen iterations when off)
- if not self.properties.ConstructTog:
+ if not self.ConstructTog:
return {'FINISHED'}
# enter the settings for the wall dimensions (area)
# start can't be zero - min/max don't matter [if max less than end] but zero don't workie.
# start can't exceed end.
- if not self.properties.WallStart or self.properties.WallStart >= self.properties.WallEnd:
- self.properties.WallStart = NOTZERO # Reset UI if input out of bounds...
+ if not self.WallStart or self.WallStart >= self.WallEnd:
+ self.WallStart = NOTZERO # Reset UI if input out of bounds...
- dims['s'] = self.properties.WallStart
- dims['e'] = self.properties.WallEnd
- dims['b'] = self.properties.WallBottom
- dims['t'] = self.properties.WallTop
+ dims['s'] = self.WallStart
+ dims['e'] = self.WallEnd
+ dims['b'] = self.WallBottom
+ dims['t'] = self.WallTop
- settings['eoff'] = self.properties.EdgeOffset
+ settings['eoff'] = self.EdgeOffset
# retrieve the settings for the wall block properties
- settings['w'] = self.properties.Width
- settings['wv'] = self.properties.WidthVariance
- settings['wm'] = self.properties.WidthMinimum
+ settings['w'] = self.Width
+ settings['wv'] = self.WidthVariance
+ settings['wm'] = self.WidthMinimum
+
if not radialized:
settings['sdv'] = settings['w']
else:
settings['sdv'] = 0.12
- settings['h'] = self.properties.Height
- settings['hv'] = self.properties.HeightVariance
- settings['hm'] = self.properties.HeightMinimum
+ settings['h'] = self.Height
+ settings['hv'] = self.HeightVariance
+ settings['hm'] = self.HeightMinimum
- settings['d'] = self.properties.Depth
- settings['dv'] = self.properties.DepthVariance
- settings['dm'] = self.properties.DepthMinimum
+ settings['d'] = self.Depth
+ settings['dv'] = self.DepthVariance
+ settings['dm'] = self.DepthMinimum
- if self.properties.MergeBlock:
+ if self.MergeBlock:
bigBlock = 1
else:
bigBlock = 0
- settings['g'] = self.properties.Grout
- settings['gv'] = self.properties.GroutVariance
- settings['gd'] = self.properties.GroutDepth
- settings['gdv'] = self.properties.GroutDepthVariance
+ settings['g'] = self.Grout
+ settings['gv'] = self.GroutVariance
+ settings['gd'] = self.GroutDepth
+ settings['gdv'] = self.GroutDepthVariance
- if self.properties.GroutEdge:
+ if self.GroutEdge:
settings['ge'] = 1
else:
settings['ge'] = 0
# set wall shape modifiers
- if self.properties.RadialTog:
+ if self.RadialTog:
radialized = 1
# eliminate to allow user control for start/completion?
dims['s'] = 0.0 # complete radial
@@ -628,7 +703,7 @@ class add_mesh_wallb(bpy.types.Operator):
else:
radialized = 0
- if self.properties.SlopeTog:
+ if self.SlopeTog:
slope = 1
else:
slope = 0
@@ -636,113 +711,113 @@ class add_mesh_wallb(bpy.types.Operator):
shelfExt = 0
shelfBack = 0
- # Add shelf if enabled
- if self.properties.ShelfTog:
+ # Add shelf if enabled
+ if self.ShelfTog:
shelfExt = 1
- shelfSpecs['h'] = self.properties.ShelfH
- shelfSpecs['w'] = self.properties.ShelfW
- shelfSpecs['d'] = self.properties.ShelfD
- shelfSpecs['x'] = self.properties.ShelfX
- shelfSpecs['z'] = self.properties.ShelfZ
+ shelfSpecs['h'] = self.ShelfH
+ shelfSpecs['w'] = self.ShelfW
+ shelfSpecs['d'] = self.ShelfD
+ shelfSpecs['x'] = self.ShelfX
+ shelfSpecs['z'] = self.ShelfZ
- if self.properties.ShelfBack:
+ if self.ShelfBack:
shelfBack = 1
stepMod = 0
stepLeft = 0
stepOnly = 0
stepBack = 0
- # Make steps if enabled
- if self.properties.StepTog:
+ # Make steps if enabled
+ if self.StepTog:
stepMod = 1
- stepSpecs['x'] = self.properties.StepX
- stepSpecs['z'] = self.properties.StepZ
- stepSpecs['h'] = self.properties.StepH
- stepSpecs['w'] = self.properties.StepW
- stepSpecs['d'] = self.properties.StepD
- stepSpecs['v'] = self.properties.StepV
- stepSpecs['t'] = self.properties.StepT
-
- if self.properties.StepLeft:
+ stepSpecs['x'] = self.StepX
+ stepSpecs['z'] = self.StepZ
+ stepSpecs['h'] = self.StepH
+ stepSpecs['w'] = self.StepW
+ stepSpecs['d'] = self.StepD
+ stepSpecs['v'] = self.StepV
+ stepSpecs['t'] = self.StepT
+
+ if self.StepLeft:
stepLeft = 1
- if self.properties.StepOnly:
+ if self.StepOnly:
stepOnly = 1
- if self.properties.StepBack:
+ if self.StepBack:
stepBack = 1
# enter the settings for the openings
# when openings overlap they create inverse stonework - interesting but not the desired effect :)
- # if opening width == indent*2 the edge blocks fail (row of blocks cross opening) - bug.
+ # if opening width == indent * 2 the edge blocks fail (row of blocks cross opening) - bug.
openingSpecs = []
openingIdx = 0 # track opening array references for multiple uses
# general openings with arch options - can be windows or doors.
- if self.properties.Opening1Tog:
+ if self.Opening1Tog:
# set defaults...
openingSpecs += [{'w': 0.5, 'h': 0.5, 'x': 0.8, 'z': 2.7, 'rp': 1,
'b': 0.0, 'v': 0, 'vl': 0, 't': 0, 'tl': 0}]
- openingSpecs[openingIdx]['w'] = self.properties.Opening1Width
- openingSpecs[openingIdx]['h'] = self.properties.Opening1Height
- openingSpecs[openingIdx]['x'] = self.properties.Opening1X
- openingSpecs[openingIdx]['z'] = self.properties.Opening1Z
- openingSpecs[openingIdx]['rp'] = self.properties.Opening1Repeat
+ openingSpecs[openingIdx]['w'] = self.Opening1Width
+ openingSpecs[openingIdx]['h'] = self.Opening1Height
+ openingSpecs[openingIdx]['x'] = self.Opening1X
+ openingSpecs[openingIdx]['z'] = self.Opening1Z
+ openingSpecs[openingIdx]['rp'] = self.Opening1Repeat
- if self.properties.Opening1TopArchTog:
- openingSpecs[openingIdx]['v'] = self.properties.Opening1TopArch
- openingSpecs[openingIdx]['t'] = self.properties.Opening1TopArchThickness
+ if self.Opening1TopArchTog:
+ openingSpecs[openingIdx]['v'] = self.Opening1TopArch
+ openingSpecs[openingIdx]['t'] = self.Opening1TopArchThickness
- if self.properties.Opening1BtmArchTog:
- openingSpecs[openingIdx]['vl'] = self.properties.Opening1BtmArch
- openingSpecs[openingIdx]['tl'] = self.properties.Opening1BtmArchThickness
+ if self.Opening1BtmArchTog:
+ openingSpecs[openingIdx]['vl'] = self.Opening1BtmArch
+ openingSpecs[openingIdx]['tl'] = self.Opening1BtmArchThickness
- openingSpecs[openingIdx]['b'] = self.properties.Opening1Bevel
+ openingSpecs[openingIdx]['b'] = self.Opening1Bevel
openingIdx += 1 # count window/door/arch openings
# Slots (narrow openings)
- if self.properties.SlotTog:
+ if self.SlotTog:
- if self.properties.SlotV: # vertical slots
+ if self.SlotV: # vertical slots
# set defaults...
openingSpecs += [{'w': 0.5, 'h': 0.5, 'x': 0.0, 'z': 2.7, 'rp': 0,
'b': 0.0, 'v': 0, 'vl': 0, 't': 0, 'tl': 0}]
- openingSpecs[openingIdx]['w'] = self.properties.SlotGap
- openingSpecs[openingIdx]['h'] = self.properties.SlotVH
- openingSpecs[openingIdx]['x'] = self.properties.SlotX
- openingSpecs[openingIdx]['z'] = self.properties.SlotVBtm
- openingSpecs[openingIdx]['rp'] = self.properties.SlotRpt
+ openingSpecs[openingIdx]['w'] = self.SlotGap
+ openingSpecs[openingIdx]['h'] = self.SlotVH
+ openingSpecs[openingIdx]['x'] = self.SlotX
+ openingSpecs[openingIdx]['z'] = self.SlotVBtm
+ openingSpecs[openingIdx]['rp'] = self.SlotRpt
# make them pointy...
- openingSpecs[openingIdx]['v'] = self.properties.SlotGap
- openingSpecs[openingIdx]['t'] = self.properties.SlotGap / 2
- openingSpecs[openingIdx]['vl'] = self.properties.SlotGap
- openingSpecs[openingIdx]['tl'] = self.properties.SlotGap / 2
+ openingSpecs[openingIdx]['v'] = self.SlotGap
+ openingSpecs[openingIdx]['t'] = self.SlotGap / 2
+ openingSpecs[openingIdx]['vl'] = self.SlotGap
+ openingSpecs[openingIdx]['tl'] = self.SlotGap / 2
openingIdx += 1 # count vertical slot openings
# need to handle overlap of H and V slots...
- if self.properties.SlotH: # Horizontal slots
+ if self.SlotH: # Horizontal slots
# set defaults...
openingSpecs += [{'w': 0.5, 'h': 0.5, 'x': 0.0, 'z': 2.7, 'rp': 0,
'b': 0.0, 'v': 0, 'vl': 0, 't': 0, 'tl': 0}]
- openingSpecs[openingIdx]['w'] = self.properties.SlotHW
- openingSpecs[openingIdx]['h'] = self.properties.SlotGap
- openingSpecs[openingIdx]['x'] = self.properties.SlotX
- openingSpecs[openingIdx]['z'] = self.properties.SlotHBtm
+ openingSpecs[openingIdx]['w'] = self.SlotHW
+ openingSpecs[openingIdx]['h'] = self.SlotGap
+ openingSpecs[openingIdx]['x'] = self.SlotX
+ openingSpecs[openingIdx]['z'] = self.SlotHBtm
# horizontal repeat isn't same spacing as vertical...
- openingSpecs[openingIdx]['rp'] = self.properties.SlotRpt
+ openingSpecs[openingIdx]['rp'] = self.SlotRpt
# make them pointy...
openingIdx += 1 # count horizontal slot openings
# Crenellations (top row openings)
- if self.properties.CrenelTog:
+ if self.CrenelTog:
# add bottom arch option?
# perhaps a repeat toggle...
@@ -752,11 +827,11 @@ class add_mesh_wallb(bpy.types.Operator):
openingSpecs += [{'w': 0.5, 'h': 0.5, 'x': 0.0, 'z': 2.7, 'rp': 1,
'b': 0.0, 'v': 0, 'vl': 0, 't': 0, 'tl': 0}]
- wallW = self.properties.WallEnd - self.properties.WallStart
- crenelW = wallW * self.properties.CrenelXP # Width % opening.
+ wallW = self.WallEnd - self.WallStart
+ crenelW = wallW * self.CrenelXP # Width % opening.
- wallH = self.properties.WallTop - self.properties.WallBottom
- crenelH = wallH * self.properties.CrenelZP # % proportional height.
+ wallH = self.WallTop - self.WallBottom
+ crenelH = wallH * self.CrenelZP # % proportional height.
openingSpecs[openingIdx]['w'] = crenelW
openingSpecs[openingIdx]['h'] = crenelH
@@ -772,14 +847,17 @@ class add_mesh_wallb(bpy.types.Operator):
openingSpecs[openingIdx]['x'] = 0
openingSpecs[openingIdx]['rp'] = 0
# set bottom of opening (center of hole)
- openingSpecs[openingIdx]['z'] = self.properties.WallTop - (crenelH / 2)
+ openingSpecs[openingIdx]['z'] = self.WallTop - (crenelH / 2)
openingIdx += 1 # count crenel openings
# Process the user settings to generate a wall
# generate the list of vertices for the wall...
- verts_array, faces_array = createWall(radialized, slope, openingSpecs, bigBlock,
- shelfExt, shelfBack, stepMod, stepLeft, stepOnly, stepBack)
+ verts_array, faces_array = createWall(
+ radialized, slope, openingSpecs, bigBlock,
+ shelfExt, shelfBack, stepMod, stepLeft, stepOnly,
+ stepBack
+ )
# Create new mesh
mesh = bpy.data.meshes.new("Wall")
diff --git a/add_mesh_extra_objects/__init__.py b/add_mesh_extra_objects/__init__.py
index a4290b35..ecc023df 100644
--- a/add_mesh_extra_objects/__init__.py
+++ b/add_mesh_extra_objects/__init__.py
@@ -16,23 +16,28 @@
#
# ##### END GPL LICENSE BLOCK #####
# Contributed to by:
-# Pontiac, Fourmadmen, varkenvarken, tuga3d, meta-androcto, metalliandy #
-# dreampainter, cotejrp1, liero, Kayo Phoenix, sugiany, dommetysk #
-# Phymec, Anthony D'Agostino, Pablo Vazquez, Richard Wilks, lijenstina #
-# xyz presets by elfnor
+# Pontiac, Fourmadmen, varkenvarken, tuga3d, meta-androcto, metalliandy #
+# dreampainter, cotejrp1, liero, Kayo Phoenix, sugiany, dommetysk, Jambay #
+# Phymec, Anthony D'Agostino, Pablo Vazquez, Richard Wilks, lijenstina, #
+# Sjaak-de-Draak, Phil Cote, cotejrp1, xyz presets by elfnor, revolt_randy, #
+
bl_info = {
"name": "Extra Objects",
"author": "Multiple Authors",
- "version": (0, 3, 1),
+ "version": (0, 3, 2),
"blender": (2, 74, 5),
"location": "View3D > Add > Mesh",
"description": "Add extra mesh object types",
"warning": "",
- "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Add_Mesh/Add_Extra",
+ "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/"
+ "Py/Scripts/Add_Mesh/Add_Extra",
"category": "Add Mesh",
}
+# Note: Blocks has to be loaded before the WallFactory or the script
+# will not work properly after (F8) reload
+
if "bpy" in locals():
import importlib
importlib.reload(add_mesh_star)
@@ -54,8 +59,8 @@ if "bpy" in locals():
importlib.reload(add_empty_as_parent)
importlib.reload(mesh_discombobulator)
importlib.reload(add_mesh_beam_builder)
- importlib.reload(Wallfactory)
importlib.reload(Blocks)
+ importlib.reload(Wallfactory)
importlib.reload(add_shape_geodesic)
importlib.reload(forms_271)
importlib.reload(geodesic_classes_271)
@@ -82,8 +87,8 @@ else:
from . import add_empty_as_parent
from . import mesh_discombobulator
from . import add_mesh_beam_builder
- from . import Wallfactory
from . import Blocks
+ from . import Wallfactory
from . import add_mesh_triangles
from .geodesic_domes import add_shape_geodesic
@@ -164,7 +169,8 @@ class INFO_MT_mesh_math_add(Menu):
layout.operator("mesh.primitive_xyz_function_surface",
text="XYZ Math Surface")
self.layout.operator("mesh.primitive_solid_add", text="Regular Solid")
- self.layout.operator("mesh.make_triangle", icon = "MESH_DATA")
+ self.layout.operator("mesh.make_triangle", icon="MESH_DATA")
+
class INFO_MT_mesh_mech(Menu):
# Define the "Math Function" menu
@@ -248,97 +254,97 @@ class discombobulator_scene_props(bpy.types.PropertyGroup):
DISC_doodads = []
# Protusions Buttons:
repeatprot = IntProperty(
- name="Repeat protusions",
- description=("Make several layers of protusion \n"
- "Use carefully, runs recursively the discombulator"),
- default=1, min=1, max=4 # set to 4 because it's 2**n reqursive
- )
+ name="Repeat protusions",
+ description=("Make several layers of protusion \n"
+ "Use carefully, runs recursively the discombulator"),
+ default=1, min=1, max=4 # set to 4 because it's 2**n reqursive
+ )
doprots = BoolProperty(
- name="Make protusions",
- description="Check if we want to add protusions to the mesh",
- default=True
- )
+ name="Make protusions",
+ description="Check if we want to add protusions to the mesh",
+ default=True
+ )
subpolygon1 = BoolProperty(
- name="1",
- default=True
- )
+ name="1",
+ default=True
+ )
subpolygon2 = BoolProperty(
- name="2",
- default=True
- )
+ name="2",
+ default=True
+ )
subpolygon3 = BoolProperty(
- name="3",
- default=True
- )
+ name="3",
+ default=True
+ )
subpolygon4 = BoolProperty(
- name="4",
- default=True
- )
+ name="4",
+ default=True
+ )
polygonschangedpercent = FloatProperty(
- name="Polygon %",
- description="Percentage of changed polygons",
- default=1.0
- )
+ name="Polygon %",
+ description="Percentage of changed polygons",
+ default=1.0
+ )
minHeight = FloatProperty(
- name="Min height",
- description="Minimal height of the protusions",
- default=0.2
- )
+ name="Min height",
+ description="Minimal height of the protusions",
+ default=0.2
+ )
maxHeight = FloatProperty(
- name="Max height",
- description="Maximal height of the protusions",
- default=0.4
- )
+ name="Max height",
+ description="Maximal height of the protusions",
+ default=0.4
+ )
minTaper = FloatProperty(
- name="Min taper",
- description="Minimal height of the protusions",
- default=0.15, min=0.0, max=1.0,
- subtype='PERCENTAGE'
- )
+ name="Min taper",
+ description="Minimal height of the protusions",
+ default=0.15, min=0.0, max=1.0,
+ subtype='PERCENTAGE'
+ )
maxTaper = FloatProperty(
- name="Max taper",
- description="Maximal height of the protusions",
- default=0.35, min=0.0, max=1.0,
- subtype='PERCENTAGE'
- )
+ name="Max taper",
+ description="Maximal height of the protusions",
+ default=0.35, min=0.0, max=1.0,
+ subtype='PERCENTAGE'
+ )
# Doodads buttons:
dodoodads = BoolProperty(
- name="Make doodads",
- description="Check if we want to generate doodads",
- default=False
- )
+ name="Make doodads",
+ description="Check if we want to generate doodads",
+ default=False
+ )
mindoodads = IntProperty(
- name="Minimum doodads number",
- description="Ask for the minimum number of doodads to generate per polygon",
- default=1, min=0, max=50
- )
+ name="Minimum doodads number",
+ description="Ask for the minimum number of doodads to generate per polygon",
+ default=1, min=0, max=50
+ )
maxdoodads = IntProperty(
- name="Maximum doodads number",
- description="Ask for the maximum number of doodads to generate per polygon",
- default=6, min=1, max=50
- )
+ name="Maximum doodads number",
+ description="Ask for the maximum number of doodads to generate per polygon",
+ default=6, min=1, max=50
+ )
doodMinScale = FloatProperty(
- name="Scale min", description="Minimum scaling of doodad",
- default=0.5, min=0.0, max=1.0,
- subtype='PERCENTAGE'
- )
+ name="Scale min", description="Minimum scaling of doodad",
+ default=0.5, min=0.0, max=1.0,
+ subtype='PERCENTAGE'
+ )
doodMaxScale = FloatProperty(
- name="Scale max",
- description="Maximum scaling of doodad",
- default=1.0, min=0.0, max=1.0,
- subtype='PERCENTAGE'
- )
+ name="Scale max",
+ description="Maximum scaling of doodad",
+ default=1.0, min=0.0, max=1.0,
+ subtype='PERCENTAGE'
+ )
# Materials buttons:
sideProtMat = IntProperty(
- name="Side's prot mat",
- description="Material of protusion's sides",
- default=0, min=0
- )
+ name="Side's prot mat",
+ description="Material of protusion's sides",
+ default=0, min=0
+ )
topProtMat = IntProperty(
- name="Prot's top mat",
- description="Material of protusion's top",
- default=0, min=0
- )
+ name="Prot's top mat",
+ description="Material of protusion's top",
+ default=0, min=0
+ )
# Register all operators and panels
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")
diff --git a/add_mesh_extra_objects/add_mesh_gears.py b/add_mesh_extra_objects/add_mesh_gears.py
index 7dc201d9..7eede285 100644
--- a/add_mesh_extra_objects/add_mesh_gears.py
+++ b/add_mesh_extra_objects/add_mesh_gears.py
@@ -2,7 +2,11 @@
import bpy
from bpy.types import Operator
-from math import atan, asin, cos, sin, tan, pi, radians
+from math import (
+ atan, asin, cos,
+ sin, tan, pi,
+ radians,
+ )
from bpy.props import (
FloatProperty,
IntProperty,
@@ -551,64 +555,74 @@ class AddGear(Operator):
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
number_of_teeth = IntProperty(name="Number of Teeth",
- description="Number of teeth on the gear",
- min=2,
- max=265,
- default=12)
+ description="Number of teeth on the gear",
+ min=2,
+ max=265,
+ default=12
+ )
radius = FloatProperty(name="Radius",
- description="Radius of the gear, negative for crown gear",
- min=-100.0,
- max=100.0,
- unit='LENGTH',
- default=1.0)
+ description="Radius of the gear, negative for crown gear",
+ min=-100.0,
+ max=100.0,
+ unit='LENGTH',
+ default=1.0
+ )
addendum = FloatProperty(name="Addendum",
- description="Addendum, extent of tooth above radius",
- min=0.01,
- max=100.0,
- unit='LENGTH',
- default=0.1)
+ description="Addendum, extent of tooth above radius",
+ min=0.01,
+ max=100.0,
+ unit='LENGTH',
+ default=0.1
+ )
dedendum = FloatProperty(name="Dedendum",
- description="Dedendum, extent of tooth below radius",
- min=0.0,
- max=100.0,
- unit='LENGTH',
- default=0.1)
+ description="Dedendum, extent of tooth below radius",
+ min=0.0,
+ max=100.0,
+ unit='LENGTH',
+ default=0.1
+ )
angle = FloatProperty(name="Pressure Angle",
- description="Pressure angle, skewness of tooth tip",
- min=0.0,
- max=radians(45.0),
- unit='ROTATION',
- default=radians(20.0))
+ description="Pressure angle, skewness of tooth tip",
+ min=0.0,
+ max=radians(45.0),
+ unit='ROTATION',
+ default=radians(20.0)
+ )
base = FloatProperty(name="Base",
- description="Base, extent of gear below radius",
- min=0.0,
- max=100.0,
- unit='LENGTH',
- default=0.2)
+ description="Base, extent of gear below radius",
+ min=0.0,
+ max=100.0,
+ unit='LENGTH',
+ default=0.2
+ )
width = FloatProperty(name="Width",
- description="Width, thickness of gear",
- min=0.05,
- max=100.0,
- unit='LENGTH',
- default=0.2)
+ description="Width, thickness of gear",
+ min=0.05,
+ max=100.0,
+ unit='LENGTH',
+ default=0.2
+ )
skew = FloatProperty(name="Skewness",
- description="Skew of teeth",
- min=radians(-90.0),
- max=radians(90.0),
- unit='ROTATION',
- default=radians(0.0))
+ description="Skew of teeth",
+ min=radians(-90.0),
+ max=radians(90.0),
+ unit='ROTATION',
+ default=radians(0.0)
+ )
conangle = FloatProperty(name="Conical angle",
- description="Conical angle of gear",
- min=0.0,
- max=radians(90.0),
- unit='ROTATION',
- default=radians(0.0))
+ description="Conical angle of gear",
+ min=0.0,
+ max=radians(90.0),
+ unit='ROTATION',
+ default=radians(0.0)
+ )
crown = FloatProperty(name="Crown",
- description="Inward pointing extend of crown teeth",
- min=0.0,
- max=100.0,
- unit='LENGTH',
- default=0.0)
+ description="Inward pointing extend of crown teeth",
+ min=0.0,
+ max=100.0,
+ unit='LENGTH',
+ default=0.0
+ )
def draw(self, context):
layout = self.layout
@@ -668,75 +682,75 @@ class AddWormGear(Operator):
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
number_of_teeth = IntProperty(
- name="Number of Teeth",
- description="Number of teeth on the gear",
- min=2,
- max=265,
- default=12
- )
+ name="Number of Teeth",
+ description="Number of teeth on the gear",
+ min=2,
+ max=265,
+ default=12
+ )
number_of_rows = IntProperty(
- name="Number of Rows",
- description="Number of rows on the worm gear",
- min=2,
- max=265,
- default=32
- )
+ name="Number of Rows",
+ description="Number of rows on the worm gear",
+ min=2,
+ max=265,
+ default=32
+ )
radius = FloatProperty(
- name="Radius",
- description="Radius of the gear, negative for crown gear",
- min=-100.0,
- max=100.0,
- unit='LENGTH',
- default=1.0
- )
+ name="Radius",
+ description="Radius of the gear, negative for crown gear",
+ min=-100.0,
+ max=100.0,
+ unit='LENGTH',
+ default=1.0
+ )
addendum = FloatProperty(
- name="Addendum",
- description="Addendum, extent of tooth above radius",
- min=0.01,
- max=100.0,
- unit='LENGTH',
- default=0.1
- )
+ name="Addendum",
+ description="Addendum, extent of tooth above radius",
+ min=0.01,
+ max=100.0,
+ unit='LENGTH',
+ default=0.1
+ )
dedendum = FloatProperty(
- name="Dedendum",
- description="Dedendum, extent of tooth below radius",
- min=0.0,
- max=100.0,
- unit='LENGTH',
- default=0.1
- )
+ name="Dedendum",
+ description="Dedendum, extent of tooth below radius",
+ min=0.0,
+ max=100.0,
+ unit='LENGTH',
+ default=0.1
+ )
angle = FloatProperty(
- name="Pressure Angle",
- description="Pressure angle, skewness of tooth tip",
- min=0.0,
- max=radians(45.0),
- default=radians(20.0),
- unit='ROTATION'
- )
+ name="Pressure Angle",
+ description="Pressure angle, skewness of tooth tip",
+ min=0.0,
+ max=radians(45.0),
+ default=radians(20.0),
+ unit='ROTATION'
+ )
row_height = FloatProperty(
- name="Row Height",
- description="Height of each Row",
- min=0.05,
- max=100.0,
- unit='LENGTH',
- default=0.2
- )
+ name="Row Height",
+ description="Height of each Row",
+ min=0.05,
+ max=100.0,
+ unit='LENGTH',
+ default=0.2
+ )
skew = FloatProperty(
- name="Skewness per Row",
- description="Skew of each row",
- min=radians(-90.0),
- max=radians(90.0),
- default=radians(11.25),
- unit='ROTATION'
- )
+ name="Skewness per Row",
+ description="Skew of each row",
+ min=radians(-90.0),
+ max=radians(90.0),
+ default=radians(11.25),
+ unit='ROTATION'
+ )
crown = FloatProperty(
- name="Crown",
- description="Inward pointing extend of crown teeth",
- min=0.0,
- max=100.0,
- unit='LENGTH',
- default=0.0
- )
+ name="Crown",
+ description="Inward pointing extend of crown teeth",
+ min=0.0,
+ max=100.0,
+ unit='LENGTH',
+ default=0.0
+ )
def draw(self, context):
layout = self.layout
@@ -745,9 +759,11 @@ class AddWormGear(Operator):
box.prop(self, "number_of_rows")
box.prop(self, "radius")
box.prop(self, "row_height")
+
box = layout.box()
box.prop(self, "addendum")
box.prop(self, "dedendum")
+
box = layout.box()
box.prop(self, "angle")
box.prop(self, "skew")
diff --git a/add_mesh_extra_objects/add_mesh_gemstones.py b/add_mesh_extra_objects/add_mesh_gemstones.py
index f99bcd43..0da6b488 100644
--- a/add_mesh_extra_objects/add_mesh_gemstones.py
+++ b/add_mesh_extra_objects/add_mesh_gemstones.py
@@ -2,7 +2,10 @@
import bpy
from bpy.types import Operator
-from mathutils import Vector, Quaternion
+from mathutils import (
+ Vector,
+ Quaternion,
+ )
from math import cos, sin, pi
from bpy.props import (
FloatProperty,
@@ -209,40 +212,40 @@ class AddDiamond(Operator):
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
segments = IntProperty(
- name="Segments",
- description="Number of segments for the diamond",
- min=3,
- max=256,
- default=32
- )
+ name="Segments",
+ description="Number of segments for the diamond",
+ min=3,
+ max=256,
+ default=32
+ )
girdle_radius = FloatProperty(
- name="Girdle Radius",
- description="Girdle radius of the diamond",
- min=0.01,
- max=9999.0,
- default=1.0
- )
+ name="Girdle Radius",
+ description="Girdle radius of the diamond",
+ min=0.01,
+ max=9999.0,
+ default=1.0
+ )
table_radius = FloatProperty(
- name="Table Radius",
- description="Girdle radius of the diamond",
- min=0.01,
- max=9999.0,
- default=0.6
- )
+ name="Table Radius",
+ description="Girdle radius of the diamond",
+ min=0.01,
+ max=9999.0,
+ default=0.6
+ )
crown_height = FloatProperty(
- name="Crown Height",
- description="Crown height of the diamond",
- min=0.01,
- max=9999.0,
- default=0.35
- )
+ name="Crown Height",
+ description="Crown height of the diamond",
+ min=0.01,
+ max=9999.0,
+ default=0.35
+ )
pavilion_height = FloatProperty(
- name="Pavilion Height",
- description="Pavilion height of the diamond",
- min=0.01,
- max=9999.0,
- default=0.8
- )
+ name="Pavilion Height",
+ description="Pavilion height of the diamond",
+ min=0.01,
+ max=9999.0,
+ default=0.8
+ )
def execute(self, context):
verts, faces = add_diamond(self.segments,
@@ -263,40 +266,40 @@ class AddGem(Operator):
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
segments = IntProperty(
- name="Segments",
- description="Longitudial segmentation",
- min=3,
- max=265,
- default=8
- )
+ name="Segments",
+ description="Longitudial segmentation",
+ min=3,
+ max=265,
+ default=8
+ )
pavilion_radius = FloatProperty(
- name="Radius",
- description="Radius of the gem",
- min=0.01,
- max=9999.0,
- default=1.0
- )
+ name="Radius",
+ description="Radius of the gem",
+ min=0.01,
+ max=9999.0,
+ default=1.0
+ )
crown_radius = FloatProperty(
- name="Table Radius",
- description="Radius of the table(top)",
- min=0.01,
- max=9999.0,
- default=0.6
- )
+ name="Table Radius",
+ description="Radius of the table(top)",
+ min=0.01,
+ max=9999.0,
+ default=0.6
+ )
crown_height = FloatProperty(
- name="Table height",
- description="Height of the top half",
- min=0.01,
- max=9999.0,
- default=0.35
- )
+ name="Table height",
+ description="Height of the top half",
+ min=0.01,
+ max=9999.0,
+ default=0.35
+ )
pavilion_height = FloatProperty(
- name="Pavilion height",
- description="Height of bottom half",
- min=0.01,
- max=9999.0,
- default=0.8
- )
+ name="Pavilion height",
+ description="Height of bottom half",
+ min=0.01,
+ max=9999.0,
+ default=0.8
+ )
def execute(self, context):
# create mesh
diff --git a/add_mesh_extra_objects/add_mesh_honeycomb.py b/add_mesh_extra_objects/add_mesh_honeycomb.py
index e93b3b86..357be4cb 100644
--- a/add_mesh_extra_objects/add_mesh_honeycomb.py
+++ b/add_mesh_extra_objects/add_mesh_honeycomb.py
@@ -2,7 +2,10 @@
import bpy
from bpy_extras import object_utils
-from math import pi, sin, cos
+from math import (
+ pi, sin,
+ cos,
+ )
from bpy.props import (
IntProperty,
BoolProperty,
@@ -216,49 +219,48 @@ class add_mesh_honeycomb(bpy.types.Operator):
self.edge = m
rows = IntProperty(
- name="Num of rows",
- default=2,
- min=1, max=100,
- description='Number of the rows'
- )
-
+ name="Num of rows",
+ default=2,
+ min=1, max=100,
+ description='Number of the rows'
+ )
cols = IntProperty(
- name='Num of cols',
- default=2,
- min=1, max=100,
- description='Number of the columns'
- )
+ name='Num of cols',
+ default=2,
+ min=1, max=100,
+ description='Number of the columns'
+ )
layers = BoolVectorProperty(
- name="Layers",
- size=20,
- subtype='LAYER',
- options={'HIDDEN', 'SKIP_SAVE'},
- )
+ name="Layers",
+ size=20,
+ subtype='LAYER',
+ options={'HIDDEN', 'SKIP_SAVE'},
+ )
diam = FloatProperty(
- name='Cell Diameter',
- default=1.0,
- min=0.0, update=fix_edge,
- description='Diameter of the cell'
- )
+ name='Cell Diameter',
+ default=1.0,
+ min=0.0, update=fix_edge,
+ description='Diameter of the cell'
+ )
edge = FloatProperty(
- name='Edge Width',
- default=0.1,
- min=0.0, update=fix_edge,
- description='Width of the edge'
- )
+ name='Edge Width',
+ default=0.1,
+ min=0.0, update=fix_edge,
+ description='Width of the edge'
+ )
# generic transform props
view_align = BoolProperty(
- name="Align to View",
- default=False
- )
+ name="Align to View",
+ default=False
+ )
location = FloatVectorProperty(
- name="Location",
- subtype='TRANSLATION'
- )
+ name="Location",
+ subtype='TRANSLATION'
+ )
rotation = FloatVectorProperty(
- name="Rotation",
- subtype='EULER'
- )
+ name="Rotation",
+ subtype='EULER'
+ )
@classmethod
def poll(cls, context):
diff --git a/add_mesh_extra_objects/add_mesh_menger_sponge.py b/add_mesh_extra_objects/add_mesh_menger_sponge.py
index 3f9ec241..088860d7 100644
--- a/add_mesh_extra_objects/add_mesh_menger_sponge.py
+++ b/add_mesh_extra_objects/add_mesh_menger_sponge.py
@@ -145,36 +145,36 @@ class AddMengerSponge(bpy.types.Operator):
bl_options = {'REGISTER', 'UNDO'}
level = IntProperty(
- name="Level",
- description="Sponge Level",
- min=0, max=4,
- default=1,
- )
+ name="Level",
+ description="Sponge Level",
+ min=0, max=4,
+ default=1,
+ )
radius = FloatProperty(
- name="Width",
- description="Sponge Radius",
- min=0.01, max=100.0,
- default=1.0,
- )
+ name="Width",
+ description="Sponge Radius",
+ min=0.01, max=100.0,
+ default=1.0,
+ )
# generic transform props
view_align = BoolProperty(
- name="Align to View",
- default=False,
- )
+ name="Align to View",
+ default=False,
+ )
location = FloatVectorProperty(
- name="Location",
- subtype='TRANSLATION',
- )
+ name="Location",
+ subtype='TRANSLATION',
+ )
rotation = FloatVectorProperty(
- name="Rotation",
- subtype='EULER',
- )
+ name="Rotation",
+ subtype='EULER',
+ )
layers = BoolVectorProperty(
- name="Layers",
- size=20,
- subtype='LAYER',
- options={'HIDDEN', 'SKIP_SAVE'},
- )
+ name="Layers",
+ size=20,
+ subtype='LAYER',
+ options={'HIDDEN', 'SKIP_SAVE'},
+ )
def execute(self, context):
sponger = MengerSponge(self.level)
diff --git a/add_mesh_extra_objects/add_mesh_pyramid.py b/add_mesh_extra_objects/add_mesh_pyramid.py
index 5c054c9f..680267cb 100644
--- a/add_mesh_extra_objects/add_mesh_pyramid.py
+++ b/add_mesh_extra_objects/add_mesh_pyramid.py
@@ -2,35 +2,43 @@
import bpy
import bmesh
+from bpy.types import Operator
from bpy.props import (
FloatProperty,
IntProperty,
)
from math import pi
-from mathutils import Quaternion, Vector
-from bpy_extras.object_utils import AddObjectHelper, object_data_add
+from mathutils import (
+ Quaternion,
+ Vector,
+ )
+from bpy_extras.object_utils import (
+ AddObjectHelper,
+ object_data_add,
+ )
def create_step(width, base_level, step_height, num_sides):
- axis = [0, 0, -1]
- PI2 = pi * 2
- rad = width / 2
+ axis = [0, 0, -1]
+ PI2 = pi * 2
+ rad = width / 2
+
+ quat_angles = [(cur_side / num_sides) * PI2
+ for cur_side in range(num_sides)]
- quat_angles = [(cur_side / num_sides) * PI2
- for cur_side in range(num_sides)]
+ quaternions = [Quaternion(axis, quat_angle)
+ for quat_angle in quat_angles]
- quaternions = [Quaternion(axis, quat_angle)
- for quat_angle in quat_angles]
+ init_vectors = [Vector([rad, 0, base_level])] * len(quaternions)
- init_vectors = [Vector([rad, 0, base_level])] * len(quaternions)
+ quat_vector_pairs = list(zip(quaternions, init_vectors))
+ vectors = [quaternion * vec for quaternion, vec in quat_vector_pairs]
+ bottom_list = [(vec.x, vec.y, vec.z) for vec in vectors]
+ top_list = [(vec.x, vec.y, vec.z + step_height) for vec in vectors]
+ full_list = bottom_list + top_list
- quat_vector_pairs = list(zip(quaternions, init_vectors))
- vectors = [quaternion * vec for quaternion, vec in quat_vector_pairs]
- bottom_list = [(vec.x, vec.y, vec.z) for vec in vectors]
- top_list = [(vec.x, vec.y, vec.z + step_height) for vec in vectors]
- full_list = bottom_list + top_list
- return full_list
+ return full_list
def split_list(l, n):
@@ -52,83 +60,83 @@ def get_connector_pairs(lst, n_sides):
def add_pyramid_object(self, context):
- all_verts = []
+ all_verts = []
- height_offset = 0
- cur_width = self.width
+ height_offset = 0
+ cur_width = self.width
- for i in range(self.num_steps):
- verts_loc = create_step(cur_width, height_offset, self.height,
- self.num_sides)
- height_offset += self.height
- cur_width -= self.reduce_by
- all_verts.extend(verts_loc)
+ for i in range(self.num_steps):
+ verts_loc = create_step(cur_width, height_offset, self.height,
+ self.num_sides)
+ height_offset += self.height
+ cur_width -= self.reduce_by
+ all_verts.extend(verts_loc)
- mesh = bpy.data.meshes.new("Pyramid")
- bm = bmesh.new()
+ mesh = bpy.data.meshes.new("Pyramid")
+ bm = bmesh.new()
- for v_co in all_verts:
- bm.verts.new(v_co)
+ for v_co in all_verts:
+ bm.verts.new(v_co)
- def add_faces(n, block_vert_sets):
- for bvs in block_vert_sets:
- for i in range(self.num_sides - 1):
- bm.faces.new([bvs[i], bvs[i + n], bvs[i + n + 1], bvs[i + 1]])
- bm.faces.new([bvs[n - 1], bvs[(n * 2) - 1], bvs[n], bvs[0]])
+ def add_faces(n, block_vert_sets):
+ for bvs in block_vert_sets:
+ for i in range(self.num_sides - 1):
+ bm.faces.new([bvs[i], bvs[i + n], bvs[i + n + 1], bvs[i + 1]])
+ bm.faces.new([bvs[n - 1], bvs[(n * 2) - 1], bvs[n], bvs[0]])
- # get the base and cap faces done.
- bm.faces.new(bm.verts[0:self.num_sides])
- bm.faces.new(reversed(bm.verts[-self.num_sides:])) # otherwise normal faces intern... T44619.
+ # get the base and cap faces done.
+ bm.faces.new(bm.verts[0:self.num_sides])
+ bm.faces.new(reversed(bm.verts[-self.num_sides:])) # otherwise normal faces intern... T44619.
- # side faces
- block_vert_sets = split_list(bm.verts, self.num_sides)
- add_faces(self.num_sides, block_vert_sets)
+ # side faces
+ block_vert_sets = split_list(bm.verts, self.num_sides)
+ add_faces(self.num_sides, block_vert_sets)
- # connector faces between faces and faces of the block above it.
- connector_pairs = get_connector_pairs(bm.verts, self.num_sides)
- add_faces(self.num_sides, connector_pairs)
+ # connector faces between faces and faces of the block above it.
+ connector_pairs = get_connector_pairs(bm.verts, self.num_sides)
+ add_faces(self.num_sides, connector_pairs)
- bm.to_mesh(mesh)
- mesh.update()
- res = object_data_add(context, mesh, operator=self)
+ bm.to_mesh(mesh)
+ mesh.update()
+ res = object_data_add(context, mesh, operator=self)
-class AddPyramid(bpy.types.Operator, AddObjectHelper):
+class AddPyramid(Operator, AddObjectHelper):
bl_idname = "mesh.primitive_steppyramid_add"
bl_label = "Pyramid"
bl_description = "Construct a step pyramid mesh"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
num_sides = IntProperty(
- name="Number Sides",
- description="How many sides each step will have",
- min=3, max=20,
- default=4
- )
+ name="Number Sides",
+ description="How many sides each step will have",
+ min=3, max=20,
+ default=4
+ )
num_steps = IntProperty(
- name="Number of Steps",
- description="How many steps for the overall pyramid",
- min=1, max=20,
- default=10
- )
+ name="Number of Steps",
+ description="How many steps for the overall pyramid",
+ min=1, max=20,
+ default=10
+ )
width = FloatProperty(
- name="Initial Width",
- description="Initial base step width",
- min=0.01, max=100.0,
- default=2
- )
+ name="Initial Width",
+ description="Initial base step width",
+ min=0.01, max=100.0,
+ default=2
+ )
height = FloatProperty(
- name="Height",
- description="How tall each step will be",
- min=0.01, max=100.0,
- default=0.1
- )
+ name="Height",
+ description="How tall each step will be",
+ min=0.01, max=100.0,
+ default=0.1
+ )
reduce_by = FloatProperty(
- name="Reduce Step By",
- description="How much to reduce each succeeding step by",
- min=.01, max=2.0,
- default=.20
- )
+ name="Reduce Step By",
+ description="How much to reduce each succeeding step by",
+ min=.01, max=2.0,
+ default=.20
+ )
def execute(self, context):
add_pyramid_object(self, context)
diff --git a/add_mesh_extra_objects/add_mesh_round_brilliant.py b/add_mesh_extra_objects/add_mesh_round_brilliant.py
index 537099b7..850421d8 100644
--- a/add_mesh_extra_objects/add_mesh_round_brilliant.py
+++ b/add_mesh_extra_objects/add_mesh_round_brilliant.py
@@ -1,9 +1,15 @@
# GPL "author": "Dominic Kröper, (dommetysk)"
import bpy
-from math import pi, sin, cos, tan
+from math import (
+ pi, sin,
+ cos, tan,
+ )
from bpy.types import Operator
-from mathutils import Vector, Euler
+from mathutils import (
+ Vector,
+ Euler,
+ )
from bpy.props import (
IntProperty,
FloatProperty,
@@ -34,7 +40,7 @@ def addBrilliant(context, s, table_w, crown_h, girdle_t, pavi_d, bezel_f,
s = s - 1
if not girdle_real:
g_real_smooth = False
- ang = 2 * pi / s # angle step size
+ ang = 2 * pi / s # angle step size
Verts = [] # collect all vertices
Faces = [] # collect all faces
ca = cos(ang)
@@ -300,85 +306,85 @@ class MESH_OT_primitive_brilliant_add(Operator):
# set user options
s = IntProperty(
- name="Segments",
- description="Longitudial segmentation",
- step=1,
- min=6,
- max=128,
- default=16,
- subtype='FACTOR'
- )
+ name="Segments",
+ description="Longitudial segmentation",
+ step=1,
+ min=6,
+ max=128,
+ default=16,
+ subtype='FACTOR'
+ )
table_w = FloatProperty(
- name="Table width",
- description="Width of table",
- min=0.001,
- max=1.0,
- default=0.53,
- subtype='PERCENTAGE'
- )
+ name="Table width",
+ description="Width of table",
+ min=0.001,
+ max=1.0,
+ default=0.53,
+ subtype='PERCENTAGE'
+ )
crown_h = FloatProperty(
- name="Crown height",
- description="Heigth of crown",
- min=0.0,
- max=1.0,
- default=0.162,
- subtype='PERCENTAGE'
- )
+ name="Crown height",
+ description="Heigth of crown",
+ min=0.0,
+ max=1.0,
+ default=0.162,
+ subtype='PERCENTAGE'
+ )
girdle_t = FloatProperty(
- name="Girdle height",
- description="Height of girdle",
- min=0.0,
- max=0.5,
- default=0.017,
- subtype='PERCENTAGE'
- )
+ name="Girdle height",
+ description="Height of girdle",
+ min=0.0,
+ max=0.5,
+ default=0.017,
+ subtype='PERCENTAGE'
+ )
girdle_real = BoolProperty(
- name="Real girdle",
- description="More beautiful girdle; has more polygons",
- default=True
- )
+ name="Real girdle",
+ description="More beautiful girdle; has more polygons",
+ default=True
+ )
g_real_smooth = BoolProperty(
- name="Smooth girdle",
- description="smooth shading for girdle, only available for real girdle",
- default=False
- )
+ name="Smooth girdle",
+ description="smooth shading for girdle, only available for real girdle",
+ default=False
+ )
pavi_d = FloatProperty(
- name="Pavilion depth",
- description="Height of pavillion",
- min=0.0,
- max=1.0,
- default=0.431,
- subtype='PERCENTAGE'
- )
+ name="Pavilion depth",
+ description="Height of pavillion",
+ min=0.0,
+ max=1.0,
+ default=0.431,
+ subtype='PERCENTAGE'
+ )
bezel_f = FloatProperty(
- name="Upper facet factor",
- description="Determines the form of bezel and upper girdle facets",
- min=0.0,
- max=1.0,
- default=0.250,
- subtype='PERCENTAGE'
- )
+ name="Upper facet factor",
+ description="Determines the form of bezel and upper girdle facets",
+ min=0.0,
+ max=1.0,
+ default=0.250,
+ subtype='PERCENTAGE'
+ )
pavi_f = FloatProperty(
- name="Lower facet factor",
- description="Determines the form of pavillion and lower girdle facets",
- min=0.001,
- max=1.0,
- default=0.400,
- subtype='PERCENTAGE'
- )
+ name="Lower facet factor",
+ description="Determines the form of pavillion and lower girdle facets",
+ min=0.001,
+ max=1.0,
+ default=0.400,
+ subtype='PERCENTAGE'
+ )
culet = FloatProperty(
- name="Culet size",
- description="0: no culet (default)",
- min=0.0,
- max=0.999,
- default=0.0,
- subtype='PERCENTAGE'
- )
+ name="Culet size",
+ description="0: no culet (default)",
+ min=0.0,
+ max=0.999,
+ default=0.0,
+ subtype='PERCENTAGE'
+ )
keep_lga = BoolProperty(
- name="Retain lower angle",
- description="If culet > 0, retains angle of pavillion facets",
- default=False
- )
+ name="Retain lower angle",
+ description="If culet > 0, retains angle of pavillion facets",
+ default=False
+ )
# call mesh/object generator function with user inputs
def execute(self, context):
diff --git a/add_mesh_extra_objects/add_mesh_round_cube.py b/add_mesh_extra_objects/add_mesh_round_cube.py
index b56ac3d3..dca438ae 100644
--- a/add_mesh_extra_objects/add_mesh_round_cube.py
+++ b/add_mesh_extra_objects/add_mesh_round_cube.py
@@ -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)
-
diff --git a/add_mesh_extra_objects/add_mesh_star.py b/add_mesh_extra_objects/add_mesh_star.py
index ae63f2c6..b7e420fe 100644
--- a/add_mesh_extra_objects/add_mesh_star.py
+++ b/add_mesh_extra_objects/add_mesh_star.py
@@ -1,7 +1,10 @@
# GPL Original by Fourmadmen
import bpy
-from mathutils import Vector, Quaternion
+from mathutils import (
+ Vector,
+ Quaternion,
+ )
from math import pi
from bpy.props import (
IntProperty,
diff --git a/add_mesh_extra_objects/add_mesh_teapot.py b/add_mesh_extra_objects/add_mesh_teapot.py
index 27e7f703..23dd084f 100644
--- a/add_mesh_extra_objects/add_mesh_teapot.py
+++ b/add_mesh_extra_objects/add_mesh_teapot.py
@@ -5,9 +5,7 @@ from bpy.props import (
IntProperty,
EnumProperty,
)
-
import mathutils
-
import io
import operator
import functools
@@ -111,10 +109,19 @@ def patches_to_raw(patches, resolution):
def make_bezier(ctrlpnts, resolution):
- b1 = lambda t: t * t * t
- b2 = lambda t: 3.0 * t * t * (1.0 - t)
- b3 = lambda t: 3.0 * t * (1.0 - t) * (1.0 - t)
- b4 = lambda t: (1.0 - t) * (1.0 - t) * (1.0 - t)
+
+ def b1(t):
+ return t * t * t
+
+ def b2(t):
+ return 3.0 * t * t * (1.0 - t)
+
+ def b3(t):
+ return 3.0 * t * (1.0 - t) * (1.0 - t)
+
+ def b4(t):
+ return (1.0 - t) * (1.0 - t) * (1.0 - t)
+
p1, p2, p3, p4 = map(mathutils.Vector, ctrlpnts)
def makevert(t):
diff --git a/add_mesh_extra_objects/add_mesh_triangles.py b/add_mesh_extra_objects/add_mesh_triangles.py
index c1a57469..f5768c0a 100644
--- a/add_mesh_extra_objects/add_mesh_triangles.py
+++ b/add_mesh_extra_objects/add_mesh_triangles.py
@@ -1,15 +1,15 @@
+# GPL # "author": Sjaak-de-Draak
+
bl_info = {
"name": "Triangles",
- "description": "Create different types of tirangles.",
+ "description": "Create different types of triangles",
"author": "Sjaak-de-Draak",
- "version": (1, 0),
+ "version": (1, 0, 1),
"blender": (2, 68, 0),
"location": "View3D > Add > Mesh",
- "warning": "First Version", # used for warning icon and text in addons panel
- "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+ "warning": "First Version",
+ "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
"Scripts/Triangles",
- "tracker_url": "http://projects.blender.org/tracker/index.php?"
- "func=detail&aid=<number>",
"category": "Add Mesh"}
"""
@@ -19,202 +19,219 @@ and a toolbar menu to further specify settings
import math
import bpy
-import mathutils
-import types
+from mathutils import Vector
+from bpy.types import Operator
+from bpy.props import (
+ BoolProperty,
+ EnumProperty,
+ FloatProperty,
+ )
-# make the mathutils Vector type accessible as Vector
-Vector=mathutils.Vector
def checkEditMode():
- ## Check if we are in edit mode
- ## Returns: 1 if True
- ## 0 if False
+ # Check if we are in edit mode
+ # Returns: 1 if True
+ # 0 if False
if (bpy.context.active_object.mode == 'EDIT'):
- return 1;
- return 0;
+ return 1
+ return 0
+
def exitEditMode():
- ## Check if we are in edit mode (cuz we don't want this when creating a new Mesh)
- ## If we are then toggle back to object mode
+ # Check if we are in edit mode (cuz we don't want this when creating a new Mesh)
+ # If we are then toggle back to object mode
# Check if there are active objects
- if (bpy.context.active_object != None ):
- # Only the active object should be in edit mode
+ if bpy.context.active_object is not None:
+ # Only the active object should be in edit mode
if (bpy.context.active_object.mode == 'EDIT'):
bpy.ops.object.editmode_toggle()
-class MakeTriangle(bpy.types.Operator):
+
+class MakeTriangle(Operator):
bl_idname = "mesh.make_triangle"
bl_label = "Triangle"
+ bl_description = "Construct different types of Triangle Meshes"
bl_options = {"REGISTER", "UNDO"}
- nothing=0
+ nothing = 0
Ya = 0.0
Xb = 0.0
Xc = 0.0
- Vertices = [ ]
- Faces = [ ]
+ Vertices = []
+ Faces = []
- triangleTypeList = [('ISOSCELES', "Isosceles", "Two equal sides", 0),
+ triangleTypeList = [
+ ('ISOSCELES', "Isosceles", "Two equal sides", 0),
('EQUILATERAL', "Equilateral", "Three equal sides and angles (60°)", 1),
('ISOSCELESRIGHTANGLE', "Isosceles right angled", "90° angle and two equal sides", 2),
- ('SCALENERIGHTANGLE', "Scalene right angled", "90° angle, no equal sides", 3)]
-
- triangleFaceList = [('DEFAULT', "Normal", "1 Tri(angle) face", 0),
+ ('SCALENERIGHTANGLE', "Scalene right angled", "90° angle, no equal sides", 3)
+ ]
+ triangleFaceList = [
+ ('DEFAULT', "Normal", "1 Tri(angle) face", 0),
('TRIANGLES', "3 Tri faces", "4 Verticies & 3 Tri(angle) faces", 1),
('QUADS', "3 Quad faces", "7 Verticies & 3 Quad faces", 2),
- ('SAFEQUADS', "6 Quad faces", "12 Verticies & 6 Quad faces", 3)]
+ ('SAFEQUADS', "6 Quad faces", "12 Verticies & 6 Quad faces", 3)
+ ]
# add definitions for some manipulation buttons
- flipX = bpy.props.BoolProperty(name="Flip X sign",
- description="Draw on the other side of the X axis (Mirror on Y axis)",
- default = False)
- flipY = bpy.props.BoolProperty(name="Flip Y sign",
- description="Draw on the other side of the Y axis (Mirror on X axis)",
- default = False)
- scale = bpy.props.FloatProperty(name="Scale",
- description="Triangle scale",
- default=1.0, min=1.0)
- triangleType = bpy.props.EnumProperty(items=triangleTypeList,
- name="Type",
- description="Triangle Type")
- triangleFace = bpy.props.EnumProperty(items=triangleFaceList,
- name="Face types",
- description="Triangle Face Types")
- at_3Dcursor = bpy.props.BoolProperty(name="At 3D Cursor",
- description="Draw the triangle where the 3D cursor is",
- default = False)
-
+ flipX = BoolProperty(
+ name="Flip X sign",
+ description="Draw on the other side of the X axis (Mirror on Y axis)",
+ default=False
+ )
+ flipY = BoolProperty(
+ name="Flip Y sign",
+ description="Draw on the other side of the Y axis (Mirror on X axis)",
+ default=False
+ )
+ scale = FloatProperty(
+ name="Scale",
+ description="Triangle scale",
+ default=1.0,
+ min=1.0
+ )
+ triangleType = EnumProperty(
+ items=triangleTypeList,
+ name="Type",
+ description="Triangle Type"
+ )
+ triangleFace = EnumProperty(
+ items=triangleFaceList,
+ name="Face types",
+ description="Triangle Face Types"
+ )
+ at_3Dcursor = BoolProperty(
+ name="Use 3D Cursor",
+ description="Draw the triangle where the 3D cursor is",
+ default=False
+ )
def draw(self, context):
layout = self.layout
- row = layout.row(align=True)
- row.label(text="Type: ")
-
- row.prop(self, "triangleType", text="")
-
- row = layout.row(align=True)
- row.prop(self, "at_3Dcursor", text="3D Cursor")
- row.prop(self, "scale")
-
- row = layout.row(align=True)
- row.label(text="Face Type: ")
- row.prop(self, "triangleFace", text="")
+ col = layout.column(align=True)
+ col.prop(self, "triangleType", text="Type")
+ col.prop(self, "scale")
+ col.prop(self, "triangleFace", text="Face")
col = layout.column(align=True)
- col.prop(self, "flipX")
- col.prop(self, "flipY")
- #end draw
+ col.prop(self, "at_3Dcursor", text="3D Cursor", toggle=True)
+
+ row = col.row(align=True)
+ row.prop(self, "flipX", toggle=True)
+ row.prop(self, "flipY", toggle=True)
def drawBasicTriangleShape(self):
# set everything to 0
- X = Xa = Xb = Xc = 0.0
- Y = Ya = Yb = Yc = 0.0
- Z = Za = Zb = Zc = 0.0
+ Xb = Xc = 0.0
+ Ya = 0.0
- scale=self.scale
+ scale = self.scale
Xsign = -1 if self.flipX else 1
Ysign = -1 if self.flipY else 1
# Isosceles (2 equal sides)
- if ( self.triangleType == 'ISOSCELES' ):
+ if (self.triangleType == 'ISOSCELES'):
# below a simple triangle containing 2 triangles with 1:2 side ratio
- Ya=(1 * Ysign * scale)
- A=Vector([0.0, Ya, 0.0])
- Xb=(0.5 * Xsign * scale)
- B=Vector([Xb, 0.0, 0.0])
- Xc=(-0.5 * Xsign * scale)
- C=Vector([Xc, 0.0, 0.0])
-
- self.Ya=Ya
- self.Xb=Xb
- self.Xc=Xc
- self.Vertices = [A, B, C,]
+ Ya = (1 * Ysign * scale)
+ A = Vector([0.0, Ya, 0.0])
+ Xb = (0.5 * Xsign * scale)
+ B = Vector([Xb, 0.0, 0.0])
+ Xc = (-0.5 * Xsign * scale)
+ C = Vector([Xc, 0.0, 0.0])
+
+ self.Ya = Ya
+ self.Xb = Xb
+ self.Xc = Xc
+ self.Vertices = [A, B, C, ]
+
return True
# Equilateral (all sides equal)
- if ( self.triangleType == 'EQUILATERAL' ):
- Ya=(math.sqrt(0.75) * Ysign * scale)
- A=Vector([0.0, Ya, 0.0])
- Xb=(0.5 * Xsign * scale)
- B=Vector([Xb, 0.0, 0.0])
- Xc=(-0.5 * Xsign * scale)
- C=Vector([Xc, 0.0, 0.0])
-
- self.Ya=Ya
- self.Xb=Xb
- self.Xc=Xc
- self.Vertices = [A, B, C,]
+ if (self.triangleType == 'EQUILATERAL'):
+ Ya = (math.sqrt(0.75) * Ysign * scale)
+ A = Vector([0.0, Ya, 0.0])
+ Xb = (0.5 * Xsign * scale)
+ B = Vector([Xb, 0.0, 0.0])
+ Xc = (-0.5 * Xsign * scale)
+ C = Vector([Xc, 0.0, 0.0])
+
+ self.Ya = Ya
+ self.Xb = Xb
+ self.Xc = Xc
+ self.Vertices = [A, B, C, ]
+
return True
- # Isosceles right angled ( 1, 1, sqrt(2) )
- if ( self.triangleType == 'ISOSCELESRIGHTANGLE' ):
- Ya=(1 * Ysign * scale)
- A=Vector([0.0, Ya, 0.0])
- Xb=0.0
- B=Vector([Xb, 0.0, 0.0])
- Xc=(1 * Xsign * scale)
- C=Vector([Xc, 0.0, 0.0])
-
- self.Ya=Ya
- self.Xb=Xb
- self.Xc=Xc
- self.Vertices = [A, B, C,]
+ # Isosceles right angled (1, 1, sqrt(2))
+ if (self.triangleType == 'ISOSCELESRIGHTANGLE'):
+ Ya = (1 * Ysign * scale)
+ A = Vector([0.0, Ya, 0.0])
+ Xb = 0.0
+ B = Vector([Xb, 0.0, 0.0])
+ Xc = (1 * Xsign * scale)
+ C = Vector([Xc, 0.0, 0.0])
+
+ self.Ya = Ya
+ self.Xb = Xb
+ self.Xc = Xc
+ self.Vertices = [A, B, C, ]
return True
- # Scalene right angled ( 3, 4, 5 )
- if ( self.triangleType == 'SCALENERIGHTANGLE' ):
- Ya=(1 * Ysign * scale)
- A=Vector([0.0, Ya, 0.0])
- Xb=0
- B=Vector([Xb, 0.0, 0.0])
- Xc=(0.75 * Xsign * scale)
- C=Vector([Xc, 0.0, 0.0])
-
- self.Ya=Ya
- self.Xb=Xb
- self.Xc=Xc
- self.Vertices = [A, B, C,]
+ # Scalene right angled (3, 4, 5)
+ if (self.triangleType == 'SCALENERIGHTANGLE'):
+ Ya = (1 * Ysign * scale)
+ A = Vector([0.0, Ya, 0.0])
+ Xb = 0
+ B = Vector([Xb, 0.0, 0.0])
+ Xc = (0.75 * Xsign * scale)
+ C = Vector([Xc, 0.0, 0.0])
+
+ self.Ya = Ya
+ self.Xb = Xb
+ self.Xc = Xc
+ self.Vertices = [A, B, C, ]
return True
+
return False
def addFaces(self, fType=None):
- Ya=self.Ya
- Xb=self.Xb
- Xc=self.Xc
+ Ya = self.Ya
+ Xb = self.Xb
+ Xc = self.Xc
if (self.triangleFace == 'DEFAULT'):
- self.Faces=[[0,1,2]]
+ self.Faces = [[0, 1, 2]]
return True
if (self.triangleFace == 'TRIANGLES'):
- A=Vector([0.0, Ya, 0.0])
- B=Vector([Xb, 0.0, 0.0])
- C=Vector([Xc, 0.0, 0.0])
- D=Vector([((A.x + B.x + C.x) /3), ((A.y + B.y + C.y) /3), ((A.z + B.z + C.z) /3)])
+ A = Vector([0.0, Ya, 0.0])
+ B = Vector([Xb, 0.0, 0.0])
+ C = Vector([Xc, 0.0, 0.0])
+ D = Vector([((A.x + B.x + C.x) / 3), ((A.y + B.y + C.y) / 3), ((A.z + B.z + C.z) / 3)])
- self.Vertices = [A, B, C, D,]
- self.Faces=[[0,1,3], [1,2,3], [2,0,3]]
+ self.Vertices = [A, B, C, D, ]
+ self.Faces = [[0, 1, 3], [1, 2, 3], [2, 0, 3]]
return True
if (self.triangleFace == 'QUADS'):
- A=Vector([0.0, Ya, 0.0])
- B=Vector([Xb, 0.0, 0.0])
- C=Vector([Xc, 0.0, 0.0])
- D=Vector([((A.x + B.x + C.x) /3), ((A.y + B.y + C.y) /3), ((A.z + B.z + C.z) /3)])
+ A = Vector([0.0, Ya, 0.0])
+ B = Vector([Xb, 0.0, 0.0])
+ C = Vector([Xc, 0.0, 0.0])
+ D = Vector([((A.x + B.x + C.x) / 3), ((A.y + B.y + C.y) / 3), ((A.z + B.z + C.z) / 3)])
AB = A.lerp(B, 0.5)
AC = A.lerp(C, 0.5)
BC = B.lerp(C, 0.5)
- self.Vertices = [A, AB, B, BC, C, AC, D,]
- self.Faces=[[0,1,6,5], [1,2,3,6], [3,4,5,6]]
+ self.Vertices = [A, AB, B, BC, C, AC, D, ]
+ self.Faces = [[0, 1, 6, 5], [1, 2, 3, 6], [3, 4, 5, 6]]
return True
if (self.triangleFace == 'SAFEQUADS'):
- A=Vector([0.0, Ya, 0.0])
- B=Vector([Xb, 0.0, 0.0])
- C=Vector([Xc, 0.0, 0.0])
- D=Vector([((A.x + B.x + C.x) /3), ((A.y + B.y + C.y) /3), ((A.z + B.z + C.z) /3)])
+ A = Vector([0.0, Ya, 0.0])
+ B = Vector([Xb, 0.0, 0.0])
+ C = Vector([Xc, 0.0, 0.0])
+ D = Vector([((A.x + B.x + C.x) / 3), ((A.y + B.y + C.y) / 3), ((A.z + B.z + C.z) / 3)])
E = A.lerp(D, 0.5)
AB = A.lerp(B, 0.5)
AC = A.lerp(C, 0.5)
@@ -226,31 +243,33 @@ class MakeTriangle(bpy.types.Operator):
BCC = BC.lerp(C, 0.5)
CCA = AC.lerp(C, 0.5)
- self.Vertices = [A, AAB, BBA, B, BBC, BC, BCC, C, CCA, AAC, D, E,]
- self.Faces=[[0,1,11,9], [1,2,10,11], [2,3,4,10], [4,5,6,10], [6,7,8,10], [8,9,11,10]]
+ self.Vertices = [A, AAB, BBA, B, BBC, BC, BCC, C, CCA, AAC, D, E, ]
+ self.Faces = [[0, 1, 11, 9], [1, 2, 10, 11], [2, 3, 4, 10],
+ [4, 5, 6, 10], [6, 7, 8, 10], [8, 9, 11, 10]]
return True
- return False
+ return False
def action_common(self, context):
# definitions:
- # a triangle consists of 3 points: A, B, C
- # a 'safer' subdividable triangle consists of 4 points: A, B, C, D
- # a subdivide friendly triangle consists of 7 points: A, B, C, D, AB, AC, BC
- # a truely subdivide friendly triangle consists of (3x4=)12 points: A, B, C, D, E, BC, AAB, AAC, BBA, BBC, BCC, CCA
+ # a triangle consists of 3 points: A, B, C
+ # a 'safer' subdividable triangle consists of 4 points: A, B, C, D
+ # a subdivide friendly triangle consists of 7 points: A, B, C, D, AB, AC, BC
+ # a truely subdivide friendly triangle consists of (3 x 4 = )12 points:
+ # A, B, C, D, E, BC, AAB, AAC, BBA, BBC, BCC, CCA
- BasicShapeCreated=False
- ShapeFacesCreated=False
- go=0
+ BasicShapeCreated = False
+ ShapeFacesCreated = False
+ go = 0
#
# call the functions for creating the triangles and test if successfull
#
- BasicShapeCreated=self.drawBasicTriangleShape()
+ BasicShapeCreated = self.drawBasicTriangleShape()
if (BasicShapeCreated):
- ShapeFacesCreated=self.addFaces()
- if (ShapeFacesCreated):
- go=1
+ ShapeFacesCreated = self.addFaces()
+ if ShapeFacesCreated:
+ go = 1
if (go == 1):
NewMesh = bpy.data.meshes.new("Triangle")
@@ -262,38 +281,37 @@ class MakeTriangle(bpy.types.Operator):
# before doing the deselect make sure edit mode isn't active
exitEditMode()
- bpy.ops.object.select_all(action = "DESELECT")
+ bpy.ops.object.select_all(action="DESELECT")
NewObj.select = True
context.scene.objects.active = NewObj
- if (self.at_3Dcursor == True):
+
+ if self.at_3Dcursor is True:
# we'll need to be sure there is actually an object selected
- if (NewObj.select == True):
+ if NewObj.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() == True):
+ if bpy.ops.view3d.snap_selected_to_cursor.poll() is True:
bpy.ops.view3d.snap_selected_to_cursor()
else:
# as we weren't considered to be in 3D View
# the object couldn't be moved to the 3D cursor
# so to avoid confusion we change the at_3Dcursor boolean to false
self.at_3Dcursor = False
+
else:
- print("Failed to create triangle: ")
- print("Triangle type: %s" % self.triangleType)
- print("Face type: %s" % self.triangleFace)
- print("Ya: %s" % self.Ya)
- print("Xb: %s" % self.Xb)
- print("Xc: %s" % self.Xc)
- print("Vertices: %s" % self.Vertices)
- print("Faces: %s" % self.Faces)
-
- #end action_common
-
- def execute(self, context) :
+ self.report({'WARNING'},
+ "Triangle could not be completed. (See Console for more Info)")
+
+ print("\n[Add Mesh Extra Objects]\n\nModule: add_mesh_triangle")
+ print("Triangle type: %s\n" % self.triangleType,
+ "Face type: %s\n" % self.triangleFace,
+ "Ya: %s, Xb: %s, Xc: %s\n" % (self.Ya, self.Xb, self.Xc),
+ "Vertices: %s\n" % self.Vertices,
+ "Faces: %s\n" % self.Faces)
+
+ def execute(self, context):
self.action_common(context)
return {"FINISHED"}
- #end execute
- def invoke(self, context, event) :
+ def invoke(self, context, event):
self.action_common(context)
return {"FINISHED"}
- #end invoke