Read Product ID and timestamp

Hello,

Is there an easy a way to read the product ID and the simulation time when a product enters a process? I created a simple script triggered by a signal sent by a process node. But I’m having trouble reading the product id.

from vcScript import *


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

ws0Signal = comp.findBehaviour("WS0")

def OnRun():
  while True:

    triggerCondition(lambda : getTrigger() == ws0Signal and ws0Signal.Value == True) 
    print("Part entered {} at -> {}".format(comp.Parent.Name, sim.SimTime))

I did not like how this script turned out, because I wish I could trigger an event when a product enters a process node and another one when in leaves. I am a begginer in Python, so am I missing something?

Thanks in advance

You can do it directly in the Process, without writing a PythonScript:
→ if the ProductID is a Product propety, you can use the notation "ProductIn.ProductID", if it’s a Component property you can use the notation “ProductIn.Component.ProductID” (Process Statements)
→ you can use the Expression “SimTime()” to get the current simulation time

2 Likes