[Bf-extensions-cvs] [0592bfec] master: Bsurfaces: Added "annotations" as guide strokes
Spivak Vladimir cwolf3d
noreply at git.blender.org
Fri May 10 00:58:07 CEST 2019
Commit: 0592bfecec826725e1bffecf4dd18dddbec31982
Author: Spivak Vladimir (cwolf3d)
Date: Fri May 10 01:55:56 2019 +0300
Branches: master
https://developer.blender.org/rBA0592bfecec826725e1bffecf4dd18dddbec31982
Bsurfaces: Added "annotations" as guide strokes
===================================================================
M mesh_bsurfaces.py
===================================================================
diff --git a/mesh_bsurfaces.py b/mesh_bsurfaces.py
index 4bc6534a..ab052695 100644
--- a/mesh_bsurfaces.py
+++ b/mesh_bsurfaces.py
@@ -75,12 +75,20 @@ class VIEW3D_PT_tools_SURFSK_mesh(Panel):
row.separator()
col.operator("gpencil.surfsk_init", text="Initialize")
col.prop(scn, "SURFSK_object_with_retopology")
- col.prop(scn, "SURFSK_object_with_strokes")
+ col.prop(scn, "SURFSK_use_annotation")
+ if not scn.SURFSK_use_annotation:
+ col.prop(scn, "SURFSK_object_with_strokes")
col.separator()
col.operator("gpencil.surfsk_add_surface", text="Add Surface")
col.operator("gpencil.surfsk_edit_surface", text="Edit Surface")
- col.operator("gpencil.surfsk_add_strokes", text="Add Strokes")
- col.operator("gpencil.surfsk_edit_strokes", text="Edit Strokes")
+ if not scn.SURFSK_use_annotation:
+ col.operator("gpencil.surfsk_add_strokes", text="Add Strokes")
+ col.operator("gpencil.surfsk_edit_strokes", text="Edit Strokes")
+ else:
+ col.operator("gpencil.surfsk_add_annotation", text="Add Annotation")
+ col.separator()
+ col.prop(scn, "SURFSK_edges_U")
+ col.prop(scn, "SURFSK_edges_V")
col.prop(scn, "SURFSK_cyclic_cross")
col.prop(scn, "SURFSK_cyclic_follow")
col.prop(scn, "SURFSK_loops_on_strokes")
@@ -110,11 +118,22 @@ class VIEW3D_PT_tools_SURFSK_curve(Panel):
# Returns the type of strokes used
-def get_strokes_type():
+def get_strokes_type(context):
strokes_type = ""
strokes_num = 0
# Check if they are grease pencil
+ if context.scene.bsurfaces.SURFSK_use_annotation:
+ try:
+ frame = bpy.data.grease_pencils["Annotations"].layers["Note"].active_frame
+
+ strokes_num = len(frame.strokes)
+
+ if strokes_num > 0:
+ strokes_type = "GP_ANNOTATION"
+ except:
+ pass
+
try:
gpencil = bpy.context.scene.bsurfaces.SURFSK_object_with_strokes
layer = gpencil.data.layers[0]
@@ -452,14 +471,15 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
except:
pass
- bpy.ops.object.delete({"selected_objects": [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)
self.main_object.select_set(True)
bpy.context.view_layer.objects.active = self.main_object
- bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
+ #bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
+ bpy.ops.object.mode_set(mode='OBJECT')
# Returns a list with the coords of the points distributed over the splines
# passed to this method according to the proportions parameter
@@ -3058,7 +3078,6 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bsurfaces_props = bpy.context.scene.bsurfaces
- bsurfaces_props.SURFSK_object_with_strokes.select_set(True)
self.main_object = bsurfaces_props.SURFSK_object_with_retopology
self.main_object.select_set(True)
bpy.context.view_layer.objects.active = self.main_object
@@ -3122,13 +3141,26 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
self.crosshatch_surface_execute()
# Delete main splines
- bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
+ #bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
+ bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.delete({"selected_objects": [self.main_splines]})
# Delete grease pencil strokes
if self.strokes_type == "GP_STROKES" and not self.stopping_errors and not self.keep_strokes:
bpy.context.scene.bsurfaces.SURFSK_object_with_strokes.data.layers[0].clear()
-
+
+ # Delete annotations
+ if self.strokes_type == "GP_ANNOTATION" and not self.stopping_errors and not self.keep_strokes:
+ bpy.data.grease_pencils["Annotations"].layers["Note"].clear()
+
+ bsurfaces_props.SURFSK_edges_U = self.edges_U
+ bsurfaces_props.SURFSK_edges_V = self.edges_V
+ bsurfaces_props.SURFSK_cyclic_cross = self.cyclic_cross
+ bsurfaces_props.SURFSK_cyclic_follow = self.cyclic_follow
+ bsurfaces_props.SURFSK_automatic_join = self.automatic_join
+ bsurfaces_props.SURFSK_loops_on_strokes = self.loops_on_strokes
+ bsurfaces_props.SURFSK_keep_strokes = self.keep_strokes
+
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
@@ -3148,15 +3180,13 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
self.automatic_join = bsurfaces_props.SURFSK_automatic_join
self.loops_on_strokes = bsurfaces_props.SURFSK_loops_on_strokes
self.keep_strokes = bsurfaces_props.SURFSK_keep_strokes
-
+
+ self.main_object = bsurfaces_props.SURFSK_object_with_retopology
try:
- bsurfaces_props.SURFSK_object_with_strokes.select_set(True)
+ self.main_object.select_set(True)
except:
self.report({'WARNING'}, "Specify the name of the object with retopology")
return{"CANCELLED"}
-
- self.main_object = bsurfaces_props.SURFSK_object_with_retopology
- self.main_object.select_set(True)
bpy.context.view_layer.objects.active = self.main_object
self.main_object_selected_verts_count = int(self.main_object.data.total_vert_sel)
@@ -3165,28 +3195,43 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
bpy.ops.wm.context_set_value(data_path='tool_settings.mesh_select_mode',
value='True, False, False')
- self.edges_U = 5
+ self.edges_U = bsurfaces_props.SURFSK_edges_U
if self.loops_on_strokes:
self.edges_V = 1
else:
- self.edges_V = 5
+ self.edges_V = bsurfaces_props.SURFSK_edges_V
self.is_fill_faces = False
self.stopping_errors = False
self.last_strokes_splines_coords = []
# Determine the type of the strokes
- self.strokes_type = get_strokes_type()
+ self.strokes_type = get_strokes_type(context)
# Check if it will be used grease pencil strokes or curves
# If there are strokes to be used
- if self.strokes_type == "GP_STROKES" or self.strokes_type == "EXTERNAL_CURVE":
+ if self.strokes_type == "GP_STROKES" or self.strokes_type == "EXTERNAL_CURVE" or self.strokes_type == "GP_ANNOTATION":
if self.strokes_type == "GP_STROKES":
# Convert grease pencil strokes to curve
gp = bsurfaces_props.SURFSK_object_with_strokes
#bpy.ops.gpencil.convert(type='CURVE', use_link_strokes=False)
- self.original_curve = conver_gpencil_to_curve(context, gp)
+ self.original_curve = conver_gpencil_to_curve(context, gp, 'GPensil')
+ # XXX gpencil.convert now keep org object as active/selected, *not* newly created curve!
+ # XXX This is far from perfect, but should work in most cases...
+ # self.original_curve = bpy.context.object
+ gplayer_prefix_translated = bpy.app.translations.pgettext_data('GP_Layer')
+ for ob in bpy.context.selected_objects:
+ if ob != bpy.context.view_layer.objects.active and \
+ ob.name.startswith((gplayer_prefix_translated, 'GP_Layer')):
+ self.original_curve = ob
+ self.using_external_curves = False
+
+ elif self.strokes_type == "GP_ANNOTATION":
+ # Convert grease pencil strokes to curve
+ gp = bpy.data.grease_pencils["Annotations"]
+ #bpy.ops.gpencil.convert(type='CURVE', use_link_strokes=False)
+ self.original_curve = conver_gpencil_to_curve(context, gp, 'Annotation')
# XXX gpencil.convert now keep org object as active/selected, *not* newly created curve!
# XXX This is far from perfect, but should work in most cases...
# self.original_curve = bpy.context.object
@@ -3360,6 +3405,10 @@ class GPENCIL_OT_SURFSK_add_surface(Operator):
# Delete grease pencil strokes
if self.strokes_type == "GP_STROKES" and not self.stopping_errors and not self.keep_strokes:
bpy.context.scene.bsurfaces.SURFSK_object_with_strokes.data.layers[0].clear()
+
+ # Delete grease pencil strokes
+ if self.strokes_type == "GP_ANNOTATION" and not self.stopping_errors and not self.keep_strokes:
+ bpy.data.grease_pencils["Annotations"].layers["Note"].clear()
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
self.main_object.select_set(True)
@@ -3425,30 +3474,45 @@ class GPENCIL_OT_SURFSK_init(Operator):
active_object: PointerProperty(type=bpy.types.Object)
def execute(self, context):
+
+ bs = bpy.context.scene.bsurfaces
+
if bpy.ops.object.mode_set.poll():
bpy.ops.object.mode_set(mode='OBJECT')
- bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
- mesh = bpy.data.meshes.new('BSurfaceMesh')
- mesh_object = object_utils.object_data_add(context, mesh, operator=None)
- mesh_object.select_set(True)
- bpy.context.view_layer.objects.active = mesh_object
- bpy.ops.object.modifier_add(type='SHRINKWRAP')
- modifier = mesh_object.modifiers["Shrinkwrap"]
- if self.active_object is not None:
- modifier.target = self.active_object
- modifier.wrap_method = 'TARGET_PROJECT'
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list