Mask checker
0.9.2 - feat: add button to check if and which layers have masks
This commit is contained in:
		
							parent
							
								
									04093cad39
								
							
						
					
					
						commit
						89abd181e2
					
				| @ -14,6 +14,11 @@ Activate / deactivate layer opaticty according to prefix | |||||||
| Activate / deactivate all masks using MA layers | Activate / deactivate all masks using MA layers | ||||||
| --> | --> | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 0.9.2 | ||||||
|  | 
 | ||||||
|  | - feat: add button to check if and which layers have masks | ||||||
|  | 
 | ||||||
| 0.9.1 | 0.9.1 | ||||||
| 
 | 
 | ||||||
| - change: stop reporting all use light disable on `check layer` (too many messages) | - change: stop reporting all use light disable on `check layer` (too many messages) | ||||||
|  | |||||||
| @ -8,6 +8,8 @@ from . import fn | |||||||
| import math | import math | ||||||
| import re | import re | ||||||
| 
 | 
 | ||||||
|  | ## TODO : export json info to re-setup layers in AE automagically | ||||||
|  | 
 | ||||||
| class GPEXP_OT_layers_state(bpy.types.Operator): | class GPEXP_OT_layers_state(bpy.types.Operator): | ||||||
|     bl_idname = "gp.layers_state" |     bl_idname = "gp.layers_state" | ||||||
|     bl_label = "Set Layers State" |     bl_label = "Set Layers State" | ||||||
| @ -103,6 +105,7 @@ class GPEXP_OT_layers_state(bpy.types.Operator): | |||||||
|                 #         mlinvert = ' <>' if ml.invert else '' |                 #         mlinvert = ' <>' if ml.invert else '' | ||||||
|                 #         print(f'{ml.info}{mlstate}{mlinvert}') |                 #         print(f'{ml.info}{mlstate}{mlinvert}') | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|                 if l.opacity != 1: |                 if l.opacity != 1: | ||||||
|                     # TODO Skip zeroed opacity ? |                     # TODO Skip zeroed opacity ? | ||||||
|                     # check if there is an exclusion word |                     # check if there is an exclusion word | ||||||
| @ -135,6 +138,13 @@ class GPEXP_OT_layers_state(bpy.types.Operator): | |||||||
|                         l.blend_mode = 'REGULAR' |                         l.blend_mode = 'REGULAR' | ||||||
|                     used = True |                     used = True | ||||||
| 
 | 
 | ||||||
|  |                 if len(l.frames) == 1 and len(l.frames[0].strokes) == 0 and not l.hide: | ||||||
|  |                     # probably used as separator | ||||||
|  |                     l.hide = True | ||||||
|  |                     mess = f'{l.info} : No frames. Hiding layer' | ||||||
|  |                     print(mess) | ||||||
|  |                     changes.append(mess) | ||||||
|  |                     used = True | ||||||
| 
 | 
 | ||||||
|                 if used: |                 if used: | ||||||
|                     print() |                     print() | ||||||
| @ -315,10 +325,65 @@ class GPEXP_OT_auto_number_object(bpy.types.Operator): | |||||||
| 
 | 
 | ||||||
|         return {"FINISHED"} |         return {"FINISHED"} | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | class GPEXP_OT_check_masks(bpy.types.Operator): | ||||||
|  |     bl_idname = "gp.check_masks" | ||||||
|  |     bl_label = "Check Masks" | ||||||
|  |     bl_description = "Check and report all masked GP layers" | ||||||
|  |     bl_options = {"REGISTER", "UNDO"} | ||||||
|  | 
 | ||||||
|  |     @classmethod | ||||||
|  |     def poll(cls, context): | ||||||
|  |         return context.object and context.object.type == 'GPENCIL' | ||||||
|  | 
 | ||||||
