question

Stan Davis avatar image
2 Likes"
Stan Davis asked Stan Davis commented

Storage Slot Label Painter Not Auto Updating After Label Node Removal

I am developing a method that clears any existing slot labels before repainting slot labels based on an external file using the function_s method.


Here is my code that removes the 'SegmentA' label's subnode under the slot's 'slotLables' and 'resetLabels' nodes.

    Storage.Object rack = Model.find("Rack_D40_A");
    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++) {

                 
treenode mytreeslot =  level.slots[k].as(treenode); 
               
               // This destroys the slotLabels subnodes
if (mytreeslot.find("slotLabels")) { 
      
      treenode myslotLabels = mytreeslot.find("slotLabels");
      
      if ( myslotLabels.find("SegmentA") ) {
      
      myslotLabels.find("SegmentA").destroy();
      
      }
              

}
else {   
//msg("hello","slotLabels do not exist");
}


               // This destroys the resetLabels subnodes
if (mytreeslot.find("resetLabels")) { 

      treenode myresetLabels = mytreeslot.find("resetLabels");
      
      if ( myresetLabels.find("SegmentA") ) {
      
      myresetLabels.find("SegmentA").destroy();
      
      }

}
else {   
//msg("hello","resetLabels do not exist");
}                

            }
        }
    }
    
 


The problem is that after I run the code and verify the labels have been removed from the Tree, the 'Paint Slot Labels' tool will still show the labels applied until I select a different slot label in the properties panel and then re-select the label that I had removed to see the change...


1661799542267.png


How do I get the 'Paint Slot Labels' tool to auto refresh and reflect the change to the Tree?? I realize this is rather minor, but I think I am just missing some reset/refresh command in my code. Thanks - Stan



FlexSim 22.2.1
slot labelspaint slot labels
1661799542267.png (112.1 KiB)
· 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.

Kavika F avatar image Kavika F ♦ commented ·

Hey @Stan Davis,

It's hard to know how to help without looking at your model. To receive a more accurate solution, please post your model or a sample model that demonstrates your question.

Proprietary models can be posted as a private question visible only to FlexSim U.S. support staff. You can also contact your local FlexSim distributor for phone or email help.

0 Likes 0 ·

1 Answer

Matthew Gillespie avatar image
1 Like"
Matthew Gillespie answered Stan Davis commented

You could call the paintLabels function_s in your script since that function marks the rack's meshes as dirty and then rebuilds them the next time the view paints. For example:

Storage.Object rack = Model.find("Rack_D40_A");
string labelName = "SegmentA";

//Call paintLabels so the rack's meshes are marked dirty for the next time the view paints
function_s(rack.getSlot(1, 1, 1).as(treenode), "paintLabel", labelName);

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++) {
                              
            treenode slotNode =  level.slots[k].as(treenode);            
            slotNode.find("slotLabels")?.find(labelName)?.destroy();
            slotNode.find("resetLabels")?.find(labelName)?.destroy();            
        }
    }
}
· 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.

Stan Davis avatar image Stan Davis commented ·
Thanks. That worked great! And thanks for the much more concise code. I forgot about using '?'. - Stan
0 Likes 0 ·