Control the direction of a Two Way Conveyor

Hey there,

I want to change the direction of a two way conveyor. I know that there is an option to change the direction manually, but is there also an option to change the direction with a pyhton script or something else?

How I can reference to the TwoWayPath::Direction of the conveyor?

in script:
comp = getComponent()
path = comp.findBehaviour(‘TwoWayPath’)
path.Direction = VC_PATH_FORWARD
path.Direction = VC_PATH_BACKWARD

see help file:

Thank you for your response. That helps me quite a bit.

I use two sensors. One on each side of the conveyor. If the cube reach a sensor, the direction should change. My problem is that there is an error message caused by the “startMovement()”-command and if the cube reach the left sensor the direction does not change.

Where is there problem? I am desperate…

My code is enclosed.

from vcScript import *

comp = getComponent()
path = comp.getBehaviour("TwoWayPath")
sensor_end_right = comp.getBehaviour("Sensor_End_Right")
sensor_end_left = comp.getBehaviour("Sensor_End_Left")
cube = comp.ChildComponents[2]

def OnRun():
  path.Direction = VC_PATH_FORWARD
  while True:
    if triggerCondition(lambda: sensor_end_right.Value == True):
      path.Direction = VC_PATH_BACKWARD    
    elif triggerCondition(lambda: sensor_end_left.Value == True):
      path.Direction = VC_PATH_FORWARD

I would use some other way to get a reference to the cube instead of: cube = comp.ChildComponents[2]

Also not sure what is happening on the final line? path.Value.startMovement()
Maybe you should use cube instead of path.Value?