How to manipulate conveyor port connection with python script?

I need to model a shuttle conveyor that will be controlled by a PLC.

How do I manipulate the ports so that the shuttle conveyor will be connected to and receive parts from a conveyor one end, and then connect and dispense parts to another conveyor on the other end of the shuttle?

I have attempted to read and modify the python script that comes with the built in VC shuttle conveyor, but was never able to get it to work. I am pretty lost on where to go next.

Is there anyway to control conveyor port connections without PnP and regardless of their position within the 3D space?

First find the paths to connect
path1=comp.findBehaviour(“Path”)
path2=conveyor2.findBehaviour(“Path”)

Get the connectors
path1_in=path1.getConnector(0) #input
path1_out=path1.getConnector(1) #output
path2_in=path2.getConnector(0) #input
path2_out=path2.getConnector(1) #output

connect
path1_out.connect(path2_in)

EDIT:
and if you want to disconnect
path1_out.connect(None)

2 Likes

Thank you very much, this seems promising. I should be able to try this soon, but I do have one question.
I know comp generally comes from the getcomponent method, but how do you access the other object? (conveyor2 in your example)

app = getApplication()
other_comp = app.findComponent('conveyor2 ')

1 Like

Thank you Unnahi and anhu, you’ve both been a big help. I have one more question if it’s not too much.

I was testing that code and realized if the conveyors are not aligned, the part will follow the second conveyors path but not move position to the second conveyor, as you can see here:

When I was messing around with ports before, I did get parts to “appear” on another conveyor that was not connected, but perhaps that was a bug/ something I shouldn’t be doing anyway.

Where are your path frames on that second conveyor? Did you move the whole thing or just geometry?

EDIT:
You can use @ sign to notify people @JoshuaReinhart

1 Like

My bad, I apologize. I had been pulled away and didn’t get the chance to come back and reply.

I was actually unable to recreate my problem, after starting fresh, the parts always moved to the other conveyor.

I assume I must have somehow left the frame features when moving the conveyor as you suggested.

I appreciate the help.

1 Like