Accessing Process Node Executor Failure

Hey everyone,

I have the following Issue, I wrote a Python Script for some distributing rules. The script works fine but when I load the Layout I get this error message: TypeError: ‘NoneType’ object is not subscriptable.
But when I recompile my script, the error disappears and everything is okay. The error occurs in the marked line. I tried to access the Executor with findBehaviour(‘ProcessExecutor__HIDE__’).Processes[0] but it wont change anything.
Thanks in advance.

from vcScript import *
import time

sim = getSimulation()
comp = getComponent()
app = getApplication()

trigger = comp.findBehaviour('trigger')
transportedIn = comp.findBehaviour('transportedIn_PS2')
took_one = comp.findBehaviour('took_One')
global stack2_lvlDrill


Error in this line --> millingProcess = comp.findBehavioursByType('rProcessExecutor')[0].Processes[0]
buffer_prop = millingProcess.getProperty('buffer_lvlMilling')

buffer_Node = app.findComponent('Process Node #6')
buffer_routine = buffer_Node.findBehaviour('ProcessExecutor__HIDE__').Processes[0]
need_prop = buffer_routine.getProperty('need')

#stack2_Node = app.findComponent('Process Node #7')
#stack2_routine = stack2_Node.findBehaviour('ProcessExecutor__HIDE__').Processes[0]
#tranIn_prop = stack2_routine.getProperty('transportedIn')

drillingProcess = app.findComponent('Process Node #8')
drilling_routine = drillingProcess.findBehaviour('ProcessExecutor__HIDE__').Processes[0]
nr_took_plate = drilling_routine.getProperty('took_Plate')

The script behavior gets compiled and the root scope runs before the executor programs are loaded.

You should move your code to e.g. OnStart or OnFinalize method.