[Bf-extensions-cvs] [f5b53cdc] master: Bsurfaces: Redesign. Fixing some problem.

Spivak Vladimir cwolf3d noreply at git.blender.org
Mon May 6 01:16:00 CEST 2019


Commit: f5b53cdcb7ee56a56aac770ec310f5f3192344e0
Author: Spivak Vladimir (cwolf3d)
Date:   Mon May 6 02:14:44 2019 +0300
Branches: master
https://developer.blender.org/rBAf5b53cdcb7ee56a56aac770ec310f5f3192344e0

Bsurfaces: Redesign. Fixing some problem.

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

M	mesh_bsurfaces.py

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

diff --git a/mesh_bsurfaces.py b/mesh_bsurfaces.py
index deae842b..e1548771 100644
--- a/mesh_bsurfaces.py
+++ b/mesh_bsurfaces.py
@@ -63,13 +63,9 @@ class VIEW3D_PT_tools_SURFSK_mesh(Panel):
     bl_space_type = 'VIEW_3D'
     bl_region_type = 'UI'
     bl_category = 'Tools'
-    bl_context = "mesh_edit"
+    #bl_context = "mesh_edit"
     bl_label = "Bsurfaces"
 
-    @classmethod
-    def poll(cls, context):
-        return context.active_object
-
     def draw(self, context):
         layout = self.layout
         scn = context.scene.bsurfaces
@@ -77,6 +73,10 @@ class VIEW3D_PT_tools_SURFSK_mesh(Panel):
         col = layout.column(align=True)
         row = layout.row()
         row.separator()
+        col.operator("gpencil.surfsk_init", text="Initialize")
+        col.prop(scn, "SURFSK_mesh_name")
+        col.prop(scn, "SURFSK_gpencil_name")
+        col.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")
@@ -85,8 +85,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'
@@ -110,14 +109,13 @@ class VIEW3D_PT_tools_SURFSK_curve(Panel):
 
 
 # Returns the type of strokes used
-def get_strokes_type(main_object):
+def get_strokes_type():
     strokes_type = ""
     strokes_num = 0
 
     # Check if they are grease pencil
     try:
-       # Get the active grease pencil layer
-       gpencil = bpy.context.scene.objects['GPencil']
+       gpencil = bpy.context.scene.objects[bpy.context.scene.bsurfaces.SURFSK_gpencil_name]
        layer = gpencil.data.layers[0]
        frame = layer.frames[0]
         
@@ -127,6 +125,12 @@ def get_strokes_type(main_object):
            strokes_type = "GP_STROKES"
     except:
         pass
+        
+    # Check if they are mesh
+    try:
+       main_object = bpy.context.scene.objects[bpy.context.scene.bsurfaces.SURFSK_mesh_name]
+    except:
+        pass
 
     # Check if they are curves, if there aren't grease pencil strokes
     if strokes_type == "":
@@ -170,6 +174,34 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
     bl_description = "Generates surfaces from grease pencil strokes, bezier curves or loose edges"
     bl_options = {'REGISTER', 'UNDO'}
 
+    is_fill_faces: BoolProperty(
+                    default=True
+                    )
+    selection_U_exists: BoolProperty(
+                    default=False
+                    )
+    selection_V_exists: BoolProperty(
+                    default=False
+                    )
+    selection_U2_exists: BoolProperty(
+                    default=False
+                    )
+    selection_V2_exists: BoolProperty(
+                    default=False
+                    )
+    selection_V_is_closed: BoolProperty(
+                    default=False
+                    )
+    selection_U_is_closed: BoolProperty(
+                    default=False
+                    )
+    selection_V2_is_closed: BoolProperty(
+                    default=False
+                    )
+    selection_U2_is_closed: BoolProperty(
+                    default=False
+                    )
+    
     edges_U: IntProperty(
                     name="Cross",
                     description="Number of face-loops crossing the strokes",
@@ -214,6 +246,14 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
                     max=3,
                     subtype='FACTOR'
                     )
+    keep_strokes: BoolProperty(
+                name="Keep strokes",
+                description="Keeps the sketched strokes or curves after adding the surface",
+                default=False
+                )
+    strokes_type: StringProperty()
+    initial_global_undo_state: BoolProperty()
+    
 
     def draw(self, context):
         layout = self.layout
