Finding all references to channel? Or creating CHOP Exports with Python?

Let’s say I have 2 operators, a Null CHOP (null1) and a Level TOP (level1)

If I drag channel 0 from null1 onto the Invert parameter of level1, I can select “Export CHOP” and create a hard export between the two ops. At this point, if I access op("null1")[0].exports in python, I’ll see an array containing the Invert parameter I’m exporting to. This is great because if I ever want to kill exports from null1 (e.g before calling op("null1").destroy()), I can iterate through its channel exports, switching them into constant or expression mode or some other backup/default reference.

Alternatively, let’s say instead of manually dropping the channel and selecting “Export CHOP”, I create a reference in python, e.g. op("level1").par.invert.expr = "op('null1')[0]". Now op("null1")[0].exports is an empty array, as it doesn’t acknowledge the expression reference as it did the earlier export. How can I programmatically access expression references to clean them up before I call op("null1").destroy()?

I’ve seen mention of using the OP Find DAT to search for all operators in the network which contain a parameter reference to op("null1")[0], which sadly isn’t practical in my network due to performance limitations, plus the reference expressions aren’t guaranteed to always be the same string.

On the other hand, if I could create a CHOP Export in python, then I could avoid expressions altogether. E.g if I could do something like op("null1")[0].exportTo(op("level1").par.invert resulting in a traditional export, then I could presumably access this relationship later via the channel’s exports attribute. But exportTo isn’t a real method, and I haven’t found anything in the docs / various class methods suggesting this is possible.

Is there a way, given a Channel, to find all parameters in the network which derive their value from that Channel, similar to traditional channel exports? Or can traditional channel exports be created in python?

Hi @benjaminben

not sure if using the COMP method .findChildren (COMP Class - Derivative) would be more performant than a OP Find DAT but might be worth a try.

You can also create and remove exports by either controlling the export table that is docked to a exporting CHOP or switching the Export Method parameter on the CHOP’s Common page to “Channelname is Path:Parameter” at which point aptly named channels (in your case level1:invert) will be able to automatically export to parameters. If the export flag is turned of or the operator is removed, nothing is left behind (as in the parameter mode of the target parameter should switch to constant mode again)

Hope this helps
cheers
Markus

Hey and thanks Markus! Funny after years with TD I never knew about manipulating the export table, that’s very insightful for future cases, although in this case I’m now realizing I might run into potential bugs as the operators on the receiving end are subject to changing paths.

On the other hand I’m seeing surprisingly solid performance with op.findChildren(parExpr="*path/to/op*"), even with a lot of operators going multiple levels deep only a couple of frames dropped. I might go this route as it’s not something I need to track constantly, just in the event of deleting the source of another op’s parameters, so being able to call a simple method in those cases is a helpful escape hatch. Thanks again!