Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import glob
- import hou
- # User inputs
- folder_path = '/server/hdri'
- file_mask = '*_acescg.exr'
- exclusion_wildcards = 'blank,do_not_use' # Comma-separated exclusion wildcards
- start_frame = 1001
- interval = 5 # Interval frame number to make changes over time
- # Get the Python SOP node
- node = hou.pwd()
- geometry = node.geometry()
- # Get all the .exr files from the folder with the given mask
- file_pattern = os.path.join(folder_path, file_mask)
- exr_files = sorted(glob.glob(file_pattern))
- if not exr_files:
- raise ValueError(f"No files found with pattern: {file_pattern}")
- # Filter out files based on exclusion wildcards
- exclusion_list = [wildcard.strip() for wildcard in exclusion_wildcards.split(',')]
- filtered_files = [f for f in exr_files if not any(excl in f for excl in exclusion_list)]
- if not filtered_files:
- raise ValueError("No files left after applying exclusion wildcards.")
- # Set file_name attribute as a detail attribute based on the current frame
- geometry.addAttrib(hou.attribType.Global, 'file_name', '')
- current_frame = hou.intFrame()
- # Determine the index of the file to use based on the current frame
- if current_frame >= start_frame:
- index = (current_frame - start_frame) // interval
- if index < len(filtered_files):
- base_name = os.path.basename(filtered_files[index])
- geometry.setGlobalAttribValue('file_name', base_name)
- else:
- geometry.setGlobalAttribValue('file_name', '') # Set to empty if out of range
- else:
- geometry.setGlobalAttribValue('file_name', '') # Set to empty if before start_frame
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement