Clear flowitems using code

Clear flowitems using code

VikSin
Not applicable
1,161 Views
7 Replies
Message 1 of 8

Clear flowitems using code

VikSin
Not applicable

[ FlexSim 23.2.0 ]

Hello, i have model that consists of different rack objects (Warehouse model) and i am creating user command for deleting all flowitems in the warehouse.
I don't want to use model reset, because on model reset there are some triggers which i don't want to run.

Is there some FlexSim command or way how to achieve it ?

Thank you in advance 🙂

0 Likes
Accepted solutions (1)
1,162 Views
7 Replies
Replies (7)
Message 2 of 8

joerg_vogel_HsH
Mentor
Mentor
Accepted solution

treenode.subnodes.clear() - a method to destroy subnodes of a container node. Unfortunately you have to call it on every involved rack object. Perhaps you do it with forobjecttreeunder - a command.

Message 3 of 8

VikSin
Not applicable

Thank you Joerg. I was thinking about this solution but also searched for some more universal way. This way I can delete for example all subnodes of the plane object (so all processors, racks etc that are under racks), am I wrong ? (one of the solution would be to put all racks that I want to clear under one group and clear just this group via subnodes.clear()).

However I was thinking if there is some internal command etc ? Because in model reset all flowitems objects are destroyed, so this could be somehow achieved or replicated

0 Likes
Message 4 of 8

jason_lightfoot_adsk
Autodesk
Autodesk
If you are wanting to reset the model like this, it sounds more like you are running a different scenario. Have you considered running scenarios via the experimenter?
0 Likes
Message 5 of 8

VikSin
Not applicable

I am using Flexsim for visualization purpose. On reset model, the data for vizualization are loaded from database. Then I am switching between different views in the model. Each view is made of different flowitems in different slots, so that's why i need to clear warehouse between jumping from one view to another.

Message 6 of 8

FelixMoehlmann
Mentor
Mentor

The code below finds all items that are currently assigned to a slot in a storage object and deletes them.

Array slotItems = Storage.system.queryItems("");
for(int i = 1; i <= slotItems.length; i++) {     Object item = slotItems.as(Storage.Slot.Item).item;     moveobject(item, model());     item.destroy(); }
Message 7 of 8

Jeanette_Fullmer
Community Manager
Community Manager

Hi @VikSin, was Joerg Vogel's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

Message 8 of 8

VikSin
Not applicable
That's perfect, thank you :)


0 Likes