New member for op class

Problem

The annotate COMP is probably one of my favorite additions to TouchDesigner in the last few years, and as such there are lots of ways I’m using these days. Recently, however, on a project we realized that while the Annotation COMP knows which ops it encloses with enclosedOPs, an operator doesn’t know if it’s inside an annotation.

Proposal

The op class contains members for dock and docked, a lovely addition would be annotated (or some other descriptor) as a member that could return a possibly empty list of annotation COMPs that an operator is inside of.

Proof of Concept

A simple python execution is fairly straightforward to implement, and could even be added to the tdu module as a helper instead of as an op class member.

def find_in_annotations(some_op:object) -> list:
    annotate_owners = []
    annotate_ops = some_op.parent().findChildren(type=annotateCOMP, depth=1)
    for each_annotate in annotate_ops:
        ops_as_paths = [each_op.path for each_op in each_annotate.enclosedOPs]
        print(ops_as_paths, some_op.path)
        if some_op.path in each_annotate.enclosedOPs:
            annotate_owners.append(each_annotate)

    return annotate_owners    

The simple python approach works with ops that are enclosed in a single op:

And also works with an op enclosed in multiple annotations:

5 Likes

+1
It would be great to hook in a callback as well for onAddOp and onRemoveOp.

Loving the annotation COMP btw.

Have you tried the Execute DAT ‘Number Children Change’ callback?

EDIT. Realize you mean sliding them into/out of range for the callback. Number Children Change would only apply to adding children, so never mind.

Above requests make sense.