7. Use BCE Extensions to Control the ROBOT_CONV to MACHINE Process

About this task

Now that you have your blocks and carriers created 'automatically' by using BCE scripts, you can now move ahead to use a BCE script to control your process.

You will create a script that looks at the COLOR attribute for your block item and move it to the appropriate machine.

Say that

  • MACHINE0 is responsible for red and green blocks.
  • MACHINE1 is responsible for assembling blue blocks.
A Delete Two Buttons
B Create a Machine Button
C Configure a Script for the Machine Button
D Review the Script for the Machine Button
E Test the Machine Button Configuration
  1. Delete Two Buttons

Delete the two buttons that move the items from

  1. Create a Machine Button


  1. Place a single button in the center of the process
    • After the ROBOT_CONV region.
    • Between the two MACHINE regions.
  2. Open the button's Properties dialog box.
  3. Select Text Button in the Properties dialog box left-pane.
    1. Clear the Multiline checkbox.
    2. Enter Machine in the String field.
  4. Select a Button color.
    1. Configure a Script for the Machine Button
  5. Select Events in the Properties dialog box left-pane.
  6. Select a Mouse Up event.
  7. Create a new script.
    1. First create a new object that represents your region.


    Dim region As New prtregion

    1. Assign this region's id property to the ROBOT_CONV region.



    1. Get the item list for this region.



    1. Examine the COLOR attribute for the block item.

    Because two items can exist in each location. you have to make sure that you are looking at the correct item within the first location.

    Your item count is going to be twice as large as the number of locations that are currently filled.


    If there are 5 locations.

    There will be 10 items, beginning with 0

    • Items 0 and 1 in location 1
    • Items 2 and 3 in location 2
    • Items 4 and 5 in location 3
    • Items 6 and 7 in location 4
    • Items 8 and 9 in location 5.

    As the block and carrier can exist in one location and the order in which they exist is dependant on which item entered that location first, it is up to you to determine where your block item exists within a particular location.

    The structure below will determine if you are looking at the correct item.


    If 'the first item's item type id is 00' then    'set the index to the second item in location 1 Else    'set the index to the first item in location 1 Endif If the color attribute(index) is red or green, update the X_MACHINE0 transition point If the color attribute(index) is blue, update the X_MACHINE1 transition point

    1. Compile the script.
    2. Close the Edit Script window.
    3. Close the Properties - Object dialog box.
    1. Review the Script for the Machine Button

    Sub OnMouseUp(x As Long, y As Long, flags As Long) Dim region As New prtregion Region.Id="ROBOT_CONV" Region.GetItemList    If region.item(0).itemtypeid = "00" Then        j = 1    Else        j = 0    End If    If region.item(j).attr(1).value = "RED" Or region.item(j).attr(1).value="GREEN" Then       PointSet "X_MACHINE0",1    Else       PointSet "X_MACHINE1",1    End If End Sub

    1. Test the Machine Button Configuration

    Check that the count in the MACHINE regions on the CimView screen corresponds with the items in  PRT_UI.

    Note: Remember to make sure there are blocks and carriers in the ROBOT_CONV region before you start.

    CimView Screen

    Click the Machine button a few times.


Either the MACHINE0 region and the MACHINE1 region display 1 or more items, depending on what color block was selected.

If you continue to click the Machine button, you will see that the items are dispersed to MACHINE0 and MACHINE1, based on the block color.


Open the PRT_UI>MACHINE0 or MACHINE1 region (depending on which region the items move to).

A block and carrier should be listed in each location.