|  |     def execute(self, context): | ||||||
|  |         # if self.all_objects: | ||||||
|  |         #     pool = [o for o in context.scene.objects if o.type == 'GPENCIL'] | ||||||
|  |         # else: | ||||||
|  |         #     pool = [o for o in context.selected_objects if o.type == 'GPENCIL'] | ||||||
|  |         changes = [] | ||||||
|  |         pool = [o for o in context.scene.objects if o.type == 'GPENCIL'] | ||||||
|  |         for o in pool: | ||||||
|  |             for l in o.data.layers: | ||||||
|  |                 if l.use_mask_layer: | ||||||
|  |                     obj_stat = f'{o.name} >>' | ||||||
|  |                     if not obj_stat in changes: | ||||||
|  |                         changes.append(obj_stat) | ||||||
|  |                         print(obj_stat) | ||||||
|  |                      | ||||||
|  |                     hide_state = ' (hided)' if l.hide else '' | ||||||
|  |                     text = f'  {l.info}{hide_state}:' # :masks:  | ||||||
|  |                     changes.append(text) | ||||||
|  |                     print(text) | ||||||
|  |                      | ||||||
|  |                     has_masks = False | ||||||
|  |                     for ml in l.mask_layers: | ||||||
|  |                         # 'hide', 'invert', 'name' | ||||||
|  |                         h = ' hided' if ml.hide else '' | ||||||
|  |                         i = ' (inverted)' if ml.invert else ''  | ||||||
|  |                         text = f'   - {ml.name}{h}{i}' | ||||||
|  |                         changes.append(text) | ||||||
|  |                         print(text) | ||||||
|  |                         has_masks = True | ||||||
|  | 
 | ||||||
|  |                     if not has_masks: | ||||||
|  |                         text = 'No masks!' | ||||||
|  |                         changes.append(text) | ||||||
|  |                         print(text)                         | ||||||
|  |                     changes.append('') | ||||||
|  | 
 | ||||||
|  |         if changes: | ||||||
|  |             fn.show_message_box(_message=changes, _title="Masks Check Report", _icon='INFO') | ||||||
|  |         else: | ||||||
|  |             fn.show_message_box(_message='No Masks!', _title="Masks Check Report", _icon='INFO') | ||||||
|  | 
 | ||||||
|  |         return {"FINISHED"} | ||||||
|  | 
 | ||||||
| classes=( | classes=( | ||||||
| GPEXP_OT_layers_state, | GPEXP_OT_layers_state, | ||||||
| GPEXP_OT_lower_layers_name, | GPEXP_OT_lower_layers_name, | ||||||
| GPEXP_OT_auto_number_object | GPEXP_OT_auto_number_object, | ||||||
|  | GPEXP_OT_check_masks, | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| def register():  | def register():  | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ bl_info = { | |||||||
|     "name": "GP Render", |     "name": "GP Render", | ||||||
|     "description": "Organise export of gp layers through compositor output", |     "description": "Organise export of gp layers through compositor output", | ||||||
|     "author": "Samuel Bernou", |     "author": "Samuel Bernou", | ||||||
|     "version": (0, 9, 1), |     "version": (0, 9, 2), | ||||||
|     "blender": (2, 93, 0), |     "blender": (2, 93, 0), | ||||||
|     "location": "View3D", |     "location": "View3D", | ||||||
|     "warning": "", |     "warning": "", | ||||||
|  | |||||||
							
								
								
									
										1
									
								
								ui.py
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								ui.py
									
									
									
									
									
								
							| @ -213,6 +213,7 @@ class GPEXP_PT_gp_dopesheet_ui(Panel): | |||||||
|         row.operator('gp.auto_number_object', icon='X', text='').delete = True |         row.operator('gp.auto_number_object', icon='X', text='').delete = True | ||||||
|         col.operator('gp.layers_state', icon='CHECKMARK', text='Check layers') |         col.operator('gp.layers_state', icon='CHECKMARK', text='Check layers') | ||||||
|         col.operator('gp.lower_layers_name', icon='SYNTAX_OFF', text='Rename Lowercase') |         col.operator('gp.lower_layers_name', icon='SYNTAX_OFF', text='Rename Lowercase') | ||||||
|  |         col.operator('gp.check_masks', icon='MOD_MASK', text='Has Masks') | ||||||
|          |          | ||||||
|         # row = layout.row() |         # row = layout.row() | ||||||
|         layout.prop(bpy.context.preferences.edit, 'use_anim_channel_group_colors') |         layout.prop(bpy.context.preferences.edit, 'use_anim_channel_group_colors') | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user