question

gust-flex avatar image
0 Likes"
gust-flex asked Felix Möhlmann answered

Stacking items next to each other in stead of on top of each other on a table

Hello, in the Question linked below @Felix Möhlmann wrote a code to store items on a table. I now want to change the code so if 2 items (or more) are unloaded on that table they are unloaded next to each other in stead of on top of each other. How can I do that?

https://answers.flexsim.com/questions/161678/packaging-on-narrow-table-with-proces-flow.html

FlexSim 23.1.2
tablesunloadingstacking
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

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered

I'd encourage you to look up the documentation on the setLocation() and also the getLocation() methods.

The code I provided in the post you linked consists of just two lines.

int itemRank = current.subnodes.length;
item.setLocation(current.size.x/2, -current.size.y/2, current.size.z + itemRank*item.size.z, 0.5, 0.5, 1);

The first line simply determines how many items are present in the object (table) at the same, since the position of the item will depend on that. Since the item is 'inside' the table object, its coordinates will be relative to the table's local coordinate system.

Basically, the first three parameters represent the midpoint of the table's top face (half the x-size along the x-axis, half the y-size along the y-axis, the full z-size along the z-axis). Objects extend into the negative y-direction in their coordinate space, hence the minus sign in front of the second parameter. In the third parameter I then also add the z-size of the item times the amount of items currently in the table object. The resulting coordinate is where the midpoint of the top face of the uppermost item should be placed. As such I choose (0.5, 0.5, 1) as the factors in the last the three parameters.

If you want to place the items side by side, you would vary the x- and/or y-coordinate depending on the item rank.

It's probably best if you just experiment with the command on your own to get an understanding of how it works.

5 |100000

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