rename fields in selection to fileoutput
1.8.0 - added: Allow to rename output on the fly using `connect selection to output`
This commit is contained in:
		
							parent
							
								
									332f8594ea
								
							
						
					
					
						commit
						fe3f0ae869
					
				| @ -14,6 +14,10 @@ Activate / deactivate layer opacity according to prefix | ||||
| Activate / deactivate all masks using MA layers | ||||
| --> | ||||
| 
 | ||||
| 1.8.0 | ||||
| 
 | ||||
| - added: Allow to rename output on the fly using `connect selection to output` | ||||
| 
 | ||||
| 1.7.4 | ||||
| 
 | ||||
| - removed: Restriction to use default scene "Scene" | ||||
|  | ||||
| @ -241,6 +241,7 @@ class GPEXP_OT_reset_render_settings(bpy.types.Operator): | ||||
| class GPEXP_PG_selectable_prop(bpy.types.PropertyGroup): | ||||
|     node_name: bpy.props.StringProperty(name="Object Name") | ||||
|     name: bpy.props.StringProperty(name="Name or Path") | ||||
|     socket_name: bpy.props.StringProperty(name="Source socket Name") # Source socket name as reference | ||||
|     select: bpy.props.BoolProperty(name="Selected", default=True) | ||||
|     is_linked: bpy.props.BoolProperty(name="Linked", default=False) | ||||
|     # is_valid: bpy.props.BoolProperty(name="Valid", default=True) | ||||
| @ -321,7 +322,8 @@ class GPEXP_OT_connect_selected_to_file_out(bpy.types.Operator): | ||||
|                     continue | ||||
|                 item = self.socket_collection.add() | ||||
|                 item.node_name = n.name | ||||
|                 item.name = o.name | ||||
|                 item.socket_name = item.name = o.name | ||||
|                 ## TODO: rename item.name according to tamplate pairs in preferences (to add later) | ||||
|                 if o.is_linked: | ||||
|                     item.is_linked = True | ||||
|                     item.select = False | ||||
| @ -358,20 +360,25 @@ class GPEXP_OT_connect_selected_to_file_out(bpy.types.Operator): | ||||
|                 row.label(text='', icon='BLANK1') | ||||
|             row.prop(item, 'select', text='') | ||||
| 
 | ||||
|             display_name = item.name | ||||
|             display_name = item.socket_name | ||||
|             if 'crypto' in display_name.lower(): | ||||
|                 display_name = f'{display_name} (-> separate 32bit output node)' | ||||
|             row.label(text=display_name) | ||||
|             row.label(text='', icon='RIGHTARROW') | ||||
|             row.prop(item, 'name', text='') | ||||
| 
 | ||||
|     def execute(self, context): | ||||
|          | ||||
|         # Build exclude dict from selection | ||||
|         excludes = {} | ||||
|         remap_names = {} | ||||
|         if len(self.socket_collection): | ||||
|             for item in self.socket_collection: | ||||
|                 if not item.select: | ||||
|                     # All deselected goes to exclude with {node_name: [socket1, ...]} | ||||
|                     excludes.setdefault(item.node_name, []).append(item.name) | ||||
|                 elif item.socket_name != item.name: | ||||
|                     remap_names[item.socket_name] = item.name | ||||
| 
 | ||||
|         ## Handle default file format | ||||
|         file_ext = self.file_format | ||||
| @ -394,7 +401,7 @@ class GPEXP_OT_connect_selected_to_file_out(bpy.types.Operator): | ||||
|          | ||||
|         # fn.connect_to_file_output(selected, outfile) | ||||
|         for n in selected: | ||||
|             fn.connect_to_file_output(n, outfile, base_path=self.base_path, excludes=excludes, file_format=file_format) | ||||
|             fn.connect_to_file_output(n, outfile, base_path=self.base_path, excludes=excludes, remap_names=remap_names, file_format=file_format) | ||||
|         return {"FINISHED"} | ||||
| 
 | ||||
| classes=( | ||||
|  | ||||
| @ -2,7 +2,7 @@ bl_info = { | ||||
|     "name": "GP Render", | ||||
|     "description": "Organise export of gp layers through compositor output", | ||||
|     "author": "Samuel Bernou", | ||||
|     "version": (1, 7, 4), | ||||
|     "version": (1, 8, 0), | ||||
|     "blender": (3, 0, 0), | ||||
|     "location": "View3D", | ||||
|     "warning": "", | ||||
|  | ||||
							
								
								
									
										14
									
								
								fn.py
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								fn.py
									
									
									
									
									
								
							| @ -1871,7 +1871,7 @@ def recursive_node_connect_check(l, target_node): | ||||
|                 return True | ||||
|     return False | ||||
| 
 | ||||
| def connect_to_file_output(node_list, file_out=None, base_path='', excludes=None, file_format=None): | ||||
| def connect_to_file_output(node_list, file_out=None, base_path='', excludes=None, remap_names=None, file_format=None): | ||||
|     """Connect selected nodes output to file output(s) | ||||
|     if a file output is selected, add intputs on it | ||||
| 
 | ||||
| @ -1952,7 +1952,12 @@ def connect_to_file_output(node_list, file_out=None, base_path='', excludes=None | ||||
|             for o in outs: | ||||
|                 if next((l for l in o.links if recursive_node_connect_check(l, fo)), None): | ||||
|                     continue | ||||
|                 slot_name = bpy.path.clean_name(o.name) | ||||
|                  | ||||
|                 if remap_names and (custom_name := remap_names.get(o.name)): | ||||
|                     slot_name = bpy.path.clean_name(custom_name) # clean name ? | ||||
|                 else: | ||||
|                     slot_name = bpy.path.clean_name(o.name) | ||||
| 
 | ||||
|                 # if fo.format.file_format == 'OPEN_EXR_MULTILAYER': | ||||
|                 #     slot_name = slot_name | ||||
|                 # else: | ||||
| @ -2011,7 +2016,10 @@ def connect_to_file_output(node_list, file_out=None, base_path='', excludes=None | ||||
|                 if next((l for l in o.links if recursive_node_connect_check(l, fo)), None): | ||||
|                     continue | ||||
| 
 | ||||
|                 slot_name = bpy.path.clean_name(o.name) # directly use name in multi layer exr | ||||
|                 if remap_names and (custom_name := remap_names.get(o.name)): | ||||
|                     slot_name = bpy.path.clean_name(custom_name) # clean name ? | ||||
|                 else: | ||||
|                     slot_name = bpy.path.clean_name(o.name) # directly use name in multi layer exr | ||||
| 
 | ||||
|                 # if fo.format.file_format == 'OPEN_EXR_MULTILAYER': | ||||
|                 #     slot_name = slot_name | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user