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:
-rw-r--r--add_mesh_extra_objects/Blocks.py1573
-rw-r--r--add_mesh_extra_objects/Wallfactory.py948
-rw-r--r--add_mesh_extra_objects/__init__.py104
-rw-r--r--add_mesh_extra_objects/add_empty_as_parent.py120
-rw-r--r--add_mesh_extra_objects/add_mesh_3d_function_surface.py418
-rw-r--r--add_mesh_extra_objects/add_mesh_beam_builder.py163
-rw-r--r--add_mesh_extra_objects/add_mesh_gears.py250
-rw-r--r--add_mesh_extra_objects/add_mesh_gemstones.py157
-rw-r--r--add_mesh_extra_objects/add_mesh_honeycomb.py159
-rw-r--r--add_mesh_extra_objects/add_mesh_menger_sponge.py80
-rw-r--r--add_mesh_extra_objects/add_mesh_pipe_joint.py355
-rw-r--r--add_mesh_extra_objects/add_mesh_pyramid.py102
-rw-r--r--add_mesh_extra_objects/add_mesh_round_brilliant.py341
-rw-r--r--add_mesh_extra_objects/add_mesh_round_cube.py141
-rw-r--r--add_mesh_extra_objects/add_mesh_solid.py497
-rw-r--r--add_mesh_extra_objects/add_mesh_star.py49
-rw-r--r--add_mesh_extra_objects/add_mesh_supertoroid.py155
-rw-r--r--add_mesh_extra_objects/add_mesh_teapot.py36
-rw-r--r--add_mesh_extra_objects/add_mesh_torusknot.py161
-rw-r--r--add_mesh_extra_objects/add_mesh_twisted_torus.py98
-rw-r--r--add_mesh_extra_objects/add_mesh_vertex.py52
-rw-r--r--add_mesh_extra_objects/geodesic_domes/__init__.py3
-rw-r--r--add_mesh_extra_objects/geodesic_domes/add_shape_geodesic.py30
-rw-r--r--add_mesh_extra_objects/geodesic_domes/forms_271.py66
-rw-r--r--add_mesh_extra_objects/geodesic_domes/geodesic_classes_271.py823
-rw-r--r--add_mesh_extra_objects/geodesic_domes/third_domes_panel_271.py1443
-rw-r--r--add_mesh_extra_objects/geodesic_domes/vefm_271.py527
27 files changed, 4973 insertions, 3878 deletions
diff --git a/add_mesh_extra_objects/Blocks.py b/add_mesh_extra_objects/Blocks.py
index 36ef5c0f..f798cf52 100644
--- a/add_mesh_extra_objects/Blocks.py
+++ b/add_mesh_extra_objects/Blocks.py
@@ -1,29 +1,5 @@
-# ***** 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
-# as published by the Free Software Foundation - either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, write to:
-#
-# the Free Software Foundation Inc.
-# 51 Franklin Street, Fifth Floor
-# Boston, MA 02110-1301, USA
-#
-# or go online at: http://www.gnu.org/licenses/ to view license options.
-#
-# ***** END GPL LICENCE BLOCK *****
+# GPL # "author":
-
-##
-#
# Module notes:
#
# Grout needs to be implemented.
@@ -38,30 +14,25 @@
# 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".
-#
-##
-# <pep8-80 compliant>
-import bpy, time, math
+import bpy
from random import random
-from math import fmod, sqrt, sin, cos, atan
+from math import fmod, sqrt, sin, cos, atan, pi as PI
-#A few constants
+# 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.
-PI = math.pi
+NOTZERO = 0.01 # for values that must be != 0; see UI options/variables - sort of a bug to be fixed.
-#global variables
+# global variables
-#General masonry Settings
+# 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}
+ '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
@@ -83,21 +54,21 @@ settings = {'w': 1.2, 'wv': 0.3, 'h': .6, 'hv': 0.3, 'd': 0.3, 'dv': 0.1,
# 'physics': set up for physics
# dims = area of wall (face)
-dims = {'s':0, 'e':PI*3/2, 'b':0.1, 't':12.3} # radial
+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':-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
+radialized = 0 # Radiating from one point - round/disc; instead of square
+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.
-#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}]
+# 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,
@@ -107,55 +78,59 @@ openingSpecs = [{'w':0.5, 'h':0.5, 'x':0.8, 'z':2.7, 'rp':1, 'b':0.0,
# Add blocks to make platforms.
shelfExt = 0
-#shelfSpecs = []
-shelfSpecs = {'w':0.5, 'h':0.5, 'd': 0.3, 'x':0.8, 'z':2.7}
+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.
stepMod = 0
-stepSpecs = {'x':0.0, 'z':-10, 'w':10.0, 'h':10.0,
- 'v':0.7, 't':1.0, 'd':1.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)
- #easier way to get to the random function
-def rnd(): return random()
+# easier way to get to the random function
+def rnd():
+ return random()
+
- #random number from -0.5 to 0.5
-def rndc(): return (random() - 0.5)
+# random number from -0.5 to 0.5
+def rndc():
+ return (random() - 0.5)
- #random number from -1.0 to 1.0
-def rndd(): return (random() - 0.5)*2.0
+# random number from -1.0 to 1.0
+def rndd():
+ return (random() - 0.5) * 2.0
-#Opening Test suite
-#opening test function
-def test(TestN = 13):
- dims = {'s':-29., 'e':29., 'b':-6., 't':TestN*7.5}
+# Opening Test suite
+# opening test function
+
+def test(TestN=13):
+ dims = {'s': -29., 'e': 29., 'b': -6., 't': TestN * 7.5}
openingSpecs = []
for i in range(TestN):
x = (random() - 0.5) * 6
- z = i*7.5
- v = .2 + i*(3./TestN)
- vl = 3.2 - i*(3./TestN)
+ z = i * 7.5
+ v = .2 + i * (3. / TestN)
+ vl = 3.2 - i * (3. / TestN)
t = 0.3 + random()
tl = 0.3 + random()
- rn = random()*2
- openingSpecs += [{'w':3.1 + rn, 'h':0.3 + rn, 'x':float(x),
- 'z':float(z), 'rp':0, 'b':0.,
- 'v':float(v), 'vl':float(vl),
- 't':float(t), 'tl':float(tl)}]
+ rn = random() * 2
+ openingSpecs += [{'w': 3.1 + rn, 'h': 0.3 + rn, 'x': float(x),
+ 'z': float(z), 'rp': 0, 'b': 0.,
+ 'v': float(v), 'vl': float(vl),
+ 't': float(t), 'tl': float(tl)}]
return dims, openingSpecs
-#dims, openingSpecs = test(15)
+# dims, openingSpecs = test(15)
-#For filling a linear space with divisions
-def fill(left, right, avedst, mindst=0.0, dev=0.0, pad=(0.0,0.0), num=0,
+# For filling a linear space with divisions
+def fill(left, right, avedst, mindst=0.0, dev=0.0, pad=(0.0, 0.0), num=0,
center=0):
__doc__ = """\
Fills a linear range with points and returns an ordered list of those points
@@ -172,32 +147,34 @@ def fill(left, right, avedst, mindst=0.0, dev=0.0, pad=(0.0,0.0), num=0,
num: substitutes a numerical limit for the right limit. fill will then make
a num+1 element list
center: flag to center the elements in the range, 0 == disabled
- """
+ """
poslist = [left]
- curpos = left+pad[0]
+ curpos = left + pad[0]
# Set offset by average spacing, then add blocks (fall through);
# if not at right edge.
if center:
- curpos += ((right-left-mindst*2)%avedst)/2+mindst
- if curpos-poslist[-1]<mindst: curpos = poslist[-1]+mindst+rnd()*dev/2
+ curpos += ((right - left - mindst * 2) % avedst) / 2 + mindst
+ if curpos - poslist[-1] < mindst:
+ curpos = poslist[-1] + mindst + rnd() * dev / 2
# clip to right edge.
- if (right-curpos<mindst) or (right-curpos< mindst-pad[1]):
+ if (right - curpos < mindst) or (right - curpos < mindst - pad[1]):
poslist.append(right)
return poslist
- else: poslist.append(curpos)
+ else:
+ poslist.append(curpos)
- #unused... for now.
+ # unused... for now.
if num:
idx = len(poslist)
- while idx<num+1:
- curpos += avedst+rndd()*dev
- if curpos-poslist[-1]<mindst:
- curpos = poslist[-1]+mindst+rnd()*dev/2
+ while idx < num + 1:
+ curpos += avedst + rndd() * dev
+ if curpos - poslist[-1] < mindst:
+ curpos = poslist[-1] + mindst + rnd() * dev / 2
poslist.append(curpos)
idx += 1
@@ -205,19 +182,19 @@ def fill(left, right, avedst, mindst=0.0, dev=0.0, pad=(0.0,0.0), num=0,
# make block edges
else:
- while True: # loop for blocks
- curpos += avedst+rndd()*dev
- if curpos-poslist[-1]<mindst:
- curpos = poslist[-1]+mindst+rnd()*dev/2
+ while True: # loop for blocks
+ curpos += avedst + rndd() * dev
+ if curpos - poslist[-1] < mindst:
+ curpos = poslist[-1] + mindst + rnd() * dev / 2
# close off edges at limit
- if (right-curpos<mindst) or (right-curpos< mindst-pad[1]):
+ if (right - curpos < mindst) or (right - curpos < mindst - pad[1]):
poslist.append(right)
return poslist
-
- else: poslist.append(curpos)
+ else:
+ poslist.append(curpos)
-#For generating block geometry
+# For generating block geometry
def MakeABlock(bounds, segsize, vll=0, Offsets=None, FaceExclude=[],
bevel=0, xBevScl=1):
__doc__ = """\
@@ -241,68 +218,76 @@ def MakeABlock(bounds, segsize, vll=0, Offsets=None, FaceExclude=[],
7:right_top_front,
]
FaceExclude: list of faces to exclude from the faces list. see bounds above for indices
- xBevScl: how much to divide the end (+- x axis) bevel dimensions. Set to current average radius to compensate for angular distortion on curved blocks
+ xBevScl: how much to divide the end (+- x axis) bevel dimensions. Set to current average
+ radius to compensate for angular distortion on curved blocks
"""
slices = fill(bounds[0], bounds[1], segsize, segsize, center=1)
points = []
faces = []
- if Offsets == None:
- points.append([slices[0],bounds[4],bounds[2]])
- points.append([slices[0],bounds[5],bounds[2]])
- points.append([slices[0],bounds[5],bounds[3]])
- points.append([slices[0],bounds[4],bounds[3]])
+ if Offsets is None:
+ points.append([slices[0], bounds[4], bounds[2]])
+ points.append([slices[0], bounds[5], bounds[2]])
+ points.append([slices[0], bounds[5], bounds[3]])
+ points.append([slices[0], bounds[4], bounds[3]])
for x in slices[1:-1]:
- points.append([x,bounds[4],bounds[2]])
- points.append([x,bounds[5],bounds[2]])
- points.append([x,bounds[5],bounds[3]])
- points.append([x,bounds[4],bounds[3]])
+ points.append([x, bounds[4], bounds[2]])
+ points.append([x, bounds[5], bounds[2]])
+ points.append([x, bounds[5], bounds[3]])
+ points.append([x, bounds[4], bounds[3]])
- points.append([slices[-1],bounds[4],bounds[2]])
- points.append([slices[-1],bounds[5],bounds[2]])
- points.append([slices[-1],bounds[5],bounds[3]])
- points.append([slices[-1],bounds[4],bounds[3]])
+ points.append([slices[-1], bounds[4], bounds[2]])
+ points.append([slices[-1], bounds[5], bounds[2]])
+ points.append([slices[-1], bounds[5], bounds[3]])
+ points.append([slices[-1], bounds[4], bounds[3]])
else:
- points.append([slices[0]+Offsets[0][0],bounds[4]+Offsets[0][1],bounds[2]+Offsets[0][2]])
- points.append([slices[0]+Offsets[1][0],bounds[5]+Offsets[1][1],bounds[2]+Offsets[1][2]])
- points.append([slices[0]+Offsets[3][0],bounds[5]+Offsets[3][1],bounds[3]+Offsets[3][2]])
- points.append([slices[0]+Offsets[2][0],bounds[4]+Offsets[2][1],bounds[3]+Offsets[2][2]])
-
- for x in slices[1:-1]:
- xwt = (x-bounds[0])/(bounds[1]-bounds[0])
- points.append([x+Offsets[0][0]*(1-xwt)+Offsets[4][0]*xwt,bounds[4]+Offsets[0][1]*(1-xwt)+Offsets[4][1]*xwt,bounds[2]+Offsets[0][2]*(1-xwt)+Offsets[4][2]*xwt])
- points.append([x+Offsets[1][0]*(1-xwt)+Offsets[5][0]*xwt,bounds[5]+Offsets[1][1]*(1-xwt)+Offsets[5][1]*xwt,bounds[2]+Offsets[1][2]*(1-xwt)+Offsets[5][2]*xwt])
- points.append([x+Offsets[3][0]*(1-xwt)+Offsets[7][0]*xwt,bounds[5]+Offsets[3][1]*(1-xwt)+Offsets[7][1]*xwt,bounds[3]+Offsets[3][2]*(1-xwt)+Offsets[7][2]*xwt])
- points.append([x+Offsets[2][0]*(1-xwt)+Offsets[6][0]*xwt,bounds[4]+Offsets[2][1]*(1-xwt)+Offsets[6][1]*xwt,bounds[3]+Offsets[2][2]*(1-xwt)+Offsets[6][2]*xwt])
-
- points.append([slices[-1]+Offsets[4][0],bounds[4]+Offsets[4][1],bounds[2]+Offsets[4][2]])
- points.append([slices[-1]+Offsets[5][0],bounds[5]+Offsets[5][1],bounds[2]+Offsets[5][2]])
- points.append([slices[-1]+Offsets[7][0],bounds[5]+Offsets[7][1],bounds[3]+Offsets[7][2]])
- points.append([slices[-1]+Offsets[6][0],bounds[4]+Offsets[6][1],bounds[3]+Offsets[6][2]])
-
- faces.append([vll,vll+3,vll+2,vll+1])
-
- for x in range(len(slices)-1):
- faces.append([vll,vll+1,vll+5,vll+4])
- vll+=1
- faces.append([vll,vll+1,vll+5,vll+4])
- vll+=1
- faces.append([vll,vll+1,vll+5,vll+4])
- vll+=1
- faces.append([vll,vll-3,vll+1,vll+4])
- vll+=1
-
- faces.append([vll,vll+1,vll+2,vll+3])
+ points.append([slices[0] + Offsets[0][0], bounds[4] + Offsets[0][1], bounds[2] + Offsets[0][2]])
+ points.append([slices[0] + Offsets[1][0], bounds[5] + Offsets[1][1], bounds[2] + Offsets[1][2]])
+ points.append([slices[0] + Offsets[3][0], bounds[5] + Offsets[3][1], bounds[3] + Offsets[3][2]])
+ points.append([slices[0] + Offsets[2][0], bounds[4] + Offsets[2][1], bounds[3] + Offsets[2][2]])
+
+ for x in slices[1: -1]:
+ xwt = (x - bounds[0]) / (bounds[1] - bounds[0])
+ points.append([x + Offsets[0][0] * (1 - xwt) + Offsets[4][0] * xwt,
+ bounds[4] + Offsets[0][1] * (1 - xwt) + Offsets[4][1] * xwt,
+ bounds[2] + Offsets[0][2] * (1 - xwt) + Offsets[4][2] * xwt])
+ points.append([x + Offsets[1][0] * (1 - xwt) + Offsets[5][0] * xwt,
+ bounds[5] + Offsets[1][1] * (1 - xwt) + Offsets[5][1] * xwt,
+ bounds[2] + Offsets[1][2] * (1 - xwt) + Offsets[5][2] * xwt])
+ points.append([x + Offsets[3][0] * (1 - xwt) + Offsets[7][0] * xwt,
+ bounds[5] + Offsets[3][1] * (1 - xwt) + Offsets[7][1] * xwt,
+ bounds[3] + Offsets[3][2] * (1 - xwt) + Offsets[7][2] * xwt])
+ points.append([x + Offsets[2][0] * (1 - xwt) + Offsets[6][0] * xwt,
+ bounds[4] + Offsets[2][1] * (1 - xwt) + Offsets[6][1] * xwt,
+ bounds[3] + Offsets[2][2] * (1 - xwt) + Offsets[6][2] * xwt])
+
+ points.append([slices[-1] + Offsets[4][0], bounds[4] + Offsets[4][1], bounds[2] + Offsets[4][2]])
+ points.append([slices[-1] + Offsets[5][0], bounds[5] + Offsets[5][1], bounds[2] + Offsets[5][2]])
+ points.append([slices[-1] + Offsets[7][0], bounds[5] + Offsets[7][1], bounds[3] + Offsets[7][2]])
+ points.append([slices[-1] + Offsets[6][0], bounds[4] + Offsets[6][1], bounds[3] + Offsets[6][2]])
+
+ faces.append([vll, vll + 3, vll + 2, vll + 1])
+
+ for x in range(len(slices) - 1):
+ faces.append([vll, vll + 1, vll + 5, vll + 4])
+ vll += 1
+ faces.append([vll, vll + 1, vll + 5, vll + 4])
+ vll += 1
+ faces.append([vll, vll + 1, vll + 5, vll + 4])
+ vll += 1
+ faces.append([vll, vll - 3, vll + 1, vll + 4])
+ vll += 1
+
+ faces.append([vll, vll + 1, vll + 2, vll + 3])
return points, faces
-#
-#
-#
-#For generating Keystone Geometry
+
+# For generating Keystone Geometry
+
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.
@@ -315,60 +300,68 @@ def MakeAKeystone(xpos, width, zpos, ztop, zbtm, thick, bevel, vll=0, FaceExclud
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
- xBevScl: how much to divide the end (+- x axis) bevel dimensions. Set to current average radius to compensate for angular distortion on curved blocks
+ xBevScl: how much to divide the end (+- x axis) bevel dimensions.
+ Set to current average radius to compensate for angular distortion on curved blocks
"""
points = []
faces = []
faceinclude = [1 for x in range(6)]
- for x in FaceExclude: faceinclude[x]=0
+ for x in FaceExclude:
+ faceinclude[x] = 0
Top = zpos + ztop
Btm = zpos - zbtm
- Wid = width/2.
- Thk = thick/2.
+ Wid = width / 2.0
+ Thk = thick / 2.0
# The front top point
points.append([xpos, Thk, Top])
# The front left point
- points.append([xpos-Wid, Thk, zpos])
+ points.append([xpos - Wid, Thk, zpos])
# The front bottom point
points.append([xpos, Thk, Btm])
# The front right point
- points.append([xpos+Wid, Thk, zpos])
+ points.append([xpos + Wid, Thk, zpos])
MirrorPoints = []
for i in points:
- MirrorPoints.append([i[0],-i[1],i[2]])
+ MirrorPoints.append([i[0], -i[1], i[2]])
points += MirrorPoints
points[6][2] += bevel
- faces.append([3,2,1,0])
- faces.append([4,5,6,7])
- faces.append([4,7,3,0])
- faces.append([5,4,0,1])
- faces.append([6,5,1,2])
- faces.append([7,6,2,3])
+ faces.append([3, 2, 1, 0])
+ faces.append([4, 5, 6, 7])
+ faces.append([4, 7, 3, 0])
+ faces.append([5, 4, 0, 1])
+ faces.append([6, 5, 1, 2])
+ faces.append([7, 6, 2, 3])
# Offset the vertex numbers by the number of verticies already in the list
for i in range(len(faces)):
- for j in range(len(faces[i])): faces[i][j] += vll
+ for j in range(len(faces[i])):
+ faces[i][j] += vll
return points, faces
-#for finding line/circle intercepts
-def circ(offs=0.,r=1.):
+# for finding line/circle intercepts
+
+def circ(offs=0., r=1.):
__doc__ = """\
offs is the distance perpendicular to the line to the center of the circle
r is the radius of the circle
circ returns the distance paralell to the line to the center of the circle at the intercept.
"""
offs = abs(offs)
- if offs > r: return None
- elif offs == r: return 0.
- else: return sqrt(r**2 - offs**2)
+ if offs > r:
+ return None
+ elif offs == r:
+ return 0.
+ else:
+ return sqrt(r ** 2 - offs ** 2)
+
+# class openings in the wall
-#class openings in the wall
class opening:
__doc__ = """\
This is the class for holding the data for the openings in the wall.
@@ -380,191 +373,208 @@ class opening:
# z = 0. # x position of the opening
# w = 0. # width of the opening
# h = 0. # height of the opening
- r = 0 # top radius of the arch (derived from 'v')
- rl = 0 # lower radius of the arch (derived from 'vl')
- rt = 0 # top arch thickness
- rtl = 0# lower arch thickness
- ts = 0 # Opening side thickness, if greater than average width, replaces it.
- c = 0 # top arch corner position (for low arches), distance from the top of the straight sides
- cl = 0 # lower arch corner position (for low arches), distance from the top of the straight sides
- # form = 0 # arch type (unused for now)
- # b = 0. # back face bevel distance, like an arrow slit
- v = 0. # top arch height
- vl = 0.# lower arch height
+ r = 0 # top radius of the arch (derived from 'v')
+ rl = 0 # lower radius of the arch (derived from 'vl')
+ rt = 0 # top arch thickness
+ rtl = 0 # lower arch thickness
+ ts = 0 # Opening side thickness, if greater than average width, replaces it.
+ c = 0 # top arch corner position (for low arches), distance from the top of the straight sides
+ cl = 0 # lower arch corner position (for low arches), distance from the top of the straight sides
+ # form = 0 # arch type (unused for now)
+ # b = 0. # back face bevel distance, like an arrow slit
+ v = 0. # top arch height
+ vl = 0. # lower arch height
# variable "s" is used for "side" in the "edge" function.
# it is a signed int, multiplied by the width to get + or - of the center
def btm(self):
- if self.vl <= self.w/2 : return self.z-self.h/2-self.vl-self.rtl
- else: return self.z - sqrt((self.rl+self.rtl)**2 - (self.rl - self.w/2 )**2) - self.h/2
-
+ if self.vl <= self.w / 2:
+ return self.z - self.h / 2 - self.vl - self.rtl
+ else:
+ return self.z - sqrt((self.rl + self.rtl) ** 2 - (self.rl - self.w / 2) ** 2) - self.h / 2
def top(self):
- if self.v <= self.w/2 : return self.z+self.h/2+self.v+self.rt
- else: return sqrt((self.r+self.rt)**2 - (self.r - self.w/2 )**2) + self.z + self.h/2
-
+ if self.v <= self.w / 2:
+ return self.z + self.h / 2 + self.v + self.rt
+ else:
+ return sqrt((self.r + self.rt) ** 2 - (self.r - self.w / 2) ** 2) + self.z + self.h / 2
- #crits returns the critical split points, or discontinuities, used for making rows
+ # crits returns the critical split points, or discontinuities, used for making rows
def crits(self):
critlist = []
- if self.vl>0: # for lower arch
+ if self.vl > 0: # for lower arch
# add the top point if it is pointed
- #if self.vl >= self.w/2.: critlist.append(self.btm())
- if self.vl < self.w/2.:#else: for low arches, with wedge blocks under them
- #critlist.append(self.btm())
- critlist.append(self.z-self.h/2 - self.cl)
+ # if self.vl >= self.w/2.: critlist.append(self.btm())
+ if self.vl < self.w / 2.: # else: for low arches, with wedge blocks under them
+ # critlist.append(self.btm())
+ critlist.append(self.z - self.h / 2 - self.cl)
- if self.h>0: # if it has a height, append points at the top and bottom of the main square section
- critlist += [self.z-self.h/2,self.z+self.h/2]
+ if self.h > 0: # if it has a height, append points at the top and bottom of the main square section
+ critlist += [self.z - self.h / 2, self.z + self.h / 2]
else: # otherwise, append just one in the center
critlist.append(self.z)
- if self.v>0: # for the upper arch
- if self.v < self.w/2.: # add the splits for the upper wedge blocks, if needed
- critlist.append(self.z+self.h/2 + self.c)
- #critlist.append(self.top())
- #otherwise just add the top point, if it is pointed
- #else: critlist.append(self.top())
+ if self.v > 0: # for the upper arch
+ if self.v < self.w / 2: # add the splits for the upper wedge blocks, if needed
+ critlist.append(self.z + self.h / 2 + self.c)
+ # critlist.append(self.top())
+ # otherwise just add the top point, if it is pointed
+ # else: critlist.append(self.top())
return critlist
-
# get the side position of the 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: r1 = abs(dims['t']*sin(ht*PI/(dims['t']*2)))
- else: r1 = abs(ht)
- else: r1 = 1
+ if slope:
+ r1 = abs(dims['t'] * sin(ht * PI / (dims['t'] * 2)))
+ else:
+ r1 = abs(ht)
+ else:
+ r1 = 1
- #Go through all the options, and return the correct value
- if ht < self.btm(): #too low
+ # Go through all the options, and return the correct value
+ if ht < self.btm(): # too low
return None
- elif ht > self.top(): #too high
+ elif ht > self.top(): # too high
return None
# Check for circ returning None - prevent TypeError (script failure) with float.
-
# in this range, pass the lower arch info
- elif ht <= self.z-self.h/2-self.cl:
- if self.vl > self.w/2:
- circVal = circ(ht-self.z+self.h/2,self.rl+self.rtl)
- if circVal == None:
+ elif ht <= self.z - self.h / 2 - self.cl:
+ if self.vl > self.w / 2:
+ circVal = circ(ht - self.z + self.h / 2, self.rl + self.rtl)
+ if circVal is None:
return None
- else: return self.x + s*(self.w/2.-self.rl+circVal)/r1
+ else:
+ return self.x + s * (self.w / 2. - self.rl + circVal) / r1
else:
- circVal = circ(ht-self.z+self.h/2+self.vl-self.rl,self.rl+self.rtl)
- if circVal == None:
+ circVal = circ(ht - self.z + self.h / 2 + self.vl - self.rl, self.rl + self.rtl)
+ if circVal is None:
return None
- else: return self.x + s*circVal/r1
+ else:
+ return self.x + s * circVal / r1
- #in this range, pass the top arch info
- elif ht >= self.z+self.h/2+self.c:
- if self.v > self.w/2:
- circVal = circ(ht-self.z-self.h/2,self.r+self.rt)
- if circVal == None:
+ # in this range, pass the top arch info
+ elif ht >= self.z + self.h / 2 + self.c:
+ if self.v > self.w / 2:
+ circVal = circ(ht - self.z - self.h / 2, self.r + self.rt)
+ if circVal is None:
return None
- else: return self.x + s*(self.w/2.-self.r+circVal)/r1
+ else:
+ return self.x + s * (self.w / 2. - self.r + circVal) / r1
else:
- circVal = circ(ht-(self.z+self.h/2+self.v-self.r),self.r+self.rt)
- if circVal == None:
+ circVal = circ(ht - (self.z + self.h / 2 + self.v - self.r), self.r + self.rt)
+ if circVal is None:
return None
- else: return self.x + s*circVal/r1
-
- #in this range pass the lower corner edge info
- elif ht <= self.z-self.h/2:
- d = sqrt(self.rtl**2 - self.cl**2)
- if self.cl > self.rtl/sqrt(2.): return self.x + s*(self.w/2 + (self.z - self.h/2 - ht)*d/self.cl)/r1
- else: return self.x + s*( self.w/2 + d )/r1
+ else:
+ return self.x + s * circVal / r1
- #in this range pass the upper corner edge info
- elif ht >= self.z+self.h/2:
- d = sqrt(self.rt**2 - self.c**2)
- if self.c > self.rt/sqrt(2.): return self.x + s*(self.w/2 + (ht - self.z - self.h/2 )*d/self.c)/r1
- else: return self.x + s*( self.w/2 + d )/r1
+ # in this range pass the lower corner edge info
+ elif ht <= self.z - self.h / 2:
+ d = sqrt(self.rtl ** 2 - self.cl ** 2)
+ if self.cl > self.rtl / sqrt(2.):
+ return self.x + s * (self.w / 2 + (self.z - self.h / 2 - ht) * d / self.cl) / r1
+ else:
+ return self.x + s * (self.w / 2 + d) / r1
- #in this range, pass the middle info (straight sides)
- else: return self.x + s*self.w/2/r1
+ # in this range pass the upper corner edge info
+ elif ht >= self.z + self.h / 2:
+ d = sqrt(self.rt ** 2 - self.c ** 2)
+ if self.c > self.rt / sqrt(2.):
+ return self.x + s * (self.w / 2 + (ht - self.z - self.h / 2) * d / self.c) / r1
+ else:
+ return self.x + s * (self.w / 2 + d) / r1
+ # in this range, pass the middle info (straight sides)
+ else:
+ return self.x + s * self.w / 2 / r1
# 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)
+ dist = abs(self.x - ht)
+
def radialAdjust(dist, sideVal):
- """take the distance and adjust for radial geometry, return dist.
- """
+ # take the distance and adjust for radial geometry, return dist
if radialized:
if slope:
- dist = dist * abs(dims['t']*sin(sideVal*PI/(dims['t']*2)))
+ dist = dist * abs(dims['t'] * sin(sideVal * PI / (dims['t'] * 2)))
else:
dist = dist * sideVal
return dist
- if s > 0 :#and (dist <= self.edgeS(self.z+self.h/2+self.c,1)-self.x): #check top down
- #hack for radialized masonry, import approx Z instead of self.top()
+ if s > 0: # and (dist <= self.edgeS(self.z + self.h / 2 + self.c, 1) - self.x): # check top down
+ # hack for radialized masonry, import approx Z instead of self.top()
dist = radialAdjust(dist, self.top())
- #no arch on top, flat
- if not self.r: return self.z+self.h/2
+ # no arch on top, flat
+ if not self.r:
+ return self.z + self.h / 2
- #pointed arch on top
- elif self.v > self.w/2:
- circVal = circ(dist-self.w/2+self.r,self.r+self.rt)
- if circVal == None:
+ # pointed arch on top
+ elif self.v > self.w / 2:
+ circVal = circ(dist - self.w / 2 + self.r, self.r + self.rt)
+ if circVal is None:
return None
- else: return self.z+self.h/2+circVal
+ else:
+ return self.z + self.h / 2 + circVal
- #domed arch on top
+ # domed arch on top
else:
- circVal = circ(dist,self.r+self.rt)
- if circVal == None:
+ circVal = circ(dist, self.r + self.rt)
+ if circVal is None:
return None
- else: return self.z+self.h/2+self.v-self.r+circVal
+ else:
+ return self.z + self.h / 2 + self.v - self.r + circVal
- else:#and (dist <= self.edgeS(self.z-self.h/2-self.cl,1)-self.x): #check bottom up
- #hack for radialized masonry, import approx Z instead of self.top()
+ else: # and (dist <= self.edgeS(self.z - self.h / 2 - self.cl, 1) - self.x): # check bottom up
+ # hack for radialized masonry, import approx Z instead of self.top()
dist = radialAdjust(dist, self.btm())
- #no arch on bottom
- if not self.rl: return self.z-self.h/2
+ # no arch on bottom
+ if not self.rl:
+ return self.z - self.h / 2
- #pointed arch on bottom
- elif self.vl > self.w/2:
- circVal = circ(dist-self.w/2+self.rl,self.rl+self.rtl)
- if circVal == None:
+ # pointed arch on bottom
+ elif self.vl > self.w / 2:
+ circVal = circ(dist - self.w / 2 + self.rl, self.rl + self.rtl)
+ if circVal is None:
return None
- else: return self.z-self.h/2-circVal
+ else:
+ return self.z - self.h / 2 - circVal
- #old conditional? if (dist-self.w/2+self.rl)<=(self.rl+self.rtl):
- #domed arch on bottom
+ # old conditional? if (dist-self.w / 2 + self.rl) <= (self.rl + self.rtl):
+ # domed arch on bottom
else:
- circVal = circ(dist,self.rl+self.rtl) # dist-self.w/2+self.rl
- if circVal == None:
+ circVal = circ(dist, self.rl + self.rtl) # dist-self.w / 2 + self.rl
+ if circVal is None:
return None
- else: return self.z-self.h/2-self.vl+self.rl-circVal
+ 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)
return 0.0
- #
+
def edgeBev(self, ht):
- if ht > (self.z + self.h/2): return 0.0
- if ht < (self.z - self.h/2): return 0.0
+ if ht > (self.z + self.h / 2):
+ return 0.0
+ if ht < (self.z - self.h / 2):
+ return 0.0
if radialized:
- if slope: r1 = abs(dims['t']*sin(ht*PI/(dims['t']*2)))
- else: r1 = abs(ht)
- else: r1 = 1
+ if slope:
+ r1 = abs(dims['t'] * sin(ht * PI / (dims['t'] * 2)))
+ else:
+ r1 = abs(ht)
+ else:
+ r1 = 1
bevel = self.b / r1
return bevel
-#
-##
-#
def __init__(self, xpos, zpos, width, height, archHeight=0, archThk=0,
archHeightLower=0, archThkLower=0, bevel=0, edgeThk=0):
@@ -576,42 +586,43 @@ class opening:
self.rtl = archThkLower
self.v = archHeight
self.vl = archHeightLower
- if self.w <= 0: self.w = SMALL
+ if self.w <= 0:
+ self.w = SMALL
- #find the upper arch radius
- if archHeight >= width/2:
+ # find the upper arch radius
+ if archHeight >= width / 2:
# just one arch, low long
- self.r = (self.v**2)/self.w + self.w/4
+ self.r = (self.v ** 2) / self.w + self.w / 4
elif archHeight <= 0:
# No arches
self.r = 0
self.v = 0
else:
# Two arches
- self.r = (self.w**2)/(8*self.v) + self.v/2.
- self.c = self.rt*cos(atan(self.w/(2*(self.r-self.v))))
+ self.r = (self.w ** 2) / (8 * self.v) + self.v / 2.
+ self.c = self.rt * cos(atan(self.w / (2 * (self.r - self.v))))
- #find the lower arch radius
- if archHeightLower >= width/2:
- self.rl = (self.vl**2)/self.w + self.w/4
+ # find the lower arch radius
+ if archHeightLower >= width / 2:
+ self.rl = (self.vl ** 2) / self.w + self.w / 4
elif archHeightLower <= 0:
self.rl = 0
self.vl = 0
else:
- self.rl = (self.w**2)/(8*self.vl) + self.vl/2.
- self.cl = self.rtl*cos(atan(self.w/(2*(self.rl-self.vl))))
+ self.rl = (self.w ** 2) / (8 * self.vl) + self.vl / 2.
+ self.cl = self.rtl * cos(atan(self.w / (2 * (self.rl - self.vl))))
- #self.form = something?
+ # self.form = something?
self.b = float(bevel)
self.ts = edgeThk
-#
-#
-#class for the whole wall boundaries; a sub-class of "opening"
+
+# class for the whole wall boundaries; a sub-class of "opening"
+
class OpeningInv(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.
+ # 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)
@@ -619,29 +630,27 @@ class OpeningInv(opening):
def edgeV(self, ht, s):
return opening.edgeV(self, ht, -s)
-#class rows in the wall
+
+# class rows in the wall
+
class rowOb:
__doc__ = """\
This is the class for holding the data for individual rows of blocks.
each row is required to have some edge blocks, and can also have
intermediate sections of "normal" blocks.
"""
-
- #z = 0.
- #h = 0.
radius = 1
EdgeOffset = 0.
-# BlocksEdge = []
-# RowSegments = []
-# BlocksNorm = []
def FillBlocks(self):
# Set the radius variable, in the case of radial geometry
if radialized:
- if slope: self.radius = dims['t']*(sin(self.z*PI/(dims['t']*2)))
- else: self.radius = self.z
+ if slope:
+ self.radius = dims['t'] * (sin(self.z * PI / (dims['t'] * 2)))
+ else:
+ self.radius = self.z
- #initialize internal variables from global settings
+ # initialize internal variables from global settings
SetH = settings['h']
SetHwt = settings['hwt']
@@ -654,52 +663,51 @@ class rowOb:
SetDepth = settings['d']
SetDepthVar = settings['dv']
- #height weight, used for making shorter rows have narrower blocks, and vice-versa
- hwt = ((self.h/SetH-1)*SetHwt+1)
+ # height weight, used for making shorter rows have narrower blocks, and vice-versa
+ hwt = ((self.h / SetH - 1) * SetHwt + 1)
# set variables for persistent values: loop optimization, readability, single ref for changes.
- avgDist = hwt*SetWid/self.radius
- minDist = SetWidMin/self.radius
- deviation = hwt*SetWidVar/self.radius
- grtOffset = SetGrt/(2*self.radius)
+ avgDist = hwt * SetWid / self.radius
+ minDist = SetWidMin / self.radius
+ deviation = hwt * SetWidVar / self.radius
+ grtOffset = SetGrt / (2 * self.radius)
# init loop variables that may change...
- grt = (SetGrt + rndc()*SetGrtVar)/(self.radius)
- ThisBlockHeight = self.h+rndc()*(1-SetRowHeightLink)*SetGrtVar
- ThisBlockDepth = rndd()*SetDepthVar+SetDepth
+ grt = (SetGrt + rndc() * SetGrtVar) / (self.radius)
+ ThisBlockHeight = self.h + rndc() * (1 - SetRowHeightLink) * SetGrtVar
+ ThisBlockDepth = rndd() * SetDepthVar + SetDepth
for segment in self.RowSegments:
- divs = fill(segment[0]+grtOffset, segment[1]-grtOffset, avgDist, minDist, deviation)
+ divs = fill(segment[0] + grtOffset, segment[1] - grtOffset, avgDist, minDist, deviation)
- #loop through the divisions, adding blocks for each one
- for i in range(len(divs)-1):
- ThisBlockx = (divs[i]+divs[i+1])/2
- ThisBlockw = divs[i+1]-divs[i]-grt
+ # loop through the divisions, adding blocks for each one
+ for i in range(len(divs) - 1):
+ ThisBlockx = (divs[i] + divs[i + 1]) / 2
+ ThisBlockw = divs[i + 1] - divs[i] - grt
self.BlocksNorm.append([ThisBlockx, self.z, ThisBlockw, ThisBlockHeight, ThisBlockDepth, None])
- if SetDepthVar: # vary depth
- ThisBlockDepth = rndd()*SetDepthVar+SetDepth
+ if SetDepthVar: # vary depth
+ ThisBlockDepth = rndd() * SetDepthVar + SetDepth
- if SetGrtVar: # vary grout
- grt = (SetGrt + rndc()*SetGrtVar)/(self.radius)
- ThisBlockHeight = self.h+rndc()*(1-SetRowHeightLink)*SetGrtVar
+ if SetGrtVar: # vary grout
+ grt = (SetGrt + rndc() * SetGrtVar) / (self.radius)
+ ThisBlockHeight = self.h + rndc() * (1 - SetRowHeightLink) * SetGrtVar
-
- def __init__(self,centerheight,rowheight,edgeoffset = 0.):
+ def __init__(self, centerheight, rowheight, edgeoffset=0.):
self.z = float(centerheight)
self.h = float(rowheight)
self.EdgeOffset = float(edgeoffset)
-#THIS INITILIZATION IS IMPORTANT! OTHERWISE ALL OBJECTS WILL HAVE THE SAME LISTS!
+ # THIS INITILIZATION IS IMPORTANT! OTHERWISE ALL OBJECTS WILL HAVE THE SAME LISTS!
self.BlocksEdge = []
self.RowSegments = []
self.BlocksNorm = []
-#
-def arch(ra,rt,x,z, archStart, archEnd, bevel, bevAngle, vll):
+
+def arch(ra, rt, x, z, archStart, archEnd, bevel, bevAngle, vll):
__doc__ = """\
Makes a list of faces and vertexes for arches.
ra: the radius of the arch, to the center of the bricks
@@ -714,16 +722,9 @@ def arch(ra,rt,x,z, archStart, archEnd, bevel, bevAngle, vll):
avlist = []
aflist = []
- #initialize internal variables for global settings
-#overkill?
- SetH = settings['h']
- SetHwt = settings['hwt']
- SetWid = settings['w']
- SetWidMin = settings['wm']
- SetWidVar = settings['wv']
+ # initialize internal variables for global settings
SetGrt = settings['g']
SetGrtVar = settings['gv']
- SetRowHeightLink = settings['rwhl']
SetDepth = settings['d']
SetDepthVar = settings['dv']
@@ -737,92 +738,103 @@ def arch(ra,rt,x,z, archStart, archEnd, bevel, bevAngle, vll):
bevel = how much to offset the edge
side = -1 for left (right side), 1 for right (left side)
"""
- left = (0,2,3)
- right = (4,6,7)
- if side == 1: pointsToAffect = right
- else: pointsToAffect = left
+ left = (0, 2, 3)
+ right = (4, 6, 7)
+ if side == 1:
+ pointsToAffect = right
+ else:
+ pointsToAffect = left
for num in pointsToAffect:
offsets[num] = offsets[num][:]
offsets[num][0] += -bevel * side
- ArchInner = ra-rt/2
- ArchOuter = ra+rt/2-SetGrt + rndc()*SetGrtVar
+ ArchInner = ra - rt / 2
+ ArchOuter = ra + rt / 2 - SetGrt + rndc() * SetGrtVar
- DepthBack = -SetDepth/2-rndc()*SetDepthVar
- DepthFront = SetDepth/2+rndc()*SetDepthVar
+ DepthBack = - SetDepth / 2 - rndc() * SetDepthVar
+ DepthFront = SetDepth / 2 + rndc() * SetDepthVar
- if radialized: subdivision = settings['sdv']
- else: subdivision = 0.12
+ if radialized:
+ subdivision = settings['sdv']
+ else:
+ subdivision = 0.12
- grt = (SetGrt + rndc()*SetGrtVar)/(2*ra) # init grout offset for loop
+ grt = (SetGrt + rndc() * SetGrtVar) / (2 * ra) # init grout offset for loop
# set up the offsets, it will be the same for every block
- offsets = ([[0]*2 + [bevel]] + [[0]*3]*3)*2
+ offsets = ([[0] * 2 + [bevel]] + [[0] * 3] * 3) * 2
- #make the divisions in the "length" of the arch
- divs = fill(archStart, archEnd, settings['w']/ra, settings['wm']/ra, settings['wv']/ra)
+ # make the divisions in the "length" of the arch
+ divs = fill(archStart, archEnd, settings['w'] / ra, settings['wm'] / ra, settings['wv'] / ra)
- for i in range(len(divs)-1):
+ for i in range(len(divs) - 1):
if i == 0:
ThisOffset = offsets[:]
- bevelEdgeOffset(ThisOffset, bevAngle, -1)
- elif i == len(divs)-2:
+ bevelEdgeOffset(ThisOffset, bevAngle, - 1)
+ elif i == len(divs) - 2:
ThisOffset = offsets[:]
bevelEdgeOffset(ThisOffset, bevAngle, 1)
else:
ThisOffset = offsets
- geom = MakeABlock([divs[i]+grt, divs[i+1]-grt, ArchInner, ArchOuter, DepthBack, DepthFront],
+ 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]
- if SetDepthVar: # vary depth
- DepthBack = -SetDepth/2-rndc()*SetDepthVar
- DepthFront = SetDepth/2+rndc()*SetDepthVar
+ if SetDepthVar: # vary depth
+ DepthBack = -SetDepth / 2 - rndc() * SetDepthVar
+ DepthFront = SetDepth / 2 + rndc() * SetDepthVar
- if SetGrtVar: # vary grout
- grt = (settings['g'] + rndc()*SetGrtVar)/(2*ra)
- ArchOuter = ra+rt/2-SetGrt + rndc()*SetGrtVar
+ if SetGrtVar: # vary grout
+ grt = (settings['g'] + rndc() * SetGrtVar) / (2 * ra)
+ ArchOuter = ra + rt / 2 - SetGrt + rndc() * SetGrtVar
- for i,vert in enumerate(avlist):
- v0 = vert[2]*sin(vert[0]) + x
+ for i, vert in enumerate(avlist):
+ v0 = vert[2] * sin(vert[0]) + x
v1 = vert[1]
- v2 = vert[2]*cos(vert[0]) + z
+ v2 = vert[2] * cos(vert[0]) + z
- if radialized==1:
- if slope==1: r1 = dims['t']*(sin(v2*PI/(dims['t']*2)))
- else: r1 = v2
- v0 = v0/r1
+ if radialized == 1:
+ if slope == 1:
+ r1 = dims['t'] * (sin(v2 * PI / (dims['t'] * 2)))
+ else:
+ r1 = v2
+ v0 = v0 / r1
- avlist[i] = [v0,v1,v2]
+ avlist[i] = [v0, v1, v2]
+
+ return (avlist, aflist)
- return (avlist,aflist)
-#
def sketch():
- __doc__ = """\
+ __doc__ = """ \
The 'sketch' function creates a list of openings from the general specifications passed to it.
It takes curved and domed walls into account, placing the openings at the appropriate angular locations
"""
boundlist = []
for x in openingSpecs:
if x['rp']:
- if radialized: r1 = x['z']
- else: r1 = 1
-
- if x['x'] > (x['w'] + settings['wm']):spacing = x['x']/r1
- else: spacing = (x['w'] + settings['wm'])/r1
+ if radialized:
+ r1 = x['z']
+ else:
+ r1 = 1
- minspacing = (x['w'] + settings['wm'])/r1
+ if x['x'] > (x['w'] + settings['wm']):
+ spacing = x['x'] / r1
+ else:
+ spacing = (x['w'] + settings['wm']) / r1
- divs = fill(dims['s'],dims['e'],spacing,minspacing,center=1)
+ minspacing = (x['w'] + settings['wm']) / r1
- for posidx in range(len(divs)-2):
- boundlist.append(opening(divs[posidx+1],x['z'],x['w'],x['h'],x['v'],x['t'],x['vl'],x['tl'],x['b']))
+ divs = fill(dims['s'], dims['e'], spacing, minspacing, center=1)
- else: boundlist.append(opening(x['x'],x['z'],x['w'],x['h'],x['v'],x['t'],x['vl'],x['tl'],x['b']))
- #check for overlaping edges?
+ for posidx in range(len(divs) - 2):
+ boundlist.append(opening(divs[posidx + 1], x['z'], x['w'], x['h'],
+ x['v'], x['t'], x['vl'], x['tl'], x['b']))
+ else:
+ boundlist.append(opening(x['x'], x['z'], x['w'], x['h'], x['v'], x['t'], x['vl'], x['tl'], x['b']))
+ # check for overlaping edges?
return boundlist
@@ -834,42 +846,47 @@ def wedgeBlocks(row, opening, leftPos, rightPos, edgeBinary, r1):
wedgeBlocks(row, LeftWedgeEdge, LNerEdge, LEB, r1)
wedgeBlocks(row, RNerEdge, RightWedgeEdge, REB, r1)
"""
- wedgeEdges = fill(leftPos, rightPos, settings['w']/r1, settings['wm']/r1,
- settings['wv']/r1)
+ wedgeEdges = fill(leftPos, rightPos, settings['w'] / r1, settings['wm'] / r1,
+ settings['wv'] / r1)
- for i in range(len(wedgeEdges)-1):
- x = (wedgeEdges[i+1] + wedgeEdges[i])/2
- grt = (settings['g'] + rndd()*settings['gv'])/r1
- w = wedgeEdges[i+1] - wedgeEdges[i] - grt
+ for i in range(len(wedgeEdges) - 1):
+ x = (wedgeEdges[i + 1] + wedgeEdges[i]) / 2
+ grt = (settings['g'] + rndd() * settings['gv']) / r1
+ w = wedgeEdges[i + 1] - wedgeEdges[i] - grt
- ThisBlockDepth = rndd()*settings['dv']+settings['d']
+ ThisBlockDepth = rndd() * settings['dv'] + settings['d']
-#edgeV may return "None" - causing TypeError for math op.
-#use 0 until wedgeBlocks operation worked out
- edgeVal = opening.edgeV(x-w/2,edgeBinary)
- if edgeVal == None: edgeVal = 0.0
+ # edgeV may return "None" - causing TypeError for math op.
+ # use 0 until wedgeBlocks operation worked out
+ edgeVal = opening.edgeV(x - w / 2, edgeBinary)
+ if edgeVal is None:
+ edgeVal = 0.0
- LeftVertOffset = -( row.z - (row.h/2)*edgeBinary - edgeVal )
+ LeftVertOffset = -(row.z - (row.h / 2) * edgeBinary - edgeVal)
-#edgeV may return "None" - causing TypeError for math op.
-#use 0 until wedgeBlocks operation worked out
- edgeVal = opening.edgeV(x+w/2,edgeBinary)
- if edgeVal == None: edgeVal = 0.0
+ # edgeV may return "None" - causing TypeError for math op.
+ # use 0 until wedgeBlocks operation worked out
+ edgeVal = opening.edgeV(x + w / 2, edgeBinary)
+ if edgeVal is None:
+ edgeVal = 0.0
- RightVertOffset = -( row.z - (row.h/2)*edgeBinary - edgeVal )
+ RightVertOffset = -(row.z - (row.h / 2) * edgeBinary - edgeVal)
- #Wedges are on top = off, blank, off, blank
- #Wedges are on btm = blank, off, blank, off
- ThisBlockOffsets = [[0,0,LeftVertOffset]]*2 + [[0]*3]*2 + [[0,0,RightVertOffset]]*2
+ # Wedges are on top = off, blank, off, blank
+ # Wedges are on btm = blank, off, blank, off
+ ThisBlockOffsets = [[0, 0, LeftVertOffset]] * 2 + [[0] * 3] * 2 + [[0, 0, RightVertOffset]] * 2
# Instert or append "blank" for top or bottom wedges.
- if edgeBinary == 1: ThisBlockOffsets = ThisBlockOffsets + [[0]*3]*2
- else: ThisBlockOffsets = [[0]*3]*2 + ThisBlockOffsets
+ if edgeBinary == 1:
+ ThisBlockOffsets = ThisBlockOffsets + [[0] * 3] * 2
+ else:
+ ThisBlockOffsets = [[0] * 3] * 2 + ThisBlockOffsets
- row.BlocksEdge.append([x,row.z,w,row.h,ThisBlockDepth,ThisBlockOffsets])
+ row.BlocksEdge.append([x, row.z, w, row.h, ThisBlockDepth, ThisBlockOffsets])
return None
+
def bevelBlockOffsets(offsets, bevel, side):
"""
Take the block offsets and modify it for the correct bevel.
@@ -878,45 +895,50 @@ def bevelBlockOffsets(offsets, bevel, side):
bevel = how much to offset the edge
side = -1 for left (right side), 1 for right (left side)
"""
-# left = (4,6)
-# right = (0,2)
- if side == 1: pointsToAffect = (0,2) # right
- else: pointsToAffect = (4,6) # left
+ if side == 1:
+ pointsToAffect = (0, 2) # right
+ else:
+ pointsToAffect = (4, 6) # left
for num in pointsToAffect:
offsets[num] = offsets[num][:]
offsets[num][0] += bevel * side
+
def rowProcessing(row, Thesketch, WallBoundaries):
__doc__ = """\
Take row and opening data and process a single row, adding edge and fill blocks to the row data.
"""
- #set end blocks
- #check for openings, record top and bottom of row for right and left of each
- #if both top and bottom intersect create blocks on each edge, appropriate to the size of the overlap
- #if only one side intersects, run fill to get edge positions, but this should never happen
- #
-
- if radialized:#this checks for radial stonework, and sets the row radius if required
- if slope: r1 = abs(dims['t']*sin(row.z*PI/(dims['t']*2)))
- else: r1 = abs(row.z)
- else: r1 = 1
+ # set end blocks
+ # check for openings, record top and bottom of row for right and left of each
+ # if both top and bottom intersect create blocks on each edge, appropriate to the size of the overlap
+ # if only one side intersects, run fill to get edge positions, but this should never happen
+
+ if radialized: # this checks for radial stonework, and sets the row radius if required
+ if slope:
+ r1 = abs(dims['t'] * sin(row.z * PI / (dims['t'] * 2)))
+ else:
+ r1 = abs(row.z)
+ else:
+ r1 = 1
# set the edge grout thickness, especially with radial stonework in mind
- edgrt = settings['ge']*(settings['g']/2 + rndc()*settings['gv'])/(2*r1)
+ edgrt = settings['ge'] * (settings['g'] / 2 + rndc() * settings['gv']) / (2 * r1)
# Sets up a list of intersections of top of row with openings,
- #from left to right [left edge of opening, right edge of opening, etc...]
- #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]]
+ # from left to right [left edge of opening, right edge of opening, etc...]
+ # 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]]
# set up some useful values for the top and bottom of the rows.
- rowTop = row.z+row.h/2
- rowBtm = row.z-row.h/2
+ rowTop = row.z + row.h / 2
+ rowBtm = row.z - row.h / 2
for hole in Thesketch:
- #check the top and bottom of the row, looking at the opening from the right
+ # check the top and bottom of the row, looking at the opening from the right
e = [hole.edgeS(rowTop, -1), hole.edgeS(rowBtm, -1)]
# If either one hit the opening, make split points for the left side of the opening.
@@ -925,14 +947,15 @@ def rowProcessing(row, Thesketch, WallBoundaries):
# If one of them missed for some reason, set that value to
# the middle of the opening.
- for i,pos in enumerate(e):
- if pos == None: e[i] = hole.x
+ for i, pos in enumerate(e):
+ if pos is None:
+ e[i] = hole.x
# add the intersects to the list of edge points
- edgetop.append([e[0],hole])
- edgetop.append([e[2],hole])
- edgebtm.append([e[1],hole])
- edgebtm.append([e[3],hole])
+ edgetop.append([e[0], hole])
+ edgetop.append([e[2], hole])
+ edgebtm.append([e[1], hole])
+ edgebtm.append([e[3], hole])
# 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
@@ -940,271 +963,284 @@ def rowProcessing(row, Thesketch, WallBoundaries):
edgetop.sort()
edgebtm.sort()
- #these two loops trim the edges to the limits of the wall. This way openings extending outside the wall don't enlarge the wall.
+ # these two loops trim the edges to the limits of the wall.
+ # This way openings extending outside the wall don't enlarge the wall.
while True:
try:
- if (edgetop[-1][0] > dims['e']+row.EdgeOffset/r1) or (edgebtm[-1][0] > dims['e']+row.EdgeOffset/r1):
+ if ((edgetop[-1][0] > dims['e'] + row.EdgeOffset / r1) or
+ (edgebtm[-1][0] > dims['e'] + row.EdgeOffset / r1)):
edgetop[-2:] = []
edgebtm[-2:] = []
- else: break
- except IndexError: break
- #still trimming the edges...
+ else:
+ break
+ except IndexError:
+ break
+ # still trimming the edges...
while True:
try:
- if (edgetop[0][0] < dims['s']+row.EdgeOffset/r1) or (edgebtm[0][0] < dims['s']+row.EdgeOffset/r1):
+ if ((edgetop[0][0] < dims['s'] + row.EdgeOffset / r1) or
+ (edgebtm[0][0] < dims['s'] + row.EdgeOffset / r1)):
edgetop[:2] = []
edgebtm[:2] = []
- else: break
- except IndexError: break
-
- #make those edge blocks and rows! Wooo!
- #This loop goes through each section, (a pair of points in edgetop)
- #and places the edge blocks and inbetween normal block zones into the row object
- for OpnSplitNo in range(int(len(edgetop)/2)):
- #left edge is edge<x>[2*OpnSplitNo], right edge edgex[2*OpnSplitNo+1]
- leftEdgeIndex = 2*OpnSplitNo
- rightEdgeIndex = 2*OpnSplitNo + 1
+ else:
+ break
+ except IndexError:
+ break
+
+ # make those edge blocks and rows! Wooo!
+ # This loop goes through each section, (a pair of points in edgetop)
+ # and places the edge blocks and inbetween normal block zones into the row object
+ for OpnSplitNo in range(int(len(edgetop) / 2)):
+ # left edge is edge<x>[2*OpnSplitNo], right edge edgex[2*OpnSplitNo+1]
+ leftEdgeIndex = 2 * OpnSplitNo
+ rightEdgeIndex = 2 * OpnSplitNo + 1
+
# get the openings, to save time and confusion
leftOpening = edgetop[leftEdgeIndex][1]
rightOpening = edgetop[rightEdgeIndex][1]
- #find the difference between the edge top and bottom on both sides
+
+ # find the difference between the edge top and bottom on both sides
LTop = edgetop[leftEdgeIndex][0]
LBtm = edgebtm[leftEdgeIndex][0]
RTop = edgetop[rightEdgeIndex][0]
RBtm = edgebtm[rightEdgeIndex][0]
- LDiff = LBtm-LTop
- RDiff = RTop-RBtm
+ LDiff = LBtm - LTop
+ RDiff = RTop - RBtm
- #which is furthur out on each side, top or bottom?
+ # which is furthur out on each side, top or bottom?
if LDiff > 0:
- LFarEdge = LTop #The furthest edge left
- LNerEdge = LBtm #the nearer edge left
- LEB = 1 #Left Edge Boolean, set to 1 if furthest edge is top, -1 if it is bottom
+ LNerEdge = LBtm # the nearer edge left
+ LEB = 1 # Left Edge Boolean, set to 1 if furthest edge is top, -1 if it is bottom
else:
- LFarEdge = LBtm
LNerEdge = LTop
LEB = -1
if RDiff > 0:
- RFarEdge = RTop #The furthest edge right
- RNerEdge = RBtm #the nearer edge right
- REB = 1 #Right Edge Boolean, set to 1 if furthest edge is top, -1 if it is bottom
+ RNerEdge = RBtm # the nearer edge right
+ REB = 1 # Right Edge Boolean, set to 1 if furthest edge is top, -1 if it is bottom
else:
- RFarEdge = RBtm #The furthest edge right
RNerEdge = RTop
- REB = -1 #Right Edge Boolean, set to 1 if furthest edge is top, -1 if it is bottom
+ REB = -1 # Right Edge Boolean, set to 1 if furthest edge is top, -1 if it is bottom
- #The space between the closest edges of the openings in this section of the row
+ # The space between the closest edges of the openings in this section of the row
InnerDiff = RNerEdge - LNerEdge
- #The mid point between the nearest edges
- InnerMid = (RNerEdge + LNerEdge)/2
+ # The mid point between the nearest edges
+ InnerMid = (RNerEdge + LNerEdge) / 2
- #maximum distance to span with one block
- MaxWid = (settings['w']+settings['wv'])/r1
+ # maximum distance to span with one block
+ MaxWid = (settings['w'] + settings['wv']) / r1
AveWid = settings['w']
- MinWid = settings['wm']
- #check the left and right sides for wedge blocks
- #Check and run the left edge first
- #find the edge of the correct side, offset for minimum block height. The LEB decides top or bottom
- ZPositionCheck = row.z + (row.h/2-settings['hm'])*LEB
-#edgeS may return "None"
- LeftWedgeEdge = leftOpening.edgeS(ZPositionCheck,1)
+ # check the left and right sides for wedge blocks
+ # Check and run the left edge first
+ # find the edge of the correct side, offset for minimum block height. The LEB decides top or bottom
+ ZPositionCheck = row.z + (row.h / 2 - settings['hm']) * LEB
+
+ # edgeS may return "None"
+ LeftWedgeEdge = leftOpening.edgeS(ZPositionCheck, 1)
if (abs(LDiff) > AveWid) or (not LeftWedgeEdge):
- #make wedge blocks
- if not LeftWedgeEdge: LeftWedgeEdge = leftOpening.x
+ # make wedge blocks
+ if not LeftWedgeEdge:
+ LeftWedgeEdge = leftOpening.x
wedgeBlocks(row, leftOpening, LeftWedgeEdge, LNerEdge, LEB, r1)
- #set the near and far edge settings to vertical, so the other edge blocks don't interfere
- LFarEdge , LTop , LBtm = LNerEdge, LNerEdge, LNerEdge
+ # set the near and far edge settings to vertical, so the other edge blocks don't interfere
+ LTop, LBtm = LNerEdge, LNerEdge
LDiff = 0
- #Now do the wedge blocks for the right, same drill... repeated code?
- #find the edge of the correct side, offset for minimum block height. The REB decides top or bottom
- ZPositionCheck = row.z + (row.h/2-settings['hm'])*REB
-#edgeS may return "None"
- RightWedgeEdge = rightOpening.edgeS(ZPositionCheck,-1)
+ # Now do the wedge blocks for the right, same drill... repeated code?
+ # find the edge of the correct side, offset for minimum block height. The REB decides top or bottom
+ ZPositionCheck = row.z + (row.h / 2 - settings['hm']) * REB
+
+ # edgeS may return "None"
+ RightWedgeEdge = rightOpening.edgeS(ZPositionCheck, -1)
if (abs(RDiff) > AveWid) or (not RightWedgeEdge):
- #make wedge blocks
- if not RightWedgeEdge: RightWedgeEdge = rightOpening.x
+ # make wedge blocks
+ if not RightWedgeEdge:
+ RightWedgeEdge = rightOpening.x
wedgeBlocks(row, rightOpening, RNerEdge, RightWedgeEdge, REB, r1)
- #set the near and far edge settings to vertical, so the other edge blocks don't interfere
- RFarEdge , RTop , RBtm = RNerEdge, RNerEdge, RNerEdge
+ # set the near and far edge settings to vertical, so the other edge blocks don't interfere
+ RTop, RBtm = RNerEdge, RNerEdge
RDiff = 0
- #Check to see if the edges are close enough toegther to warrant a single block filling it
+ # Check to see if the edges are close enough toegther to warrant a single block filling it
if (InnerDiff < MaxWid):
- #if this is true, then this row is just one block!
- x = (LNerEdge + RNerEdge)/2.
+ # if this is true, then this row is just one block!
+ x = (LNerEdge + RNerEdge) / 2.
w = InnerDiff
- ThisBlockDepth = rndd()*settings['dv']+settings['d']
+ ThisBlockDepth = rndd() * settings['dv'] + settings['d']
BtmOff = LBtm - LNerEdge
TopOff = LTop - LNerEdge
- ThisBlockOffsets = [[BtmOff,0,0]]*2 + [[TopOff,0,0]]*2
+ ThisBlockOffsets = [[BtmOff, 0, 0]] * 2 + [[TopOff, 0, 0]] * 2
BtmOff = RBtm - RNerEdge
TopOff = RTop - RNerEdge
- ThisBlockOffsets += [[BtmOff,0,0]]*2 + [[TopOff,0,0]]*2
+ ThisBlockOffsets += [[BtmOff, 0, 0]] * 2 + [[TopOff, 0, 0]] * 2
bevel = leftOpening.edgeBev(rowTop)
bevelBlockOffsets(ThisBlockOffsets, bevel, 1)
bevel = rightOpening.edgeBev(rowTop)
bevelBlockOffsets(ThisBlockOffsets, bevel, -1)
- row.BlocksEdge.append([x,row.z,w,row.h,ThisBlockDepth,ThisBlockOffsets])
+ row.BlocksEdge.append([x, row.z, w, row.h, ThisBlockDepth, ThisBlockOffsets])
continue
# it's not one block, must be two or more
# set up the offsets for the left
BtmOff = LBtm - LNerEdge
TopOff = LTop - LNerEdge
- leftOffsets = [[BtmOff,0,0]]*2 + [[TopOff,0,0]]*2 + [[0]*3]*4
+ leftOffsets = [[BtmOff, 0, 0]] * 2 + [[TopOff, 0, 0]] * 2 + [[0] * 3] * 4
bevelL = leftOpening.edgeBev(rowTop)
bevelBlockOffsets(leftOffsets, bevelL, 1)
# and now for the right
BtmOff = RBtm - RNerEdge
TopOff = RTop - RNerEdge
- rightOffsets = [[0]*3]*4 + [[BtmOff,0,0]]*2 + [[TopOff,0,0]]*2
+ rightOffsets = [[0] * 3] * 4 + [[BtmOff, 0, 0]] * 2 + [[TopOff, 0, 0]] * 2
bevelR = rightOpening.edgeBev(rowTop)
bevelBlockOffsets(rightOffsets, bevelR, -1)
# check to see if it is only two blocks
- if (InnerDiff < MaxWid*2):
- #this row is just two blocks! Left block, then right block
- #div is the x position of the dividing point between the two bricks
- div = InnerMid + (rndd()*settings['wv'])/r1
- #set the grout distance, since we need grout seperation between the blocks
- grt = (settings['g'] + rndc()*settings['gv'])/r1
- #set the x position and width for the left block
- x = (div + LNerEdge)/2 - grt/4
- w = (div - LNerEdge) - grt/2
- ThisBlockDepth = rndd()*settings['dv']+settings['d']
- #For reference: EdgeBlocks = [[x,z,w,h,d,[corner offset matrix]],[etc.]]
- row.BlocksEdge.append([x,row.z,w,row.h,ThisBlockDepth,leftOffsets])
- #Initialize for the block on the right side
- x = (div + RNerEdge)/2 + grt/4
- w = (RNerEdge - div) - grt/2
- ThisBlockDepth = rndd()*settings['dv']+settings['d']
- row.BlocksEdge.append([x,row.z,w,row.h,ThisBlockDepth,rightOffsets])
+ if (InnerDiff < MaxWid * 2):
+ # this row is just two blocks! Left block, then right block
+ # div is the x position of the dividing point between the two bricks
+ div = InnerMid + (rndd() * settings['wv']) / r1
+ # set the grout distance, since we need grout seperation between the blocks
+ grt = (settings['g'] + rndc() * settings['gv']) / r1
+ # set the x position and width for the left block
+ x = (div + LNerEdge) / 2 - grt / 4
+ w = (div - LNerEdge) - grt / 2
+ ThisBlockDepth = rndd() * settings['dv'] + settings['d']
+ # For reference: EdgeBlocks = [[x, z, w, h, d, [corner offset matrix]], [etc.]]
+ row.BlocksEdge.append([x, row.z, w, row.h, ThisBlockDepth, leftOffsets])
+ # Initialize for the block on the right side
+ x = (div + RNerEdge) / 2 + grt / 4
+ w = (RNerEdge - div) - grt / 2
+ ThisBlockDepth = rndd() * settings['dv'] + settings['d']
+ row.BlocksEdge.append([x, row.z, w, row.h, ThisBlockDepth, rightOffsets])
continue
- #program should only get here if there are more than two blocks in the row, and no wedge blocks
-
- #make Left edge block
- #set the grout
- grt = (settings['g'] + rndc()*settings['gv'])/r1
- #set the x position and width for the left block
+ # program should only get here if there are more than two blocks in the row, and no wedge blocks
+ # make Left edge block
+ # set the grout
+ grt = (settings['g'] + rndc() * settings['gv']) / r1
+ # set the x position and width for the left block
widOptions = [settings['w'], bevelL + settings['wm'], leftOpening.ts]
baseWid = max(widOptions)
- w = (rndd()*settings['wv']+baseWid+row.EdgeOffset)
+ w = (rndd() * settings['wv'] + baseWid + row. EdgeOffset)
widOptions[0] = settings['wm']
widOptions[2] = w
w = max(widOptions) / r1 - grt
- x = w/2 + LNerEdge + grt/2
- BlockRowL = x + w/2
- ThisBlockDepth = rndd()*settings['dv']+settings['d']
- row.BlocksEdge.append([x,row.z,w,row.h,ThisBlockDepth,leftOffsets])
-
- #make Right edge block
- #set the grout
- grt = (settings['g'] + rndc()*settings['gv'])/r1
- #set the x position and width for the left block
+ x = w / 2 + LNerEdge + grt / 2
+ BlockRowL = x + w / 2
+ ThisBlockDepth = rndd() * settings['dv'] + settings['d']
+ row.BlocksEdge.append([x, row.z, w, row.h, ThisBlockDepth, leftOffsets])
+
+ # make Right edge block
+ # set the grout
+ grt = (settings['g'] + rndc() * settings['gv']) / r1
+ # set the x position and width for the left block
widOptions = [settings['w'], bevelR + settings['wm'], rightOpening.ts]
baseWid = max(widOptions)
- w = (rndd()*settings['wv']+baseWid+row.EdgeOffset)
+ w = (rndd() * settings['wv'] + baseWid + row.EdgeOffset)
widOptions[0] = settings['wm']
widOptions[2] = w
w = max(widOptions) / r1 - grt
- x = RNerEdge - w/2 - grt/2
- BlockRowR = x - w/2
- ThisBlockDepth = rndd()*settings['dv']+settings['d']
- row.BlocksEdge.append([x,row.z,w,row.h,ThisBlockDepth,rightOffsets])
+ x = RNerEdge - w / 2 - grt / 2
+ BlockRowR = x - w / 2
+ ThisBlockDepth = rndd() * settings['dv'] + settings['d']
+ row.BlocksEdge.append([x, row.z, w, row.h, ThisBlockDepth, rightOffsets])
- row.RowSegments.append([BlockRowL,BlockRowR])
+ row.RowSegments.append([BlockRowL, BlockRowR])
return None
-def plan(Thesketch, oldrows = 0):
+def plan(Thesketch, oldrows=0):
__doc__ = """\
The 'plan' function takes the data generated by the sketch function and the global settings
and creates a list of blocks.
It passes out a list of row heights, edge positions, edge blocks, and rows of blocks.
"""
# if we were passed a list of rows already, use those; else make a list.
- if oldrows: rows = oldrows
+ if oldrows:
+ rows = oldrows
else:
- #rows holds the important information common to all rows
- #rows = [list of row objects]
+ # rows holds the important information common to all rows
+ # rows = [list of row objects]
rows = []
- #splits are places where we NEED a row division, to accomidate openings
- #add a split for the bottom row
- splits = [dims['b']+settings['hb']]
+ # splits are places where we NEED a row division, to accomidate openings
+ # add a split for the bottom row
+ splits = [dims['b'] + settings['hb']]
- #add a split for each critical point on each opening
- for hole in Thesketch: splits += hole.crits()
+ # add a split for each critical point on each opening
+ for hole in Thesketch:
+ splits += hole.crits()
- #and, a split for the top row
- splits.append(dims['t']-settings['ht'])
+ # and, a split for the top row
+ splits.append(dims['t'] - settings['ht'])
splits.sort()
- #divs are the normal old row divisions, add them between the top and bottom split
- divs = fill(splits[0],splits[-1],settings['h'],settings['hm']+settings['g'],settings['hv'])[1:-1]
+ # divs are the normal old row divisions, add them between the top and bottom split
+ divs = fill(splits[0], splits[-1], settings['h'], settings['hm'] + settings['g'], settings['hv'])[1: -1]
- #remove the divisions that are too close to the splits, so we don't get tiny thin rows
- for i in range(len(divs)-1,-1,-1):
+ # remove the divisions that are too close to the splits, so we don't get tiny thin rows
+ for i in range(len(divs) - 1, -1, -1):
for j in range(len(splits)):
diff = abs(divs[i] - splits[j])
- #(settings['hm']+settings['g']) is the old minimum value
- if diff < (settings['h']-settings['hv']+settings['g']):
+ if diff < (settings['h'] - settings['hv'] + settings['g']):
del(divs[i])
break
- #now merge the divs and splits lists
+ # now merge the divs and splits lists
divs += splits
- #add bottom and/or top points, if bottom and/or top row heights are more than zero
- if settings['hb']>0: divs.insert(0,dims['b'])
- if settings['ht']>0: divs.append(dims['t'])
+ # add bottom and/or top points, if bottom and/or top row heights are more than zero
+ if settings['hb'] > 0:
+ divs.insert(0, dims['b'])
+ if settings['ht'] > 0:
+ divs.append(dims['t'])
divs.sort()
- #trim the rows to the bottom and top of the wall
- if divs[0] < dims['b']: divs[:1] = []
- if divs[-1] > dims['t']: divs[-1:] = []
+ # trim the rows to the bottom and top of the wall
+ if divs[0] < dims['b']:
+ divs[:1] = []
+ if divs[-1] > dims['t']:
+ divs[-1:] = []
- #now, make the data for each row
- #rows = [[center height,row height,edge offset],[etc.]]
+ # now, make the data for each row
+ # rows = [[center height,row height,edge offset],[etc.]]
- divCount = len(divs)-1 # number of divs to check
- divCheck = 0 # current div entry
+ divCount = len(divs) - 1 # number of divs to check
+ divCheck = 0 # current div entry
while divCheck < divCount:
- RowZ = (divs[divCheck]+divs[divCheck+1])/2
- RowHeight = divs[divCheck+1]-divs[divCheck]-settings['g']+rndc()*settings['rwhl']*settings['gv']
- EdgeOffset = settings['eoff']*(fmod(divCheck,2)-0.5)+settings['eoffv']*rndd()
+ RowZ = (divs[divCheck] + divs[divCheck + 1]) / 2
+ RowHeight = divs[divCheck + 1] - divs[divCheck] - settings['g'] + rndc() * \
+ settings['rwhl'] * settings['gv']
+ EdgeOffset = settings['eoff'] * (fmod(divCheck, 2) - 0.5) + settings['eoffv'] * rndd()
# if row height is too shallow: delete next div entry, decrement total, and recheck current entry.
if RowHeight < settings['hm']:
- del(divs[divCheck+1])
- divCount -= 1 # Adjust count for removed div entry.
+ del(divs[divCheck + 1])
+ divCount -= 1 # Adjust count for removed div entry.
continue
rows.append(rowOb(RowZ, RowHeight, EdgeOffset))
- divCheck += 1 # on to next div entry
+ divCheck += 1 # on to next div entry
- #set up a special opening object to handle the edges of the wall
- x = (dims['s'] + dims['e'])/2
- z = (dims['t'] + dims['b'])/2
+ # set up a special opening object to handle the edges of the wall
+ x = (dims['s'] + dims['e']) / 2
+ z = (dims['t'] + dims['b']) / 2
w = (dims['e'] - dims['s'])
h = (dims['t'] - dims['b'])
- WallBoundaries = OpeningInv(x,z,w,h)
+ WallBoundaries = OpeningInv(x, z, w, h)
- #Go over each row in the list, set up edge blocks and block sections
+ # Go over each row in the list, set up edge blocks and block sections
for rownum in range(len(rows)):
rowProcessing(rows[rownum], Thesketch, WallBoundaries)
- #now return the things everyone needs
- #return [rows,edgeBlocks,blockRows,Asketch]
- return [rows,Thesketch]
+ # now return the things everyone needs
+ # return [rows,edgeBlocks,blockRows,Asketch]
+ return [rows, Thesketch]
def archGeneration(hole, vlist, flist, sideSign):
@@ -1226,17 +1262,17 @@ def archGeneration(hole, vlist, flist, sideSign):
# Top (1) or bottom (-1)
if sideSign == -1:
- r = hole.rl #radius of the arch
- rt = hole.rtl #thickness of the arch (stone height)
- v = hole.vl #height of the arch
+ r = hole.rl # radius of the arch
+ rt = hole.rtl # thickness of the arch (stone height)
+ v = hole.vl # height of the arch
c = hole.cl
else:
- r = hole.r #radius of the arch
- rt = hole.rt #thickness of the arch (stone height)
- v = hole.v #height of the arch
+ r = hole.r # radius of the arch
+ rt = hole.rt # thickness of the arch (stone height)
+ v = hole.v # height of the arch
c = hole.c
- ra = r + rt/2 #average radius of the arch
+ ra = r + rt / 2 # average radius of the arch
x = hole.x
w = hole.w
h = hole.h
@@ -1244,156 +1280,173 @@ def archGeneration(hole, vlist, flist, sideSign):
bev = hole.b
sideSignInv = -sideSign
- if v > w/2: #two arcs, to make a pointed arch
+ if v > w / 2: # two arcs, to make a pointed arch
# positioning
- zpos = z + (h/2)*sideSign
- xoffset = r - w/2
- #left side top, right side bottom
- #angles reference straight up, and are in radians
+ zpos = z + (h / 2) * sideSign
+ xoffset = r - w / 2
+ # left side top, right side bottom
+ # angles reference straight up, and are in radians
bevRad = r + bev
- bevHt = sqrt(bevRad**2 - (bevRad - (w/2 + bev))**2)
- midHalfAngle = atan(v/(r-w/2))
- midHalfAngleBevel = atan(bevHt/(r-w/2))
+ bevHt = sqrt(bevRad ** 2 - (bevRad - (w / 2 + bev)) ** 2)
+ midHalfAngle = atan(v / (r - w / 2))
+ midHalfAngleBevel = atan(bevHt / (r - w / 2))
bevelAngle = midHalfAngle - midHalfAngleBevel
- anglebeg = (PI/2)*(sideSignInv)
- angleend = (PI/2)*(sideSignInv) + midHalfAngle
+ anglebeg = (PI / 2) * (sideSignInv)
+ angleend = (PI / 2) * (sideSignInv) + midHalfAngle
- avlist,aflist = arch(ra,rt,(xoffset)*(sideSign),zpos,anglebeg,angleend,bev,bevelAngle,len(vlist))
+ avlist, aflist = arch(ra, rt, (xoffset) * (sideSign), zpos, anglebeg, angleend, bev, bevelAngle, len(vlist))
- for i,vert in enumerate(avlist): avlist[i] = [vert[0]+hole.x,vert[1],vert[2]]
+ for i, vert in enumerate(avlist):
+ avlist[i] = [vert[0] + hole.x, vert[1], vert[2]]
vlist += avlist
flist += aflist
- #right side top, left side bottom
+ # right side top, left side bottom
- #angles reference straight up, and are in radians
- anglebeg = (PI/2)*(sideSign) - midHalfAngle
- angleend = (PI/2)*(sideSign)
+ # angles reference straight up, and are in radians
+ anglebeg = (PI / 2) * (sideSign) - midHalfAngle
+ angleend = (PI / 2) * (sideSign)
- avlist,aflist = arch(ra,rt,(xoffset)*(sideSignInv),zpos,anglebeg,angleend,bev,bevelAngle,len(vlist))
+ avlist, aflist = arch(ra, rt, (xoffset) * (sideSignInv), zpos, anglebeg, angleend, bev, bevelAngle, len(vlist))
- for i,vert in enumerate(avlist): avlist[i] = [vert[0]+hole.x,vert[1],vert[2]]
+ for i, vert in enumerate(avlist):
+ avlist[i] = [vert[0] + hole.x, vert[1], vert[2]]
vlist += avlist
flist += aflist
- #keystone
- Dpth = settings['d']+rndc()*settings['dv']
- Grout = settings['g'] + rndc()*settings['gv']
- angleBevel = (PI/2)*(sideSign) - midHalfAngle
- Wdth = (rt - Grout - bev) * 2 * sin(angleBevel) * sideSign #note, sin may be negative
- MidZ = ((sideSign)*(bevHt + h/2.0) + z) + (rt - Grout - bev) * cos(angleBevel) #note, cos may come out negative too
- nearCorner = sideSign*(MidZ - z) - v - h/2
+ # keystone
+ Dpth = settings['d'] + rndc() * settings['dv']
+ Grout = settings['g'] + rndc() * settings['gv']
+ angleBevel = (PI / 2) * (sideSign) - midHalfAngle
+ Wdth = (rt - Grout - bev) * 2 * sin(angleBevel) * sideSign # note, sin may be negative
+ MidZ = ((sideSign) * (bevHt + h / 2.0) + z) + (rt - Grout - bev) \
+ * cos(angleBevel) # note, cos may come out negative
+ nearCorner = sideSign * (MidZ - z) - v - h / 2
if sideSign == 1:
TopHt = hole.top() - MidZ - Grout
BtmHt = nearCorner
else:
- BtmHt = - (hole.btm() - MidZ) - Grout
+ BtmHt = - (hole.btm() - MidZ) - Grout
TopHt = nearCorner
# set the amout to bevel the keystone
- keystoneBevel = (bevHt - v)*sideSign
+ keystoneBevel = (bevHt - v) * sideSign
if Wdth >= settings['hm']:
- avlist,aflist = MakeAKeystone(x, Wdth, MidZ, TopHt, BtmHt, Dpth, keystoneBevel, len(vlist))
+ avlist, aflist = MakeAKeystone(x, Wdth, MidZ, TopHt, BtmHt, Dpth, keystoneBevel, len(vlist))
if radialized:
- for i,vert in enumerate(avlist):
- if slope: r1 = dims['t']*sin(vert[2]*PI/(dims['t']*2))
- else: r1 = vert[2]
- avlist[i] = [((vert[0]-hole.x)/r1)+hole.x,vert[1],vert[2]]
+ for i, vert in enumerate(avlist):
+ if slope:
+ r1 = dims['t'] * sin(vert[2] * PI / (dims['t'] * 2))
+ else:
+ r1 = vert[2]
+ avlist[i] = [((vert[0] - hole.x) / r1) + hole.x, vert[1], vert[2]]
vlist += avlist
flist += aflist
-# remove "debug note" once bevel is finalized.
- else: print("keystone was too narrow - " + str(Wdth))
+ # remove "debug note" once bevel is finalized.
+ else:
+ print("keystone was too narrow - " + str(Wdth))
- else: # only one arc - curve not peak.
-#bottom (sideSign -1) arch has poorly sized blocks...
+ else: # only one arc - curve not peak.
+ # bottom (sideSign -1) arch has poorly sized blocks...
- zpos = z + (sideSign * (h/2 + v - r)) # single arc positioning
+ zpos = z + (sideSign * (h / 2 + v - r)) # single arc positioning
- #angles reference straight up, and are in radians
- if sideSign == -1: angleOffset = PI
- else: angleOffset = 0.0
+ # angles reference straight up, and are in radians
+ if sideSign == -1:
+ angleOffset = PI
+ else:
+ angleOffset = 0.0
- if v < w/2:
- halfangle = atan(w/(2*(r-v)))
+ if v < w / 2:
+ halfangle = atan(w / (2 * (r - v)))
anglebeg = angleOffset - halfangle
angleend = angleOffset + halfangle
else:
- anglebeg = angleOffset - PI/2
- angleend = angleOffset + PI/2
+ anglebeg = angleOffset - PI / 2
+ angleend = angleOffset + PI / 2
- avlist,aflist = arch(ra,rt,0,zpos,anglebeg,angleend,bev,0.0,len(vlist))
+ avlist, aflist = arch(ra, rt, 0, zpos, anglebeg, angleend, bev, 0.0, len(vlist))
- for i,vert in enumerate(avlist): avlist[i] = [vert[0]+x,vert[1],vert[2]]
+ for i, vert in enumerate(avlist):
+ avlist[i] = [vert[0] + x, vert[1], vert[2]]
vlist += avlist
flist += aflist
- #Make the Side Stones
- grt = (settings['g'] + rndc()*settings['gv'])
- width = sqrt(rt**2 - c**2) - grt
+ # Make the Side Stones
+ grt = (settings['g'] + rndc() * settings['gv'])
+ width = sqrt(rt ** 2 - c ** 2) - grt
if c > settings['hm'] + grt and c < width + grt:
- if radialized: subdivision = settings['sdv'] * (zpos + (h/2)*sideSign)
- else: subdivision = settings['sdv']
+ if radialized:
+ subdivision = settings['sdv'] * (zpos + (h / 2) * sideSign)
+ else:
+ subdivision = settings['sdv']
- #set the height of the block, it should be as high as the max corner position, minus grout
- height = c - grt*(0.5 + c/(width + grt))
+ # set the height of the block, it should be as high as the max corner position, minus grout
+ height = c - grt * (0.5 + c / (width + grt))
- #the vertical offset for the short side of the block
+ # the vertical offset for the short side of the block
voff = sideSign * (settings['hm'] - height)
- xstart = w/2
- zstart = z + sideSign * (h/2 + grt/2)
- woffset = width*(settings['hm'] + grt/2)/(c - grt/2)
- depth = rndd()*settings['dv']+settings['d']
+ xstart = w / 2
+ zstart = z + sideSign * (h / 2 + grt / 2)
+ woffset = width * (settings['hm'] + grt / 2) / (c - grt / 2)
+ depth = rndd() * settings['dv'] + settings['d']
if sideSign == 1:
- offsets = [[0]*3]*6 + [[0]*2 + [voff]]*2
- topSide = zstart+height
+ offsets = [[0] * 3] * 6 + [[0] * 2 + [voff]] * 2
+ topSide = zstart + height
btmSide = zstart
else:
- offsets = [[0]*3]*4 + [[0]*2 + [voff]]*2 + [[0]*3]*2
+ offsets = [[0] * 3] * 4 + [[0] * 2 + [voff]] * 2 + [[0] * 3] * 2
topSide = zstart
- btmSide = zstart-height
+ btmSide = zstart - height
# 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"
+ # top didn't use radialized in prev version;
+ # just noting for clarity - may need to revise for "sideSign == 1"
if radialized:
- for i,vert in enumerate(avlist): avlist[i] = [((vert[0]-x)/vert[2])+x,vert[1],vert[2]]
+ for i, vert in enumerate(avlist):
+ avlist[i] = [((vert[0] - x) / vert[2]) + x, vert[1], vert[2]]
vlist += avlist
flist += aflist
-# keep sizing same - neat arches = master masons :)
-# grt = (settings['g'] + rndc()*settings['gv'])
-# height = c - grt*(0.5 + c/(width + grt))
-# if grout varies may as well change width too... width = sqrt(rt**2 - c**2) - grt
-# voff = sideSign * (settings['hm'] - height)
-# woffset = width*(settings['hm'] + grt/2)/(c - grt/2)
+ # keep sizing same - neat arches = master masons :)
+ # grt = (settings['g'] + rndc()*settings['gv'])
+ # height = c - grt*(0.5 + c/(width + grt))
+ # if grout varies may as well change width too... width = sqrt(rt**2 - c**2) - grt
+ # voff = sideSign * (settings['hm'] - height)
+ # woffset = width*(settings['hm'] + grt/2)/(c - grt/2)
if sideSign == 1:
- offsets = [[0]*3]*2 + [[0]*2 + [voff]]*2 + [[0]*3]*4
- topSide = zstart+height
+ offsets = [[0] * 3] * 2 + [[0] * 2 + [voff]] * 2 + [[0] * 3] * 4
+ topSide = zstart + height
btmSide = zstart
else:
- offsets = [[0]*2 + [voff]]*2 + [[0]*3]*6
+ offsets = [[0] * 2 + [voff]] * 2 + [[0] * 3] * 6
topSide = zstart
- btmSide = zstart-height
+ btmSide = zstart - height
# 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"
+ # top didn't use radialized in prev version;
+ # just noting for clarity - may need to revise for "sideSign == 1"
if radialized:
- for i,vert in enumerate(avlist): avlist[i] = [((vert[0]-x)/vert[2])+x,vert[1],vert[2]]
+ for i, vert in enumerate(avlist):
+ avlist[i] = [((vert[0] - x) / vert[2]) + x, vert[1], vert[2]]
vlist += avlist
flist += aflist
@@ -1408,102 +1461,70 @@ def build(Aplan):
physics interaction enabled. Otherwise it creates
geometry for the blocks, arches, etc. of the wall.
"""
-
vlist = []
flist = []
rows = Aplan[0]
-#dead code...
- #Physics setup is horribly broken. Revisit when new API is in place.
- '''if False: #settings['physics']:
- geom = MakeABlock([-0.5,0.5,-0.5,0.5,-0.5,0.5], 3, 0, None,[], 3*settings['b']/(settings['w'] + settings['h'] + settings['d']))
- blockmesh = Blender.Mesh.New('block')
- vlist += geom[0]
- flist += geom[1]
- blockmesh.verts.extend(vlist)
- blockmesh.faces.extend(flist)
-
- for block in Aplan[1]:
- x,z,w,h,d = block[:5]
- block = scn.objects.new(blockmesh, 'block')
- block.loc = [x, 0, z]
- block.size = [w,d,h]
- block.rbFlags = Blender.Object.RBFlags['BOUNDS'] | Blender.Object.RBFlags['ACTOR'] | Blender.Object.RBFlags['DYNAMIC'] | Blender.Object.RBFlags['RIGIDBODY']
- block.rbShapeBoundType = Blender.Object.RBShapes['BOX']
-
-
- for row in Aplan[2]:#row=[xstart,xend,z,h]
- #currently, radial geometry is disabled for physics blocks setup
- if radialized:
- if slope: r1 = dims['t']*sin(row[2]*PI/(dims['t']*2))
- else: r1 = row[2]
-
- else: r1 = 1
-
- divs = fill(row[0], row[1], settings['w'], settings['wm'], settings['wv'])
- for i in range(len(divs)-1):
- block = scn.objects.new(blockmesh, 'block')
- block.loc = [(divs[i]+divs[i+1])/2, 0, row[2]]
- block.size = [(divs[i + 1] - divs[i]) - settings['g'], (settings['d'] + rndd()*settings['dv'])*(1-settings['t']*((row[3]-dims['b'])/(dims['t'] - dims['b']))), row[3]]
- block.rbFlags = Blender.Object.RBFlags['BOUNDS'] | Blender.Object.RBFlags['ACTOR'] | Blender.Object.RBFlags['DYNAMIC'] | Blender.Object.RBFlags['RIGIDBODY']
- block.rbShapeBoundType = Blender.Object.RBShapes['BOX']
-
- return None'''
-#end dead code...
-
# all the edge blocks, redacted
- #AllBlocks = [[x,z,w,h,d,[corner offset matrix]],[etc.]]
+ # AllBlocks = [[x, z, w, h, d, [corner offset matrix]], [etc.]]
- #loop through each row, adding the normal old blocks
- for rowidx in range(len(rows)):#row = row object
+ # loop through each row, adding the normal old blocks
+ for rowidx in range(len(rows)):
rows[rowidx].FillBlocks()
AllBlocks = []
# If the wall is set to merge blocks, check all the blocks to see if you can merge any
-#seems to only merge vertical, should do horizontal too
+ # seems to only merge vertical, should do horizontal too
if bigBlock:
- for rowidx in range(len(rows)-1):
+ for rowidx in range(len(rows) - 1):
if radialized:
- if slope: r1 = dims['t']*sin(abs(rows[rowidx].z)*PI/(dims['t']*2))
- else: r1 = abs(rows[rowidx].z)
- else: r1 = 1
+ if slope:
+ r1 = dims['t'] * sin(abs(rows[rowidx].z) * PI / (dims['t'] * 2))
+ else:
+ r1 = abs(rows[rowidx].z)
+ else:
+ r1 = 1
- Tollerance = settings['g']/r1
+ Tollerance = settings['g'] / r1
idxThis = len(rows[rowidx].BlocksNorm[:]) - 1
- idxThat = len(rows[rowidx+1].BlocksNorm[:]) - 1
+ idxThat = len(rows[rowidx + 1].BlocksNorm[:]) - 1
while True:
# end loop when either array idx wraps
- if idxThis < 0 or idxThat < 0: break
+ if idxThis < 0 or idxThat < 0:
+ break
blockThis = rows[rowidx].BlocksNorm[idxThis]
- blockThat = rows[rowidx+1].BlocksNorm[idxThat]
+ blockThat = rows[rowidx + 1].BlocksNorm[idxThat]
-#seems to only merge vertical, should do horizontal too...
+ # seems to only merge vertical, should do horizontal too...
cx, cz, cw, ch, cd = blockThis[:5]
ox, oz, ow, oh, od = blockThat[:5]
- if (abs(cw - ow) < Tollerance) and (abs(cx - ox) < Tollerance) :
- if cw > ow: BlockW = ow
- else: BlockW = cw
+ if (abs(cw - ow) < Tollerance) and (abs(cx - ox) < Tollerance):
+ if cw > ow:
+ BlockW = ow
+ else:
+ BlockW = cw
- AllBlocks.append([(cx+ox)/2,(cz+oz+(oh-ch)/2)/2,BlockW,abs(cz-oz)+(ch+oh)/2,(cd+od)/2,None])
+ AllBlocks.append([(cx + ox) / 2, (cz + oz + (oh - ch) / 2) / 2,
+ BlockW, abs(cz - oz) + (ch + oh) / 2, (cd + od) / 2, None])
rows[rowidx].BlocksNorm.pop(idxThis)
- rows[rowidx+1].BlocksNorm.pop(idxThat)
+ rows[rowidx + 1].BlocksNorm.pop(idxThat)
idxThis -= 1
idxThat -= 1
- elif cx > ox: idxThis -= 1
- else: idxThat -= 1
+ elif cx > ox:
+ idxThis -= 1
+ else:
+ idxThat -= 1
- #
- #
# Add blocks to create a "shelf/platform".
# Does not account for openings (crosses gaps - which is a good thing)
if shelfExt:
- SetGrtOff = settings['g']/2 # half grout for block size modifier
+ SetGrtOff = settings['g'] / 2 # half grout for block size modifier
# Use wall block settings for shelf
SetBW = settings['w']
@@ -1516,15 +1537,18 @@ def build(Aplan):
ShelfBtm = shelfSpecs['z']
ShelfEnd = ShelfLft + shelfSpecs['w']
ShelfTop = ShelfBtm + shelfSpecs['h']
- ShelfThk = shelfSpecs['d'] * 2 # use double-depth due to offsets to position at cursor.
+ ShelfThk = shelfSpecs['d'] * 2 # use double-depth due to offsets to position at cursor.
# Use "corners" to adjust position so not centered on depth.
- # Facing shelf, at cursor (middle of wall blocks) - 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]]
+ # Facing shelf, at cursor (middle of wall blocks)
+ # - 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]]
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:
@@ -1533,43 +1557,45 @@ def build(Aplan):
# Does not vary grout.
divs = fill(ShelfLft, ShelfEnd, SetBW, SetBWMin, SetBWVar)
- #loop through the row divisions, adding blocks for each one
- for i in range(len(divs)-1):
- ThisBlockx = (divs[i]+divs[i+1])/2
- ThisBlockw = divs[i+1]-divs[i]-SetGrtOff
+ # loop through the row divisions, adding blocks for each one
+ for i in range(len(divs) - 1):
+ ThisBlockx = (divs[i] + divs[i + 1]) / 2
+ ThisBlockw = divs[i + 1] - divs[i] - SetGrtOff
AllBlocks.append([ThisBlockx, ShelfBtm, ThisBlockw, SetBH, ShelfThk, ShelfOffsets])
- ShelfBtm += SetBH + SetGrtOff # moving up to next row...
- #
- #
+ ShelfBtm += SetBH + SetGrtOff # moving up to next row...
+
# Add blocks to create "steps".
# Does not account for openings (crosses gaps - which is a good thing)
if stepMod:
- SetGrtOff = settings['g']/2 # half grout for block size modifier
+ SetGrtOff = settings['g'] / 2 # half grout for block size modifier
# Vary block width by wall block variations.
SetWidVar = settings['wv']
SetWidMin = settings['wm']
- StepXMod = stepSpecs['t'] # width of step/tread, also sets basic block size.
+ StepXMod = stepSpecs['t'] # width of step/tread, also sets basic block size.
StepZMod = stepSpecs['v']
StepLft = stepSpecs['x']
StepRt = stepSpecs['x'] + stepSpecs['w']
- StepBtm = stepSpecs['z'] + StepZMod/2 # Start offset for centered blocks
+ StepBtm = stepSpecs['z'] + StepZMod / 2 # Start offset for centered blocks
StepWide = stepSpecs['w']
StepTop = StepBtm + stepSpecs['h']
- StepThk = stepSpecs['d'] * 2 # use double-depth due to offsets to position at cursor.
+ StepThk = stepSpecs['d'] * 2 # use double-depth due to offsets to position at cursor.
# Use "corners" to adjust steps so not centered on depth.
- # Facing steps, at cursor (middle of wall blocks) - this way no gaps between steps and wall face due to wall block depth.
+ # Facing steps, at cursor (middle of wall blocks)
+ # - this way no gaps between steps and wall face due to wall block depth.
# Also, will work fine as stand-alone if not used with wall (try block depth 0 and see what happens).
- wallDepth = settings['d']/2 # offset by wall depth so step depth matches UI setting :)
- 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]]
+ 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]]
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:
@@ -1577,7 +1603,7 @@ def build(Aplan):
# Make blocks for each step row - based on rowOb::fillblocks
# Does not vary grout.
- if stepOnly: # "cantilevered steps"
+ if stepOnly: # "cantilevered steps"
if stepLeft:
stepStart = StepRt - StepXMod
else:
@@ -1587,66 +1613,68 @@ def build(Aplan):
else:
divs = fill(StepLft, StepRt, StepXMod, SetWidMin, SetWidVar)
- #loop through the row divisions, adding blocks for each one
- for i in range(len(divs)-1):
- ThisBlockx = (divs[i]+divs[i+1])/2
- ThisBlockw = divs[i+1]-divs[i]-SetGrtOff
+ # loop through the row divisions, adding blocks for each one
+ for i in range(len(divs) - 1):
+ ThisBlockx = (divs[i] + divs[i + 1]) / 2
+ ThisBlockw = divs[i + 1] - divs[i] - SetGrtOff
AllBlocks.append([ThisBlockx, StepBtm, ThisBlockw, StepZMod, StepThk, StepOffsets])
- StepBtm += StepZMod + SetGrtOff # moving up to next row...
- StepWide -= StepXMod # reduce step width
+ StepBtm += StepZMod + SetGrtOff # moving up to next row...
+ StepWide -= StepXMod # reduce step width
# adjust side limit depending on direction of steps
if stepLeft:
- StepRt -= StepXMod # move in from right
+ StepRt -= StepXMod # move in from right
else:
- StepLft += StepXMod # move in from left
+ StepLft += StepXMod # move in from left
-
- #Copy all the blocks out of the rows
+ # Copy all the blocks out of the rows
for row in rows:
AllBlocks += row.BlocksEdge
AllBlocks += row.BlocksNorm
- #This loop makes individual blocks for each block specified in the plan
+ # This loop makes individual blocks for each block specified in the plan
for block in AllBlocks:
- x,z,w,h,d,corners = block
+ x, z, w, h, d, corners = block
if radialized:
- if slope: r1 = dims['t']*sin(z*PI/(dims['t']*2))
- else: r1 = z
- else: r1 = 1
+ if slope:
+ r1 = dims['t'] * sin(z * PI / (dims['t'] * 2))
+ else:
+ r1 = z
+ 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), corners, None, settings['b']+rndd()*settings['bv'], r1)
+ 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]
-
# This loop makes Arches for every opening specified in the plan.
for hole in Aplan[1]:
# lower arch stones
- if hole.vl > 0 and hole.rtl > (settings['g'] + settings['hm']):#make lower arch blocks
+ if hole.vl > 0 and hole.rtl > (settings['g'] + settings['hm']): # make lower arch blocks
archGeneration(hole, vlist, flist, -1)
- #top arch stones
- if hole.v > 0 and hole.rt > (settings['g'] + settings['hm']):#make upper arch blocks
+ # top arch stones
+ if hole.v > 0 and hole.rt > (settings['g'] + settings['hm']): # make upper arch blocks
archGeneration(hole, vlist, flist, 1)
- #
- #Warp all the points for domed stonework
+ # Warp all the points for domed stonework
if slope:
- for i,vert in enumerate(vlist):
- vlist[i] = [vert[0],(dims['t']+vert[1])*cos(vert[2]*PI/(2*dims['t'])),(dims['t']+vert[1])*sin(vert[2]*PI/(2*dims['t']))]
+ for i, vert in enumerate(vlist):
+ vlist[i] = [vert[0], (dims['t'] + vert[1]) * cos(vert[2] * PI / (2 * dims['t'])),
+ (dims['t'] + vert[1]) * sin(vert[2] * PI / (2 * dims['t']))]
- #Warp all the points for radial stonework
+ # Warp all the points for radial stonework
if radialized:
- for i,vert in enumerate(vlist):
- vlist[i] = [vert[2]*cos(vert[0]),vert[2]*sin(vert[0]),vert[1]]
+ for i, vert in enumerate(vlist):
+ vlist[i] = [vert[2] * cos(vert[0]), vert[2] * sin(vert[0]), vert[1]]
return vlist, flist
-#The main function
+# The main function
def createWall(radial, curve, openings, mergeBlox, shelf, shelfSide,
steps, stepDir, stepBare, stepSide):
__doc__ = """\
@@ -1680,4 +1708,3 @@ def createWall(radial, curve, openings, mergeBlox, shelf, shelfSide,
aplan = plan(asketch, 0)
return build(aplan)
-
diff --git a/add_mesh_extra_objects/Wallfactory.py b/add_mesh_extra_objects/Wallfactory.py
index cd432a52..a58b9f5a 100644
--- a/add_mesh_extra_objects/Wallfactory.py
+++ b/add_mesh_extra_objects/Wallfactory.py
@@ -13,392 +13,549 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, write to:
#
-# the Free Software Foundation Inc.
-# 51 Franklin Street, Fifth Floor
-# Boston, MA 02110-1301, USA
+# the Free Software Foundation Inc.
+# 51 Franklin Street, Fifth Floor
+# Boston, MA 02110-1301, USA
#
# or go online at: http://www.gnu.org/licenses/ to view license options.
#
# ***** 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.
-#
import bpy
-import mathutils
-from bpy.props import *
+from bpy.props import (
+ BoolProperty,
+ FloatProperty,
+ )
from add_mesh_extra_objects.Blocks import *
-#from add_mesh_walls.preset_utils import *
-#
class add_mesh_wallb(bpy.types.Operator):
- """Add a wall mesh"""
bl_idname = "mesh.wall_add"
- bl_label = "Add A Masonry Wall"
- bl_options = {'REGISTER', 'UNDO'} # removes object, does not reset to "last" modification.
- bl_description = "adds a block wall"
+ bl_label = "Add a Masonry Wall"
+ bl_description = "Create a block (masonry) wall mesh"
+ bl_options = {'REGISTER', 'UNDO'}
- # UI items - API for properties - User accessable variables...
-# not all options are via UI, and some operations just don't work yet.
+ # UI items - API for properties - User accessable variables...
+ # not all options are via UI, and some operations just don't work yet
# 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)
+ 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)
# make the wall circular - if not sloped it's a flat disc
- RadialTog = BoolProperty(name="Radial",
- description="Make masonry radial",
- default = False)
-
+ RadialTog = BoolProperty(
+ 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)
-
-#need to review defaults and limits for all of these UI objects.
+ SlopeTog = BoolProperty(
+ 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)
- WallEnd = FloatProperty(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)
- WallTop = FloatProperty(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)
-
+ WallStart = FloatProperty(
+ 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
+ )
+ WallBottom = FloatProperty(
+ 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
+ )
+ EdgeOffset = FloatProperty(
+ 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)
- WidthVariance = FloatProperty(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)
- Height = FloatProperty(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)
- HeightMinimum = FloatProperty(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)
- DepthVariance = FloatProperty(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)
- MergeBlock = BoolProperty(name="Merge Blocks",
- description="Make big blocks (merge closely adjoining blocks)",
- default = False)
-
+ Width = FloatProperty(
+ 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
+ )
+ WidthMinimum = FloatProperty(
+ 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
+ )
+ HeightVariance = FloatProperty(
+ 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
+ )
+ Depth = FloatProperty(
+ 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
+ )
+ DepthMinimum = FloatProperty(
+ 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
+ )
# edging for blocks
- Grout = FloatProperty(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)
- GroutDepth = FloatProperty(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)
- GroutEdge = BoolProperty(name="Edging",
- description="Grout perimiter",
- default = False)
-
- #properties for openings
- Opening1Tog = BoolProperty(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)
- Opening1Height = FloatProperty(name="Height",
- description="The Height of opening 1",
- 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)
- Opening1Z = FloatProperty(name="Bottom",
- description="The z position of opening 1",
- default=5.0, min=-100, max=100.0)
- Opening1Repeat = BoolProperty(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)
- Opening1TopArch = FloatProperty(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)
- Opening1BtmArchTog = BoolProperty(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)
- Opening1BtmArchThickness = FloatProperty(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)
-
-
- # openings on top of wall.
- CrenelTog = BoolProperty(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)
- CrenelZP = FloatProperty(name="Height %",
- description="Crenel Height as % of wall height",
- default=0.10, min=0.10, max=1.0)
-
-
+ Grout = FloatProperty(
+ 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)
+ GroutDepth = FloatProperty(
+ 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
+ )
+ GroutEdge = BoolProperty(
+ name="Edging",
+ description="Grout perimiter",
+ default=False
+ )
+ # properties for openings
+ Opening1Tog = BoolProperty(
+ 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
+ )
+ Opening1Height = FloatProperty(
+ name="Height",
+ description="The Height of opening 1",
+ 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
+ )
+ Opening1Z = FloatProperty(
+ name="Bottom",
+ description="The z position of opening 1",
+ default=5.0,
+ min=-100, max=100.0
+ )
+ Opening1Repeat = BoolProperty(
+ 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
+ )
+ Opening1TopArch = FloatProperty(
+ 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
+ )
+ Opening1BtmArchTog = BoolProperty(
+ 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
+ )
+ Opening1BtmArchThickness = FloatProperty(
+ 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
+ )
+ # openings on top of wall
+ CrenelTog = BoolProperty(
+ 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
+ )
+ CrenelZP = FloatProperty(
+ name="Height %",
+ description="Crenel Height as % of wall height",
+ default=0.10,
+ min=0.10, max=1.0
+ )
# 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)
+ # 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)
- SlotWdg = BoolProperty(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)
- SlotGap = FloatProperty(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)
- SlotVH = FloatProperty(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)
- SlotH = BoolProperty(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)
-#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)
-
-
- #properties for shelf (extend blocks in area)
- ShelfTog = BoolProperty(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)
- ShelfZ = FloatProperty(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)
- ShelfW = FloatProperty(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)
- ShelfBack = BoolProperty(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)
- StepX = FloatProperty(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)
- StepH = FloatProperty(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)
- 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)
- StepV = FloatProperty(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)
- StepLeft = BoolProperty(name="High Left",description="Height left; else Height right", default = False)
- StepOnly = BoolProperty(name="No Blocks",description="Steps only, no supporting blocks", default = False)
- StepBack = BoolProperty(name="Backside",description="Steps on backside of wall", default = False)
-
-##
-##
-#####
-# Show the UI - expose the properties.
-#####
-##
-##
- # Display the toolbox options
+ description="Repeat slots along wall",
+ default=False
+ )
+ SlotWdg = BoolProperty(
+ 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
+ )
+ SlotGap = FloatProperty(
+ 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
+ )
+ SlotVH = FloatProperty(
+ 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
+ )
+ SlotH = BoolProperty(
+ 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
+ )
+ # 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
+ )
+ # properties for shelf (extend blocks in area)
+ ShelfTog = BoolProperty(
+ 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
+ )
+ ShelfZ = FloatProperty(
+ 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
+ )
+ ShelfW = FloatProperty(
+ 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
+ )
+ ShelfBack = BoolProperty(
+ 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
+ )
+ StepX = FloatProperty(
+ 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
+ )
+ StepH = FloatProperty(
+ 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
+ )
+ 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
+ )
+ StepV = FloatProperty(
+ 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
+ )
+ StepLeft = BoolProperty(
+ name="High Left",
+ description="Height left; else Height right",
+ default=False
+ )
+ StepOnly = BoolProperty(
+ name="No Blocks",
+ description="Steps only, no supporting blocks",
+ default=False
+ )
+ StepBack = BoolProperty(
+ name="Backside",
+ description="Steps on backside of wall",
+ default=False
+ )
+ # Display the toolbox options
def draw(self, context):
-
layout = self.layout
box = layout.box()
box.prop(self, 'ConstructTog')
-# Wall area (size/position)
+ # 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')
- box.prop(self, 'EdgeOffset')
-
-# Wall block sizing
+ box.label(text="Wall Size (area)")
+ box.prop(self, "WallStart")
+ box.prop(self, "WallEnd")
+ box.prop(self, "WallBottom")
+ box.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')
-
-# grout settings
+ # 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")
+
+ # grout settings
box = layout.box()
- bl_label = "Grout"
- box.label(text='Grout')
- box.prop(self, 'Grout')
- box.prop(self, 'GroutVariance')
- box.prop(self, 'GroutDepth')
- box.prop(self, 'GroutDepthVariance')
-# box.prop(self, 'GroutEdge')
-
-# Wall shape modifiers
+ box.label(text="Grout")
+ box.prop(self, "Grout")
+ box.prop(self, "GroutVariance")
+ box.prop(self, "GroutDepth")
+ box.prop(self, "GroutDepthVariance")
+
+ # Wall shape modifiers
box = layout.box()
- box.label(text='Wall Shape')
- box.prop(self, 'RadialTog')
- box.prop(self, 'SlopeTog')
+ box.label(text="Wall Shape")
+ box.prop(self, "RadialTog")
+ box.prop(self, "SlopeTog")
-# Openings (doors, windows; arched)
+ # 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')
-
-# Slots (narrow openings)
+ 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")
+
+ # Slots (narrow openings)
box = layout.box()
box.prop(self, 'SlotTog')
if self.properties.SlotTog:
-# box.prop(self, 'SlotWdg')
- 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')
-
-# Crenels, gaps in top of wall
+ 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")
+
+ # Crenels, gaps in top of wall
box = layout.box()
- box.prop(self, 'CrenelTog')
+ box.prop(self, "CrenelTog")
if self.properties.CrenelTog:
- box.prop(self, 'CrenelXP')
- box.prop(self, 'CrenelZP')
+ box.prop(self, "CrenelXP")
+ box.prop(self, "CrenelZP")
-# Shelfing (protrusions)
+ # 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')
- box.prop(self, 'ShelfBack')
-
-# Steps
+ box.prop(self, "ShelfX")
+ box.prop(self, "ShelfZ")
+ box.prop(self, "ShelfH")
+ box.prop(self, "ShelfW")
+ box.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')
-
-##
-#####
-# Respond to UI - get the properties set by user.
-#####
-##
+ 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")
+
+ # Respond to UI - get the properties set by user.
# Check and process UI settings to generate masonry
def execute(self, context):
-
global radialized
global slope
global openingSpecs
@@ -411,13 +568,14 @@ class add_mesh_wallb(bpy.types.Operator):
global stepBack
# Create the wall when enabled (skip regen iterations when off)
- if not self.properties.ConstructTog: return {'FINISHED'}
+ if not self.properties.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.
+ # 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...
+ self.properties.WallStart = NOTZERO # Reset UI if input out of bounds...
dims['s'] = self.properties.WallStart
dims['e'] = self.properties.WallEnd
@@ -426,12 +584,14 @@ class add_mesh_wallb(bpy.types.Operator):
settings['eoff'] = self.properties.EdgeOffset
- #retrieve the settings for the wall block properties
+ # retrieve the settings for the wall block properties
settings['w'] = self.properties.Width
settings['wv'] = self.properties.WidthVariance
settings['wm'] = self.properties.WidthMinimum
- if not radialized: settings['sdv'] = settings['w']
- else: settings['sdv'] = 0.12
+ if not radialized:
+ settings['sdv'] = settings['w']
+ else:
+ settings['sdv'] = 0.12
settings['h'] = self.properties.Height
settings['hv'] = self.properties.HeightVariance
@@ -443,33 +603,40 @@ class add_mesh_wallb(bpy.types.Operator):
if self.properties.MergeBlock:
bigBlock = 1
- else: bigBlock = 0
+ else:
+ bigBlock = 0
settings['g'] = self.properties.Grout
settings['gv'] = self.properties.GroutVariance
settings['gd'] = self.properties.GroutDepth
settings['gdv'] = self.properties.GroutDepthVariance
- if self.properties.GroutEdge: settings['ge'] = 1
- else: settings['ge'] = 0
+ if self.properties.GroutEdge:
+ settings['ge'] = 1
+ else:
+ settings['ge'] = 0
# set wall shape modifiers
if self.properties.RadialTog:
radialized = 1
-#eliminate to allow user control for start/completion?
- dims['s'] = 0.0 # complete radial
- if dims['e'] > PI*2: dims['e'] = PI*2 # max end for circle
- if dims['b'] < settings['g']: dims['b'] = settings['g'] # min bottom for grout extension
- else: radialized = 0
-
- if self.properties.SlopeTog: slope = 1
- else: slope = 0
-
+ # eliminate to allow user control for start/completion?
+ dims['s'] = 0.0 # complete radial
+ if dims['e'] > PI * 2:
+ dims['e'] = PI * 2 # max end for circle
+ if dims['b'] < settings['g']:
+ dims['b'] = settings['g'] # min bottom for grout extension
+ else:
+ radialized = 0
+
+ if self.properties.SlopeTog:
+ slope = 1
+ else:
+ slope = 0
shelfExt = 0
shelfBack = 0
- # Add shelf if enabled
+ # Add shelf if enabled
if self.properties.ShelfTog:
shelfExt = 1
shelfSpecs['h'] = self.properties.ShelfH
@@ -480,14 +647,12 @@ class add_mesh_wallb(bpy.types.Operator):
if self.properties.ShelfBack:
shelfBack = 1
-
-
stepMod = 0
stepLeft = 0
stepOnly = 0
stepBack = 0
- # Make steps if enabled
+ # Make steps if enabled
if self.properties.StepTog:
stepMod = 1
stepSpecs['x'] = self.properties.StepX
@@ -507,17 +672,17 @@ class add_mesh_wallb(bpy.types.Operator):
if self.properties.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.
+ # 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.
openingSpecs = []
- openingIdx = 0 # track opening array references for multiple uses
+ openingIdx = 0 # track opening array references for multiple uses
# general openings with arch options - can be windows or doors.
if self.properties.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 += [{'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
@@ -532,17 +697,18 @@ class add_mesh_wallb(bpy.types.Operator):
if self.properties.Opening1BtmArchTog:
openingSpecs[openingIdx]['vl'] = self.properties.Opening1BtmArch
openingSpecs[openingIdx]['tl'] = self.properties.Opening1BtmArchThickness
-
+
openingSpecs[openingIdx]['b'] = self.properties.Opening1Bevel
- openingIdx += 1 # count window/door/arch openings
+ openingIdx += 1 # count window/door/arch openings
# Slots (narrow openings)
if self.properties.SlotTog:
- if self.properties.SlotV: # vertical slots
+ if self.properties.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 += [{'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
@@ -552,74 +718,68 @@ class add_mesh_wallb(bpy.types.Operator):
# make them pointy...
openingSpecs[openingIdx]['v'] = self.properties.SlotGap
- openingSpecs[openingIdx]['t'] = self.properties.SlotGap/2
+ openingSpecs[openingIdx]['t'] = self.properties.SlotGap / 2
openingSpecs[openingIdx]['vl'] = self.properties.SlotGap
- openingSpecs[openingIdx]['tl'] = self.properties.SlotGap/2
+ openingSpecs[openingIdx]['tl'] = self.properties.SlotGap / 2
- openingIdx += 1 # count vertical slot openings
+ openingIdx += 1 # count vertical slot openings
-# need to handle overlap of H and V slots...
+ # need to handle overlap of H and V slots...
- if self.properties.SlotH: # Horizontal slots
+ if self.properties.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 += [{'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
-#horizontal repeat isn't same spacing as vertical...
+ # horizontal repeat isn't same spacing as vertical...
openingSpecs[openingIdx]['rp'] = self.properties.SlotRpt
# make them pointy...
-# want arc to go sideways... maybe wedge will be sufficient and can skip horiz arcs.
-# 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
-
- openingIdx += 1 # count horizontal slot openings
-
+ openingIdx += 1 # count horizontal slot openings
# Crenellations (top row openings)
if self.properties.CrenelTog:
-# add bottom arch option?
-# perhaps a repeat toggle...
-# if crenel opening overlaps with arch opening it fills with blocks...
+ # add bottom arch option?
+ # perhaps a repeat toggle...
+ # if crenel opening overlaps with arch opening it fills with blocks...
# set defaults...
- 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}]
+ 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.
+ crenelW = wallW * self.properties.CrenelXP # Width % opening.
wallH = self.properties.WallTop - self.properties.WallBottom
- crenelH = wallH*self.properties.CrenelZP # % proportional height.
+ crenelH = wallH * self.properties.CrenelZP # % proportional height.
openingSpecs[openingIdx]['w'] = crenelW
openingSpecs[openingIdx]['h'] = crenelH
# calculate the spacing between openings.
- # this isn't the absolute start (left), it's opening center offset relative to cursor (space between openings)...
- openingSpecs[openingIdx]['x'] = crenelW*2-1 # assume standard spacing
+ # this isn't the absolute start (left),
+ # it's opening center offset relative to cursor (space between openings)...
+ openingSpecs[openingIdx]['x'] = crenelW * 2 - 1 # assume standard spacing
- if not radialized: # normal wall?
+ if not radialized: # normal wall?
# set indent 0 (center) if opening is 50% or more of wall width, no repeat.
- if crenelW*2 >= wallW:
+ if crenelW * 2 >= wallW:
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.properties.WallTop - (crenelH/2) # set bottom of opening (center of hole)
-
- openingIdx += 1 # count crenel openings
+ 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)
+ shelfExt, shelfBack, stepMod, stepLeft, stepOnly, stepBack)
# Create new mesh
mesh = bpy.data.meshes.new("Wall")
@@ -636,12 +796,12 @@ class add_mesh_wallb(bpy.types.Operator):
ob_new = bpy.data.objects.new("Wall", mesh)
scene.objects.link(ob_new)
-# leave this out to prevent 'Tab key" going into edit mode :):):)
-# Use rmb click to select and still modify.
+ # leave this out to prevent 'Tab key" going into edit mode :)
+ # Use rmb click to select and still modify.
scene.objects.active = ob_new
ob_new.select = True
ob_new.location = tuple(context.scene.cursor_location)
- ob_new.rotation_quaternion = [1.0,0.0,0.0,0.0]
+ ob_new.rotation_quaternion = [1.0, 0.0, 0.0, 0.0]
return {'FINISHED'}
diff --git a/add_mesh_extra_objects/__init__.py b/add_mesh_extra_objects/__init__.py
index 24bc6aab..d116526e 100644
--- a/add_mesh_extra_objects/__init__.py
+++ b/add_mesh_extra_objects/__init__.py
@@ -16,14 +16,15 @@
#
# ##### 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 #
+# 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
bl_info = {
"name": "Extra Objects",
"author": "Multiple Authors",
- "version": (0, 3, 0),
+ "version": (0, 3, 1),
"blender": (2, 74, 5),
"location": "View3D > Add > Mesh",
"description": "Add extra mesh object types",
@@ -87,15 +88,17 @@ else:
from . import Blocks
import bpy
+from bpy.types import Menu
from bpy.props import (
BoolProperty,
IntProperty,
FloatProperty,
+ StringProperty,
)
-class INFO_MT_mesh_vert_add(bpy.types.Menu):
- # Define the "Pipe Joints" menu
+class INFO_MT_mesh_vert_add(Menu):
+ # Define the "Single Vert" menu
bl_idname = "INFO_MT_mesh_vert_add"
bl_label = "Single Vert"
@@ -103,7 +106,8 @@ class INFO_MT_mesh_vert_add(bpy.types.Menu):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("mesh.primitive_vert_add",
- text="Add Single Vert ")
+ text="Add Single Vert")
+ layout.separator()
layout.operator("mesh.primitive_emptyvert_add",
text="Object Origin Only")
layout.operator("mesh.primitive_symmetrical_vert_add",
@@ -112,7 +116,7 @@ class INFO_MT_mesh_vert_add(bpy.types.Menu):
text="Object Origin Mirrored")
-class INFO_MT_mesh_gears_add(bpy.types.Menu):
+class INFO_MT_mesh_gears_add(Menu):
# Define the "Gears" menu
bl_idname = "INFO_MT_mesh_gears_add"
bl_label = "Gears"
@@ -126,8 +130,8 @@ class INFO_MT_mesh_gears_add(bpy.types.Menu):
text="Worm")
-class INFO_MT_mesh_diamonds_add(bpy.types.Menu):
- # Define the "Gears" menu
+class INFO_MT_mesh_diamonds_add(Menu):
+ # Define the "Diamonds" menu
bl_idname = "INFO_MT_mesh_diamonds_add"
bl_label = "Diamonds"
@@ -142,7 +146,7 @@ class INFO_MT_mesh_diamonds_add(bpy.types.Menu):
text="Gem")
-class INFO_MT_mesh_math_add(bpy.types.Menu):
+class INFO_MT_mesh_math_add(Menu):
# Define the "Math Function" menu
bl_idname = "INFO_MT_mesh_math_add"
bl_label = "Math Functions"
@@ -157,19 +161,36 @@ class INFO_MT_mesh_math_add(bpy.types.Menu):
self.layout.operator("mesh.primitive_solid_add", text="Regular Solid")
-class INFO_MT_mesh_extras_add(bpy.types.Menu):
- # Define the "Simple Objects" menu
+class INFO_MT_mesh_mech(Menu):
+ # Define the "Math Function" menu
+ bl_idname = "INFO_MT_mesh_mech_add"
+ bl_label = "Mechanical"
+
+ def draw(self, context):
+ layout = self.layout
+ layout.operator_context = 'INVOKE_REGION_WIN'
+ layout.menu("INFO_MT_mesh_pipe_joints_add",
+ text="Pipe Joints", icon="SNAP_PEEL_OBJECT")
+ layout.menu("INFO_MT_mesh_gears_add",
+ text="Gears", icon="SCRIPTWIN")
+
+
+class INFO_MT_mesh_extras_add(Menu):
+ # Define the "Extra Objects" menu
bl_idname = "INFO_MT_mesh_extras_add"
bl_label = "Extras"
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
- layout.menu("INFO_MT_mesh_diamonds_add", text="Diamonds", icon="PMARKER_SEL")
+ layout.menu("INFO_MT_mesh_diamonds_add", text="Diamonds",
+ icon="PMARKER_SEL")
+ layout.separator()
layout.operator("mesh.add_beam",
text="Beam Builder")
layout.operator("mesh.wall_add",
text="Wall Factory")
+ layout.separator()
layout.operator("mesh.primitive_star_add",
text="Simple Star")
layout.operator("mesh.primitive_steppyramid_add",
@@ -182,8 +203,8 @@ class INFO_MT_mesh_extras_add(bpy.types.Menu):
text="Menger Sponge")
-class INFO_MT_mesh_torus_add(bpy.types.Menu):
- # Define the "Simple Objects" menu
+class INFO_MT_mesh_torus_add(Menu):
+ # Define the "Torus Objects" menu
bl_idname = "INFO_MT_mesh_torus_add"
bl_label = "Torus Objects"
@@ -198,7 +219,7 @@ class INFO_MT_mesh_torus_add(bpy.types.Menu):
text="Torus Knot")
-class INFO_MT_mesh_pipe_joints_add(bpy.types.Menu):
+class INFO_MT_mesh_pipe_joints_add(Menu):
# Define the "Pipe Joints" menu
bl_idname = "INFO_MT_mesh_pipe_joints_add"
bl_label = "Pipe Joints"
@@ -219,9 +240,7 @@ class INFO_MT_mesh_pipe_joints_add(bpy.types.Menu):
class discombobulator_scene_props(bpy.types.PropertyGroup):
-
DISC_doodads = []
-
# Protusions Buttons:
repeatprot = IntProperty(
name="Repeat protusions",
@@ -250,7 +269,6 @@ class discombobulator_scene_props(bpy.types.PropertyGroup):
name="4",
default=True
)
-
polygonschangedpercent = FloatProperty(
name="Polygon %",
description="Percentage of changed polygons",
@@ -324,19 +342,29 @@ class discombobulator_scene_props(bpy.types.PropertyGroup):
def menu_func(self, context):
lay_out = self.layout
lay_out.operator_context = 'INVOKE_REGION_WIN'
+
lay_out.separator()
- lay_out.menu("INFO_MT_mesh_vert_add", text="Single Vert", icon="LAYER_ACTIVE")
- lay_out.operator("mesh.primitive_round_cube_add", text="Round Cube", icon="MOD_SUBSURF")
- lay_out.menu("INFO_MT_mesh_math_add", text="Math Function", icon="PACKAGE")
- lay_out.operator("mesh.generate_geodesic_dome", text="Geodesic Dome", icon="MESH_ICOSPHERE")
- lay_out.operator("discombobulate.ops", text="Discombobulator", icon="RETOPO")
- lay_out.menu("INFO_MT_mesh_pipe_joints_add", text="Pipe Joints", icon="SNAP_PEEL_OBJECT")
- lay_out.menu("INFO_MT_mesh_gears_add", text="Gears", icon="SCRIPTWIN")
- lay_out.menu("INFO_MT_mesh_torus_add", text="Torus Objects", icon="MESH_TORUS")
- lay_out.menu("INFO_MT_mesh_extras_add", text="Extras", icon="MESH_DATA")
+ lay_out.menu("INFO_MT_mesh_vert_add",
+ text="Single Vert", icon="LAYER_ACTIVE")
+ lay_out.operator("mesh.primitive_round_cube_add",
+ text="Round Cube", icon="MOD_SUBSURF")
+ lay_out.menu("INFO_MT_mesh_math_add",
+ text="Math Function", icon="PACKAGE")
+ lay_out.menu("INFO_MT_mesh_mech_add",
+ text="Mechanical", icon="SCRIPTWIN")
+ lay_out.menu("INFO_MT_mesh_torus_add",
+ text="Torus Objects", icon="MESH_TORUS")
lay_out.separator()
- lay_out.operator("object.parent_to_empty", text="Parent To Empty", icon="LINK_AREA")
+ lay_out.operator("mesh.generate_geodesic_dome",
+ text="Geodesic Dome", icon="MESH_ICOSPHERE")
+ lay_out.operator("discombobulate.ops",
+ text="Discombobulator", icon="RETOPO")
lay_out.separator()
+ lay_out.menu("INFO_MT_mesh_extras_add",
+ text="Extras", icon="MESH_DATA")
+ lay_out.separator()
+ lay_out.operator("object.parent_to_empty",
+ text="Parent To Empty", icon="LINK_AREA")
def register():
@@ -346,6 +374,21 @@ def register():
bpy.types.Scene.discomb = bpy.props.PointerProperty(
type=discombobulator_scene_props
)
+ # Error messages for Geodesic Domes
+ bpy.types.Scene.error_message = StringProperty(
+ name="actual error",
+ default=""
+ )
+ bpy.types.Scene.geodesic_not_yet_called = BoolProperty(
+ name="geodesic_not_called",
+ default=True
+ )
+ bpy.types.Scene.gd_help_text_width = IntProperty(
+ name="Text Width",
+ description="The width above which the text wraps",
+ default=60,
+ max=180, min=20
+ )
# Add "Extras" menu to the "Add Mesh" menu
bpy.types.INFO_MT_mesh_add.append(menu_func)
@@ -356,6 +399,9 @@ def unregister():
bpy.types.INFO_MT_mesh_add.remove(menu_func)
del bpy.types.Scene.discomb
+ del bpy.types.Scene.error_message
+ del bpy.types.Scene.geodesic_not_yet_called
+ del bpy.types.Scene.gd_help_text_width
bpy.utils.unregister_module(__name__)
diff --git a/add_mesh_extra_objects/add_empty_as_parent.py b/add_mesh_extra_objects/add_empty_as_parent.py
index b7431b6d..bcaecf64 100644
--- a/add_mesh_extra_objects/add_empty_as_parent.py
+++ b/add_mesh_extra_objects/add_empty_as_parent.py
@@ -1,26 +1,49 @@
# GPL # Original Author Liero #
import bpy
-from bpy.props import StringProperty, BoolProperty, EnumProperty
+from bpy.types import Operator
+from bpy.props import (
+ StringProperty,
+ BoolProperty,
+ EnumProperty,
+ )
-def centro(sel):
- x = sum([obj.location[0] for obj in sel])/len(sel)
- y = sum([obj.location[1] for obj in sel])/len(sel)
- z = sum([obj.location[2] for obj in sel])/len(sel)
- return (x,y,z)
-
-
-class P2E(bpy.types.Operator):
- bl_idname = 'object.parent_to_empty'
- bl_label = 'Parent to Empty'
- bl_description = 'Parent selected objects to a new Empty'
- bl_options = {'REGISTER', 'UNDO'}
- nombre = StringProperty(name='', default='OBJECTS', description='Give the empty / group a name')
- grupo = bpy.props.BoolProperty(name='Create Group', default=False, description='Also add objects to a group')
- locat = bpy.props.EnumProperty(name='', items=[('CURSOR','Cursor','Cursor'),('ACTIVE','Active','Active'),
- ('CENTER','Center','Selection Center')],description='Empty location', default='CENTER')
- renom = bpy.props.BoolProperty(name='Add Prefix', default=False, description='Add prefix to objects name')
+def centro(sel):
+ x = sum([obj.location[0] for obj in sel]) / len(sel)
+ y = sum([obj.location[1] for obj in sel]) / len(sel)
+ z = sum([obj.location[2] for obj in sel]) / len(sel)
+ return (x, y, z)
+
+
+class P2E(Operator):
+ bl_idname = "object.parent_to_empty"
+ bl_label = "Parent to Empty"
+ bl_description = "Parent selected objects to a new Empty"
+ bl_options = {"REGISTER", "UNDO"}
+
+ nombre = StringProperty(
+ name="",
+ default='OBJECTS',
+ description='Give the empty / group a name'
+ )
+ grupo = BoolProperty(
+ name="Create Group",
+ default=False,
+ description="Also add objects to a group"
+ )
+ locat = EnumProperty(
+ name='',
+ items=[('CURSOR', 'Cursor', 'Cursor'), ('ACTIVE', 'Active', 'Active'),
+ ('CENTER', 'Center', 'Selection Center')],
+ description='Empty location',
+ default='CENTER'
+ )
+ renom = BoolProperty(
+ name="Add Prefix",
+ default=False,
+ description="Add prefix to objects name"
+ )
@classmethod
def poll(cls, context):
@@ -29,34 +52,38 @@ class P2E(bpy.types.Operator):
def draw(self, context):
layout = self.layout
- layout.prop(self,'nombre')
+ layout.prop(self, "nombre")
column = layout.column(align=True)
- column.prop(self,'locat')
- column.prop(self,'grupo')
- column.prop(self,'renom')
+ column.prop(self, "locat")
+ column.prop(self, "grupo")
+ column.prop(self, "renom")
def execute(self, context):
objs = context.selected_objects
act = context.object
sce = context.scene
- try: bpy.ops.object.mode_set()
- except: pass
+
+ try:
+ bpy.ops.object.mode_set()
+ except:
+ pass
+
if self.locat == 'CURSOR':
loc = sce.cursor_location
elif self.locat == 'ACTIVE':
loc = act.location
else:
- loc = centro(objs)
-
- bpy.ops.object.add(type='EMPTY',location=loc)
+ loc = centro(objs)
+
+ bpy.ops.object.add(type='EMPTY', location=loc)
context.object.name = self.nombre
context.object.show_name = True
context.object.show_x_ray = True
-
+
if self.grupo:
bpy.ops.group.create(name=self.nombre)
bpy.ops.group.objects_add_active()
-
+
for o in objs:
o.select = True
if not o.parent:
@@ -66,50 +93,37 @@ class P2E(bpy.types.Operator):
o.select = False
for o in objs:
if self.renom:
- o.name = self.nombre+'_'+o.name
+ o.name = self.nombre + '_' + o.name
return {'FINISHED'}
-class PreFix(bpy.types.Operator):
- bl_idname = 'object.toggle_prefix'
- bl_label = 'Toggle Sufix'
- bl_description = 'Toggle parent name as sufix for c'
- bl_options = {'REGISTER', 'UNDO'}
+class PreFix(Operator):
+ bl_idname = "object.toggle_prefix"
+ bl_label = "Toggle Sufix"
+ bl_description = "Toggle parent name as sufix for c"
+ bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
- act = bpy.context.object
+ act = context.object
return (act and act.type == 'EMPTY')
def execute(self, context):
- act = bpy.context.object
+ act = context.object
objs = act.children
- prefix = act.name+'_'
+ prefix = act.name + '_'
remove = False
for o in objs:
if o.name.startswith(prefix):
remove = True
break
- if remove == True:
+ if remove is True:
for o in objs:
if o.name.startswith(prefix):
o.name = o.name.partition(prefix)[2]
else:
for o in objs:
- o.name = prefix+o.name
+ o.name = prefix + o.name
return {'FINISHED'}
-
-
-class PanelP2E(bpy.types.Panel):
- bl_label = 'Parent to Empty'
- bl_space_type = 'VIEW_3D'
- bl_region_type = 'TOOLS'
- bl_category = 'Relations'
-
- def draw(self, context):
- layout = self.layout
- layout.operator('object.parent_to_empty')
- layout.operator('object.toggle_prefix')
-
diff --git a/add_mesh_extra_objects/add_mesh_3d_function_surface.py b/add_mesh_extra_objects/add_mesh_3d_function_surface.py
index f41673ab..616add3f 100644
--- a/add_mesh_extra_objects/add_mesh_3d_function_surface.py
+++ b/add_mesh_extra_objects/add_mesh_3d_function_surface.py
@@ -3,7 +3,14 @@
import bpy
from mathutils import *
from math import *
-from bpy.props import *
+from bpy.types import Operator
+from bpy.props import (
+ StringProperty,
+ IntProperty,
+ FloatProperty,
+ BoolProperty,
+ )
+
# List of safe functions for eval()
safe_list = ['math', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'cosh',
@@ -16,35 +23,36 @@ safe_dict = dict((k, globals().get(k, None)) for k in safe_list)
# Stores the values of a list of properties and the
-# operator id in a property group ('recall_op') inside the object.
+# operator id in a property group ('recall_op') inside the object
# Could (in theory) be used for non-objects.
# Note: Replaces any existing property group with the same name!
-# ob ... Object to store the properties in.
-# op ... The operator that should be used.
+# ob ... Object to store the properties in
+# op ... The operator that should be used
# op_args ... A dictionary with valid Blender
-# properties (operator arguments/parameters).
+# properties (operator arguments/parameters)
-# Create a new mesh (object) from verts/edges/faces.
+# Create a new mesh (object) from verts/edges/faces
# verts/edges/faces ... List of vertices/edges/faces for the
-# new mesh (as used in from_pydata).
-# name ... Name of the new mesh (& object).
+# new mesh (as used in from_pydata)
+# name ... Name of the new mesh (& object)
+
def create_mesh_object(context, verts, edges, faces, name):
# Create new mesh
mesh = bpy.data.meshes.new(name)
- # Make a mesh from a list of verts/edges/faces.
+ # Make a mesh from a list of verts/edges/faces
mesh.from_pydata(verts, edges, faces)
- # Update mesh geometry after adding stuff.
+ # Update mesh geometry after adding stuff
mesh.update()
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)
-# A very simple "bridge" tool.
+# A very simple "bridge" tool
def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
faces = []
@@ -65,7 +73,7 @@ def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
total = len(vertIdx2)
if closed:
- # Bridge the start with the end.
+ # Bridge the start with the end
if flipped:
face = [
vertIdx1[0],
@@ -82,7 +90,7 @@ def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
face.append(vertIdx2[total - 1])
faces.append(face)
- # Bridge the rest of the faces.
+ # Bridge the rest of the faces
for num in range(total - 1):
if flipped:
if fan:
@@ -102,39 +110,47 @@ def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
return faces
-class AddZFunctionSurface(bpy.types.Operator):
- """Add a surface defined defined by a function z=f(x,y)"""
+class AddZFunctionSurface(Operator):
bl_idname = "mesh.primitive_z_function_surface"
bl_label = "Add Z Function Surface"
+ bl_description = "Add a surface defined defined by a function z=f(x,y)"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
- equation = StringProperty(name="Z Equation",
- description="Equation for z=f(x,y)",
- default="1 - ( x**2 + y**2 )")
-
- div_x = IntProperty(name="X Subdivisions",
- description="Number of vertices in x direction",
- default=16,
- min=3,
- max=256)
- div_y = IntProperty(name="Y Subdivisions",
- description="Number of vertices in y direction",
- default=16,
- min=3,
- max=256)
-
- size_x = FloatProperty(name="X Size",
- description="Size of the x axis",
- default=2.0,
- min=0.01,
- max=100.0,
- unit="LENGTH")
- size_y = FloatProperty(name="Y Size",
- description="Size of the y axis",
- default=2.0,
- min=0.01,
- max=100.0,
- unit="LENGTH")
+ equation = StringProperty(
+ name="Z Equation",
+ description="Equation for z=f(x,y)",
+ default="1 - ( x**2 + y**2 )"
+ )
+ div_x = IntProperty(
+ name="X Subdivisions",
+ description="Number of vertices in x direction",
+ default=16,
+ min=3,
+ max=256
+ )
+ div_y = IntProperty(
+ name="Y Subdivisions",
+ description="Number of vertices in y direction",
+ default=16,
+ min=3,
+ max=256
+ )
+ size_x = FloatProperty(
+ name="X Size",
+ description="Size of the x axis",
+ default=2.0,
+ min=0.01,
+ max=100.0,
+ unit="LENGTH"
+ )
+ size_y = FloatProperty(
+ name="Y Size",
+ description="Size of the y axis",
+ default=2.0,
+ min=0.01,
+ max=100.0,
+ unit="LENGTH"
+ )
def execute(self, context):
equation = self.equation
@@ -153,55 +169,67 @@ class AddZFunctionSurface(bpy.types.Operator):
edgeloop_prev = []
- try:
- expr_args = (
- compile(equation, __file__, 'eval'),
- {"__builtins__": None},
- safe_dict)
- except:
- import traceback
- self.report({'ERROR'}, "Error parsing expression: "
- + traceback.format_exc(limit=1))
- return {'CANCELLED'}
+ if equation:
+ try:
+ expr_args = (
+ compile(equation, __file__, 'eval'),
+ {"__builtins__": None},
+ safe_dict)
+ except:
+ import traceback
+ # WARNING is used to prevent the constant pop-up spam
+ self.report({'WARNING'},
+ "Error parsing expression: {} "
+ "(Check the console for more info)".format(equation))
+ print("\n[Add Z Function Surface]:\n\n", traceback.format_exc(limit=1))
+
+ return {'CANCELLED'}
- for row_x in range(div_x):
- edgeloop_cur = []
- x = start_x + row_x * delta_x
+ for row_x in range(div_x):
+ edgeloop_cur = []
+ x = start_x + row_x * delta_x
- for row_y in range(div_y):
- y = start_y + row_y * delta_y
- z = 0.0
+ for row_y in range(div_y):
+ y = start_y + row_y * delta_y
+ z = 0.0
- safe_dict['x'] = x
- safe_dict['y'] = y
+ safe_dict['x'] = x
+ safe_dict['y'] = y
- # Try to evaluate the equation.
- try:
- z = float(eval(*expr_args))
- except:
- import traceback
- self.report({'ERROR'}, "Error evaluating expression: "
- + traceback.format_exc(limit=1))
- return {'CANCELLED'}
+ # Try to evaluate the equation.
+ try:
+ z = float(eval(*expr_args))
+ except:
+ import traceback
+ self.report({'WARNING'},
+ "Error evaluating expression: {} "
+ "(Check the console for more info)".format(equation))
+ print("\n[Add Z Function Surface]:\n\n", traceback.format_exc(limit=1))
- edgeloop_cur.append(len(verts))
- verts.append((x, y, z))
+ return {'CANCELLED'}
- if len(edgeloop_prev) > 0:
- faces_row = createFaces(edgeloop_prev, edgeloop_cur)
- faces.extend(faces_row)
+ edgeloop_cur.append(len(verts))
+ verts.append((x, y, z))
- edgeloop_prev = edgeloop_cur
+ if len(edgeloop_prev) > 0:
+ faces_row = createFaces(edgeloop_prev, edgeloop_cur)
+ faces.extend(faces_row)
- base = create_mesh_object(context, verts, [], faces, "Z Function")
+ edgeloop_prev = edgeloop_cur
+
+ base = create_mesh_object(context, verts, [], faces, "Z Function")
+ else:
+ self.report({'WARNING'}, "Z Equation - No expression is given")
+
+ return {'CANCELLED'}
return {'FINISHED'}
def xyz_function_surface_faces(self, x_eq, y_eq, z_eq,
- range_u_min, range_u_max, range_u_step, wrap_u,
- range_v_min, range_v_max, range_v_step, wrap_v,
- a_eq, b_eq, c_eq, f_eq, g_eq, h_eq, n, close_v):
+ range_u_min, range_u_max, range_u_step, wrap_u,
+ range_v_min, range_v_max, range_v_step, wrap_v,
+ a_eq, b_eq, c_eq, f_eq, g_eq, h_eq, n, close_v):
verts = []
faces = []
@@ -261,8 +289,9 @@ def xyz_function_surface_faces(self, x_eq, y_eq, z_eq,
safe_dict)
except:
import traceback
- self.report({'ERROR'}, "Error parsing expression: "
- + traceback.format_exc(limit=1))
+ self.report({'WARNING'}, "Error parsing expression(s) - "
+ "Check the console for more info")
+ print("\n[Add X, Y, Z Function Surface]:\n\n", traceback.format_exc(limit=1))
return [], []
for vN in range(vRange):
@@ -289,11 +318,11 @@ def xyz_function_surface_faces(self, x_eq, y_eq, z_eq,
float(eval(*expr_args_x)),
float(eval(*expr_args_y)),
float(eval(*expr_args_z))))
-
except:
import traceback
- self.report({'ERROR'}, "Error evaluating expression: "
- + traceback.format_exc(limit=1))
+ self.report({'WARNING'}, "Error evaluating expression(s) - "
+ "Check the console for more info")
+ print("\n[Add X, Y, Z Function Surface]:\n\n", traceback.format_exc(limit=1))
return [], []
for vN in range(range_v_step):
@@ -346,112 +375,131 @@ def xyz_function_surface_faces(self, x_eq, y_eq, z_eq,
# u_max = pi
# v_min = -pi/4,
# v max = 5*pi/2
-class AddXYZFunctionSurface(bpy.types.Operator):
- """Add a surface defined defined by 3 functions:""" \
- """ x=F1(u,v), y=F2(u,v) and z=F3(u,v)"""
+
+class AddXYZFunctionSurface(Operator):
bl_idname = "mesh.primitive_xyz_function_surface"
- bl_label = "Add X,Y,Z Function Surface"
+ bl_label = "Add X, Y, Z Function Surface"
+ bl_description = ("Add a surface defined defined by 3 functions:\n"
+ "x=F1(u,v), y=F2(u,v) and z=F3(u,v)")
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
- x_eq = StringProperty(name="X equation",
- description="Equation for x=F(u,v). " \
- "Also available: n, a, b, c, f, g, h",
- default="cos(v)*(1+cos(u))*sin(v/8)")
-
- y_eq = StringProperty(name="Y equation",
- description="Equation for y=F(u,v). " \
- "Also available: n, a, b, c, f, g, h",
- default="sin(u)*sin(v/8)+cos(v/8)*1.5")
-
- z_eq = StringProperty(name="Z equation",
- description="Equation for z=F(u,v). " \
- "Also available: n, a, b, c, f, g, h",
- default="sin(v)*(1+cos(u))*sin(v/8)")
-
- range_u_min = FloatProperty(name="U min",
- description="Minimum U value. Lower boundary of U range",
- min=-100.00,
- max=0.00,
- default=0.00)
-
- range_u_max = FloatProperty(name="U max",
- description="Maximum U value. Upper boundary of U range",
- min=0.00,
- max=100.00,
- default=2 * pi)
-
- range_u_step = IntProperty(name="U step",
- description="U Subdivisions",
- min=1,
- max=1024,
- default=32)
-
- wrap_u = BoolProperty(name="U wrap",
- description="U Wrap around",
- default=True)
-
- range_v_min = FloatProperty(name="V min",
- description="Minimum V value. Lower boundary of V range",
- min=-100.00,
- max=0.00,
- default=0.00)
-
- range_v_max = FloatProperty(name="V max",
- description="Maximum V value. Upper boundary of V range",
- min=0.00,
- max=100.00,
- default=4 * pi)
-
- range_v_step = IntProperty(name="V step",
- description="V Subdivisions",
- min=1,
- max=1024,
- default=128)
-
- wrap_v = BoolProperty(name="V wrap",
- description="V Wrap around",
- default=False)
-
- close_v = BoolProperty(name="Close V",
- description="Create faces for first and last " \
- "V values (only if U is wrapped)",
- default=False)
-
- n_eq = IntProperty(name="Number of objects (n=0..N-1)",
- description="The parameter n will be the index " \
- "of the current object, 0 to N-1",
- min=1,
- max=100,
- default=1)
-
- a_eq = StringProperty(name="A helper function",
- description="Equation for a=F(u,v). Also available: n",
- default="0")
-
- b_eq = StringProperty(name="B helper function",
- description="Equation for b=F(u,v). Also available: n",
- default="0")
-
- c_eq = StringProperty(name="C helper function",
- description="Equation for c=F(u,v). Also available: n",
- default="0")
-
- f_eq = StringProperty(name="F helper function",
- description="Equation for f=F(u,v). Also available: n, a, b, c",
- default="0")
-
- g_eq = StringProperty(name="G helper function",
- description="Equation for g=F(u,v). Also available: n, a, b, c",
- default="0")
-
- h_eq = StringProperty(name="H helper function",
- description="Equation for h=F(u,v). Also available: n, a, b, c",
- default="0")
+ x_eq = StringProperty(
+ name="X equation",
+ description="Equation for x=F(u,v). "
+ "Also available: n, a, b, c, f, g, h",
+ default="cos(v)*(1+cos(u))*sin(v/8)"
+ )
+ y_eq = StringProperty(
+ name="Y equation",
+ description="Equation for y=F(u,v). "
+ "Also available: n, a, b, c, f, g, h",
+ default="sin(u)*sin(v/8)+cos(v/8)*1.5"
+ )
+ z_eq = StringProperty(
+ name="Z equation",
+ description="Equation for z=F(u,v). "
+ "Also available: n, a, b, c, f, g, h",
+ default="sin(v)*(1+cos(u))*sin(v/8)"
+ )
+ range_u_min = FloatProperty(
+ name="U min",
+ description="Minimum U value. Lower boundary of U range",
+ min=-100.00,
+ max=0.00,
+ default=0.00
+ )
+ range_u_max = FloatProperty(
+ name="U max",
+ description="Maximum U value. Upper boundary of U range",
+ min=0.00,
+ max=100.00,
+ default=2 * pi
+ )
+ range_u_step = IntProperty(
+ name="U step",
+ description="U Subdivisions",
+ min=1,
+ max=1024,
+ default=32
+ )
+ wrap_u = BoolProperty(
+ name="U wrap",
+ description="U Wrap around",
+ default=True
+ )
+ range_v_min = FloatProperty(
+ name="V min",
+ description="Minimum V value. Lower boundary of V range",
+ min=-100.00,
+ max=0.00,
+ default=0.00
+ )
+ range_v_max = FloatProperty(
+ name="V max",
+ description="Maximum V value. Upper boundary of V range",
+ min=0.00,
+ max=100.00,
+ default=4 * pi
+ )
+ range_v_step = IntProperty(
+ name="V step",
+ description="V Subdivisions",
+ min=1,
+ max=1024,
+ default=128
+ )
+ wrap_v = BoolProperty(
+ name="V wrap",
+ description="V Wrap around",
+ default=False
+ )
+ close_v = BoolProperty(
+ name="Close V",
+ description="Create faces for first and last "
+ "V values (only if U is wrapped)",
+ default=False
+ )
+ n_eq = IntProperty(
+ name="Number of objects (n=0..N-1)",
+ description="The parameter n will be the index "
+ "of the current object, 0 to N-1",
+ min=1,
+ max=100,
+ default=1
+ )
+ a_eq = StringProperty(
+ name="A helper function",
+ description="Equation for a=F(u,v). Also available: n",
+ default="0"
+ )
+ b_eq = StringProperty(
+ name="B helper function",
+ description="Equation for b=F(u,v). Also available: n",
+ default="0"
+ )
+ c_eq = StringProperty(
+ name="C helper function",
+ description="Equation for c=F(u,v). Also available: n",
+ default="0"
+ )
+ f_eq = StringProperty(
+ name="F helper function",
+ description="Equation for f=F(u,v). Also available: n, a, b, c",
+ default="0"
+ )
+ g_eq = StringProperty(
+ name="G helper function",
+ description="Equation for g=F(u,v). Also available: n, a, b, c",
+ default="0"
+ )
+ h_eq = StringProperty(
+ name="H helper function",
+ description="Equation for h=F(u,v). Also available: n, a, b, c",
+ default="0"
+ )
def execute(self, context):
-
for n in range(0, self.n_eq):
-
verts, faces = xyz_function_surface_faces(
self,
self.x_eq,
@@ -472,8 +520,8 @@ class AddXYZFunctionSurface(bpy.types.Operator):
self.g_eq,
self.h_eq,
n,
- self.close_v)
-
+ self.close_v
+ )
if not verts:
return {'CANCELLED'}
diff --git a/add_mesh_extra_objects/add_mesh_beam_builder.py b/add_mesh_extra_objects/add_mesh_beam_builder.py
index 3f7cf285..9bbe1e25 100644
--- a/add_mesh_extra_objects/add_mesh_beam_builder.py
+++ b/add_mesh_extra_objects/add_mesh_beam_builder.py
@@ -1,38 +1,26 @@
-################################################################################
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This is free software; you may redistribute it, and/or modify it,
-# under the terms of the GNU General Public License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License (http://www.gnu.org/licenses/) for more details.
-#
-# ***** END GPL LICENSE BLOCK *****
-'''
-Create "Beam" primitives. Based on original script by revolt_randy.
-'''
-# Author(s): revolt_randy, Jambay
-#
+# GPL # "author": revolt_randy, Jambay
+
+# Create "Beam" primitives. Based on original script by revolt_randy.
# @todo: track 3D cursor for location.
-#
-################################################################################
+
import bpy
-from bpy.props import BoolProperty, EnumProperty, FloatProperty, FloatVectorProperty, IntProperty
+from bpy.props import (
+ EnumProperty,
+ FloatProperty,
+ IntProperty,
+ )
from bpy_extras import object_utils
-########################################
-#
+# #####################
# Create vertices for end of mesh
#
# y_off - verts y-axis origin
#
# returns:
# endVs - x,y,z list
-#
+
def beamEndVs(sRef, y_off):
thick = sRef.beamW * 2
@@ -63,15 +51,14 @@ def beamEndVs(sRef, y_off):
return endVs
-########################################
-#
+# #####################
# Create End Faces
#
# verts_list - list of vertices
#
# returns:
# beamFs, a list of tuples defining the end faces.
-#
+
def beamEndFaces(verts_list):
beamFs = []
@@ -98,8 +85,7 @@ def beamEndFaces(verts_list):
return beamFs
-########################################
-#
+# #####################
# Bridge vertices to create side faces.
#
# front_verts - front face vertices
@@ -109,7 +95,7 @@ def beamEndFaces(verts_list):
#
# returns:
# sideFaces, a list of the bridged faces
-#
+
def beamSides(front_verts, back_verts):
sideFaces = []
@@ -127,14 +113,13 @@ def beamSides(front_verts, back_verts):
return sideFaces
-####################################################
-#
+# #####################
# Creates a box beam
#
# returns:
# beamVs - x, y, z, location of each vertice
# beamFs - vertices that make up each face
-#
+
def create_beam(sRef):
frontVs = []
@@ -190,15 +175,14 @@ def create_beam(sRef):
return beamVs, beamFs
-########################################
-#
+# #####################
# Taper/angle faces of beam.
# inner vert toward outer vert
# based on percentage of taper.
#
# returns:
# adVert - the calculated vertex
-#
+
def beamSlant(sRef, outV, inV):
bTaper = 100 - sRef.edgeA
@@ -209,15 +193,14 @@ def beamSlant(sRef, outV, inV):
return adVert
-########################################
-#
+# #####################
# Modify location to shape beam.
#
# verts - tuples for one end of beam
#
# returns:
# verts - modified tuples for beam shape.
-#
+
def beamSquareEnds(sRef, verts):
# match 5th & 6th z locations to 1st & 2nd
@@ -235,7 +218,7 @@ def beamSquareEnds(sRef, verts):
return verts
-########################################
+# #####################
#
# Create U shaped beam
# Shared with C shape - see beamEndVs
@@ -244,7 +227,7 @@ def beamSquareEnds(sRef, verts):
# returns:
# beamVs - vertice x, y, z, locations
# beamFs - face vertices
-#
+
def create_u_beam(sRef):
# offset vertices from center
@@ -308,12 +291,11 @@ def create_u_beam(sRef):
return beamVs, beamFs
-###################################
-#
+# #####################
# returns:
# verts_final - x, y, z, location of each vertice
# faces_final - vertices that make up each face
-#
+
def create_L_beam(sRef):
thick = sRef.beamW
@@ -392,12 +374,11 @@ def create_L_beam(sRef):
return verts_final, faces_final
-###################################
-#
+# #####################
# returns:
# verts_final - a list of tuples of the x, y, z, location of each vertice
# faces_final - a list of tuples of the vertices that make up each face
-#
+
def create_T_beam(sRef):
thick = sRef.beamW
@@ -513,12 +494,11 @@ def create_T_beam(sRef):
return verts_final, faces_final
-###################################
-#
+# #####################
# returns:
# verts_final - a list of tuples of the x, y, z, location of each vertice
# faces_final - a list of tuples of the vertices that make up each face
-#
+
def create_I_beam(sRef):
thick = sRef.beamW
@@ -645,10 +625,10 @@ def create_I_beam(sRef):
return verts_final, faces_final
-################################################################################
+# ######################
#
# Generate beam object.
-#
+
def addBeamObj(sRef, context):
verts = []
faces = []
@@ -683,56 +663,75 @@ def addBeamObj(sRef, context):
bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)
-################################################################################
-#
+# ######################
# Create a beam primitive.
#
# UI functions and object creation.
-#
+
class addBeam(bpy.types.Operator):
bl_idname = "mesh.add_beam"
- bl_description = "Beam Builder"
bl_label = "Beam Builder"
+ bl_description = "Create beam meshes of various profiles"
bl_options = {'REGISTER', 'UNDO'}
- Type = EnumProperty(items=(
- ('0', "Box", "Square Beam"),
- ("1", "U", "U Beam"),
- ("2", "C", "C Beam"),
- ("3", "L", "L Beam"),
- ("4", "I", "T Beam"),
- ("5", "T", "I Beam")
- ),
- description="Beam form.")
-
- beamZ = FloatProperty(name="Height", min=0.01, max=100, default=1)
- beamX = FloatProperty(name="Width", min=0.01, max=100, default=.5)
- beamY = FloatProperty(name="Depth", min=0.01, max=100, default=2)
- beamW = FloatProperty(name="Thickness", min=0.01, max=1, default=0.1)
-
- edgeA = IntProperty(name="Taper", min=0, max=100, default=0, description="Angle beam edges.")
+ Type = EnumProperty(
+ items=(
+ ('0', "Box", "Square Beam"),
+ ("1", "U", "U Beam"),
+ ("2", "C", "C Beam"),
+ ("3", "L", "L Beam"),
+ ("4", "I", "T Beam"),
+ ("5", "T", "I Beam")
+ ),
+ description="Beam form."
+ )
+ beamZ = FloatProperty(
+ name="Height",
+ min=0.01, max=100,
+ default=1
+ )
+ beamX = FloatProperty(
+ name="Width",
+ min=0.01, max=100,
+ default=.5
+ )
+ beamY = FloatProperty(
+ name="Depth",
+ min=0.01,
+ max=100,
+ default=2
+ )
+ beamW = FloatProperty(
+ name="Thickness",
+ min=0.01, max=1,
+ default=0.1
+ )
+ edgeA = IntProperty(
+ name="Taper",
+ min=0, max=100,
+ default=0,
+ description="Angle beam edges"
+ )
- ########################################
def draw(self, context):
layout = self.layout
box = layout.box()
row = box.row()
- row.prop(self, 'Type', text='')
+ row.prop(self, "Type", text="")
- box.prop(self, 'beamZ')
- box.prop(self, 'beamX')
- box.prop(self, 'beamY')
- box.prop(self, 'beamW')
+ box.prop(self, "beamZ")
+ box.prop(self, "beamX")
+ box.prop(self, "beamY")
+ box.prop(self, "beamW")
if self.Type != '0':
- box.prop(self, 'edgeA')
+ box.prop(self, "edgeA")
- ########################################
def execute(self, context):
if bpy.context.mode == "OBJECT":
addBeamObj(self, context)
return {'FINISHED'}
- else:
- self.report({'WARNING'}, "Option only valid in Object mode")
- return {'CANCELLED'}
+
+ self.report({'WARNING'}, "Option only valid in Object mode")
+ return {'CANCELLED'}
diff --git a/add_mesh_extra_objects/add_mesh_gears.py b/add_mesh_extra_objects/add_mesh_gears.py
index 0518e659..7dc201d9 100644
--- a/add_mesh_extra_objects/add_mesh_gears.py
+++ b/add_mesh_extra_objects/add_mesh_gears.py
@@ -1,13 +1,19 @@
# GPL # (c) 2009, 2010 Michel J. Anders (varkenvarken)
import bpy
-from math import *
-from bpy.props import *
+from bpy.types import Operator
+from math import atan, asin, cos, sin, tan, pi, radians
+from bpy.props import (
+ FloatProperty,
+ IntProperty,
+ )
+
# Create a new mesh (object) from verts/edges/faces.
# verts/edges/faces ... List of vertices/edges/faces for the
-# new mesh (as used in from_pydata).
-# name ... Name of the new mesh (& object).
+# new mesh (as used in from_pydata)
+# name ... Name of the new mesh (& object)
+
def create_mesh_object(context, verts, edges, faces, name):
# Create new mesh
mesh = bpy.data.meshes.new(name)
@@ -21,19 +27,20 @@ def create_mesh_object(context, verts, edges, faces, name):
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)
+
# A very simple "bridge" tool.
# Connects two equally long vertex rows with faces.
# Returns a list of the new faces (list of lists)
#
-# vertIdx1 ... First vertex list (list of vertex indices).
-# vertIdx2 ... Second vertex list (list of vertex indices).
-# closed ... Creates a loop (first & last are closed).
-# flipped ... Invert the normal of the face(s).
+# vertIdx1 ... First vertex list (list of vertex indices)
+# vertIdx2 ... Second vertex list (list of vertex indices)
+# closed ... Creates a loop (first & last are closed)
+# flipped ... Invert the normal of the face(s)
#
# Note: You can set vertIdx1 to a single vertex index to create
-# a fan/star of faces.
+# a fan/star of faces
# Note: If both vertex idx list are the same length they have
-# to have at least 2 vertices.
+# to have at least 2 vertices
def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
faces = []
@@ -90,6 +97,7 @@ def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
return faces
+
# Calculate the vertex coordinates for a single
# section of a gear tooth.
# Returns 4 lists of vertex coords (list of tuples):
@@ -160,9 +168,10 @@ def add_tooth(a, t, d, radius, Ad, De, base, p_angle, rack=0, crown=0.0):
return (verts_inner_base, verts_outer_base,
verts_middle_tooth, verts_tip_tooth)
+
# EXPERIMENTAL Calculate the vertex coordinates for a single
# section of a gearspoke.
-# Returns them as a list of tuples.
+# Returns them as a list of tuples
#
# a
# t
@@ -181,7 +190,6 @@ def add_tooth(a, t, d, radius, Ad, De, base, p_angle, rack=0, crown=0.0):
def add_spoke(a, t, d, radius, De, base, s, w, l, gap=0, width=19):
Rd = radius - De
Rb = Rd - base
- # Rl = Rb # UNUSED
verts = []
edgefaces = []
@@ -216,29 +224,30 @@ def add_spoke(a, t, d, radius, De, base, s, w, l, gap=0, width=19):
return verts, edgefaces, edgefaces2, sf
+
# Create gear geometry.
# Returns:
# * A list of vertices (list of tuples)
# * A list of faces (list of lists)
-# * A list (group) of vertices of the tip (list of vertex indices).
-# * A list (group) of vertices of the valley (list of vertex indices).
+# * A list (group) of vertices of the tip (list of vertex indices)
+# * A list (group) of vertices of the valley (list of vertex indices)
#
-# teethNum ... Number of teeth on the gear.
+# teethNum ... Number of teeth on the gear
# radius ... Radius of the gear, negative for crown gear
-# Ad ... Addendum, extent of tooth above radius.
-# De ... Dedendum, extent of tooth below radius.
-# base ... Base, extent of gear below radius.
+# Ad ... Addendum, extent of tooth above radius
+# De ... Dedendum, extent of tooth below radius
+# base ... Base, extent of gear below radius
# p_angle ... Pressure angle. Skewness of tooth tip. (radiant)
-# width ... Width, thickness of gear.
+# width ... Width, thickness of gear
# skew ... Skew of teeth. (radiant)
# conangle ... Conical angle of gear. (radiant)
# rack
-# crown ... Inward pointing extend of crown teeth.
+# crown ... Inward pointing extend of crown teeth
#
# inner radius = radius - (De + base)
def add_gear(teethNum, radius, Ad, De, base, p_angle,
- width=1, skew=0, conangle=0, rack=0, crown=0.0):
+ width=1, skew=0, conangle=0, rack=0, crown=0.0):
if teethNum < 2:
return None, None, None, None
@@ -266,8 +275,7 @@ def add_gear(teethNum, radius, Ad, De, base, p_angle,
verts_outside_top = []
verts_outside_bottom = []
for (s, d, c, top) \
- in [(0, -width, 1, True), \
- (skew, width, scale, False)]:
+ in [(0, -width, 1, True), (skew, width, scale, False)]:
verts1, verts2, verts3, verts4 = add_tooth(a + s, t, d,
radius * c, Ad * c, De * c, base * c, p_angle,
@@ -290,7 +298,7 @@ def add_gear(teethNum, radius, Ad, De, base, p_angle,
verts_outside.append(vertsIdx2[-1])
if top:
- #verts_inside_top = vertsIdx1
+ # verts_inside_top = vertsIdx1
verts_outside_top = verts_outside
verts_bridge_start.append(vertsIdx1[0])
@@ -299,7 +307,7 @@ def add_gear(teethNum, radius, Ad, De, base, p_angle,
verts_bridge_end.append(vertsIdx2[-1])
else:
- #verts_inside_bottom = vertsIdx1
+ # verts_inside_bottom = vertsIdx1
verts_outside_bottom = verts_outside
verts_bridge_start.append(vertsIdx2[0])
@@ -323,8 +331,8 @@ def add_gear(teethNum, radius, Ad, De, base, p_angle,
faces.extend(faces_tooth_middle_top)
faces.extend(faces_tooth_outer_top)
- #faces_inside = createFaces(verts_inside_top, verts_inside_bottom)
- #faces.extend(faces_inside)
+ # faces_inside = createFaces(verts_inside_top, verts_inside_bottom)
+ # faces.extend(faces_inside)
faces_outside = createFaces(verts_outside_top, verts_outside_bottom,
flipped=True)
@@ -336,7 +344,6 @@ def add_gear(teethNum, radius, Ad, De, base, p_angle,
# Bridge one tooth to the next
if verts_bridge_prev:
faces_bridge = createFaces(verts_bridge_prev, verts_bridge_start)
- #, closed=True (for "inside" faces)
faces.extend(faces_bridge)
# Remember "end" vertices for next tooth.
@@ -344,21 +351,21 @@ def add_gear(teethNum, radius, Ad, De, base, p_angle,
# Bridge the first to the last tooth.
faces_bridge_f_l = createFaces(verts_bridge_prev, verts_bridge_first)
- #, closed=True (for "inside" faces)
faces.extend(faces_bridge_f_l)
return verts, faces, vgroup_top, vgroup_valley
-# Create spokes geometry.
+
+# Create spokes geometry
# Returns:
# * A list of vertices (list of tuples)
# * A list of faces (list of lists)
#
# teethNum ... Number of teeth on the gear.
# radius ... Radius of the gear, negative for crown gear
-# De ... Dedendum, extent of tooth below radius.
-# base ... Base, extent of gear below radius.
-# width ... Width, thickness of gear.
+# De ... Dedendum, extent of tooth below radius
+# base ... Base, extent of gear below radius
+# width ... Width, thickness of gear
# conangle ... Conical angle of gear. (radiant)
# rack
# spoke
@@ -369,10 +376,10 @@ def add_gear(teethNum, radius, Ad, De, base, p_angle,
#
# @todo Finish this
# @todo Create a function that takes a "Gear" and creates a
-# matching "Gear Spokes" object.
+# matching "Gear Spokes" object
def add_spokes(teethNum, radius, De, base, width=1, conangle=0, rack=0,
- spoke=3, spbevel=0.1, spwidth=0.2, splength=1.0, spresol=9):
+ spoke=3, spbevel=0.1, spwidth=0.2, splength=1.0, spresol=9):
if teethNum < 2:
return None, None, None, None
@@ -433,6 +440,7 @@ def add_spokes(teethNum, radius, De, base, width=1, conangle=0, rack=0,
return verts, faces
+
# Create worm geometry.
# Returns:
# * A list of vertices
@@ -442,16 +450,17 @@ def add_spokes(teethNum, radius, De, base, width=1, conangle=0, rack=0,
#
# teethNum ... Number of teeth on the worm
# radius ... Radius of the gear, negative for crown gear
-# Ad ... Addendum, extent of tooth above radius.
-# De ... Dedendum, extent of tooth below radius.
+# Ad ... Addendum, extent of tooth above radius
+# De ... Dedendum, extent of tooth below radius
# p_angle ... Pressure angle. Skewness of tooth tip. (radiant)
-# width ... Width, thickness of gear.
-# crown ... Inward pointing extend of crown teeth.
+# width ... Width, thickness of gear
+# crown ... Inward pointing extend of crown teeth
#
-# @todo: Fix teethNum. Some numbers are not possible yet.
+# @todo: Fix teethNum. Some numbers are not possible yet
# @todo: Create start & end geoemtry (closing faces)
+
def add_worm(teethNum, rowNum, radius, Ad, De, p_angle,
- width=1, skew=radians(11.25), crown=0.0):
+ width=1, skew=radians(11.25), crown=0.0):
worm = teethNum
teethNum = 24
@@ -463,7 +472,7 @@ def add_worm(teethNum, rowNum, radius, Ad, De, p_angle,
vgroup_top = [] # Vertex group of top/tip? vertices.
vgroup_valley = [] # Vertex group of valley vertices
- #width = width / 2.0
+ # width = width / 2.0
edgeloop_prev = []
for Row in range(rowNum):
@@ -534,10 +543,11 @@ def add_worm(teethNum, rowNum, radius, Ad, De, p_angle,
return verts, faces, vgroup_top, vgroup_valley
-class AddGear(bpy.types.Operator):
- """Add a gear mesh"""
+
+class AddGear(Operator):
bl_idname = "mesh.primitive_gear"
bl_label = "Add Gear"
+ bl_description = "Construct a gear mesh"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
number_of_teeth = IntProperty(name="Number of Teeth",
@@ -621,7 +631,6 @@ class AddGear(bpy.types.Operator):
box.prop(self, 'conangle')
box.prop(self, 'crown')
-
def execute(self, context):
verts, faces, verts_tip, verts_valley = add_gear(
self.number_of_teeth,
@@ -633,7 +642,8 @@ class AddGear(bpy.types.Operator):
width=self.width,
skew=self.skew,
conangle=self.conangle,
- crown=self.crown)
+ crown=self.crown
+ )
# Actually create the mesh object from this geometry data.
base = create_mesh_object(context, verts, [], faces, "Gear")
@@ -650,79 +660,98 @@ class AddGear(bpy.types.Operator):
return {'FINISHED'}
-class AddWormGear(bpy.types.Operator):
- """Add a worm gear mesh"""
+
+class AddWormGear(Operator):
bl_idname = "mesh.primitive_worm_gear"
bl_label = "Add Worm Gear"
+ bl_description = "Construct a worm gear mesh"
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)
- number_of_rows = IntProperty(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)
- addendum = FloatProperty(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)
- 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')
- row_height = FloatProperty(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')
- crown = FloatProperty(name="Crown",
- description="Inward pointing extend of crown teeth",
- min=0.0,
- max=100.0,
- unit='LENGTH',
- default=0.0)
+ number_of_teeth = IntProperty(
+ 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
+ )
+ radius = FloatProperty(
+ 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
+ )
+ dedendum = FloatProperty(
+ 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'
+ )
+ row_height = FloatProperty(
+ 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'
+ )
+ crown = FloatProperty(
+ 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
box = layout.box()
- box.prop(self, 'number_of_teeth')
- box.prop(self, 'number_of_rows')
- box.prop(self, 'radius')
- box.prop(self, 'row_height')
+ box.prop(self, "number_of_teeth")
+ 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.prop(self, "addendum")
+ box.prop(self, "dedendum")
box = layout.box()
- box.prop(self, 'angle')
- box.prop(self, 'skew')
- box.prop(self, 'crown')
+ box.prop(self, "angle")
+ box.prop(self, "skew")
+ box.prop(self, "crown")
def execute(self, context):
@@ -735,7 +764,8 @@ class AddWormGear(bpy.types.Operator):
self.angle,
width=self.row_height,
skew=self.skew,
- crown=self.crown)
+ crown=self.crown
+ )
# Actually create the mesh object from this geometry data.
base = create_mesh_object(context, verts, [], faces, "Worm Gear")
diff --git a/add_mesh_extra_objects/add_mesh_gemstones.py b/add_mesh_extra_objects/add_mesh_gemstones.py
index e6b4b67b..f99bcd43 100644
--- a/add_mesh_extra_objects/add_mesh_gemstones.py
+++ b/add_mesh_extra_objects/add_mesh_gemstones.py
@@ -1,14 +1,20 @@
# GPL # "author": "Pontiac, Fourmadmen, Dreampainter"
import bpy
-from mathutils import *
-from math import *
-from bpy.props import *
+from bpy.types import Operator
+from mathutils import Vector, Quaternion
+from math import cos, sin, pi
+from bpy.props import (
+ FloatProperty,
+ IntProperty,
+ )
+
# Create a new mesh (object) from verts/edges/faces.
# verts/edges/faces ... List of vertices/edges/faces for the
-# new mesh (as used in from_pydata).
-# name ... Name of the new mesh (& object).
+# new mesh (as used in from_pydata)
+# name ... Name of the new mesh (& object)
+
def create_mesh_object(context, verts, edges, faces, name):
# Create new mesh
@@ -23,6 +29,7 @@ def create_mesh_object(context, verts, edges, faces, name):
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)
+
# A very simple "bridge" tool.
def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
@@ -44,7 +51,7 @@ def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
total = len(vertIdx2)
if closed:
- # Bridge the start with the end.
+ # Bridge the start with the end
if flipped:
face = [
vertIdx1[0],
@@ -61,7 +68,7 @@ def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
face.append(vertIdx2[total - 1])
faces.append(face)
- # Bridge the rest of the faces.
+ # Bridge the rest of the faces
for num in range(total - 1):
if flipped:
if fan:
@@ -80,6 +87,7 @@ def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
return faces
+
# @todo Clean up vertex&face creation process a bit.
def add_gem(r1, r2, seg, h1, h2):
"""
@@ -139,8 +147,9 @@ def add_gem(r1, r2, seg, h1, h2):
return verts, faces
+
def add_diamond(segments, girdle_radius, table_radius,
- crown_height, pavilion_height):
+ crown_height, pavilion_height):
PI_2 = pi * 2.0
z_axis = (0.0, 0.0, -1.0)
@@ -192,37 +201,48 @@ def add_diamond(segments, girdle_radius, table_radius,
return verts, faces
-class AddDiamond(bpy.types.Operator):
- """Add a diamond mesh"""
+
+class AddDiamond(Operator):
bl_idname = "mesh.primitive_diamond_add"
bl_label = "Add Diamond"
+ bl_description = "Construct a diamond mesh"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
- segments = IntProperty(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)
- table_radius = FloatProperty(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)
- pavilion_height = FloatProperty(name="Pavilion Height",
- description="Pavilion height of the diamond",
- min=0.01,
- max=9999.0,
- default=0.8)
+ segments = IntProperty(
+ 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
+ )
+ table_radius = FloatProperty(
+ 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
+ )
+ pavilion_height = FloatProperty(
+ 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,
@@ -235,41 +255,50 @@ class AddDiamond(bpy.types.Operator):
return {'FINISHED'}
-class AddGem(bpy.types.Operator):
- """Add a diamond gem"""
+
+class AddGem(Operator):
bl_idname = "mesh.primitive_gem_add"
bl_label = "Add Gem"
- bl_description = "Create an offset faceted gem"
+ bl_description = "Construct an offset faceted gem mesh"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
- segments = IntProperty(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)
- crown_radius = FloatProperty(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)
- pavilion_height = FloatProperty(name="Pavilion height",
- description="Height of bottom half",
- min=0.01,
- max=9999.0,
- default=0.8)
+ segments = IntProperty(
+ 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
+ )
+ crown_radius = FloatProperty(
+ 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
+ )
+ pavilion_height = FloatProperty(
+ name="Pavilion height",
+ description="Height of bottom half",
+ min=0.01,
+ max=9999.0,
+ default=0.8
+ )
def execute(self, context):
-
# create mesh
verts, faces = add_gem(
self.pavilion_radius,
diff --git a/add_mesh_extra_objects/add_mesh_honeycomb.py b/add_mesh_extra_objects/add_mesh_honeycomb.py
index 3e30afe7..e93b3b86 100644
--- a/add_mesh_extra_objects/add_mesh_honeycomb.py
+++ b/add_mesh_extra_objects/add_mesh_honeycomb.py
@@ -1,6 +1,16 @@
# GPL # "author": "Kayo Phoenix"
+import bpy
+from bpy_extras import object_utils
from math import pi, sin, cos
+from bpy.props import (
+ IntProperty,
+ BoolProperty,
+ BoolVectorProperty,
+ FloatProperty,
+ FloatVectorProperty,
+ )
+
class honeycomb_geometry():
def __init__(self, rows, cols, D, E):
@@ -21,7 +31,6 @@ class honeycomb_geometry():
self.r = self.R - self.e
self.hr = 0.5 * self.r
-
self.H = self.R * (1.5 * self.rows + 0.5) + self.e
if self.rows > 1:
self.W = self.d * (self.cols + 0.5) + self.E
@@ -41,47 +50,64 @@ class honeycomb_geometry():
def vert(self, row, col):
# full cell
- if row >= 0 and row < self.rows and col >= 0 and col < self.cols: return [0, 1, 2, 3, 4, 5]
+ if row >= 0 and row < self.rows and col >= 0 and col < self.cols:
+ return [0, 1, 2, 3, 4, 5]
# right down corner
- if row == -1 and col == self.cols - 1: return [1, 2]
- if row == 0 and self.rows > 1 and col == self.cols: return [1, 2, 3]
+ if row == -1 and col == self.cols - 1:
+ return [1, 2]
+ if row == 0 and self.rows > 1 and col == self.cols:
+ return [1, 2, 3]
# left down corner
- if row == -1 and col == -1: return [0, 1]
+ if row == -1 and col == -1:
+ return [0, 1]
if self.rows % 2:
# left up corner
- if row == self.rows and col == -1: return [4, 5]
+ if row == self.rows and col == -1:
+ return [4, 5]
# right up corner
- if row == self.rows and col == self.cols - 1: return [3, 4]
- if row == self.rows - 1 and self.rows > 1 and col == self.cols: return [2, 3, 4]
+ if row == self.rows and col == self.cols - 1:
+ return [3, 4]
+ if row == self.rows - 1 and self.rows > 1 and col == self.cols:
+ return [2, 3, 4]
else:
# left up corner
- if row == self.rows and col == 0: return [4, 5]
- if row == self.rows - 1 and self.rows > 1 and col == -1: return [0, 4, 5]
+ if row == self.rows and col == 0:
+ return [4, 5]
+ if row == self.rows - 1 and self.rows > 1 and col == -1:
+ return [0, 4, 5]
# right up corner
- if row == self.rows and col == self.cols: return [3, 4]
+ if row == self.rows and col == self.cols:
+ return [3, 4]
# horizontal lines
if col >= 0 and col < self.cols:
- if row == -1: return [0, 1, 2]
- if row == self.rows: return [3, 4, 5]
+ if row == -1:
+ return [0, 1, 2]
+ if row == self.rows:
+ return [3, 4, 5]
# vertical lines
if row >= 0 and row < self.rows:
if col == -1:
- if row % 2: return [0, 1, 4, 5]
- else: return [0, 5]
+ if row % 2:
+ return [0, 1, 4, 5]
+ else:
+ return [0, 5]
if col == self.cols:
- if row % 2 or self.rows == 1: return [2, 3]
- else: return [1, 2, 3, 4]
+ if row % 2 or self.rows == 1:
+ return [2, 3]
+ else:
+ return [1, 2, 3, 4]
return []
def cell(self, row, col, idx):
- cp = [self.sx + self.dx * col, self.sy + self.dy * row, 0] # central point
- if row % 2: cp[0] += self.gx
- co = [] # vertexes coords
+ cp = [self.sx + self.dx * col, self.sy + self.dy * row, 0] # central point
+ if row % 2:
+ cp[0] += self.gx
+ co = [] # vertices coords
vi = self.vert(row, col)
ap = {}
for i in vi:
- a = pi / 6 + i * pi / 3 # angle
+ a = pi / 6 + i * pi / 3 # angle
ap[i] = idx + len(co)
co.append((cp[0] + cos(a) * self.r, cp[1] + sin(a) * self.r, cp[2]))
return co, ap
@@ -115,7 +141,8 @@ class honeycomb_geometry():
# top row
row = len(cells) - 1
cs = 0
- if row % 2: cs += 1
+ if row % 2:
+ cs += 1
for col in range(1 + cs, len(cells[row]) - 1):
s = cells[row][col]
l = cells[row][col - 1]
@@ -126,7 +153,8 @@ class honeycomb_geometry():
# middle rows
for row in range(1, len(cells) - 1):
cs = 0
- if row % 2: cs += 1
+ if row % 2:
+ cs += 1
for col in range(1, len(cells[row]) - 1):
s = cells[row][col]
l = cells[row][col - 1]
@@ -144,7 +172,8 @@ class honeycomb_geometry():
col = len(cells[row]) - 1
for row in range(1, len(cells) - 1):
cs = 0
- if row % 2: cs += 1
+ if row % 2:
+ cs += 1
s = cells[row][col]
l = cells[row][col - 1]
@@ -170,72 +199,78 @@ class honeycomb_geometry():
return verts, faces
-import bpy
-from bpy.props import *
-from bpy_extras import object_utils
def edge_max(diam):
return diam * sin(pi / 3)
+
class add_mesh_honeycomb(bpy.types.Operator):
- """Simple honeycomb mesh generator"""
- bl_idname = 'mesh.honeycomb_add'
- bl_label = 'Add HoneyComb'
+ bl_idname = "mesh.honeycomb_add"
+ bl_label = "Add HoneyComb"
+ bl_description = "Simple honeycomb mesh generator"
bl_options = {'REGISTER', 'UNDO'}
+ def fix_edge(self, context):
+ m = edge_max(self.diam)
+ if self.edge > m:
+ 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'},
- )
- def fix_edge(self, context):
- m = edge_max(self.diam)
- if self.edge > m: self.edge = m
-
+ 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'
+ )
- ##### POLL #####
@classmethod
def poll(cls, context):
return context.scene is not None
- ##### EXECUTE #####
def execute(self, context):
mesh = bpy.data.meshes.new(name='honeycomb')
comb = honeycomb_geometry(self.rows, self.cols, self.diam, self.edge)
verts, faces = comb.generate()
- mesh.from_pydata(vertices = verts, edges = [], faces = faces)
+ mesh.from_pydata(vertices=verts, edges=[], faces=faces)
mesh.update()
object_utils.object_data_add(context, mesh, operator=self)
diff --git a/add_mesh_extra_objects/add_mesh_menger_sponge.py b/add_mesh_extra_objects/add_mesh_menger_sponge.py
index 1e58ebce..3f9ec241 100644
--- a/add_mesh_extra_objects/add_mesh_menger_sponge.py
+++ b/add_mesh_extra_objects/add_mesh_menger_sponge.py
@@ -3,13 +3,18 @@
# This file is distributed under the MIT License. See the LICENSE.md for more details.
import bpy
+from bpy.props import (
+ IntProperty,
+ BoolProperty,
+ BoolVectorProperty,
+ FloatVectorProperty,
+ FloatProperty,
+ )
-from bpy.props import IntProperty, BoolProperty, BoolVectorProperty, FloatVectorProperty, FloatProperty
-
-import bpy
import mathutils
import copy
+
class MengerSponge(object):
FACE_INDICES = [
[3, 7, 4, 0],
@@ -111,13 +116,13 @@ class MengerSponge(object):
continue
next_points = [
local_vert_map[(x, y, z)],
- local_vert_map[(x+1, y, z)],
- local_vert_map[(x+1, y, z+1)],
- local_vert_map[(x, y, z+1)],
- local_vert_map[(x, y+1, z)],
- local_vert_map[(x+1, y+1, z)],
- local_vert_map[(x+1, y+1, z+1)],
- local_vert_map[(x, y+1, z+1)],
+ local_vert_map[(x + 1, y, z)],
+ local_vert_map[(x + 1, y, z + 1)],
+ local_vert_map[(x, y, z + 1)],
+ local_vert_map[(x, y + 1, z)],
+ local_vert_map[(x + 1, y + 1, z)],
+ local_vert_map[(x + 1, y + 1, z + 1)],
+ local_vert_map[(x, y + 1, z + 1)],
]
visibility = copy.copy(self.__face_visibility[(x, y, z)])
if face_vis:
@@ -134,44 +139,43 @@ class MengerSponge(object):
class AddMengerSponge(bpy.types.Operator):
- """Add a menger sponge"""
bl_idname = "mesh.menger_sponge_add"
bl_label = "Menger Sponge"
+ bl_description = "Construct a menger sponge mesh"
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)
vertices, faces = sponger.create(self.radius * 2, self.radius * 2)
@@ -182,7 +186,7 @@ class AddMengerSponge(bpy.types.Operator):
uvs = [(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)]
mesh.uv_textures.new()
for i, uvloop in enumerate(mesh.uv_layers.active.data):
- uvloop.uv = uvs[i%4]
+ uvloop.uv = uvs[i % 4]
from bpy_extras import object_utils
object_utils.object_data_add(context, mesh, operator=self)
diff --git a/add_mesh_extra_objects/add_mesh_pipe_joint.py b/add_mesh_extra_objects/add_mesh_pipe_joint.py
index 85899cd3..c0a995d8 100644
--- a/add_mesh_extra_objects/add_mesh_pipe_joint.py
+++ b/add_mesh_extra_objects/add_mesh_pipe_joint.py
@@ -1,13 +1,19 @@
# GPL # "author": "Buerbaum Martin (Pontiac)"
import bpy
-from math import *
-from bpy.props import *
+from math import sin, cos, tan, pi, radians
+from bpy.types import Operator
+from bpy.props import (
+ FloatProperty,
+ IntProperty,
+ )
+
# Create a new mesh (object) from verts/edges/faces.
# verts/edges/faces ... List of vertices/edges/faces for the
-# new mesh (as used in from_pydata).
-# name ... Name of the new mesh (& object).
+# new mesh (as used in from_pydata)
+# name ... Name of the new mesh (& object)
+
def create_mesh_object(context, verts, edges, faces, name):
# Create new mesh
mesh = bpy.data.meshes.new(name)
@@ -21,6 +27,7 @@ def create_mesh_object(context, verts, edges, faces, name):
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)
+
# A very simple "bridge" tool.
def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
@@ -78,46 +85,55 @@ def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
return faces
-class AddElbowJoint(bpy.types.Operator):
- # Create the vertices and polygons for a simple elbow (bent pipe).
- """Add an Elbow pipe mesh"""
+
+# Create the vertices and polygons for a simple elbow (bent pipe)
+
+class AddElbowJoint(Operator):
bl_idname = "mesh.primitive_elbow_joint_add"
bl_label = "Add Pipe Elbow"
+ bl_description = "Construct an elbow pipe mesh"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
- radius = FloatProperty(name="Radius",
+ radius = FloatProperty(
+ name="Radius",
description="The radius of the pipe",
default=1.0,
min=0.01,
max=100.0,
- unit="LENGTH")
- div = IntProperty(name="Divisions",
+ unit="LENGTH"
+ )
+ div = IntProperty(
+ name="Divisions",
description="Number of vertices (divisions)",
- default=32, min=3, max=256)
-
- angle = FloatProperty(name="Angle",
- description="The angle of the branching pipe (i.e. the 'arm' - " \
+ default=32, min=3, max=256
+ )
+ angle = FloatProperty(
+ name="Angle",
+ description="The angle of the branching pipe (i.e. the 'arm' - "
"Measured from the center line of the main pipe",
default=radians(45.0),
min=radians(-179.9),
max=radians(179.9),
- unit="ROTATION")
-
- startLength = FloatProperty(name="Length Start",
+ unit="ROTATION"
+ )
+ startLength = FloatProperty(
+ name="Length Start",
description="Length of the beginning of the pipe",
default=3.0,
min=0.01,
max=100.0,
- unit="LENGTH")
- endLength = FloatProperty(name="End Length",
+ unit="LENGTH"
+ )
+ endLength = FloatProperty(
+ name="End Length",
description="Length of the end of the pipe",
default=3.0,
min=0.01,
max=100.0,
- unit="LENGTH")
+ unit="LENGTH"
+ )
def execute(self, context):
-
radius = self.radius
div = self.div
@@ -177,57 +193,68 @@ class AddElbowJoint(bpy.types.Operator):
return {'FINISHED'}
-class AddTeeJoint(bpy.types.Operator):
- # Create the vertices and polygons for a simple tee (T) joint.
- # The base arm of the T can be positioned in an angle if needed though.
- """Add a Tee-Joint mesh"""
+
+# Create the vertices and polygons for a simple tee (T) joint
+# The base arm of the T can be positioned in an angle if needed though
+
+class AddTeeJoint(Operator):
bl_idname = "mesh.primitive_tee_joint_add"
bl_label = "Add Pipe Tee-Joint"
+ bl_description = "Construct a tee-joint pipe mesh"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
- radius = FloatProperty(name="Radius",
+ radius = FloatProperty(
+ name="Radius",
description="The radius of the pipe",
default=1.0,
min=0.01,
max=100.0,
- unit="LENGTH")
- div = IntProperty(name="Divisions",
+ unit="LENGTH"
+ )
+ div = IntProperty(
+ name="Divisions",
description="Number of vertices (divisions)",
default=32,
min=4,
- max=256)
-
- angle = FloatProperty(name="Angle",
- description="The angle of the branching pipe (i.e. the 'arm' - " \
+ max=256
+ )
+ angle = FloatProperty(
+ name="Angle",
+ description="The angle of the branching pipe (i.e. the 'arm' - "
"Measured from the center line of the main pipe",
default=radians(90.0),
min=radians(0.1),
max=radians(179.9),
- unit="ROTATION")
-
- startLength = FloatProperty(name="Length Start",
- description="Length of the beginning of the" \
+ unit="ROTATION"
+ )
+ startLength = FloatProperty(
+ name="Length Start",
+ description="Length of the beginning of the"
" main pipe (the straight one)",
default=3.0,
min=0.01,
max=100.0,
- unit="LENGTH")
- endLength = FloatProperty(name="End Length",
- description="Length of the end of the" \
+ unit="LENGTH"
+ )
+ endLength = FloatProperty(
+ name="End Length",
+ description="Length of the end of the"
" main pipe (the straight one)",
default=3.0,
min=0.01,
max=100.0,
- unit="LENGTH")
- branchLength = FloatProperty(name="Arm Length",
+ unit="LENGTH"
+ )
+ branchLength = FloatProperty(
+ name="Arm Length",
description="Length of the arm pipe (the bent one)",
default=3.0,
min=0.01,
max=100.0,
- unit="LENGTH")
+ unit="LENGTH"
+ )
def execute(self, context):
-
radius = self.radius
div = self.div
@@ -238,24 +265,20 @@ class AddTeeJoint(bpy.types.Operator):
branchLength = self.branchLength
if (div % 2):
- # Odd vertice number not supported (yet).
+ # Odd vertice number not supported (yet)
+ self.report({'INFO'}, "Odd vertices number is not yet supported")
return {'CANCELLED'}
verts = []
faces = []
# List of vert indices of each cross section
- loopMainStart = [] # Vert indices for the
- # beginning of the main pipe.
- loopJoint1 = [] # Vert indices for joint that is used
- # to connect the joint & loopMainStart.
- loopJoint2 = [] # Vert indices for joint that is used
- # to connect the joint & loopArm.
- loopJoint3 = [] # Vert index for joint that is used
- # to connect the joint & loopMainEnd.
- loopArm = [] # Vert indices for the end of the arm.
- loopMainEnd = [] # Vert indices for the
- # end of the main pipe.
+ loopMainStart = [] # Vert indices for the beginning of the main pipe
+ loopJoint1 = [] # Vert indices for joint that is used to connect the joint & loopMainStart
+ loopJoint2 = [] # Vert indices for joint that is used to connect the joint & loopArm
+ loopJoint3 = [] # Vert index for joint that is used to connect the joint & loopMainEnd
+ loopArm = [] # Vert indices for the end of the arm
+ loopMainEnd = [] # Vert indices for the end of the main pipe.
# Create start circle (main pipe)
for vertIdx in range(div):
@@ -355,61 +378,73 @@ class AddTeeJoint(bpy.types.Operator):
return {'FINISHED'}
-class AddWyeJoint(bpy.types.Operator):
- """Add a Wye-Joint mesh"""
+
+class AddWyeJoint(Operator):
bl_idname = "mesh.primitive_wye_joint_add"
bl_label = "Add Pipe Wye-Joint"
+ bl_description = "Construct a wye-joint pipe mesh"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
- radius = FloatProperty(name="Radius",
+ radius = FloatProperty(
+ name="Radius",
description="The radius of the pipe",
default=1.0,
min=0.01,
max=100.0,
- unit="LENGTH")
- div = IntProperty(name="Divisions",
+ unit="LENGTH"
+ )
+ div = IntProperty(
+ name="Divisions",
description="Number of vertices (divisions)",
default=32,
min=4,
- max=256)
-
- angle1 = FloatProperty(name="Angle 1",
- description="The angle of the 1. branching pipe " \
+ max=256
+ )
+ angle1 = FloatProperty(
+ name="Angle 1",
+ description="The angle of the 1. branching pipe "
"(measured from the center line of the main pipe)",
default=radians(45.0),
min=radians(-179.9),
max=radians(179.9),
- unit="ROTATION")
- angle2 = FloatProperty(name="Angle 2",
- description="The angle of the 2. branching pipe " \
+ unit="ROTATION"
+ )
+ angle2 = FloatProperty(
+ name="Angle 2",
+ description="The angle of the 2. branching pipe "
"(measured from the center line of the main pipe) ",
default=radians(45.0),
min=radians(-179.9),
max=radians(179.9),
- unit="ROTATION")
-
- startLength = FloatProperty(name="Length Start",
- description="Length of the beginning of the" \
+ unit="ROTATION"
+ )
+ startLength = FloatProperty(
+ name="Length Start",
+ description="Length of the beginning of the"
" main pipe (the straight one)",
default=3.0,
min=0.01,
max=100.0,
- unit="LENGTH")
- branch1Length = FloatProperty(name="Length Arm 1",
+ unit="LENGTH"
+ )
+ branch1Length = FloatProperty(
+ name="Length Arm 1",
description="Length of the 1. arm",
default=3.0,
min=0.01,
max=100.0,
- unit="LENGTH")
- branch2Length = FloatProperty(name="Length Arm 2",
+ unit="LENGTH"
+ )
+ branch2Length = FloatProperty(
+ name="Length Arm 2",
description="Length of the 2. arm",
default=3.0,
min=0.01,
max=100.0,
- unit="LENGTH")
+ unit="LENGTH"
+ )
def execute(self, context):
-
radius = self.radius
div = self.div
@@ -421,23 +456,20 @@ class AddWyeJoint(bpy.types.Operator):
branch2Length = self.branch2Length
if (div % 2):
- # Odd vertice number not supported (yet).
+ # Odd vertice number not supported (yet)
+ self.report({'INFO'}, "Odd vertices number is not yet supported")
return {'CANCELLED'}
verts = []
faces = []
# List of vert indices of each cross section
- loopMainStart = [] # Vert indices for
- # the beginning of the main pipe.
- loopJoint1 = [] # Vert index for joint that is used
- # to connect the joint & loopMainStart.
- loopJoint2 = [] # Vert index for joint that
- # is used to connect the joint & loopArm1.
- loopJoint3 = [] # Vert index for joint that is
- # used to connect the joint & loopArm2.
- loopArm1 = [] # Vert idxs for end of the 1. arm.
- loopArm2 = [] # Vert idxs for end of the 2. arm.
+ loopMainStart = [] # Vert indices for the beginning of the main pipe
+ loopJoint1 = [] # Vert index for joint that is used to connect the joint & loopMainStart
+ loopJoint2 = [] # Vert index for joint that is used to connect the joint & loopArm1
+ loopJoint3 = [] # Vert index for joint that is used to connect the joint & loopArm2
+ loopArm1 = [] # Vert idxs for end of the 1. arm
+ loopArm2 = [] # Vert idxs for end of the 2. arm
# Create start circle
for vertIdx in range(div):
@@ -480,11 +512,9 @@ class AddWyeJoint(bpy.types.Operator):
if (vertIdx > div / 2):
curVertAngle = vertIdx * (2.0 * pi / div)
- locX = (-sin(curVertAngle) * sin(angleJoint)
- / sin(angle2 - angleJoint))
+ locX = (-sin(curVertAngle) * sin(angleJoint) / sin(angle2 - angleJoint))
locY = -cos(curVertAngle)
- locZ = (-(sin(curVertAngle) * cos(angleJoint)
- / sin(angle2 - angleJoint)))
+ locZ = (-(sin(curVertAngle) * cos(angleJoint) / sin(angle2 - angleJoint)))
loopTemp.append(len(verts))
verts.append([locX * radius, locY * radius, locZ * radius])
@@ -548,72 +578,86 @@ class AddWyeJoint(bpy.types.Operator):
return {'FINISHED'}
-class AddCrossJoint(bpy.types.Operator):
- """Add a Cross-Joint mesh"""
- # Create the vertices and polygons for a coss (+ or X) pipe joint.
+
+# Create the vertices and polygons for a cross (+ or X) pipe joint
+
+class AddCrossJoint(Operator):
bl_idname = "mesh.primitive_cross_joint_add"
bl_label = "Add Pipe Cross-Joint"
+ bl_description = "Construct a cross-joint pipe mesh"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
- radius = FloatProperty(name="Radius",
+ radius = FloatProperty(
+ name="Radius",
description="The radius of the pipe",
default=1.0,
min=0.01,
max=100.0,
- unit="LENGTH")
- div = IntProperty(name="Divisions",
+ unit="LENGTH"
+ )
+ div = IntProperty(
+ name="Divisions",
description="Number of vertices (divisions)",
default=32,
min=4,
- max=256)
-
- angle1 = FloatProperty(name="Angle 1",
+ max=256
+ )
+ angle1 = FloatProperty(
+ name="Angle 1",
description="The angle of the 1. arm (from the main axis)",
default=radians(90.0),
min=radians(-179.9),
max=radians(179.9),
- unit="ROTATION")
+ unit="ROTATION"
+ )
angle2 = FloatProperty(name="Angle 2",
description="The angle of the 2. arm (from the main axis)",
default=radians(90.0),
min=radians(-179.9),
max=radians(179.9),
- unit="ROTATION")
+ unit="ROTATION"
+ )
angle3 = FloatProperty(name="Angle 3 (center)",
description="The angle of the center arm (from the main axis)",
default=radians(0.0),
min=radians(-179.9),
max=radians(179.9),
- unit="ROTATION")
-
- startLength = FloatProperty(name="Length Start",
- description="Length of the beginning of the " \
+ unit="ROTATION"
+ )
+ startLength = FloatProperty(
+ name="Length Start",
+ description="Length of the beginning of the "
"main pipe (the straight one)",
default=3.0,
min=0.01,
max=100.0,
- unit="LENGTH")
+ unit="LENGTH"
+ )
branch1Length = FloatProperty(name="Length Arm 1",
description="Length of the 1. arm",
default=3.0,
min=0.01,
max=100.0,
- unit="LENGTH")
- branch2Length = FloatProperty(name="Length Arm 2",
+ unit="LENGTH"
+ )
+ branch2Length = FloatProperty(
+ name="Length Arm 2",
description="Length of the 2. arm",
default=3.0,
min=0.01,
max=100.0,
- unit="LENGTH")
- branch3Length = FloatProperty(name="Length Arm 3 (center)",
+ unit="LENGTH"
+ )
+ branch3Length = FloatProperty(
+ name="Length Arm 3 (center)",
description="Length of the center arm",
default=3.0,
min=0.01,
max=100.0,
- unit="LENGTH")
+ unit="LENGTH"
+ )
def execute(self, context):
-
radius = self.radius
div = self.div
@@ -626,26 +670,22 @@ class AddCrossJoint(bpy.types.Operator):
branch2Length = self.branch2Length
branch3Length = self.branch3Length
if (div % 2):
- # Odd vertice number not supported (yet).
+ # Odd vertice number not supported (yet)
+ self.report({'INFO'}, "Odd vertices number is not yet supported")
return {'CANCELLED'}
verts = []
faces = []
# List of vert indices of each cross section
- loopMainStart = [] # Vert indices for the
- # beginning of the main pipe.
- loopJoint1 = [] # Vert index for joint that is used
- # to connect the joint & loopMainStart.
- loopJoint2 = [] # Vert index for joint that is used
- # to connect the joint & loopArm1.
- loopJoint3 = [] # Vert index for joint that is used
- # to connect the joint & loopArm2.
- loopJoint4 = [] # Vert index for joint that is used
- # to connect the joint & loopArm3.
- loopArm1 = [] # Vert idxs for the end of the 1. arm.
- loopArm2 = [] # Vert idxs for the end of the 2. arm.
- loopArm3 = [] # Vert idxs for the center arm end.
+ loopMainStart = [] # Vert indices for the beginning of the main pipe
+ loopJoint1 = [] # Vert index for joint that is used to connect the joint & loopMainStart
+ loopJoint2 = [] # Vert index for joint that is used to connect the joint & loopArm1
+ loopJoint3 = [] # Vert index for joint that is used to connect the joint & loopArm2
+ loopJoint4 = [] # Vert index for joint that is used to connect the joint & loopArm3
+ loopArm1 = [] # Vert idxs for the end of the 1. arm
+ loopArm2 = [] # Vert idxs for the end of the 2. arm
+ loopArm3 = [] # Vert idxs for the center arm end
# Create start circle
for vertIdx in range(div):
@@ -681,8 +721,6 @@ class AddCrossJoint(bpy.types.Operator):
verts.append([locX * radius, locY * radius, locZ * radius])
- # loopTemp2 = loopJoint2[:] # UNUSED
-
# Create 2. deformed joint circle
loopTempA = []
loopTempB = []
@@ -693,7 +731,7 @@ class AddCrossJoint(bpy.types.Operator):
# Skip pole vertices
# @todo: This will possibly break if
- # we ever support odd divisions.
+ # we ever support odd divisions
if not (vertIdx == 0) and not (vertIdx == div / 2):
if (vertIdx > div / 2):
@@ -708,11 +746,9 @@ class AddCrossJoint(bpy.types.Operator):
Z = 1.0
loopTempB.append(len(verts))
- locX = (sin(curVertAngle) * sin(angleJoint)
- / sin(angle - angleJoint))
+ locX = (sin(curVertAngle) * sin(angleJoint) / sin(angle - angleJoint))
locY = -cos(curVertAngle)
- locZ = (Z * (sin(curVertAngle) * cos(angleJoint)
- / sin(angle - angleJoint)))
+ locZ = (Z * (sin(curVertAngle) * cos(angleJoint) / sin(angle - angleJoint)))
verts.append([locX * radius, locY * radius, locZ * radius])
@@ -802,35 +838,45 @@ class AddCrossJoint(bpy.types.Operator):
return {'FINISHED'}
-class AddNJoint(bpy.types.Operator):
- """Add a N-Joint mesh"""
- # Create the vertices and polygons for a regular n-joint.
+
+# Create the vertices and polygons for a regular n-joint
+
+class AddNJoint(Operator):
bl_idname = "mesh.primitive_n_joint_add"
bl_label = "Add Pipe N-Joint"
+ bl_description = "Construct a n-joint pipe mesh"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
- radius = FloatProperty(name="Radius",
+ radius = FloatProperty(
+ name="Radius",
description="The radius of the pipe",
default=1.0,
min=0.01,
max=100.0,
- unit="LENGTH")
- div = IntProperty(name="Divisions",
+ unit="LENGTH"
+ )
+ div = IntProperty(
+ name="Divisions",
description="Number of vertices (divisions)",
default=32,
min=4,
- max=256)
- number = IntProperty(name="Arms/Joints",
- description="Number of joints/arms",
+ max=256
+ )
+ number = IntProperty(
+ name="Arms / Joints",
+ description="Number of joints / arms",
default=5,
min=2,
- max=99999)
- length = FloatProperty(name="Length",
- description="Length of each joint/arm",
+ max=99999
+ )
+ length = FloatProperty(
+ name="Length",
+ description="Length of each joint / arm",
default=3.0,
min=0.01,
max=100.0,
- unit="LENGTH")
+ unit="LENGTH"
+ )
def execute(self, context):
radius = self.radius
@@ -839,7 +885,8 @@ class AddNJoint(bpy.types.Operator):
length = self.length
if (div % 2):
- # Odd vertice number not supported (yet).
+ # Odd vertice number not supported (yet)
+ self.report({'INFO'}, "Odd vertices number is not yet supported")
return {'CANCELLED'}
if (number < 2):
@@ -857,7 +904,7 @@ class AddNJoint(bpy.types.Operator):
angleDiv = (2.0 * pi / number)
- # Create vertices for the end circles.
+ # Create vertices for the end circles
for num in range(number):
circle = []
# Create start circle
@@ -882,7 +929,7 @@ class AddNJoint(bpy.types.Operator):
loopsEndCircles.append(circle)
- # Create vertices for the joint circles.
+ # Create vertices for the joint circles
loopJoint = []
for vertIdx in range(div):
curVertAngle = vertIdx * (2.0 * pi / div)
@@ -898,7 +945,7 @@ class AddNJoint(bpy.types.Operator):
skipVert = True
elif vertIdx == div / 2:
# @todo: This will possibly break if we
- # ever support odd divisions.
+ # ever support odd divisions
if (num == 0):
vertTemp1 = len(verts)
else:
@@ -930,7 +977,7 @@ class AddNJoint(bpy.types.Operator):
loopsJointsTemp.append(loopJoint)
# Create complete loops (loopsJoints) out of the
- # double number of half loops in loopsJointsTemp.
+ # double number of half loops in loopsJointsTemp
for halfLoopIdx in range(len(loopsJointsTemp)):
if (halfLoopIdx == len(loopsJointsTemp) - 1):
idx1 = halfLoopIdx
@@ -948,7 +995,7 @@ class AddNJoint(bpy.types.Operator):
loopsJoints.append(loopJoint)
# Create faces from the two
- # loop arrays (loopsJoints -> loopsEndCircles).
+ # loop arrays (loopsJoints -> loopsEndCircles)
for loopIdx in range(len(loopsEndCircles)):
faces.extend(
createFaces(loopsJoints[loopIdx],
diff --git a/add_mesh_extra_objects/add_mesh_pyramid.py b/add_mesh_extra_objects/add_mesh_pyramid.py
index b0852e7f..5c054c9f 100644
--- a/add_mesh_extra_objects/add_mesh_pyramid.py
+++ b/add_mesh_extra_objects/add_mesh_pyramid.py
@@ -2,30 +2,33 @@
import bpy
import bmesh
-from bpy.props import FloatProperty, IntProperty
+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
def create_step(width, base_level, step_height, num_sides):
-
- axis = [0,0,-1]
+
+ axis = [0, 0, -1]
PI2 = pi * 2
rad = width / 2
-
- quat_angles = [(cur_side/num_sides) * PI2
+
+ quat_angles = [(cur_side / num_sides) * PI2
for cur_side in range(num_sides)]
-
- quaternions = [Quaternion(axis, quat_angle)
+
+ quaternions = [Quaternion(axis, quat_angle)
for quat_angle in quat_angles]
-
+
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]
+ top_list = [(vec.x, vec.y, vec.z + step_height) for vec in vectors]
full_list = bottom_list + top_list
return full_list
@@ -36,9 +39,8 @@ def split_list(l, n):
http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python
"""
n *= 2
- returned_list = [l[i:i+n] for i in range(0, len(l), n)]
+ returned_list = [l[i: i + n] for i in range(0, len(l), n)]
return returned_list
-
def get_connector_pairs(lst, n_sides):
@@ -48,87 +50,87 @@ def get_connector_pairs(lst, n_sides):
lst = split_list(lst, n_sides)
return lst
+
def add_pyramid_object(self, context):
all_verts = []
-
+
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)
-
+ all_verts.extend(verts_loc)
+
mesh = bpy.data.meshes.new("Pyramid")
bm = bmesh.new()
for v_co in all_verts:
bm.verts.new(v_co)
-
-
- # do the sides.
- n = self.num_sides
-
+
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]])
-
-
+ 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.
-
+
# 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)
-
+
bm.to_mesh(mesh)
mesh.update()
res = object_data_add(context, mesh, operator=self)
-
+
class AddPyramid(bpy.types.Operator, AddObjectHelper):
- '''Add a mesh pyramid'''
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)
+ 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)
-
+ 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)
+
return {'FINISHED'}
diff --git a/add_mesh_extra_objects/add_mesh_round_brilliant.py b/add_mesh_extra_objects/add_mesh_round_brilliant.py
index 365705a1..537099b7 100644
--- a/add_mesh_extra_objects/add_mesh_round_brilliant.py
+++ b/add_mesh_extra_objects/add_mesh_round_brilliant.py
@@ -3,204 +3,209 @@
import bpy
from math import pi, sin, cos, tan
from bpy.types import Operator
-from bpy.props import IntProperty, FloatProperty, BoolProperty
-from mathutils import Vector, Euler
+from mathutils import Vector, Euler
+from bpy.props import (
+ IntProperty,
+ FloatProperty,
+ BoolProperty,
+ )
+
# mesh/object generating function, returns final object
-def addBrilliant(context, s, table_w, crown_h, girdle_t, pavi_d, bezel_f,
+
+def addBrilliant(context, s, table_w, crown_h, girdle_t, pavi_d, bezel_f,
pavi_f, culet, girdle_real, keep_lga, g_real_smooth):
-
-# # possible user inputs ( output 100% = 2 blender units )
-# s # no. of girdle facets (steps) default: 16
-# table_w # table width default: 0.530
-# crown_h # crown height default: 0.162
-# girdle_t # girdle thickness default: 0.017
-# pavi_d # pavillion depth default: 0.431
-# bezel_f # bezel factor default: 0.250
-# pavi_f # pavillion factor default: 0.400
-# culet # culet size default: 0.000
-# girdle_real # type of girdle flat/real default: True
-# g_real_smooth # smooth or flat shading default: False
-# keep_lga # when culet > 0, keep lga default: False
+
+ # # possible user inputs ( output 100% = 2 blender units )
+ # s # no. of girdle facets (steps) default: 16
+ # table_w # table width default: 0.530
+ # crown_h # crown height default: 0.162
+ # girdle_t # girdle thickness default: 0.017
+ # pavi_d # pavillion depth default: 0.431
+ # bezel_f # bezel factor default: 0.250
+ # pavi_f # pavillion factor default: 0.400
+ # culet # culet size default: 0.000
+ # girdle_real # type of girdle flat/real default: True
+ # g_real_smooth # smooth or flat shading default: False
+ # keep_lga # when culet > 0, keep lga default: False
# variables / shortcuts
if s % 2: # prevent odd number of steps (messes up mesh)
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)
- ca2 = cos(ang/2)
- sa4 = sin(ang/4)
- ta4 = tan(ang/4)
- ta8 = tan(ang/8)
-
+ ca = cos(ang)
+ ca2 = cos(ang / 2)
+ sa4 = sin(ang / 4)
+ ta4 = tan(ang / 4)
+ ta8 = tan(ang / 8)
+
def fa(*vs): # shortcut Faces.append
v = []
for u in vs:
v.append(u)
Faces.append(v)
-
- def va(vx, vz, iang, sang, n): # shortcut Verts.append
+
+ def va(vx, vz, iang, sang, n): # shortcut Verts.append
for i in range(n):
v = Vector((vx, 0, vz))
- ai = sang + iang*i
- E_rot = Euler((0, 0, ai), 'XYZ')
- v.rotate(E_rot)
- Verts.append((v.x, v.y, v.z))
-
+ ai = sang + iang * i
+ E_rot = Euler((0, 0, ai), 'XYZ')
+ v.rotate(E_rot)
+ Verts.append((v.x, v.y, v.z))
- # upper girdle angle
- uga = (1-bezel_f) * crown_h*2 / (ca2 -
- (table_w + (1-table_w) * bezel_f) * ca2/ca)
+ # upper girdle angle
+ uga = (1 - bezel_f) * crown_h * 2 / (ca2 -
+ (table_w + (1 - table_w) * bezel_f) * ca2 / ca)
- # lower girdle angle
+ # lower girdle angle
if keep_lga:
if pavi_f > 0 and pavi_f < 1:
- lga = (1-pavi_f) * pavi_d*2 / (ca2 - pavi_f*ca2 / ca)
+ lga = (1 - pavi_f) * pavi_d * 2 / (ca2 - pavi_f * ca2 / ca)
elif pavi_f == 1:
lga = 0
else:
- lga = 2*pavi_d*ca
+ lga = 2 * pavi_d * ca
else:
- lga = (1-pavi_f) * pavi_d*2 / (ca2 -
- (culet + (1-culet) * pavi_f) * ca2/ca)
-
+ lga = (1 - pavi_f) * pavi_d * 2 / (ca2 -
+ (culet + (1 - culet) * pavi_f) * ca2 / ca)
+
# append girdle vertices
va(1, 0, ang, 0, s)
- va(1, 2*girdle_t, ang, 0, s)
+ va(1, 2 * girdle_t, ang, 0, s)
- # append real girdle vertices
+ # append real girdle vertices
if girdle_real:
dnu = uga * (1 - ca2)
dfu = uga * (ta8 + ta4) * sa4
- dnl = lga * (1 - ca2)
+ dnl = lga * (1 - ca2)
dfl = lga * (ta8 + ta4) * sa4
- if abs(dnu) + abs(dnl) > 2*girdle_t or dnu < 0 or dnl < 0:
+ if abs(dnu) + abs(dnl) > 2 * girdle_t or dnu < 0 or dnl < 0:
girdle_real = False
else:
- va(1, dnl, ang, ang/2, s)
- va(1, 2*girdle_t - dnu, ang, ang/2, s)
- va(1, dfl, ang/2, ang/4, 2*s)
- va(1, 2*girdle_t - dfu, ang/2, ang/4, 2*s)
-
+ va(1, dnl, ang, ang / 2, s)
+ va(1, 2 * girdle_t - dnu, ang, ang / 2, s)
+ va(1, dfl, ang / 2, ang / 4, 2 * s)
+ va(1, 2 * girdle_t - dfu, ang / 2, ang / 4, 2 * s)
+
# make girdle faces
l1 = len(Verts) # 2*s / 8*s
for i in range(l1):
if girdle_real:
if i < s:
- fa(i, i + s, 2*i + 6*s, 2*i + 4*s)
+ fa(i, i + s, 2 * i + 6 * s, 2 * i + 4 * s)
if i == 0:
- fa(i, s, l1 - 1, 6*s - 1)
+ fa(i, s, l1 - 1, 6 * s - 1)
else:
- fa(i, i + s, 2*i + 6*s - 1, 2*i + 4*s - 1)
- elif i > 2*s - 1 and i < 3*s:
- fa(i, i + s, 2 * (i+s), 2*i)
- fa(i, i + s, 2 * (i+s) + 1, 2*i + 1)
+ fa(i, i + s, 2 * i + 6 * s - 1, 2 * i + 4 * s - 1)
+ elif i > 2 * s - 1 and i < 3 * s:
+ fa(i, i + s, 2 * (i + s), 2 * i)
+ fa(i, i + s, 2 * (i + s) + 1, 2 * i + 1)
else:
if i < s - 1:
fa(i, i + s, i + s + 1, i + 1)
elif i == s - 1:
fa(i, i + s, s, 0)
-
+
# append upper girdle facet vertices
- va((table_w + (1-table_w) * bezel_f) / ca, (1-bezel_f) * 2*crown_h +
- 2*girdle_t, 2*ang, ang, int(s/2))
+ va((table_w + (1 - table_w) * bezel_f) / ca, (1 - bezel_f) * 2 * crown_h +
+ 2 * girdle_t, 2 * ang, ang, int(s / 2))
# make upper girdle facet faces
l2 = len(Verts) # 2.5*s / 8.5*s
for i in range(l2):
- if i > s and i < 2*s - 1 and i % 2 != 0:
+ if i > s and i < 2 * s - 1 and i % 2 != 0:
if girdle_real:
- fa(i, 2 * (i + 2*s), i + 2*s, 2 * (i + 2*s) + 1, i + 1,
- int(7.5*s) + int((i-1) / 2))
- fa(i, 2 * (i + 2*s) - 1, i + 2*s - 1, 2 * (i + 2*s - 1),
- i - 1, int(7.5*s) + int((i-1) / 2))
+ fa(i, 2 * (i + 2 * s), i + 2 * s, 2 * (i + 2 * s) + 1, i + 1,
+ int(7.5 * s) + int((i - 1) / 2))
+ fa(i, 2 * (i + 2 * s) - 1, i + 2 * s - 1, 2 * (i + 2 * s - 1),
+ i - 1, int(7.5 * s) + int((i - 1) / 2))
else:
- fa(i, i + 1, int((i + 3*s) / 2))
- fa(i, i - 1, int((i + 3*s) / 2))
+ fa(i, i + 1, int((i + 3 * s) / 2))
+ fa(i, i - 1, int((i + 3 * s) / 2))
elif i == s:
if girdle_real:
- fa(i, l1 - 1, 4*s - 1, l1 - 2, 2*i - 1, l2 - 1)
- fa(2*i - 2, l1 - 4, 4*s - 2, l1 - 3, 2*i - 1, l2 - 1)
+ fa(i, l1 - 1, 4 * s - 1, l1 - 2, 2 * i - 1, l2 - 1)
+ fa(2 * i - 2, l1 - 4, 4 * s - 2, l1 - 3, 2 * i - 1, l2 - 1)
else:
- fa(i, 2*i - 1, l2 - 1)
- fa(2*i - 1, 2*i - 2, l2 - 1)
-
+ fa(i, 2 * i - 1, l2 - 1)
+ fa(2 * i - 1, 2 * i - 2, l2 - 1)
+
# append table vertices
- va(table_w, (crown_h + girdle_t)*2, 2*ang, 0, int(s/2))
+ va(table_w, (crown_h + girdle_t) * 2, 2 * ang, 0, int(s / 2))
# make bezel facet faces and star facet faces
l3 = len(Verts) # 3*s / 9*s
for i in range(l3):
if i > l2 - 1 and i < l3 - 1:
- fa(i, i + 1, i - int(s/2))
- fa(i + 1, i - int(s/2), 2 * (i-l2) + 2 + s, i - int(s/2) + 1)
+ fa(i, i + 1, i - int(s / 2))
+ fa(i + 1, i - int(s / 2), 2 * (i - l2) + 2 + s, i - int(s / 2) + 1)
elif i == l3 - 1:
fa(i, l2, l2 - 1)
- fa(s, l2 - 1, l2, l2 - int(s/2))
-
+ fa(s, l2 - 1, l2, l2 - int(s / 2))
+
# make table facet face
tf = []
for i in range(l3):
if i > l2 - 1:
tf.append(i)
fa(*tf)
-
+
# append lower girdle facet vertices
- if keep_lga:
- va(pavi_f/ca, (pavi_f-1) * pavi_d*2, 2*ang, ang, int(s/2))
+ if keep_lga:
+ va(pavi_f / ca, (pavi_f - 1) * pavi_d * 2, 2 * ang, ang, int(s / 2))
else:
- va((pavi_f * (1-culet) + culet) / ca, (pavi_f-1) * pavi_d*2, 2*ang,
- ang, int(s/2))
-
+ va((pavi_f * (1 - culet) + culet) / ca, (pavi_f - 1) * pavi_d * 2, 2 * ang,
+ ang, int(s / 2))
+
# make lower girdle facet faces
l4 = len(Verts) # 3.5*s / 9.5*s
for i in range(l4):
if i > 0 and i < s - 1 and i % 2 == 0:
if girdle_real:
- fa(i, 2 * (i + 2*s), i + 2*s, 2 * (i + 2*s) + 1, i + 1,
- int(i/2) + 9*s)
- fa(i, 2 * (i + 2*s) - 1, i + 2*s - 1, 2 * (i + 2*s - 1),
- i-1, int(i/2) + 9*s - 1)
+ fa(i, 2 * (i + 2 * s), i + 2 * s, 2 * (i + 2 * s) + 1, i + 1,
+ int(i / 2) + 9 * s)
+ fa(i, 2 * (i + 2 * s) - 1, i + 2 * s - 1, 2 * (i + 2 * s - 1),
+ i - 1, int(i / 2) + 9 * s - 1)
else:
- fa(i, i + 1, int(i/2) + l4 - int(s/2))
- fa(i, i - 1, int(i/2) + l4 - int(s/2) - 1)
+ fa(i, i + 1, int(i / 2) + l4 - int(s / 2))
+ fa(i, i - 1, int(i / 2) + l4 - int(s / 2) - 1)
elif i == 0:
if girdle_real:
- fa(0, 4*s, 2*s, 4*s + 1, 1, 9*s)
- fa(0, 6*s - 1, 3*s - 1, 6*s - 2, s - 1, l4 - 1)
+ fa(0, 4 * s, 2 * s, 4 * s + 1, 1, 9 * s)
+ fa(0, 6 * s - 1, 3 * s - 1, 6 * s - 2, s - 1, l4 - 1)
else:
- fa(0, 1, l4 - int(s/2))
+ fa(0, 1, l4 - int(s / 2))
fa(0, s - 1, l4 - 1)
-
+
# append culet vertice(s)
if culet == 0:
- va(0, pavi_d*(-2), 0, 0, 1)
+ va(0, pavi_d * (-2), 0, 0, 1)
else:
if keep_lga:
- va(culet * pavi_f / ca, pavi_d*(-2) + culet * pavi_f * 2 * pavi_d,
- 2*ang, ang, int(s/2))
+ va(culet * pavi_f / ca, pavi_d * (-2) + culet * pavi_f * 2 * pavi_d,
+ 2 * ang, ang, int(s / 2))
else:
- va(culet/ca, pavi_d*(-2), 2*ang, ang, int(s/2))
-
+ va(culet / ca, pavi_d * (-2), 2 * ang, ang, int(s / 2))
+
# make pavillion facet face
l5 = len(Verts) # 4*s / 10*s //if !culet: 3.5*s+1 / 9.5*s+1
for i in range(l5):
if i > 0 and i < s - 1 and i % 2 == 0:
if culet:
- fa(i, l3 + int(i/2), l3 + int((s+i) / 2),
- l3 + int((s+i) / 2) - 1, l3 + int(i/2) - 1)
+ fa(i, l3 + int(i / 2), l3 + int((s + i) / 2),
+ l3 + int((s + i) / 2) - 1, l3 + int(i / 2) - 1)
else:
- fa(i, l3 + int(i/2), l5 - 1, l3 + int(i/2) - 1)
+ fa(i, l3 + int(i / 2), l5 - 1, l3 + int(i / 2) - 1)
elif i == 0:
if culet:
fa(i, l3, l4, l5 - 1, l4 - 1)
else:
fa(i, l3, l5 - 1, l4 - 1)
-
+
# make culet facet face
if culet:
cf = []
@@ -208,13 +213,13 @@ def addBrilliant(context, s, table_w, crown_h, girdle_t, pavi_d, bezel_f,
if i > l4 - 1:
cf.append(i)
fa(*cf)
-
+
# bpy variables / shortcuts
- scene = bpy.context.scene
+ scene = bpy.context.scene
# deactivate possible active Objects
- bpy.context.scene.objects.active = None
-
+ bpy.context.scene.objects.active = None
+
# create actual mesh and object based on Verts and Faces given
dmesh = bpy.data.meshes.new("dmesh")
dmesh.from_pydata(Verts, [], Faces)
@@ -240,126 +245,146 @@ def addBrilliant(context, s, table_w, crown_h, girdle_t, pavi_d, bezel_f,
bpy.ops.mesh.normals_make_consistent(inside=False)
bpy.context.tool_settings.mesh_select_mode = sel_mode
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
-
+
# make girdle smooth for complex girdle
if girdle_real and g_real_smooth:
-
+
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
-
+
bpy.ops.mesh.select_all(action='DESELECT') # deselect all mesh data
- bpy.ops.object.mode_set(mode='OBJECT')
+ bpy.ops.object.mode_set(mode='OBJECT')
pls = []
- dp = obj.data.polygons[:4*s] # only consider faces of girdle
+ dp = obj.data.polygons[:4 * s] # only consider faces of girdle
ov = obj.data.vertices
-
+
for i, p in enumerate(dp):
pls.extend(p.vertices) # list all verts of girdle
-
+
for i, e in enumerate(obj.data.edges): # select egdes to mark sharp
if e.vertices[0] in pls and e.vertices[1] in pls and abs(
ov[e.vertices[0]].co.x - ov[e.vertices[1]].co.x):
obj.data.edges[i].select = True
continue
obj.data.edges[i].select = False
-
+
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.ops.mesh.mark_sharp()
-
+
bpy.context.tool_settings.mesh_select_mode = [False, False, True]
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
bpy.ops.object.select_all(action='DESELECT')
- for i, face in enumerate(obj.data.polygons):
- if i < 4*s:
- face.select = True
+ for i, face in enumerate(obj.data.polygons):
+ if i < 4 * s:
+ face.select = True
continue
- face.select = False
+ face.select = False
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.ops.mesh.faces_shade_smooth()
-
+
bpy.ops.object.modifier_add(type='EDGE_SPLIT')
-
- bpy.context.tool_settings.mesh_select_mode = sel_mode
+
+ bpy.context.tool_settings.mesh_select_mode = sel_mode
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
-
+
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="EdgeSplit")
-
-
+
return dobj
# add new operator for object
-class MESH_OT_primitive_brilliant_add(bpy.types.Operator):
+class MESH_OT_primitive_brilliant_add(Operator):
bl_idname = "mesh.primitive_brilliant_add"
bl_label = "Custom Brilliant"
+ bl_description = "Contruct a custom brilliant mesh"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
-
+
# set user options
- s = IntProperty(name="Segments",
+ s = IntProperty(
+ name="Segments",
description="Longitudial segmentation",
step=1,
min=6,
max=128,
default=16,
- subtype='FACTOR')
- table_w = FloatProperty(name="Table width",
+ subtype='FACTOR'
+ )
+ table_w = FloatProperty(
+ name="Table width",
description="Width of table",
min=0.001,
max=1.0,
default=0.53,
- subtype='PERCENTAGE')
- crown_h = FloatProperty(name="Crown height",
+ subtype='PERCENTAGE'
+ )
+ crown_h = FloatProperty(
+ name="Crown height",
description="Heigth of crown",
min=0.0,
max=1.0,
default=0.162,
- subtype='PERCENTAGE')
- girdle_t = FloatProperty(name="Girdle height",
+ subtype='PERCENTAGE'
+ )
+ girdle_t = FloatProperty(
+ name="Girdle height",
description="Height of girdle",
min=0.0,
max=0.5,
default=0.017,
- subtype='PERCENTAGE')
- girdle_real = BoolProperty(name="Real girdle",
+ subtype='PERCENTAGE'
+ )
+ girdle_real = BoolProperty(
+ 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)
- pavi_d = FloatProperty(name="Pavilion depth",
+ default=True
+ )
+ g_real_smooth = BoolProperty(
+ 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')
- bezel_f = FloatProperty(name="Upper facet factor",
- description=
- "Determines the form of bezel and upper girdle facets",
+ 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')
- pavi_f = FloatProperty(name="Lower facet factor",
- description=
- "Determines the form of pavillion and lower girdle facets",
+ 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')
- culet = FloatProperty(name="Culet size",
+ subtype='PERCENTAGE'
+ )
+ culet = FloatProperty(
+ 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",
+ subtype='PERCENTAGE'
+ )
+ keep_lga = BoolProperty(
+ name="Retain lower angle",
description="If culet > 0, retains angle of pavillion facets",
- default=False)
-
+ default=False
+ )
+
# call mesh/object generator function with user inputs
- def execute(self, context):
- ob = addBrilliant(context, self.s, self.table_w, self.crown_h,
- self.girdle_t, self.pavi_d, self.bezel_f,
- self.pavi_f, self.culet, self.girdle_real,
- self.keep_lga, self.g_real_smooth)
+ def execute(self, context):
+ ob = addBrilliant(context, self.s, self.table_w, self.crown_h,
+ self.girdle_t, self.pavi_d, self.bezel_f,
+ self.pavi_f, self.culet, self.girdle_real,
+ self.keep_lga, self.g_real_smooth
+ )
return {'FINISHED'}
diff --git a/add_mesh_extra_objects/add_mesh_round_cube.py b/add_mesh_extra_objects/add_mesh_round_cube.py
index 189f19b4..d97c6c0b 100644
--- a/add_mesh_extra_objects/add_mesh_round_cube.py
+++ b/add_mesh_extra_objects/add_mesh_round_cube.py
@@ -4,14 +4,23 @@ import bpy
from bpy_extras import object_utils
from itertools import permutations
from math import copysign, pi, sqrt
+from bpy.props import (
+ BoolProperty,
+ EnumProperty,
+ FloatProperty,
+ FloatVectorProperty,
+ IntProperty
+ )
-def round_cube(radius=1.0, arcdiv=4, lindiv=0., size=(0. ,0. ,0.), div_type='CORNERS', odd_axis_align=False, info_only=False):
+
+def round_cube(radius=1.0, arcdiv=4, lindiv=0., size=(0., 0., 0.),
+ div_type='CORNERS', odd_axis_align=False, info_only=False):
# subdiv bitmasks
CORNERS, EDGES, ALL = 0, 1, 2
try:
subdiv = ('CORNERS', 'EDGES', 'ALL').index(div_type)
except ValueError:
- subdiv = CORNERS # fallback
+ subdiv = CORNERS # fallback
radius = max(radius, 0.)
if not radius:
@@ -28,7 +37,7 @@ def round_cube(radius=1.0, arcdiv=4, lindiv=0., size=(0. ,0. ,0.), div_type='COR
if not lindiv:
subdiv = CORNERS
- odd = arcdiv % 2 # even = arcdiv % 2 ^ 1
+ odd = arcdiv % 2 # even = arcdiv % 2 ^ 1
step_size = 2. / arcdiv
odd_aligned = 0
@@ -43,8 +52,8 @@ def round_cube(radius=1.0, arcdiv=4, lindiv=0., size=(0. ,0. ,0.), div_type='COR
if arcdiv == 1 and not odd_aligned and subdiv == EDGES:
subdiv = CORNERS
- half_chord = 0. # ~ spherical cap base radius
- sagitta = 0. # ~ spherical cap height
+ half_chord = 0. # ~ spherical cap base radius
+ sagitta = 0. # ~ spherical cap height
if not axis_aligned:
half_chord = sqrt(3.) * radius / (3. * arcdiv)
id2 = 1. / (arcdiv * arcdiv)
@@ -54,8 +63,8 @@ def round_cube(radius=1.0, arcdiv=4, lindiv=0., size=(0. ,0. ,0.), div_type='COR
exyz = [0. if s < 2. * (radius - sagitta) else (s - 2. * (radius - sagitta)) * 0.5 for s in size]
ex, ey, ez = exyz
- dxyz = [0, 0, 0] # extrusion divisions per axis
- dssxyz = [0., 0., 0.] # extrusion division step sizes per axis
+ dxyz = [0, 0, 0] # extrusion divisions per axis
+ dssxyz = [0., 0., 0.] # extrusion division step sizes per axis
for i in range(3):
sc = 2. * (exyz[i] + half_chord)
@@ -78,22 +87,22 @@ def round_cube(radius=1.0, arcdiv=4, lindiv=0., size=(0. ,0. ,0.), div_type='COR
dvc += ec * ec // 2 * sum(dxyz) + ec * (ec - 1)
else:
dvc = (arcdiv * 4) * ec + ec * (ec - 1) if axis_aligned else 0
- vert_count = int(6 * arcdiv*arcdiv + (0 if odd_aligned else 2) + dvc)
+ vert_count = int(6 * arcdiv * arcdiv + (0 if odd_aligned else 2) + dvc)
if not radius and not max(size) > 0:
vert_count = 1
return arcdiv, lindiv, vert_count
if not radius and not max(size) > 0:
# Single vertex
- return [(0,0,0)], []
+ return [(0, 0, 0)], []
# uv lookup table
uvlt = []
v = vi
for j in range(1, steps + 1):
- v2 = v*v
+ v2 = v * v
uvlt.append((v, v2, radius * sqrt(18. - 6. * v2) / 6.))
- v = vi + j * step_size # v += step_size # instead of accumulating errors
+ v = vi + j * step_size # v += step_size # instead of accumulating errors
# clear fp errors / signs at axis
if abs(v) < 1e-10:
v = 0.0
@@ -150,7 +159,7 @@ def round_cube(radius=1.0, arcdiv=4, lindiv=0., size=(0. ,0. ,0.), div_type='COR
svitc = svit[side]
exr = exyz[xp]
eyr = exyz[yp]
- ri = 0 # row index
+ ri = 0 # row index
rij = zer if side < 4 else yer
if side == 5:
@@ -161,16 +170,16 @@ def round_cube(radius=1.0, arcdiv=4, lindiv=0., size=(0. ,0. ,0.), div_type='COR
span = range(1, arcdiv)
ri = 1
- for j in span: # rows
+ for j in span: # rows
v, v2, mv2 = uvlt[j]
- tv2mh = 1./3. * v2 - 0.5
+ tv2mh = 1. / 3. * v2 - 0.5
hv2 = 0.5 * v2
if j == hemi and rij:
# Jump over non-edge row indices
ri += rij
- for i in span: # columns
+ for i in span: # columns
u, u2, mu2 = uvlt[i]
vert[xp] = u * mv2
vert[yp] = v * mu2
@@ -182,7 +191,7 @@ def round_cube(radius=1.0, arcdiv=4, lindiv=0., size=(0. ,0. ,0.), div_type='COR
rv = tuple(vert)
if exr and i == hemi:
- rx = vert[xp] # save rotated x
+ rx = vert[xp] # save rotated x
vert[xp] = rxi = (-exr - half_chord) * dir[xp]
if axis_aligned:
svitc[ri].append(len(verts))
@@ -216,7 +225,7 @@ def round_cube(radius=1.0, arcdiv=4, lindiv=0., size=(0. ,0. ,0.), div_type='COR
svitc[hemi + axis_aligned + l].append(len(verts))
verts.append(tuple(vert))
vert[yp] = ry
- vert[xp] = rx # restore
+ vert[xp] = rx # restore
if eyr and j == hemi:
vert[yp] = (-eyr - half_chord) * dir[yp]
@@ -276,122 +285,119 @@ def round_cube(radius=1.0, arcdiv=4, lindiv=0., size=(0. ,0. ,0.), div_type='COR
for side, rows in enumerate(svit):
xp, yp = sides[side][:2]
oa4 = odd_aligned and side == 4
- if oa4: # special case
+ if oa4: # special case
hemi += 1
for j, row in enumerate(rows[:-1]):
- tri = odd_aligned and (oa4 and not j or rows[j+1][-1] < 0)
+ tri = odd_aligned and (oa4 and not j or rows[j + 1][-1] < 0)
for i, vi in enumerate(row[:-1]):
# odd_aligned triangle corners
if vi < 0:
if not j and not i:
- faces.append((row[i+1], rows[j+1][i+1], rows[j+1][i]))
+ faces.append((row[i + 1], rows[j + 1][i + 1], rows[j + 1][i]))
elif oa4 and not i and j == len(rows) - 2:
- faces.append((vi, row[i+1], rows[j+1][i+1]))
+ faces.append((vi, row[i + 1], rows[j + 1][i + 1]))
elif tri and i == len(row) - 2:
if j:
- faces.append((vi, row[i+1], rows[j+1][i]))
+ faces.append((vi, row[i + 1], rows[j + 1][i]))
else:
if oa4 or arcdiv > 1:
- faces.append((vi, rows[j+1][i+1], rows[j+1][i]))
+ faces.append((vi, rows[j + 1][i + 1], rows[j + 1][i]))
else:
- faces.append((vi, row[i+1], rows[j+1][i]))
+ faces.append((vi, row[i + 1], rows[j + 1][i]))
# subdiv = EDGES (not ALL)
elif subdiv and len(rows[j + 1]) < len(row) and (i >= hemi):
if (i == hemi):
- faces.append((vi, row[i+1+dxyz[xp]], rows[j+1+dxyz[yp]][i+1+dxyz[xp]], rows[j+1+dxyz[yp]][i]))
+ faces.append((vi, row[i + 1 + dxyz[xp]], rows[j + 1 + dxyz[yp]][i + 1 + dxyz[xp]],
+ rows[j + 1 + dxyz[yp]][i]))
elif i > hemi + dxyz[xp]:
- faces.append((vi, row[i+1], rows[j+1][i+1-dxyz[xp]], rows[j+1][i-dxyz[xp]]))
+ faces.append((vi, row[i + 1], rows[j + 1][i + 1 - dxyz[xp]], rows[j + 1][i - dxyz[xp]]))
elif subdiv and len(rows[j + 1]) > len(row) and (i >= hemi):
if (i > hemi):
- faces.append((vi, row[i+1], rows[j+1][i+1+dxyz[xp]], rows[j+1][i+dxyz[xp]]))
+ faces.append((vi, row[i + 1], rows[j + 1][i + 1 + dxyz[xp]], rows[j + 1][i + dxyz[xp]]))
elif subdiv and len(row) < len(rows[0]) and i == hemi:
pass
else:
# Most faces...
- faces.append((vi, row[i+1], rows[j+1][i+1], rows[j+1][i]))
+ faces.append((vi, row[i + 1], rows[j + 1][i + 1], rows[j + 1][i]))
if oa4:
hemi -= 1
return verts, faces
-from bpy.props import BoolProperty, EnumProperty, FloatProperty, FloatVectorProperty, IntProperty
class AddRoundCube(bpy.types.Operator, object_utils.AddObjectHelper):
- """Add Round Cube Primitive"""
- bl_idname = 'mesh.primitive_round_cube_add'
- bl_label = 'Add Round Cube'
- bl_description = 'Add mesh primitives: Quadspheres, Capsules, Rounded Cuboids, 3D Grids, etc'
- bl_options = {'REGISTER', 'UNDO', 'PRESET'}
+ bl_idname = "mesh.primitive_round_cube_add"
+ bl_label = "Add Round Cube"
+ bl_description = ("Create mesh primitives: Quadspheres,"
+ "\nCapsules, 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',
- default = 1.0, min = 0.0, soft_min=0.01, step=10
+ 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',
- subtype = 'XYZ',
+ name='Size',
+ description='Size',
+ subtype='XYZ',
)
-
arc_div = IntProperty(
- name = 'Arc Divisions',
- description = 'Arc curve divisions, per quadrant; 0 = derive from Linear',
- default = 4, min = 1
+ 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',
- default = 0.0, min = 0.0, step=100, precision=1
+ 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(
- name = 'Type',
- description = 'Division type',
- items = (
+ name='Type',
+ description='Division type',
+ items=(
('CORNERS', 'Corners', 'Sphere / Corners'),
('EDGES', 'Edges', 'Sphere / Corners and extruded edges (size)'),
('ALL', 'All', 'Sphere / Corners, extruded edges and faces (size)')),
- default = 'CORNERS',
+ default='CORNERS',
)
-
odd_axis_align = BoolProperty(
- name = 'Odd Axis Align',
- description = 'Align odd arc divisions with axes (Note: triangle corners!)',
+ name='Odd Axis Align',
+ description='Align odd arc divisions with axes (Note: triangle corners!)',
)
-
no_limit = BoolProperty(
- name = 'No Limit',
- description = 'Do not limit to '+str(sanity_check_verts)+' vertices (sanity check)',
- options = {'HIDDEN'}
+ name='No Limit',
+ description='Do not limit to ' + str(sanity_check_verts) + ' vertices (sanity check)',
+ options={'HIDDEN'}
)
def execute(self, context):
- if self.arc_div <=0 and self.lin_div <= 0:
+ if self.arc_div <= 0 and self.lin_div <= 0:
self.report({'ERROR'}, 'Either Arc Divisions or Linear Divisions must be greater than zero!')
return {'CANCELLED'}
if not self.no_limit:
if self.vert_count > self.sanity_check_verts:
- self.report({'ERROR'}, 'More than '+str(self.sanity_check_verts)+' vertices! Check "No Limit" to proceed')
+ self.report({'ERROR'}, 'More than ' + str(self.sanity_check_verts) +
+ ' vertices! Check "No Limit" to proceed')
return {'CANCELLED'}
- verts, faces = round_cube(self.radius, self.arc_div, self.lin_div, self.size, self.div_type, self.odd_axis_align)
+ verts, faces = round_cube(self.radius, self.arc_div, self.lin_div,
+ self.size, self.div_type, self.odd_axis_align)
mesh = bpy.data.meshes.new('Roundcube')
- mesh.from_pydata(verts,[],faces)
+ mesh.from_pydata(verts, [], faces)
object_utils.object_data_add(context, mesh, operator=self)
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)
- return True # False
+ 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):
self.check(context)
@@ -433,4 +439,3 @@ class AddRoundCube(bpy.types.Operator, object_utils.AddObjectHelper):
col = layout.column(align=True)
col.prop(self, 'rotation', expand=True)
-
diff --git a/add_mesh_extra_objects/add_mesh_solid.py b/add_mesh_extra_objects/add_mesh_solid.py
index d2243fd3..3fb058c9 100644
--- a/add_mesh_extra_objects/add_mesh_solid.py
+++ b/add_mesh_extra_objects/add_mesh_solid.py
@@ -1,25 +1,31 @@
# GPL # "author": "DreamPainter"
import bpy
-from bpy.props import FloatProperty,EnumProperty,BoolProperty
from math import sqrt
from mathutils import Vector
from functools import reduce
+from bpy.props import (
+ FloatProperty,
+ EnumProperty,
+ BoolProperty,
+ )
from bpy_extras.object_utils import object_data_add
+
# this function creates a chain of quads and, when necessary, a remaining tri
# for each polygon created in this script. be aware though, that this function
# assumes each polygon is convex.
# poly: list of faces, or a single face, like those
# needed for mesh.from_pydata.
# returns the tessellated faces.
+
def createPolys(poly):
# check for faces
if len(poly) == 0:
return []
# one or more faces
if type(poly[0]) == type(1):
- poly = [poly] # if only one, make it a list of one face
+ poly = [poly] # if only one, make it a list of one face
faces = []
for i in poly:
L = len(i)
@@ -28,20 +34,24 @@ def createPolys(poly):
faces.append(i)
# split all polygons in half and bridge the two halves
else:
- f = [[i[x],i[x+1],i[L-2-x],i[L-1-x]] for x in range(L//2-1)]
+ f = [[i[x], i[x + 1], i[L - 2 - x], i[L - 1 - x]] for x in range(L // 2 - 1)]
faces.extend(f)
- if L&1 == 1:
- faces.append([i[L//2-1+x] for x in [0,1,2]])
+ if L & 1 == 1:
+ faces.append([i[L // 2 - 1 + x] for x in [0, 1, 2]])
return faces
+
# function to make the reduce function work as a workaround to sum a list of vectors
+
def vSum(list):
- return reduce(lambda a,b: a+b, list)
+ return reduce(lambda a, b: a + b, list)
+
# creates the 5 platonic solids as a base for the rest
# plato: should be one of {"4","6","8","12","20"}. decides what solid the
# outcome will be.
# returns a list of vertices and faces
+
def source(plato):
verts = []
faces = []
@@ -49,72 +59,74 @@ def source(plato):
# Tetrahedron
if plato == "4":
# Calculate the necessary constants
- s = sqrt(2)/3.0
- t = -1/3
- u = sqrt(6)/3
+ s = sqrt(2) / 3.0
+ t = -1 / 3
+ u = sqrt(6) / 3
# create the vertices and faces
- v = [(0,0,1),(2*s,0,t),(-s,u,t),(-s,-u,t)]
- faces = [[0,1,2],[0,2,3],[0,3,1],[1,3,2]]
+ v = [(0, 0, 1), (2 * s, 0, t), (-s, u, t), (-s, -u, t)]
+ faces = [[0, 1, 2], [0, 2, 3], [0, 3, 1], [1, 3, 2]]
# Hexahedron (cube)
elif plato == "6":
# Calculate the necessary constants
- s = 1/sqrt(3)
+ s = 1 / sqrt(3)
# create the vertices and faces
- v = [(-s,-s,-s),(s,-s,-s),(s,s,-s),(-s,s,-s),(-s,-s,s),(s,-s,s),(s,s,s),(-s,s,s)]
- faces = [[0,3,2,1],[0,1,5,4],[0,4,7,3],[6,5,1,2],[6,2,3,7],[6,7,4,5]]
+ v = [(-s, -s, -s), (s, -s, -s), (s, s, -s), (-s, s, -s), (-s, -s, s), (s, -s, s), (s, s, s), (-s, s, s)]
+ faces = [[0, 3, 2, 1], [0, 1, 5, 4], [0, 4, 7, 3], [6, 5, 1, 2], [6, 2, 3, 7], [6, 7, 4, 5]]
# Octahedron
elif plato == "8":
# create the vertices and faces
- v = [(1,0,0),(-1,0,0),(0,1,0),(0,-1,0),(0,0,1),(0,0,-1)]
- faces = [[4,0,2],[4,2,1],[4,1,3],[4,3,0],[5,2,0],[5,1,2],[5,3,1],[5,0,3]]
+ v = [(1, 0, 0), (-1, 0, 0), (0, 1, 0), (0, -1, 0), (0, 0, 1), (0, 0, -1)]
+ faces = [[4, 0, 2], [4, 2, 1], [4, 1, 3], [4, 3, 0], [5, 2, 0], [5, 1, 2], [5, 3, 1], [5, 0, 3]]
# Dodecahedron
elif plato == "12":
# Calculate the necessary constants
- s = 1/sqrt(3)
- t = sqrt((3-sqrt(5))/6)
- u = sqrt((3+sqrt(5))/6)
+ s = 1 / sqrt(3)
+ t = sqrt((3 - sqrt(5)) / 6)
+ u = sqrt((3 + sqrt(5)) / 6)
# create the vertices and faces
- v = [(s,s,s),(s,s,-s),(s,-s,s),(s,-s,-s),(-s,s,s),(-s,s,-s),(-s,-s,s),(-s,-s,-s),
- (t,u,0),(-t,u,0),(t,-u,0),(-t,-u,0),(u,0,t),(u,0,-t),(-u,0,t),(-u,0,-t),(0,t,u),
- (0,-t,u),(0,t,-u),(0,-t,-u)]
- faces = [[0,8,9,4,16],[0,12,13,1,8],[0,16,17,2,12],[8,1,18,5,9],[12,2,10,3,13],
- [16,4,14,6,17],[9,5,15,14,4],[6,11,10,2,17],[3,19,18,1,13],[7,15,5,18,19],
- [7,11,6,14,15],[7,19,3,10,11]]
+ v = [(s, s, s), (s, s, -s), (s, -s, s), (s, -s, -s), (-s, s, s), (-s, s, -s), (-s, -s, s), (-s, -s, -s),
+ (t, u, 0), (-t, u, 0), (t, -u, 0), (-t, -u, 0), (u, 0, t), (u, 0, -t), (-u, 0, t), (-u, 0, -t), (0, t, u),
+ (0, -t, u), (0, t, -u), (0, -t, -u)]
+ faces = [[0, 8, 9, 4, 16], [0, 12, 13, 1, 8], [0, 16, 17, 2, 12], [8, 1, 18, 5, 9], [12, 2, 10, 3, 13],
+ [16, 4, 14, 6, 17], [9, 5, 15, 14, 4], [6, 11, 10, 2, 17], [3, 19, 18, 1, 13], [7, 15, 5, 18, 19],
+ [7, 11, 6, 14, 15], [7, 19, 3, 10, 11]]
# Icosahedron
elif plato == "20":
# Calculate the necessary constants
- s = (1+sqrt(5))/2
- t = sqrt(1+s*s)
- s = s/t
- t = 1/t
+ s = (1 + sqrt(5)) / 2
+ t = sqrt(1 + s * s)
+ s = s / t
+ t = 1 / t
# create the vertices and faces
- v = [(s,t,0),(-s,t,0),(s,-t,0),(-s,-t,0),(t,0,s),(t,0,-s),(-t,0,s),(-t,0,-s),
- (0,s,t),(0,-s,t),(0,s,-t),(0,-s,-t)]
- faces = [[0,8,4],[0,5,10],[2,4,9],[2,11,5],[1,6,8],[1,10,7],[3,9,6],[3,7,11],
- [0,10,8],[1,8,10],[2,9,11],[3,11,9],[4,2,0],[5,0,2],[6,1,3],[7,3,1],
- [8,6,4],[9,4,6],[10,5,7],[11,7,5]]
+ v = [(s, t, 0), (-s, t, 0), (s, -t, 0), (-s, -t, 0), (t, 0, s), (t, 0, -s), (-t, 0, s), (-t, 0, -s),
+ (0, s, t), (0, -s, t), (0, s, -t), (0, -s, -t)]
+ faces = [[0, 8, 4], [0, 5, 10], [2, 4, 9], [2, 11, 5], [1, 6, 8], [1, 10, 7], [3, 9, 6], [3, 7, 11],
+ [0, 10, 8], [1, 8, 10], [2, 9, 11], [3, 11, 9], [4, 2, 0], [5, 0, 2], [6, 1, 3], [7, 3, 1],
+ [8, 6, 4], [9, 4, 6], [10, 5, 7], [11, 7, 5]]
# convert the tuples to Vectors
verts = [Vector(i) for i in v]
- return verts,faces
+ return verts, faces
+
# processes the raw data from source
-def createSolid(plato,vtrunc,etrunc,dual,snub):
+
+def createSolid(plato, vtrunc, etrunc, dual, snub):
# the duals from each platonic solid
- dualSource = {"4":"4",
- "6":"8",
- "8":"6",
- "12":"20",
- "20":"12"}
+ dualSource = {"4": "4",
+ "6": "8",
+ "8": "6",
+ "12": "20",
+ "20": "12"}
# constants saving space and readability
vtrunc *= 0.5
@@ -126,25 +138,25 @@ def createSolid(plato,vtrunc,etrunc,dual,snub):
# no truncation
if vtrunc == 0:
- if dual: # dual is as simple as another, but mirrored platonic solid
+ if dual: # dual is as simple as another, but mirrored platonic solid
vInput, fInput = source(dualSource[plato])
- supposedSize = vSum(vInput[i] for i in fInput[0]).length/len(fInput[0])
- vInput = [-i*supposedSize for i in vInput] # mirror it
+ supposedSize = vSum(vInput[i] for i in fInput[0]).length / len(fInput[0])
+ vInput = [-i * supposedSize for i in vInput] # mirror it
return vInput, fInput
return source(plato)
- elif 0 < vtrunc <= 0.5: # simple truncation of the source
+ elif 0 < vtrunc <= 0.5: # simple truncation of the source
vInput, fInput = source(plato)
else:
# truncation is now equal to simple truncation of the dual of the source
vInput, fInput = source(dualSource[plato])
supposedSize = vSum(vInput[i] for i in fInput[0]).length / len(fInput[0])
- vtrunc = 1-vtrunc # account for the source being a dual
- if vtrunc == 0: # no truncation needed
+ vtrunc = 1 - vtrunc # account for the source being a dual
+ if vtrunc == 0: # no truncation needed
if dual:
vInput, fInput = source(plato)
- vInput = [i*supposedSize for i in vInput]
+ vInput = [i * supposedSize for i in vInput]
return vInput, fInput
- vInput = [-i*supposedSize for i in vInput]
+ vInput = [-i * supposedSize for i in vInput]
return vInput, fInput
# generate connection database
@@ -153,141 +165,146 @@ def createSolid(plato,vtrunc,etrunc,dual,snub):
for x in range(len(fInput)):
i = fInput[x]
for j in range(len(i)):
- vDict[i[j-1]][i[j]] = [i[j-2],x]
- if len(vDict[i[j-1]]) == 1: vDict[i[j-1]][-1] = i[j]
+ vDict[i[j - 1]][i[j]] = [i[j - 2], x]
+ if len(vDict[i[j - 1]]) == 1:
+ vDict[i[j - 1]][-1] = i[j]
# the actual connection database: exists out of:
# [vtrunc pos, etrunc pos, connected vert IDs, connected face IDs]
- vData = [[[],[],[],[]] for i in vInput]
- fvOutput = [] # faces created from truncated vertices
- feOutput = [] # faces created from truncated edges
- vOutput = [] # newly created vertices
+ vData = [[[], [], [], []] for i in vInput]
+ fvOutput = [] # faces created from truncated vertices
+ feOutput = [] # faces created from truncated edges
+ vOutput = [] # newly created vertices
for x in range(len(vInput)):
- i = vDict[x] # lookup the current vertex
+ i = vDict[x] # lookup the current vertex
current = i[-1]
- while True: # follow the chain to get a ccw order of connected verts and faces
+ while True: # follow the chain to get a ccw order of connected verts and faces
vData[x][2].append(i[current][0])
vData[x][3].append(i[current][1])
# create truncated vertices
- vData[x][0].append((1-vtrunc)*vInput[x] + vtrunc*vInput[vData[x][2][-1]])
+ vData[x][0].append((1 - vtrunc) * vInput[x] + vtrunc * vInput[vData[x][2][-1]])
current = i[current][0]
- if current == i[-1]: break # if we're back at the first: stop the loop
- fvOutput.append([]) # new face from truncated vert
- fOffset = x*(len(i)-1) # where to start off counting faceVerts
+ if current == i[-1]:
+ break # if we're back at the first: stop the loop
+ fvOutput.append([]) # new face from truncated vert
+ fOffset = x * (len(i) - 1) # where to start off counting faceVerts
# only create one vert where one is needed (v1 todo: done)
if etrunc == 0.5:
- for j in range(len(i)-1):
- vOutput.append((vData[x][0][j]+vData[x][0][j-1])*etrunc) # create vert
- fvOutput[x].append(fOffset+j) # add to face
- fvOutput[x] = fvOutput[x][1:]+[fvOutput[x][0]] # rotate face for ease later on
+ for j in range(len(i) - 1):
+ vOutput.append((vData[x][0][j] + vData[x][0][j - 1]) * etrunc) # create vert
+ fvOutput[x].append(fOffset + j) # add to face
+ fvOutput[x] = fvOutput[x][1:] + [fvOutput[x][0]] # rotate face for ease later on
# create faces from truncated edges.
- for j in range(len(i)-1):
- if x > vData[x][2][j]: #only create when other vertex has been added
+ for j in range(len(i) - 1):
+ if x > vData[x][2][j]: # only create when other vertex has been added
index = vData[vData[x][2][j]][2].index(x)
- feOutput.append([fvOutput[x][j],fvOutput[x][j-1],
+ feOutput.append([fvOutput[x][j], fvOutput[x][j - 1],
fvOutput[vData[x][2][j]][index],
- fvOutput[vData[x][2][j]][index-1]])
+ fvOutput[vData[x][2][j]][index - 1]])
# edge truncation between none and full
elif etrunc > 0:
- for j in range(len(i)-1):
+ for j in range(len(i) - 1):
# create snubs from selecting verts from rectified meshes
if rSnub:
- vOutput.append(etrunc*vData[x][0][j]+(1-etrunc)*vData[x][0][j-1])
- fvOutput[x].append(fOffset+j)
+ vOutput.append(etrunc * vData[x][0][j] + (1 - etrunc) * vData[x][0][j - 1])
+ fvOutput[x].append(fOffset + j)
elif lSnub:
- vOutput.append((1-etrunc)*vData[x][0][j]+etrunc*vData[x][0][j-1])
- fvOutput[x].append(fOffset+j)
- else: #noSnub, select both verts from rectified mesh
- vOutput.append(etrunc*vData[x][0][j]+(1-etrunc)*vData[x][0][j-1])
- vOutput.append((1-etrunc)*vData[x][0][j]+etrunc*vData[x][0][j-1])
- fvOutput[x].append(2*fOffset+2*j)
- fvOutput[x].append(2*fOffset+2*j+1)
+ vOutput.append((1 - etrunc) * vData[x][0][j] + etrunc * vData[x][0][j - 1])
+ fvOutput[x].append(fOffset + j)
+ else: # noSnub, select both verts from rectified mesh
+ vOutput.append(etrunc * vData[x][0][j] + (1 - etrunc) * vData[x][0][j - 1])
+ vOutput.append((1 - etrunc) * vData[x][0][j] + etrunc * vData[x][0][j - 1])
+ fvOutput[x].append(2 * fOffset + 2 * j)
+ fvOutput[x].append(2 * fOffset + 2 * j + 1)
# rotate face for ease later on
- if noSnub: fvOutput[x] = fvOutput[x][2:]+fvOutput[x][:2]
- else: fvOutput[x] = fvOutput[x][1:]+[fvOutput[x][0]]
+ if noSnub:
+ fvOutput[x] = fvOutput[x][2:] + fvOutput[x][:2]
+ else:
+ fvOutput[x] = fvOutput[x][1:] + [fvOutput[x][0]]
# create single face for each edge
if noSnub:
- for j in range(len(i)-1):
+ for j in range(len(i) - 1):
if x > vData[x][2][j]:
index = vData[vData[x][2][j]][2].index(x)
- feOutput.append([fvOutput[x][j*2],fvOutput[x][2*j-1],
- fvOutput[vData[x][2][j]][2*index],
- fvOutput[vData[x][2][j]][2*index-1]])
+ feOutput.append([fvOutput[x][j * 2], fvOutput[x][2 * j - 1],
+ fvOutput[vData[x][2][j]][2 * index],
+ fvOutput[vData[x][2][j]][2 * index - 1]])
# create 2 tri's for each edge for the snubs
elif rSnub:
- for j in range(len(i)-1):
+ for j in range(len(i) - 1):
if x > vData[x][2][j]:
index = vData[vData[x][2][j]][2].index(x)
- feOutput.append([fvOutput[x][j],fvOutput[x][j-1],
+ feOutput.append([fvOutput[x][j], fvOutput[x][j - 1],
fvOutput[vData[x][2][j]][index]])
- feOutput.append([fvOutput[x][j],fvOutput[vData[x][2][j]][index],
- fvOutput[vData[x][2][j]][index-1]])
+ feOutput.append([fvOutput[x][j], fvOutput[vData[x][2][j]][index],
+ fvOutput[vData[x][2][j]][index - 1]])
elif lSnub:
- for j in range(len(i)-1):
+ for j in range(len(i) - 1):
if x > vData[x][2][j]:
index = vData[vData[x][2][j]][2].index(x)
- feOutput.append([fvOutput[x][j],fvOutput[x][j-1],
- fvOutput[vData[x][2][j]][index-1]])
- feOutput.append([fvOutput[x][j-1],fvOutput[vData[x][2][j]][index],
- fvOutput[vData[x][2][j]][index-1]])
+ feOutput.append([fvOutput[x][j], fvOutput[x][j - 1],
+ fvOutput[vData[x][2][j]][index - 1]])
+ feOutput.append([fvOutput[x][j - 1], fvOutput[vData[x][2][j]][index],
+ fvOutput[vData[x][2][j]][index - 1]])
# special rules fro birectified mesh (v1 todo: done)
elif vtrunc == 0.5:
- for j in range(len(i)-1):
- if x < vData[x][2][j]: # use current vert, since other one has not passed yet
+ for j in range(len(i) - 1):
+ if x < vData[x][2][j]: # use current vert, since other one has not passed yet
vOutput.append(vData[x][0][j])
- fvOutput[x].append(len(vOutput)-1)
+ fvOutput[x].append(len(vOutput) - 1)
else:
# search for other edge to avoid duplicity
connectee = vData[x][2][j]
fvOutput[x].append(fvOutput[connectee][vData[connectee][2].index(x)])
- else: # vert truncation only
- vOutput.extend(vData[x][0]) # use generated verts from way above
- for j in range(len(i)-1): # create face from them
- fvOutput[x].append(fOffset+j)
+ else: # vert truncation only
+ vOutput.extend(vData[x][0]) # use generated verts from way above
+ for j in range(len(i) - 1): # create face from them
+ fvOutput[x].append(fOffset + j)
# calculate supposed vertex length to ensure continuity
if supposedSize and not dual: # this to make the vtrunc > 1 work
- supposedSize *= len(fvOutput[0])/vSum(vOutput[i] for i in fvOutput[0]).length
- vOutput = [-i*supposedSize for i in vOutput]
+ supposedSize *= len(fvOutput[0]) / vSum(vOutput[i] for i in fvOutput[0]).length
+ vOutput = [-i * supposedSize for i in vOutput]
# create new faces by replacing old vert IDs by newly generated verts
ffOutput = [[] for i in fInput]
for x in range(len(fInput)):
- # only one generated vert per vertex, so choose accordingly
+ # only one generated vert per vertex, so choose accordingly
if etrunc == 0.5 or (etrunc == 0 and vtrunc == 0.5) or lSnub or rSnub:
- ffOutput[x] = [fvOutput[i][vData[i][3].index(x)-1] for i in fInput[x]]
+ ffOutput[x] = [fvOutput[i][vData[i][3].index(x) - 1] for i in fInput[x]]
# two generated verts per vertex
elif etrunc > 0:
for i in fInput[x]:
- ffOutput[x].append(fvOutput[i][2*vData[i][3].index(x)-1])
- ffOutput[x].append(fvOutput[i][2*vData[i][3].index(x)-2])
- else: # cutting off corners also makes 2 verts
+ ffOutput[x].append(fvOutput[i][2 * vData[i][3].index(x) - 1])
+ ffOutput[x].append(fvOutput[i][2 * vData[i][3].index(x) - 2])
+ else: # cutting off corners also makes 2 verts
for i in fInput[x]:
ffOutput[x].append(fvOutput[i][vData[i][3].index(x)])
- ffOutput[x].append(fvOutput[i][vData[i][3].index(x)-1])
+ ffOutput[x].append(fvOutput[i][vData[i][3].index(x) - 1])
if not dual:
- return vOutput,fvOutput + feOutput + ffOutput
+ return vOutput, fvOutput + feOutput + ffOutput
else:
- # do the same procedure as above, only now on the generated mesh
+ # do the same procedure as above, only now on the generated mesh
# generate connection database
vDict = [{} for i in vOutput]
dvOutput = [0 for i in fvOutput + feOutput + ffOutput]
dfOutput = []
- for x in range(len(dvOutput)): # for every face
- i = (fvOutput + feOutput + ffOutput)[x] # choose face to work with
+ for x in range(len(dvOutput)): # for every face
+ i = (fvOutput + feOutput + ffOutput)[x] # choose face to work with
# find vertex from face
- normal = (vOutput[i[0]]-vOutput[i[1]]).cross(vOutput[i[2]]-vOutput[i[1]]).normalized()
- dvOutput[x] = normal/(normal.dot(vOutput[i[0]]))
- for j in range(len(i)): # create vert chain
- vDict[i[j-1]][i[j]] = [i[j-2],x]
- if len(vDict[i[j-1]]) == 1: vDict[i[j-1]][-1] = i[j]
+ normal = (vOutput[i[0]] - vOutput[i[1]]).cross(vOutput[i[2]] - vOutput[i[1]]).normalized()
+ dvOutput[x] = normal / (normal.dot(vOutput[i[0]]))
+ for j in range(len(i)): # create vert chain
+ vDict[i[j - 1]][i[j]] = [i[j - 2], x]
+ if len(vDict[i[j - 1]]) == 1:
+ vDict[i[j - 1]][-1] = i[j]
# calculate supposed size for continuity
- supposedSize = vSum([vInput[i] for i in fInput[0]]).length/len(fInput[0])
+ supposedSize = vSum([vInput[i] for i in fInput[0]]).length / len(fInput[0])
supposedSize /= dvOutput[-1].length
- dvOutput = [i*supposedSize for i in dvOutput]
+ dvOutput = [i * supposedSize for i in dvOutput]
# use chains to create faces
for x in range(len(vOutput)):
@@ -297,10 +314,12 @@ def createSolid(plato,vtrunc,etrunc,dual,snub):
while True:
face.append(i[current][1])
current = i[current][0]
- if current == i[-1]: break
+ if current == i[-1]:
+ break
dfOutput.append(face)
- return dvOutput,dfOutput
+ return dvOutput, dfOutput
+
class Solids(bpy.types.Operator):
"""Add one of the (regular) solids (mesh)"""
@@ -309,118 +328,134 @@ class Solids(bpy.types.Operator):
bl_description = "Add one of the Platonic, Archimedean or Catalan solids"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
- source = EnumProperty(items = (("4","Tetrahedron",""),
- ("6","Hexahedron",""),
- ("8","Octahedron",""),
- ("12","Dodecahedron",""),
- ("20","Icosahedron","")),
- name = "Source",
- description = "Starting point of your solid")
- size = FloatProperty(name = "Size",
- description = "Radius of the sphere through the vertices",
- min = 0.01,
- soft_min = 0.01,
- max = 100,
- soft_max = 100,
- default = 1.0)
- vTrunc = FloatProperty(name = "Vertex Truncation",
- description = "Ammount of vertex truncation",
- min = 0.0,
- soft_min = 0.0,
- max = 2.0,
- soft_max = 2.0,
- default = 0.0,
- precision = 3,
- step = 0.5)
- eTrunc = FloatProperty(name = "Edge Truncation",
- description = "Ammount of edge truncation",
- min = 0.0,
- soft_min = 0.0,
- max = 1.0,
- soft_max = 1.0,
- default = 0.0,
- precision = 3,
- step = 0.2)
- snub = EnumProperty(items = (("None","No Snub",""),
- ("Left","Left Snub",""),
- ("Right","Right Snub","")),
- name = "Snub",
- description = "Create the snub version")
- dual = BoolProperty(name="Dual",
- description="Create the dual of the current solid",
- default=False)
- keepSize = BoolProperty(name="Keep Size",
- description="Keep the whole solid at a constant size",
- default=False)
- preset = EnumProperty(items = (("0","Custom",""),
- ("t4","Truncated Tetrahedron",""),
- ("r4","Cuboctahedron",""),
- ("t6","Truncated Cube",""),
- ("t8","Truncated Octahedron",""),
- ("b6","Rhombicuboctahedron",""),
- ("c6","Truncated Cuboctahedron",""),
- ("s6","Snub Cube",""),
- ("r12","Icosidodecahedron",""),
- ("t12","Truncated Dodecahedron",""),
- ("t20","Truncated Icosahedron",""),
- ("b12","Rhombicosidodecahedron",""),
- ("c12","Truncated Icosidodecahedron",""),
- ("s12","Snub Dodecahedron",""),
- ("dt4","Triakis Tetrahedron",""),
- ("dr4","Rhombic Dodecahedron",""),
- ("dt6","Triakis Octahedron",""),
- ("dt8","Tetrakis Hexahedron",""),
- ("db6","Deltoidal Icositetrahedron",""),
- ("dc6","Disdyakis Dodecahedron",""),
- ("ds6","Pentagonal Icositetrahedron",""),
- ("dr12","Rhombic Triacontahedron",""),
- ("dt12","Triakis Icosahedron",""),
- ("dt20","Pentakis Dodecahedron",""),
- ("db12","Deltoidal Hexecontahedron",""),
- ("dc12","Disdyakis Triacontahedron",""),
- ("ds12","Pentagonal Hexecontahedron","")),
- name = "Presets",
- description = "Parameters for some hard names")
+ source = EnumProperty(
+ items=(("4", "Tetrahedron", ""),
+ ("6", "Hexahedron", ""),
+ ("8", "Octahedron", ""),
+ ("12", "Dodecahedron", ""),
+ ("20", "Icosahedron", "")),
+ name="Source",
+ description="Starting point of your solid"
+ )
+ size = FloatProperty(
+ name="Size",
+ description="Radius of the sphere through the vertices",
+ min=0.01,
+ soft_min=0.01,
+ max=100,
+ soft_max=100,
+ default=1.0
+ )
+ vTrunc = FloatProperty(
+ name="Vertex Truncation",
+ description="Ammount of vertex truncation",
+ min=0.0,
+ soft_min=0.0,
+ max=2.0,
+ soft_max=2.0,
+ default=0.0,
+ precision=3,
+ step=0.5
+ )
+ eTrunc = FloatProperty(
+ name="Edge Truncation",
+ description="Ammount of edge truncation",
+ min=0.0,
+ soft_min=0.0,
+ max=1.0,
+ soft_max=1.0,
+ default=0.0,
+ precision=3,
+ step=0.2
+ )
+ snub = EnumProperty(
+ items=(("None", "No Snub", ""),
+ ("Left", "Left Snub", ""),
+ ("Right", "Right Snub", "")),
+ name="Snub",
+ description="Create the snub version"
+ )
+ dual = BoolProperty(
+ name="Dual",
+ description="Create the dual of the current solid",
+ default=False
+ )
+ keepSize = BoolProperty(
+ name="Keep Size",
+ description="Keep the whole solid at a constant size",
+ default=False
+ )
+ preset = EnumProperty(
+ items=(("0", "Custom", ""),
+ ("t4", "Truncated Tetrahedron", ""),
+ ("r4", "Cuboctahedron", ""),
+ ("t6", "Truncated Cube", ""),
+ ("t8", "Truncated Octahedron", ""),
+ ("b6", "Rhombicuboctahedron", ""),
+ ("c6", "Truncated Cuboctahedron", ""),
+ ("s6", "Snub Cube", ""),
+ ("r12", "Icosidodecahedron", ""),
+ ("t12", "Truncated Dodecahedron", ""),
+ ("t20", "Truncated Icosahedron", ""),
+ ("b12", "Rhombicosidodecahedron", ""),
+ ("c12", "Truncated Icosidodecahedron", ""),
+ ("s12", "Snub Dodecahedron", ""),
+ ("dt4", "Triakis Tetrahedron", ""),
+ ("dr4", "Rhombic Dodecahedron", ""),
+ ("dt6", "Triakis Octahedron", ""),
+ ("dt8", "Tetrakis Hexahedron", ""),
+ ("db6", "Deltoidal Icositetrahedron", ""),
+ ("dc6", "Disdyakis Dodecahedron", ""),
+ ("ds6", "Pentagonal Icositetrahedron", ""),
+ ("dr12", "Rhombic Triacontahedron", ""),
+ ("dt12", "Triakis Icosahedron", ""),
+ ("dt20", "Pentakis Dodecahedron", ""),
+ ("db12", "Deltoidal Hexecontahedron", ""),
+ ("dc12", "Disdyakis Triacontahedron", ""),
+ ("ds12", "Pentagonal Hexecontahedron", "")),
+ name="Presets",
+ description="Parameters for some hard names"
+ )
# actual preset values
- p = {"t4":["4",2/3,0,0,"None"],
- "r4":["4",1,1,0,"None"],
- "t6":["6",2/3,0,0,"None"],
- "t8":["8",2/3,0,0,"None"],
- "b6":["6",1.0938,1,0,"None"],
- "c6":["6",1.0572,0.585786,0,"None"],
- "s6":["6",1.0875,0.704,0,"Left"],
- "r12":["12",1,0,0,"None"],
- "t12":["12",2/3,0,0,"None"],
- "t20":["20",2/3,0,0,"None"],
- "b12":["12",1.1338,1,0,"None"],
- "c12":["20",0.921,0.553,0,"None"],
- "s12":["12",1.1235,0.68,0,"Left"],
- "dt4":["4",2/3,0,1,"None"],
- "dr4":["4",1,1,1,"None"],
- "dt6":["6",2/3,0,1,"None"],
- "dt8":["8",2/3,0,1,"None"],
- "db6":["6",1.0938,1,1,"None"],
- "dc6":["6",1.0572,0.585786,1,"None"],
- "ds6":["6",1.0875,0.704,1,"Left"],
- "dr12":["12",1,0,1,"None"],
- "dt12":["12",2/3,0,1,"None"],
- "dt20":["20",2/3,0,1,"None"],
- "db12":["12",1.1338,1,1,"None"],
- "dc12":["20",0.921,0.553,1,"None"],
- "ds12":["12",1.1235,0.68,1,"Left"]}
-
- #previous preset, for User-friendly reasons
+ p = {"t4": ["4", 2 / 3, 0, 0, "None"],
+ "r4": ["4", 1, 1, 0, "None"],
+ "t6": ["6", 2 / 3, 0, 0, "None"],
+ "t8": ["8", 2 / 3, 0, 0, "None"],
+ "b6": ["6", 1.0938, 1, 0, "None"],
+ "c6": ["6", 1.0572, 0.585786, 0, "None"],
+ "s6": ["6", 1.0875, 0.704, 0, "Left"],
+ "r12": ["12", 1, 0, 0, "None"],
+ "t12": ["12", 2 / 3, 0, 0, "None"],
+ "t20": ["20", 2 / 3, 0, 0, "None"],
+ "b12": ["12", 1.1338, 1, 0, "None"],
+ "c12": ["20", 0.921, 0.553, 0, "None"],
+ "s12": ["12", 1.1235, 0.68, 0, "Left"],
+ "dt4": ["4", 2 / 3, 0, 1, "None"],
+ "dr4": ["4", 1, 1, 1, "None"],
+ "dt6": ["6", 2 / 3, 0, 1, "None"],
+ "dt8": ["8", 2 / 3, 0, 1, "None"],
+ "db6": ["6", 1.0938, 1, 1, "None"],
+ "dc6": ["6", 1.0572, 0.585786, 1, "None"],
+ "ds6": ["6", 1.0875, 0.704, 1, "Left"],
+ "dr12": ["12", 1, 0, 1, "None"],
+ "dt12": ["12", 2 / 3, 0, 1, "None"],
+ "dt20": ["20", 2 / 3, 0, 1, "None"],
+ "db12": ["12", 1.1338, 1, 1, "None"],
+ "dc12": ["20", 0.921, 0.553, 1, "None"],
+ "ds12": ["12", 1.1235, 0.68, 1, "Left"]}
+
+ # previous preset, for User-friendly reasons
previousSetting = ""
- def execute(self,context):
+ def execute(self, context):
# turn off undo for better performance (3-5x faster), also makes sure
# that mesh ops are undoable and entire script acts as one operator
bpy.context.user_preferences.edit.use_global_undo = False
# piece of code to make presets remain until parameters are changed
if self.preset != "0":
- #if preset, set preset
+ # if preset, set preset
if self.previousSetting != self.preset:
using = self.p[self.preset]
self.source = using[0]
@@ -434,7 +469,7 @@ class Solids(bpy.types.Operator):
result1 = abs(self.vTrunc - using[1]) < 0.004
result2 = abs(self.eTrunc - using[2]) < 0.0015
result4 = using[4] == self.snub or ((using[4] == "Left") and
- self.snub in ["Left","Right"])
+ self.snub in ["Left", "Right"])
if (result0 and result1 and result2 and result4):
if self.p[self.previousSetting][3] != self.dual:
if self.preset[0] == "d":
@@ -447,20 +482,22 @@ class Solids(bpy.types.Operator):
self.previousSetting = self.preset
# generate mesh
- verts,faces = createSolid(self.source,
+ verts, faces = createSolid(self.source,
self.vTrunc,
self.eTrunc,
self.dual,
- self.snub)
+ self.snub
+ )
# turn n-gons in quads and tri's
faces = createPolys(faces)
# resize to normal size, or if keepSize, make sure all verts are of length 'size'
if self.keepSize:
- rad = self.size/verts[-1 if self.dual else 0].length
- else: rad = self.size
- verts = [i*rad for i in verts]
+ rad = self.size / verts[-1 if self.dual else 0].length
+ else:
+ rad = self.size
+ verts = [i * rad for i in verts]
# generate object
# Create new mesh
diff --git a/add_mesh_extra_objects/add_mesh_star.py b/add_mesh_extra_objects/add_mesh_star.py
index 9bdd0b83..ae63f2c6 100644
--- a/add_mesh_extra_objects/add_mesh_star.py
+++ b/add_mesh_extra_objects/add_mesh_star.py
@@ -1,14 +1,19 @@
# GPL Original by Fourmadmen
import bpy
-from mathutils import *
-from math import *
-from bpy.props import *
+from mathutils import Vector, Quaternion
+from math import pi
+from bpy.props import (
+ IntProperty,
+ FloatProperty,
+ )
+
# Create a new mesh (object) from verts/edges/faces.
# verts/edges/faces ... List of vertices/edges/faces for the
-# new mesh (as used in from_pydata).
-# name ... Name of the new mesh (& object).
+# new mesh (as used in from_pydata)
+# name ... Name of the new mesh (& object)
+
def create_mesh_object(context, verts, edges, faces, name):
# Create new mesh
@@ -23,6 +28,7 @@ def create_mesh_object(context, verts, edges, faces, name):
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)
+
# A very simple "bridge" tool.
def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
@@ -68,14 +74,14 @@ def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
face = [vertIdx2[num], vertIdx1[0], vertIdx2[num + 1]]
else:
face = [vertIdx2[num], vertIdx1[num],
- vertIdx1[num + 1], vertIdx2[num + 1]]
+ vertIdx1[num + 1], vertIdx2[num + 1]]
faces.append(face)
else:
if fan:
face = [vertIdx1[0], vertIdx2[num], vertIdx2[num + 1]]
else:
face = [vertIdx1[num], vertIdx2[num],
- vertIdx2[num + 1], vertIdx1[num + 1]]
+ vertIdx2[num + 1], vertIdx1[num + 1]]
faces.append(face)
return faces
@@ -121,8 +127,6 @@ def add_star(points, outer_radius, inner_radius, height):
vec = quat * Vector((radius, 0, -half_height))
verts.append(vec)
-
-
faces_top = createFaces([vert_idx_top], edgeloop_top, closed=True)
faces_outside = createFaces(edgeloop_top, edgeloop_bottom, closed=True)
faces_bottom = createFaces([vert_idx_bottom], edgeloop_bottom,
@@ -134,32 +138,40 @@ def add_star(points, outer_radius, inner_radius, height):
return verts, faces
+
class AddStar(bpy.types.Operator):
- """Add a star mesh"""
bl_idname = "mesh.primitive_star_add"
bl_label = "Simple Star"
+ bl_description = "Construct a star mesh"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
- points = IntProperty(name="Points",
+ points = IntProperty(
+ name="Points",
description="Number of points for the star",
min=2,
max=256,
- default=5)
- outer_radius = FloatProperty(name="Outer Radius",
+ default=5
+ )
+ outer_radius = FloatProperty(
+ name="Outer Radius",
description="Outer radius of the star",
min=0.01,
max=9999.0,
- default=1.0)
- innter_radius = FloatProperty(name="Inner Radius",
+ default=1.0
+ )
+ innter_radius = FloatProperty(
+ name="Inner Radius",
description="Inner radius of the star",
min=0.01,
max=9999.0,
- default=0.5)
+ default=0.5
+ )
height = FloatProperty(name="Height",
description="Height of the star",
min=0.01,
max=9999.0,
- default=0.5)
+ default=0.5
+ )
def execute(self, context):
@@ -167,7 +179,8 @@ class AddStar(bpy.types.Operator):
self.points,
self.outer_radius,
self.innter_radius,
- self.height)
+ self.height
+ )
obj = create_mesh_object(context, verts, [], faces, "Star")
diff --git a/add_mesh_extra_objects/add_mesh_supertoroid.py b/add_mesh_extra_objects/add_mesh_supertoroid.py
index 4728acec..65533315 100644
--- a/add_mesh_extra_objects/add_mesh_supertoroid.py
+++ b/add_mesh_extra_objects/add_mesh_supertoroid.py
@@ -1,15 +1,20 @@
# GPL # "author": "DreamPainter"
import bpy
-from bpy.props import FloatProperty,BoolProperty,IntProperty
+from bpy.props import (
+ FloatProperty,
+ BoolProperty,
+ IntProperty,
+ )
from math import pi, cos, sin
from mathutils import Vector
-from bpy_extras import object_utils
-# Create a new mesh (object) from verts/edges/faces.
+
+# Create a new mesh (object) from verts/edges/faces
# verts/edges/faces ... List of vertices/edges/faces for the
-# new mesh (as used in from_pydata).
-# name ... Name of the new mesh (& object).
+# new mesh (as used in from_pydata)
+# name ... Name of the new mesh (& object)
+
def create_mesh_object(context, verts, edges, faces, name):
# Create new mesh
@@ -24,7 +29,8 @@ def create_mesh_object(context, verts, edges, faces, name):
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)
-# A very simple "bridge" tool.
+
+# A very simple "bridge" tool
def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
faces = []
@@ -82,12 +88,13 @@ def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
return faces
-def power(a,b):
+def power(a, b):
if a < 0:
- return -((-a)**b)
- return a**b
-
-def supertoroid(R,r,u,v,n1,n2):
+ return -((-a) ** b)
+ return a ** b
+
+
+def supertoroid(R, r, u, v, n1, n2):
"""
R = big radius
r = small radius
@@ -96,99 +103,121 @@ def supertoroid(R,r,u,v,n1,n2):
n1 = value determines the shape of the torus
n2 = value determines the shape of the cross-section
"""
-
# create the necessary constants
- a = 2*pi/u
- b = 2*pi/v
+ a = 2 * pi / u
+ b = 2 * pi / v
verts = []
faces = []
-
- # create each cross-section by calculating each vector on the
+
+ # create each cross-section by calculating each vector on the
# the wannabe circle
- # x = (cos(theta)**n1)*(R+r*(cos(phi)**n2))
- # y = (sin(theta)**n1)*(R+r*(cos(phi)**n2))
- # z = (r*sin(phi)**n2)
+ # x = (cos(theta) ** n1)*(R + r * (cos(phi) ** n2))
+ # y = (sin(theta) ** n1)*(R + r * (cos(phi) ** n2))
+ # z = (r * sin(phi) ** n2)
# with theta and phi rangeing from 0 to 2pi
+
for i in range(u):
- s = power(sin(i*a),n1)
- c = power(cos(i*a),n1)
+ s = power(sin(i * a), n1)
+ c = power(cos(i * a), n1)
for j in range(v):
- c2 = R+r*power(cos(j*b),n2)
- s2 = r*power(sin(j*b),n2)
- verts.append(Vector((c*c2,s*c2,s2)))
+ c2 = R + r * power(cos(j * b), n2)
+ s2 = r * power(sin(j * b), n2)
+ verts.append(Vector((c * c2, s * c2, s2)))
+
# bridge the last circle with the previous circle
if i > 0: # but not for the first circle, 'cus there's no previous before the first
- f = createFaces(range((i-1)*v,i*v),range(i*v,(i+1)*v),closed = True)
+ f = createFaces(range((i - 1) * v, i * v), range(i * v, (i + 1) * v), closed=True)
faces.extend(f)
# bridge the last circle with the first
- f = createFaces(range((u-1)*v,u*v),range(v),closed=True)
+ f = createFaces(range((u - 1) * v, u * v), range(v), closed=True)
faces.extend(f)
return verts, faces
+
class add_supertoroid(bpy.types.Operator):
- """Add a SuperToroid"""
bl_idname = "mesh.primitive_supertoroid_add"
bl_label = "Add SuperToroid"
- bl_description = "Create a SuperToroid"
+ bl_description = "Construct a supertoroid mesh"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
- R = FloatProperty(name = "big radius",
- description = "The radius inside the tube",
- default = 1.0, min = 0.01, max = 100.0)
- r = FloatProperty(name = "small radius",
- description = "The radius of the tube",
- default = 0.3, min = 0.01, max = 100.0)
- u = IntProperty(name = "U-segments",
- description = "radial segmentation",
- default = 16, min = 3, max = 265)
- v = IntProperty(name = "V-segments",
- description = "lateral segmentation",
- default = 8, min = 3, max = 265)
- n1 = FloatProperty(name = "Ring manipulator",
- description = "Manipulates the shape of the Ring",
- default = 1.0, min = 0.01, max = 100.0)
- n2 = FloatProperty(name = "Cross manipulator",
- description = "Manipulates the shape of the cross-section",
- default = 1.0, min = 0.01, max = 100.0)
- ie = BoolProperty(name = "Use Int.+Ext. radii",
- description = "Use internal and external radii",
- default = False)
- edit = BoolProperty(name="",
- description="",
- default=False,
- options={'HIDDEN'})
-
- def execute(self,context):
+ R = FloatProperty(
+ name="Big radius",
+ description="The radius inside the tube",
+ default=1.0,
+ min=0.01, max=100.0
+ )
+ r = FloatProperty(
+ name="Small radius",
+ description="The radius of the tube",
+ default=0.3,
+ min=0.01, max=100.0
+ )
+ u = IntProperty(
+ name="U-segments",
+ description="Radial segmentation",
+ default=16,
+ min=3, max=265
+ )
+ v = IntProperty(
+ name="V-segments",
+ description="Lateral segmentation",
+ default=8,
+ min=3, max=265
+ )
+ n1 = FloatProperty(
+ name="Ring manipulator",
+ description="Manipulates the shape of the Ring",
+ default=1.0,
+ min=0.01, max=100.0
+ )
+ n2 = FloatProperty(
+ name="Cross manipulator",
+ description="Manipulates the shape of the cross-section",
+ default=1.0,
+ min=0.01, max=100.0
+ )
+ ie = BoolProperty(
+ name="Use Int. and Ext. radii",
+ description="Use internal and external radii",
+ default=False
+ )
+ edit = BoolProperty(
+ name="",
+ description="",
+ default=False,
+ options={'HIDDEN'}
+ )
+
+ def execute(self, context):
props = self.properties
# check how the radii properties must be used
if props.ie:
- rad1 = (props.R+props.r)/2
- rad2 = (props.R-props.r)/2
+ rad1 = (props.R + props.r) / 2
+ rad2 = (props.R - props.r) / 2
# for consistency in the mesh, ie no crossing faces, make the largest of the two
# the outer radius
if rad2 > rad1:
- [rad1,rad2] = [rad2,rad1]
+ [rad1, rad2] = [rad2, rad1]
else:
rad1 = props.R
rad2 = props.r
- # again for consistency, make the radius in the tube,
+ # again for consistency, make the radius in the tube,
# at least as big as the radius of the tube
if rad2 > rad1:
rad1 = rad2
# create mesh
- verts,faces = supertoroid(rad1,
+ verts, faces = supertoroid(rad1,
rad2,
props.u,
props.v,
props.n1,
- props.n2)
-
+ props.n2
+ )
# create the object
obj = create_mesh_object(context, verts, [], faces, "SuperToroid")
-
return {'FINISHED'}
diff --git a/add_mesh_extra_objects/add_mesh_teapot.py b/add_mesh_extra_objects/add_mesh_teapot.py
index 01b16a38..27e7f703 100644
--- a/add_mesh_extra_objects/add_mesh_teapot.py
+++ b/add_mesh_extra_objects/add_mesh_teapot.py
@@ -1,7 +1,10 @@
# GPL # Author, Anthony D'Agostino
import bpy
-from bpy.props import IntProperty
+from bpy.props import (
+ IntProperty,
+ EnumProperty,
+ )
import mathutils
@@ -9,21 +12,26 @@ import io
import operator
import functools
+
class AddTeapot(bpy.types.Operator):
- """Add a teapot mesh"""
bl_idname = "mesh.primitive_teapot_add"
bl_label = "Add Teapot"
+ bl_description = "Construct a teapot or teaspoon mesh"
bl_options = {"REGISTER", "UNDO"}
resolution = IntProperty(
name="Resolution",
description="Resolution of the Teapot",
- default=5, min=2, max=15,
+ default=5,
+ min=2, max=15,
)
- objecttype = IntProperty(
+ objecttype = EnumProperty(
name="Object Type",
description="Type of Bezier Object",
- default=1, min=1, max=2)
+ items=(('1', "Teapot", "Construct a teapot mesh"),
+ ('2', "Tea Spoon", "Construct a teaspoon mesh")),
+ default='1',
+ )
def execute(self, context):
verts, faces = make_teapot(self.objecttype,
@@ -32,6 +40,7 @@ class AddTeapot(bpy.types.Operator):
obj = create_mesh_object(context, verts, [], faces, "Teapot")
return {'FINISHED'}
+
def create_mesh_face_hack(faces):
# FIXME, faces with duplicate vertices shouldn't be created in the first place.
faces_copy = []
@@ -43,6 +52,7 @@ def create_mesh_face_hack(faces):
faces_copy.append(f_copy)
faces[:] = faces_copy
+
def create_mesh_object(context, verts, edges, faces, name):
create_mesh_face_hack(faces)
@@ -60,6 +70,7 @@ def create_mesh_object(context, verts, edges, faces, name):
# ==========================
# === Bezier patch Block ===
# ==========================
+
def read_indexed_patch_file(filename):
file = io.StringIO(filename)
rawpatches = []
@@ -81,7 +92,7 @@ def read_indexed_patch_file(filename):
v1, v2, v3 = map(float, line.split(","))
verts.append((v1, v2, v3))
for i in range(len(patches)):
- for j in range(4): # len(patches[i])):
+ for j in range(4): # len(patches[i])):
for k in range(4): # len(patches[i][j])):
index = patches[i][j][k] - 1
rawpatches[i][j][k] = verts[index]
@@ -109,7 +120,7 @@ def make_bezier(ctrlpnts, resolution):
def makevert(t):
x, y, z = b1(t) * p1 + b2(t) * p2 + b3(t) * p3 + b4(t) * p4
return (x, y, z)
- curveverts = [makevert(i/resolution) for i in range(resolution+1)]
+ curveverts = [makevert(i / resolution) for i in range(resolution + 1)]
return curveverts
@@ -178,14 +189,21 @@ def transpose(rowsbycols):
return colsbyrows
-def make_teapot(filename, resolution):
+def make_teapot(enumname, resolution):
filenames = [None, teapot, teaspoon]
- filename = filenames[filename]
+ try:
+ indexs = int(enumname)
+ filename = filenames[indexs]
+ except:
+ print("Add Teapot Error: EnumProperty could not be set")
+ filename = filenames[1]
+
patches = read_indexed_patch_file(filename)
raw = patches_to_raw(patches, resolution)
verts, faces = raw_to_indexed(raw)
return (verts, faces)
+
# =================================
# === Indexed Bezier Data Block ===
# =================================
diff --git a/add_mesh_extra_objects/add_mesh_torusknot.py b/add_mesh_extra_objects/add_mesh_torusknot.py
index 24bb9b4e..1cdac6b6 100644
--- a/add_mesh_extra_objects/add_mesh_torusknot.py
+++ b/add_mesh_extra_objects/add_mesh_torusknot.py
@@ -1,6 +1,10 @@
# GPL # Author, Anthony D'Agostino
-import bpy, mathutils, math
+import bpy
+from mathutils import Vector
+from math import sin, cos, pi
+from bpy.props import IntProperty
+
def create_mesh_object(context, verts, edges, faces, name):
# Create new mesh
@@ -12,90 +16,103 @@ def create_mesh_object(context, verts, edges, faces, name):
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)
+
# ========================
# === Torus Knot Block ===
# ========================
+
def k1(t):
- x = math.cos(t) - 2*math.cos(2*t)
- y = math.sin(t) + 2*math.sin(2*t)
- z = math.sin(3*t)
- return mathutils.Vector([x,y,z])
+ x = cos(t) - 2 * cos(2 * t)
+ y = sin(t) + 2 * sin(2 * t)
+ z = sin(3 * t)
+ return Vector([x, y, z])
+
def k2(t):
- x = 10 * (math.cos(t) + math.cos(3*t)) + math.cos(2*t) + math.cos(4*t)
- y = 6 * math.sin(t) + 10 * math.sin(3*t)
- z = 4 * math.sin(3*t) * math.sin(5*t/2) + 4*math.sin(4*t) - 2*math.sin(6*t)
- return mathutils.Vector([x,y,z]) * 0.2
+ x = 10 * (cos(t) + cos(3 * t)) + cos(2 * t) + cos(4 * t)
+ y = 6 * sin(t) + 10 * sin(3 * t)
+ z = 4 * sin(3 * t) * sin(5 * t / 2) + 4 * sin(4 * t) - 2 * sin(6 * t)
+ return Vector([x, y, z]) * 0.2
+
def k3(t):
- x = 2.5*math.cos(t+math.pi)/3 + 2*math.cos(3*t)
- y = 2.5*math.sin(t)/3 + 2*math.sin(3*t)
- z = 1.5*math.sin(4*t) + math.sin(2*t)/3
- return mathutils.Vector([x,y,z])
+ x = 2.5 * cos(t + pi) / 3 + 2 * cos(3 * t)
+ y = 2.5 * sin(t) / 3 + 2 * sin(3 * t)
+ z = 1.5 * sin(4 * t) + sin(2 * t) / 3
+ return Vector([x, y, z])
+
def make_verts(ures, vres, r2, knotfunc):
- verts = []
- for i in range(ures):
- t1 = (i+0) * 2*math.pi/ures
- t2 = (i+1) * 2*math.pi/ures
- a = knotfunc(t1) # curr point
- b = knotfunc(t2) # next point
- a,b = map(mathutils.Vector, (a,b))
- e = a-b
- f = a+b
- g = e.cross(f)
- h = e.cross(g)
- g.normalize()
- h.normalize()
- for j in range(vres):
- k = j * 2*math.pi/vres
- l = (math.cos(k),0.0,math.sin(k))
- l = mathutils.Vector(l)
- m = l * r2
- x,y,z = m
- n = h*x
- o = g*z
- p = n+o
- q = a+p
- verts.append(q)
- return verts
+ verts = []
+ for i in range(ures):
+ t1 = (i + 0) * 2 * pi / ures
+ t2 = (i + 1) * 2 * pi / ures
+ a = knotfunc(t1) # curr point
+ b = knotfunc(t2) # next point
+ a, b = map(Vector, (a, b))
+ e = a - b
+ f = a + b
+ g = e.cross(f)
+ h = e.cross(g)
+ g.normalize()
+ h.normalize()
+ for j in range(vres):
+ k = j * 2 * pi / vres
+ l = (cos(k), 0.0, sin(k))
+ l = Vector(l)
+ m = l * r2
+ x, y, z = m
+ n = h * x
+ o = g * z
+ p = n + o
+ q = a + p
+ verts.append(q)
+ return verts
+
def make_faces(ures, vres):
- faces = []
- for u in range(0, ures):
- for v in range(0, vres):
- p1 = v + u*vres
- p2 = v + ((u+1)%ures)*vres
- p4 = (v+1)%vres + u*vres
- p3 = (v+1)%vres + ((u+1)%ures)*vres
- faces.append([p4, p3, p2, p1])
- return faces
+ faces = []
+ for u in range(0, ures):
+ for v in range(0, vres):
+ p1 = v + u * vres
+ p2 = v + ((u + 1) % ures) * vres
+ p4 = (v + 1) % vres + u * vres
+ p3 = (v + 1) % vres + ((u + 1) % ures) * vres
+ faces.append([p4, p3, p2, p1])
+ return faces
+
def make_knot(knotidx, ures):
- knots = [k1,k2,k3]
- knotfunc = knots[knotidx-1]
- vres = ures//10
- r2 = 0.5
- verts = make_verts(ures, vres, r2, knotfunc)
- faces = make_faces(ures, vres)
- return (verts, faces)
+ knots = [k1, k2, k3]
+ knotfunc = knots[knotidx - 1]
+ vres = ures // 10
+ r2 = 0.5
+ verts = make_verts(ures, vres, r2, knotfunc)
+ faces = make_faces(ures, vres)
+ return (verts, faces)
+
class AddTorusKnot(bpy.types.Operator):
- """Add a torus-knot mesh"""
- bl_idname = "mesh.primitive_torusknot_add"
- bl_label = "Add Torus Knot"
- bl_options = {"REGISTER", "UNDO"}
-
- resolution = bpy.props.IntProperty(name="Resolution",
- description="Resolution of the Torus Knot",
- default=80, min=30, max=256)
-
- objecttype = bpy.props.IntProperty(name="Knot Type",
- description="Type of Knot",
- default=1, min=1, max=3)
-
- def execute(self, context):
- verts, faces = make_knot(self.objecttype,
- self.resolution)
- obj = create_mesh_object(context, verts, [], faces, "Torus Knot")
- return {'FINISHED'}
+ bl_idname = "mesh.primitive_torusknot_add"
+ bl_label = "Add Torus Knot"
+ bl_description = "Construct a torus knot mesh"
+ bl_options = {"REGISTER", "UNDO"}
+
+ resolution = IntProperty(
+ name="Resolution",
+ description="Resolution of the Torus Knot",
+ default=80,
+ min=30, max=256
+ )
+ objecttype = IntProperty(
+ name="Knot Type",
+ description="Type of Knot",
+ default=1,
+ min=1, max=3
+ )
+
+ def execute(self, context):
+ verts, faces = make_knot(self.objecttype, self.resolution)
+ obj = create_mesh_object(context, verts, [], faces, "Torus Knot")
+
+ return {'FINISHED'}
diff --git a/add_mesh_extra_objects/add_mesh_twisted_torus.py b/add_mesh_extra_objects/add_mesh_twisted_torus.py
index e628055f..f66324a4 100644
--- a/add_mesh_extra_objects/add_mesh_twisted_torus.py
+++ b/add_mesh_extra_objects/add_mesh_twisted_torus.py
@@ -1,30 +1,36 @@
-# GPL # by Paulo_Gomes
+# GPL # "author": Paulo_Gomes
import bpy
-from bpy.props import *
-
-from mathutils import *
+from mathutils import Quaternion, Vector
from math import cos, sin, pi
+from bpy.props import (
+ FloatProperty,
+ IntProperty,
+ BoolProperty,
+ )
+
-# Create a new mesh (object) from verts/edges/faces.
+# Create a new mesh (object) from verts/edges/faces
# verts/edges/faces ... List of vertices/edges/faces for the
-# new mesh (as used in from_pydata).
-# name ... Name of the new mesh (& object).
+# new mesh (as used in from_pydata)
+# name ... Name of the new mesh (& object)
+
def create_mesh_object(context, verts, edges, faces, name):
# Create new mesh
mesh = bpy.data.meshes.new(name)
- # Make a mesh from a list of verts/edges/faces.
+ # Make a mesh from a list of verts/edges/faces
mesh.from_pydata(verts, edges, faces)
- # Update mesh geometry after adding stuff.
+ # Update mesh geometry after adding stuff
mesh.update()
from bpy_extras import object_utils
return object_utils.object_data_add(context, mesh, operator=None)
-# A very simple "bridge" tool.
+
+# A very simple "bridge" tool
def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
faces = []
@@ -45,7 +51,7 @@ def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
total = len(vertIdx2)
if closed:
- # Bridge the start with the end.
+ # Bridge the start with the end
if flipped:
face = [
vertIdx1[0],
@@ -62,7 +68,7 @@ def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
face.append(vertIdx2[total - 1])
faces.append(face)
- # Bridge the rest of the faces.
+ # Bridge the rest of the faces
for num in range(total - 1):
if flipped:
if fan:
@@ -81,6 +87,7 @@ def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
return faces
+
def add_twisted_torus(major_rad, minor_rad, major_seg, minor_seg, twists):
PI_2 = pi * 2.0
z_axis = (0.0, 0.0, 1.0)
@@ -108,7 +115,7 @@ def add_twisted_torus(major_rad, minor_rad, major_seg, minor_seg, twists):
edgeloop.append(len(verts))
verts.append(vec)
- # Remember very first edgeloop.
+ # Remember very first edgeloop
if major_index == 0:
edgeloop_first = edgeloop
@@ -125,56 +132,72 @@ def add_twisted_torus(major_rad, minor_rad, major_seg, minor_seg, twists):
return verts, faces
+
class AddTwistedTorus(bpy.types.Operator):
- """Add a torus mesh"""
bl_idname = "mesh.primitive_twisted_torus_add"
- bl_label = "Add Torus"
+ bl_label = "Add Twisted Torus"
+ bl_description = "Construct a twisted torus mesh"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
- major_radius = FloatProperty(name="Major Radius",
- description="Radius from the origin to the" \
- " center of the cross section",
+ major_radius = FloatProperty(
+ name="Major Radius",
+ description="Radius from the origin to the"
+ " center of the cross section",
min=0.01,
max=100.0,
- default=1.0)
- minor_radius = FloatProperty(name="Minor Radius",
+ default=1.0
+ )
+ minor_radius = FloatProperty(
+ name="Minor Radius",
description="Radius of the torus' cross section",
min=0.01,
max=100.0,
- default=0.25)
- major_segments = IntProperty(name="Major Segments",
+ default=0.25
+ )
+ major_segments = IntProperty(
+ name="Major Segments",
description="Number of segments for the main ring of the torus",
min=3,
max=256,
- default=48)
- minor_segments = IntProperty(name="Minor Segments",
+ default=48
+ )
+ minor_segments = IntProperty(
+ name="Minor Segments",
description="Number of segments for the minor ring of the torus",
min=3,
max=256,
- default=12)
- twists = IntProperty(name="Twists",
+ default=12
+ )
+ twists = IntProperty(
+ name="Twists",
description="Number of twists of the torus",
min=0,
max=256,
- default=1)
-
- use_abso = BoolProperty(name="Use Int/Ext Controls",
+ default=1
+ )
+ use_abso = BoolProperty(
+ name="Use Int/Ext Controls",
description="Use the Int/Ext controls for torus dimensions",
- default=False)
- abso_major_rad = FloatProperty(name="Exterior Radius",
+ default=False
+ )
+ abso_major_rad = FloatProperty(
+ name="Exterior Radius",
description="Total Exterior Radius of the torus",
min=0.01,
max=100.0,
- default=1.0)
- abso_minor_rad = FloatProperty(name="Inside Radius",
+ default=1.0
+ )
+ abso_minor_rad = FloatProperty(
+ name="Inside Radius",
description="Total Interior Radius of the torus",
min=0.01,
max=100.0,
- default=0.5)
+ default=0.5
+ )
def execute(self, context):
- if self.use_abso == True:
+ if self.use_abso is True:
extra_helper = (self.abso_major_rad - self.abso_minor_rad) * 0.5
self.major_radius = self.abso_minor_rad + extra_helper
self.minor_radius = extra_helper
@@ -184,9 +207,10 @@ class AddTwistedTorus(bpy.types.Operator):
self.minor_radius,
self.major_segments,
self.minor_segments,
- self.twists)
+ self.twists
+ )
- # Actually create the mesh object from this geometry data.
+ # Create the mesh object from this geometry data.
obj = create_mesh_object(context, verts, [], faces, "TwistedTorus")
return {'FINISHED'}
diff --git a/add_mesh_extra_objects/add_mesh_vertex.py b/add_mesh_extra_objects/add_mesh_vertex.py
index 10c86657..eac3d742 100644
--- a/add_mesh_extra_objects/add_mesh_vertex.py
+++ b/add_mesh_extra_objects/add_mesh_vertex.py
@@ -1,12 +1,7 @@
# GPL # Originals by meta-androcto, Pablo Vazquez, Liero, Richard Wilks
import bpy
-import bmesh
-from bpy.props import StringProperty, FloatProperty, BoolProperty, FloatVectorProperty
-
- # add the mesh as an object into the scene with this utility module
-from bpy_extras import object_utils
-
+from bpy.types import Operator
def object_origin(width, height, depth):
@@ -14,10 +9,7 @@ def object_origin(width, height, depth):
This function takes inputs and returns vertex and face arrays.
no actual mesh data creation is done here.
"""
-
- verts = [(+0.0, +0.0, +0.0)
- ]
-
+ verts = [(+0.0, +0.0, +0.0)]
faces = []
# apply size
@@ -26,42 +18,45 @@ def object_origin(width, height, depth):
return verts, faces
-class AddVert(bpy.types.Operator):
- '''Add a Single Vertice to Edit Mode'''
+
+class AddVert(Operator):
bl_idname = "mesh.primitive_vert_add"
bl_label = "Single Vert"
+ bl_description = "Add a Single Vertice to Edit Mode"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
mesh = bpy.data.meshes.new("Vert")
mesh.vertices.add(1)
-
+
from bpy_extras import object_utils
object_utils.object_data_add(context, mesh, operator=None)
- bpy.ops.object.mode_set(mode = 'EDIT')
+ bpy.ops.object.mode_set(mode='EDIT')
return {'FINISHED'}
-class AddEmptyVert(bpy.types.Operator):
- '''Add an Object Origin to Edit Mode'''
+
+class AddEmptyVert(Operator):
bl_idname = "mesh.primitive_emptyvert_add"
bl_label = "Empty Object Origin"
+ bl_description = "Add an Object Origin to Edit Mode"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
mesh = bpy.data.meshes.new("Vert")
mesh.vertices.add(1)
-
+
from bpy_extras import object_utils
object_utils.object_data_add(context, mesh, operator=None)
- bpy.ops.object.mode_set(mode = 'EDIT')
+ bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.delete(type='VERT')
return {'FINISHED'}
+
def Add_Symmetrical_Empty():
- bpy.ops.mesh.primitive_plane_add(enter_editmode = True)
+ bpy.ops.mesh.primitive_plane_add(enter_editmode=True)
sempty = bpy.context.object
sempty.name = "SymmEmpty"
@@ -70,16 +65,17 @@ def Add_Symmetrical_Empty():
if (sempty.modifiers and sempty.modifiers['Mirror']):
pass
else:
- bpy.ops.object.modifier_add(type ='MIRROR')
+ bpy.ops.object.modifier_add(type='MIRROR')
# Delete all!
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.mesh.select_all(action='TOGGLE')
- bpy.ops.mesh.delete(type ='VERT')
+ bpy.ops.mesh.delete(type='VERT')
+
def Add_Symmetrical_Vert():
- bpy.ops.mesh.primitive_plane_add(enter_editmode = True)
+ bpy.ops.mesh.primitive_plane_add(enter_editmode=True)
sempty = bpy.context.object
sempty.name = "SymmVert"
@@ -88,15 +84,15 @@ def Add_Symmetrical_Vert():
if (sempty.modifiers and sempty.modifiers['Mirror']):
pass
else:
- bpy.ops.object.modifier_add(type ='MIRROR')
+ bpy.ops.object.modifier_add(type='MIRROR')
# Delete all!
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.mesh.merge(type='CENTER')
-class AddSymmetricalEmpty(bpy.types.Operator):
+class AddSymmetricalEmpty(Operator):
bl_idname = "mesh.primitive_symmetrical_empty_add"
bl_label = "Add Symmetrical Object Origin"
bl_description = "Object Origin with a Mirror Modifier for symmetrical modeling"
@@ -106,7 +102,7 @@ class AddSymmetricalEmpty(bpy.types.Operator):
layout = self.layout
mirror = bpy.context.object.modifiers['Mirror']
- layout.prop(mirror,'use_clip', text="Use Clipping")
+ layout.prop(mirror, "use_clip", text="Use Clipping")
layout.label("Mirror Axis")
row = layout.row(align=True)
@@ -116,10 +112,11 @@ class AddSymmetricalEmpty(bpy.types.Operator):
def execute(self, context):
Add_Symmetrical_Empty()
+
return {'FINISHED'}
-class AddSymmetricalVert(bpy.types.Operator):
+class AddSymmetricalVert(Operator):
bl_idname = "mesh.primitive_symmetrical_vert_add"
bl_label = "Add Symmetrical Origin & Vert"
bl_description = "Object Origin with a Mirror Modifier for symmetrical modeling"
@@ -129,7 +126,7 @@ class AddSymmetricalVert(bpy.types.Operator):
layout = self.layout
mirror = bpy.context.object.modifiers['Mirror']
- layout.prop(mirror,'use_clip', text="Use Clipping")
+ layout.prop(mirror, "use_clip", text="Use Clipping")
layout.label("Mirror Axis")
row = layout.row(align=True)
@@ -139,4 +136,5 @@ class AddSymmetricalVert(bpy.types.Operator):
def execute(self, context):
Add_Symmetrical_Vert()
+
return {'FINISHED'}
diff --git a/add_mesh_extra_objects/geodesic_domes/__init__.py b/add_mesh_extra_objects/geodesic_domes/__init__.py
index 711de18e..aa2e509a 100644
--- a/add_mesh_extra_objects/geodesic_domes/__init__.py
+++ b/add_mesh_extra_objects/geodesic_domes/__init__.py
@@ -38,12 +38,13 @@ else:
import bpy
from bpy.props import *
+
def register():
bpy.utils.register_module(__name__)
+
def unregister():
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()
-
diff --git a/add_mesh_extra_objects/geodesic_domes/add_shape_geodesic.py b/add_mesh_extra_objects/geodesic_domes/add_shape_geodesic.py
index 879f6fa1..36b11ae5 100644
--- a/add_mesh_extra_objects/geodesic_domes/add_shape_geodesic.py
+++ b/add_mesh_extra_objects/geodesic_domes/add_shape_geodesic.py
@@ -1,16 +1,18 @@
import bpy
import mathutils
+
def reset_transform(ob):
m = mathutils.Matrix()
ob.matrix_local = m
+
def func_add_corrective_pose_shape_fast(source, target):
result = ""
reset_transform(target)
# If target object doesn't have Basis shape key, create it.
try:
- num_keys = len( target.data.shape_keys.key_blocks )
+ num_keys = len(target.data.shape_keys.key_blocks)
except:
basis = target.shape_key_add()
basis.name = "Basis"
@@ -21,11 +23,11 @@ def func_add_corrective_pose_shape_fast(source, target):
new_shapekey = target.shape_key_add()
new_shapekey.name = "Shape_" + source.name
new_shapekey_name = new_shapekey.name
- key_index = len(target.data.shape_keys.key_blocks)-1
+ key_index = len(target.data.shape_keys.key_blocks) - 1
target.active_shape_key_index = key_index
# else, the active shape will be used (updated)
target.show_only_shape_key = True
- shape_key_verts = target.data.shape_keys.key_blocks[ key_index ].data
+ shape_key_verts = target.data.shape_keys.key_blocks[key_index].data
try:
vgroup = target.active_shape_key.vertex_group
target.active_shape_key.vertex_group = ''
@@ -36,20 +38,20 @@ def func_add_corrective_pose_shape_fast(source, target):
# copy the local vertex positions to the new shape
verts = source.data.vertices
try:
- for n in range( len(verts)):
+ for n in range(len(verts)):
shape_key_verts[n].co = verts[n].co
- # go to all armature modifies and unpose the shape
+ # go to all armature modifies and unpose the shape
except:
message = "***ERROR***, meshes have different number of vertices"
- result = message
+ result = message
for n in target.modifiers:
if n.type == 'ARMATURE' and n.show_viewport:
- #~ print("got one")
+ # print("got one")
n.use_bone_envelopes = False
n.use_deform_preserve_volume = False
n.use_vertex_groups = True
armature = n.object
- unposeMesh( shape_key_verts, target, armature)
+ unposeMesh(shape_key_verts, target, armature)
break
# set the new shape key value to 1.0, so we see the result instantly
@@ -58,20 +60,21 @@ def func_add_corrective_pose_shape_fast(source, target):
target.active_shape_key.vertex_group = vgroup
except:
print("bluba")
- result = result + "bluba"
+ result = result + "bluba"
pass
target.show_only_shape_key = False
target.data.update()
return result
+
class add_corrective_pose_shape_fast(bpy.types.Operator):
- '''Adds 1st object as shape to 2nd object as pose shape (only 1 armature)'''
bl_idname = "object.add_corrective_pose_shape_fast"
bl_label = "Add object as corrective shape faster"
+ bl_description = "Adds 1st object as shape to 2nd object as pose shape (only 1 armature)"
@classmethod
def poll(cls, context):
- return context.active_object != None
+ return context.active_object is not None
def execute(self, context):
@@ -87,12 +90,15 @@ class add_corrective_pose_shape_fast(bpy.types.Operator):
source = selection[0]
print(source)
print(target)
- func_add_corrective_pose_shape_fast( source, target)
+ func_add_corrective_pose_shape_fast(source, target)
+
return {'FINISHED'}
+
def register():
bpy.utils.register_module(__name__)
+
def unregister():
bpy.utils.unregister_module(__name__)
diff --git a/add_mesh_extra_objects/geodesic_domes/forms_271.py b/add_mesh_extra_objects/geodesic_domes/forms_271.py
index d3e46dca..f4dd5119 100644
--- a/add_mesh_extra_objects/geodesic_domes/forms_271.py
+++ b/add_mesh_extra_objects/geodesic_domes/forms_271.py
@@ -1,8 +1,9 @@
-import math
-from math import sin, cos
+from math import sin, cos, sqrt
from .vefm_271 import *
+
+
class form(mesh):
- def __init__(self, uresolution, vresolution, uscale, vscale, upart,\
+ def __init__(self, uresolution, vresolution, uscale, vscale, upart,
vpart, uphase, vphase, utwist, vtwist, xscale, yscale, sform):
mesh.__init__(self)
@@ -24,11 +25,11 @@ class form(mesh):
self.yscale = yscale
self.sform = sform
- if self.upart != 1.0: ## there is a gap in the major radius
+ if self.upart != 1.0: # there is a gap in the major radius
self.uflag = 1
else:
self.uflag = 0
- if self.vpart != 1.0: ## there is a gap in the minor radius
+ if self.vpart != 1.0: # there is a gap in the minor radius
self.vflag = 1
else:
self.vflag = 0
@@ -50,25 +51,25 @@ class form(mesh):
self.yscaleflag = 1
else:
self.yscaleflag = 0
- self.rowlist=[]
+ self.rowlist = []
def generatepoints(self):
for i in range(self.ufinish):
- row=[]
+ row = []
for j in range(self.vfinish):
u = self.ustep * i + self.uphase
v = self.vstep * j + self.vphase
if self.sform[12]:
- r1 = self.superform(self.sform[0], self.sform[1], self.sform[2],\
- self.sform[3], self.sform[14] + u, self.sform[4],\
- self.sform[5], self.sform[16] * v)
+ r1 = self.superform(self.sform[0], self.sform[1], self.sform[2],
+ self.sform[3], self.sform[14] + u, self.sform[4],
+ self.sform[5], self.sform[16] * v)
else:
r1 = 1.0
if self.sform[13]:
- r2 = self.superform(self.sform[6], self.sform[7], self.sform[8],\
- self.sform[9], self.sform[15] + v, self.sform[10],\
- self.sform[11], self.sform[17] * v)
+ r2 = self.superform(self.sform[6], self.sform[7], self.sform[8],
+ self.sform[9], self.sform[15] + v, self.sform[10],
+ self.sform[11], self.sform[17] * v)
else:
r2 = 1.0
x, y, z = self.formula(u, v, r1, r2)
@@ -82,7 +83,7 @@ class form(mesh):
else:
for i in range(len(self.rowlist)):
self.rowlist[i].append(self.rowlist[i][0])
- if self.uflag:
+ if self.uflag:
pass
else:
self.rowlist.append(self.rowlist[0])
@@ -113,17 +114,19 @@ class form(mesh):
edge4 = edge(b, c)
self.edges.append(edge4)
+
class grid(form):
- def __init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,\
+ def __init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,
uphase, vphase, utwist, vtwist, xscale, yscale, sform):
- form.__init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,\
- uphase, vphase, utwist, vtwist, xscale, yscale, sform)
+ form.__init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,
+ uphase, vphase, utwist, vtwist, xscale, yscale, sform)
unit = 1.0 / self.a360
- if self.ures == 1 :
- print("\n***ERRORin forms_271.grid L121***, ures is 1, changed into 2\n\n")
+
+ if self.ures == 1:
+ print("\n***ERRORin forms_271.grid L126***, ures is 1, changed into 2\n\n")
self.ures = 2
- if self.vres == 1 :
- print("\n***ERROR in grid forms_271.grid L124***, vres is 1, changed into 2\n\n")
+ if self.vres == 1:
+ print("\n***ERROR in grid forms_271.grid L129***, vres is 1, changed into 2\n\n")
self.vres = 2
self.ustep = self.a360 / (self.ures - 1)
self.vstep = self.a360 / (self.vres - 1)
@@ -152,9 +155,9 @@ class grid(form):
class cylinder(form):
- def __init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,\
+ def __init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,
uphase, vphase, utwist, vtwist, xscale, yscale, sform):
- form.__init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,\
+ form.__init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,
uphase, vphase, utwist, vtwist, xscale, yscale, sform)
unit = 1.0 / self.a360
self.vshift = self.vscale * 0.5
@@ -172,10 +175,11 @@ class cylinder(form):
z = v * self.vexpand - self.vshift
return x, y, z
+
class parabola(form):
- def __init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,\
+ def __init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,
uphase, vphase, utwist, vtwist, xscale, yscale, sform):
- form.__init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,\
+ form.__init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,
uphase, vphase, utwist, vtwist, xscale, yscale, sform)
unit = 1.0 / self.a360
self.vshift = self.vscale * 0.5
@@ -194,10 +198,11 @@ class parabola(form):
z = - v * self.vexpand + self.vshift
return x, y, z
+
class torus(form):
- def __init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,\
+ def __init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,
uphase, vphase, utwist, vtwist, xscale, yscale, sform):
- form.__init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,\
+ form.__init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,
uphase, vphase, utwist, vtwist, xscale, yscale, sform)
self.generatepoints()
self.generatefaces()
@@ -211,11 +216,12 @@ class torus(form):
x = (self.vscale + self.uscale * cos(v)) * sin(u) * r1 * r2 * self.xscale
return x, y, z
+
class sphere(form):
- def __init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,\
+ def __init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,
uphase, vphase, utwist, vtwist, xscale, yscale, sform):
- form.__init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,\
- uphase,vphase,utwist,vtwist,xscale,yscale,sform)
+ form.__init__(self, uresolution, vresolution, uscale, vscale, upart, vpart,
+ uphase, vphase, utwist, vtwist, xscale, yscale, sform)
self.vstep = (self.a360 / (self.vres - 1)) * self.vpart
self.vflag = 1
self.generatepoints()
diff --git a/add_mesh_extra_objects/geodesic_domes/geodesic_classes_271.py b/add_mesh_extra_objects/geodesic_domes/geodesic_classes_271.py
index 985dcccd..6f54bff7 100644
--- a/add_mesh_extra_objects/geodesic_domes/geodesic_classes_271.py
+++ b/add_mesh_extra_objects/geodesic_domes/geodesic_classes_271.py
@@ -1,22 +1,21 @@
-
from .vefm_271 import mesh, vertex, edge, face
+from math import pi, acos, sin, cos, atan, tan, fabs, sqrt
-import math
-from math import pi,acos,sin,cos,atan,tan,fabs, sqrt
-def check_contains(cl,name , print_value = False):
+def check_contains(cl, name, print_value=False):
dir_class = dir(cl)
for el in dir_class:
if el.startswith("_"):
pass
else:
if print_value:
- tmp = getattr(cl,el)
- print(name , " contains ==>",el," value = ", tmp)
+ tmp = getattr(cl, el)
+ print(name, " contains ==>", el, " value = ", tmp)
else:
- print(name , " contains ==>",el)
+ print(name, " contains ==>", el)
print("\ncheck_contains finished\n\n")
+
class geodesic(mesh):
def __init__(self):
@@ -25,9 +24,9 @@ class geodesic(mesh):
self.panels = []
self.vertsdone = []
- self.skeleton = [] # List of verts in the full skeleton edges.
- self.vertskeleton = [] # config needs this member
- self.edgeskeleton = [] # config needs this member
+ self.skeleton = [] # List of verts in the full skeleton edges.
+ self.vertskeleton = [] # config needs this member
+ self.edgeskeleton = [] # config needs this member
self.sphericalverts = []
self.a45 = pi * 0.25
self.a90 = pi * 0.5
@@ -35,7 +34,7 @@ class geodesic(mesh):
self.a270 = pi * 1.5
self.a360 = pi * 2
# define members here
- # setparams needs:
+ # setparams needs:
self.frequency = None
self.eccentricity = None
self.squish = None
@@ -53,7 +52,7 @@ class geodesic(mesh):
self.sform = None
self.super = None
self.odd = None
- #config needs
+ # config needs
self.panelpoints = None
self.paneledges = None
self.reversepanel = None
@@ -61,45 +60,45 @@ class geodesic(mesh):
self.vertsdone = None
self.panels = []
- def setparameters(self,params):
+ def setparameters(self, params):
parameters = self.PKHG_parameters = params
- self.frequency = parameters[0] ## How many subdivisions - up to 20.
- self.eccentricity = parameters[1] ## Elliptical if >1.0.
- self.squish = parameters[2] ## Flattened if < 1.0.
- self.radius = parameters[3] ## Exactly what it says.
- self.square = parameters[4] ## Controls amount of superellipse in X/Y plane.
- self.squarez = parameters[5] ## Controls amount of superellipse in Z dimension.
- self.cart = parameters[6] ## Cuts out sphericalisation step.
- self.shape = parameters[7] ## Full sphere, dome, flatbase.
- self.baselevel = parameters[8] ## Where the base is cut on a flatbase dome.
- self.faceshape = parameters[9] ## Triangular, hexagonal, tri-hex.
+ self.frequency = parameters[0] # How many subdivisions - up to 20.
+ self.eccentricity = parameters[1] # Elliptical if >1.0.
+ self.squish = parameters[2] # Flattened if < 1.0.
+ self.radius = parameters[3] # Exactly what it says.
+ self.square = parameters[4] # Controls amount of superellipse in X/Y plane.
+ self.squarez = parameters[5] # Controls amount of superellipse in Z dimension.
+ self.cart = parameters[6] # Cuts out sphericalisation step.
+ self.shape = parameters[7] # Full sphere, dome, flatbase.
+ self.baselevel = parameters[8] # Where the base is cut on a flatbase dome.
+ self.faceshape = parameters[9] # Triangular, hexagonal, tri-hex.
self.dualflag = parameters[10]
self.rotxy = parameters[11]
self.rotz = parameters[12]
self.klass = parameters[13]
self.sform = parameters[14]
- self.super = 0 ## Toggles superellipse.
+ self.super = 0 # Toggles superellipse.
if self.square != 2.0 or self.squarez != 2.0:
self.super = 1
- self.odd = 0 ## Is the frequency odd. It matters for dome building.
+ self.odd = 0 # Is the frequency odd. It matters for dome building.
if self.frequency % 2 != 0:
self.odd = 1
def makegeodesic(self):
- self.vertedgefacedata() #PKHG only a pass 13okt11
- self.config() ## Generate all the configuration information.
+ self.vertedgefacedata() # PKHG only a pass 13okt11
+ self.config() # Generate all the configuration information.
if self.klass:
self.class2()
if self.faceshape == 1:
- self.hexify() ## Hexagonal faces
+ self.hexify() # Hexagonal faces
elif self.faceshape == 2:
- self.starify() ## Hex and Triangle faces
+ self.starify() # Hex and Triangle faces
if self.dualflag:
self.dual()
if not self.cart:
- self.sphericalize() ## Convert x,y,z positions into spherical u,v.
- self.sphere2cartesian() ## Convert spherical uv back into cartesian x,y,z for final shape.
- for i in range(len( self.verts)):
+ self.sphericalize() # Convert x,y,z positions into spherical u,v.
+ self.sphere2cartesian() # Convert spherical uv back into cartesian x,y,z for final shape.
+ for i in range(len(self.verts)):
self.verts[i].index = i
for edg in self.edges:
edg.findvect()
@@ -111,20 +110,20 @@ class geodesic(mesh):
for i in range(len(self.vertskeleton)):
self.vertskeleton[i].index = i
for edges in self.edgeskeleton:
- s = skeletonrow(self.frequency, edges, 0, self) #self a geodesic
+ s = skeletonrow(self.frequency, edges, 0, self) # self a geodesic
self.skeleton.append(s)
- for i in range(len( self.verts)):
+ for i in range(len(self.verts)):
self.verts[i].index = i
for i in range(len(self.panelpoints)):
a = self.vertsdone[self.panelpoints[i][0]][1]
b = self.vertsdone[self.panelpoints[i][1]][1]
c = self.vertsdone[self.panelpoints[i][2]][1]
- panpoints = [ self.verts[a],
+ panpoints = [self.verts[a],
self.verts[b],
self.verts[c]]
- panedges = [ self.skeleton[self.paneledges[i][0]],
+ panedges = [self.skeleton[self.paneledges[i][0]],
self.skeleton[self.paneledges[i][1]],
- self.skeleton[self.paneledges[i][2]] ]
+ self.skeleton[self.paneledges[i][2]]]
reverseflag = 0
for flag in self.reversepanel:
if flag == i:
@@ -140,9 +139,9 @@ class geodesic(mesh):
y = vert.vector.y
z = vert.vector.z
- u = self.usphericalise(x,y,z)
- v = self.vsphericalise(x,y,z)
- self.sphericalverts.append([u,v])
+ u = self.usphericalise(x, y, z)
+ v = self.vsphericalise(x, y, z)
+ self.sphericalverts.append([u, v])
def sphere2cartesian(self):
for i in range(len(self.verts)):
@@ -154,69 +153,69 @@ class geodesic(mesh):
else:
u = self.sphericalverts[i][0]
v = self.sphericalverts[i][1]
- if self.squish != 1.0 or self.eccentricity>1.0:
+ if self.squish != 1.0 or self.eccentricity > 1.0:
scalez = 1 / self.squish
- v = self.ellipsecomp(scalez,v)
- u = self.ellipsecomp(self.eccentricity,u)
+ v = self.ellipsecomp(scalez, v)
+ u = self.ellipsecomp(self.eccentricity, u)
if self.super:
- r1 = self.superell(self.square,u,self.rotxy)
- r2 = self.superell(self.squarez,v,self.rotz)
+ r1 = self.superell(self.square, u, self.rotxy)
+ r2 = self.superell(self.squarez, v, self.rotz)
else:
r1 = 1.0
r2 = 1.0
if self.sform[12]:
- r1 = r1 * self.superform(self.sform[0],self.sform[1],\
- self.sform[2],self.sform[3],\
- self.sform[14] + u,self.sform[4],\
- self.sform[5],self.sform[16] * v)
+ r1 = r1 * self.superform(self.sform[0], self.sform[1],
+ self.sform[2], self.sform[3],
+ self.sform[14] + u, self.sform[4],
+ self.sform[5], self.sform[16] * v)
if self.sform[13]:
- r2 = r2 * self.superform(self.sform[6],self.sform[7],\
- self.sform[8],self.sform[9],\
- self.sform[15] + v,self.sform[10],\
- self.sform[11],self.sform[17] * v)
- x,y,z = self.cartesian(u,v,r1,r2)
+ r2 = r2 * self.superform(self.sform[6], self.sform[7],
+ self.sform[8], self.sform[9],
+ self.sform[15] + v, self.sform[10],
+ self.sform[11], self.sform[17] * v)
+ x, y, z = self.cartesian(u, v, r1, r2)
- self.verts[i] = vertex((x,y,z))
+ self.verts[i] = vertex((x, y, z))
- def usphericalise(self,x,y,z):
+ def usphericalise(self, x, y, z):
if y == 0.0:
- if x>0:
+ if x > 0:
theta = 0.0
else:
theta = self.a180
elif x == 0.0:
- if y>0:
+ if y > 0:
theta = self.a90
else:
theta = self.a270
-
else:
theta = atan(y / x)
+
if x < 0.0 and y < 0.0:
theta = theta + self.a180
- elif x < 0.0 and y>0.0:
+ elif x < 0.0 and y > 0.0:
theta = theta + self.a180
u = theta
return u
- def vsphericalise(self,x,y,z) :
+ def vsphericalise(self, x, y, z):
if z == 0.0:
phi = self.a90
else:
- rho = sqrt(x ** 2 + y**2 + z**2)
+ rho = sqrt(x ** 2 + y ** 2 + z ** 2)
phi = acos(z / rho)
v = phi
return v
- def ellipsecomp(self,efactor,theta):
+ def ellipsecomp(self, efactor, theta):
if theta == self.a90:
result = self.a90
elif theta == self.a270:
result = self.a270
else:
result = atan(tan(theta) / efactor**0.5)
- if result>=0.0:
+ if result >= 0.0:
x = result
y = self.a180 + result
if fabs(x - theta) <= fabs(y - theta):
@@ -236,24 +235,24 @@ class geodesic(mesh):
def cutbasecomp(self):
pass
- def cartesian(self,u,v,r1,r2):
+ def cartesian(self, u, v, r1, r2):
x = r1 * cos(u) * r2 * sin(v) * self.radius * self.eccentricity
y = r1 * sin(u) * r2 * sin(v) * self.radius
z = r2 * cos(v) * self.radius * self.squish
- return x,y,z
+ return x, y, z
class edgerow:
def __init__(self, count, anchor, leftindex, rightindex, stepvector, endflag, parentgeo):
self.points = []
self.edges = []
- ## Make a row of evenly spaced points.
+ # Make a row of evenly spaced points.
for i in range(count + 1):
if i == 0:
self.points.append(leftindex)
elif i == count and not endflag:
self.points.append(rightindex)
- else: #PKHG Vectors added!
+ else: # PKHG Vectors added!
newpoint = anchor + (stepvector * i)
vertcount = len(parentgeo.verts)
self.points.append(vertcount)
@@ -262,17 +261,18 @@ class edgerow:
for i in range(count):
a = parentgeo.verts[self.points[i]]
b = parentgeo.verts[self.points[i + 1]]
- line = edge(a,b)
+ line = edge(a, b)
self.edges.append(len(parentgeo.edges))
parentgeo.edges.append(line)
+
class skeletonrow:
def __init__(self, count, skeletonedge, shortflag, parentgeo):
self.points = []
self.edges = []
self.vect = skeletonedge.vect
self.step = skeletonedge.vect / float(count)
- ## Make a row of evenly spaced points.
+ # Make a row of evenly spaced points.
for i in range(count + 1):
vert1 = skeletonedge.a
vert2 = skeletonedge.b
@@ -284,22 +284,21 @@ class skeletonrow:
vertcount = len(parentgeo.verts)
self.points.append(vertcount)
newpoint.index = vertcount
- parentgeo.vertsdone[vert1.index] = [1,vertcount]
+ parentgeo.vertsdone[vert1.index] = [1, vertcount]
parentgeo.verts.append(newpoint)
elif i == count:
if parentgeo.vertsdone[vert2.index][0]:
self.points.append(parentgeo.vertsdone[vert2.index][1])
else:
-
newpoint = vertex(vert2.vector)
vertcount = len(parentgeo.verts)
self.points.append(vertcount)
newpoint.index = vertcount
- parentgeo.vertsdone[vert2.index] = [1,vertcount]
+ parentgeo.vertsdone[vert2.index] = [1, vertcount]
parentgeo.verts.append(newpoint)
else:
- newpoint = vertex(vert1.vector + (self.step * i)) #must be a vertex!
+ newpoint = vertex(vert1.vector + (self.step * i)) # must be a vertex!
vertcount = len(parentgeo.verts)
self.points.append(vertcount)
newpoint.index = vertcount
@@ -307,32 +306,35 @@ class skeletonrow:
for i in range(count):
a = parentgeo.verts[self.points[i]]
b = parentgeo.verts[self.points[i + 1]]
- line = edge(a,b)
+ line = edge(a, b)
self.edges.append(len(parentgeo.edges))
parentgeo.edges.append(line)
+
class facefill:
def __init__(self, upper, lower, reverseflag, parentgeo, finish):
for i in range(finish):
- a,b,c = upper.points[i],lower.points[i + 1],lower.points[i]
+ a, b, c = upper.points[i], lower.points[i + 1], lower.points[i]
if reverseflag:
- upface = face([parentgeo.verts[a],parentgeo.verts[c],parentgeo.verts[b]])
+ upface = face([parentgeo.verts[a], parentgeo.verts[c], parentgeo.verts[b]])
else:
- upface = face([parentgeo.verts[a],parentgeo.verts[b],parentgeo.verts[c]])
+ upface = face([parentgeo.verts[a], parentgeo.verts[b], parentgeo.verts[c]])
parentgeo.faces.append(upface)
if i == finish - 1:
pass
else:
d = upper.points[i + 1]
if reverseflag:
- downface = face([parentgeo.verts[b],parentgeo.verts[d],parentgeo.verts[a]])
+ downface = face([parentgeo.verts[b], parentgeo.verts[d], parentgeo.verts[a]])
else:
- downface = face([parentgeo.verts[b],parentgeo.verts[a],parentgeo.verts[d]])
- line = edge(parentgeo.verts[a],parentgeo.verts[b])
- line2 = edge(parentgeo.verts[d],parentgeo.verts[b])
+ downface = face([parentgeo.verts[b], parentgeo.verts[a], parentgeo.verts[d]])
+ line = edge(parentgeo.verts[a], parentgeo.verts[b])
+ line2 = edge(parentgeo.verts[d], parentgeo.verts[b])
parentgeo.faces.append(downface)
parentgeo.edges.append(line)
parentgeo.edges.append(line2)
+
+
class panel:
def __init__(self, points, edges, reverseflag, parentgeo):
self.cardinal = points[0]
@@ -341,12 +343,12 @@ class panel:
self.leftedge = edges[0]
self.rightedge = edges[1]
self.baseedge = edges[2]
- self.rows=[]
- self.orient(parentgeo,edges)
+ self.rows = []
+ self.orient(parentgeo, edges)
self.createrows(parentgeo)
- self.createfaces(parentgeo,reverseflag)
+ self.createfaces(parentgeo, reverseflag)
- def orient(self,parentgeo,edges):
+ def orient(self, parentgeo, edges):
if self.leftedge.points[0] != self.cardinal.index:
self.leftedge.points.reverse()
self.leftedge.vect.negative()
@@ -365,377 +367,438 @@ class panel:
if i == parentgeo.frequency:
newrow = self.baseedge
else:
- newrow = edgerow(i, parentgeo.verts[self.leftedge.points[i]], self.leftedge.points[i], self.rightedge.points[i], self.baseedge.step, 0, parentgeo )
+ newrow = edgerow(i, parentgeo.verts[self.leftedge.points[i]], self.leftedge.points[i],
+ self.rightedge.points[i], self.baseedge.step, 0, parentgeo)
self.rows.append(newrow)
- def createfaces(self, parentgeo,reverseflag):
+ def createfaces(self, parentgeo, reverseflag):
for i in range(len(self.leftedge.points) - 1):
facefill(self.rows[i], self.rows[i + 1], reverseflag, parentgeo, len(self.rows[i].points))
-#for point on top? YES!
-class tetrahedron(geodesic,mesh):
- def __init__(self,parameter):
+
+# for point on top? YES!
+class tetrahedron(geodesic, mesh):
+ def __init__(self, parameter):
geodesic.__init__(mesh)
- geodesic.setparameters(self,parameter)
+ geodesic.setparameters(self, parameter)
self.set_vert_edge_skeleons()
def set_vert_edge_skeleons(self):
- self.vertskeleton=[ vertex(( 0.0 , 0.0 , 1.73205080757 )),
- vertex(( 0.0 , -1.63299316185 , -0.577350269185 )),
- vertex(( 1.41421356237 , 0.816496580927 , -0.57735026919 )),
- vertex(( -1.41421356237 , 0.816496580927 , -0.57735026919 )) ]
- self.edgeskeleton=[ edge(self.vertskeleton[0],self.vertskeleton[1]),
- edge(self.vertskeleton[0],self.vertskeleton[2]),
- edge(self.vertskeleton[0],self.vertskeleton[3]),
- edge(self.vertskeleton[1],self.vertskeleton[2]),
- edge(self.vertskeleton[2],self.vertskeleton[3]),
- edge(self.vertskeleton[1],self.vertskeleton[3]) ]
-
- self.panelpoints=[[0,1,2],[0,2,3],[0,1,3],[1,2,3]]
- self.paneledges=[[0,1,3],[1,2,4],[0,2,5],[3,5,4]]
- self.reversepanel=[2,3]
- self.edgelength=[]
- self.vertsdone=[[0,0]] * len(self.vertskeleton)
-
-#for edge on top? YES
+ self.vertskeleton = [vertex((0.0, 0.0, 1.73205080757)),
+ vertex((0.0, -1.63299316185, -0.577350269185)),
+ vertex((1.41421356237, 0.816496580927, -0.57735026919)),
+ vertex((-1.41421356237, 0.816496580927, -0.57735026919))]
+
+ self.edgeskeleton = [edge(self.vertskeleton[0], self.vertskeleton[1]),
+ edge(self.vertskeleton[0], self.vertskeleton[2]),
+ edge(self.vertskeleton[0], self.vertskeleton[3]),
+ edge(self.vertskeleton[1], self.vertskeleton[2]),
+ edge(self.vertskeleton[2], self.vertskeleton[3]),
+ edge(self.vertskeleton[1], self.vertskeleton[3])]
+
+ self.panelpoints = [[0, 1, 2], [0, 2, 3], [0, 1, 3], [1, 2, 3]]
+ self.paneledges = [[0, 1, 3], [1, 2, 4], [0, 2, 5], [3, 5, 4]]
+ self.reversepanel = [2, 3]
+ self.edgelength = []
+ self.vertsdone = [[0, 0]] * len(self.vertskeleton)
+
+
+# for edge on top? YES
class tetraedge(geodesic):
- def __init__(self,parameter):
+ def __init__(self, parameter):
geodesic.__init__(mesh)
- geodesic.setparameters(self,parameter)
+ geodesic.setparameters(self, parameter)
self.set_vert_edge_skeleons()
def set_vert_edge_skeleons(self):
- self.vertskeleton=[ vertex(( 0.0 , -1.41421356237 , 1.0 )),
- vertex(( 0.0 , 1.41421356237 , 1.0 )),
- vertex(( 1.41421356237 , 0.0 , -1.0 )),
- vertex(( -1.41421356237 , 0.0 , -1.0 )) ]
- self.edgeskeleton=[ edge(self.vertskeleton[0],self.vertskeleton[1]),
- edge(self.vertskeleton[0],self.vertskeleton[2]),
- edge(self.vertskeleton[0],self.vertskeleton[3]),
- edge(self.vertskeleton[1],self.vertskeleton[3]),
- edge(self.vertskeleton[1],self.vertskeleton[2]),
- edge(self.vertskeleton[2],self.vertskeleton[3]) ]
+ self.vertskeleton = [vertex((0.0, -1.41421356237, 1.0)),
+ vertex((0.0, 1.41421356237, 1.0)),
+ vertex((1.41421356237, 0.0, -1.0)),
+ vertex((-1.41421356237, 0.0, -1.0))]
+
+ self.edgeskeleton = [edge(self.vertskeleton[0], self.vertskeleton[1]),
+ edge(self.vertskeleton[0], self.vertskeleton[2]),
+ edge(self.vertskeleton[0], self.vertskeleton[3]),
+ edge(self.vertskeleton[1], self.vertskeleton[3]),
+ edge(self.vertskeleton[1], self.vertskeleton[2]),
+ edge(self.vertskeleton[2], self.vertskeleton[3])]
+
for i in range(len(self.vertskeleton)):
self.vertskeleton[i].index = i
- self.panelpoints=[[0,1,2],[1,2,3],[0,1,3],[0,2,3]]
- self.paneledges=[[0,1,4],[4,3,5],[0,2,3],[1,2,5]]
- self.reversepanel=[0,3]
- self.edgelength=[]
- self.vertsdone=[[0,0]] * len(self.vertskeleton)
-#for face on top? YES
+ self.panelpoints = [[0, 1, 2], [1, 2, 3], [0, 1, 3], [0, 2, 3]]
+ self.paneledges = [[0, 1, 4], [4, 3, 5], [0, 2, 3], [1, 2, 5]]
+ self.reversepanel = [0, 3]
+ self.edgelength = []
+ self.vertsdone = [[0, 0]] * len(self.vertskeleton)
+
+
+# for face on top? YES
class tetraface(geodesic):
- def __init__(self,parameter):
+ def __init__(self, parameter):
geodesic.__init__(mesh)
- geodesic.setparameters(self,parameter)
+ geodesic.setparameters(self, parameter)
self.set_vert_edge_skeleons()
def set_vert_edge_skeleons(self):
- self.vertskeleton=[ vertex(( -1.41421356237 , -0.816496580927 , 0.57735026919 )),
- vertex(( 1.41421356237 , -0.816496580927 , 0.57735026919 )),
- vertex(( 0.0 , 1.63299316185 , 0.577350269185 )),
- vertex(( 0.0 , 0.0 , -1.73205080757 )) ]
- self.edgeskeleton=[ edge(self.vertskeleton[0],self.vertskeleton[1]),
- edge(self.vertskeleton[2],self.vertskeleton[1]),
- edge(self.vertskeleton[2],self.vertskeleton[0]),
- edge(self.vertskeleton[0],self.vertskeleton[3]),
- edge(self.vertskeleton[1],self.vertskeleton[3]),
- edge(self.vertskeleton[2],self.vertskeleton[3]) ]
- self.panelpoints=[[2,0,1],[0,1,3],[2,1,3],[2,0,3]]
- self.paneledges=[[2,1,0],[0,3,4],[1,5,4],[2,5,3]]
- self.reversepanel=[1,3]
- self.edgelength=[]
- self.vertsdone=[[0,0]] * len(self.vertskeleton)
+ self.vertskeleton = [vertex((-1.41421356237, -0.816496580927, 0.57735026919)),
+ vertex((1.41421356237, -0.816496580927, 0.57735026919)),
+ vertex((0.0, 1.63299316185, 0.577350269185)),
+ vertex((0.0, 0.0, -1.73205080757))]
+
+ self.edgeskeleton = [edge(self.vertskeleton[0], self.vertskeleton[1]),
+ edge(self.vertskeleton[2], self.vertskeleton[1]),
+ edge(self.vertskeleton[2], self.vertskeleton[0]),
+ edge(self.vertskeleton[0], self.vertskeleton[3]),
+ edge(self.vertskeleton[1], self.vertskeleton[3]),
+ edge(self.vertskeleton[2], self.vertskeleton[3])
+ ]
+ self.panelpoints = [[2, 0, 1], [0, 1, 3], [2, 1, 3], [2, 0, 3]]
+
+ self.paneledges = [[2, 1, 0], [0, 3, 4], [1, 5, 4], [2, 5, 3]]
+ self.reversepanel = [1, 3]
+ self.edgelength = []
+ self.vertsdone = [[0, 0]] * len(self.vertskeleton)
+
class octahedron(geodesic):
- def __init__(self,parameter):
+ def __init__(self, parameter):
geodesic.__init__(mesh)
- geodesic.setparameters(self,parameter)
+ geodesic.setparameters(self, parameter)
self.set_vert_edge_skeleons()
def set_vert_edge_skeleons(self):
- self.vertskeleton=[ vertex((0.0,0.0,1.0)),
- vertex((0.0,1.0,0.0)),
- vertex((-1.0,0.0,0.0)),
- vertex((0.0,-1.0,0.0)),
- vertex((1.0,0.0,0.0)),
- vertex((0.0,0.0,-1.0)) ]
+ self.vertskeleton = [vertex((0.0, 0.0, 1.0)),
+ vertex((0.0, 1.0, 0.0)),
+ vertex((-1.0, 0.0, 0.0)),
+ vertex((0.0, -1.0, 0.0)),
+ vertex((1.0, 0.0, 0.0)),
+ vertex((0.0, 0.0, -1.0))]
+
for i in range(len(self.vertskeleton)):
self.vertskeleton[i].index = i
- self.edgeskeleton=[ edge(self.vertskeleton[0],self.vertskeleton[1]),
- edge(self.vertskeleton[0],self.vertskeleton[2]),
- edge(self.vertskeleton[0],self.vertskeleton[3]),
- edge(self.vertskeleton[0],self.vertskeleton[4]),
- edge(self.vertskeleton[1],self.vertskeleton[2]),
- edge(self.vertskeleton[2],self.vertskeleton[3]),
- edge(self.vertskeleton[3],self.vertskeleton[4]),
- edge(self.vertskeleton[4],self.vertskeleton[1]),
- edge(self.vertskeleton[1],self.vertskeleton[5]),
- edge(self.vertskeleton[2],self.vertskeleton[5]),
- edge(self.vertskeleton[3],self.vertskeleton[5]),
- edge(self.vertskeleton[4],self.vertskeleton[5]) ]
- self.panelpoints=[[0,1,2],[0,2,3],[0,3,4],[0,4,1],[1,2,5],[2,3,5],[3,4,5],[4,1,5]]
- self.paneledges=[[0,1,4],[1,2,5],[2,3,6],[3,0,7],[4,8,9],[5,9,10],[6,10,11],[7,11,8]]
- self.reversepanel=[4,5,6,7]
- self.edgelength=[]
- self.vertsdone=[[0,0]] * len(self.vertskeleton)
+ self.edgeskeleton = [edge(self.vertskeleton[0], self.vertskeleton[1]),
+ edge(self.vertskeleton[0], self.vertskeleton[2]),
+ edge(self.vertskeleton[0], self.vertskeleton[3]),
+ edge(self.vertskeleton[0], self.vertskeleton[4]),
+ edge(self.vertskeleton[1], self.vertskeleton[2]),
+ edge(self.vertskeleton[2], self.vertskeleton[3]),
+ edge(self.vertskeleton[3], self.vertskeleton[4]),
+ edge(self.vertskeleton[4], self.vertskeleton[1]),
+ edge(self.vertskeleton[1], self.vertskeleton[5]),
+ edge(self.vertskeleton[2], self.vertskeleton[5]),
+ edge(self.vertskeleton[3], self.vertskeleton[5]),
+ edge(self.vertskeleton[4], self.vertskeleton[5])]
+
+ self.panelpoints = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 1], [1, 2, 5],
+ [2, 3, 5], [3, 4, 5], [4, 1, 5]]
+ self.paneledges = [[0, 1, 4], [1, 2, 5], [2, 3, 6], [3, 0, 7], [4, 8, 9],
+ [5, 9, 10], [6, 10, 11], [7, 11, 8]]
+ self.reversepanel = [4, 5, 6, 7]
+ self.edgelength = []
+ self.vertsdone = [[0, 0]] * len(self.vertskeleton)
+
class octaedge(geodesic):
- def __init__(self,parameter):
+ def __init__(self, parameter):
geodesic.__init__(mesh)
- geodesic.setparameters(self,parameter)
+ geodesic.setparameters(self, parameter)
self.set_vert_edge_skeleons()
def set_vert_edge_skeleons(self):
- self.vertskeleton=[ vertex(( 0.0 , -0.707106781187 , 0.707106781187 )),
- vertex(( 0.0 , 0.707106781187 , 0.707106781187 )),
- vertex(( 1.0 , 0.0 , 0.0 )),
- vertex(( -1.0 , 0.0 , 0.0 )),
- vertex(( 0.0 , -0.707106781187 , -0.707106781187 )),
- vertex(( 0.0 , 0.707106781187 , -0.707106781187 )) ]
- self.edgeskeleton=[ edge(self.vertskeleton[0],self.vertskeleton[1]),
- edge(self.vertskeleton[0],self.vertskeleton[4]),
- edge(self.vertskeleton[0],self.vertskeleton[2]),
- edge(self.vertskeleton[1],self.vertskeleton[2]),
- edge(self.vertskeleton[1],self.vertskeleton[5]),
- edge(self.vertskeleton[1],self.vertskeleton[3]),
- edge(self.vertskeleton[0],self.vertskeleton[3]),
- edge(self.vertskeleton[2],self.vertskeleton[4]),
- edge(self.vertskeleton[2],self.vertskeleton[5]),
- edge(self.vertskeleton[3],self.vertskeleton[5]),
- edge(self.vertskeleton[3],self.vertskeleton[4]),
- edge(self.vertskeleton[4],self.vertskeleton[5]) ]
- self.panelpoints=[[0,1,2],[0,1,3],[0,2,4],[1,2,5],[1,3,5],[0,3,4],[2,4,5],[3,4,5]]
- self.paneledges=[[0,2,3],[0,6,5],[2,1,7],[3,4,8],[5,4,9],[6,1,10],[7,8,11],[10,9,11]]
- self.reversepanel=[0,2,4,7]
- self.edgelength=[]
- self.vertsdone=[[0,0]] * len(self.vertskeleton)
+ self.vertskeleton = [vertex((0.0, -0.707106781187, 0.707106781187)),
+ vertex((0.0, 0.707106781187, 0.707106781187)),
+ vertex((1.0, 0.0, 0.0)),
+ vertex((-1.0, 0.0, 0.0)),
+ vertex((0.0, -0.707106781187, -0.707106781187)),
+ vertex((0.0, 0.707106781187, -0.707106781187))]
+
+ self.edgeskeleton = [edge(self.vertskeleton[0], self.vertskeleton[1]),
+ edge(self.vertskeleton[0], self.vertskeleton[4]),
+ edge(self.vertskeleton[0], self.vertskeleton[2]),
+ edge(self.vertskeleton[1], self.vertskeleton[2]),
+ edge(self.vertskeleton[1], self.vertskeleton[5]),
+ edge(self.vertskeleton[1], self.vertskeleton[3]),
+ edge(self.vertskeleton[0], self.vertskeleton[3]),
+ edge(self.vertskeleton[2], self.vertskeleton[4]),
+ edge(self.vertskeleton[2], self.vertskeleton[5]),
+ edge(self.vertskeleton[3], self.vertskeleton[5]),
+ edge(self.vertskeleton[3], self.vertskeleton[4]),
+ edge(self.vertskeleton[4], self.vertskeleton[5])]
+
+ self.panelpoints = [[0, 1, 2], [0, 1, 3], [0, 2, 4], [1, 2, 5], [1, 3, 5],
+ [0, 3, 4], [2, 4, 5], [3, 4, 5]]
+ self.paneledges = [[0, 2, 3], [0, 6, 5], [2, 1, 7], [3, 4, 8], [5, 4, 9],
+ [6, 1, 10], [7, 8, 11], [10, 9, 11]]
+
+ self.reversepanel = [0, 2, 4, 7]
+ self.edgelength = []
+ self.vertsdone = [[0, 0]] * len(self.vertskeleton)
+
class octaface(geodesic):
- def __init__(self,parameter):
+ def __init__(self, parameter):
geodesic.__init__(mesh)
- geodesic.setparameters(self,parameter)
+ geodesic.setparameters(self, parameter)
self.set_vert_edge_skeleons()
def set_vert_edge_skeleons(self):
- self.vertskeleton=[ vertex(( 0.408248458663 , -0.707106781187 , 0.577350150255 )),
- vertex(( 0.408248458663 , 0.707106781187 , 0.577350150255 )),
- vertex(( -0.816496412728 , 0.0 , 0.577350507059 )),
- vertex(( -0.408248458663 , -0.707106781187 , -0.577350150255 )),
- vertex(( 0.816496412728 , 0.0 , -0.577350507059 )),
- vertex(( -0.408248458663 , 0.707106781187 , -0.577350150255 )) ]
- self.edgeskeleton=[ edge(self.vertskeleton[0],self.vertskeleton[1]),
- edge(self.vertskeleton[2],self.vertskeleton[1]),
- edge(self.vertskeleton[2],self.vertskeleton[0]),
- edge(self.vertskeleton[0],self.vertskeleton[3]),
- edge(self.vertskeleton[0],self.vertskeleton[4]),
- edge(self.vertskeleton[1],self.vertskeleton[4]),
- edge(self.vertskeleton[1],self.vertskeleton[5]),
- edge(self.vertskeleton[2],self.vertskeleton[5]),
- edge(self.vertskeleton[2],self.vertskeleton[3]),
- edge(self.vertskeleton[3],self.vertskeleton[4]),
- edge(self.vertskeleton[4],self.vertskeleton[5]),
- edge(self.vertskeleton[3],self.vertskeleton[5]) ]
- self.panelpoints=[[2,0,1],[0,3,4],[0,1,4],[1,4,5],[2,1,5],[2,3,5],[2,0,3],[3,4,5]]
- self.paneledges=[[2,1,0],[3,4,9],[0,4,5],[5,6,10],[1,7,6],[8,7,11],[2,8,3],[9,11,10]]
- self.reversepanel=[2,5,6,7]
- self.edgelength=[]
- self.vertsdone=[[0,0]] * len(self.vertskeleton)
+ self.vertskeleton = [vertex((0.408248458663, -0.707106781187, 0.577350150255)),
+ vertex((0.408248458663, 0.707106781187, 0.577350150255)),
+ vertex((-0.816496412728, 0.0, 0.577350507059)),
+ vertex((-0.408248458663, -0.707106781187, -0.577350150255)),
+ vertex((0.816496412728, 0.0, -0.577350507059)),
+ vertex((-0.408248458663, 0.707106781187, -0.577350150255))]
+
+ self.edgeskeleton = [edge(self.vertskeleton[0], self.vertskeleton[1]),
+ edge(self.vertskeleton[2], self.vertskeleton[1]),
+ edge(self.vertskeleton[2], self.vertskeleton[0]),
+ edge(self.vertskeleton[0], self.vertskeleton[3]),
+ edge(self.vertskeleton[0], self.vertskeleton[4]),
+ edge(self.vertskeleton[1], self.vertskeleton[4]),
+ edge(self.vertskeleton[1], self.vertskeleton[5]),
+ edge(self.vertskeleton[2], self.vertskeleton[5]),
+ edge(self.vertskeleton[2], self.vertskeleton[3]),
+ edge(self.vertskeleton[3], self.vertskeleton[4]),
+ edge(self.vertskeleton[4], self.vertskeleton[5]),
+ edge(self.vertskeleton[3], self.vertskeleton[5])]
+
+ self.panelpoints = [[2, 0, 1], [0, 3, 4], [0, 1, 4], [1, 4, 5],
+ [2, 1, 5], [2, 3, 5], [2, 0, 3], [3, 4, 5]]
+
+ self.paneledges = [[2, 1, 0], [3, 4, 9], [0, 4, 5], [5, 6, 10],
+ [1, 7, 6], [8, 7, 11], [2, 8, 3], [9, 11, 10]]
+
+ self.reversepanel = [2, 5, 6, 7]
+ self.edgelength = []
+ self.vertsdone = [[0, 0]] * len(self.vertskeleton)
+
class icosahedron(geodesic):
- def __init__(self,parameter):
+ def __init__(self, parameter):
geodesic.__init__(mesh)
- geodesic.setparameters(self,parameter)
+ geodesic.setparameters(self, parameter)
self.set_vert_edge_skeleons()
def set_vert_edge_skeleons(self):
- self.vertskeleton=[ vertex(( 0.0 , 0.0 , 0.587785252292 )),
- vertex(( 0.0 , -0.525731096637 , 0.262865587024 )),
- vertex(( 0.5 , -0.162459832634 , 0.262865565628 )),
- vertex(( 0.309016994375 , 0.425325419658 , 0.262865531009 )),
- vertex(( -0.309016994375 , 0.425325419658 , 0.262865531009 )),
- vertex(( -0.5 , -0.162459832634 , 0.262865565628 )),
- vertex(( 0.309016994375 , -0.425325419658 , -0.262865531009 )),
- vertex(( 0.5 , 0.162459832634 , -0.262865565628 )),
- vertex(( 0.0 , 0.525731096637 , -0.262865587024 )),
- vertex(( -0.5 , 0.162459832634 , -0.262865565628 )),
- vertex(( -0.309016994375 , -0.425325419658 , -0.262865531009 )),
- vertex(( 0.0 , 0.0 , -0.587785252292 )) ]
- self.edgeskeleton=[ edge(self.vertskeleton[0],self.vertskeleton[1]),
- edge(self.vertskeleton[0],self.vertskeleton[2]),
- edge(self.vertskeleton[0],self.vertskeleton[3]),
- edge(self.vertskeleton[0],self.vertskeleton[4]),
- edge(self.vertskeleton[0],self.vertskeleton[5]),
- edge(self.vertskeleton[1],self.vertskeleton[2]),
- edge(self.vertskeleton[2],self.vertskeleton[3]),
- edge(self.vertskeleton[3],self.vertskeleton[4]),
- edge(self.vertskeleton[4],self.vertskeleton[5]),
- edge(self.vertskeleton[5],self.vertskeleton[1]),
- edge(self.vertskeleton[1],self.vertskeleton[6]),
- edge(self.vertskeleton[2],self.vertskeleton[6]),
- edge(self.vertskeleton[2],self.vertskeleton[7]),
- edge(self.vertskeleton[3],self.vertskeleton[7]),
- edge(self.vertskeleton[3],self.vertskeleton[8]),
- edge(self.vertskeleton[4],self.vertskeleton[8]),
- edge(self.vertskeleton[4],self.vertskeleton[9]),
- edge(self.vertskeleton[5],self.vertskeleton[9]),
- edge(self.vertskeleton[5],self.vertskeleton[10]),
- edge(self.vertskeleton[1],self.vertskeleton[10]),
- edge(self.vertskeleton[6],self.vertskeleton[7]),
- edge(self.vertskeleton[7],self.vertskeleton[8]),
- edge(self.vertskeleton[8],self.vertskeleton[9]),
- edge(self.vertskeleton[9],self.vertskeleton[10]),
- edge(self.vertskeleton[10],self.vertskeleton[6]),
- edge(self.vertskeleton[6],self.vertskeleton[11]),
- edge(self.vertskeleton[7],self.vertskeleton[11]),
- edge(self.vertskeleton[8],self.vertskeleton[11]),
- edge(self.vertskeleton[9],self.vertskeleton[11]),
- edge(self.vertskeleton[10],self.vertskeleton[11]) ]
- self.panelpoints=[[0,1,2],[0,2,3],[0,3,4],[0,4,5],[0,5,1],[1,2,6],[2,6,7],[2,3,7],[3,7,8],[3,4,8],[4,8,9],[4,5,9],[5,9,10],[5,1,10],[1,10,6],[6,7,11],[7,8,11],[8,9,11],[9,10,11],[10,6,11]]
- self.paneledges=[[0,1,5],[1,2,6],[2,3,7],[3,4,8],[4,0,9],[5,10,11],[11,12,20],[6,12,13],[13,14,21],[7,14,15],[15,16,22],[8,16,17],[17,18,23],[9,18,19],[19,10,24],[20,25,26],[21,26,27],[22,27,28],[23,28,29],[24,29,25]]
- self.reversepanel=[5,7,9,11,13,15,16,17,18,19]
- self.edgelength=[]
- self.vertsdone=[[0,0]] * len(self.vertskeleton)
+ self.vertskeleton = [vertex((0.0, 0.0, 0.587785252292)),
+ vertex((0.0, -0.525731096637, 0.262865587024)),
+ vertex((0.5, -0.162459832634, 0.262865565628)),
+ vertex((0.309016994375, 0.425325419658, 0.262865531009)),
+ vertex((-0.309016994375, 0.425325419658, 0.262865531009)),
+ vertex((-0.5, -0.162459832634, 0.262865565628)),
+ vertex((0.309016994375, -0.425325419658, -0.262865531009)),
+ vertex((0.5, 0.162459832634, -0.262865565628)),
+ vertex((0.0, 0.525731096637, -0.262865587024)),
+ vertex((-0.5, 0.162459832634, -0.262865565628)),
+ vertex((-0.309016994375, -0.425325419658, -0.262865531009)),
+ vertex((0.0, 0.0, -0.587785252292))]
+
+ self.edgeskeleton = [edge(self.vertskeleton[0], self.vertskeleton[1]),
+ edge(self.vertskeleton[0], self.vertskeleton[2]),
+ edge(self.vertskeleton[0], self.vertskeleton[3]),
+ edge(self.vertskeleton[0], self.vertskeleton[4]),
+ edge(self.vertskeleton[0], self.vertskeleton[5]),
+ edge(self.vertskeleton[1], self.vertskeleton[2]),
+ edge(self.vertskeleton[2], self.vertskeleton[3]),
+ edge(self.vertskeleton[3], self.vertskeleton[4]),
+ edge(self.vertskeleton[4], self.vertskeleton[5]),
+ edge(self.vertskeleton[5], self.vertskeleton[1]),
+ edge(self.vertskeleton[1], self.vertskeleton[6]),
+ edge(self.vertskeleton[2], self.vertskeleton[6]),
+ edge(self.vertskeleton[2], self.vertskeleton[7]),
+ edge(self.vertskeleton[3], self.vertskeleton[7]),
+ edge(self.vertskeleton[3], self.vertskeleton[8]),
+ edge(self.vertskeleton[4], self.vertskeleton[8]),
+ edge(self.vertskeleton[4], self.vertskeleton[9]),
+ edge(self.vertskeleton[5], self.vertskeleton[9]),
+ edge(self.vertskeleton[5], self.vertskeleton[10]),
+ edge(self.vertskeleton[1], self.vertskeleton[10]),
+ edge(self.vertskeleton[6], self.vertskeleton[7]),
+ edge(self.vertskeleton[7], self.vertskeleton[8]),
+ edge(self.vertskeleton[8], self.vertskeleton[9]),
+ edge(self.vertskeleton[9], self.vertskeleton[10]),
+ edge(self.vertskeleton[10], self.vertskeleton[6]),
+ edge(self.vertskeleton[6], self.vertskeleton[11]),
+ edge(self.vertskeleton[7], self.vertskeleton[11]),
+ edge(self.vertskeleton[8], self.vertskeleton[11]),
+ edge(self.vertskeleton[9], self.vertskeleton[11]),
+ edge(self.vertskeleton[10], self.vertskeleton[11])]
+
+ self.panelpoints = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 1], [1, 2, 6],
+ [2, 6, 7], [2, 3, 7], [3, 7, 8], [3, 4, 8], [4, 8, 9], [4, 5, 9],
+ [5, 9, 10], [5, 1, 10], [1, 10, 6], [6, 7, 11], [7, 8, 11],
+ [8, 9, 11], [9, 10, 11], [10, 6, 11]]
+
+ self.paneledges = [[0, 1, 5], [1, 2, 6], [2, 3, 7], [3, 4, 8], [4, 0, 9], [5, 10, 11],
+ [11, 12, 20], [6, 12, 13], [13, 14, 21], [7, 14, 15], [15, 16, 22],
+ [8, 16, 17], [17, 18, 23], [9, 18, 19], [19, 10, 24], [20, 25, 26],
+ [21, 26, 27], [22, 27, 28], [23, 28, 29], [24, 29, 25]]
+
+ self.reversepanel = [5, 7, 9, 11, 13, 15, 16, 17, 18, 19]
+ self.edgelength = []
+ self.vertsdone = [[0, 0]] * len(self.vertskeleton)
+
class icoedge(geodesic):
- def __init__(self,parameter):
+ def __init__(self, parameter):
geodesic.__init__(mesh)
- geodesic.setparameters(self,parameter)
+ geodesic.setparameters(self, parameter)
self.set_vert_edge_skeleons()
def set_vert_edge_skeleons(self):
- self.vertskeleton=[ vertex(( 0 , 0.309016994375 , 0.5 )),
- vertex(( 0 , -0.309016994375 , 0.5 )),
- vertex(( -0.5 , 0 , 0.309016994375 )),
- vertex(( 0.5 , 0 , 0.309016994375 )),
- vertex(( -0.309016994375 , -0.5 , 0 )),
- vertex(( 0.309016994375 , -0.5 , 0 )),
- vertex(( 0.309016994375 , 0.5 , 0 )),
- vertex(( -0.309016994375 , 0.5 , 0 )),
- vertex(( -0.5 , 0 , -0.309016994375 )),
- vertex(( 0.5 , 0 , -0.309016994375 )),
- vertex(( 0 , 0.309016994375 , -0.5 )),
- vertex(( 0 , -0.309016994375 , -0.5 )) ]
- self.edgeskeleton=[ edge(self.vertskeleton[0],self.vertskeleton[1]),
- edge(self.vertskeleton[0],self.vertskeleton[7]),
- edge(self.vertskeleton[0],self.vertskeleton[2]),
- edge(self.vertskeleton[1],self.vertskeleton[2]),
- edge(self.vertskeleton[1],self.vertskeleton[4]),
- edge(self.vertskeleton[1],self.vertskeleton[5]),
- edge(self.vertskeleton[1],self.vertskeleton[3]),
- edge(self.vertskeleton[0],self.vertskeleton[3]),
- edge(self.vertskeleton[0],self.vertskeleton[6]),
- edge(self.vertskeleton[2],self.vertskeleton[7]),
- edge(self.vertskeleton[2],self.vertskeleton[8]),
- edge(self.vertskeleton[2],self.vertskeleton[4]),
- edge(self.vertskeleton[4],self.vertskeleton[5]),
- edge(self.vertskeleton[3],self.vertskeleton[5]),
- edge(self.vertskeleton[3],self.vertskeleton[9]),
- edge(self.vertskeleton[3],self.vertskeleton[6]),
- edge(self.vertskeleton[6],self.vertskeleton[7]),
- edge(self.vertskeleton[7],self.vertskeleton[10]),
- edge(self.vertskeleton[7],self.vertskeleton[8]),
- edge(self.vertskeleton[4],self.vertskeleton[8]),
- edge(self.vertskeleton[4],self.vertskeleton[11]),
- edge(self.vertskeleton[5],self.vertskeleton[11]),
- edge(self.vertskeleton[5],self.vertskeleton[9]),
- edge(self.vertskeleton[6],self.vertskeleton[9]),
- edge(self.vertskeleton[6],self.vertskeleton[10]),
- edge(self.vertskeleton[8],self.vertskeleton[10]),
- edge(self.vertskeleton[8],self.vertskeleton[11]),
- edge(self.vertskeleton[9],self.vertskeleton[11]),
- edge(self.vertskeleton[9],self.vertskeleton[10]),
- edge(self.vertskeleton[10],self.vertskeleton[11]) ]
- self.panelpoints=[ [0,1,2],[0,1,3],[0,2,7],[1,2,4],[1,4,5],[1,3,5],[0,3,6],[0,6,7],[2,7,8],[2,4,8],
- [3,5,9],[3,6,9],[7,8,10],[4,8,11],[4,5,11],[5,9,11],[6,9,10],[6,7,10],[8,10,11],[9,10,11]]
- self.paneledges=[[0,2,3],[0,7,6],[2,1,9],[3,4,11],[4,5,12],[6,5,13],[7,8,15],[8,1,16],[9,10,18],[11,10,19],
- [13,14,22],[15,14,23],[18,17,25],[19,20,26],[12,20,21],[22,21,27],[23,24,28],[16,24,17],[25,26,29],[28,27,29]]
- self.reversepanel=[0,2,5,9,11,12,14,15,17,19]
- self.edgelength=[]
- self.vertsdone=[[0,0]] * len(self.vertskeleton)
+ self.vertskeleton = [vertex((0, 0.309016994375, 0.5)),
+ vertex((0, -0.309016994375, 0.5)),
+ vertex((-0.5, 0, 0.309016994375)),
+ vertex((0.5, 0, 0.309016994375)),
+ vertex((-0.309016994375, -0.5, 0)),
+ vertex((0.309016994375, -0.5, 0)),
+ vertex((0.309016994375, 0.5, 0)),
+ vertex((-0.309016994375, 0.5, 0)),
+ vertex((-0.5, 0, -0.309016994375)),
+ vertex((0.5, 0, -0.309016994375)),
+ vertex((0, 0.309016994375, -0.5)),
+ vertex((0, -0.309016994375, -0.5))]
+
+ self.edgeskeleton = [edge(self.vertskeleton[0], self.vertskeleton[1]),
+ edge(self.vertskeleton[0], self.vertskeleton[7]),
+ edge(self.vertskeleton[0], self.vertskeleton[2]),
+ edge(self.vertskeleton[1], self.vertskeleton[2]),
+ edge(self.vertskeleton[1], self.vertskeleton[4]),
+ edge(self.vertskeleton[1], self.vertskeleton[5]),
+ edge(self.vertskeleton[1], self.vertskeleton[3]),
+ edge(self.vertskeleton[0], self.vertskeleton[3]),
+ edge(self.vertskeleton[0], self.vertskeleton[6]),
+ edge(self.vertskeleton[2], self.vertskeleton[7]),
+ edge(self.vertskeleton[2], self.vertskeleton[8]),
+ edge(self.vertskeleton[2], self.vertskeleton[4]),
+ edge(self.vertskeleton[4], self.vertskeleton[5]),
+ edge(self.vertskeleton[3], self.vertskeleton[5]),
+ edge(self.vertskeleton[3], self.vertskeleton[9]),
+ edge(self.vertskeleton[3], self.vertskeleton[6]),
+ edge(self.vertskeleton[6], self.vertskeleton[7]),
+ edge(self.vertskeleton[7], self.vertskeleton[10]),
+ edge(self.vertskeleton[7], self.vertskeleton[8]),
+ edge(self.vertskeleton[4], self.vertskeleton[8]),
+ edge(self.vertskeleton[4], self.vertskeleton[11]),
+ edge(self.vertskeleton[5], self.vertskeleton[11]),
+ edge(self.vertskeleton[5], self.vertskeleton[9]),
+ edge(self.vertskeleton[6], self.vertskeleton[9]),
+ edge(self.vertskeleton[6], self.vertskeleton[10]),
+ edge(self.vertskeleton[8], self.vertskeleton[10]),
+ edge(self.vertskeleton[8], self.vertskeleton[11]),
+ edge(self.vertskeleton[9], self.vertskeleton[11]),
+ edge(self.vertskeleton[9], self.vertskeleton[10]),
+ edge(self.vertskeleton[10], self.vertskeleton[11])]
+
+ self.panelpoints = [[0, 1, 2], [0, 1, 3], [0, 2, 7], [1, 2, 4], [1, 4, 5],
+ [1, 3, 5], [0, 3, 6], [0, 6, 7], [2, 7, 8], [2, 4, 8],
+ [3, 5, 9], [3, 6, 9], [7, 8, 10], [4, 8, 11], [4, 5, 11],
+ [5, 9, 11], [6, 9, 10], [6, 7, 10], [8, 10, 11], [9, 10, 11]]
+
+ self.paneledges = [[0, 2, 3], [0, 7, 6], [2, 1, 9], [3, 4, 11], [4, 5, 12], [6, 5, 13],
+ [7, 8, 15], [8, 1, 16], [9, 10, 18], [11, 10, 19], [13, 14, 22],
+ [15, 14, 23], [18, 17, 25], [19, 20, 26], [12, 20, 21], [22, 21, 27],
+ [23, 24, 28], [16, 24, 17], [25, 26, 29], [28, 27, 29]]
+
+ self.reversepanel = [0, 2, 5, 9, 11, 12, 14, 15, 17, 19]
+ self.edgelength = []
+ self.vertsdone = [[0, 0]] * len(self.vertskeleton)
+
class icoface(geodesic):
- def __init__(self,parameter):
+ def __init__(self, parameter):
geodesic.__init__(mesh)
- geodesic.setparameters(self,parameter)
+ geodesic.setparameters(self, parameter)
self.set_vert_edge_skeleons()
def set_vert_edge_skeleons(self):
- self.vertskeleton=[ vertex(( -0.17841104489 , 0.309016994375 , 0.46708617948 )),
- vertex(( -0.17841104489 , -0.309016994375 , 0.46708617948 )),
- vertex(( 0.35682208977 , 0.0 , 0.467086179484 )),
- vertex(( -0.57735026919 , 0.0 , 0.110264089705 )),
- vertex(( -0.288675134594 , -0.5 , -0.11026408971 )),
- vertex(( 0.288675134594 , -0.5 , 0.11026408971 )),
- vertex(( 0.57735026919 , 0.0 , -0.110264089705 )),
- vertex(( 0.288675134594 , 0.5 , 0.11026408971 )),
- vertex(( -0.288675134594 , 0.5 , -0.11026408971 )),
- vertex(( -0.35682208977 , 0.0 , -0.467086179484 )),
- vertex(( 0.17841104489 , -0.309016994375 , -0.46708617948 )),
- vertex(( 0.17841104489 , 0.309016994375 , -0.46708617948 )) ]
- self.edgeskeleton=[ edge(self.vertskeleton[0],self.vertskeleton[1]),
- edge(self.vertskeleton[2],self.vertskeleton[1]),
- edge(self.vertskeleton[2],self.vertskeleton[0]),
- edge(self.vertskeleton[0],self.vertskeleton[3]),
- edge(self.vertskeleton[1],self.vertskeleton[3]),
- edge(self.vertskeleton[1],self.vertskeleton[4]),
- edge(self.vertskeleton[1],self.vertskeleton[5]),
- edge(self.vertskeleton[2],self.vertskeleton[5]),
- edge(self.vertskeleton[2],self.vertskeleton[6]),
- edge(self.vertskeleton[2],self.vertskeleton[7]),
- edge(self.vertskeleton[0],self.vertskeleton[7]),
- edge(self.vertskeleton[0],self.vertskeleton[8]),
- edge(self.vertskeleton[3],self.vertskeleton[9]),
- edge(self.vertskeleton[3],self.vertskeleton[4]),
- edge(self.vertskeleton[5],self.vertskeleton[4]),
- edge(self.vertskeleton[5],self.vertskeleton[10]),
- edge(self.vertskeleton[5],self.vertskeleton[6]),
- edge(self.vertskeleton[7],self.vertskeleton[6]),
- edge(self.vertskeleton[7],self.vertskeleton[11]),
- edge(self.vertskeleton[7],self.vertskeleton[8]),
- edge(self.vertskeleton[3],self.vertskeleton[8]),
- edge(self.vertskeleton[4],self.vertskeleton[9]),
- edge(self.vertskeleton[4],self.vertskeleton[10]),
- edge(self.vertskeleton[6],self.vertskeleton[10]),
- edge(self.vertskeleton[6],self.vertskeleton[11]),
- edge(self.vertskeleton[8],self.vertskeleton[11]),
- edge(self.vertskeleton[8],self.vertskeleton[9]),
- edge(self.vertskeleton[9],self.vertskeleton[10]),
- edge(self.vertskeleton[11],self.vertskeleton[10]),
- edge(self.vertskeleton[11],self.vertskeleton[9]) ]
- self.panelpoints=[[2,0,1],[0,1,3],[2,1,5],[2,0,7],[1,3,4],[1,5,4],[2,5,6],[2,7,6],[0,7,8],[0,3,8],[3,4,9],[5,4,10],[5,6,10],[7,6,11],[7,8,11],[3,8,9],[4,9,10],[6,11,10],[8,11,9],[11,9,10]]
- self.paneledges=[[2,1,0],[0,3,4],[1,7,6],[2,9,10],[4,5,13],[6,5,14],[7,8,16],[9,8,17],[10,11,19],[3,11,20],
- [13,12,21],[14,15,22],[16,15,23],[17,18,24],[19,18,25],[20,12,26],[21,22,27],[24,23,28],[25,26,29],[29,28,27]]
- self.reversepanel=[1,3,5,7,9,10,12,14,17,19]
- self.edgelength=[]
- self.vertsdone=[[0,0]] * len(self.vertskeleton)
-
-##???PKHG TODO this does not work yet ...
-def creategeo(geo,polytype,orientation,parameters):
+ self.vertskeleton = [vertex((-0.17841104489, 0.309016994375, 0.46708617948)),
+ vertex((-0.17841104489, -0.309016994375, 0.46708617948)),
+ vertex((0.35682208977, 0.0, 0.467086179484)),
+ vertex((-0.57735026919, 0.0, 0.110264089705)),
+ vertex((-0.288675134594, -0.5, -0.11026408971)),
+ vertex((0.288675134594, -0.5, 0.11026408971)),
+ vertex((0.57735026919, 0.0, -0.110264089705)),
+ vertex((0.288675134594, 0.5, 0.11026408971)),
+ vertex((-0.288675134594, 0.5, -0.11026408971)),
+ vertex((-0.35682208977, 0.0, -0.467086179484)),
+ vertex((0.17841104489, -0.309016994375, -0.46708617948)),
+ vertex((0.17841104489, 0.309016994375, -0.46708617948))]
+
+ self.edgeskeleton = [edge(self.vertskeleton[0], self.vertskeleton[1]),
+ edge(self.vertskeleton[2], self.vertskeleton[1]),
+ edge(self.vertskeleton[2], self.vertskeleton[0]),
+ edge(self.vertskeleton[0], self.vertskeleton[3]),
+ edge(self.vertskeleton[1], self.vertskeleton[3]),
+ edge(self.vertskeleton[1], self.vertskeleton[4]),
+ edge(self.vertskeleton[1], self.vertskeleton[5]),
+ edge(self.vertskeleton[2], self.vertskeleton[5]),
+ edge(self.vertskeleton[2], self.vertskeleton[6]),
+ edge(self.vertskeleton[2], self.vertskeleton[7]),
+ edge(self.vertskeleton[0], self.vertskeleton[7]),
+ edge(self.vertskeleton[0], self.vertskeleton[8]),
+ edge(self.vertskeleton[3], self.vertskeleton[9]),
+ edge(self.vertskeleton[3], self.vertskeleton[4]),
+ edge(self.vertskeleton[5], self.vertskeleton[4]),
+ edge(self.vertskeleton[5], self.vertskeleton[10]),
+ edge(self.vertskeleton[5], self.vertskeleton[6]),
+ edge(self.vertskeleton[7], self.vertskeleton[6]),
+ edge(self.vertskeleton[7], self.vertskeleton[11]),
+ edge(self.vertskeleton[7], self.vertskeleton[8]),
+ edge(self.vertskeleton[3], self.vertskeleton[8]),
+ edge(self.vertskeleton[4], self.vertskeleton[9]),
+ edge(self.vertskeleton[4], self.vertskeleton[10]),
+ edge(self.vertskeleton[6], self.vertskeleton[10]),
+ edge(self.vertskeleton[6], self.vertskeleton[11]),
+ edge(self.vertskeleton[8], self.vertskeleton[11]),
+ edge(self.vertskeleton[8], self.vertskeleton[9]),
+ edge(self.vertskeleton[9], self.vertskeleton[10]),
+ edge(self.vertskeleton[11], self.vertskeleton[10]),
+ edge(self.vertskeleton[11], self.vertskeleton[9])]
+
+ self.panelpoints = [[2, 0, 1], [0, 1, 3], [2, 1, 5], [2, 0, 7], [1, 3, 4], [1, 5, 4],
+ [2, 5, 6], [2, 7, 6], [0, 7, 8], [0, 3, 8], [3, 4, 9], [5, 4, 10],
+ [5, 6, 10], [7, 6, 11], [7, 8, 11], [3, 8, 9], [4, 9, 10],
+ [6, 11, 10], [8, 11, 9], [11, 9, 10]]
+
+ self.paneledges = [[2, 1, 0], [0, 3, 4], [1, 7, 6], [2, 9, 10], [4, 5, 13], [6, 5, 14],
+ [7, 8, 16], [9, 8, 17], [10, 11, 19], [3, 11, 20], [13, 12, 21],
+ [14, 15, 22], [16, 15, 23], [17, 18, 24], [19, 18, 25], [20, 12, 26],
+ [21, 22, 27], [24, 23, 28], [25, 26, 29], [29, 28, 27]]
+
+ self.reversepanel = [1, 3, 5, 7, 9, 10, 12, 14, 17, 19]
+ self.edgelength = []
+ self.vertsdone = [[0, 0]] * len(self.vertskeleton)
+
+
+# PKHG TODO this does not work yet ...
+def creategeo(geo, polytype, orientation, parameters):
if polytype == 'Tetrahedron':
if orientation == 'PointUp':
my_tetrahedron = tetrahedron(geodesic)
my_tetrahedron.set_vert_edge_skeleons()
my_tetrahedron.config()
- check_contains(my_tetrahedron,"my_tetra",True)
+ check_contains(my_tetrahedron, "my_tetra", True)
vefm_add_object(geo)
elif orientation == 'EdgeUp':
geo = tetraedge(parameters)
- else: # orientation==2:
- geo=tetraface(parameters)
- elif polytype == 'Octahedron': # octahedron
+ else: # orientation == 2:
+ geo = tetraface(parameters)
+ elif polytype == 'Octahedron':
if orientation == 'PointUp':
geo = octahedron(parameters)
elif orientation == 'EdgeUp':
geo = octaedge(parameters)
- else: #if orientation==2:
+ else: # if orientation == 2:
geo = octaface(parameters)
- elif polytype == 'Icosahedron': # icosahedron
+ elif polytype == 'Icosahedron':
if orientation == 'PointUp':
geo = icosahedron(parameters)
elif orientation == 'EdgeUp':
geo = icoedge(parameters)
- else: #if orientation==2:
+ else: # if orientation == 2:
geo = icoface(parameters)
+
return geo
diff --git a/add_mesh_extra_objects/geodesic_domes/third_domes_panel_271.py b/add_mesh_extra_objects/geodesic_domes/third_domes_panel_271.py
index bca0f71f..75760e9d 100644
--- a/add_mesh_extra_objects/geodesic_domes/third_domes_panel_271.py
+++ b/add_mesh_extra_objects/geodesic_domes/third_domes_panel_271.py
@@ -5,400 +5,819 @@ from . import forms_271
from . import geodesic_classes_271
from . import add_shape_geodesic
-from bpy.props import EnumProperty, IntProperty, FloatProperty, StringProperty, BoolProperty
+from bpy.types import Operator
+from bpy.props import (
+ EnumProperty,
+ IntProperty,
+ FloatProperty,
+ StringProperty,
+ BoolProperty,
+ )
from math import pi
-from mathutils import Vector #needed to check vertex.vector values
+from mathutils import Vector # used for vertex.vector values
-########global######
+# global #
last_generated_object = None
last_imported_mesh = None
basegeodesic = None
imported_hubmesh_to_use = None
-########global end######
+# global end #
-########EIND FOR SHAPEKEYS######
-### error messages?!
-bpy.types.Scene.error_message = StringProperty(name="actual error", default = "")
+# ###### EIND FOR SHAPEKEYS ######
-bpy.types.Scene.geodesic_not_yet_called = BoolProperty(name="geodesic_not_called",default = True)
-
-bpy.types.Scene.gd_help_text_width = IntProperty(name = "Text Width" , description = "The width above which the text wraps" , default = 60 , max = 180 , min = 20)
-
-class GenerateGeodesicDome(bpy.types.Operator):
+class GenerateGeodesicDome(Operator):
bl_label = "Modify Geodesic Objects"
bl_idname = "mesh.generate_geodesic_dome"
bl_description = "Create Geodesic Object Types"
bl_options = {'REGISTER', 'UNDO'}
-#PKHG_NEW saving and loading parameters
- save_parameters = BoolProperty(name = "save params",\
- description = "activation save */tmp/GD_0.GD", default = False)
- load_parameters = BoolProperty(name = "load params",\
- description = "read */tmp/GD_0.GD", default = False)
-
- gd_help_text_width = IntProperty(name = "Text Width" , description = "The width above which the text wraps" , default = 60 , max = 180 , min = 20)
-
-
+ # PKHG_NEW saving and loading parameters
+ save_parameters = BoolProperty(
+ name="Save params",
+ description="Activation save */tmp/GD_0.GD",
+ default=False
+ )
+ load_parameters = BoolProperty(
+ name="Load params",
+ description="Read */tmp/GD_0.GD",
+ default=False
+ )
+ gd_help_text_width = IntProperty(
+ name="Text Width",
+ description="The width above which the text wraps",
+ default=60,
+ max=180, min=20
+ )
mainpages = EnumProperty(
- name="Menu",
- description="Create Faces, Struts & Hubs",
- items=[("Main", "Main", "Geodesic objects"),
- ("Faces", "Faces", "Generate Faces"),
- ("Struts", "Struts", "Generate Struts"),
- ("Hubs", "Hubs", "Generate Hubs"),
- ("Help", "Help", "Not implemented"),
- ],
- default='Main')
-
-#for Faces!
+ name="Menu",
+ description="Create Faces, Struts & Hubs",
+ items=[("Main", "Main", "Geodesic objects"),
+ ("Faces", "Faces", "Generate Faces"),
+ ("Struts", "Struts", "Generate Struts"),
+ ("Hubs", "Hubs", "Generate Hubs"),
+ ("Help", "Help", "Not implemented"),
+ ],
+ default='Main'
+ )
+ # for Faces
facetype_menu = EnumProperty(
- name="Faces",
- description="choose a facetype",
- items=[("0", "strip", "strip"),
- ("1", "open vertical", "vertical"),
- ("2", "open slanted", "slanted"),
- ("3", "closed point", "closed point"),
- ("4", "pillow", "pillow"),
- ("5", "closed vertical", "closed vertical"),
- ("6", "stepped", "stepped"),
- ("7", "spikes", "spikes"),
- ("8", "boxed", "boxed"),
- ("9", "diamond", "diamond"),
- ("10", "bar", "bar"),
- ],
- default='0')
-
- facetoggle = BoolProperty(name="Activate: Face Object", description = "Activate Faces for Geodesic object", default = False )
-
- face_use_imported_object = BoolProperty(name="Use: Imported Object",\
- description = "Activate faces on your Imported object", default = False)
- facewidth = FloatProperty(name="facewidth", min = -1, soft_min = 0.001, max = 4, default = .50)
- fwtog = BoolProperty(name="fwtog", default = False )
- faceheight = FloatProperty(name="faceheight", min = 0.001, max = 4, default = 1 )
- fhtog = BoolProperty(name="fhtog", default = False )
- face_detach = BoolProperty(name="face_detach", default = False )
- fmeshname = StringProperty(name="fmeshname", default = "defaultface")
-
-
+ name="Faces",
+ description="choose a facetype",
+ items=[("0", "strip", "strip"),
+ ("1", "open vertical", "vertical"),
+ ("2", "open slanted", "slanted"),
+ ("3", "closed point", "closed point"),
+ ("4", "pillow", "pillow"),
+ ("5", "closed vertical", "closed vertical"),
+ ("6", "stepped", "stepped"),
+ ("7", "spikes", "spikes"),
+ ("8", "boxed", "boxed"),
+ ("9", "diamond", "diamond"),
+ ("10", "bar", "bar"),
+ ],
+ default='0'
+ )
+ facetoggle = BoolProperty(
+ name="Activate: Face Object",
+ description="Activate Faces for Geodesic object",
+ default=False
+ )
+ face_use_imported_object = BoolProperty(
+ name="Use: Imported Object",
+ description="Activate faces on your Imported object",
+ default=False
+ )
+ facewidth = FloatProperty(
+ name="Face Width",
+ min=-1, soft_min=0.001, max=4,
+ default=.50
+ )
+ fwtog = BoolProperty(
+ name="Width tweak",
+ default=False
+ )
+ faceheight = FloatProperty(
+ name="Face Height",
+ min=0.001, max=4,
+ default=1
+ )
+ fhtog = BoolProperty(
+ name="Height tweak",
+ default=False
+ )
+ face_detach = BoolProperty(
+ name="Detach Faces",
+ default=False
+ )
+ fmeshname = StringProperty(
+ name="Face Mesh name",
+ default="defaultface"
+ )
geodesic_types = EnumProperty(
- name="Objects",
- description="Choose Geodesic, Grid, Cylinder, Parabola,\
- Torus, Sphere, Import your mesh or Superparameters",
- items=[("Geodesic", "Geodesic", "Generate Geodesic"),
- ("Grid", "Grid", "Generate Grid"),
- ("Cylinder", "Cylinder", "Generate Cylinder"),
- ("Parabola", "Parabola", "Generate Parabola"),
- ("Torus", "Torus", "Generate Torus"),
- ("Sphere", "Sphere", "Generate Sphere"),
- ("Import your mesh", "Import your mesh", "Import Your Mesh"),
- ],
- default = 'Geodesic')
-
- import_mesh_name = StringProperty(name = "mesh to import",\
- description = "the name has to be the name of a meshobject", default = "None")
-
+ name="Objects",
+ description="Choose Geodesic, Grid, Cylinder, Parabola, "
+ "Torus, Sphere, Import your mesh or Superparameters",
+ items=[("Geodesic", "Geodesic", "Generate Geodesic"),
+ ("Grid", "Grid", "Generate Grid"),
+ ("Cylinder", "Cylinder", "Generate Cylinder"),
+ ("Parabola", "Parabola", "Generate Parabola"),
+ ("Torus", "Torus", "Generate Torus"),
+ ("Sphere", "Sphere", "Generate Sphere"),
+ ("Import your mesh", "Import your mesh", "Import Your Mesh"),
+ ],
+ default='Geodesic'
+ )
+ import_mesh_name = StringProperty(
+ name="Mesh to import",
+ description="the name has to be the name of a meshobject",
+ default="None"
+ )
base_type = EnumProperty(
- name="Hedron",
- description="Choose between Tetrahedron, Octahedron, Icosahedron ",\
- items=[("Tetrahedron", "Tetrahedron", "Generate Tetrahedron"),\
- ("Octahedron", "Octahedron", "Generate Octahedron"),\
- ("Icosahedron", "Icosahedron", "Generate Icosahedron"),
- ],
- default='Tetrahedron')
-
+ name="Hedron",
+ description="Choose between Tetrahedron, Octahedron, Icosahedron ",
+ items=[("Tetrahedron", "Tetrahedron", "Generate Tetrahedron"),
+ ("Octahedron", "Octahedron", "Generate Octahedron"),
+ ("Icosahedron", "Icosahedron", "Generate Icosahedron"),
+ ],
+ default='Tetrahedron'
+ )
orientation = EnumProperty(
- name="Point^",
- description="Point (Vert), Edge or Face pointing upwards",
- items=[("PointUp", "PointUp", "Point up"),
- ("EdgeUp", "EdgeUp", "Edge up"),
- ("FaceUp", "FaceUp", "Face up"),
- ],
- default='PointUp')
-
+ name="Point^",
+ description="Point (Vert), Edge or Face pointing upwards",
+ items=[("PointUp", "PointUp", "Point up"),
+ ("EdgeUp", "EdgeUp", "Edge up"),
+ ("FaceUp", "FaceUp", "Face up"),
+ ],
+ default='PointUp'
+ )
geodesic_class = EnumProperty(
- name="Class",
- description="Subdivide Basic/Triacon",
- items=[("Class 1", "Class 1", "class one"),
- ("Class 2", "Class 2", "class two"),
- ],
- default='Class 1')
-
+ name="Class",
+ description="Subdivide Basic/Triacon",
+ items=[("Class 1", "Class 1", "class one"),
+ ("Class 2", "Class 2", "class two"),
+ ],
+ default='Class 1'
+ )
tri_hex_star = EnumProperty(
- name="Shape",
- description="Choose between tri hex star face types",
- items=[("tri", "tri", "tri faces"),
- ("hex", "hex", "hex faces(by tri)"),
- ("star", "star", "star faces(by tri)"),
- ],
- default='tri')
-
+ name="Shape",
+ description="Choose between tri hex star face types",
+ items=[("tri", "tri", "tri faces"),
+ ("hex", "hex", "hex faces(by tri)"),
+ ("star", "star", "star faces(by tri)"),
+ ],
+ default='tri'
+ )
spherical_flat = EnumProperty(
- name="Round",
- description="Choose between spherical or flat ",
- items=[("spherical", "spherical", "Generate spherical"),
- ("flat", "flat", "Generate flat"),
- ],
- default='spherical')
-
- use_imported_mesh = BoolProperty(name="use import",\
- description = "Use an imported mesh", default = False)
-
-#Cylinder
- cyxres= IntProperty(name="Resolution x/y", min = 3, max = 32,\
- description = "number of faces around x/y", default = 5 )
- cyyres= IntProperty(name="Resolution z", min = 3, max = 32,\
- description = "number of faces in z direction", default = 5 )
- cyxsz= FloatProperty(name="Scale x/y", min = 0.01, max = 10,\
- description = "scale in x/y direction", default = 1 )
- cyysz= FloatProperty(name="Scale z", min = 0.01, max = 10,\
- description = "scale in z direction", default = 1 )
- cyxell= FloatProperty(name="Stretch x", min = 0.001, max = 4,\
- description = "stretch in x direction", default = 1 )
- cygap= FloatProperty(name="Gap", min = -2, max = 2,\
- description = "shrink in % around radius", default = 1 )
- cygphase= FloatProperty(name="Phase", min = -4, max = 4,\
- description = "rotate around pivot x/y", default = 0 )
-#Parabola
- paxres= IntProperty(name="Resolution x/y", min = 3, max = 32,\
- description = "number of faces around x/y", default = 5 )
- payres= IntProperty(name="Resolution z", min = 3, max = 32,\
- description = "number of faces in z direction", default = 5 )
- paxsz= FloatProperty(name="Scale x/y", min = 0.001, max = 10,\
- description = "scale in x/y direction", default = 0.30)
- paysz= FloatProperty(name="Scale z", min = 0.001, max = 10,\
- description = "scale in z direction", default = 1 )
- paxell= FloatProperty(name="Stretch x", min = 0.001, max = 4,\
- description = "stretch in x direction", default = 1 )
- pagap= FloatProperty(name="Gap", min = -2, max = 2,\
- description = "shrink in % around radius", default = 1 )
- pagphase= FloatProperty(name="Phase", min = -4, max = 4,\
- description = "rotate around pivot x/y", default = 0 )
-#Torus
- ures= IntProperty(name="Resolution x/y",min = 3, max = 32,\
- description = "number of faces around x/y", default = 8 )
- vres= IntProperty(name="Resolution z", min = 3, max = 32,\
- description = "number of faces in z direction", default = 8 )
- urad= FloatProperty(name="Radius x/y", min = 0.001, max = 10,\
- description = "radius in x/y plane", default = 1 )
- vrad= FloatProperty(name="Radius z", min = 0.001, max = 10,\
- description = "radius in z plane", default = 0.250)
- uellipse= FloatProperty(name="Stretch x", min = 0.001, max = 10,\
- description = "number of faces in z direction", default = 1 )
- vellipse= FloatProperty(name="Stretch z", min = 0.001, max = 10,\
- description = "number of faces in z direction", default = 1 )
- upart= FloatProperty(name="Gap x/y", min = -4, max = 4,\
- description = "shrink faces around x/y", default = 1 )
- vpart= FloatProperty(name="Gap z", min = -4, max = 4,\
- description = "shrink faces in z direction", default = 1 )
- ugap= FloatProperty(name="Phase x/y", min = -4, max = 4,\
- description = "rotate around pivot x/y", default = 0 )
- vgap= FloatProperty(name="Phase z", min = -4, max = 4,\
- description = "rotate around pivot z", default = 0 )
- uphase= FloatProperty(name="uphase", min = -4, max = 4,\
- description = "number of faces in z direction", default = 0 )
- vphase= FloatProperty(name="vphase", min = -4, max = 4,\
- description = "number of faces in z direction", default = 0 )
- uexp= FloatProperty(name="uexp", min = -4, max = 4,\
- description = "number of faces in z direction", default = 0 )
- vexp= FloatProperty(name="vexp", min = -4, max = 4,\
- description = "number of faces in z direction", default = 0 )
- usuper= FloatProperty(name="usuper", min = -4, max = 4,\
- description = "first set of superform parameters", default = 2 )
- vsuper= FloatProperty(name="vsuper", min = -4, max = 4,\
- description = "second set of superform parameters", default = 2 )
- utwist= FloatProperty(name="Twist x/y", min = -4, max = 4,\
- description = " use with superformular u", default = 0 )
- vtwist= FloatProperty(name="Twist z", min = -4, max = 4,\
- description = "use with superformular v", default = 0 )
-
-#Sphere
- bures= IntProperty(name="Resolution x/y", min = 3, max = 32,\
- description = "number of faces around x/y", default = 8 )
- bvres= IntProperty(name="Resolution z", min = 3, max = 32,\
- description = "number of faces in z direction", default = 8 )
- burad= FloatProperty(name="Radius", min = -4, max = 4,\
- description = "overall radius", default = 1 )
- bupart= FloatProperty(name="Gap x/y", min = -4, max = 4,\
- description = "shrink faces around x/y", default = 1 )
- bvpart= FloatProperty(name="Gap z", min = -4, max = 4,\
- description = "shrink faces in z direction", default = 1 )
- buphase= FloatProperty(name="Phase x/y", min = -4, max = 4,
- description = "rotate around pivot x/y", default = 0 )
- bvphase= FloatProperty(name="Phase z", min = -4, max = 4,\
- description = "rotate around pivot z", default = 0 )
- buellipse= FloatProperty(name="Stretch x", min = 0.001, max = 4,\
- description = "stretch in the x direction", default = 1 )
- bvellipse= FloatProperty(name="Stretch z", min = 0.001, max = 4,\
- description = "stretch in the z direction", default = 1 )
-#Grid
- grxres = IntProperty(name="Resolution x", min = 2, soft_max = 10, max = 20,\
- description = "number of faces in x direction", default = 5 )
- gryres = IntProperty(name="Resolution z",min = 2, soft_min = 2, soft_max=10, max = 20,\
- description = "number of faces in x direction", default = 2)
- grxsz = FloatProperty(name = "X size", min = 1, soft_min=0.01, soft_max=5, max = 10,\
- description = "x size", default = 2.0)
- grysz = FloatProperty(name="Y size",min = 1, soft_min=0.01, soft_max=5, max = 10,\
- description = "y size", default = 1.0)
-
-#PKHG_TODO_??? what means cart
- cart = IntProperty(name = "cart",min = 0, max = 2, default = 0)
- frequency = IntProperty(name="Frequency", min = 1, max = 8,\
- description ="subdivide base triangles", default = 1 )
- eccentricity = FloatProperty(name = "Eccentricity", min = 0.01 , max = 4,\
- description = "scaling in x/y dimension", default = 1 )
- squish = FloatProperty(name = "Squish",min = 0.01, soft_max = 4, max = 10,\
- description = "scaling in z dimension", default = 1 )
- radius = FloatProperty(name = "Radius",min = 0.01, soft_max = 4, max = 10,\
- description = "overall radius", default = 1 )
- squareness = FloatProperty(name="Square x/y", min = 0.1, max = 5,\
- description = "superelipse action in x/y", default = 2 )
- squarez = FloatProperty(name="Square z", min = 0.1, soft_max = 5, max = 10,\
- description = "superelipse action in z", default = 2 )
- baselevel = IntProperty(name="baselevel", default = 5 )
- dual = BoolProperty(name="Dual", description = "faces become verts,\
- verts become faces, edges flip", default = False)
- rotxy = FloatProperty(name="Rotate x/y", min= -4, max = 4,\
- description = "rotate superelipse action in x/y", default = 0 )
- rotz = FloatProperty(name="Rotate z", min= -4, max = 4,\
- description = "rotate superelipse action in z", default = 0 )
-
-#for choice of superformula
- uact = BoolProperty(name = 'superformula u (x/y)',\
- description = "activate superformula u parameters", default = False)
- vact = BoolProperty(name = 'superformula v (z)',\
- description = "activate superformula v parameters", default = False)
- um = FloatProperty(name = 'Pinch x/y', min = 0, soft_min=0.1, soft_max=5,max = 10,\
- description = "Pinch the mesh on x/y", default = 3)
- un1 = FloatProperty(name = 'Squash x/y', min = 0, soft_min=0.1, soft_max=5,max = 20,\
- description = "Squash the mesh x/y", default = 1)
- un2 = FloatProperty(name = 'Inflate x/y', min = 0, soft_min=0.1, soft_max=5,max = 10,\
- description = "Inflate the mesh x/y", default = 1)
- un3 = FloatProperty(name = 'Roundify x/y', min = 0, soft_min=0.1, soft_max=5,max = 10,\
- description = "Roundify x/y", default = 1)
- ua = FloatProperty(name = 'Shrink', min = 0, soft_min=0.1, soft_max=5,max = 10,\
- description = "Shrink", default = 1.0)
- ub = FloatProperty(name = 'Shrink x/y', min = 0, soft_min=0.1, soft_max=5,max = 10,\
- description = "Shrink y/x", default = 4.0)
- vm = FloatProperty(name = 'Scale Z Base', min = 0, soft_min=0.1, soft_max=5,max = 10,\
- description = "Scale Z Base", default = 1)
- vn1 = FloatProperty(name = 'Scale lock Top Z', min = 0, soft_min=0.1, soft_max=5,max = 10,\
- description = "Scale lock Top Z", default = 1)
- vn2 = FloatProperty(name = 'Inflate Base', min = 0, soft_min=0.1, soft_max=5,max = 10,\
- description = "Inflate Base", default = 1)
- vn3 = FloatProperty(name = 'Inflate', min = 0, soft_min=0.1, soft_max=5,max = 10,\
- description = "Inflate", default = 1)
- va = FloatProperty(name = 'Scale 1', min = 0, soft_min=0.1, soft_max=5,max = 10,\
- description = "Scale 1", default = 1)
- vb = FloatProperty(name = 'Scale 2', min = 0, soft_min=0.1, soft_max=5,max = 10,\
- description = "Scale 2", default = 1)
-
- uturn = FloatProperty(name = 'x/y Vert cycle', min = 0, soft_min=0.1, soft_max=5,max = 10,\
- description = "x/y Vert cycle", default = 0)
- vturn = FloatProperty(name = 'z Vert cycle', min = 0, soft_min=0.1, soft_max=5,max = 10,\
- description = "z Vert cycle", default = 0)
- utwist = FloatProperty(name = 'x/y Twist cycle', min = 0, soft_min=0.1, soft_max=5,max = 10,\
- description = "x/y Twist cycle", default = 0)
- vtwist = FloatProperty(name = 'z Twist cycle', min = 0, soft_min=0.1, soft_max=5,max = 10,\
- description = "z Twist cycle", default = 0)
-
-#Strut
- struttype= IntProperty(name="struttype", default= 0)
- struttoggle = BoolProperty(name="struttoggle", default = False )
- strutimporttoggle= BoolProperty(name="strutimporttoggle", default = False )
- strutimpmesh= StringProperty(name="strutimpmesh", default = "None")
- strutwidth= FloatProperty(name="strutwidth", min = -10, soft_min = 5, soft_max = 5,\
- max = 10, default = 1 )
- swtog= BoolProperty(name="swtog", default = False )
- strutheight= FloatProperty(name="strutheight", min = -5, soft_min = -1, soft_max = 5,\
- max = 10, default = 1 )
- shtog= BoolProperty(name="shtog", default = False )
- strutshrink= FloatProperty(name="strutshrink", min = 0.001, max = 4, default = 1 )
- sstog= BoolProperty(name="sstog", default = False )
- stretch= FloatProperty(name="stretch", min= -4, max = 4, default = 1.0 )
- lift= FloatProperty(name="lift", min = 0.001, max = 10, default = 0 )
- smeshname= StringProperty(name="smeshname", default = "defaultstrut")
-
-#Hubs
- hubtype = BoolProperty(name ="hubtype", description = "not used", default = True )
- hubtoggle = BoolProperty(name ="hubtoggle", default = False )
- hubimporttoggle = BoolProperty(name="new import", description = "import a mesh",\
- default = False )
- hubimpmesh = StringProperty(name="hubimpmesh",\
- description = "name of mesh to import", default = "None")
- hubwidth = FloatProperty(name="hubwidth", min = 0.01, max = 10,\
- default = 1 )
- hwtog = BoolProperty(name="hwtog", default = False )
- hubheight = FloatProperty(name="hubheight", min = 0.01, max = 10,\
- default = 1 )
- hhtog = BoolProperty(name="hhtog", default = False )
- hublength = FloatProperty(name ="hublength", min = 0.1, max = 10,\
- default = 1 )
- hstog= BoolProperty(name="hstog", default = False )
- hmeshname= StringProperty(name="hmeshname",\
- description = "Name of an existing mesh needed!", default = "None")
-
- name_list = ['facetype_menu','facetoggle','face_use_imported_object',
-'facewidth','fwtog','faceheight','fhtog',
-'face_detach','fmeshname','geodesic_types','import_mesh_name',
-'base_type','orientation','geodesic_class','tri_hex_star',
-'spherical_flat','use_imported_mesh','cyxres','cyyres',
-'cyxsz','cyysz','cyxell','cygap',
-'cygphase','paxres','payres','paxsz',
-'paysz','paxell','pagap','pagphase',
-'ures','vres','urad','vrad',
-'uellipse','vellipse','upart','vpart',
-'ugap','vgap','uphase','vphase',
-'uexp','vexp','usuper','vsuper',
-'utwist','vtwist','bures','bvres',
-'burad','bupart','bvpart','buphase',
-'bvphase','buellipse','bvellipse','grxres',
-'gryres','grxsz','grysz',
-'cart','frequency','eccentricity','squish',
-'radius','squareness','squarez','baselevel',
-'dual','rotxy','rotz',
-'uact','vact','um','un1',
-'un2','un3','ua','ub',
-'vm','vn1','vn2','vn3',
-'va','vb','uturn','vturn',
-'utwist','vtwist','struttype','struttoggle',
-'strutimporttoggle','strutimpmesh','strutwidth','swtog',
-'strutheight','shtog','strutshrink','sstog',
-'stretch','lift','smeshname','hubtype',
-'hubtoggle','hubimporttoggle','hubimpmesh','hubwidth',
-'hwtog','hubheight','hhtog','hublength',
-'hstog','hmeshname']
-
- def write_params(self,filename):
+ name="Round",
+ description="Choose between spherical or flat ",
+ items=[("spherical", "spherical", "Generate spherical"),
+ ("flat", "flat", "Generate flat"),
+ ],
+ default='spherical'
+ )
+ use_imported_mesh = BoolProperty(
+ name="use import",
+ description="Use an imported mesh",
+ default=False
+ )
+ # Cylinder
+ cyxres = IntProperty(
+ name="Resolution x/y",
+ min=3, max=32,
+ description="Number of faces around x/y",
+ default=5
+ )
+ cyyres = IntProperty(
+ name="Resolution z",
+ min=3, max=32,
+ description="Number of faces in z direction",
+ default=5
+ )
+ cyxsz = FloatProperty(
+ name="Scale x/y",
+ min=0.01, max=10,
+ description="Scale in x/y direction",
+ default=1
+ )
+ cyysz = FloatProperty(
+ name="Scale z",
+ min=0.01, max=10,
+ description="Scale in z direction",
+ default=1
+ )
+ cyxell = FloatProperty(
+ name="Stretch x",
+ min=0.001, max=4,
+ description="Stretch in x direction",
+ default=1
+ )
+ cygap = FloatProperty(
+ name="Gap",
+ min=-2, max=2,
+ description="Shrink in % around radius",
+ default=1
+ )
+ cygphase = FloatProperty(
+ name="Phase", min=-4, max=4,
+ description="Rotate around pivot x/y",
+ default=0
+ )
+ # Parabola
+ paxres = IntProperty(
+ name="Resolution x/y",
+ min=3, max=32,
+ description="Number of faces around x/y",
+ default=5
+ )
+ payres = IntProperty(
+ name="Resolution z",
+ min=3, max=32,
+ description="Number of faces in z direction",
+ default=5
+ )
+ paxsz = FloatProperty(
+ name="Scale x/y",
+ min=0.001, max=10,
+ description="scale in x/y direction",
+ default=0.30
+ )
+ paysz = FloatProperty(
+ name="Scale z",
+ min=0.001, max=10,
+ description="Scale in z direction",
+ default=1
+ )
+ paxell = FloatProperty(
+ name="Stretch x",
+ min=0.001, max=4,
+ description="Stretch in x direction",
+ default=1
+ )
+ pagap = FloatProperty(
+ name="Gap",
+ min=-2, max=2,
+ description="Shrink in % around radius",
+ default=1
+ )
+ pagphase = FloatProperty(
+ name="Phase",
+ min=-4, max=4,
+ description="Rotate around pivot x/y",
+ default=0
+ )
+ # Torus
+ ures = IntProperty(
+ name="Resolution x/y",
+ min=3, max=32,
+ description="Number of faces around x/y",
+ default=8)
+ vres = IntProperty(
+ name="Resolution z",
+ min=3, max=32,
+ description="Number of faces in z direction",
+ default=8)
+ urad = FloatProperty(
+ name="Radius x/y",
+ min=0.001, max=10,
+ description="Radius in x/y plane",
+ default=1
+ )
+ vrad = FloatProperty(
+ name="Radius z",
+ min=0.001, max=10,
+ description="Radius in z plane",
+ default=0.250
+ )
+ uellipse = FloatProperty(
+ name="Stretch x",
+ min=0.001, max=10,
+ description="Number of faces in z direction",
+ default=1
+ )
+ vellipse = FloatProperty(
+ name="Stretch z",
+ min=0.001, max=10,
+ description="Number of faces in z direction",
+ default=1
+ )
+ upart = FloatProperty(
+ name="Gap x/y",
+ min=-4, max=4,
+ description="Shrink faces around x/y",
+ default=1
+ )
+ vpart = FloatProperty(
+ name="Gap z",
+ min=-4, max=4,
+ description="Shrink faces in z direction",
+ default=1
+ )
+ ugap = FloatProperty(
+ name="Phase x/y",
+ min=-4, max=4,
+ description="Rotate around pivot x/y",
+ default=0
+ )
+ vgap = FloatProperty(
+ name="Phase z",
+ min=-4, max=4,
+ description="Rotate around pivot z",
+ default=0
+ )
+ uphase = FloatProperty(
+ name="uphase",
+ min=-4, max=4,
+ description="Number of faces in z direction",
+ default=0
+ )
+ vphase = FloatProperty(
+ name="vphase",
+ min=-4, max=4,
+ description="Number of faces in z direction",
+ default=0
+ )
+ uexp = FloatProperty(
+ name="uexp",
+ min=-4, max=4,
+ description="Number of faces in z direction",
+ default=0
+ )
+ vexp = FloatProperty(
+ name="vexp",
+ min=-4, max=4,
+ description="Number of faces in z direction",
+ default=0
+ )
+ usuper = FloatProperty(
+ name="usuper",
+ min=-4, max=4,
+ description="First set of superform parameters",
+ default=2
+ )
+ vsuper = FloatProperty(
+ name="vsuper",
+ min=-4, max=4,
+ description="Second set of superform parameters",
+ default=2
+ )
+ utwist = FloatProperty(
+ name="Twist x/y",
+ min=-4, max=4,
+ description="Use with superformular u",
+ default=0
+ )
+ vtwist = FloatProperty(
+ name="Twist z",
+ min=-4, max=4,
+ description="Use with superformular v",
+ default=0
+ )
+ # Sphere
+ bures = IntProperty(
+ name="Resolution x/y",
+ min=3, max=32,
+ description="Number of faces around x/y",
+ default=8
+ )
+ bvres = IntProperty(
+ name="Resolution z",
+ min=3, max=32,
+ description="Number of faces in z direction",
+ default=8
+ )
+ burad = FloatProperty(
+ name="Radius",
+ min=-4, max=4,
+ description="overall radius",
+ default=1
+ )
+ bupart = FloatProperty(
+ name="Gap x/y",
+ min=-4, max=4,
+ description="Shrink faces around x/y",
+ default=1
+ )
+ bvpart = FloatProperty(
+ name="Gap z",
+ min=-4, max=4,
+ description="Shrink faces in z direction",
+ default=1
+ )
+ buphase = FloatProperty(
+ name="Phase x/y",
+ min=-4, max=4,
+ description="Rotate around pivot x/y",
+ default=0
+ )
+ bvphase = FloatProperty(
+ name="Phase z",
+ min=-4, max=4,
+ description="Rotate around pivot z",
+ default=0
+ )
+ buellipse = FloatProperty(
+ name="Stretch x",
+ min=0.001, max=4,
+ description="Stretch in the x direction",
+ default=1
+ )
+ bvellipse = FloatProperty(
+ name="Stretch z",
+ min=0.001, max=4,
+ description="Stretch in the z direction",
+ default=1
+ )
+ # Grid
+ grxres = IntProperty(
+ name="Resolution x",
+ min=2, soft_max=10, max=20,
+ description="Number of faces in x direction",
+ default=5
+ )
+ gryres = IntProperty(
+ name="Resolution z",
+ min=2, soft_min=2,
+ soft_max=10, max=20,
+ description="Number of faces in x direction",
+ default=2
+ )
+ grxsz = FloatProperty(
+ name="X size",
+ min=1, soft_min=0.01,
+ soft_max=5, max=10,
+ description="X size",
+ default=2.0
+ )
+ grysz = FloatProperty(
+ name="Y size",
+ min=1, soft_min=0.01,
+ soft_max=5, max=10,
+ description="Y size",
+ default=1.0
+ )
+
+ # PKHG_TODO_??? what means cart
+ cart = IntProperty(
+ name="cart",
+ min=0, max=2,
+ default=0
+ )
+ frequency = IntProperty(
+ name="Frequency",
+ min=1, max=8,
+ description="Subdivide base triangles",
+ default=1
+ )
+ eccentricity = FloatProperty(
+ name="Eccentricity",
+ min=0.01, max=4,
+ description="Scaling in x/y dimension",
+ default=1
+ )
+ squish = FloatProperty(
+ name="Squish",
+ min=0.01,
+ soft_max=4, max=10,
+ description="Scaling in z dimension",
+ default=1
+ )
+ radius = FloatProperty(
+ name="Radius",
+ min=0.01,
+ soft_max=4, max=10,
+ description="Overall radius",
+ default=1
+ )
+ squareness = FloatProperty(
+ name="Square x/y",
+ min=0.1, max=5,
+ description="Superelipse action in x/y",
+ default=2
+ )
+ squarez = FloatProperty(
+ name="Square z",
+ min=0.1, soft_max=5, max=10,
+ description="Superelipse action in z",
+ default=2
+ )
+ baselevel = IntProperty(
+ name="baselevel",
+ default=5
+ )
+ dual = BoolProperty(
+ name="Dual",
+ description="Faces become verts, "
+ "verts become faces, edges flip",
+ default=False
+ )
+ rotxy = FloatProperty(
+ name="Rotate x/y",
+ min=-4, max=4,
+ description="Rotate superelipse action in x/y",
+ default=0
+ )
+ rotz = FloatProperty(
+ name="Rotate z",
+ min=-4, max=4,
+ description="Rotate superelipse action in z",
+ default=0
+ )
+
+ # for choice of superformula
+ uact = BoolProperty(
+ name="Superformula u (x/y)",
+ description="Activate superformula u parameters",
+ default=False
+ )
+ vact = BoolProperty(
+ name="Superformula v (z)",
+ description="Activate superformula v parameters",
+ default=False
+ )
+ um = FloatProperty(
+ name="Pinch x/y",
+ min=0, soft_min=0.1,
+ soft_max=5, max=10,
+ description="Pinch the mesh on x/y",
+ default=3
+ )
+ un1 = FloatProperty(
+ name="Squash x/y",
+ min=0, soft_min=0.1,
+ soft_max=5, max=20,
+ description="Squash the mesh x/y",
+ default=1
+ )
+ un2 = FloatProperty(
+ name="Inflate x/y",
+ min=0, soft_min=0.1,
+ soft_max=5, max=10,
+ description="Inflate the mesh x/y",
+ default=1
+ )
+ un3 = FloatProperty(
+ name="Roundify x/y",
+ min=0, soft_min=0.1,
+ soft_max=5, max=10,
+ description="Roundify x/y",
+ default=1
+ )
+ ua = FloatProperty(
+ name="Shrink",
+ min=0, soft_min=0.1,
+ soft_max=5, max=10,
+ description="Shrink",
+ default=1.0
+ )
+ ub = FloatProperty(
+ name="Shrink x/y",
+ min=0, soft_min=0.1,
+ soft_max=5, max=10,
+ description="Shrink y/x",
+ default=4.0
+ )
+ vm = FloatProperty(
+ name="Scale Z Base",
+ min=0, soft_min=0.1,
+ soft_max=5, max=10,
+ description="Scale Z Base",
+ default=1
+ )
+ vn1 = FloatProperty(
+ name="Scale lock Top Z",
+ min=0, soft_min=0.1,
+ soft_max=5, max=10,
+ description="Scale lock Top Z",
+ default=1
+ )
+ vn2 = FloatProperty(
+ name="Inflate Base",
+ min=0, soft_min=0.1,
+ soft_max=5, max=10,
+ description="Inflate Base",
+ default=1
+ )
+ vn3 = FloatProperty(
+ name="Inflate",
+ min=0, soft_min=0.1,
+ soft_max=5, max=10,
+ description="Inflate",
+ default=1
+ )
+ va = FloatProperty(
+ name="Scale 1",
+ min=0, soft_min=0.1,
+ soft_max=5, max=10,
+ description="Scale 1",
+ default=1
+ )
+ vb = FloatProperty(
+ name="Scale 2",
+ min=0, soft_min=0.1,
+ soft_max=5, max=10,
+ description="Scale 2",
+ default=1
+ )
+
+ uturn = FloatProperty(
+ name="x/y Vert cycle",
+ min=0, soft_min=0.1,
+ soft_max=5, max=10,
+ description="x/y Vert cycle",
+ default=0
+ )
+ vturn = FloatProperty(
+ name="z Vert cycle",
+ min=0, soft_min=0.1,
+ soft_max=5, max=10,
+ description="z Vert cycle",
+ default=0
+ )
+ utwist = FloatProperty(
+ name="x/y Twist cycle",
+ min=0, soft_min=0.1,
+ soft_max=5, max=10,
+ description="x/y Twist cycle",
+ default=0
+ )
+ vtwist = FloatProperty(
+ name="z Twist cycle",
+ min=0, soft_min=0.1,
+ soft_max=5, max=10,
+ description="z Twist cycle",
+ default=0
+ )
+ # Strut
+ struttype = IntProperty(
+ name="Strut type",
+ default=0
+ )
+ struttoggle = BoolProperty(
+ name="Use Struts",
+ default=False
+ )
+ strutimporttoggle = BoolProperty(
+ name="Strut import toggle",
+ default=False
+ )
+ strutimpmesh = StringProperty(
+ name="Strut import mesh",
+ default="None"
+ )
+ strutwidth = FloatProperty(
+ name="Strut width",
+ min=-10, soft_min=5,
+ soft_max=5, max=10,
+ default=1
+ )
+ swtog = BoolProperty(
+ name="Width enable",
+ default=False
+ )
+ strutheight = FloatProperty(
+ name="Strut height",
+ min=-5, soft_min=-1,
+ soft_max=5, max=10,
+ default=1
+ )
+ shtog = BoolProperty(
+ name="Height tweak",
+ default=False
+ )
+ strutshrink = FloatProperty(
+ name="Strut shrink",
+ min=0.001, max=4,
+ default=1
+ )
+ sstog = BoolProperty(
+ name="Shrink tweak",
+ default=False
+ )
+ stretch = FloatProperty(
+ name="Stretch",
+ min=-4, max=4,
+ default=1.0
+ )
+ lift = FloatProperty(
+ name="Lift",
+ min=0.001, max=10,
+ default=0
+ )
+ smeshname = StringProperty(
+ name="Strut mesh name",
+ default="defaultstrut"
+ )
+ # Hubs
+ hubtype = BoolProperty(
+ name="Hub type",
+ description="not used",
+ default=True
+ )
+ hubtoggle = BoolProperty(
+ name="Use Hubs",
+ default=False
+ )
+ hubimporttoggle = BoolProperty(
+ name="New import",
+ description="Import a mesh",
+ default=False
+ )
+ hubimpmesh = StringProperty(
+ name="Hub mesh import",
+ description="Name of mesh to import",
+ default="None"
+ )
+ hubwidth = FloatProperty(
+ name="Hub width",
+ min=0.01, max=10,
+ default=1
+ )
+ hwtog = BoolProperty(
+ name="Width tweak",
+ default=False
+ )
+ hubheight = FloatProperty(
+ name="Hub height",
+ min=0.01, max=10,
+ default=1
+ )
+ hhtog = BoolProperty(
+ name="Height tweak",
+ default=False
+ )
+ hublength = FloatProperty(
+ name="Hub length",
+ min=0.1, max=10,
+ default=1
+ )
+ hstog = BoolProperty(
+ name="Hub s tweak",
+ default=False
+ )
+ hmeshname = StringProperty(
+ name="Hub mesh name",
+ description="Name of an existing mesh needed!",
+ default="None"
+ )
+ name_list = [
+ 'facetype_menu', 'facetoggle', 'face_use_imported_object',
+ 'facewidth', 'fwtog', 'faceheight', 'fhtog',
+ 'face_detach', 'fmeshname', 'geodesic_types', 'import_mesh_name',
+ 'base_type', 'orientation', 'geodesic_class', 'tri_hex_star',
+ 'spherical_flat', 'use_imported_mesh', 'cyxres', 'cyyres',
+ 'cyxsz', 'cyysz', 'cyxell', 'cygap',
+ 'cygphase', 'paxres', 'payres', 'paxsz',
+ 'paysz', 'paxell', 'pagap', 'pagphase',
+ 'ures', 'vres', 'urad', 'vrad',
+ 'uellipse', 'vellipse', 'upart', 'vpart',
+ 'ugap', 'vgap', 'uphase', 'vphase',
+ 'uexp', 'vexp', 'usuper', 'vsuper',
+ 'utwist', 'vtwist', 'bures', 'bvres',
+ 'burad', 'bupart', 'bvpart', 'buphase',
+ 'bvphase', 'buellipse', 'bvellipse', 'grxres',
+ 'gryres', 'grxsz', 'grysz',
+ 'cart', 'frequency', 'eccentricity', 'squish',
+ 'radius', 'squareness', 'squarez', 'baselevel',
+ 'dual', 'rotxy', 'rotz',
+ 'uact', 'vact', 'um', 'un1',
+ 'un2', 'un3', 'ua', 'ub',
+ 'vm', 'vn1', 'vn2', 'vn3',
+ 'va', 'vb', 'uturn', 'vturn',
+ 'utwist', 'vtwist', 'struttype', 'struttoggle',
+ 'strutimporttoggle', 'strutimpmesh', 'strutwidth', 'swtog',
+ 'strutheight', 'shtog', 'strutshrink', 'sstog',
+ 'stretch', 'lift', 'smeshname', 'hubtype',
+ 'hubtoggle', 'hubimporttoggle', 'hubimpmesh', 'hubwidth',
+ 'hwtog', 'hubheight', 'hhtog', 'hublength',
+ 'hstog', 'hmeshname'
+ ]
+
+ def write_params(self, filename):
file = open(filename, "w", encoding="utf8", newline="\n")
fw = file.write
- #for Faces!
+ # for Faces!
for el in self.name_list:
fw(el + ", ")
- fw(repr(getattr(self,el)))
- fw(",\n")
+ fw(repr(getattr(self, el)))
+ fw(", \n")
file.close()
- def read_file(self,filename):
+ def read_file(self, filename):
file = open(filename, "r", newline="\n")
result = []
line = file.readline()
while(line):
- tmp = line.split(", ")
+ tmp = line.split(", ")
result.append(eval(tmp[1]))
line = file.readline()
return result
-
- def draw(self,context):
- sce = context.scene
+ def draw(self, context):
layout = self.layout
row = layout.row()
-# row.prop(self, "save_parameters")
-# row.prop(self, "load_parameters")
col = layout.column()
- col.label(" ")
col.prop(self, "mainpages")
which_mainpages = self.mainpages
if which_mainpages == 'Main':
@@ -512,15 +931,15 @@ class GenerateGeodesicDome(bpy.types.Operator):
elif tmp == 'Import your mesh':
col.prop(self, "use_imported_mesh")
col.prop(self, "import_mesh_name")
-#######superform parameters only where possible
+ # superform parameters only where possible
row = layout.row()
row.prop(self, "uact")
row = layout.row()
row.prop(self, "vact")
row = layout.row()
if not(tmp == 'Import your mesh'):
- if (self.uact == False) and (self.vact == False):
- row.label("no checkbox active!")
+ if (self.uact is False) and (self.vact is False):
+ row.label(text="No checkbox active", icon="INFO")
else:
row.label("Superform Parameters")
if self.uact:
@@ -557,23 +976,20 @@ class GenerateGeodesicDome(bpy.types.Operator):
row.prop(self, "vturn")
row = layout.row()
row.prop(self, "vtwist")
-########einde superform
- elif which_mainpages == "Hubs":
+ # einde superform
+ elif which_mainpages == "Hubs":
row = layout.row()
row.prop(self, "hubtoggle")
-
- row = layout.row()
-
row = layout.row()
if self.hubimpmesh == "None":
row = layout.row()
- row.label("name of a hub to use")
+ row.label("Name of a hub to use")
row = layout.row()
row.prop(self, "hubimpmesh")
row = layout.row()
if self.hmeshname == "None":
row = layout.row()
- row.label("name of mesh to be filled in!")
+ row.label("Name of mesh to be filled in")
row = layout.row()
row.prop(self, "hmeshname")
row = layout.row()
@@ -604,7 +1020,7 @@ class GenerateGeodesicDome(bpy.types.Operator):
row = layout.row()
row.prop(self, "sstog")
if self.sstog:
- row.prop(self, "strutshrink")
+ row.prop(self, "strutshrink")
row = layout.row()
row.prop(self, "stretch")
row = layout.row()
@@ -632,7 +1048,7 @@ class GenerateGeodesicDome(bpy.types.Operator):
row.prop(self, "fmeshname")
row = layout.row()
- #help menu GUI
+ # help menu GUI
elif which_mainpages == "Help":
import textwrap
@@ -642,39 +1058,39 @@ class GenerateGeodesicDome(bpy.types.Operator):
# other parameters are ui : here you usually pass layout
# text: is a list with each index representing a line of text
- def multi_label(text, ui,text_width=120):
- for x in range(0,len(text)):
- el = textwrap.wrap(text[x], width = text_width )
+ def multi_label(text, ui, text_width=120):
+ for x in range(0, len(text)):
+ el = textwrap.wrap(text[x], width=text_width)
- for y in range(0,len(el)):
+ for y in range(0, len(el)):
ui.label(text=el[y])
box = layout.box()
help_text = ["NEW!",
- "New facility: save or load (nearly all) parameters",
- "A file GD_0.GD will be used, living in:",
- "geodesic_domes/tmp",
- "--------",
- "After loading you have to change a ",
- "parameter back and forth"
- "to see it"]
+ "Save or load (nearly all) parameters",
+ "A file GD_0.GD will be used, living in:",
+ "geodesic_domes/tmp",
+ "--------",
+ "After loading you have to change a ",
+ "parameter back and forth "
+ "to see it"]
text_width = self.gd_help_text_width
- box.prop(self, "gd_help_text_width",slider=True)
- multi_label(help_text,box, text_width)
+ box.prop(self, "gd_help_text_width", slider=True)
+ multi_label(help_text, box, text_width)
def execute(self, context):
global last_generated_object, last_imported_mesh, basegeodesic, imported_hubmesh_to_use
- #default superformparam = [3, 10, 10, 10, 1, 1, 4, 10, 10, 10, 1, 1, 0, 0, 0.0, 0.0, 0, 0]]
- superformparam = [self.um, self.un1, self.un2, self.un3, self.ua,\
- self.ub, self.vm, self.vn1, self.vn2, self.vn3,\
- self.va, self.vb, self.uact, self.vact,\
- self.uturn*pi, self.vturn*pi, \
+ # default superformparam = [3, 10, 10, 10, 1, 1, 4, 10, 10, 10, 1, 1, 0, 0, 0.0, 0.0, 0, 0]]
+ superformparam = [self.um, self.un1, self.un2, self.un3, self.ua,
+ self.ub, self.vm, self.vn1, self.vn2, self.vn3,
+ self.va, self.vb, self.uact, self.vact,
+ self.uturn * pi, self.vturn * pi,
self.utwist, self.vtwist]
context.scene.error_message = ""
if self.mainpages == 'Main':
if self.geodesic_types == "Geodesic":
tmp_fs = self.tri_hex_star
- faceshape = 0 # tri!
+ faceshape = 0 # tri!
if tmp_fs == "hex":
faceshape = 1
elif tmp_fs == "star":
@@ -684,83 +1100,90 @@ class GenerateGeodesicDome(bpy.types.Operator):
if tmp_cl == "Class 2":
klass = 1
shape = 0
- parameters = [self.frequency, self.eccentricity, self.squish,\
- self.radius, self.squareness, self.squarez, 0,\
- shape, self.baselevel, faceshape, self.dual,\
- self.rotxy, self.rotz, klass, superformparam]
- basegeodesic = creategeo(self.base_type,self.orientation,parameters)
+ parameters = [self.frequency, self.eccentricity, self.squish,
+ self.radius, self.squareness, self.squarez, 0,
+ shape, self.baselevel, faceshape, self.dual,
+ self.rotxy, self.rotz, klass, superformparam]
+
+ basegeodesic = creategeo(self.base_type, self.orientation, parameters)
basegeodesic.makegeodesic()
basegeodesic.connectivity()
mesh = vefm_271.mesh()
- vefm_271.finalfill(basegeodesic,mesh) #always! for hexifiy etc. necessarry!!!
+ vefm_271.finalfill(basegeodesic, mesh) # always! for hexifiy etc. necessarry!!!
vefm_271.vefm_add_object(mesh)
last_generated_object = context.active_object
- last_generated_object.location = (0,0,0)
+ last_generated_object.location = (0, 0, 0)
context.scene.objects.active = last_generated_object
elif self.geodesic_types == 'Grid':
- basegeodesic = forms_271.grid(self.grxres,self.gryres,\
- self.grxsz,self.grysz,1.0,1.0,0,0,0,\
- 0,1.0,1.0,superformparam)
+ basegeodesic = forms_271.grid(self.grxres, self.gryres,
+ self.grxsz, self.grysz, 1.0, 1.0, 0, 0, 0,
+ 0, 1.0, 1.0, superformparam)
vefm_271.vefm_add_object(basegeodesic)
- bpy.data.objects[-1].location = (0,0,0)
+ bpy.data.objects[-1].location = (0, 0, 0)
elif self.geodesic_types == "Cylinder":
- basegeodesic = forms_271.cylinder(self.cyxres, self.cyyres, \
- self.cyxsz, self.cyysz, self.cygap, \
- 1.0, self.cygphase, 0, 0, 0, self.cyxell,\
- 1.0, superformparam)
+ basegeodesic = forms_271.cylinder(
+ self.cyxres, self.cyyres,
+ self.cyxsz, self.cyysz, self.cygap,
+ 1.0, self.cygphase, 0, 0, 0, self.cyxell,
+ 1.0, superformparam
+ )
vefm_271.vefm_add_object(basegeodesic)
- bpy.data.objects[-1].location = (0,0,0)
+ bpy.data.objects[-1].location = (0, 0, 0)
elif self.geodesic_types == "Parabola":
- basegeodesic=forms_271.parabola(self.paxres, self.payres,\
- self.paxsz, self.paysz, self.pagap,1.0, self.pagphase,\
- 0,0,0, self.paxell,1.0,superformparam)
+ basegeodesic = forms_271.parabola(
+ self.paxres, self.payres,
+ self.paxsz, self.paysz, self.pagap, 1.0, self.pagphase,
+ 0, 0, 0, self.paxell, 1.0, superformparam
+ )
vefm_271.vefm_add_object(basegeodesic)
- bpy.data.objects[-1].location = (0,0,0)
+ bpy.data.objects[-1].location = (0, 0, 0)
elif self.geodesic_types == "Torus":
- basegeodesic = forms_271.torus(self.ures, self.vres,\
- self.vrad, self.urad, self.upart, self.vpart,\
- self.ugap, self.vgap,0,0, self.uellipse,\
- self.vellipse, superformparam)
+ basegeodesic = forms_271.torus(
+ self.ures, self.vres,
+ self.vrad, self.urad, self.upart, self.vpart,
+ self.ugap, self.vgap, 0, 0, self.uellipse,
+ self.vellipse, superformparam
+ )
vefm_271.vefm_add_object(basegeodesic)
- bpy.data.objects[-1].location = (0,0,0)
+ bpy.data.objects[-1].location = (0, 0, 0)
elif self.geodesic_types == "Sphere":
- basegeodesic=forms_271.sphere(self.bures, self.bvres,\
- self.burad,1.0, self.bupart, self.bvpart,\
- self.buphase, self.bvphase,0,0, self.buellipse,\
- self.bvellipse,superformparam)
+ basegeodesic = forms_271.sphere(
+ self.bures, self.bvres,
+ self.burad, 1.0, self.bupart, self.bvpart,
+ self.buphase, self.bvphase, 0, 0, self.buellipse,
+ self.bvellipse, superformparam
+ )
vefm_271.vefm_add_object(basegeodesic)
- bpy.data.objects[-1].location = (0,0,0)
+ bpy.data.objects[-1].location = (0, 0, 0)
elif self.geodesic_types == "Import your mesh":
obj_name = self.import_mesh_name
if obj_name == "None":
- message = "fill in a name \nof an existing mesh\nto be imported"
+ message = "Fill in a name \nof an existing mesh\nto be imported"
context.scene.error_message = message
self.report({"INFO"}, message)
- print("***INFO*** you have to fill in the name of an existing mesh")
+ print("***INFO*** You have to fill in the name of an existing mesh")
else:
-# obj_in_scene = context.objects
names = [el.name for el in context.scene.objects]
if obj_name in names and context.scene.objects[obj_name].type == "MESH":
obj = context.scene.objects[obj_name]
-# if obj.type == "MESH":
- your_obj = vefm_271.importmesh(obj.name,False)
+ your_obj = vefm_271.importmesh(obj.name, False)
last_imported_mesh = your_obj
vefm_271.vefm_add_object(your_obj)
last_generated_object = bpy.context.active_object
- last_generated_object.name ="Imported mesh"
- bpy.context.active_object.location = (0,0,0)
+ last_generated_object.name = "Imported mesh"
+ bpy.context.active_object.location = (0, 0, 0)
else:
- message = obj_name +" does not exist \nor is not a MESH"
+ message = obj_name + " does not exist \nor is not a Mesh"
context.scene.error_message = message
bpy.ops.object.dialog_operator('INVOKE_DEFAULT')
self.report({'ERROR'}, message)
- print("***ERROR***" + obj_name +" does not exist or is not a MESH")
+ print("***ERROR***" + obj_name + " does not exist or is not a Mesh")
elif self.mainpages == "Hubs":
hubtype = self.hubtype
- hubtoggle = self.hubtoggle
+ hubtoggle = self.hubtoggle
hubimporttoggle = self.hubimporttoggle
hubimpmesh = self.hubimpmesh
hubwidth = self.hubwidth
@@ -768,31 +1191,32 @@ class GenerateGeodesicDome(bpy.types.Operator):
hubheight = self.hubheight
hhtog = self.hhtog
hublength = self.hublength
- hstog = self.hstog
- hmeshname= self.hmeshname
+ hstog = self.hstog
+ hmeshname = self.hmeshname
- if not (hmeshname == "None") and not (hubimpmesh == "None") and hubtoggle:
+ if not (hmeshname == "None") and not (hubimpmesh == "None") and hubtoggle:
try:
+ hub_obj = vefm_271.importmesh(hmeshname, 0)
- hub_obj = vefm_271.importmesh(hmeshname,0)
-
- hub = vefm_271.hub(hub_obj, True,\
- hubwidth, hubheight, hublength,\
- hwtog, hhtog, hstog, hubimpmesh)
-
+ hub = vefm_271.hub(
+ hub_obj, True,
+ hubwidth, hubheight, hublength,
+ hwtog, hhtog, hstog, hubimpmesh
+ )
mesh = vefm_271.mesh("test")
- vefm_271.finalfill(hub,mesh)
+ vefm_271.finalfill(hub, mesh)
vefm_271.vefm_add_object(mesh)
- bpy.data.objects[-1].location = (0,0,0)
+ bpy.data.objects[-1].location = (0, 0, 0)
except:
- message = "***ERROR third_domes_panel L811 *** \neither no mesh for hub\nor " + hmeshname + " available"
+ message = "***ERROR*** \nEither no mesh for hub\nor " + \
+ hmeshname + " available"
context.scene.error_message = message
bpy.ops.object.dialog_operator('INVOKE_DEFAULT')
print(message)
else:
- message = "***INFO***\nuse the hub toggle!"
+ message = "***INFO***\nEnable Hubs first"
context.scene.error_message = message
- print("\n***INFO*** use the hub toggle!")
+ print("\n***INFO*** Enable Hubs first")
elif self.mainpages == "Struts":
struttype = self.struttype
struttoggle = self.struttoggle
@@ -810,77 +1234,85 @@ class GenerateGeodesicDome(bpy.types.Operator):
if not (strutimpmesh == "None") and struttoggle:
names = [el.name for el in context.scene.objects]
if strutimpmesh in names and context.scene.objects[strutimpmesh].type == "MESH":
- strut = vefm_271.strut(basegeodesic, struttype, strutwidth,\
- strutheight, stretch, swtog, shtog, swtog,\
- strutimpmesh, sstog, lift)
+ strut = vefm_271.strut(
+ basegeodesic, struttype, strutwidth,
+ strutheight, stretch, swtog, shtog, swtog,
+ strutimpmesh, sstog, lift
+ )
strutmesh = vefm_271.mesh()
- vefm_271.finalfill(strut,strutmesh)
+ vefm_271.finalfill(strut, strutmesh)
vefm_271.vefm_add_object(strutmesh)
last_generated_object = context.active_object
last_generated_object.name = smeshname
- last_generated_object.location = (0,0,0)
+ last_generated_object.location = (0, 0, 0)
else:
- message = "***ERROR***\n" + strutimpmesh + "\nis not a MESH"
+ message = "***ERROR***\nStrut object " + strutimpmesh + "\nis not a Mesh"
context.scene.error_message = message
bpy.ops.object.dialog_operator('INVOKE_DEFAULT')
- print("***ERROR*** strut obj is not a MESH")
+ print("***ERROR*** Strut object is not a Mesh")
else:
vefm_271.vefm_add_object(basegeodesic)
elif self.mainpages == "Faces":
if self.facetoggle:
- faceparams=[[self.face_detach,0,[[0.5,0.0]]], #0 strip
- [self.face_detach,0,[[0.0,0.5]]], #1 vertical
- [self.face_detach,0,[[0.5,0.5]]], #2 slanted
- [self.face_detach,1,[[0.25,0.25],[0.5,0.5]]], #3 closed point
- [self.face_detach,1,[[0.1,0.03],[0.33,0.06],[0.0,0.1]]], #4 pillow
- [self.face_detach,2,[[0.0,0.5]]], #5 closed vertical
- [self.face_detach,2,[[0.0,0.25],[0.25,0.25],[0.25,0.5]]], #6 stepped
- [self.face_detach,1,[[0.2,0.1],[0.4,0.2],[0.0,1.0]]], #7 spikes
- [self.face_detach,3,[[0.25,0.0],[0.25,0.5],[0.0,0.5]]], #8 boxed
- [self.face_detach,3,[[0.25,0.5],[0.5,0.0],[0.25,-0.5]]], #9 diamond
- [self.face_detach,4,[[0.5,0.0],[0.5,0.5],[0.0,0.5]]],] #10 bar
+ faceparams = [[self.face_detach, 0, [[0.5, 0.0]]], # 0 strip
+ [self.face_detach, 0, [[0.0, 0.5]]], # 1 vertical
+ [self.face_detach, 0, [[0.5, 0.5]]], # 2 slanted
+ [self.face_detach, 1, [[0.25, 0.25], [0.5, 0.5]]], # 3 closed point
+ [self.face_detach, 1, [[0.1, 0.03], [0.33, 0.06], [0.0, 0.1]]], # 4 pillow
+ [self.face_detach, 2, [[0.0, 0.5]]], # 5 closed vertical
+ [self.face_detach, 2, [[0.0, 0.25], [0.25, 0.25], [0.25, 0.5]]], # 6 stepped
+ [self.face_detach, 1, [[0.2, 0.1], [0.4, 0.2], [0.0, 1.0]]], # 7 spikes
+ [self.face_detach, 3, [[0.25, 0.0], [0.25, 0.5], [0.0, 0.5]]], # 8 boxed
+ [self.face_detach, 3, [[0.25, 0.5], [0.5, 0.0], [0.25, -0.5]]], # 9 diamond
+ [self.face_detach, 4, [[0.5, 0.0], [0.5, 0.5], [0.0, 0.5]]], ] # 10 bar
facedata = faceparams[int(self.facetype_menu)]
if not self.face_use_imported_object:
- faceobject = vefm_271.facetype(basegeodesic, facedata, self.facewidth,\
- self.faceheight,self.fwtog)
+ faceobject = vefm_271.facetype(
+ basegeodesic, facedata, self.facewidth,
+ self.faceheight, self.fwtog
+ )
else:
if last_imported_mesh:
- faceobject = vefm_271.facetype(last_imported_mesh, facedata,\
- self.facewidth, self.faceheight, self.fwtog)
+ faceobject = vefm_271.facetype(
+ last_imported_mesh, facedata,
+ self.facewidth, self.faceheight, self.fwtog
+ )
else:
- message = "***ERROR***\nno imported message available\n" + "last geodesic used"
+ message = "***ERROR***\nNo imported message available\n" + "last geodesic used"
context.scene.error_message = message
bpy.ops.object.dialog_operator('INVOKE_DEFAULT')
- print("\n***ERROR*** no imported mesh available")
- print("last geodesic used!")
- faceobject = vefm_271.facetype(basegeodesic,facedata,\
- self.facewidth,self.faceheight,self.fwtog)
+ print("\n***ERROR*** No imported mesh available \nLast geodesic used!")
+ faceobject = vefm_271.facetype(
+ basegeodesic, facedata,
+ self.facewidth, self.faceheight, self.fwtog
+ )
facemesh = vefm_271.mesh()
finalfill(faceobject, facemesh)
vefm_271.vefm_add_object(facemesh)
obj = bpy.data.objects[-1]
obj.name = self.fmeshname
- obj.location = (0,0,0)
-#PKHG save or load (nearly) all parameters
+ obj.location = (0, 0, 0)
+
+ # PKHG save or load (nearly) all parameters
if self.save_parameters:
self.save_parameters = False
try:
scriptpath = bpy.utils.script_paths()[0]
sep = os.path.sep
- tmpdir = os.path.join(scriptpath, "addons", "add_mesh_extra_objects" , "tmp")
-#scriptpath + sep + "addons" + sep + "geodesic_domes" + sep + "tmp"
+ tmpdir = os.path.join(scriptpath, "addons", "add_mesh_extra_objects", "tmp")
+ # scriptpath + sep + "addons" + sep + "geodesic_domes" + sep + "tmp"
if not os.path.isdir(tmpdir):
message = "***ERROR***\n" + tmpdir + "\nnot (yet) available"
filename = tmpdir + sep + "GD_0.GD"
-# self.read_file(filename)
+ # self.read_file(filename)
try:
self.write_params(filename)
- message = "***OK***\nparameters saved in\n" + filename
+ message = "***OK***\nParameters saved in\n" + filename
print(message)
except:
- message = "***ERRROR***\n" + "writing " + filename + "\nnot possible"
- #bpy.context.scene.instant_filenames = filenames
+ message = "***ERRROR***\n" + "Writing " + filename + "\nis not possible"
+ # bpy.context.scene.instant_filenames = filenames
except:
message = "***ERROR***\n Contakt PKHG, something wrong happened"
@@ -894,26 +1326,27 @@ class GenerateGeodesicDome(bpy.types.Operator):
scriptpath = bpy.utils.script_paths()[0]
sep = os.path.sep
tmpdir = os.path.join(scriptpath, "addons", "add_mesh_extra_objects", "tmp")
- #PKHG>NEXT comment????
- #scriptpath + sep + "addons" + sep + "geodesic_domes" + sep + "tmp"
+ # PKHG>NEXT comment????
+ # scriptpath + sep + "addons" + sep + "geodesic_domes" + sep + "tmp"
if not os.path.isdir(tmpdir):
- message = "***ERROR***\n" + tmpdir + "\nnot available"
+ message = "***ERROR***\n" + tmpdir + "\nis not available"
print(message)
filename = tmpdir + sep + "GD_0.GD"
-# self.read_file(filename)
+ # self.read_file(filename)
try:
res = self.read_file(filename)
- for i,el in enumerate(self.name_list):
- setattr(self,el,res[i])
+ for i, el in enumerate(self.name_list):
+ setattr(self, el, res[i])
message = "***OK***\nparameters read from\n" + filename
print(message)
except:
- message = "***ERRROR***\n" + "writing " + filename + "\nnot possible"
- #bpy.context.scene.instant_filenames = filenames
+ message = "***ERRROR***\n" + "Writing " + filename + "\nnot possible"
+ # bpy.context.scene.instant_filenames = filenames
except:
message = "***ERROR***\n Contakt PKHG,\nsomething went wrong reading params happened"
context.scene.error_message = message
bpy.ops.object.dialog_operator('INVOKE_DEFAULT')
+
return {'FINISHED'}
def invoke(self, context, event):
@@ -923,44 +1356,48 @@ class GenerateGeodesicDome(bpy.types.Operator):
if tmp:
context.scene.geodesic_not_yet_called = False
self.execute(context)
+
return {'FINISHED'}
-def creategeo(polytype,orientation,parameters):
+
+def creategeo(polytype, orientation, parameters):
geo = None
if polytype == "Tetrahedron":
if orientation == "PointUp":
geo = geodesic_classes_271.tetrahedron(parameters)
elif orientation == "EdgeUp":
- geo=geodesic_classes_271.tetraedge(parameters)
+ geo = geodesic_classes_271.tetraedge(parameters)
elif orientation == "FaceUp":
- geo=geodesic_classes_271.tetraface(parameters)
+ geo = geodesic_classes_271.tetraface(parameters)
elif polytype == "Octahedron":
if orientation == "PointUp":
- geo=geodesic_classes_271.octahedron(parameters)
+ geo = geodesic_classes_271.octahedron(parameters)
elif orientation == "EdgeUp":
- geo=geodesic_classes_271.octaedge(parameters)
+ geo = geodesic_classes_271.octaedge(parameters)
elif orientation == "FaceUp":
- geo=geodesic_classes_271.octaface(parameters)
+ geo = geodesic_classes_271.octaface(parameters)
elif polytype == "Icosahedron":
if orientation == "PointUp":
- geo=geodesic_classes_271.icosahedron(parameters)
+ geo = geodesic_classes_271.icosahedron(parameters)
elif orientation == "EdgeUp":
- geo=geodesic_classes_271.icoedge(parameters)
+ geo = geodesic_classes_271.icoedge(parameters)
elif orientation == "FaceUp":
- geo=geodesic_classes_271.icoface(parameters)
+ geo = geodesic_classes_271.icoface(parameters)
return geo
-basegeodesic,fmeshname,smeshname,hmeshname,outputmeshname,strutimpmesh,hubimpmesh = [None]*7
-def finalfill(source,target):
- count=0
+basegeodesic, fmeshname, smeshname, hmeshname, outputmeshname, strutimpmesh, hubimpmesh = [None] * 7
+
+
+def finalfill(source, target):
+ count = 0
for point in source.verts:
newvert = vefm_271.vertex(point.vector)
target.verts.append(newvert)
point.index = count
- count += 1
+ count += 1
for facey in source.faces:
- row=len(facey.vertices)
+ row = len(facey.vertices)
if row >= 5:
newvert = vefm_271.average(facey.vertices).centroid()
centre = vefm_271.vertex(newvert.vector)
@@ -971,9 +1408,9 @@ def finalfill(source,target):
b = target.verts[facey.vertices[0].index]
else:
a = target.verts[facey.vertices[i].index]
- b = target.verts[facey.vertices[i+1].index]
+ b = target.verts[facey.vertices[i + 1].index]
c = centre
- f = [a,b,c]
+ f = [a, b, c]
target.faces.append(f)
else:
f = []
@@ -983,12 +1420,13 @@ def finalfill(source,target):
f.append(target.verts[a.index])
target.faces.append(f)
-###for error messages
-class DialogOperator(bpy.types.Operator):
+
+# for error messages
+class DialogOperator(Operator):
bl_idname = "object.dialog_operator"
bl_label = "INFO"
- def draw(self,context):
+ def draw(self, context):
layout = self.layout
message = context.scene.error_message
col = layout.column()
@@ -1004,13 +1442,12 @@ class DialogOperator(bpy.types.Operator):
return wm.invoke_props_dialog(self)
-######### register all
def register():
bpy.utils.register_module(__name__)
+
def unregister():
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()
-
diff --git a/add_mesh_extra_objects/geodesic_domes/vefm_271.py b/add_mesh_extra_objects/geodesic_domes/vefm_271.py
index f9965ec7..cac2b74d 100644
--- a/add_mesh_extra_objects/geodesic_domes/vefm_271.py
+++ b/add_mesh_extra_objects/geodesic_domes/vefm_271.py
@@ -1,26 +1,23 @@
# vert class and overloading experiments
import bpy
-#PKHG>NEEDED?
+# PKHG>NEEDED?
import bmesh
-import math
-from math import sqrt,acos,pi,sin,cos,atan,tan,fabs
+from math import acos, pi, sin, cos, atan, tan
from mathutils import Vector
+from bpy_extras.object_utils import AddObjectHelper, object_data_add
-#PKHG>DBG change the DBG_info and use extra_DBG_info
-DBG_info ={"MeshInfo":False, "StrutMesh":False, "HubMesh":False}
+# PKHG>DBG change the DBG_info and use extra_DBG_info
+DBG_info = {"MeshInfo": False, "StrutMesh": False, "HubMesh": False}
-def extra_DBG_info(name = "value from DBG_info", info_text="default\n", info_obj=None):
+def extra_DBG_info(name="value from DBG_info", info_text="default\n", info_obj=None):
global DBG_info
DBG_keys = DBG_info.keys()
if name in DBG_keys:
if DBG_info[name]:
print(info_text, info_obj)
-sgn = lambda x : (x>0) - (x<0) #missing signum function in Python
-
-from bpy_extras.object_utils import AddObjectHelper, object_data_add
-from collections import Counter
+sgn = lambda x: (x > 0) - (x < 0) # missing signum function in Python
def vefm_add_object(selfobj):
@@ -31,23 +28,23 @@ def vefm_add_object(selfobj):
e = [[edge.a.index, edge.b.index] for edge in selfobj.edges]
if type(selfobj.faces[0]) == type([]):
-
-#PKHG should be a list of vertices, which have an index
- f = [[v.index for v in face] for face in selfobj.faces]
+ # PKHG should be a list of vertices, which have an index
+ f = [[v.index for v in face] for face in selfobj.faces]
else:
- f = [[v.index for v in face.vertices] for face in selfobj.faces]
+ f = [[v.index for v in face.vertices] for face in selfobj.faces]
- m = bpy.data.meshes.new(name= selfobj.name)
- m.from_pydata(v, e, f )
+ m = bpy.data.meshes.new(name=selfobj.name)
+ m.from_pydata(v, e, f)
# useful for development when the mesh may be invalid.
- m.validate(verbose = False)
- object_data_add(bpy.context, m, operator = None)
+ m.validate(verbose=False)
+ object_data_add(bpy.context, m, operator=None)
+
-#extra test phase
+# extra test phase
class vertex:
- def __init__(self, vec=(0,0,0)): #default x = 0, y = 0, z = 0):
- self.vector = Vector(vec)
+ def __init__(self, vec=(0, 0, 0)): # default x = 0, y = 0, z = 0):
+ self.vector = Vector(vec)
self.length = self.vector.length
self.index = 0
self.normal = 0
@@ -56,19 +53,19 @@ class vertex:
self.boundary = 0
def findlength(self):
- self.length = self.vector.length
+ self.length = self.vector.length
def normalize(self):
self.findlength()
if self.length > 0:
- tmp = 1.0/self.length
- self.vector = tmp * self.vector
+ tmp = 1.0 / self.length
+ self.vector = tmp * self.vector
self.length = 1.0
def findnormal(self):
target = []
if self.faces[:] == []:
- print("vefm vertex L81 pkhg:*****ERROR**** findnormal has no faces")
+ print("vefm vertex L68 pkhg:*****ERROR**** findnormal has no faces")
return
for currentface in self.faces:
target.append(currentface.normal)
@@ -76,10 +73,10 @@ class vertex:
self.normal.findlength()
if self.length == 0:
print("******ERROR*** lenght zero in findnormal, j = (0,1,0) replcaced")
- self.normal = vertex((0,1,0))
+ self.normal = vertex((0, 1, 0))
self.normal.normalize()
- def clockwise(self): #PKHG self is a vertex
+ def clockwise(self): # PKHG self is a vertex
if self.boundary:
start = self.boundarystart()
else:
@@ -116,7 +113,7 @@ class vertex:
def __sub__(self, other):
if isinstance(other, Vector):
- tmp = self.vector - other
+ tmp = self.vector - other
else:
tmp = self.vector - other.vector
return vertex(tmp)
@@ -126,44 +123,47 @@ class vertex:
return vertex(tmp)
def __truediv__(self, other):
- denom = 1.0/other
+ denom = 1.0 / other
tmp = self.vector * denom
return (tmp)
def negative(self):
return vertex(-self.vector)
+
class crossp:
- ## Takes in two vertices(vectors), returns the cross product.
+ # Takes in two vertices(vectors), returns the cross product.
def __init__(self, v1, v2):
self.v1 = v1
self.v2 = v2
-#
+
def docrossproduct(self):
tmp = self.v1.vector.cross(self.v2.vector)
return vertex(tmp)
+
class average:
- ## Takes a list of vertices and returns the average. If two verts are passed, returns midpoint.
+ # Takes a list of vertices and returns the average. If two verts are passed, returns midpoint.
def __init__(self, vertlist):
self.vertlist = vertlist
def centroid(self):
- tmp = Vector()
-#PKHG avoid emptylist problems
+ tmp = Vector()
+ # PKHG avoid emptylist problems
divisor = 1.0
nr_vertices = len(self.vertlist)
if nr_vertices > 1:
divisor = 1.0 / len(self.vertlist)
elif nr_vertices == 0:
- print("\n***WARNING*** empty list in vefm_271.centroid! L180")
+ print("\n***WARNING*** empty list in vefm_271.centroid! L158")
for vert in self.vertlist:
tmp = tmp + vert.vector
tmp = tmp * divisor
return vertex(tmp)
+
class edge:
- def __init__(self, a = 0, b = 0):
+ def __init__(self, a=0, b=0):
self.a = a
self.b = b
self.index = 0
@@ -171,13 +171,12 @@ class edge:
self.cross = 0
self.unit = 0
self.faces = []
- self.vect = 0 #PKHG becomes b - a
- self.vectb = 0 #PKHG becomes a - b
+ self.vect = 0 # PKHG becomes b - a
+ self.vectb = 0 # PKHG becomes a - b
self.boundary = 0
self.findvect()
self.findlength()
-
def findvect(self):
self.vect = self.b - self.a
self.vectb = self.a - self.b
@@ -187,9 +186,8 @@ class edge:
self.vectb.length = self.vect.length
def findnormal(self):
-
if self.boundary:
- self.normal = self.faces[0].normal #average([self.a, self.b]).centroid()
+ self.normal = self.faces[0].normal # average([self.a, self.b]).centroid()
else:
self.normal = average([self.faces[0].normal, self.faces[1].normal]).centroid()
self.normal.normalize()
@@ -197,22 +195,23 @@ class edge:
class face:
def __init__(self, vertices=[]):
-#PKHG ok good for tri's at least
- self.vertices = vertices ## List of vertex instances.
- self.edges=[] ## Will be filled with the sides of the face.
- self.boundary = 0 ## When set will have bool and id of edge concerned.
- self.normal = 0 ## Face normal found through cross product.
- self.corners=[]
- self.spokes=[] ## Vectors of the bisecting angles from each corner
- ## to the centre + dotproduct.
+ # PKHG ok good for tri's at least
+ self.vertices = vertices # List of vertex instances
+ self.edges = [] # Will be filled with the sides of the face
+ self.boundary = 0 # When set will have bool and id of edge concerned
+ self.normal = 0 # Face normal found through cross product
+ self.corners = []
+ self.spokes = [] # Vectors of the bisecting angles from each corner to the centre + dotproduct
+
self.index = 0
- #dotproduct is misleading name, it is the hook between two vectors!
+ # dotproduct is misleading name, it is the hook between two vectors!
def dotproduct(self, v1, v2):
v1.findlength()
v2.findlength()
if v1.length == 0 or v2.length == 0:
- print("\nPKHG warning, =====vefm_271 dotproduct L245====== at least one zero vector 0 used")
+ print("\nPKHG warning, ===== vefm_271 dotproduct L212 ======"
+ " at least one zero vector 0 used")
return 0
dot = v1.vector.dot(v2.vector)
costheta = dot / (v1.length * v2.length)
@@ -220,63 +219,60 @@ class face:
return tmp
def orderedges(self):
- temp=[]
+ temp = []
finish = len(self.vertices)
for i in range(finish):
current = self.vertices[i]
- if i==finish-1:
+ if i == finish - 1:
next = self.vertices[0]
else:
- next = self.vertices[i+1]
+ next = self.vertices[i + 1]
for edge in face.edges:
- if edge.a==current and edge.b==next:
+ if edge.a == current and edge.b == next:
face.clockw.append(edge.vect)
face.aclockw.append(edge.vectb)
temp.append(edge)
- if edge.b==current and edge.a==next:
+ if edge.b == current and edge.a == next:
face.clockw.append(edge.vectb)
face.aclockw.append(edge.vect)
temp.append(edge)
for edge in face.edges:
- if edge.a==current and edge.b==next:
+ if edge.a == current and edge.b == next:
face.clockw.append(edge.vect)
face.aclockw.append(edge.vectb)
temp.append(edge)
- if edge.b==current and edge.a==next:
+ if edge.b == current and edge.a == next:
face.clockw.append(edge.vectb)
face.aclockw.append(edge.vect)
temp.append(edge)
face.vertices = temp
-
def docorners(self):
- ## This function identifies and stores the vectors coming from each vertex
- ## allowing easier calculation of cross and dot products.
+ # This function identifies and stores the vectors coming from each vertex
+ # allowing easier calculation of cross and dot products.
finish = len(self.vertices)
for i in range(finish):
current = self.vertices[i]
- if i==finish-1:
+ if i == finish - 1:
next = self.vertices[0]
else:
- next = self.vertices[i+1]
- if i==0:
+ next = self.vertices[i + 1]
+ if i == 0:
previous = self.vertices[-1]
else:
- previous = self.vertices[i-1]
- corner=[current] #PKHG new for each vertex = current
- #corner = current
+ previous = self.vertices[i - 1]
+ corner = [current] # PKHG new for each vertex = current
+ # corner = current
rightedge = None
leftedge = None
teller = -1
for edge in self.edges:
-
- if finish == 3 and len(self.edges) == 2 and i == 2:
+ if finish == 3 and len(self.edges) == 2 and i == 2:
return
teller += 1
- currentinfo = (current, edge.a, edge.b, edge.a is current, edge.b is current)
- #next and previous are vertex with respect to ith vertex
- if edge.a is current or edge.b is current: ## does this edge contain our current vert
+ # next and previous are vertex with respect to ith vertex
+ if edge.a is current or edge.b is current: # does this edge contain our current vert
if edge.a is current:
if edge.b is next:
rightedge = edge
@@ -299,7 +295,6 @@ class face:
corner.append(dotty)
self.corners.append(corner)
-
def findnormal(self):
one = self.corners[1][2]
two = self.corners[1][1]
@@ -316,7 +311,6 @@ class face:
self.normal.normalize()
def dospokes(self):
-
for corner in self.corners:
vert = corner[0]
right = corner[1]
@@ -332,7 +326,7 @@ class face:
one.normalize()
two.normalize()
- spoke = one+two
+ spoke = one + two
spoke.normalize()
self.spokes.append(spoke)
@@ -340,14 +334,15 @@ class face:
centre = average(self.vertices).centroid()
for point in self.vertices:
newedge = edge(point, centre)
- spokes.append(newedge)
+ self.spokes.append(newedge)
+
class mesh:
- def __init__(self , name="GD_mesh"):
+ def __init__(self, name="GD_mesh"):
self.name = name
- self.verts=[]
- self.edges=[]
- self.faces=[]
+ self.verts = []
+ self.edges = []
+ self.faces = []
self.edgeflag = 0
self.faceflag = 0
self.vertexflag = 0
@@ -364,35 +359,34 @@ class mesh:
self.a270 = pi * 1.5
self.a360 = pi * 2
-
- def power(self, a, b): ## Returns a power, including negative numbers
- result = sgn(a)*(abs(a)**b)
+ def power(self, a, b): # Returns a power, including negative numbers
+ result = sgn(a) * (abs(a) ** b)
return result
- def sign(self, d): ## Works out the sign of a number.
+ def sign(self, d): # Works out the sign of a number.
return sgn(d)
def ellipsecomp(self, efactor, theta):
- if theta==self.a90:
+ if theta == self.a90:
result = self.a90
- elif theta==self.a180:
+ elif theta == self.a180:
result = self.a180
- elif theta==self.a270:
+ elif theta == self.a270:
result = self.a270
- elif theta==self.a360:
+ elif theta == self.a360:
result = 0.0
else:
- result = atan(tan(theta)/efactor**0.5)
- if result<0.0:
- if theta>self.a180:
- result = result+self.a180
- elif theta<self.a180:
- result = result+self.a180
-
- if result>0.0:
- if theta>self.a180:
- result = result+self.a180
- elif theta<self.a180:
+ result = atan(tan(theta) / efactor ** 0.5)
+ if result < 0.0:
+ if theta > self.a180:
+ result = result + self.a180
+ elif theta < self.a180:
+ result = result + self.a180
+
+ if result > 0.0:
+ if theta > self.a180:
+ result = result + self.a180
+ elif theta < self.a180:
result = result
return result
@@ -403,23 +397,23 @@ class mesh:
self.boundary()
def superell(self, n1, uv, turn):
- t1 = sin(uv+turn)
+ t1 = sin(uv + turn)
t1 = abs(t1)
- t1 = t1**n1
- t2 = cos(uv+turn)
+ t1 = t1 ** n1
+ t2 = cos(uv + turn)
t2 = abs(t2)
- t2 = t2**n1
- r = self.power(1.0/(t1+t2),(1.0/n1))
+ t2 = t2 ** n1
+ r = self.power(1.0 / (t1 + t2), (1.0 / n1))
return r
def superform(self, m, n1, n2, n3, uv, a, b, twist):
- t1 = cos(m*(uv+twist)*.25)*a
+ t1 = cos(m * (uv + twist) * .25) * a
t1 = abs(t1)
- t1 = t1**n2
- t2 = sin(m*(uv+twist)*.25)*b
+ t1 = t1 ** n2
+ t2 = sin(m * (uv + twist) * .25) * b
t2 = abs(t2)
- t2 = t2**n3
- r = self.power(1.0/(t1+t2), n1)
+ t2 = t2 ** n3
+ r = self.power(1.0 / (t1 + t2), n1)
return r
def dovertedge(self):
@@ -441,21 +435,21 @@ class mesh:
self.vertfaceflag = 1
def dofaceedge(self):
- self.dovertedge() ## just in case they haven't been done
- self.dovertface() ##
+ self.dovertedge() # just in case they haven't been done
+ self.dovertface()
if not self.faceedgeflag:
for edge in self.edges:
- edge.faces=[]
+ edge.faces = []
for face in self.faces:
face.edges = []
for face in self.faces:
finish = len(face.vertices)
for i in range(finish):
current = face.vertices[i]
- if i == finish-1:
+ if i == finish - 1:
next = face.vertices[0]
else:
- next = face.vertices[i+1]
+ next = face.vertices[i + 1]
for edge in current.edges:
if edge.a is current or edge.b is current:
if edge.b is next or edge.a is next:
@@ -472,17 +466,17 @@ class mesh:
edge.a.boundary = 1
edge.b.boundary = 1
-## The functions below turn the basic triangular faces into
-## hexagonal faces, creating the buckyball effect.
-#PKHG seems to work only for meshes with tri's ;-) ??!!
+ # The functions below turn the basic triangular faces into
+ # hexagonal faces, creating the buckyball effect.
+ # PKHG seems to work only for meshes with tri's ;-)
def hexify(self):
- self.hexverts=[]
- self.hexedges=[]
- self.hexfaces=[]
- #PKHG renumbering the index of the verts
+ self.hexverts = []
+ self.hexedges = []
+ self.hexfaces = []
+ # PKHG renumbering the index of the verts
for i in range(len(self.verts)):
self.verts[i].index = i
- #PKHG renumbering the index of the edges
+ # PKHG renumbering the index of the edges
for i in range(len(self.edges)):
self.edges[i].index = i
@@ -491,7 +485,7 @@ class mesh:
for edge in self.edges:
self.hexshorten(edge, hexvert_counter)
- hexvert_counter += 2 #PKHG two new vertices done
+ hexvert_counter += 2 # PKHG two new vertices done
for face in self.faces:
self.makehexfaces(face)
@@ -506,15 +500,14 @@ class mesh:
self.vertfaceflag = 0
self.faceedgeflag = 0
-
def hexshorten(self, currentedge, hexvert_counter):
- third = vertex(currentedge.vect/3.0)
+ third = vertex(currentedge.vect / 3.0)
newvert1 = vertex(currentedge.a.vector)
newvert2 = vertex(currentedge.b.vector)
newvert1 = newvert1 + third
newvert1.index = hexvert_counter
newvert2 = newvert2 - third
- newvert2.index = hexvert_counter + 1 #PKHG caller adjusts +=2
+ newvert2.index = hexvert_counter + 1 # PKHG caller adjusts +=2
newedge = edge(newvert1, newvert2)
newedge.index = currentedge.index
self.hexverts.append(newvert1)
@@ -522,7 +515,7 @@ class mesh:
self.hexedges.append(newedge)
def makehexfaces(self, currentface):
- vertices=[]
+ vertices = []
currentface.docorners()
for corner in currentface.corners:
vert = corner[0]
@@ -551,7 +544,7 @@ class mesh:
self.hexedges.append(newedge3)
def hexvertface(self, vert):
- vertices=[]
+ vertices = []
for edge in vert.edges:
eid = edge.index
if edge.a is vert:
@@ -562,9 +555,9 @@ class mesh:
self.hexfaces.append(newface)
def starify(self):
- self.starverts=[]
- self.staredges=[]
- self.starfaces=[]
+ self.starverts = []
+ self.staredges = []
+ self.starfaces = []
for i in range(len(self.verts)):
self.verts[i].index = i
for i in range(len(self.edges)):
@@ -580,11 +573,9 @@ class mesh:
star_edge_counter = 0
for currentface in self.faces:
currentface.docorners()
- vertices=[]
+ vertices = []
for corner in currentface.corners:
vert = self.starverts[corner[1].index]
-# vert.index = star_vert_counter
-# star_vert_counter += 1
vertices.append(vert)
newface = face(vertices)
newface.index = star_face_counter
@@ -601,7 +592,7 @@ class mesh:
self.staredges.append(newedge2)
self.staredges.append(newedge3)
for vert in self.verts:
- vertices=[]
+ vertices = []
vert.clockwise()
for currentedge in vert.edges:
eid = currentedge.index
@@ -618,9 +609,9 @@ class mesh:
self.faceedgeflag = 0
def class2(self):
- self.class2verts=[]
- self.class2edges=[]
- self.class2faces=[]
+ self.class2verts = []
+ self.class2edges = []
+ self.class2faces = []
newvertstart = len(self.verts)
newedgestart = len(self.edges)
@@ -642,28 +633,28 @@ class mesh:
newedge1 = edge(currentface.vertices[0], newvert)
newedge2 = edge(currentface.vertices[1], newvert)
newedge3 = edge(currentface.vertices[2], newvert)
+
self.edges.append(newedge1)
self.edges.append(newedge2)
self.edges.append(newedge3)
for currentedge in range(newedgestart):
- self.edges[currentedge].a = self.verts[self.edges[currentedge].faces[0].index+newvertstart]
- self.edges[currentedge].b = self.verts[self.edges[currentedge].faces[1].index+newvertstart]
+ self.edges[currentedge].a = self.verts[self.edges[currentedge].faces[0].index + newvertstart]
+ self.edges[currentedge].b = self.verts[self.edges[currentedge].faces[1].index + newvertstart]
self.edges[currentedge].findvect()
for currentvert in range(newvertstart):
vert = self.verts[currentvert]
- vertices=[]
+ vertices = []
vert.clockwise()
for currentface in vert.faces:
eid = currentface.index
-
vertices.append(self.verts[newvertstart + eid])
for i in range(len(vertices)):
if i == len(vertices) - 1:
next = vertices[0]
else:
- next = vertices[i+1]
+ next = vertices[i + 1]
newface = face([vert, vertices[i], next])
self.class2faces.append(newface)
@@ -674,9 +665,9 @@ class mesh:
self.faceedgeflag = 0
def dual(self):
- self.dualverts=[]
+ self.dualverts = []
- self.dualfaces=[]
+ self.dualfaces = []
counter_verts = len(self.verts)
for i in range(counter_verts):
@@ -690,11 +681,11 @@ class mesh:
for currentface in self.faces:
currentface.docorners()
newvert = average(currentface.vertices).centroid()
- newvert.index = counter_verts #PKHG needed in >= 2.59
+ newvert.index = counter_verts # PKHG needed in >= 2.59
counter_verts += 1
self.dualverts.append(newvert)
for vert in self.verts:
- vertices=[]
+ vertices = []
vert.clockwise()
for currentface in vert.faces:
eid = currentface.index
@@ -711,6 +702,7 @@ class mesh:
self.vertfaceflag = 0
self.faceedgeflag = 0
+
class facetype(mesh):
def __init__(self, basegeodesic, parameters, width, height, relative):
mesh.__init__(self)
@@ -723,12 +715,12 @@ class facetype(mesh):
if not self.relative:
newwidth = self.findrelative()
- self.width = width*newwidth
+ self.width = width * newwidth
self.height = height
self.base.connectivity()
for coord in self.coords:
- coord[0]=coord[0]*self.width
- coord[1]=coord[1]*self.height
+ coord[0] = coord[0] * self.width
+ coord[1] = coord[1] * self.height
if not self.base.facenormalflag:
for currentface in self.base.faces:
@@ -736,7 +728,7 @@ class facetype(mesh):
currentface.findnormal()
self.base.facenormalflag = 1
- if self.endtype==4 and not self.base.vertnormalflag:
+ if self.endtype == 4 and not self.base.vertnormalflag:
for currentvert in self.base.verts:
currentvert.findnormal()
self.base.vertnormalflag = 1
@@ -744,16 +736,16 @@ class facetype(mesh):
def findrelative(self):
centre = average(self.base.faces[0].vertices).centroid()
- edgelist=[]
+ edgelist = []
for point in self.base.faces[0].vertices:
newedge = edge(centre, point)
edgelist.append(newedge)
length = 0
for edg in edgelist:
extra = edg.vect.length
- length = length+extra
+ length = length + extra
- length = length/len(edgelist)
+ length = length / len(edgelist)
return length
@@ -761,7 +753,7 @@ class facetype(mesh):
if not self.detatch:
for point in self.base.verts:
self.verts.append(point)
- if self.endtype==4:
+ if self.endtype == 4:
self.createghostverts()
for currentface in self.base.faces:
self.doface(currentface)
@@ -773,68 +765,69 @@ class facetype(mesh):
self.verts.append(newvert)
def doface(self, candidate):
- grid=[]
+ grid = []
candidate.dospokes()
if not self.detatch:
- line=[]
+ line = []
for vert in candidate.vertices:
line.append(vert)
grid.append(line)
else:
- line=[]
+ line = []
for point in candidate.vertices:
newvert = vertex(point.vector)
self.verts.append(newvert)
line.append(newvert)
grid.append(line)
finish = len(self.coords)
- if self.endtype==1 or self.endtype==4:
- finish = finish-1
+ if self.endtype == 1 or self.endtype == 4:
+ finish = finish - 1
for i in range(finish):
- up = candidate.normal*self.coords[i][1]
- line=[]
+ up = candidate.normal * self.coords[i][1]
+ line = []
for j in range(len(candidate.vertices)):
- dotfac = candidate.corners[j][3]*0.5
- vec=(candidate.spokes[j]*(self.coords[i][0]/sin(dotfac)))
+ dotfac = candidate.corners[j][3] * 0.5
+ vec = (candidate.spokes[j] * (self.coords[i][0] / sin(dotfac)))
- newvert = candidate.vertices[j]+vec+up
+ newvert = candidate.vertices[j] + vec + up
line.append(newvert)
self.verts.append(newvert)
grid.append(line)
- if self.endtype==4:
- line=[]
+ if self.endtype == 4:
+ line = []
for i in range(len(candidate.vertices)):
- vert = self.verts[candidate.vertices[i].index+self.ghoststart]
+ vert = self.verts[candidate.vertices[i].index + self.ghoststart]
line.append(vert)
grid.append(line)
for line in grid:
line.append(line[0])
- if self.endtype==3:
+ if self.endtype == 3:
grid.append(grid[0])
- for i in range(len(grid)-1):
- for j in range(len(grid[i])-1):
+ for i in range(len(grid) - 1):
+ for j in range(len(grid[i]) - 1):
one = grid[i][j]
- two = grid[i][j+1]
- three = grid[i+1][j+1]
- four = grid[i+1][j]
+ two = grid[i][j + 1]
+ three = grid[i + 1][j + 1]
+ four = grid[i + 1][j]
newface = face([one, two, three, four])
self.faces.append(newface)
- if self.endtype==2:
+ if self.endtype == 2:
finalfaceverts = grid[-1]
newface = face(finalfaceverts[:-1])
self.faces.append(newface)
- if self.endtype==1:
+ if self.endtype == 1:
lastvert = average(candidate.vertices).centroid()
- up = candidate.normal*self.coords[-1][1]
- newvert = lastvert+up
+ up = candidate.normal * self.coords[-1][1]
+ newvert = lastvert + up
self.verts.append(newvert)
ring = grid[-1]
- for i in range(len(ring)-1):
- newface = face([newvert, ring[i], ring[i+1]])
+ for i in range(len(ring) - 1):
+ newface = face([newvert, ring[i], ring[i + 1]])
self.faces.append(newface)
+
class importmesh(mesh):
def __init__(self, meshname, breakquadflag):
mesh.__init__(self)
@@ -842,34 +835,27 @@ class importmesh(mesh):
obj = bpy.data.objects[meshname]
bpy.context.scene.objects.active = obj
obj.select = True
- copied_mesh = None
impmesh = None
if not breakquadflag:
bpy.ops.object.mode_set(mode='EDIT')
- impmesh = bmesh.new() # create an empty BMesh
- impmesh.from_mesh(obj.data) # fill it in from a Mesh
+ impmesh = bmesh.new() # create an empty BMesh
+ impmesh.from_mesh(obj.data) # fill it in from a Mesh
bpy.ops.object.mode_set(mode='OBJECT')
if breakquadflag:
-
- name = obj.name
-
- impmesh_name = "Original_" + name
-
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.quads_convert_to_tris()
- impmesh = bmesh.new() # create an empty BMesh
+ impmesh = bmesh.new() # create an empty BMesh
impmesh.from_mesh(obj.data) # fill it in from a Mesh
bpy.ops.object.mode_set(mode='OBJECT')
-
for v in impmesh.verts:
vert = vertex(v.co)
vert.index = v.index
self.verts.append(vert)
- #PKHG verts is now a list of vertex, so to say a copy of the Vectors
+ # PKHG verts is now a list of vertex, so to say a copy of the Vectors
- #PKHG edges
+ # PKHG edges
for e in impmesh.edges:
tmp = []
for vert in e.verts:
@@ -878,40 +864,40 @@ class importmesh(mesh):
newedge = edge(tmp[0], tmp[1])
newedge.index = e.index
self.edges.append(newedge)
- #PKHG faces
- extra_DBG_info("MeshInfo","vefm L995 the mesh impmesh", impmesh.faces[:])
+ # PKHG faces
+ extra_DBG_info("MeshInfo", "vefm L868 the mesh impmesh", impmesh.faces[:])
for f in impmesh.faces:
- temp=[]
- for vert in f.verts: #PKHG a list! of indices ??? PKHG>???
- a = self.verts[vert.index] #PKHG verts contains already vertex objects
+ temp = []
+ for vert in f.verts: # PKHG a list! of indices ??? PKHG>???
+ a = self.verts[vert.index] # PKHG verts contains already vertex objects
temp.append(a)
newface = face(temp)
- newface.index = f.index #indexcount
+ newface.index = f.index # indexcount
self.faces.append(newface)
self.dovertedge()
self.dovertface()
- self.temp=[]
+ self.temp = []
for i in range(len(self.verts)):
self.temp.append([])
self.verts[i].index = i
for i in range(len(self.verts)):
target = self.surroundingverts(self.verts[i])
- for j in range(len(target)): ## go through those verts
+ for j in range(len(target)): # go through those verts
temptarg = self.temp[target[j].index]
- flag = 0 ## set a flag up
+ flag = 0 # set a flag up
- for k in range(len(temptarg)): ## go through temp list for each of those verts
+ for k in range(len(temptarg)): # go through temp list for each of those verts
- if temptarg[k]==i: ## if we find a match to the current vert...
- flag = 1 ## raise the flag
+ if temptarg[k] == i: # if we find a match to the current vert...
+ flag = 1 # raise the flag
- if flag==0: ## if there is no flag after all that...
- self.temp[target[j].index].append(i) ## add current vert to temp list of this surrounding vert
- self.temp[i].append(target[j].index) ## add this surrounding vert to the current temp list
+ if flag == 0: # if there is no flag after all that...
+ self.temp[target[j].index].append(i) # add current vert to temp list of this surrounding vert
+ self.temp[i].append(target[j].index) # add this surrounding vert to the current temp list
newedge = edge(self.verts[i], self.verts[target[j].index])
- self.edges.append(newedge) ## add the newly found edge to the edges list
+ self.edges.append(newedge) # add the newly found edge to the edges list
for edg in self.edges:
edg.findvect()
@@ -921,45 +907,49 @@ class importmesh(mesh):
def surroundingverts(self, vert):
''' Find the verts surrounding vert'''
- surround=[] ## list to be filled and returned
- for faces in vert.faces: ## loop through faces attached to vert
+ surround = [] # list to be filled and returned
+ for faces in vert.faces: # loop through faces attached to vert
finish = len(faces.vertices)
for i in range(finish):
- if i==finish-1:
+ if i == finish - 1:
next = faces.vertices[0]
else:
- next = faces.vertices[i+1]
+ next = faces.vertices[i + 1]
if vert == faces.vertices[i]:
surround.append(next)
return surround
def breakquad(self, quad_face):
''' turn quads into triangles'''
- distance1 = quad_face.vertices[0]-quad_face.vertices[2]
- distance2 = quad_face.vertices[1]-quad_face.vertices[3]
+ distance1 = quad_face.vertices[0] - quad_face.vertices[2]
+ distance2 = quad_face.vertices[1] - quad_face.vertices[3]
distance1.findlength()
distance2.findlength()
- if abs(distance1.length)<abs(distance2.length):
- self.faces[quad_face.index]=face([quad_face.vertices[0], quad_face.vertices[1], quad_face.vertices[2]])
+ if abs(distance1.length) < abs(distance2.length):
+ self.faces[quad_face.index] = face([quad_face.vertices[0], quad_face.vertices[1], quad_face.vertices[2]])
self.faces.append(face([quad_face.vertices[0], quad_face.vertices[2], quad_face.vertices[3]]))
else:
- self.faces[quad_face.index]=face([quad_face.vertices[0], quad_face.vertices[1], quad_face.vertices[3]])
+ self.faces[quad_face.index] = face([quad_face.vertices[0], quad_face.vertices[1], quad_face.vertices[3]])
self.faces.append(face([quad_face.vertices[1], quad_face.vertices[2], quad_face.vertices[3]]))
class strut(mesh):
- def __init__(self, base, struttype, width, height, length, widthtog, heighttog, lengthtog, meshname, stretchflag, lift):
- extra_DBG_info(name = "StrutMesh", info_text="vefm L1026\nstrut called: ", info_obj=[base, struttype, width, height, length, widthtog, heighttog, lengthtog, meshname, stretchflag, lift])
+ def __init__(self, base, struttype, width, height, length, widthtog, heighttog,
+ lengthtog, meshname, stretchflag, lift):
+
+ extra_DBG_info(name="StrutMesh", info_text="vefm L940\nstrut called: ",
+ info_obj=[base, struttype, width, height, length, widthtog,
+ heighttog, lengthtog, meshname, stretchflag, lift])
mesh.__init__(self)
- ## put in strut prep stuff here
- if struttype==None:
+ # put in strut prep stuff here
+ if struttype is None:
return
total = 0
divvy = len(base.faces[0].edges)
for lengf in base.faces[0].edges:
lengf.vect.findlength()
- total = total+lengf.vect.length
- yardstick = total/divvy
+ total = total + lengf.vect.length
+ yardstick = total / divvy
if widthtog:
self.width = width
else:
@@ -967,7 +957,7 @@ class strut(mesh):
if heighttog:
self.height = height
else:
- self.height = height*yardstick
+ self.height = height * yardstick
if lengthtog:
self.shrink = length
else:
@@ -983,63 +973,51 @@ class strut(mesh):
edj.unit = side.vect
edj.unit.normalize()
edj.cross = crossp(edj.normal, edj.unit).docrossproduct()
- template = importmesh(meshname,0)
+ template = importmesh(meshname, 0)
maxx = 0
minx = 0
for vert in template.verts:
-# if vert.x>maxx:
if vert.vector.x > maxx:
-# maxx = vert.x
maxx = vert.vector.x
-# if vert.x<minx:
if vert.vector.x < minx:
-# minx = vert.x
minx = vert.vector.x
for edj in base.edges:
start = len(self.verts)
centre = average([edj.a, edj.b]).centroid()
- split = edj.vect.length/2
- #PKHG no division by zero!!
+ split = edj.vect.length / 2
+ # PKHG no division by zero!!
tmp = 1.0
if maxx != minx:
- tmp = 1.0/(maxx - minx)
+ tmp = 1.0 / (maxx - minx)
dubbl = edj.vect.length * tmp
- #PKHG end no division by zero!!
- diffplus = split-maxx
- diffminus=-split-minx
+ # PKHG end no division by zero!!
+ diffplus = split - maxx
+ diffminus = -split - minx
for point in template.verts:
-
- ay=(edj.normal * point.vector.z * self.height) + (edj.normal * lift)
-
+ ay = (edj.normal * point.vector.z * self.height) + (edj.normal * lift)
ce = edj.cross * point.vector.y * self.width
+
if stretchflag:
-# be = edj.unit*self.shrink*dubbl*point.x
be = edj.unit * self.shrink * dubbl * point.vector.x
else:
-# if point.x > 0.0:
if point.vector.x > 0.0:
-# be = edj.unit * self.shrink * (point.x + diffplus)
be = edj.unit * self.shrink * (point.vector.x + diffplus)
-# elif point.x < 0.0:
elif point.vector.x < 0.0:
-# be = edj.unit * self.shrink * (point.x + diffminus)
be = edj.unit * self.shrink * (point.vector.x + diffminus)
-# elif point.x == 0.0:
elif point.vector.x == 0.0:
-# be = edj.unit * self.shrink * point.x
be = edj.unit * self.shrink * point.vector.x
de = ay + be + ce
newvert = centre + de
self.verts.append(newvert)
for edjy in template.edges:
- one = edjy.a.index+start
- two = edjy.b.index+start
+ one = edjy.a.index + start
+ two = edjy.b.index + start
newedge = edge(self.verts[one], self.verts[two])
self.edges.append(newedge)
for facey in template.faces:
- faceverts=[]
+ faceverts = []
for verty in facey.vertices:
- index = verty.index+start
+ index = verty.index + start
faceverts.append(self.verts[index])
newface = face(faceverts)
self.faces.append(newface)
@@ -1049,21 +1027,21 @@ class strut(mesh):
class hub(mesh):
- def __init__(self, base, hubtype, width, height, length,\
+ def __init__(self, base, hubtype, width, height, length,
widthtog, heighttog, lengthtog, meshname):
mesh.__init__(self)
self.width = 1.0
self.height = 1.0
self.shrink = 1.0
- ## put in strut prep stuff here
- extra_DBG_info("vefm L1133 HubMesh","base is ", str(dir(base))+"\n and meshname = " + meshname)
- if hubtype==None:
+ # put in strut prep stuff here
+ extra_DBG_info("vefm L1037 HubMesh", "base is ", str(dir(base)) + "\n and meshname = " + meshname)
+ if hubtype is None:
return
total = 0
divvy = len(base.faces[0].edges)
for lengf in base.verts[0].edges:
lengf.vect.findlength()
- total = total+lengf.vect.length
+ total = total + lengf.vect.length
yardstick = total / divvy
if widthtog:
self.width = width
@@ -1087,12 +1065,12 @@ class hub(mesh):
for apex in base.verts:
apex.findnormal()
side = edge(apex.edges[0].a, apex.edges[0].b)
- apex.unit = side.vect #PKHG is Vector: b -a
+ apex.unit = side.vect # PKHG is Vector: b - a
apex.unit.normalize()
apex.cross = crossp(apex.normal, apex.unit).docrossproduct()
apex.unit = crossp(apex.cross, apex.normal).docrossproduct()
- template = importmesh(meshname,0)
+ template = importmesh(meshname, 0)
for apex in base.verts:
start = len(self.verts)
centre = apex
@@ -1100,18 +1078,18 @@ class hub(mesh):
ay = apex.normal * point.vector.z * self.height
ce = apex.cross * point.vector.y * self.width
be = apex.unit * point.vector.x * self.shrink
- de = ay+be+ce
- newvert = centre+de
+ de = ay + be + ce
+ newvert = centre + de
self.verts.append(newvert)
for edjy in template.edges:
- one = edjy.a.index+start
- two = edjy.b.index+start
+ one = edjy.a.index + start
+ two = edjy.b.index + start
newedge = edge(self.verts[one], self.verts[two])
self.edges.append(newedge)
for facey in template.faces:
- faceverts=[]
+ faceverts = []
for verty in facey.vertices:
- index = verty.index+start
+ index = verty.index + start
faceverts.append(self.verts[index])
newface = face(faceverts)
self.faces.append(newface)
@@ -1119,33 +1097,32 @@ class hub(mesh):
self.vertedgeflag = 0
self.connectivity()
-#???PKHG TODO Nmesh used yet wrong!
+
+# ???PKHG TODO Nmesh used yet wrong!
def finalfill(source, target):
- if source == target: #PKHG: otherewise >infinite< loop
- print("\n***WARNING*** vefm_271.finalfill L1148 source == target empty mesh used")
- target = mesh() #
-#PKHG_??? maybe renumverting and checkkin faces wiht >=4 5 vertices?
+ if source == target: # PKHG: otherewise >infinite< loop
+ print("\n***WARNING*** vefm_271.finalfill L1104 source == target empty mesh used")
+ target = mesh()
+ # PKHG_??? maybe renumverting and checkkin faces wiht >=4 5 vertices?
count = 0
for point in source.verts:
-
newvert = vertex(point.vector)
newvert.index = count
target.verts.append(newvert)
- point.index = count #PKHG_INFO source renumbered too!
+ point.index = count # PKHG_INFO source renumbered too!
count += 1
for facey in source.faces:
row = len(facey.vertices)
if row >= 5:
-
tmp = Vector()
for el in facey.vertices:
- tmp = tmp + target.verts[el.index].vector
+ tmp = tmp + target.verts[el.index].vector
tmp = tmp / row
centre = vertex(tmp)
- centre.index = count #PKHG_??? give it a good index
+ centre.index = count # PKHG_??? give it a good index
count += 1
target.verts.append(centre)
@@ -1155,15 +1132,13 @@ def finalfill(source, target):
b = target.verts[facey.vertices[0].index]
else:
a = target.verts[facey.vertices[i].index]
- b = target.verts[facey.vertices[i+1].index]
+ b = target.verts[facey.vertices[i + 1].index]
target.faces.append([a, b, centre])
else:
f = []
-
for j in range(len(facey.vertices)):
a = facey.vertices[j]
-
f.append(target.verts[a.index])
- target.faces.append(f)
+ target.faces.append(f)