Get Source Elements
_
=

Get Source Elements

Find tracks, exposed parameters, links and more of parameters

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 here 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
#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()}")

See Also: