[Bf-extensions-cvs] [0ca541cb] master: Fix T72115: Console Error to open Blender with Bsurfaces GPL Edition (1, 7, 5) addon activated

Spivak Vladimir cwolf3d noreply at git.blender.org
Mon Dec 2 21:38:04 CET 2019


Commit: 0ca541cbdb531c3c4ec50a147d9069dd37a4f181
Author: Spivak Vladimir (cwolf3d)
Date:   Mon Dec 2 22:37:34 2019 +0200
Branches: master
https://developer.blender.org/rBA0ca541cbdb531c3c4ec50a147d9069dd37a4f181

Fix T72115: Console Error to open Blender with Bsurfaces GPL Edition (1, 7, 5) addon activated

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

M	mesh_bsurfaces.py

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

diff --git a/mesh_bsurfaces.py b/mesh_bsurfaces.py
index d35b19cf..3232c582 100644
--- a/mesh_bsurfaces.py
+++ b/mesh_bsurfaces.py
@@ -20,7 +20,7 @@
 bl_info = {
     "name": "Bsurfaces GPL Edition",
     "author": "Eclectiel, Vladimir Spivak (cwolf3d)",
-    "version": (1, 7, 5),
+    "version": (1, 7, 6),
     "blender": (2, 80, 0),
     "location": "View3D EditMode > Sidebar > Edit Tab",
     "description": "Modeling and retopology tool",
@@ -87,9 +87,9 @@ class VIEW3D_PT_tools_SURFSK_mesh(Panel):
         col = layout.column(align=True)
         row = layout.row()
         row.separator()
-        col.operator("gpencil.surfsk_init", text="Initialize (Add BSurface mesh)")
-        col.operator("gpencil.surfsk_add_modifiers", text="Add Mirror and others modifiers")
-        
+        col.operator("mesh.surfsk_init", text="Initialize (Add BSurface mesh)")
+        col.operator("mesh.surfsk_add_modifiers", text="Add Mirror and others modifiers")
+
         col.label(text="Mesh of BSurface:")
         col.prop(scn, "SURFSK_mesh", text="")
         col.prop(scn, "SURFSK_mesh_color")
@@ -97,7 +97,7 @@ class VIEW3D_PT_tools_SURFSK_mesh(Panel):
         col.prop(scn, "SURFSK_in_front")
         col.prop(scn, "SURFSK_shade_smooth")
         col.prop(scn, "SURFSK_show_wire")
-        
+
         col.label(text="Guide strokes:")
         col.row().prop(scn, "SURFSK_guide", expand=True)
         if scn.SURFSK_guide == 'GPencil':
@@ -106,26 +106,26 @@ class VIEW3D_PT_tools_SURFSK_mesh(Panel):
         if scn.SURFSK_guide == 'Curve':
             col.prop(scn, "SURFSK_curve", text="")
             col.separator()
-        
+
         col.separator()
-        props = col.operator("gpencil.surfsk_add_surface", text="Add Surface")
-        col.operator("gpencil.surfsk_edit_surface", text="Edit Surface")
-        
+        props = col.operator("mesh.surfsk_add_surface", text="Add Surface")
+        col.operator("mesh.surfsk_edit_surface", text="Edit Surface")
+
         col.separator()
         if scn.SURFSK_guide == 'GPencil':
            col.operator("gpencil.surfsk_add_strokes", text="Add Strokes")
            col.operator("gpencil.surfsk_edit_strokes", text="Edit Strokes")
            col.separator()
            col.operator("gpencil.surfsk_strokes_to_curves", text="Strokes to curves")
-        
+
         if scn.SURFSK_guide == 'Annotation':
            col.operator("gpencil.surfsk_add_annotation", text="Add Annotation")
            col.separator()
            col.operator("gpencil.surfsk_annotations_to_curves", text="Annotation to curves")
-        
+
         if scn.SURFSK_guide == 'Curve':
-           col.operator("gpencil.surfsk_edit_curve", text="Edit curve")
-        
+           col.operator("curve.surfsk_edit_curve", text="Edit curve")
+
         col.separator()
         col.label(text="Initial settings:")
         col.prop(scn, "SURFSK_edges_U")
@@ -135,7 +135,7 @@ class VIEW3D_PT_tools_SURFSK_mesh(Panel):
         col.prop(scn, "SURFSK_loops_on_strokes")
         col.prop(scn, "SURFSK_automatic_join")
         col.prop(scn, "SURFSK_keep_strokes")
-        
+
 class VIEW3D_PT_tools_SURFSK_curve(Panel):
     bl_space_type = 'VIEW_3D'
     bl_region_type = 'UI'
@@ -168,21 +168,21 @@ def get_strokes_type(context):
     if context.scene.bsurfaces.SURFSK_guide == 'Annotation':
         try:
             strokes = bpy.data.grease_pencils[0].layers.active.active_frame.strokes
-        
+
             strokes_num = len(strokes)
 
             if strokes_num > 0:
                strokes_type = "GP_ANNOTATION"
         except:
             strokes_type = "NO_STROKES"
-    
+
     # Check if they are grease pencil
     if context.scene.bsurfaces.SURFSK_guide == 'GPencil':
         try:
             global global_gpencil_object
             gpencil = bpy.data.objects[global_gpencil_object]
             strokes = gpencil.data.layers.active.active_frame.strokes
-        
+
             strokes_num = len(strokes)
 
             if strokes_num > 0:
@@ -198,7 +198,7 @@ def get_strokes_type(context):
             if ob.type == "CURVE":
                 strokes_type = "EXTERNAL_CURVE"
                 strokes_num = len(ob.data.splines)
-        
+
                 # Check if there is any non-bezier spline
                 for i in range(len(ob.data.splines)):
                     if ob.data.splines[i].type != "BEZIER":
@@ -215,7 +215,7 @@ def get_strokes_type(context):
         global global_mesh_object
         self.main_object = bpy.data.objects[global_mesh_object]
         total_vert_sel = len([v for v in self.main_object.data.vertices if v.select])
-    
+
         # Check if there is a single stroke without any selection in the object
         if strokes_num == 1 and total_vert_sel == 0:
             if strokes_type == "EXTERNAL_CURVE":
@@ -227,13 +227,13 @@ def get_strokes_type(context):
             strokes_type = "SELECTION_ALONE"
     except:
         pass
-        
+
     return strokes_type
 
 # ----------------------------
 # Surface generator operator
-class GPENCIL_OT_SURFSK_add_surface(Operator):
-    bl_idname = "gpencil.surfsk_add_surface"
+class MESH_OT_SURFSK_add_surface(Operator):
+    bl_idname = "mesh.surfsk_add_surface"
     bl_label = "Bsurfaces add surface"
     bl_description = "Generates surfaces from grease pencil strokes, bezier curves or loose edges"
     bl_options = {'REGISTER', 'UNDO'}
@@ -265,7 +265,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
     selection_U2_is_closed: BoolProperty(
                     default=False
                     )
-    
+
     edges_U: IntProperty(
                     name="Cross",
                     description="Number of face-loops crossing the strokes",
@@ -360,7 +360,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
                 col.separator()
                 row.separator()
                 col.prop(self, "join_stretch_factor")
-            
+
             col.prop(self, "keep_strokes")
 
     # Get an ordered list of a chain of vertices
@@ -1061,7 +1061,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
         bpy.ops.object.mode_set('INVOKE_REGION_WIN', mode='EDIT')
         bpy.ops.mesh.normals_make_consistent(inside=False)
         bpy.ops.object.mode_set('INVOKE_REGION_WIN', mode='OBJECT')
-        
+
         self.update()
 
         return num_faces_created
@@ -1693,40 +1693,44 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
                 # and compare it with the distance they would have if joined.
                 # If they don't change much, that vert can be joined
                 merge_actual_vert = True
-                if len(surface_connected_verts[i]) < 4:
-                    for c_v_idx in surface_connected_verts[i]:
-                        points_original = []
-                        points_original.append(ob_surface.data.vertices[c_v_idx].co)
-                        points_original.append(ob_surface.data.vertices[i].co)
+                try:
+                    if len(surface_connected_verts[i]) < 4:
+                        for c_v_idx in surface_connected_verts[i]:
+                            points_original = []
+                            points_original.append(ob_surface.data.vertices[c_v_idx].co)
+                            points_original.append(ob_surface.data.vertices[i].co)
 
-                        points_target = []
-                        points_target.append(ob_surface.data.vertices[c_v_idx].co)
-                        points_target.append(final_ob_duplicate.data.vertices[i].co)
+                            points_target = []
+                            points_target.append(ob_surface.data.vertices[c_v_idx].co)
+                            points_target.append(final_ob_duplicate.data.vertices[i].co)
 
-                        vec_A = points_original[0] - points_original[1]
-                        vec_B = points_target[0] - points_target[1]
+                            vec_A = points_original[0] - points_original[1]
+                            vec_B = points_target[0] - points_target[1]
 
-                        dist_A = (points_original[0] - points_original[1]).length
-                        dist_B = (points_target[0] - points_target[1]).length
+                            dist_A = (points_original[0] - points_original[1]).length
+                            dist_B = (points_target[0] - points_target[1]).length
 
-                        if not (
-                           points_original[0] == points_original[1] or
-                           points_target[0] == points_target[1]
-                           ):  # If any vector's length is zero
+                            if not (
+                               points_original[0] == points_original[1] or
+                               points_target[0] == points_target[1]
+                               ):  # If any vector's length is zero
 
-                            angle = vec_A.angle(vec_B) / pi
-                        else:
-                            angle = 0
+                                angle = vec_A.angle(vec_B) / pi
+                            else:
+                                angle = 0
 
-                        # Set a range of acceptable variation in the connected edges
-                        if dist_B > dist_A * 1.7 * self.join_stretch_factor or \
-                           dist_B < dist_A / 2 / self.join_stretch_factor or \
-                           angle >= 0.15 * self.join_stretch_factor:
+                            # Set a range of acceptable variation in the connected edges
+                            if dist_B > dist_A * 1.7 * self.join_stretch_factor or \
+                               dist_B < dist_A / 2 / self.join_stretch_factor or \
+                               angle >= 0.15 * self.join_stretch_factor:
 
-                            merge_actual_vert = False
-                            break
-                else:
-                    merge_actual_vert = False
+                                merge_actual_vert = False
+                                break
+                    else:
+                        merge_actual_vert = False
+                except:
+                    self.report({'WARNING'},
+                  

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list