question

Martin K5 avatar image
0 Likes"
Martin K5 asked Martin K5 commented

Paint slot labels by code?

Hi,

I would like to ask. Is it possible to paint objects (especially whole Rack) by code? I know how to make it manually by creating label in storage system and then enabling the function paint slot labels, then selecting the created Label and selecting the filter "paint all slots in same object" and changing the numbers to paint the racks. Is it possible to do it by code? I am building whole model by code and it would be perfect if I would be able to do this also by code? Is there anyone who knows?


Thank you.


Martin

FlexSim 21.1.4
coderackspaint slot labels
5 |100000

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

Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Martin K5 commented

If you want to paint slots individually then you just set the label of the slot. This code will set each slot to have a random Type label:

Storage.Object rack = Model.find("Rack1");
for (int i = 1; i <= rack.bays.length; i++) {
    Storage.Bay bay = rack.bays[i];
    for (int j = 1; j <= bay.levels.length; j++) {
        Storage.Level level = bay.levels[j];
        for (int k = 1; k <= level.slots.length; k++) {
            Storage.Slot slot = level.slots[k];
            slot.Type = duniform(1,5);
        }
    }
}

However, the Storage.Level, Storage.Bay, and Storage.Object classes all have a setSlotLabels method() if you want to set all the level, bay, or storage object's label values at once. For example, setting all the slots in a rack to have the same Type label:

Storage.Object rack = Model.find("Rack1");
rack.setSlotLabels("Type", 2);

Or setting all slots in the same bay to have the same Type label:

Storage.Object rack = Model.find("Rack1");
for (int i = 1; i <= rack.bays.length; i++) {
    Storage.Bay bay = rack.bays[i];
    bay.setSlotLabels("Type", i);
}
· 1
5 |100000

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

Martin K5 avatar image Martin K5 commented ·
Hi,

thank you a lot, this is exactly what I was looking for


0 Likes 0 ·
Krzysztof J avatar image
0 Likes"
Krzysztof J answered Martin K5 commented
· 1
5 |100000

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

Martin K5 avatar image Martin K5 commented ·
I tried this one, but it does not what I want. I meant that, if I would paint the whole rack manually, it is shown by the color and I would like to make the same by the code...
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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