[Bf-extensions-cvs] [aa8f255c] master: Add Mesh Extra Objects: Update, Fix crash with Wall Factory

lijenstina noreply at git.blender.org
Fri Jun 9 23:07:30 CEST 2017


Commit: aa8f255c0eaf31b2665d6adf0569da4892d8d1a4
Author: lijenstina
Date:   Fri Jun 9 23:06:28 2017 +0200
Branches: master
https://developer.blender.org/rBAaa8f255c0eaf31b2665d6adf0569da4892d8d1a4

Add Mesh Extra Objects: Update, Fix crash with Wall Factory

Bumped version to 0.3.2
Wall Factory:
Fix crash with Wall Factory when openings and slots
are enabled (unorderable types: opening() < opening())
with the repeat option on as the sort function compared
stored classes instead of the numerical values
Fix the module not working properly after (F8) reload
Cleanup - consistent prop definitions
Remove star imports
Small UI reorganization to save vertical space
The code will probably need some further refactor
as the usage of globals is not so clear

add_mesh_triangles:
cleanup, remove unused vars add missing GPL notice,
some UI tweaks, add tooltip

add_mesh_pyramid: indentation cleanup
add_mesh_beam_builder: add an option to snap to cursor
add_mesh_teapot: use defs instead of assigning lambdas (E731)

===================================================================

M	add_mesh_extra_objects/Blocks.py
M	add_mesh_extra_objects/Wallfactory.py
M	add_mesh_extra_objects/__init__.py
M	add_mesh_extra_objects/add_mesh_beam_builder.py
M	add_mesh_extra_objects/add_mesh_gears.py
M	add_mesh_extra_objects/add_mesh_gemstones.py
M	add_mesh_extra_objects/add_mesh_honeycomb.py
M	add_mesh_extra_objects/add_mesh_menger_sponge.py
M	add_mesh_extra_objects/add_mesh_pyramid.py
M	add_mesh_extra_objects/add_mesh_round_brilliant.py
M	add_mesh_extra_objects/add_mesh_round_cube.py
M	add_mesh_extra_objects/add_mesh_star.py
M	add_mesh_extra_objects/add_mesh_teapot.py
M	add_mesh_extra_objects/add_mesh_triangles.py

===================================================================

diff --git a/add_mesh_extra_objects/Blocks.py b/add_mesh_extra_objects/Blocks.py
index f798cf52..bade30d0 100644
--- a/add_mesh_extra_objects/Blocks.py
+++ b/add_mesh_extra_objects/Blocks.py
@@ -1,4 +1,4 @@
-# GPL # "author":
+# GPL # "authors": dudecon, jambay
 
 # Module notes:
 #
@@ -8,87 +8,150 @@
 # auto-clip wall edge to SMALL for radial and domes.
 # unregister doesn't release all references.
 # repeat for opening doesn't distribute evenly when radialized - see wrap around
-#   note above.
+# note above.
 # if opening width == indent*2 the edge blocks fail (row of blocks cross opening).
 # if openings overlap fills inverse with blocks - see h/v slots.
 # Negative grout width creates a pair of phantom blocks, seperated by grout
-#   width, inside the edges.
-# if block width variance is 0, and edging is on, right edge blocks create a "vertical seam".
+# width, inside the edges.
+# if block width variance is 0, and edging is on, right edge blocks create a "vertical seam"
 
 
 import bpy
 from random import random
-from math import fmod, sqrt, sin, cos, atan, pi as PI
+from math import (
+        fmod, sqrt,
+        sin, cos, atan,
+        pi as PI,
+        )
+
+# Set to True to enable debug_prints
+DEBUG = False
 
 # A few constants
 SMALL = 0.000000000001
-NOTZERO = 0.01  # for values that must be != 0; see UI options/variables - sort of a bug to be fixed.
+# for values that must be != 0; see UI options/variables - sort of a bug to be fixed
+NOTZERO = 0.01
 
-# global variables
+# Global variables
 
 # General masonry Settings
