How to Add Storage System Slot Labels Via Code

How to Add Storage System Slot Labels Via Code

stan.e.davis
Advocate Advocate
53 Views
7 Replies
Message 1 of 8

How to Add Storage System Slot Labels Via Code

stan.e.davis
Advocate
Advocate

[ FlexSim 23.0.2 ]

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.


// CLEAR EXISTING SLOT LABELS
treenode myslotlabels = Model.find("Tools/StorageSystem>variables/slotLabels"); 
myslotlabels.subnodes.clear(); 
 
 
// REBUILD SLOT LABELS
treenode myStorageSystem = Storage.system;
int labelsneeded = 100;
treenode myslotlabel;
 
for(int k=1;k<=labelsneededk++){
    
 myslotlabel = function_s(myStorageSystem"addSlotLabel"); 
 myslotlabel.name = concat("PartNo", string.fromNum(k)); 
 myslotlabel.subnodes["colorPalette"].value = Model.find("Tools/ColorPalettes/PartNoColors");
 myslotlabel.subnodes["indexType"].value = 1
}


Thanks

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

joerg_vogel_HsH
Mentor
Mentor
0 Likes
Message 3 of 8

stan.e.davis
Advocate
Advocate
Yes, I've reviewed that post many times and use similar elsewhere. This is a little different. Here, I'm setting the subnodes as well.
0 Likes
Message 4 of 8

stan.e.davis
Advocate
Advocate

Note to FlexSim Support. I tried to submit this question twice after inserting the code from the editor. Both times it was blocked. The blocked message stated to contact site owner with Cloudflare Ray ID. I did that via email (support@flexsim.com) but received non-monitored failed email response. Tried to call FlexSim in Utah a few times but only received 'leave a message' message. How do we notify FlexSim of issues like this???


0 Likes
Message 5 of 8

kavika_faleumu
Autodesk
Autodesk
Hey @Stan Davis, we received your call, but when we tried to call you back from our office line and cell phones, we got an automated voice saying we couldn't get through.

As for your code being blocked before, submitted code should be in a code block. This will avoid being blocked by the internal security system. If that still doesn't work, you can always post a screenshot.

0 Likes
Message 6 of 8

stan.e.davis
Advocate
Advocate
Kavika, Thanks - Stan
0 Likes
Message 7 of 8

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

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.

0 Likes
Message 8 of 8

stan.e.davis
Advocate
Advocate
Appreciate the feedback! Understood - Stan
0 Likes