Addon: LoopTools: Fixed select active Annotation

This commit is contained in:
Vladimir Spivak 2019-07-23 02:23:53 +03:00
parent e27ec695f1
commit be6738522d
Notes: blender-bot 2023-02-14 19:12:09 +01:00
Referenced by issue #67465, Addon: LoopTools Gstrech + deleted annotation = broken
1 changed files with 11 additions and 11 deletions

View File

@ -61,10 +61,11 @@ looptools_cache = {}
def get_annotation(self, context):
if 'Annotations' in bpy.data.grease_pencils.keys():
try:
layer = bpy.data.grease_pencils[0].layers.active
return True
else:
self.report({'WARNING'}, "Annotation not found")
except:
self.report({'WARNING'}, "active Annotation not found")
return False
# force a full recalculation next time
@ -2840,7 +2841,7 @@ def gstretch_get_strokes(self, context):
gp = get_annotation(self, context)
if not gp:
return(None)
layer = bpy.data.grease_pencils["Annotations"].layers["Note"]
layer = bpy.data.grease_pencils[0].layers.active
if not layer:
return(None)
frame = layer.active_frame
@ -3818,15 +3819,15 @@ class Flatten(Operator):
# gstretch operator
class RemoveGP(Operator):
bl_idname = "remove.gp"
bl_label = "Remove GP"
bl_label = "Remove Annotation"
bl_description = "Remove all Annotation Strokes"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if get_annotation(self, context):
bpy.data.grease_pencils["Annotations"].layers["Note"].clear()
else:
try:
bpy.data.grease_pencils[0].layers.active.clear()
except:
self.report({'INFO'}, "No Annotation data to Unlink")
return {'CANCELLED'}
@ -3836,7 +3837,7 @@ class RemoveGP(Operator):
class GStretch(Operator):
bl_idname = "mesh.looptools_gstretch"
bl_label = "Gstretch"
bl_description = "Stretch selected vertices to Annotation stroke"
bl_description = "Stretch selected vertices to active Annotation stroke"
bl_options = {'REGISTER', 'UNDO'}
conversion: EnumProperty(
@ -3973,7 +3974,7 @@ class GStretch(Operator):
row.prop(self, "lock_z", text="Z", icon='UNLOCKED')
col_move.prop(self, "influence")
col.separator()
col.operator("remove.gp", text="Delete GP Strokes")
col.operator("remove.gp", text="Cancel and delete annotation strokes")
def invoke(self, context, event):
# flush cached strokes
@ -5042,7 +5043,6 @@ class LoopToolsProps(PropertyGroup):
default=False
)
# draw function for integration in menus
def menu_func(self, context):
self.layout.menu("VIEW3D_MT_edit_mesh_looptools")