From 4410bd0a9f82aba3422e737f0fae4a916cf6c0c1 Mon Sep 17 00:00:00 2001 From: "Spivak Vladimir (cwolf3d)" Date: Fri, 26 Jul 2019 02:34:14 +0300 Subject: Addon: BSurfaces: Fixed select active Annotation --- mesh_bsurfaces.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/mesh_bsurfaces.py b/mesh_bsurfaces.py index 1fc761ae..11c80686 100644 --- a/mesh_bsurfaces.py +++ b/mesh_bsurfaces.py @@ -125,9 +125,9 @@ def get_strokes_type(context): # 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 = bpy.data.grease_pencils[0].layers.active.active_frame.strokes - strokes_num = len(frame.strokes) + strokes_num = len(strokes) if strokes_num > 0: strokes_type = "GP_ANNOTATION" @@ -136,10 +136,9 @@ def get_strokes_type(context): try: gpencil = bpy.context.scene.bsurfaces.SURFSK_object_with_strokes - layer = gpencil.data.layers[0] - frame = layer.frames[0] + strokes = gpencil.data.layers.active.active_frame.strokes - strokes_num = len(frame.strokes) + strokes_num = len(strokes) if strokes_num > 0: strokes_type = "GP_STROKES" @@ -3148,11 +3147,11 @@ 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() + bpy.context.scene.bsurfaces.SURFSK_object_with_strokes.data.layers.active.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() + bpy.data.grease_pencils[0].layers.active.clear() bsurfaces_props.SURFSK_edges_U = self.edges_U bsurfaces_props.SURFSK_edges_V = self.edges_V @@ -3399,11 +3398,11 @@ 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() + bpy.context.scene.bsurfaces.SURFSK_object_with_strokes.data.layers.active.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.data.grease_pencils[0].layers.active.clear() bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT') self.main_object.select_set(True) @@ -3615,7 +3614,7 @@ class GPENCIL_OT_SURFSK_edit_strokes(Operator): ob_gp_strokes = bpy.context.object # Delete grease pencil strokes - bpy.context.scene.bsurfaces.SURFSK_object_with_strokes.data.layers[0].clear() + bpy.context.scene.bsurfaces.SURFSK_object_with_strokes.data.layers.active.clear() # Clean up curves bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT') @@ -3871,7 +3870,7 @@ class CURVE_OT_SURFSK_reorder_splines(Operator): bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN') bpy.ops.curve.select_all('INVOKE_REGION_WIN', action='DESELECT') - bpy.context.scene.bsurfaces.SURFSK_object_with_strokes.data.layers[0].clear() + bpy.context.scene.bsurfaces.SURFSK_object_with_strokes.data.layers.active.clear() return {"FINISHED"} @@ -4061,12 +4060,18 @@ def conver_gpencil_to_curve(self, context, pencil, type): newCurve = bpy.data.curves.new('gpencil_curve', type='CURVE') # curvedatablock newCurve.dimensions = '3D' CurveObject = object_utils.object_data_add(context, newCurve) # place in active scene - CurveObject.location = self.main_object.location if type == 'GPensil': - strokes = pencil.data.layers[0].active_frame.strokes + strokes = pencil.data.layers.active.active_frame.strokes + CurveObject.location = pencil.location + CurveObject.rotation_euler = pencil.rotation_euler + CurveObject.scale = pencil.scale elif type == 'Annotation': - strokes = bpy.data.grease_pencils["Annotations"].layers["Note"].active_frame.strokes + grease_pencil = bpy.data.grease_pencils[0] + strokes = grease_pencil.layers.active.active_frame.strokes + CurveObject.location = (0.0, 0.0, 0.0) + CurveObject.rotation_euler = (0.0, 0.0, 0.0) + CurveObject.scale = (1.0, 1.0, 1.0) for i, stroke in enumerate(strokes): stroke_points = strokes[i].points -- cgit v1.2.3