Prioritize an assembly according to the part type

I want to prioritize the assembly of the assembly 1 if all the components to make it are present. If and only if, one of the two components for assembly 1 are not available, the operator can move on to assembly two.

To do this, I tried with a python script in the workstation component. I want to be able to catch the value of a signal from the Warehouse_Process_Shelf (yellow buffer) which is another component. Then, write TRUE to the NoPart1 signal in the workstation component.

I don’t really understand how I can get the value of a signal from component A and use it in a script for component B.

This is my script of the WorkStation (NoPart1Script)

from vcScript import *

app = getApplication()
comp = getComponent()

fromBufferFixture = app.findComponent(“Warehouse_Process_Shelf”)
varSignalFixture1 = fromBufferFixture.findBehaviour(“SignalFixture1”)

fromBufferRawPart1 = app.findComponent(“Buffer_Raw_Part1”)
varSignalPart1 = fromBufferFixture.findBehaviour(“SignalPart1”)

NoPart1Signal = comp.findBehaviour(“NoPart1”)

def OnRun():

if varSignalFixture1.signal || varSignalPart1 == False:
NoPart1Signal.signal(True)
print (trigger,NoPart1Signal)

PriorityWithPythonScript.vcmx (3.4 MB)

Thank you for your help!

1 Like

Hi,

I’m not sure what your exact conditions are, but this is how you can read and send signals:

Reading is done by {signalname.Value == condition} and sending by {signalname.signal(condition)}.

Don’t forget to add some delay as shown below, otherwise, if the conditions are not met then the script will crash
image

Hi Jesper,

Thank you, now it works.
I still have an error when I run the simulation.
When I don’t put arguments in the OnRunm there is this error :
Error1

And when I put two arguments, this error happen:
error2

Do you know why?

My script is now this:

I added, the containerBF1.OnTransition = OnRun, without this, the value of the signals SignalFixture1 and signalPart1 don’t change.

1 Like

OnRun is a reserved function name within VC, it should not be used in trigger events, you can try your own function name.

Hi,

This is how OnRun functions:

It is triggered once at the start of the simulation and it does not require parameters.

So if you want your script to continuously check for the if statement you could put it inside a while loop:
image

Oh! Okay, I understand! Thank you so much at both of you for helping me ! It’s really appreciated :blush: