Fix file checker's redundant strokes delete
4.1.3 - fixed: error in "remove stroke duplication" using file checker
This commit is contained in:
parent
3624f5cabd
commit
939b4f534f
@ -1,5 +1,8 @@
|
||||
# Changelog
|
||||
|
||||
4.1.3
|
||||
|
||||
- fixed: error in "remove stroke duplication" using file checker
|
||||
|
||||
4.1.2
|
||||
|
||||
|
@ -15,24 +15,26 @@ def remove_stroke_exact_duplications(apply=True):
|
||||
:apply: Remove the duplication instead of just listing dupes
|
||||
return number of duplication found/deleted
|
||||
'''
|
||||
# TODO: add additional check of material (even if unlikely to happen)
|
||||
# TODO: Add additional check of material (even if unlikely to happen, better to avoid false positive)
|
||||
ct = 0
|
||||
gp_datas = [gp for gp in bpy.data.grease_pencils]
|
||||
gp_datas = [gp for gp in bpy.data.grease_pencils_v3]
|
||||
for gp in gp_datas:
|
||||
for l in gp.layers:
|
||||
for f in l.frames:
|
||||
stroke_list = []
|
||||
for s in reversed(f.drawing.strokes):
|
||||
|
||||
point_list = [p.position for p in s.points]
|
||||
idx_to_delete = []
|
||||
|
||||
for idx, s in enumerate(f.drawing.strokes):
|
||||
point_list = [p.position.copy() for p in s.points]
|
||||
if point_list in stroke_list:
|
||||
ct += 1
|
||||
if apply:
|
||||
# Remove redundancy
|
||||
f.drawing.strokes.remove(s)
|
||||
idx_to_delete.append(idx)
|
||||
else:
|
||||
stroke_list.append(point_list)
|
||||
|
||||
if apply:
|
||||
# Remove redundancy
|
||||
f.drawing.remove_strokes(indices=idx_to_delete)
|
||||
return ct
|
||||
class GPTB_OT_file_checker(bpy.types.Operator):
|
||||
bl_idname = "gp.file_checker"
|
||||
@ -267,6 +269,7 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
||||
bpy.context.scene.tool_settings.lock_object_mode = False
|
||||
|
||||
if fix.remove_redundant_strokes:
|
||||
print('removing redundant strokes')
|
||||
ct = remove_stroke_exact_duplications(apply=apply)
|
||||
if ct > 0:
|
||||
mess = f'Removed {ct} strokes duplications' if apply else f'Found {ct} strokes duplications'
|
||||
@ -274,7 +277,7 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
||||
|
||||
# ## Set onion skin filter to 'All type'
|
||||
# fix_kf_type = 0
|
||||
# for gp in bpy.data.grease_pencils:#from data
|
||||
# for gp in bpy.data.grease_pencils_v3:#from data
|
||||
# if not gp.is_annotation:
|
||||
# if gp.onion_keyframe_type != 'ALL':
|
||||
# gp.onion_keyframe_type = 'ALL'
|
||||
|
@ -166,7 +166,7 @@ class GPTB_OT_import_obj_palette(Operator):
|
||||
|
||||
# unlink objects and their gp data
|
||||
for src_ob in linked_objs:
|
||||
bpy.data.grease_pencils.remove(src_ob.data)
|
||||
bpy.data.grease_pencils_v3.remove(src_ob.data)
|
||||
|
||||
|
||||
return {"FINISHED"}
|
||||
|
@ -4,7 +4,7 @@ bl_info = {
|
||||
"name": "GP toolbox",
|
||||
"description": "Tool set for Grease Pencil in animation production",
|
||||
"author": "Samuel Bernou, Christophe Seux",
|
||||
"version": (4, 1, 2),
|
||||
"version": (4, 1, 3),
|
||||
"blender": (4, 3, 0),
|
||||
"location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
|
||||
"warning": "",
|
||||
|
@ -11,10 +11,12 @@ from bpy.props import (
|
||||
from .OP_cursor_snap_canvas import cursor_follow_update
|
||||
from .OP_layer_manager import layer_name_build
|
||||
|
||||
def change_edit_lines_opacity(self, context):
|
||||
for gp in bpy.data.grease_pencils:
|
||||
if not gp.is_annotation:
|
||||
gp.edit_line_color[3]=self.edit_lines_opacity
|
||||
|
||||
## Obsolete: Gpv3 has no edit line color anymore
|
||||
# def change_edit_lines_opacity(self, context):
|
||||
# for gp in bpy.data.grease_pencils:
|
||||
# if not gp.is_annotation:
|
||||
# gp.edit_line_color[3]=self.edit_lines_opacity
|
||||
|
||||
|
||||
def update_layer_name(self, context):
|
||||
|
Loading…
x
Reference in New Issue
Block a user