[Bf-extensions-cvs] [856c1b92] master: mesh tissue: update panels by Alessandro

meta-androcto noreply at git.blender.org
Fri Jun 16 01:24:20 CEST 2017


Commit: 856c1b92841d552cd763b678d75f74c214bdb963
Author: meta-androcto
Date:   Fri Jun 16 09:23:53 2017 +1000
Branches: master
https://developer.blender.org/rBA856c1b92841d552cd763b678d75f74c214bdb963

mesh tissue: update panels by Alessandro

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

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

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

diff --git a/mesh_tissue/__init__.py b/mesh_tissue/__init__.py
index ee264060..7c1e7fba 100644
--- a/mesh_tissue/__init__.py
+++ b/mesh_tissue/__init__.py
@@ -36,7 +36,6 @@ if "bpy" in locals():
     importlib.reload(tessellate_numpy)
     importlib.reload(colors_groups_exchanger)
     importlib.reload(dual_mesh)
-    importlib.reload(lattice)
 
 else:
     from . import tessellate_numpy
@@ -52,8 +51,8 @@ from mathutils import Vector
 bl_info = {
 	"name": "Tissue",
 	"author": "Alessandro Zomparelli (Co-de-iT)",
-	"version": (0, 3, 0),
-	"blender": (2, 7, 8),
+	"version": (0, 3, 1),
+	"blender": (2, 7, 9),
 	"location": "",
 	"description": "Tools for Computational Design",
 	"warning": "",
@@ -75,5 +74,6 @@ def unregister():
     dual_mesh.unregister()
     lattice.unregister()
 
+
 if __name__ == "__main__":
     register()
diff --git a/mesh_tissue/colors_groups_exchanger.py b/mesh_tissue/colors_groups_exchanger.py
index 5bd69f92..39b3c115 100644
--- a/mesh_tissue/colors_groups_exchanger.py
+++ b/mesh_tissue/colors_groups_exchanger.py
@@ -229,7 +229,7 @@ class curvature_to_vertex_groups(bpy.types.Operator):
       max=1, description="Blur strength per iteration")
 
     blur_iterations = bpy.props.IntProperty(
-      name="Blur Strength", default=1, min=0,
+      name="Blur Iterations", default=1, min=0,
       max=40, description="Number of times to blur the values")
 
     min_angle = bpy.props.FloatProperty(
@@ -251,6 +251,7 @@ class curvature_to_vertex_groups(bpy.types.Operator):
         vertex_colors[-1].active = True
         vertex_colors[-1].active_render = True
         vertex_colors[-1].name = "Curvature"
+        for c in vertex_colors[-1].data: c.color.r, c.color.g, c.color.b = 1,1,1
         bpy.ops.object.mode_set(mode='VERTEX_PAINT')
         bpy.ops.paint.vertex_color_dirt(blur_strength=self.blur_strength, blur_iterations=self.blur_iterations, clean_angle=self.max_angle, dirt_angle=self.min_angle)
         bpy.ops.object.vertex_colors_to_vertex_groups(invert=self.invert)
@@ -313,7 +314,7 @@ class face_area_to_vertex_groups(bpy.types.Operator):
 
 
 class colors_groups_exchanger_panel(bpy.types.Panel):
-    bl_label = "Tissue Data Tools"
+    bl_label = "Tissue Tools"
     bl_category = "Tools"
     bl_space_type = "VIEW_3D"
     bl_region_type = "TOOLS"
@@ -321,22 +322,21 @@ class colors_groups_exchanger_panel(bpy.types.Panel):
     #bl_context = "objectmode"
 
     def draw(self, context):
-        layout = self.layout
-        col = layout.column(align=True)
-        col.label(text="Create Vertex Groups:")
-        col.operator(
-            "object.vertex_colors_to_vertex_groups", icon="GROUP_VCOL")
-        col.operator("object.face_area_to_vertex_groups", icon="SNAP_FACE")
-        col.operator("object.curvature_to_vertex_groups", icon="SURFACE_DATA")
-
-        col.separator()
-        col.label(text="Create Vertex Colors:")
-        col.operator("object.vertex_group_to_vertex_colors", icon="GROUP_VERTEX")
-        col.separator()
-        col.label(text="Lattice Along Surface:")
         try:
-            col.operator("object.lattice_along_surface", icon="MOD_LATTICE")
-
+            if bpy.context.active_object.type == 'MESH':
+                layout = self.layout
+                col = layout.column(align=True)
+                col.label(text="Transform:")
+                col.operator("object.dual_mesh")
+                col.separator()
+                col.label(text="Weight from:")
+                col.operator(
+                    "object.vertex_colors_to_vertex_groups", icon="GROUP_VCOL")
+                col.operator("object.face_area_to_vertex_groups", icon="SNAP_FACE")
+                col.operator("object.curvature_to_vertex_groups", icon="SMOOTHCURVE")
+                col.separator()
+                col.label(text="Vertex Color from:")
+                col.operator("object.vertex_group_to_vertex_colors", icon="GROUP_VERTEX")
         except:
             pass
 
diff --git a/mesh_tissue/dual_mesh.py b/mesh_tissue/dual_mesh.py
index 808271d4..29926250 100644
--- a/mesh_tissue/dual_mesh.py
+++ b/mesh_tissue/dual_mesh.py
@@ -48,7 +48,7 @@ class dual_mesh(bpy.types.Operator):
     bl_idname = "object.dual_mesh"
     bl_label = "Dual Mesh"
     bl_options = {'REGISTER', 'UNDO'}
-    bl_description = ("Convert a generic mesh to its dual.")
+    bl_description = ("Convert a generic mesh into a polygonal mesh.")
 
     quad_method = bpy.props.EnumProperty(
         items=[('BEAUTY', 'Beauty',
@@ -75,14 +75,31 @@ class dual_mesh(bpy.types.Operator):
         name="Preserve Borders", default=True,
         description="Preserve original borders")
 
+    apply_modifiers = bpy.props.BoolProperty(
+        name="Apply Modifiers", default=True,
+        description="Apply object's modifiers")
+
     def execute(self, context):
+        mode = context.mode
+        if mode == 'EDIT_MESH': mode = 'EDIT'
         act = bpy.context.active_object
-        sel = bpy.context.selected_objects
+        if mode != 'OBJECT':
+            sel = [act]
+            bpy.ops.object.mode_set(mode='OBJECT')
+        else: sel = bpy.context.selected_objects
         doneMeshes = []
+        '''
+        if self.new_object:
+            bpy.ops.object.duplicate_move()
+            for i in range(len(sel)):
+                bpy.context.selected_objects[i].name = sel[i].name + "_dual"
+                if sel[i] == act:
+                    bpy.context.scene.objects.active = bpy.context.selected_objects[i]
+            sel = bpy.context.selected_objects
+        '''
         for ob0 in sel:
             if ob0.type != 'MESH': continue
             if ob0.data.name in doneMeshes: continue
-            ##ob = bpy.data.objects.new("dual_mesh_wip", ob0.data.copy())
             ob = ob0
             mesh_name = ob0.data.name
 
@@ -96,31 +113,33 @@ class dual_mesh(bpy.types.Operator):
                     count+=1
                     clones.append(o)
                 if count == n_users: break
+            if self.apply_modifiers: bpy.ops.object.convert(target='MESH')
             ob.data = ob.data.copy()
             bpy.ops.object.select_all(action='DESELECT')
             ob.select = True
             bpy.context.scene.objects.active = ob0
             bpy.ops.object.mode_set(mode = 'EDIT')
 
-            if self.preserve_borders:
-                bpy.ops.mesh.select_mode(
-                    use_extend=False, use_expand=False, type='EDGE')
-                bpy.ops.mesh.select_non_manifold(
-                    extend=False, use_wire=False, use_boundary=True,
-                    use_multi_face=False, use_non_contiguous=False,
-                    use_verts=False)
-                bpy.ops.mesh.extrude_region_move(
-                    MESH_OT_extrude_region={"mirror":False},
-                    TRANSFORM_OT_translate={"value":(0, 0, 0),
-                    "constraint_axis":(False, False, False),
-                    "constraint_orientation":'GLOBAL', "mirror":False,
-                    "proportional":'DISABLED',
-                    "proportional_edit_falloff":'SMOOTH', "proportional_size":1,
-                    "snap":False, "snap_target":'CLOSEST',
-                    "snap_point":(0, 0, 0), "snap_align":False,
-                    "snap_normal":(0, 0, 0), "gpencil_strokes":False,
-                    "texture_space":False, "remove_on_cancel":False,
-                    "release_confirm":False})
+            # prevent borders erosion
+            bpy.ops.mesh.select_mode(
+                use_extend=False, use_expand=False, type='EDGE')
+            bpy.ops.mesh.select_non_manifold(
+                extend=False, use_wire=False, use_boundary=True,
+                use_multi_face=False, use_non_contiguous=False,
+                use_verts=False)
+            bpy.ops.mesh.extrude_region_move(
+                MESH_OT_extrude_region={"mirror":False},
+                TRANSFORM_OT_translate={"value":(0, 0, 0),
+                "constraint_axis":(False, False, False),
+                "constraint_orientation":'GLOBAL', "mirror":False,
+                "proportional":'DISABLED',
+                "proportional_edit_falloff":'SMOOTH', "proportional_size":1,
+                "snap":False, "snap_target":'CLOSEST',
+                "snap_point":(0, 0, 0), "snap_align":False,
+                "snap_normal":(0, 0, 0), "gpencil_strokes":False,
+                "texture_space":False, "remove_on_cancel":False,
+                "release_confirm":False})
+
 
             bpy.ops.mesh.select_mode(
                 use_extend=False, use_expand=False, type='VERT',
@@ -132,6 +151,9 @@ class dual_mesh(bpy.types.Operator):
             bpy.ops.object.mode_set(mode = 'OBJECT')
             bpy.ops.object.modifier_add(type='SUBSURF')
             ob.modifiers[-1].name = "dual_mesh_subsurf"
+            while True:
+                bpy.ops.object.modifier_move_up(modifier="dual_mesh_subsurf")
+                if ob.modifiers[0].name == "dual_mesh_subsurf": break
             bpy.ops.object.modifier_apply(
                 apply_as='DATA', modifier='dual_mesh_subsurf')
 
@@ -199,6 +221,14 @@ class dual_mesh(bpy.types.Operator):
             bpy.ops.mesh.dissolve_verts()
             bpy.ops.mesh.select_all(action = 'DESELECT')
 
+            # remove border faces
+            if not self.preserve_borders:
+                bpy.ops.mesh.select_non_manifold(
+                    extend=False, use_wire=False, use_boundary=True,
+                    use_multi_face=False, use_non_contiguous=False, use_verts=False)
+                bpy.ops.mesh.select_more()
+                bpy.ops.mesh.delete(type='FACE')
+
             # clean wires
             bpy.ops.mesh.select_non_manifold(
                 extend=False, use_wire=True, use_boundary=False,
@@ -211,16 +241,16 @@ class dual_mesh(bpy.types.Operator):
             for o in clones: o.data = ob.data
         for o in sel: o.select = True
         bpy.context.scene.objects.active = act
+        bpy.ops.object.mode_set(mode=mode)
         return {'FINISHED'}
 
 '''
 class dual_mesh_panel(bpy.types.Panel):
     bl_label = "Dual Mesh"
-    bl_category = "Create"
+    bl_category = "Tools"
     bl_space_type = "VIEW_3D"


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list