question

Sean Webster avatar image
0 Likes"
Sean Webster asked Jason Lightfoot commented

Any way to speed up script loading?

I wrote a program which uses data from an AutoCAD drawing of a conveyor system and generates an equivalent FlexSim model. It creates a script which I have been pasting into flexsim. As I've tested it on larger systems, the FlexSim script editor has become a bit of a problem due to how long it takes to load. On my computer, an ~15,000 line script takes around 10 mins to paste into the editor and during this time, FlexSim is unresponsive and gives no indication of progress on loading the script. Once the script is actually loaded, it runs great and only takes a few seconds to execute. When pasting the same script into a code editor like Visual Studio, it loads in around 1 second.

Is there anyway that I can turn off the text processing in the script editor and just get it to execute the script without the text editor processing? Or is there a way to load the script from a text document directly and execute it that way?

FlexSim 21.1.2
flexsim 21.1.2script
· 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.

Ben Wilson avatar image Ben Wilson ♦♦ commented ·

@Sean Webster,

I bet there would be a lot of interest in your script among members of this community. If it is something you can share, you could post an article explaining how to use it, with the download attached. Pretty cool that you have that working!

0 Likes 0 ·
Sean Webster avatar image Sean Webster Ben Wilson ♦♦ commented ·

Thank you for your help Ben! Unfortunately, I cannot share the script.

0 Likes 0 ·
robert.nevin avatar image robert.nevin Sean Webster commented ·

Sean, could you give some indications on how you achieved your script?

0 Likes 0 ·

1 Answer

Ben Wilson avatar image
3 Likes"
Ben Wilson answered Jason Lightfoot commented

Hi @Sean Webster,

Try the executefsfile() command:

executefsfile (str filename, num direct)

Description

For developer use. Executes Flexscript code in a file. The specified file is loaded and its content is executed. The contents of the file are assumed to be valid Flexscript code. If direct is 0, then FlexSim's program directory will be concatenated onto the front of filename, otherwise filename will remain as it is.

Example

executefsfile("c:/myscript.fs",1)


· 2
5 |100000

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

Tomi Kosunen avatar image Tomi Kosunen commented ·

Hi

executefsfile is new command for me and interests me. Is there any issues that I should be aware of? Does this have any affect to the simulation speed compering to the normal way to writing and executing code? If I'd have a model with lot of events, would it be slower to run if the code is in a file compering to have the code in a model node?


0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Tomi Kosunen commented ·

Yes it will be slower - the code on a node is in memory while executefsfile has to find and load it and check its syntax.

1 Like 1 ·