I’m a beginner of Python script. My final goal is to trim top 24 flame (slate) and tail 24 flame (black) with a python script. I’ve tried some basic python coding, right now I’m facing custom UI problem.
I got script_to_change_segment_colors from Andy. I copied the structure of it and change it to script to change clip colors for a baby step. Here is the script:
get all of your code inside the triple backticks like this
Taking a look… you are defining a timeline right click menu action that only appears for PyClip objects… but i think in a timeline with multiple shots… you could have PySegment objects and thats why its not appearing perhaps? It would only be a PyClip if its a timeline with 1 shot, 2 or more shots = PySegments.
So maybe try
def scope_timeline_object(selection):
"""Filter out only supported Timeline objects."""
valid_objects = (
flame.PyClip,
flame.PySegment)
return all(isinstance(item, valid_objects) for item in selection)
Or if you are doing a typical shift selection for a bunch of shots in a timeline, its actually going to include the PyTransition objects in between each shot as well. So you would need to include that in your filter, and then skip over transitions in your red() function.
def scope_timeline_object(selection):
"""Filter for PySegments or PyTransitions.
PyTransitions are included because typical box or shift + click selections will
include them.
"""
valid_objects = (
flame.PySegment,
flame.PyTransition)
return all(isinstance(item, valid_objects) for item in selection)
And then, I dont quite understand your final goal… but maybe instead of trimming, just set in & out on your timelines and then export using Export Between Marks would be an easier workflow. I have a script that sets in/out or clears them on all selected timelines (link to github or availble on logik portal). Though I do need to update it to work with 2025.
My bad, I fixed it. I’ll try what you give me.
My post studio gave me the weird instruction that you need to do hard commit on the top track of timelines and trim out timeline elements like slate and black frames before exporting. They think that prevents audio sub-frame shift when exporting.