question

Stan Davis avatar image
0 Likes"
Stan Davis asked Jason Lightfoot edited

How to Add Storage System Slot Labels Via Code

Having a large number of slot labels, I needed a way to quickly clear and re-add them to the Storage System. Here is what I developed. It works, but I am not sure it is the 'correct' way to do this. Any comments would be appreciated.


  1. // CLEAR EXISTING SLOT LABELS
  2. treenode myslotlabels = Model.find("Tools/StorageSystem>variables/slotLabels"); 
  3. myslotlabels.subnodes.clear(); 
  4.  
  5.  
  6. // REBUILD SLOT LABELS
  7. treenode myStorageSystem = Storage.system;
  8. int labelsneeded = 100;
  9. treenode myslotlabel;
  10.  
  11. for(int k=1;k<=labelsneeded; k++){
  12.  
  13.  myslotlabel = function_s(myStorageSystem, "addSlotLabel"); 
  14.  myslotlabel.name = concat("PartNo", string.fromNum(k)); 
  15.  myslotlabel.subnodes["colorPalette"].value = Model.find("Tools/ColorPalettes/PartNoColors");
  16.  myslotlabel.subnodes["indexType"].value = 1; 
  17. }


Thanks

FlexSim 23.0.2
slot labelsbest practices
· 3
5 |100000

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

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

There are no exposed methods for adding Storage System labels, so what you have is the only way currently. Just keep in mind that function_s calls are subject to change in future versions and then you'd have to manage any updates yourself. For that reason try to put function_s calls in one place so you don't need to go through and edit your model extensively - so consider creating your own user command to add a Storage System label where you pass in the name, default value and color palette for example. I expect you should also consider adding the "defaultValue" and "trackedVariableType" subnodes too to be consistent.

· 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.

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Stan Davis 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.