[Bf-extensions-cvs] [664ecb16] master: Mesh Tissue: cleanup, fix remove base object crashes

lijenstina noreply at git.blender.org
Sun Jun 25 16:02:01 CEST 2017


Commit: 664ecb162c9beb5a19df67934866badb0ce2b3e4
Author: lijenstina
Date:   Sun Jun 25 16:01:21 2017 +0200
Branches: master
https://developer.blender.org/rBA664ecb162c9beb5a19df67934866badb0ce2b3e4

Mesh Tissue: cleanup, fix remove base object crashes

Bumped version to 0.3.3
Pep8 Cleanup
Fix crashes related to removing the base object with
Settings and Refresh
Move bl_info on top of the files
Imports as tuples
consistent prop definitions

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

M	mesh_tissue/__init__.py
M	mesh_tissue/colors_groups_exchanger.py
M	mesh_tissue/dual_mesh.py
M	mesh_tissue/lattice.py
M	mesh_tissue/tessellate_numpy.py
M	mesh_tissue/uv_to_mesh.py

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

diff --git a/mesh_tissue/__init__.py b/mesh_tissue/__init__.py
index 7d8b0078..bef99625 100644
--- a/mesh_tissue/__init__.py
+++ b/mesh_tissue/__init__.py
@@ -16,8 +16,8 @@
 #
 # ##### END GPL LICENSE BLOCK #####
 
-# --------------------------------- TISSUE ------------------------------------#
-#-------------------------------- version 0.3 ---------------------------------#
+# --------------------------------- TISSUE ----------------------------------- #
+# ------------------------------- version 0.3 -------------------------------- #
 #                                                                              #
 # Creates duplicates of selected mesh to active morphing the shape according   #
 # to target faces.                                                             #
@@ -28,7 +28,20 @@
 # http://www.co-de-it.com/                                                     #
 # http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Mesh/Tissue      #
 #                                                                              #
-################################################################################
+# ############################################################################ #
+
+bl_info = {
+    "name": "Tissue",
+    "author": "Alessandro Zomparelli (Co-de-iT)",
+    "version": (0, 3, 3),
+    "blender": (2, 7, 9),
+    "location": "",
+    "description": "Tools for Computational Design",
+    "warning": "",
+    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/"
+                "Py/Scripts/Mesh/Tissue",
+    "tracker_url": "https://plus.google.com/u/0/+AlessandroZomparelli/",
+    "category": "Mesh"}
 
 
 if "bpy" in locals():
@@ -47,28 +60,14 @@ else:
     from . import uv_to_mesh
 
 import bpy
-from mathutils import Vector
-#bpy.types.Object.vertexgroup = bpy.props.StringProperty()
-#bpy.types.Panel.vertexgroup = bpy.props.StringProperty()
-
-bl_info = {
-	"name": "Tissue",
-	"author": "Alessandro Zomparelli (Co-de-iT)",
-	"version": (0, 3, 2),
-	"blender": (2, 7, 9),
-	"location": "",
-	"description": "Tools for Computational Design",
-	"warning": "",
-	"wiki_url": ("http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/M"
-        "esh/Tissue"),
-	"tracker_url": "https://plus.google.com/u/0/+AlessandroZomparelli/",
-	"category": "Mesh"}
+from bpy.props import PointerProperty
 
 
 def register():
     bpy.utils.register_module(__name__)
-    bpy.types.Object.tissue_tessellate = bpy.props.PointerProperty(
-        type=tessellate_numpy.tissue_tessellate_prop)
+    bpy.types.Object.tissue_tessellate = PointerProperty(
+                                            type=tessellate_numpy.tissue_tessellate_prop
+                                            )
 
 
 def unregister():
@@ -78,6 +77,8 @@ def unregister():
     lattice.unregister()
     uv_to_mesh.unregister()
 
+    del bpy.types.Object.tissue_tessellate
+
 
 if __name__ == "__main__":
     register()
diff --git a/mesh_tissue/colors_groups_exchanger.py b/mesh_tissue/colors_groups_exchanger.py
index 49378c1e..b102a5b6 100644
--- a/mesh_tissue/colors_groups_exchanger.py
+++ b/mesh_tissue/colors_groups_exchanger.py
@@ -16,7 +16,7 @@
 #
 # ##### END GPL LICENSE BLOCK #####
 
-#-------------------------- COLORS / GROUPS EXCHANGER -------------------------#
+# ------------------------- COLORS / GROUPS EXCHANGER ------------------------ #
 #                                                                              #
 # Vertex Color to Vertex Group allow you to convert colors channles to weight  #
 # maps.                                                                        #
@@ -31,131 +31,172 @@
 #                                                                              #
 # http://www.co-de-it.com/                                                     #
 #                                                                              #
-################################################################################
-
-import bpy
-import math
-from math import pi, sin
+# ############################################################################ #
 
 bl_info = {
     "name": "Colors/Groups Exchanger",
     "author": "Alessandro Zomparelli (Co-de-iT)",
-    "version": (0, 3),
-    "blender": (2, 7, 9),
+    "version": (0, 3, 1),
+    "blender": (2, 7, 8),
     "location": "",
     "description": ("Convert vertex colors channels to vertex groups and vertex"
                     " groups to colors"),
     "warning": "",
     "wiki_url": "",
-    "tracker_url": "",
     "category": "Mesh"}
 
