question

Raja G avatar image
0 Likes"
Raja G asked Jason Lightfoot commented

Learn coding

How to start learn coding in flexsim.

I want to learn from basic so please give me the idea what will I do and how to learn

create a basic coding structure and please send me.

FlexSim 22.2.2
coding
5 |100000

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

1 Answer

·
Felix Möhlmann avatar image
3 Likes"
Felix Möhlmann answered Jason Lightfoot commented

Since the programming language FlexSim uses is based on C++ you could start by looking up the very basics of how that works (how to declare variables, basic math operations, if-statements, for- and while-loops). Tutorials for C++ are available on the web in just about any language.

A lot of the mentioned points, in addition to FlexSim specific variable types and commands, is also covered on this and the following pages.

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

Raja G avatar image Raja G commented ·

how to use in flexsim

please create a basic model with programming then I understand easily

-1 Like -1 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Raja G commented ·
Also - you can test out small snippets of code or expressions in the script window - where it will also tell you a return value, and if you have the incorrect syntax.
1 Like 1 ·
Felix Möhlmann avatar image Felix Möhlmann Raja G commented ·

In FlexSim you will write code mostly either in trigger functions or various option fields.

For almost all of those, you can open the code editor window with a button or option that looks like a scroll.

1668757514384.png

In that window you can enter your code. Most of the time you will have access to pre-defined variables that depend on which option/trigger you are editing. These will automatically appear at the top when opening the code editor.

For example, for the process time option you have references to the processor/combiner/separator and the processed item available.

1668757611353.png

Such option fields expect that the code will return some value that is then used as the value for the respective option.

1668757736526.png

This code would set the process time to 8s for items of type 3 or 6 and 12 for all other types.


Triggers generally do not need a return value. They are mostly used to set labels or manipulate objects in the model directly.

The example below (On Process Finish Trigger of a ombiner) changes the color of all boxes there were placed on the pallet according to the "Type" label on the pallet.

1668757958586.png

CodingExample.fsm

0 Likes 0 ·
1668757514384.png (5.6 KiB)
1668757611353.png (6.5 KiB)
1668757736526.png (12.2 KiB)
1668757958586.png (14.1 KiB)
codingexample.fsm (27.3 KiB)

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.