Check file dry run mode and lock object mode
1.5.7 - feat: check list, Specify in addon pref if you prefer a dry run (check without set) - feat: check file can change the lock object mode state (do nothing by default)gpv2
parent
66ef75c76d
commit
9612c84396
|
@ -1,5 +1,9 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
1.5.7
|
||||||
|
|
||||||
|
- feat: check list, specify in addon pref if you prefer a dry run (check without set)
|
||||||
|
- feat: check file can change the lock object mode state (do nothing by default)
|
||||||
|
|
||||||
1.5.6
|
1.5.6
|
||||||
|
|
||||||
|
|
|
@ -24,15 +24,26 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
||||||
# GP stroke placement/projection check
|
# GP stroke placement/projection check
|
||||||
# Disabled animation
|
# Disabled animation
|
||||||
# Set onion skin filter to 'All type'
|
# Set onion skin filter to 'All type'
|
||||||
|
# Set filepath type
|
||||||
|
# Set Lock object mode state
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
self.ctrl = event.ctrl
|
||||||
|
return self.execute(context)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
prefs = get_addon_prefs()
|
prefs = get_addon_prefs()
|
||||||
fix = prefs.fixprops
|
fix = prefs.fixprops
|
||||||
problems = []
|
problems = []
|
||||||
|
|
||||||
|
apply = not fix.check_only
|
||||||
|
|
||||||
|
# If Ctrl is pressed, invert behavior (invert boolean)
|
||||||
|
apply ^= self.ctrl
|
||||||
|
|
||||||
## Lock main cam:
|
## Lock main cam:
|
||||||
if fix.lock_main_cam:
|
if fix.lock_main_cam:
|
||||||
if not 'layout' in Path(bpy.data.filepath).stem.lower():#dont touch layout cameras
|
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:
|
||||||
|
@ -44,7 +55,8 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
||||||
triple = (True,True,True)
|
triple = (True,True,True)
|
||||||
if cam.lock_location[:] != triple or cam.lock_rotation[:] != triple:
|
if cam.lock_location[:] != triple or cam.lock_rotation[:] != triple:
|
||||||
problems.append('Lock main camera')
|
problems.append('Lock main camera')
|
||||||
cam.lock_location = cam.lock_rotation = triple
|
if apply:
|
||||||
|
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:
|
if fix.set_scene_res:
|
||||||
|
@ -52,19 +64,22 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
||||||
# 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:
|
||||||
problems.append(f'Resolution {context.scene.render.resolution_x}x{context.scene.render.resolution_y} >> {rx}x{ry}')
|
problems.append(f'Resolution {context.scene.render.resolution_x}x{context.scene.render.resolution_y} >> {rx}x{ry}')
|
||||||
context.scene.render.resolution_x, context.scene.render.resolution_y = rx, ry
|
if apply:
|
||||||
|
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 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
|
if apply:
|
||||||
|
context.scene.render.resolution_percentage = 100
|
||||||
|
|
||||||
## set fps according to preferences settings
|
## set fps according to preferences settings
|
||||||
if fix.set_fps:
|
if fix.set_fps:
|
||||||
if context.scene.render.fps != prefs.fps:
|
if context.scene.render.fps != prefs.fps:
|
||||||
problems.append( (f"framerate corrected {context.scene.render.fps} >> {prefs.fps}", 'ERROR') )
|
problems.append( (f"framerate corrected {context.scene.render.fps} >> {prefs.fps}", 'ERROR') )
|
||||||
context.scene.render.fps = prefs.fps
|
if apply:
|
||||||
|
context.scene.render.fps = prefs.fps
|
||||||
|
|
||||||
## set show slider and sync range
|
## set show slider and sync range
|
||||||
if fix.set_slider_n_sync:
|
if fix.set_slider_n_sync:
|
||||||
|
@ -74,7 +89,6 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
||||||
if area.type == 'DOPESHEET_EDITOR':
|
if area.type == 'DOPESHEET_EDITOR':
|
||||||
if hasattr(area.spaces[0], 'show_sliders'):
|
if hasattr(area.spaces[0], 'show_sliders'):
|
||||||
setattr(area.spaces[0], 'show_sliders', True)
|
setattr(area.spaces[0], 'show_sliders', True)
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
@ -83,8 +97,9 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
||||||
tool = fix.select_active_tool
|
tool = fix.select_active_tool
|
||||||
if tool != 'none':
|
if tool != 'none':
|
||||||
if bpy.context.workspace.tools.from_space_view3d_mode(bpy.context.mode, create=False).idname != tool:
|
if bpy.context.workspace.tools.from_space_view3d_mode(bpy.context.mode, create=False).idname != tool:
|
||||||
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]}')
|
||||||
|
if apply:
|
||||||
|
bpy.ops.wm.tool_set_by_id(name=tool) # Tweaktoolcode
|
||||||
|
|
||||||
# ## 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:
|
||||||
|
@ -119,17 +134,20 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
||||||
if fix.set_pivot_median_point:
|
if fix.set_pivot_median_point:
|
||||||
if context.scene.tool_settings.transform_pivot_point != 'MEDIAN_POINT':
|
if context.scene.tool_settings.transform_pivot_point != 'MEDIAN_POINT':
|
||||||
problems.append(f"Pivot changed from '{context.scene.tool_settings.transform_pivot_point}' to 'MEDIAN_POINT'")
|
problems.append(f"Pivot changed from '{context.scene.tool_settings.transform_pivot_point}' to 'MEDIAN_POINT'")
|
||||||
context.scene.tool_settings.transform_pivot_point = 'MEDIAN_POINT'
|
if apply:
|
||||||
|
context.scene.tool_settings.transform_pivot_point = 'MEDIAN_POINT'
|
||||||
|
|
||||||
if fix.disable_guide:
|
if fix.disable_guide:
|
||||||
if context.scene.tool_settings.gpencil_sculpt.guide.use_guide == True:
|
if context.scene.tool_settings.gpencil_sculpt.guide.use_guide == True:
|
||||||
problems.append(f"Disabled Draw Guide")
|
problems.append(f"Disabled Draw Guide")
|
||||||
context.scene.tool_settings.gpencil_sculpt.guide.use_guide = False
|
if apply:
|
||||||
|
context.scene.tool_settings.gpencil_sculpt.guide.use_guide = False
|
||||||
|
|
||||||
if fix.autokey_add_n_replace:
|
if fix.autokey_add_n_replace:
|
||||||
if context.scene.tool_settings.auto_keying_mode != 'ADD_REPLACE_KEYS':
|
if context.scene.tool_settings.auto_keying_mode != 'ADD_REPLACE_KEYS':
|
||||||
problems.append(f"Autokey mode reset to 'Add & Replace'")
|
problems.append(f"Autokey mode reset to 'Add & Replace'")
|
||||||
context.scene.tool_settings.auto_keying_mode = 'ADD_REPLACE_KEYS'
|
if apply:
|
||||||
|
context.scene.tool_settings.auto_keying_mode = 'ADD_REPLACE_KEYS'
|
||||||
|
|
||||||
if fix.file_path_type != 'none':
|
if fix.file_path_type != 'none':
|
||||||
pathes = []
|
pathes = []
|
||||||
|
@ -146,7 +164,22 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
||||||
print(mess)
|
print(mess)
|
||||||
print('\n'.join(pathes))
|
print('\n'.join(pathes))
|
||||||
print('-')
|
print('-')
|
||||||
|
|
||||||
|
if fix.lock_object_mode != 'none':
|
||||||
|
lockmode = bpy.context.scene.tool_settings.lock_object_mode
|
||||||
|
if fix.lock_object_mode == 'LOCK':
|
||||||
|
if not lockmode:
|
||||||
|
problems.append(f"Lock object mode toggled On")
|
||||||
|
if apply:
|
||||||
|
bpy.context.scene.tool_settings.lock_object_mode = True
|
||||||
|
|
||||||
|
elif fix.lock_object_mode == 'UNLOCK':
|
||||||
|
if lockmode:
|
||||||
|
problems.append(f"Lock object mode toggled Off")
|
||||||
|
if apply:
|
||||||
|
bpy.context.scene.tool_settings.lock_object_mode = False
|
||||||
|
|
||||||
|
|
||||||
# ## Set onion skin filter to 'All type'
|
# ## Set onion skin filter to 'All type'
|
||||||
# fix_kf_type = 0
|
# fix_kf_type = 0
|
||||||
# for gp in bpy.data.grease_pencils:#from data
|
# for gp in bpy.data.grease_pencils:#from data
|
||||||
|
@ -169,8 +202,10 @@ class GPTB_OT_file_checker(bpy.types.Operator):
|
||||||
print(p)
|
print(p)
|
||||||
else:
|
else:
|
||||||
print(p[0])
|
print(p[0])
|
||||||
|
|
||||||
# Show in viewport
|
# Show in viewport
|
||||||
show_message_box(problems, _title = "Changed Settings", _icon = 'INFO')
|
title = "Changed Settings" if apply else "Checked Settings (dry run, nothing changed)"
|
||||||
|
show_message_box(problems, _title = title, _icon = 'INFO')
|
||||||
else:
|
else:
|
||||||
self.report({'INFO'}, 'All good')
|
self.report({'INFO'}, 'All good')
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
|
@ -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, 6),
|
"version": (1, 5, 7),
|
||||||
"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": "",
|
||||||
|
@ -453,6 +453,11 @@ class GPTB_prefs(bpy.types.AddonPreferences):
|
||||||
layout.label(text='Following checks will be made when clicking "Check File" button:')
|
layout.label(text='Following checks will be made when clicking "Check File" button:')
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
# row = col.row()
|
# row = col.row()
|
||||||
|
|
||||||
|
col.prop(self.fixprops, 'check_only')
|
||||||
|
col.label(text='If dry run is checked, no modification is done')
|
||||||
|
col.label(text='Note: you can use Ctrl+Click on Check file button to invert the behavior')
|
||||||
|
col.separator()
|
||||||
col.prop(self.fixprops, 'lock_main_cam')
|
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_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_res_percentage')
|
||||||
|
@ -467,6 +472,7 @@ class GPTB_prefs(bpy.types.AddonPreferences):
|
||||||
#-# col.prop(self.fixprops, 'set_cursor_type')
|
#-# col.prop(self.fixprops, 'set_cursor_type')
|
||||||
col.prop(self.fixprops, "select_active_tool", icon='RESTRICT_SELECT_OFF')
|
col.prop(self.fixprops, "select_active_tool", icon='RESTRICT_SELECT_OFF')
|
||||||
col.prop(self.fixprops, "file_path_type")
|
col.prop(self.fixprops, "file_path_type")
|
||||||
|
col.prop(self.fixprops, "lock_object_mode")
|
||||||
# row.label(text='lock the active camera if not a draw cam (and if not "layout" in blendfile name)')
|
# 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':
|
||||||
|
|
|
@ -17,6 +17,12 @@ def change_edit_lines_opacity(self, context):
|
||||||
|
|
||||||
|
|
||||||
class GP_PG_FixSettings(bpy.types.PropertyGroup):
|
class GP_PG_FixSettings(bpy.types.PropertyGroup):
|
||||||
|
|
||||||
|
check_only : BoolProperty(
|
||||||
|
name="Dry run mode (Check only)",
|
||||||
|
description="Do not change anything, just print the messages",
|
||||||
|
default=False, options={'HIDDEN'})
|
||||||
|
|
||||||
lock_main_cam : BoolProperty(
|
lock_main_cam : BoolProperty(
|
||||||
name="Lock Main Cam",
|
name="Lock Main Cam",
|
||||||
description="Lock the main camera (works only if 'layout' is not in name)",
|
description="Lock the main camera (works only if 'layout' is not in name)",
|
||||||
|
@ -79,7 +85,7 @@ class GP_PG_FixSettings(bpy.types.PropertyGroup):
|
||||||
|
|
||||||
## default active tool to use
|
## default active tool to use
|
||||||
select_active_tool : EnumProperty(
|
select_active_tool : EnumProperty(
|
||||||
name="Default selection tool", description="Active tool to set when launching check fix scene",
|
name="Set Default Selection Tool", description="Active tool to set when launching check fix scene",
|
||||||
default='builtin.select_lasso',
|
default='builtin.select_lasso',
|
||||||
items=(
|
items=(
|
||||||
('none', 'Dont change', 'Let the current active tool without change', 0),#'MOUSE_RMB'
|
('none', 'Dont change', 'Let the current active tool without change', 0),#'MOUSE_RMB'
|
||||||
|
@ -99,6 +105,16 @@ class GP_PG_FixSettings(bpy.types.PropertyGroup):
|
||||||
('ABSOLUTE', 'Absolute', 'Check if all path are absolute', 2),
|
('ABSOLUTE', 'Absolute', 'Check if all path are absolute', 2),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
## check set lock object mode
|
||||||
|
lock_object_mode : EnumProperty(
|
||||||
|
name="Set Lock Object Mode", description="Set 'Lock object mode' parameter check'",
|
||||||
|
default='none',
|
||||||
|
items=(
|
||||||
|
('none', 'Do nothing', 'Do not set', 0),
|
||||||
|
('LOCK', 'Lock object mode', 'Toggle lock object mode On', 1),
|
||||||
|
('UNLOCK', 'Unlock object mode', 'Toggle lock object mode Off', 2),
|
||||||
|
))
|
||||||
|
|
||||||
class GP_PG_ToolsSettings(bpy.types.PropertyGroup):
|
class GP_PG_ToolsSettings(bpy.types.PropertyGroup):
|
||||||
eraser_radius : IntProperty(
|
eraser_radius : IntProperty(
|
||||||
name="Eraser Radius", description="Radius of eraser brush",
|
name="Eraser Radius", description="Radius of eraser brush",
|
||||||
|
|
Loading…
Reference in New Issue