-class vertex_colors_to_vertex_groups(bpy.types.Operator):
+
+import bpy
+from bpy.props import (
+        BoolProperty,
+        EnumProperty,
+        FloatProperty,
+        IntProperty,
+        )
+from bpy.types import Operator
+from math import (
+        pi, sin,
+        )
+
+
+class vertex_colors_to_vertex_groups(Operator):
     bl_idname = "object.vertex_colors_to_vertex_groups"
     bl_label = "Vertex Color"
+    bl_description = ("Convert the active Vertex Color into a Vertex Group")
     bl_options = {'REGISTER', 'UNDO'}
-    bl_description = ("Convert the active Vertex Color into a Vertex Group.")
-
-    red = bpy.props.BoolProperty(
-        name="red channel", default=False, description="convert red channel")
-    green = bpy.props.BoolProperty(
-        name="green channel", default=False,
-        description="convert green channel")
-    blue = bpy.props.BoolProperty(
-        name="blue channel", default=False, description="convert blue channel")
-    value = bpy.props.BoolProperty(
-        name="value channel", default=True, description="convert value channel")
-    invert = bpy.props.BoolProperty(
-         name="invert", default=False, description="invert all color channels")
+
+    red = BoolProperty(
+            name="Red Channel",
+            default=False,
+            description="Convert Red Channel"
+            )
+    green = BoolProperty(
+            name="Green Channel",
+            default=False,
+            description="Convert Green Channel"
+            )
+    blue = BoolProperty(
+            name="Blue Channel",
+            default=False,
+            description="Convert Blue Channel"
+            )
+    value = BoolProperty(
+            name="Value Channel",
+            default=True,
+            description="Convert Value Channel"
+            )
+    invert = BoolProperty(
+            name="Invert",
+            default=False,
+            description="Invert all Color Channels"
+            )
 
     def execute(self, context):
         obj = bpy.context.active_object
-        id = len(obj.vertex_groups)
-        id_red = id
-        id_green = id
-        id_blue = id
-        id_value = id
+        ids = len(obj.vertex_groups)
+        id_red = ids
+        id_green = ids
+        id_blue = ids
+        id_value = ids
 
         boolCol = len(obj.data.vertex_colors)
-        if(boolCol): col_name = obj.data.vertex_colors.active.name
+        if boolCol:
+            col_name = obj.data.vertex_colors.active.name
         bpy.ops.object.mode_set(mode='EDIT')
         bpy.ops.mesh.select_all(action='SELECT')
 
-        if(self.red and boolCol):
+        if self.red and boolCol:
             bpy.ops.object.vertex_group_add()
             bpy.ops.object.vertex_group_assign()
-            id_red = id
+            id_red = ids
             obj.vertex_groups[id_red].name = col_name + '_red'
-            id+=1
-        if(self.green and boolCol):
+            ids += 1
+        if self.green and boolCol:
             bpy.ops.object.vertex_group_add()
             bpy.ops.object.vertex_group_assign()
-            id_green = id
+            id_green = ids
             obj.vertex_groups[id_green].name = col_name + '_green'
-            id+=1
-        if(self.blue and boolCol):
+            ids += 1
+        if self.blue and boolCol:
             bpy.ops.object.vertex_group_add()
             bpy.ops.object.vertex_group_assign()
-            id_blue = id
+            id_blue = ids
             obj.vertex_groups[id_blue].name = col_name + '_blue'
-            id+=1
-        if(self.value and boolCol):
+            ids += 1
+        if self.value and boolCol:
             bpy.ops.object.vertex_group_add()
             bpy.ops.object.vertex_group_assign()
-            id_value = id
+            id_value = ids
             obj.vertex_groups[id_value].name = col_name + '_value'
-            id+=1
+            ids += 1
 
         mult = 1
-        if(self.invert): mult = -1
+        if self.invert:
+            mult = -1
+
         bpy.ops.object.mode_set(mode='OBJECT')
         sub_red = 1 + self.value + self.blue + self.green
         sub_green = 1 + self.value + self.blue
         sub_blue = 1 + self.value
         sub_value = 1
 
-        id = len(obj.vertex_groups)
-        if(id_red <= id and id_green <= id and id_blue <= id and id_value <= \
-                id and boolCol):
+        ids = len(obj.vertex_groups)
+        if (id_red <= ids and id_green <= ids and id_blue <= ids and id_value <=
+                    ids and boolCol):
             v_colors = obj.data.vertex_colors.active.data
             i = 0
             for f in obj.data.polygons:
                 for v in f.vertices:
                     gr = obj.data.vertices[v].groups
-                    if(self.red): gr[min(len(gr)-sub_red, id_red)].weight = \
-                        self.invert + mult * v_colors[i].color.r
-                    if(self.green): gr[min(len(gr)-sub_green, id_green)].weight\
-                        = self.invert + mult * v_colors[i].color.g
-                    if(self.blue): gr[min(len(gr)-sub_blue, id_blue)].weight = \
-                        self.invert + mult * v_colors[i].color.b
-                    if(self.value): gr[min(len(gr)-sub_value, id_value)].weight\
-                        = self.invert + mult * v_colors[i].color.v
-                    i+=1
+                    if self.red:
+                        gr[min(len(gr) - sub_red, id_red)].weight = \
+                                self.invert + mult * v_colors[i].color.r
+
+                    if self.green:
+                        gr[min(len(gr) - sub_green, id_green)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list