question

adak-romero avatar image
0 Likes"
adak-romero asked Joerg Vogel edited

Automating Model Creation and Buffer Transfer via Script

script-flexsim.jpgI need help writing a code that automatically generates a model from a script. So far, I’ve managed to create and position the elements, but now I need to configure a process where, through the code, the worker takes the pieces and transfers them to the buffer.

What can I do to achieve this through the code?




Object F1= createinstance(library().find("?Source"), model());

F1.setLocation(0,0,0);

F1.name="F1";


Object M1 = createinstance(library().find("?Processor"), model());

M1.setLocation(0,10,0);

M1.name="Daria";


Object M2 = createinstance(library().find("?Queue"), model());

M2.setLocation(0,20,0);

M2.name="Buffer";


Object S1 = Object.create("Sink");

S1.setLocation(0,30,0);

S1.name="Salida";


objectconnect(Model.find("F1"),Model.find("Daria"));

objectconnect(Model.find("Daria"),Model.find("Buffer"));

objectconnect(Model.find("Buffer"),Model.find("Salida"));


Object T1= createinstance(library().find("?Operator"), model());

T1.setLocation(5,15,0);

T1.name="Trabajador";

FlexSim 23.2.0
using code
script-flexsim.jpg (138.2 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.

Joerg Vogel avatar image Joerg Vogel commented ·

@Adak_Romero,so far you cannot generate a process flow logic chart by code. You can add 3D flow connections into a model. It is possible by command contextdragconnection. There are some restrictions if you connect module objects like conveyors.

Code based logic is a totally different aspect. Internally you put string data into a node and make this node later to a script node. Alternatively you can manipulate a stored model in XML format.
There is always a really large “BUT“. At some point you need to reset your model. And there is not a single command to achieve this internally from inside a running model AND get your model run again.

0 Likes 0 ·

0 Answers