file checker remove stroke duplicates
2.2.0 - added: _Remove redundant stroke_ in File checker (Just list duplicate numbers in "check only" mode)gpv2
parent
d1748c592d
commit
d1b03c804c
|
@ -1,9 +1,13 @@
|
|||
# Changelog
|
||||
|
||||
|
||||
2.2.0
|
||||
|
||||
- added: _Remove redundant stroke_ in File checker (Just list duplicate numbers in "check only" mode)
|
||||
|
||||
2.1.6
|
||||
|
||||
- Fixed: Prevent some keymaps to register when blender is launched in background mode
|
||||
- fixed: Prevent some keymaps to register when blender is launched in background mode
|
||||
|
||||
2.1.5
|
||||
|
||||
|
|
|
@ -1,8 +1,33 @@
|
|||
import bpy
|
||||
import os
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
from . import utils
|
||||
|
||||
def remove_stroke_exact_duplications(apply=True):
|
||||
'''Remove accidental stroke duplication (points exactly in the same place)
|
||||
: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)
|
||||
ct = 0
|
||||
gp_datas = [gp for gp in bpy.data.grease_pencils]
|
||||
for gp in gp_datas:
|
||||
for l in gp.layers:
|
||||
for f in l.frames:
|
||||
stroke_list = []
|
||||
for s in reversed(f.strokes):
|
||||
|
||||
point_list = [p.co for p in s.points]
|
||||
|
||||
if point_list in stroke_list:
|
||||
ct += 1
|
||||
if apply:
|
||||
# Remove redundancy
|
||||
f.strokes.remove(s)
|
||||
else:
|
||||
stroke_list.append(point_list)
|
||||
return ct
|
||||
class GPTB_OT_file_checker(bpy.types.Operator):
|
||||
bl_idname = "gp.file_checker"
|
||||
bl_label = "Check File"
|
||||
|
@ -26,6 +51,7 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
|||
# Set filepath type
|
||||
# Set Lock object mode state
|
||||
# Disable use light on all object
|
||||
# Remove redundant strokes in frames
|
||||
|
||||
def invoke(self, context, event):
|
||||
# need some self-control (I had to...)
|
||||
|
@ -234,6 +260,12 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
|||
if apply:
|
||||
bpy.context.scene.tool_settings.lock_object_mode = False
|
||||
|
||||
if fix.remove_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'
|
||||
problems.append(mess)
|
||||
|
||||
# ## Set onion skin filter to 'All type'
|
||||
# fix_kf_type = 0
|
||||
# for gp in bpy.data.grease_pencils:#from data
|
||||
|
@ -505,6 +537,7 @@ class GPTB_OT_list_object_visibility(bpy.types.Operator):
|
|||
return context.window_manager.invoke_props_dialog(self, width=250)
|
||||
|
||||
def draw(self, context):
|
||||
# TODO: Add visibility check with viewlayer visibility as well
|
||||
layout = self.layout
|
||||
for o in self.ob_list:
|
||||
row = layout.row()
|
||||
|
|
|
@ -4,7 +4,7 @@ bl_info = {
|
|||
"name": "GP toolbox",
|
||||
"description": "Tool set for Grease Pencil in animation production",
|
||||
"author": "Samuel Bernou, Christophe Seux",
|
||||
"version": (2, 1, 6),
|
||||
"version": (2, 2, 0),
|
||||
"blender": (3, 0, 0),
|
||||
"location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
|
||||
"warning": "",
|
||||
|
@ -643,6 +643,7 @@ class GPTB_prefs(bpy.types.AddonPreferences):
|
|||
col.prop(self.fixprops, 'list_gp_mod_vis_conflict')
|
||||
col.prop(self.fixprops, 'list_broken_mod_targets')
|
||||
col.prop(self.fixprops, 'autokey_add_n_replace')
|
||||
col.prop(self.fixprops, 'remove_redundant_strokes')
|
||||
#-# col.prop(self.fixprops, 'set_cursor_type')
|
||||
|
||||
# col = layout.column()
|
||||
|
|
|
@ -110,6 +110,11 @@ class GP_PG_FixSettings(PropertyGroup):
|
|||
name="Autokey Mode Add and Replace",
|
||||
description="Change autokey mode back to 'Add & Replace'",
|
||||
default=True, options={'HIDDEN'})
|
||||
|
||||
remove_redundant_strokes : BoolProperty(
|
||||
name="Remove Redundant Strokes",
|
||||
description="Remove GP strokes duplication. When points are exactly identical within the same frame",
|
||||
default=True, options={'HIDDEN'})
|
||||
|
||||
# set_cursor_type : BoolProperty(
|
||||
# name="Set Select Cursor Mode",
|
||||
|
|
Loading…
Reference in New Issue