Create a ticket

Q100343: How to automatically create OCIOCDLTransform soft effects and set .cc file paths for clips in NukeStudio and Hiero


This article explains how you can use Python to automatically create a OCIOCDLTransform soft effect for each clip in your NukeStudio or Hiero timeline, and define the ASC CDL file path for each shot.



When you manually create OCIOCDLTransform soft effects for clips inside NukeStudio or Hiero, you can create one effect at a time for each clip, then manually have to set the .cc file path for each of the soft effects.

This can be rather time consuming, particularly if you have a lot of shots in your timeline and each one has it’s own .cc file to apply.

However, you can use Python to automate this setup and below is the example code that creates a OCIOCDLTransform soft effect for each clip and applies a different .cc file path to each soft effect:

for trackItem in [y for x in hiero.ui.activeSequence().videoTracks() for y in x.items()]:
trackItemEffect = trackItem.parentTrack().createEffect("OCIOCDLTransform",trackItem=trackItem )
shotNumber =["_")+1:]
ocioPath = "/path/to/CDL/shot_" + shotNumber + ".cc"


Breaking down the code line by line, here is an explanation of what each line does:

for trackItem in [y for x in hiero.ui.activeSequence().videoTracks() for y in x.items()]:

This first line creates a for loop and iterates through all the clips in the timeline. The rest of the code is then applied to each clip at a time within the list of timeline clips.

The hiero.ui.activeSequence().videoTracks() command queries the currently active sequence on the timeline, loops through all the clip items of each video track and adds them to a Python list. This creates the full list of clips to apply the commands from the next lines to. 

trackItemEffect = trackItem.parentTrack().createEffect("OCIOCDLTransform",trackItem=trackItem )

This second line creates the soft effect and adds it to the current clip we're on in the for loop. 


This third line sets the 'read from file' knob value on the soft effect created for the current clip. 

shotNumber =["_")+1:]

This fourth line generates the shot number of the clip. This works by querying the shot name, finding the last underscore and splitting the name of the shot to leave just the shot number.

ocioPath = "/path/to/CDL/shot_" + shotNumber + ".cc"

This fifth line generates the path to the .cc file by using the location path and file naming convention, and concatenating it to the shot number and the .cc file extension.


This last line sets the soft effects file path to the one generated in line 5.

NOTE: The code works based on an established naming convention for shots and for the .cc file paths. To adapt this to your workflow you will need to adjust line 4 and 5 to match the naming convention used for your project.


Below is the result of the code being run within the Script Editor and the OCIOCDLTransform soft effects being created for all clips within the NukeStudio timeline:


Was this article helpful?

We're sorry to hear that!

Please tell us why.
3 out of 3 found this helpful