-settings = {'w': 1.2, 'wv': 0.3, 'h': .6, 'hv': 0.3, 'd': 0.3, 'dv': 0.1,
-            'g': 0.1, 'gv': 0.07, 'gd': 0.01, 'gdv': 0.0, 'b': 0, 'bv': 0,
-            'f': 0.0, 'fv': 0.0, 't': 0.0, 'sdv': 0.1, 'hwt': 0.5, 'aln': 0,
-            'wm': 0.8, 'hm': 0.3, 'dm': 0.1,
-            'woff': 0.0, 'woffv': 0.0, 'eoff': 0.3, 'eoffv': 0.0, 'rwhl': 1,
-            'hb': 0, 'ht': 0, 'ge': 0, 'physics': 0}
-# 'w':width 'wv':widthVariation
-# 'h':height 'hv':heightVariation
-# 'd':depth 'dv':depthVariation
-# 'g':grout 'gv':groutVariation 'gd':groutDepth 'gdv':groutDepthVariation
-# 'b':bevel 'bv':bevelVariation
-# 'f':flawSize 'fv':flawSizeVariation 'ff':flawFraction
-# 't':taper
-# 'sdv':subdivision(distance or angle)
-# 'hwt':row height effect on block widths in the row (0=no effect,
-#     1=1:1 relationship, negative values allowed, 0.5 works well)
-# 'aln':alignment(0=none, 1=rows w/features, 2=features w/rows)
-#     (currently un-used)
-# 'wm':width minimum 'hm':height minimum 'dm':depth minimum
-# 'woff':row start offset(fraction of width)
-# 'woffv':width offset variation(fraction of width)
-# 'eoff':edge offset 'eoffv':edge offset variation
-# 'rwhl':row height lock(1 is all blocks in row have same height)
-# 'hb':bottom row height 'ht': top row height 'ge': grout the edges
-# 'physics': set up for physics
+# ------------------------
+settings = {
+    'w': 1.2, 'wv': 0.3, 'h': .6, 'hv': 0.3, 'd': 0.3, 'dv': 0.1,
+    'g': 0.1, 'gv': 0.07, 'gd': 0.01, 'gdv': 0.0, 'b': 0, 'bv': 0,
+    'f': 0.0, 'fv': 0.0, 't': 0.0, 'sdv': 0.1, 'hwt': 0.5, 'aln': 0,
+    'wm': 0.8, 'hm': 0.3, 'dm': 0.1,
+    'woff': 0.0, 'woffv': 0.0, 'eoff': 0.3, 'eoffv': 0.0, 'rwhl': 1,
+    'hb': 0, 'ht': 0, 'ge': 0, 'physics': 0
+    }
+"""
+    settings DOCUMENTATION:
+    'w':width 'wv':widthVariation
+    'h':height 'hv':heightVariation
+    'd':depth 'dv':depthVariation
+    'g':grout 'gv':groutVariation 'gd':groutDepth 'gdv':groutDepthVariation
+    'b':bevel 'bv':bevelVariation
+    'f':flawSize 'fv':flawSizeVariation 'ff':flawFraction
+    't':taper
+    'sdv':subdivision(distance or angle)
+    'hwt':row height effect on block widths in the row (0=no effect,
+          1=1:1 relationship, negative values allowed, 0.5 works well)
+    'aln':alignment(0=none, 1=rows w/features, 2=features w/rows)
+         (currently unused)
+    'wm':width minimum 'hm':height minimum 'dm':depth minimum
+    'woff':row start offset(fraction of width)
+    'woffv':width offset variation(fraction of width)
+    'eoff':edge offset 'eoffv':edge offset variation
+    'rwhl':row height lock(1 is all blocks in row have same height)
+    'hb':bottom row height 'ht': top row height 'ge': grout the edges
+    'physics': set up for physics
+"""
 
 # dims = area of wall (face)
-dims = {'s': 0, 'e': PI * 3 / 2, 'b': 0.1, 't': 12.3}  # radial
-# 's':start x or theta 'e':end x or theta 'b':bottom z or r 't':top z or r
-# 'w' = e-s and h = t-b; calculated to optimize for various operations/usages
-# dims = {'s':-12, 'e':15, 'w':27, 'b':-15., 't':15., 'h':30}
-# dims = {'s':-bayDim/2, 'e':bayDim/2, 'b':-5., 't':10.} # bay settings?
-
+# ------------------------
+dims = {
+    's': 0, 'e': PI * 3 / 2, 'b': 0.1, 't': 12.3
+    }  # radial
+"""
+    dims DOCUMENTATION:
+    's':start x or theta 'e':end x or theta 'b':bottom z or r 't':top z or r
+    'w' = e-s and h = t-b; calculated to optimize for various operations/usages
+    dims = {'s':-12, 'e':15, 'w':27, 'b':-15., 't':15., 'h':30}
+    dims = {'s':-bayDim/2, 'e':bayDim/2, 'b':-5., 't':10.} # bay settings?
+"""
+
+# ------------------------
 radialized = 0  # Radiating from one point - round/disc; instead of square
-slope = 0  # Warp/slope; curved over like a vaulted tunnel
+slope = 0       # Warp/slope; curved over like a vaulted tunnel
+
 # 'bigblock': merge adjacent blocks into single large blocks
-bigBlock = 0  # Merge blocks
+bigBlock = 0    # Merge blocks
 
-# Gaps in blocks for various apertures.
+
+# Gaps in blocks for various apertures
+# ------------------------
 # openingSpecs = []
