Get Source Elements

Find tracks, exposed parameters, links and more of parameters

sourceElements sourceElements sourceElements sourceElements

The sourceElements() function return the elements that have pointers to this Object : tracks, exposed parameters, links, etc…

o = script.parentElement.layers[0].renderer.opacity
for sourceElement in o.sourceElements():
    print (f"Source Element: {sourceElement.__oil_repr__()}")

In the example above, we want to create a new target inside the exposed parameter that control the color of the UniformLeft.

So we use the sourceElements() function to get the target and take it’s parent (the exposed color parameter)

Now we can add a new target that we link to the color of the UniformRight :

GetSourceElements GetSourceElements

#layer color
leftColor =  script.parentElement.layers["UniformLeft"].generator.color
rightColor =  script.parentElement.layers["UniformRight"].generator.color

#find the parameter that control the color of the UniformLeft
exposedParam = leftColor.sourceElements()[0].parent

#create a new target and assign it target to the UniformRight color
targetL = Oil.createObject("ParameterLinkTarget")
targetL.target.set(rightColor)

#add the target to the exposed parameter
exposedParam.append(targetL)

There also is a low level function that returns the pointers to this Object :

o = script.parentElement.layers[0].renderer.opacity
for sourcePointer in o.sourcePointers():
    print (f"Source Pointer: {sourcePointer.__oil_repr__()} {sourcePointer.getFriendlyName()}")