question

Gesa R avatar image
0 Likes"
Gesa R asked Joerg Vogel edited

Interlaced structure of items

Hi,

I am struggeling with an interlaced structure of items.

The case: I have items (material=boxes no1 in flowitembin --> Basic FlowItem), which are packed on a Container FlowItem. Sometimes this container is packed on another container and on another container... it varys how deep the stucture is.

In the end I want to count all material items, not the Container and push them to a list.

I started my model with just one container to represent all container in one.

EventSource: OnEntering Queue (the container object enters)

Delay:Breathe

CreateTokens: token.object.subnodes.length

Push the created Tokens to a list

How can I implement the interlaced structure when I don't know how deep it is, or when I want to know if there is any material left in the container structure? All my material items are boxes. The container FlowitemBin rank varies.

Thank you for helping.

FlexSim 18.0.3
process flowflowitemcontainertree structure
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Joerg Vogel edited

The command "forobjecttreeunder(node container)" is suitable to get a reference to all objects to find recursively in the tree. You use the reference to identify if it is a container or an item. If you use the items of the class Tote or Pallet as the container you can look for the attribute "eventfunctions". The standard flowitems don't have such an attribute. I set one container item to the reference selected object by the context menu. The reference is "so()".

Array cont = [so()]; // Array to store content of item, here the container
Array itm =Array(0); // Array to store just the items 
forobjecttreeunder(so()) // find items under the container (item entering the combiner through port 1)
{   Object testObj = a; // a is the reference of the object looked for in the tree      
	if(testObj.attrs.eventfunctions.subnodes.length) // get all objects having an OnReceive function - e.g. Tote or Pallet          
	cont.push(a); // add to the array the container items
	else itm.push(a); // add items to the item array
}
print(cont," number of containers: ", cont.length);
print(itm,"number of items: ",itm.length);

The attached model contains the coude in the OnExit Trigger of the combiner. The reference item is chosen instead of so().


5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.