check list for file

1.5.1

- fix: eraser brush
- change: check file has custom check list in addon prefs
This commit is contained in:
Pullusb
2021-06-17 16:21:27 +02:00
parent 060fa8ff92
commit 2efbb36ddf
5 changed files with 202 additions and 77 deletions
Regular → Executable
+97 -68
View File
@@ -27,92 +27,121 @@ class GPTB_OT_file_checker(bpy.types.Operator):
def execute(self, context):
prefs = get_addon_prefs()
fix = prefs.fixprops
problems = []
## Lock main cam:
if not 'layout' in Path(bpy.data.filepath).stem:#dont touch layout cameras
if context.scene.camera:
cam = context.scene.camera
if cam.name == 'draw_cam' and cam.parent:
if cam.parent.type == 'CAMERA':
cam = cam.parent
else:
cam = None
if cam:
triple = (True,True,True)
if cam.lock_location[:] != triple or cam.lock_rotation[:] != triple:
problems.append('Lock main camera')
cam.lock_location = cam.lock_rotation = triple
if fix.lock_main_cam:
if not 'layout' in Path(bpy.data.filepath).stem.lower():#dont touch layout cameras
if context.scene.camera:
cam = context.scene.camera
if cam.name == 'draw_cam' and cam.parent:
if cam.parent.type == 'CAMERA':
cam = cam.parent
else:
cam = None
if cam:
triple = (True,True,True)
if cam.lock_location[:] != triple or cam.lock_rotation[:] != triple:
problems.append('Lock main camera')
cam.lock_location = cam.lock_rotation = triple
## set scene res at pref res according to addon pref
rx, ry = prefs.render_res_x, prefs.render_res_y
# 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:
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 fix.set_scene_res:
rx, ry = prefs.render_res_x, prefs.render_res_y
# 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:
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
## set scene percentage at 100:
if context.scene.render.resolution_percentage != 100:
problems.append('Resolution output to 100%')
context.scene.render.resolution_percentage = 100
## set show slider and sync range
for window in bpy.context.window_manager.windows:
screen = window.screen
for area in screen.areas:
if area.type == 'DOPESHEET_EDITOR':
if hasattr(area.spaces[0], 'show_sliders'):
setattr(area.spaces[0], 'show_sliders', True)
if hasattr(area.spaces[0], 'show_locked_time'):
setattr(area.spaces[0], 'show_locked_time', True)
if fix.set_res_percentage:
if context.scene.render.resolution_percentage != 100:
problems.append('Resolution output to 100%')
context.scene.render.resolution_percentage = 100
## 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
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
if fix.set_slider_n_sync:
for window in bpy.context.window_manager.windows:
screen = window.screen
for area in screen.areas:
if area.type == 'DOPESHEET_EDITOR':
if hasattr(area.spaces[0], 'show_sliders'):
setattr(area.spaces[0], 'show_sliders', True)
if hasattr(area.spaces[0], 'show_locked_time'):
setattr(area.spaces[0], 'show_locked_time', True)
## set cursor type (according to prefs ?)
if context.mode in ("EDIT_GPENCIL", "SCULPT_GPENCIL"):
tool = prefs.select_active_tool
if tool != 'none':
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]}')
if fix.set_cursor_type:
if context.mode in ("EDIT_GPENCIL", "SCULPT_GPENCIL"):
tool = prefs.select_active_tool
if tool != 'none':
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]}')
# ## GP use additive drawing (else creating a frame in dopesheet makes it blank...)
# if not context.scene.tool_settings.use_gpencil_draw_additive:
# problems.append(f'Activated Gp additive drawing mode (snowflake)')
# context.scene.tool_settings.use_gpencil_draw_additive = True
## GP use additive drawing (else creating a frame in dopesheet makes it blank...)
if not context.scene.tool_settings.use_gpencil_draw_additive:
problems.append(f'Activated Gp additive drawing mode (snowflake)')
context.scene.tool_settings.use_gpencil_draw_additive = True
## GP stroke placement/projection check
if context.scene.tool_settings.gpencil_sculpt.lock_axis != 'AXIS_Y':
problems.append('/!\\ Draw axis not "Front" (Need Manual change if not Ok)')
if fix.check_front_axis:
if context.scene.tool_settings.gpencil_sculpt.lock_axis != 'AXIS_Y':
problems.append('/!\\ Draw axis not "Front" (Need Manual change if not Ok)')
if bpy.context.scene.tool_settings.gpencil_stroke_placement_view3d != 'ORIGIN':
problems.append('/!\\ Draw placement not "Origin" (Need Manual change if not Ok)')
if fix.check_placement:
if bpy.context.scene.tool_settings.gpencil_stroke_placement_view3d != 'ORIGIN':
problems.append('/!\\ Draw placement not "Origin" (Need Manual change if not Ok)')
## Disabled animation
fcu_ct = 0
for act in bpy.data.actions:
if not act.users:
continue
for fcu in act.fcurves:
if fcu.mute:
fcu_ct += 1
print(f"muted: {act.name} > {fcu.data_path}")
if fcu_ct:
problems.append(f'{fcu_ct} anim channel disabled (details -> console)')
if fix.list_disabled_anim:
fcu_ct = 0
for act in bpy.data.actions:
if not act.users:
continue
for fcu in act.fcurves:
if fcu.mute:
fcu_ct += 1
print(f"muted: {act.name} > {fcu.data_path}")
if fcu_ct:
problems.append(f'{fcu_ct} anim channel disabled (details -> console)')
## Use median point
if fix.set_pivot_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'")
context.scene.tool_settings.transform_pivot_point = 'MEDIAN_POINT'
if fix.disable_guide:
if context.scene.tool_settings.gpencil_sculpt.guide.use_guide == True:
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'")
## 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
# if ob.type == 'GPENCIL':
# ob.data.onion_keyframe_type = 'ALL'