check list for file

1.5.1

- fix: eraser brush
- change: check file has custom check list in addon prefs
gpv2
Pullusb 2021-06-17 16:21:27 +02:00
parent 060fa8ff92
commit 2efbb36ddf
5 changed files with 202 additions and 77 deletions

View File

@ -1,5 +1,10 @@
# Changelog # Changelog
1.5.1
- fix: eraser brush
- change: check file has custom check list in addon prefs
1.5.0 1.5.0
- feat: Eraser Brush Tool (Need to be enable in the preferences) - feat: Eraser Brush Tool (Need to be enable in the preferences)

67
OP_file_checker.py Normal file → Executable file
View File

@ -27,10 +27,12 @@ class GPTB_OT_file_checker(bpy.types.Operator):
def execute(self, context): def execute(self, context):
prefs = get_addon_prefs() prefs = get_addon_prefs()
fix = prefs.fixprops
problems = [] problems = []
## Lock main cam: ## Lock main cam:
if not 'layout' in Path(bpy.data.filepath).stem:#dont touch layout cameras if fix.lock_main_cam:
if not 'layout' in Path(bpy.data.filepath).stem.lower():#dont touch layout cameras
if context.scene.camera: if context.scene.camera:
cam = context.scene.camera cam = context.scene.camera
if cam.name == 'draw_cam' and cam.parent: if cam.name == 'draw_cam' and cam.parent:
@ -45,6 +47,7 @@ class GPTB_OT_file_checker(bpy.types.Operator):
cam.lock_location = cam.lock_rotation = triple cam.lock_location = cam.lock_rotation = triple
## set scene res at pref res according to addon pref ## set scene res at pref res according to addon pref
if fix.set_scene_res:
rx, ry = prefs.render_res_x, prefs.render_res_y rx, ry = prefs.render_res_x, prefs.render_res_y
# TODO set (rx, ry) to camera resolution if specified in camera name # TODO set (rx, ry) to camera resolution if specified in camera name
if context.scene.render.resolution_x != rx or context.scene.render.resolution_y != ry: if context.scene.render.resolution_x != rx or context.scene.render.resolution_y != ry:
@ -52,11 +55,19 @@ class GPTB_OT_file_checker(bpy.types.Operator):
context.scene.render.resolution_x, context.scene.render.resolution_y = rx, ry context.scene.render.resolution_x, context.scene.render.resolution_y = rx, ry
## set scene percentage at 100: ## set scene percentage at 100:
if fix.set_res_percentage:
if context.scene.render.resolution_percentage != 100: if context.scene.render.resolution_percentage != 100:
problems.append('Resolution output to 100%') problems.append('Resolution output to 100%')
context.scene.render.resolution_percentage = 100 context.scene.render.resolution_percentage = 100
## set fps according to preferences settings
if fix.set_fps:
if context.scene.render.fps != prefs.fps:
problems.append( (f"framerate corrected {context.scene.render.fps} >> {prefs.fps}", 'ERROR') )
context.scene.render.fps = prefs.fps
## set show slider and sync range ## set show slider and sync range
if fix.set_slider_n_sync:
for window in bpy.context.window_manager.windows: for window in bpy.context.window_manager.windows:
screen = window.screen screen = window.screen
for area in screen.areas: for area in screen.areas:
@ -67,12 +78,8 @@ class GPTB_OT_file_checker(bpy.types.Operator):
if hasattr(area.spaces[0], 'show_locked_time'): if hasattr(area.spaces[0], 'show_locked_time'):
setattr(area.spaces[0], 'show_locked_time', True) setattr(area.spaces[0], 'show_locked_time', True)
## set fps according to preferences settings
if context.scene.render.fps != prefs.fps:
problems.append( (f"framerate corrected {context.scene.render.fps} >> {prefs.fps}", 'ERROR') )
context.scene.render.fps = prefs.fps
## set cursor type (according to prefs ?) ## set cursor type (according to prefs ?)
if fix.set_cursor_type:
if context.mode in ("EDIT_GPENCIL", "SCULPT_GPENCIL"): if context.mode in ("EDIT_GPENCIL", "SCULPT_GPENCIL"):
tool = prefs.select_active_tool tool = prefs.select_active_tool
if tool != 'none': if tool != 'none':
@ -80,19 +87,24 @@ class GPTB_OT_file_checker(bpy.types.Operator):
bpy.ops.wm.tool_set_by_id(name=tool)# Tweaktoolcode bpy.ops.wm.tool_set_by_id(name=tool)# Tweaktoolcode
problems.append(f'tool changed to {tool.split(".")[1]}') problems.append(f'tool changed to {tool.split(".")[1]}')
## GP use additive drawing (else creating a frame in dopesheet makes it blank...) # ## GP use additive drawing (else creating a frame in dopesheet makes it blank...)
if not context.scene.tool_settings.use_gpencil_draw_additive: # if not context.scene.tool_settings.use_gpencil_draw_additive:
problems.append(f'Activated Gp additive drawing mode (snowflake)') # problems.append(f'Activated Gp additive drawing mode (snowflake)')
context.scene.tool_settings.use_gpencil_draw_additive = True # context.scene.tool_settings.use_gpencil_draw_additive = True
## GP stroke placement/projection check ## GP stroke placement/projection check
if fix.check_front_axis:
if context.scene.tool_settings.gpencil_sculpt.lock_axis != 'AXIS_Y': if context.scene.tool_settings.gpencil_sculpt.lock_axis != 'AXIS_Y':
problems.append('/!\\ Draw axis not "Front" (Need Manual change if not Ok)') problems.append('/!\\ Draw axis not "Front" (Need Manual change if not Ok)')
if fix.check_placement:
if bpy.context.scene.tool_settings.gpencil_stroke_placement_view3d != 'ORIGIN': if bpy.context.scene.tool_settings.gpencil_stroke_placement_view3d != 'ORIGIN':
problems.append('/!\\ Draw placement not "Origin" (Need Manual change if not Ok)') problems.append('/!\\ Draw placement not "Origin" (Need Manual change if not Ok)')
## Disabled animation ## Disabled animation
if fix.list_disabled_anim:
fcu_ct = 0 fcu_ct = 0
for act in bpy.data.actions: for act in bpy.data.actions:
if not act.users: if not act.users:
@ -104,15 +116,32 @@ class GPTB_OT_file_checker(bpy.types.Operator):
if fcu_ct: if fcu_ct:
problems.append(f'{fcu_ct} anim channel disabled (details -> console)') problems.append(f'{fcu_ct} anim channel disabled (details -> console)')
## Set onion skin filter to 'All type' ## Use median point
fix_kf_type = 0 if fix.set_pivot_median_point:
for gp in bpy.data.grease_pencils:#from data if context.scene.tool_settings.transform_pivot_point != 'MEDIAN_POINT':
if not gp.is_annotation: problems.append(f"Pivot changed from '{context.scene.tool_settings.transform_pivot_point}' to 'MEDIAN_POINT'")
if gp.onion_keyframe_type != 'ALL': context.scene.tool_settings.transform_pivot_point = 'MEDIAN_POINT'
gp.onion_keyframe_type = 'ALL'
fix_kf_type += 1 if fix.disable_guide:
if fix_kf_type: if context.scene.tool_settings.gpencil_sculpt.guide.use_guide == True:
problems.append(f"{fix_kf_type} GP onion skin filter to 'All type'") problems.append(f"Disabled Draw Guide")
context.scene.tool_settings.gpencil_sculpt.guide.use_guide = False
if fix.autokey_add_n_replace:
if context.scene.tool_settings.auto_keying_mode != 'ADD_REPLACE_KEYS':
problems.append(f"Autokey mode reset to 'Add & Replace'")
context.scene.tool_settings.auto_keying_mode = 'ADD_REPLACE_KEYS'
# ## Set onion skin filter to 'All type'
# fix_kf_type = 0
# for gp in bpy.data.grease_pencils:#from data
# if not gp.is_annotation:
# if gp.onion_keyframe_type != 'ALL':
# gp.onion_keyframe_type = 'ALL'
# fix_kf_type += 1
# if fix_kf_type:
# problems.append(f"{fix_kf_type} GP onion skin filter to 'All type'")
# for ob in context.scene.objects:#from object # for ob in context.scene.objects:#from object
# if ob.type == 'GPENCIL': # if ob.type == 'GPENCIL':
# ob.data.onion_keyframe_type = 'ALL' # ob.data.onion_keyframe_type = 'ALL'

