LoopTools: Gstretch fix.
Grease pencil must have name 'GPencil'. Script take only the first strokes.
This commit is contained in:
parent
1efa00c323
commit
b23f156030
|
@ -61,7 +61,7 @@ looptools_cache = {}
|
|||
|
||||
|
||||
def get_grease_pencil(object, context):
|
||||
gp = bpy.data.grease_pencils
|
||||
gp = bpy.context.scene.objects['GPencil']
|
||||
if not gp:
|
||||
gp = context.view_layers.grease_pencils
|
||||
return gp
|
||||
|
@ -2843,13 +2843,13 @@ def gstretch_get_strokes(object, context):
|
|||
gp = get_grease_pencil(object, context)
|
||||
if not gp:
|
||||
return(None)
|
||||
layer = context.active_gpencil_layer
|
||||
layer = gp.data.layers[0]
|
||||
if not layer:
|
||||
return(None)
|
||||
frame = context.active_gpencil_frame
|
||||
frame = layer.frames[0]
|
||||
if not frame:
|
||||
return(None)
|
||||
strokes = context.editable_gpencil_strokes
|
||||
strokes = frame.strokes
|
||||
if len(strokes) < 1:
|
||||
return(None)
|
||||
|
||||
|
@ -3828,8 +3828,15 @@ class RemoveGP(Operator):
|
|||
|
||||
def execute(self, context):
|
||||
|
||||
if context.gpencil_data is not None:
|
||||
bpy.ops.gpencil.data_unlink()
|
||||
gp = bpy.context.scene.objects['GPencil']
|
||||
if len(gp.data.layers[0].frames) is not 0:
|
||||
bpy.ops.object.mode_set(mode='OBJECT')
|
||||
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
|
||||
gp.select_set(True)
|
||||
bpy.context.view_layer.objects.active = gp
|
||||
bpy.ops.object.mode_set(mode='PAINT_GPENCIL')
|
||||
bpy.ops.gpencil.active_frame_delete('INVOKE_REGION_WIN')
|
||||
bpy.ops.object.mode_set(mode='OBJECT')
|
||||
else:
|
||||
self.report({'INFO'}, "No Grease Pencil data to Unlink")
|
||||
return {'CANCELLED'}
|
||||
|
|
Loading…
Reference in New Issue