-openingSpecs = [{'w': 0.5, 'h': 0.5, 'x': 0.8, 'z': 2.7, 'rp': 1, 'b': 0.0,
-                 'v': 0, 'vl': 0, 't': 0, 'tl': 0}]
-# 'w': opening width, 'h': opening height,
-# 'x': horizontal position, 'z': vertical position,
-# 'rp': make multiple openings, with a spacing of x,
-# 'b': bevel the opening, inside only, like an arrow slit.
-# 'v': height of the top arch, 'vl':height of the bottom arch,
-# 't': thickness of the top arch, 'tl': thickness of the bottom arch
-
-# Add blocks to make platforms.
+openingSpecs = [
+    {'w': 0.5, 'h': 0.5, 'x': 0.8, 'z': 2.7, 'rp': 1, 'b': 0.0,
+     'v': 0, 'vl': 0, 't': 0, 'tl': 0}
+    ]
+"""
+    openingSpecs DOCUMENTATION:
+    'w': opening width, 'h': opening height,
+    'x': horizontal position, 'z': vertical position,
+    'rp': make multiple openings, with a spacing of x,
+    'b': bevel the opening, inside only, like an arrow slit.
+    'v': height of the top arch, 'vl':height of the bottom arch,
+    't': thickness of the top arch, 'tl': thickness of the bottom arch
+"""
+
+# Add blocks to make platforms
+# ------------------------
 shelfExt = 0
-shelfSpecs = {'w': 0.5, 'h': 0.5, 'd': 0.3, 'x': 0.8, 'z': 2.7}
-# 'w': block width, 'h': block height, 'd': block depth (shelf size; offset from wall)
-# 'x': horizontal start position, 'z': vertical start position
 
-# Add blocks to make steps.
+shelfSpecs = {
+    'w': 0.5, 'h': 0.5, 'd': 0.3, 'x': 0.8, 'z': 2.7
+    }
+"""
+    shelfSpecs DOCUMENTATION:
+    'w': block width, 'h': block height, 'd': block depth (shelf size; offset from wall)
+    'x': horizontal start position, 'z': vertical start position
+"""
+
+# Add blocks to make steps
+# ------------------------
 stepMod = 0
-stepSpecs = {'x': 0.0, 'z': -10, 'w': 10.0, 'h': 10.0,
-            'v': 0.7, 't': 1.0, 'd': 1.0}
-# 'x': horizontal start position, 'z': vertical start position,
-# 'w': step area width, 'h': step area height,
-# 'v': riser height, 't': tread width, 'd': block depth (step size; offset from wall)
+
+stepSpecs = {
+    'x': 0.0, 'z': -10, 'w': 10.0, 'h': 10.0,
+    'v': 0.7, 't': 1.0, 'd': 1.0
+    }
+"""
+    stepSpecs DOCUMENTATION:
+    'x': horizontal start position, 'z': vertical start position,
+    'w': step area width, 'h': step area height,
+    'v': riser height, 't': tread width, 'd': block depth (step size; offset from wall)
+"""
+stepLeft = 0
+shelfBack = 0
+stepOnly = 0
+stepBack = 0
+
+
+# switchable prints
+def debug_prints(func="", text="Message", var=None):
+    global DEBUG
+    if DEBUG:
+        print("\n[{}]\nmessage: {}".format(func, text))
+        if var:
+            print("Error: ", var)
+
+
+# pass variables just like for the regular prints
+def debug_print_vars(*args, **kwargs):
+    global DEBUG
+    if DEBUG:
+        print(*args, **kwargs)
 
 
 # easier way to get to the random function
@@ -126,6 +189,7 @@ def test(TestN=13):
                           't': float(t), 'tl': float(tl)}]
     return dims, openingSpecs
 
+
 # dims, openingSpecs = test(15)
 
 
@@ -290,7 +354,8 @@ def MakeABlock(bounds, segsize, vll=0, Offsets=None, FaceExclude=[],
 
 def MakeAKeystone(xpos, width, zpos, ztop, zbtm, thick, bevel, vll=0, FaceExclude=[], xBevScl=1):
     __doc__ = """\
-    MakeAKeystone returns lists of points and faces to be made into a square cornered keystone, with optional bevels.
+    MakeAKeystone returns lists of points and faces to be made into a
+    square cornered keystone, with optional bevels.
     xpos: x position of the centerline
     width: x width of the keystone at the widest point (discounting bevels)
     zpos: z position of the widest point
@@ -299,7 +364,8 @@ def MakeAKeystone(xpos, width, zpos, ztop, zbtm, thick, bevel, vll=0, FaceExclud
     thick: thickness
     bevel: the amount to raise the back vertex to account for arch beveling
     vll: the number of vertexes already in the mesh. len(mesh.verts) should give this number
-    faceExclude: list of faces to exclude from the faces list.  0:left, 1:right, 2:bottom, 3:top, 4:back, 5:front
+    faceExclude: list of faces to exclude from the faces list.
+                 0:left, 1:right, 2:bottom, 3:top, 4:back, 5:front
     xBevScl: how much to divide the end (+- x axis) bevel dimensions.
     Set to current average radius to compensate for angular distortion on curved blocks
     """
@@ -427,6 +493,7 @@ class opening:
     # ht is the z position; s is the side: 1 for right, -1 for left
     # if the height passed is above or below the opening, return None
     def edgeS(self, ht, s):
+
         # set the row radius: 1 for standard wall (flat)
    

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list