Pull From Array Based on 3D Object Label

Pull From Array Based on 3D Object Label

bcolmeryBF42R
Participant Participant
35 Views
2 Replies
Message 1 of 3

Pull From Array Based on 3D Object Label

bcolmeryBF42R
Participant
Participant

[ FlexSim 24.0.2 ]

I have 4 carts on an AGV. Two of the carts have VinylLine label value "L2" and two of the carts have a label value "L3".

1723738813884.png1723738837715.png


In my process flow, the carts are represented in the "pulledIGUCart" array below.

1723738959851.png


I want to unload the 2 carts labeled "L3" into a queue. How do I remove them from the array based on 3D object label values?

0 Likes
Accepted solutions (1)
36 Views
2 Replies
Replies (2)
Message 2 of 3

moehlmann_fe
Explorer
Explorer
Accepted solution

If the goal is to actually remove the entries from the array, then you have to loop through all entries, splicing out the items with the "correct" label value. See example code below.

string matchValue = "L2";
Array itemsToMove = []; Array loadedItems = token.totalIGUCart; for(int i = 1; i <= loadedItems.length; i++) {     if(loadedItems.VinylLine == matchValue)     {         itemsToMove.push(loadedItems);         loadedItems.splice(i, 1);         i--;     } }

If it's Ok for the entries to stay in the array (label is not used label) you can push all items to a list and pull only the ones with the target label value (query: WHERE VinylLine == 'L2')

0 Likes
Message 3 of 3

bcolmeryBF42R
Participant
Participant
I'm good with entries remaining in the array, so I used the WHERE query and it worked. Thanks!
0 Likes