[Bf-extensions-cvs] [88dac155] master: Update addon to Blender 2.80

Spivak Vladimir cwolf3d noreply at git.blender.org
Sat May 4 03:52:43 CEST 2019


Commit: 88dac15512756ce423d5c2f0c208995761d8fb31
Author: Spivak Vladimir (cwolf3d)
Date:   Sat May 4 04:50:23 2019 +0300
Branches: master
https://developer.blender.org/rBA88dac15512756ce423d5c2f0c208995761d8fb31

Update addon to Blender 2.80

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

M	mesh_bsurfaces.py

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

diff --git a/mesh_bsurfaces.py b/mesh_bsurfaces.py
index 9cbcd0e0..04168fd7 100644
--- a/mesh_bsurfaces.py
+++ b/mesh_bsurfaces.py
@@ -19,9 +19,9 @@
 
 bl_info = {
     "name": "Bsurfaces GPL Edition",
-    "author": "Eclectiel",
+    "author": "Eclectiel, Spivak Vladimir(cwolf3d)",
     "version": (1, 5, 1),
-    "blender": (2, 76, 0),
+    "blender": (2, 80, 0),
     "location": "View3D > EditMode > ToolShelf",
     "description": "Modeling and retopology tool",
     "wiki_url": "https://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Bsurfaces_1.5",
@@ -31,9 +31,10 @@ bl_info = {
 
 import bpy
 import bmesh
+from bpy_extras import object_utils
 
 import operator
-from mathutils import Vector
+from mathutils import Matrix, Vector
 from mathutils.geometry import (
         intersect_line_line,
         intersect_point_line,
@@ -60,7 +61,7 @@ from bpy.types import (
 
 class VIEW3D_PT_tools_SURFSK_mesh(Panel):
     bl_space_type = 'VIEW_3D'
-    bl_region_type = 'TOOLS'
+    bl_region_type = 'UI'
     bl_category = 'Tools'
     bl_context = "mesh_edit"
     bl_label = "Bsurfaces"
@@ -77,6 +78,7 @@ class VIEW3D_PT_tools_SURFSK_mesh(Panel):
         row = layout.row()
         row.separator()
         col.operator("gpencil.surfsk_add_surface", text="Add Surface")
+        col.operator("gpencil.surfsk_add_strokes", text="Add Strokes")
         col.operator("gpencil.surfsk_edit_strokes", text="Edit Strokes")
         col.prop(scn, "SURFSK_cyclic_cross")
         col.prop(scn, "SURFSK_cyclic_follow")
@@ -87,7 +89,7 @@ class VIEW3D_PT_tools_SURFSK_mesh(Panel):
 
 class VIEW3D_PT_tools_SURFSK_curve(Panel):
     bl_space_type = 'VIEW_3D'
-    bl_region_type = 'TOOLS'
+    bl_region_type = 'UI'
     bl_context = "curve_edit"
     bl_category = 'Tools'
     bl_label = "Bsurfaces"
@@ -114,11 +116,15 @@ def get_strokes_type(main_object):
 
     # Check if they are grease pencil
     try:
-        # Get the active grease pencil layer
-        strokes_num = len(main_object.grease_pencil.layers.active.active_frame.strokes)
-
-        if strokes_num > 0:
-            strokes_type = "GP_STROKES"
+       # Get the active grease pencil layer
+       gpencil = bpy.context.scene.objects['GPencil']
+       layer = gpencil.data.layers[0]
+       frame = layer.frames[0]
+        
+       strokes_num = len(frame.strokes)
+
+       if strokes_num > 0:
+           strokes_type = "GP_STROKES"
     except:
         pass
 
@@ -354,7 +360,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
         matrix = object.matrix_world
 
         for i in range(0, len(verts_idx)):
-            dist = (point_co - matrix * object.data.vertices[verts_idx[i]].co).length
+            dist = (point_co - matrix @ object.data.vertices[verts_idx[i]].co).length
             if i == 0:
                 prev_dist = dist
                 nearest_vert_idx = verts_idx[i]
@@ -399,7 +405,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
         # from grease pencil and wasn't made by hand, delete it
         if not self.using_external_curves:
             try:
-                bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
+                bpy.ops.object.select_all(action='DESELECT')
                 self.original_curve.select_set(True)
                 bpy.context.view_layer.objects.active = self.original_curve
 
@@ -407,11 +413,11 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
             except:
                 pass
 
-            bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
+            bpy.ops.object.select_all(action='DESELECT')
             self.main_object.select_set(True)
             bpy.context.view_layer.objects.active = self.main_object
         else:
-            bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
+            bpy.ops.object.select_all(action='DESELECT')
             self.original_curve.select_set(True)
             self.main_object.select_set(True)
             bpy.context.view_layer.objects.active = self.main_object
@@ -995,8 +1001,8 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
                                     )
                 self.main_object.modifiers[m_idx].show_viewport = False
 
-        bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
-        ob_original_splines.select = True
+        bpy.ops.object.select_all(action='DESELECT')
+        ob_original_splines.select_set(True)
         bpy.context.view_layer.objects.active = ob_original_splines
 
         if len(ob_original_splines.data.splines) >= 2:
@@ -1121,8 +1127,8 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
 
                 self.crosshatch_merge_distance = shortest_dist / 3
 
-            bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
-            ob_splines.select = True
+            bpy.ops.object.select_all(action='DESELECT')
+            ob_splines.select_set(True)
             bpy.context.view_layer.objects.active = ob_splines
 
             # Deselect all points
@@ -1309,7 +1315,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
 
         # Delete all duplicates
         for o in objects_to_delete:
-            bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
+            bpy.ops.object.select_all(action='DESELECT')
             o.select_set(True)
             bpy.context.view_layer.objects.active = o
             bpy.ops.object.delete()
@@ -1357,7 +1363,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
         ob.data = me
         bpy.context.collection.objects.link(ob)
 
-        bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
+        bpy.ops.object.select_all(action='DESELECT')
         ob.select_set(True)
         bpy.context.view_layer.objects.active = ob
 
@@ -1536,15 +1542,15 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
         bpy.context.collection.objects.link(ob_surface)
 
         # Delete final points temporal object
-        bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
-        final_points_ob.select = True
+        bpy.ops.object.select_all(action='DESELECT')
+        final_points_ob.select_set(True)
         bpy.context.view_layer.objects.active = final_points_ob
 
         bpy.ops.object.delete()
 
         # Delete isolated verts if there are any
-        bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
-        ob_surface.select = True
+        bpy.ops.object.select_all(action='DESELECT')
+        ob_surface.select_set(True)
         bpy.context.view_layer.objects.active = ob_surface
 
         bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
@@ -1601,7 +1607,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
         # Make list with verts of original mesh as index and coords as value
         main_object_verts_coords = []
         for v in self.main_object.data.vertices:
-            coords = self.main_object.matrix_world * v.co
+            coords = self.main_object.matrix_world @ v.co
 
             # To avoid problems when taking "-0.00" as a different value as "0.00"
             for c in range(len(coords)):
@@ -1673,22 +1679,22 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
                            self.main_object_selected_verts_count == 0:
 
                             ob_surface.data.vertices[i].co = final_ob_duplicate.data.vertices[i].co
-                            ob_surface.data.vertices[i].select = True
+                            ob_surface.data.vertices[i].select_set(True)
                             crosshatch_verts_to_merge.append(i)
 
                             # Make sure the vert in the main object is selected,
                             # in case it wasn't selected and the "join crosshatch" option is active
-                            self.main_object.data.vertices[main_object_related_vert_idx].select = True
+                            self.main_object.data.vertices[main_object_related_vert_idx].select_set(True)
 
         # Delete duplicated object
-        bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
+        bpy.ops.object.select_all(action='DESELECT')
         final_ob_duplicate.select_set(True)
         bpy.context.view_layer.objects.active = final_ob_duplicate
         bpy.ops.object.delete()
 
         # Join crosshatched surface and main object
-        bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
-        ob_surface.select = True
+        bpy.ops.object.select_all(action='DESELECT')
+        ob_surface.select_set(True)
         self.main_object.select_set(True)
         bpy.context.view_layer.objects.active = self.main_object
 
@@ -1892,8 +1898,8 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
 
         bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
 
-        bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
-        self.main_splines.select = True
+        bpy.ops.object.select_all(action='DESELECT')
+        self.main_splines.select_set(True)
         bpy.context.view_layer.objects.active = self.main_splines
 
         # Enter editmode for the new curve (converted from grease pencil strokes), to smooth it out
@@ -1932,16 +1938,16 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
             points_first_stroke_tips = []
 
             points_A.append(
-                self.main_object.matrix_world * self.main_object.data.vertices[verts_tips_parsed_idx[0]].co
+                self.main_object.matrix_world @ self.main_object.data.vertices[verts_tips_parsed_idx[0]].co
                 )
             points_A.append(
-                self.main_object.matrix_world * self.main_object.data.vertices[middle_vertex_idx].co
+                self.main_object.matrix_world @ self.main_object.data.vertices[middle_vertex_idx].co
                 )
             points_B.append(
-                self.main_object.matrix_world * self.main_object.data.vertices[verts_tips_parsed_idx[1]].co
+                self.main_object.matrix_world @ self.main_object.data.vertices[verts_tips_parsed_idx[1]].co
                 )
             points_B.append(
-                self.main_object.matrix_world * self.main_object.data.vertices[middle_vertex_idx].co
+                self.main_object.mat

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list