question

Ana Ta avatar image
1 Like"
Ana Ta asked Sebastian Hemmann edited

How to add permanently a script to the flexsim?

Hello friend,

I have wrote a script in flexsim, but I would like to have this script in flexsim whenever I open the flexsim on my PC? Could you please help me how I can do it?

Just to be more clear, I have wrote a script "check" in the flexsim model "test.fsm". I can see the script only if I open the file test.fsm. Buy creating a new flexsim model, I cannot see the script any more.

Thanks for your support,

FlexSim 17.1.4
script
5 |100000

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

Sebastian Hemmann avatar image
2 Likes"
Sebastian Hemmann answered Sebastian Hemmann edited

In the Toolbox you find in "Modelling Logic" the user Command.

modelling-logic.png

Here you can add your own FlexScript commands. After this, the button (showed in this Picture)

usercommand.png

allowes you to add this command to a user library.

Now you will find a UserLibrary in your Library in the left side and you can save it after clicking the Little triangle:

userlibrary.png

Under File you will find the Option to "Open User Libraries..."


modelling-logic.png (32.2 KiB)
usercommand.png (22.6 KiB)
userlibrary.png (31.4 KiB)
5 |100000

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

martin.j avatar image
1 Like"
martin.j answered Ana Ta commented

In the top left hand corner of the scripting window there are 4 small icons, and the two first from the left deal with saving and loading scripts. If you write a useful script that you feel you may need often you can click the small menu arrow next to the save icon ( the second icon from the left) and you will be given the option to name your script and save it as either a s user script or a model script.

If saved as a user script it will be available whenever you use the current flexsim installation, and if saved as a model script it will only be available in the current model. I use the latter option often when dealing with scripts for debugging and testing my models. To load a script simply open a new scripting window and click the first icon i the top left corner. Now you can select your script from a list to load.

A far more advanced option could be to use the model SDK to create a module that adds your own special commands to the Flexsim environment. But in most cases this would be complete overkill.


savescript.jpg (24.5 KiB)
loadscript.jpg (18.6 KiB)
· 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.

Ana Ta avatar image Ana Ta commented ·

@martin.jensen,

Thanks for your detailed explanation.

I did what you mentioned above and works perfectly. But I would like to be able to run the script as a function. For example, I would like by writing SelectAllRacks(), the script will be run.

Now, when I choose the script that I want to run, I can see all the code but I would like to run the script in more proper way which is calling it as a function in a blanck script.

Is there any possibility to do that?

Thanks

0 Likes 0 ·
Sebastian Hemmann avatar image
0 Likes"
Sebastian Hemmann answered Ana Ta commented

If it is an usercommand you can add it to an userlibrary as autoinstall and you also can set, what userlibrarys have to be opened by Default in your Settings.

Does this help?

· 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.

Ana Ta avatar image Ana Ta commented ·

@sebastian.hemmann
Thanks a lot for your prompte answer. I am so new in using flexsim. I have started about 3 weeks ago to learn it by myself. So, I cannot understand where I can find what you wrote me. I opened a script from the tool bar and started to write inside it. How can I figure out which userlibrarys, I am using?

Thanks.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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