@@ -256,6 +296,8 @@ 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
     def get_ordered_verts(self, ob, all_selected_edges_idx, all_selected_verts_idx,
@@ -405,17 +447,11 @@ 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')
-                self.original_curve.select_set(True)
-                bpy.context.view_layer.objects.active = self.original_curve
-
-                bpy.ops.object.delete()
+                bpy.ops.object.delete({"selected_objects": [self.original_curve]})
             except:
                 pass
 
-            bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
-            self.main_object.select_set(True)
-            bpy.context.view_layer.objects.active = self.main_object
+            bpy.ops.object.delete({"selected_objects": [self.main_object]})
         else:
             bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
             self.original_curve.select_set(True)
@@ -1314,11 +1350,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
                 self.is_crosshatch = False
 
         # Delete all duplicates
-        for o in objects_to_delete:
-            bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
-            o.select_set(True)
-            bpy.context.view_layer.objects.active = o
-            bpy.ops.object.delete()
+        bpy.ops.object.delete({"selected_objects": objects_to_delete})
 
         # If the main object has modifiers, turn their "viewport view status" to
         # what it was before the forced deactivation above
@@ -1542,11 +1574,7 @@ 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_set(True)
-        bpy.context.view_layer.objects.active = final_points_ob
-
-        bpy.ops.object.delete()
+        bpy.ops.object.delete({"selected_objects": [final_points_ob]})
 
         # Delete isolated verts if there are any
         bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
@@ -1687,10 +1715,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
                             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')
-        final_ob_duplicate.select_set(True)
-        bpy.context.view_layer.objects.active = final_ob_duplicate
-        bpy.ops.object.delete()
+        bpy.ops.object.delete({"selected_objects": [final_ob_duplicate]})
 
         # Join crosshatched surface and main object
         bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
@@ -2495,11 +2520,7 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
                             ob_simplified_curve[i].data.splines[0].bezier_points[t].co
 
                 # Delete the temporal curve
-                bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
-                ob_simplified_curve[i].select_set(True)
-                bpy.context.view_layer.objects.active = ob_simplified_curve[i]
-
-                bpy.ops.object.delete()
+                bpy.ops.object.delete({"selected_objects": [ob_simplified_curve[i]]})
 
         # Get the coords of the points distributed along the sketched strokes,
         # with proportions-U of the first selection
@@ -2980,18 +3001,9 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
                             surface_splines_parsed[len(surface_splines_parsed) - 1][i] = verts_middle_position_co
 
         # Delete object with control points and object from grease pencil conversion
-        bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
-        ob_ctrl_pts.select_set(True)
-        bpy.context.view_layer.objects.active = ob_ctrl_pts
-
-        bpy.ops.object.delete()
+        bpy.ops.object.delete({"selected_objects": [ob_ctrl_pts]})
 
-        for sp_ob in splines_U_objects:
-            bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
-            sp_ob.select_set(True)
-            bpy.context.view_layer.objects.active = sp_ob
-
-            bpy.ops.object.delete()
+        bpy.ops.object.delete({"selected_objects": splines_U_objects})
 
         # Generate surface
 
@@ -3043,7 +3055,12 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
 
     def execute(self, context):
 
-        self.main_object = bpy.context.view_layer.objects.active
+        bsurfaces_props = bpy.context.scene.bsurfaces
+        
+        bpy.context.scene.objects[bsurfaces_props.SURFSK_gpencil_name].select_set(True)
+        self.main_object = bpy.context.scene.objects[bsurfaces_props.SURFSK_mesh_name]
+        self.main_object.select_set(True)
+        bpy.context.view_layer.objects.active = self.main_object
         
         bpy.context.preferences.edit.use_global_undo = False
 
@@ -3105,17 +3122,16 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
 
             # Delete main splines
             bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
-
-            bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
-            self.main_splines.select_set(True)
-            bpy.context.view_layer.objects.active = self.main_splines
-
-            bpy.ops.object.delete()
+            bpy.ops.object.delete({"selected_objects": [self.main_splines]})
 
             bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
             self.main_object.select_set(True)
             bpy.context.view_layer.objects.active = self.main_object
 
+            # D

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list