Detach component from path and attach it again


I’m writing a Python Script to control a bucket conveyor where every bucket is independent.

After some testing I managed to detach the bucket from my path and attach it to the 3D world, but I cannot attach it back to my path and I don’t know what I’m doing wrong.

from vcScript import *
comp = getComponent()
app = getApplication()
sim = getSimulation()
toppath = comp.getBehaviour(“TopPath”)
sensor = comp.findBehaviour(“ComponentPathSensor”)
world_container = sim.World.getBehavioursByType(VC_CONTAINER)[0]
bucket = comp.ChildComponents[0]

def OnRun():

while app.Simulation.IsRunning == True:
triggerCondition(lambda: sensor.BoolSignal.Value==True)

I did not wanted do use part.stopMovement() and path.Enabled because the ideal would be to use just one path and sometimes I need to stop just a bucket while the rest is moving and down the line I would have to stop many at a time.

I think it might be a problem with your while loop, the fact that when you go back to the conveyor belt again from the 3D world, it’s still on the sensor, that is, when you grab it again, it triggers the “world_container .grab(part)”. Hope that solves your problem, have a nice day!

Hello Bad,

Indeed it was a problem with my loop. Thank you very much for the help!

1 Like