Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlijenstina <lijenstina@gmail.com>2017-06-05 15:53:42 +0300
committerlijenstina <lijenstina@gmail.com>2017-06-05 15:53:42 +0300
commitbe1ffdc175be417a0f9eabc95e6c7c6f243dab01 (patch)
tree728a3c73d32c84aece48de779e0cbf96f4bff3ed /object_fracture_crack/__init__.py
parent6feeb4de6d939c17d931f2763043ea9224154949 (diff)
Cell Fracture Crack It: Fixes, clean up
Bumped verison to 0.1.1 Pep8 cleanup Replace deprecated imp calls with importlib Small UI changes Make the Panel by default closed Move scene properties to a PropertyGroup they can be accessed with context.scene.crackit Fixed some polling issues related to using Fracture (as the operator will ignore objects that are not processed) causing the operation to fail further on Added an option for using the original names or the Enum ones for the materials shipped in the Blend file More robust error handling Add a button for the wm.addon_userpref_show to open the Cell Fracture add-on if it is not enabled
Diffstat (limited to 'object_fracture_crack/__init__.py')
-rw-r--r--object_fracture_crack/__init__.py208
1 files changed, 114 insertions, 94 deletions
diff --git a/object_fracture_crack/__init__.py b/object_fracture_crack/__init__.py
index f2aa7593..dc43fbe3 100644
--- a/object_fracture_crack/__init__.py
+++ b/object_fracture_crack/__init__.py
@@ -1,4 +1,4 @@
-#====================== BEGIN GPL LICENSE BLOCK ======================
+# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -14,115 +14,135 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
-#======================= END GPL LICENSE BLOCK ========================
+# ##### END GPL LICENSE BLOCK #####
+bl_info = {
+ "name": "Cell Fracture Crack It",
+ "author": "Nobuyuki Hirakata",
+ "version": (0, 1, 1),
+ "blender": (2, 78, 5),
+ "location": "View3D > Toolshelf > Crack it! Tab",
+ "description": "Displaced Cell Fracture Addon",
+ "warning": "Make sure to enable 'Object: Cell Fracture' Addon",
+ "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/"
+ "Py/Scripts/Object/CrackIt",
+ "category": "Object"
+}
if 'bpy' in locals():
- import imp
- imp.reload(operator)
+ import importlib
+ importlib.reload(operator)
else:
from . import operator
import bpy
+from bpy.types import PropertyGroup
+from bpy.props import (
+ BoolProperty,
+ EnumProperty,
+ FloatProperty,
+ IntProperty,
+ PointerProperty,
+ )
import os
-bl_info = {
- "name": "Cell Fracture Crack It",
- "author": "Nobuyuki Hirakata",
- "version": (0, 1, 0),
- "blender": (2, 77, 0),
- "location": "View3D > Toolshelf > Creat Tab",
- "description": "Displaced Cell Fracture Addon",
- "warning": "Make sure to enable 'Object: Cell Fracture' Addon",
- "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Object/CrackIt",
- "category": "Object"
-}
+
+class CrackItProperties(PropertyGroup):
+ # Input on toolshelf before execution
+ # In Panel subclass, In bpy.types.Operator subclass,
+ # reference them by context.scene.crackit
+
+ fracture_childverts = BoolProperty(
+ name="From Child Verts",
+ description="Use child object's vertices and position for origin of crack",
+ default=False
+ )
+ fracture_scalex = FloatProperty(
+ name="Scale X",
+ description="Scale X",
+ default=1.00,
+ min=0.00,
+ max=1.00
+ )
+ fracture_scaley = FloatProperty(
+ name="Scale Y",
+ description="Scale Y",
+ default=1.00,
+ min=0.00,
+ max=1.00
+ )
+ fracture_scalez = FloatProperty(
+ name="Scale Z",
+ description="Scale Z",
+ default=1.00,
+ min=0.00,
+ max=1.00
+ )
+ fracture_div = IntProperty(
+ name="Max Crack",
+ description="Max Crack",
+ default=100,
+ min=0,
+ max=10000
+ )
+ fracture_margin = FloatProperty(
+ name="Margin Size",
+ description="Margin Size",
+ default=0.001,
+ min=0.000,
+ max=1.000
+ )
+ extrude_offset = FloatProperty(
+ name="Offset",
+ description="Extrude Offset",
+ default=0.10,
+ min=0.00,
+ max=2.00
+ )
+ extrude_random = FloatProperty(
+ name="Random",
+ description="Extrude Random",
+ default=0.30,
+ min=-1.00,
+ max=1.00
+ )
+ # Path of the addon
+ material_addonpath = os.path.dirname(__file__)
+ # Selection of material preset
+ # Note: you can choose the original name in the library blend
+ # or the prop name
+ material_preset = EnumProperty(
+ name="Preset",
+ description="Material Preset",
+ items=[
+ ('crackit_organic_mud', "Organic Mud", "Mud material"),
+ ('crackit_mud1', "Mud", "Mud material"),
+ ('crackit_tree1_moss1', "Tree Moss", "Tree Material"),
+ ('crackit_tree2_dry1', "Tree Dry", "Tree Material"),
+ ('crackit_tree3_red1', "Tree Red", "Tree Material"),
+ ('crackit_rock1', "Rock", "Rock Material")
+ ]
+ )
+ material_lib_name = BoolProperty(
+ name="Library Name",
+ description="Use the original Material name from the .blend library\n"
+ "instead of the one defined in the Preset",
+ default=True
+ )
+
def register():
bpy.utils.register_module(__name__)
-
- # Input on toolshelf before execution --------------------------
- # In Panel subclass, In bpy.types.Operator subclass, reference them by context.scene.~.
-
- bpy.types.Scene.crackit_fracture_childverts = bpy.props.BoolProperty(
- name = 'From Child Verts',
- description = "Use child object's vertices and position for origin of crack.",
- default = False
- )
- bpy.types.Scene.crackit_fracture_scalex = bpy.props.FloatProperty(
- name = 'Scale X',
- description = "Scale X",
- default = 1.00,
- min = 0.00,
- max = 1.00
- )
- bpy.types.Scene.crackit_fracture_scaley = bpy.props.FloatProperty(
- name = 'Scale Y',
- description = "Scale Y",
- default = 1.00,
- min = 0.00,
- max = 1.00
- )
- bpy.types.Scene.crackit_fracture_scalez = bpy.props.FloatProperty(
- name = 'Scale Z',
- description = "Scale Z",
- default = 1.00,
- min = 0.00,
- max = 1.00
- )
- bpy.types.Scene.crackit_fracture_div = bpy.props.IntProperty(
- name = 'Max Crack',
- description = "Max Crack",
- default = 100,
- min = 0,
- max = 10000
- )
- bpy.types.Scene.crackit_fracture_margin = bpy.props.FloatProperty(
- name = 'Margin Size',
- description = "Margin Size",
- default = 0.001,
- min = 0.000,
- max = 1.000
- )
- bpy.types.Scene.crackit_extrude_offset = bpy.props.FloatProperty(
- name = 'Extrude',
- description = "Extrude Offset",
- default = 0.10,
- min = 0.00,
- max = 2.00
- )
- bpy.types.Scene.crackit_extrude_random = bpy.props.FloatProperty(
- name = 'Random',
- description = "Extrude Random",
- default = 0.30,
- min = -1.00,
- max = 1.00
- )
- # Path of the addon.
- bpy.types.Scene.crackit_material_addonpath = os.path.dirname(__file__)
- # Selection of material preset.
- bpy.types.Scene.crackit_material_preset = bpy.props.EnumProperty(
- name = 'Preset',
- description = "Material Preset",
- items = [('crackit_organic_mud', 'Organic Mud', "Mud material"),
- ('crackit_mud1', 'Mud', "Mud material"),
- ('crackit_tree1_moss1', 'Tree1_moss', "Tree Material"),
- ('crackit_tree2_dry1', 'Tree2_dry', "Tree Material"),
- ('crackit_tree3_red1', 'Tree3_red', "Tree Material"),
- ('crackit_rock1', 'Rock', "Rock Material")]
- )
+ bpy.types.Scene.crackit = PointerProperty(
+ type=CrackItProperties
+ )
+
def unregister():
- # Delete bpy.types.Scene.~.
- del bpy.types.Scene.crackit_fracture_scalex
- del bpy.types.Scene.crackit_fracture_scaley
- del bpy.types.Scene.crackit_fracture_scalez
- del bpy.types.Scene.crackit_fracture_div
- del bpy.types.Scene.crackit_fracture_margin
- del bpy.types.Scene.crackit_extrude_offset
-
+ del bpy.types.Scene.crackit
bpy.utils.unregister_module(__name__)
+
if __name__ == "__main__":
register()