question

Jimmy avatar image
0 Likes"
Jimmy asked Logan Gold commented

Save model by FlexScript

Hi

I use Flexsim to verify my algorithm, but after several iterations, the program sometimes shuts down due to insufficient memory. I want the model to be automatically saved during the iteration process, this allows me to keep the latest results when crashingand ,and not to pop up a window asking me to click OK. What should I do?


I've trued this https://answers.flexsim.com/questions/166210/save-the-model-using-code-given-a-path.html

It looks like the save was successful, but this error message pops up.

1728359611583.png

Thanks.

FlexSim 23.2.0
flexsim scriptautosave
1728359611583.png (17.4 KiB)
· 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.

Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·

Hi @Jimmy,

Thank you for contributing to our community! We couldn't identify a maintained license or subscription linked to your account.

You may need to update your profile information to identify yourself as a license owner or their associate. Check out our article for how to ensure you receive timely support. If you update your profile comment back to let us know - we'll adjust the priority of your post accordingly.

If your current license is expired, please contact your local distributor to renew.

0 Likes 0 ·

Hi @Jimmy, was my answer helpful? If so, please click the "Accept" button at the bottom of the 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 comment back to reopen your question.

0 Likes 0 ·

1 Answer

Logan Gold avatar image
0 Likes"
Logan Gold answered

Hey @Jimmy, I think the issue is the save path doesn't have everything it needs. If you use the modeldir() function in conjunction with the text you are using, it will save the model in the same directory where it is currently saved:

modeldir() + "mySavePath.fsm"

Putting it all together:

applicationcommand("executescripts",node("MAIN:/project/events/OnSaveModelAutoIncrement"),modeldir() + "mySavePath.fsm",0);

If there is already a file with the mySavePath.fsm name, it will overwrite the file. Or if there isn't a file by that name yet, a new save file will be created.

It seems like if you want to mimic the behavior of the auto increment save feature, you'll need to keep track of which iteration you're on, increment the number yourself, and adjust the "mySavePath.fsm" text accordingly.

5 |100000

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