View File

@ -304,7 +304,9 @@ class GPTB_PT_render(bpy.types.Panel):
layout.operator('render.setup_render_path', text = 'Setup output', icon = 'TOOL_SETTINGS')#SETTINGS layout.operator('render.setup_render_path', text = 'Setup output', icon = 'TOOL_SETTINGS')#SETTINGS
blend = Path(bpy.data.filepath) blend = bpy.data.filepath
if blend:
blend = Path(blend)
out = blend.parents[1] / "compo" / "base" out = blend.parents[1] / "compo" / "base"
layout.operator("wm.path_open", text='Open render folder', icon='FILE_FOLDER').filepath = str(out) layout.operator("wm.path_open", text='Open render folder', icon='FILE_FOLDER').filepath = str(out)

35
__init__.py Normal file → Executable file
View File

@ -15,7 +15,7 @@ bl_info = {
"name": "GP toolbox", "name": "GP toolbox",
"description": "Set of tools for Grease Pencil in animation production", "description": "Set of tools for Grease Pencil in animation production",
"author": "Samuel Bernou, Christophe Seux", "author": "Samuel Bernou, Christophe Seux",
"version": (1, 5, 0), "version": (1, 5, 1),
"blender": (2, 91, 0), "blender": (2, 91, 0),
"location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties", "location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
"warning": "", "warning": "",
@ -57,7 +57,7 @@ from .OP_pseudo_tint import GPT_OT_auto_tint_gp_layers
from . import UI_tools from . import UI_tools
from .properties import GP_PG_ToolsSettings from .properties import GP_PG_ToolsSettings, GP_PG_FixSettings
from bpy.props import (FloatProperty, from bpy.props import (FloatProperty,
BoolProperty, BoolProperty,
@ -122,6 +122,7 @@ class GPTB_prefs(bpy.types.AddonPreferences):
items=(('PREF', "Preferences", "Change some preferences of the modal"), items=(('PREF', "Preferences", "Change some preferences of the modal"),
('MAN_OPS', "Operator", "Operator to add Manually"), ('MAN_OPS', "Operator", "Operator to add Manually"),
# ('TUTO', "Tutorial", "How to use the tool"), # ('TUTO', "Tutorial", "How to use the tool"),
('CHECKS', "Check List", "Customise what should happend when hitting 'check fix' button"),
('UPDATE', "Update", "Check and apply updates"), ('UPDATE', "Update", "Check and apply updates"),
# ('KEYMAP', "Keymap", "customise the default keymap"), # ('KEYMAP', "Keymap", "customise the default keymap"),
), ),
@ -180,7 +181,7 @@ class GPTB_prefs(bpy.types.AddonPreferences):
fps : IntProperty( fps : IntProperty(
name='Frame Rate', name='Frame Rate',
description="Fps of the project, Used to conform the file when you use Check file operator", description="Fps of the project, Used to conform the file when you use Check file operator",
default=25, default=24,
min=1, min=1,
max=10000 max=10000
) )
@ -307,6 +308,9 @@ class GPTB_prefs(bpy.types.AddonPreferences):
description = "add ctrl", description = "add ctrl",
default = False) default = False)
fixprops: bpy.props.PointerProperty(type = GP_PG_FixSettings)
## Temp cutter ## Temp cutter
# temp_cutter_use_shortcut: BoolProperty( # temp_cutter_use_shortcut: BoolProperty(
# name = "Use temp cutter Shortcut", # name = "Use temp cutter Shortcut",
@ -437,6 +441,26 @@ class GPTB_prefs(bpy.types.AddonPreferences):
box.label(text='Note: You can access user pref file and startup file in config folder') box.label(text='Note: You can access user pref file and startup file in config folder')
box.operator("wm.path_open", text='Open config location').filepath = bpy.utils.user_resource('CONFIG') box.operator("wm.path_open", text='Open config location').filepath = bpy.utils.user_resource('CONFIG')
if self.pref_tabs == 'CHECKS':
layout.label(text='Following checks will be made when clicking "Check File" button:')
col = layout.column()
# row = col.row()
col.prop(self.fixprops, 'lock_main_cam')
col.prop(self.fixprops, 'set_scene_res', text=f'Reset Scene Resolution (to {self.render_res_x}x{self.render_res_y})')
col.prop(self.fixprops, 'set_res_percentage')
col.prop(self.fixprops, 'set_fps', text=f'Reset FPS (to {self.fps})')
col.prop(self.fixprops, 'set_slider_n_sync')
col.prop(self.fixprops, 'set_cursor_type')
col.prop(self.fixprops, 'check_front_axis')
col.prop(self.fixprops, 'check_placement')
col.prop(self.fixprops, 'set_pivot_median_point')
col.prop(self.fixprops, 'disable_guide')
col.prop(self.fixprops, 'list_disabled_anim')
col.prop(self.fixprops, 'autokey_add_n_replace')
# row.label(text='lock the active camera if not a draw cam (and if not "layout" in blendfile name)')
if self.pref_tabs == 'UPDATE': if self.pref_tabs == 'UPDATE':
addon_updater_ops.update_settings_ui(self, context) addon_updater_ops.update_settings_ui(self, context)
@ -448,8 +472,9 @@ class GPTB_prefs(bpy.types.AddonPreferences):
classes = ( classes = (
GPTB_prefs, GP_PG_FixSettings,
GP_PG_ToolsSettings, GP_PG_ToolsSettings,
GPTB_prefs,
GPT_OT_auto_tint_gp_layers, GPT_OT_auto_tint_gp_layers,
) )
@ -458,6 +483,7 @@ GPT_OT_auto_tint_gp_layers,
def register(): def register():
addon_updater_ops.register(bl_info) addon_updater_ops.register(bl_info)
# bpy.types.Scene.gpfixprops = bpy.props.PointerProperty(type = GP_PG_FixSettings) # used in prefs
for cls in classes: for cls in classes:
bpy.utils.register_class(cls) bpy.utils.register_class(cls)
OP_helpers.register() OP_helpers.register()
@ -519,6 +545,7 @@ def unregister():
GP_colorize.unregister()## GP_guided_colorize. GP_colorize.unregister()## GP_guided_colorize.
OP_playblast_bg.unregister() OP_playblast_bg.unregister()
OP_playblast.unregister() OP_playblast.unregister()
# del bpy.types.Scene.gpfixprops
del bpy.types.Scene.gptoolprops del bpy.types.Scene.gptoolprops

64
properties.py Normal file → Executable file
View File

@ -15,7 +15,69 @@ def change_edit_lines_opacity(self, context):
if not gp.is_annotation: if not gp.is_annotation:
gp.edit_line_color[3]=self.edit_lines_opacity gp.edit_line_color[3]=self.edit_lines_opacity
class GP_PG_ToolsSettings(bpy.types.PropertyGroup) :
class GP_PG_FixSettings(bpy.types.PropertyGroup):
lock_main_cam : BoolProperty(
name="Lock Main Cam",
description="Lock the main camera (works only if 'layout' is not in name)",
default=False, options={'HIDDEN'})
set_scene_res : BoolProperty(
name="Reset Scene Resolution",
description="Set the scene resolution to current prefs project settings",
default=True, options={'HIDDEN'})
set_res_percentage : BoolProperty(
name="Reset Resolution Percentage To 100%",
description="",
default=True, options={'HIDDEN'})
set_fps : BoolProperty(
name="Reset Fps",
description="Set the framerate of the scene to current prefs project settings",
default=False, options={'HIDDEN'})
set_slider_n_sync : BoolProperty(
name="Dopesheets Show Slider And Sync Range",
description="Toggle on the use of show slider and sync range",
default=True, options={'HIDDEN'})
set_cursor_type : BoolProperty(
name="Set Select Cursor Mode",
description="Set the type of the selection cursor (according to addon prefs)",
default=True, options={'HIDDEN'})
check_front_axis : BoolProperty(
name="Check If Draw Axis is Front (X-Z)",
description="Alert if the current grease pencil draw axis is not front (X-Z)",
default=True, options={'HIDDEN'})
check_placement : BoolProperty(
name="Check Stroke Placement",
description="Alert if the current grease pencil stroke placement is not Origin",
default=True, options={'HIDDEN'})
set_pivot_median_point : BoolProperty(
name="Set Pivot To Median Point",
description="Change the pivot point to the most used median point",
default=True, options={'HIDDEN'})
disable_guide : BoolProperty(
name="Disable Drawing Guide",
description="Disable constrained guide in draw mode",
default=False, options={'HIDDEN'})
list_disabled_anim : BoolProperty(
name="List Disabled Animation",
description="Alert if there are disabled animations",
default=True, options={'HIDDEN'})
autokey_add_n_replace : BoolProperty(
name="Autokey Mode Add and Replace",
description="Change autokey mode back to 'Add & Replace'",
default=True, options={'HIDDEN'})
class GP_PG_ToolsSettings(bpy.types.PropertyGroup):
eraser_radius : IntProperty( eraser_radius : IntProperty(
name="Tint hue offset", description="Radius of eraser brush", name="Tint hue offset", description="Radius of eraser brush",
default=20, min=0, max=500, subtype='PIXEL') default=20, min=0, max=500, subtype='PIXEL')