question

Daniel R13 avatar image
0 Likes"
Daniel R13 asked Jason Lightfoot commented

Storing Location X and Y

Hi FlexSim Team!

I am currently trying to store a bunch of X and Y coordinate locations, using FlexScript, then trying to get the average location between them all. I have looked at into using a Statistics Collector, Tracked Variables, and a normal table and am not sure how to add more rows to either based on the documentation. I am probably just not using ctrl-f well enough but not sure where else to go. Thanks!

-Dan

FlexSim 21.1.2
flexscriptstatistics collectorflexsim 21.1.2tracked variablestable
· 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.

Eric M avatar image Eric M commented ·

Hi @Daniel R13, was Jason Lightfoot's answer helpful? If so, please click the red "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered Jason Lightfoot commented

Can't you just keep a running total of X and Y and then just divide both by the number of observations to get your average? Or use Vec2 if you want a single operation on both axes.

· 7
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 Jason Lightfoot ♦♦ commented ·

Example script:

Vec2 totallocs;
for (int n=1000;n>0;n--)
    totallocs+=Vec2(uniform(-1000,1000),uniform(-1000,1000));
return totallocs/1000;
0 Likes 0 ·
Daniel R13 avatar image Daniel R13 commented ·

I believe I could keep a running total but I would want to understand how to utilize one of those FlexScript components stated above. This is also in order for me to get a better understanding of how to manage the data from a programmatic perspective in FlexSim.

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Daniel R13 commented ·

I don't understand what you're now asking.

0 Likes 0 ·
Daniel R13 avatar image Daniel R13 Jason Lightfoot ♦♦ commented ·

Sorry for the confusion Jason.

My current goal is to attempt to get a better understanding of the FlexScript commands from here. The storing of X and Y locations was an attempt at trying to store some data from certain objects, in FlexScript, and saving the information in one of FlexSim's toolbox components. The ones I am interested in are the Statistics Collector, Tracked Variables, and a normal table. However by reviewing all of the FlexScript documentation it is a bit unclear on how to store the values in these components. This is in order to do some calculations at different points of the model.

Let me know if anything is unclear and thanks for your patience.

0 Likes 0 ·
Show more comments