question

Gilles avatar image
0 Likes"
Gilles asked Joerg Vogel edited

model is freezing - using script to create conveyors system

Hello,

I am using a script to create my conveyor system. my script is very simple. in the beginning I create 48 conveyors. the first image below shows you how I create these conveyors. then I have few for loops where I create additional conveyors. the second image show an example of one of the for loop. I started having issue when I added a third for loop in the script. what happens is, when I run the script, it looks like the model is taking forever and nothing is happening. and I have to close the model to stop it. if I run the script in a debug mode with many debugging points, I won't have the issue and I will get the results that I expected.

1734061467270.png

1734061588178.png


FlexSim 23.2.1
conveyorsscriptissue
1734061467270.png (51.5 KiB)
1734061588178.png (195.8 KiB)
· 4
5 |100000

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

Hi @Gilles ,

It's hard to know how to help without looking at your model. To receive a more accurate solution, please post your model or a sample model that demonstrates your question.

If your model contains sensitive information, you could first toggle your post as private using the "make private" option under your question's "gear" menu. Private questions are visible only to site moderators. You can also contact your local FlexSim distributor for phone or email help.

1 Like 1 ·
Joerg Vogel avatar image Joerg Vogel commented ·
@Gilles, it looks like a runtime problem. There are functions, that you are calling that needs to be completed before another step of code begins or same function is allowed to be called again. I would recursively call my code by messages again and use in my code a switch structure to return in a next block of code. Messages have an ability start a new execution of a processor cycle.
0 Likes 0 ·
Gilles avatar image Gilles Joerg Vogel commented ·

@Joerg Vogel , thank you!

I understand your solution but I can't figure out how to implement it in a script. I am using script (see image below) to write my code. so I don't see how to use message and switch in that script.

1734107121349.png

Could you send me an example of script which implements your solution?

0 Likes 0 ·
1734107121349.png (76.7 KiB)
Joerg Vogel avatar image Joerg Vogel Gilles commented ·

@Gilles please print to an output console c.

print(c);

if it is path to your script then try if you can call your script recursively. But be aware of an indefinite loop you may create.

@Gilles additional solution: Please put your script into an object trigger like on Message and On Reset Event and test it if you can get it to work by recursive calls in switch to case structure. This would tell you that my suspicion would be right. Then developers can suggest methods to get a similar approach for a loadable script code for a script window.

0 Likes 0 ·

0 Answers