Writing behaviors to other component’s signal.Connections is throwing error, but working ok.
Adding other behaviors to the Connections list using API is not prevented, and this approach works ok. However, sometimes this might be a bit unstable, for example components objects can be lost when layout has been changed or reopened, etc. That’s why you might see the warning printed in the Output window:
Warning: Assigning value of incorrect type for property ‘Connections’ in script ‘Human (Anna)::ResourceScript’. Property type is ‘List<Ref >’.
To avoid this problem, safer approach would be to register to signal.OnValueChange event.
Remember to use evaluateCondition() to re-evaluate the condition when waiting on that line.
Here is an example:
from vcScript import *
app = getApplication()
comp = getComponent()
monitoredSignal = None
triggerer = None
def OnStart():
global monitoredSignal
monitoredComp = app.findComponent("Shape Feeder")
monitoredSignal = monitoredComp.findBehaviour("TransitionSignal")
monitoredSignal.OnValueChange = on_transition_signal
def on_transition_signal(signal):
global triggerer
triggerer = signal
evaluateCondition()
def OnRun():
global triggerer
n = 0
while True:
triggerCondition(lambda: triggerer == monitoredSignal and triggerer.Value == True)
triggerer = None
n += 1
print n, "New component created!"