How to access bundle values

How to access bundle values

jason_botha
Not applicable
35 Views
3 Replies
Message 1 of 4

How to access bundle values

jason_botha
Not applicable

[ FlexSim 16.0.1 ]

Hi there.

Is there a function that will allow me to access the values stored in an array on a node? (See the picture below)

287-tree-screen-shot.png

I want to write a piece of code that will allow me to extract values from nodes similar to the picture above.

Any help would be greatly appreciated.

Accepted solutions (1)
36 Views
3 Replies
Replies (3)
Message 2 of 4

regan_blackett
Autodesk
Autodesk
Accepted solution

You are looking for the getbundlevalue(node, entry, field) function. Bundle nodes are characterized as having 'Entries' (rows) and 'Fields' (columns) of data and a zero based index of both. The zero based aspect can be a little confusing because the first row of data in the bundle is actually row 0.

So to use getbundlevalue(), you need a reference to the bundle node (like pictured above) for the first parameter, the entry number for the second parameter and the field name OR number for the third. For example if I had the following code:

treenode bundle = node("Tools/Experimenter/DashBoardData/Content vs Time/Scenario1/1/timedata", model());

double value = getbundlevalue(bundle, 5, 1);

My variable 'value' would get the number 17 because entry 5, field 1 is 17. Take note that the entry number is the number listed to the left of the square brackets [].

Message 3 of 4

Matthew_Gillespie
Autodesk
Autodesk

There are a bunch of bundle commands that you'll find useful in Help > Commands in the Statistics section.

288-statistics.png



Matthew Gillespie
FlexSim Software Developer

Message 4 of 4

anthony_johnsonT83CM
Autodesk
Autodesk

I would suggest actually using the standard table commands: gettablenum(), settablenum(), gettablerows(), etc. They work on bundle data and avoid the 0-based inconsistency of using the bundle commands. And while the tree shows the 0-based rows (we might change that), exploring the node as a table shows the 1-based rows. There may not be full parity between the two (which we hope to resolve as those issues come up), but if you're just reading from a table, you should be able to use the straight table commands.