Python script works in Hiero Script Editor but fails in AYON Custom Tools

Hi,
I’m trying to run a small Python snippet through AYON Custom Tools in Foundry Hiero to set custom colorspace on selected clips.
The same code works fine in Hiero’s Script Editor, but in AYON it gives an invalid syntax error when I run it.
Am I missing something about how AYON expects the code to be written or executed?

script

seq = hiero.ui.activeSequence();
te = hiero.ui.getTimelineEditor(seq);

selected_nodes = te.selection();

for node in selected_nodes:
if isinstance(node, hiero.core.TrackItem):
node.setSourceMediaColourTransform(‘data’)

Sounds like it could be lacking the right indentations (spaces?)

import hiero
seq = hiero.ui.activeSequence()
te = hiero.ui.getTimelineEditor(seq)

selected_nodes = te.selection()
for node in selected_nodes:
    if isinstance(node, hiero.core.TrackItem):
        node.setSourceMediaColourTransform("data")

Also, make sure to import hiero just in case.

Indentation is actually there, but when I added it in the post, it got removed. I also tried using import hiero. The only error I was getting was a syntax error. I found out that each line needs to end with ; lines where I added the ; no longer gave errors.

The issue now is with the for loop that’s where the syntax error comes up, because it’s tricky to use ; in AYON’s parser with loops. Earlier, the error was even pointing to the very first line, but that got resolved once I added a ; at the end of that line.

I see - I think the issue is really in the way the settings are exposing the commands. Because the Scripts Menu should just be passing the script as is to be executed.

Can you try this PR by any chance: Allow multi-line commands as custom tools + make `sourcetype` an enum by BigRoy · Pull Request #115 · ynput/ayon-hiero · GitHub