How to accomplish the following (rather common) behaviour on the production line using python script?
Example
Two part classes:
1. Rack (container part) - with capacity of 20 parts. Predefined positions for the parts.
2. Cell
Elements:
- Component creators for rack and simple-parts.
- Three conveyours (rack in, cell in, rack out)
- Table
Material flow:
Racks and cells are transfered along separate conveyors to the table.
After the rack is placed on the table we'll wait for the cells to arrive.
Every time cell arrives, we place it in the rack (with 20sec work time) and this continues until the rack capacity is full.
After rack is filled it will be moved out along the final conveyour - and we'll let in the next rack.
---
Even though this is probably quite simple thing to do I can't figure out how to place cells into certain positions of the container part with python.
Grab command grabs the cell to the rack but doesn't allow the exact placement. Rack has predefined position for cells (using single coordinate with offsets would work just fine) and I we'll need to put the parts into those.
FillContainer sounds like a working solution except there is no possibility to add single part to the container - only available command is "Fill" which is not suitable here.
Here is the script that works just fine except for the container part positions>>
from vcScript import *
def OnRun():
comp = getComponent()
rackpath = comp.findBehaviour("path_RACK")
cellpath = comp.findBehaviour("path_CELL")
racksignal = comp.findBehaviour("signal_RACK")
cellsignal = comp.findBehaviour("signal_CELL")
while True:
cellpath.Enabled = False
#waiting for a rack to arrive
triggerCondition(lambda: getTrigger() == racksignal)
rack = racksignal.Value
#rack has arrived - only one rack at the time on the table so disable the rackpath.
rackpath.Enabled = False
if (rack <> None):
#finding out the container part behaviour from the rack and stopping the rack
cpart = rack.findBehaviour("ComponentContainer")
rack.stopMovement()
print "start loading the rack [" + rack.Name + "] Capacity [" + str(cpart.Capacity) + "]"
else:
print"error - rack == none!" #just in case of faulty signal
continue
while (cpart.ComponentCount <= cpart.Capacity):
print "[" + str(cpart.ComponentCount) + "/" + str(cpart.Capacity) +"] waiting for next part"
cellpath.Enabled = True
triggerCondition(lambda: getTrigger() == cellsignal)
cellpath.Enabled = False
cell = cellsignal.Value
cpart.grab(cell)
print "cell grabbed"
print "rack full"
rack.startMovement()
cellpath.Enabled = True
rackpath.Enabled = True
---------
So the question is: how do I place parts into another container to predefined positions using python?