question

Borja Lorenzo avatar image
0 Likes"
Borja Lorenzo asked Borja Lorenzo commented

Define an array by composing the name of an object

Hello

I can't share my files for privacity reason.

I hoppe you could help me.

I would like to set my Process Flow replicable to change a few labels at the begging of the Process and so to use de same activities and custom codes.

But, I have a problem to define a array which depend on an Object, composing its name

I attach same image to explaing it better.


I want compose the array Puestos1 without use a especificic references to the machine LR00

If I define the variable Array Puestos1 like:


1719216065246.png

Puestos1[n]=Model.find("PuestoLR00_"+ Ref[n]);

That it works well.

Return the correct array PuestosRef1 Array[2]: {/PuestoLR00_1,/PuestoLR00_2}

So I think the Array Ref is rigth defined.


In other hand, If I define the variable Array Puestos1 like:1719215406113.png

Puestos1[n]=Model.find("Puesto'"+Linea+"'_"+ Ref[n]);

The array shows "no Path".

What am I doing wrong?


Thanks for your comments.

FlexSim 24.1.0
arrayobjectcompose
1719215406113.png (249.3 KiB)
1719216065246.png (239.7 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.

Felix Möhlmann avatar image
2 Likes"
Felix Möhlmann answered Borja Lorenzo commented

Try removing the single quotation marks in line 25 (after "Puesto" and ahead of the underscore). I don't see those as a part of the object name so they are likely to blame for not finding the object.

In general I would advise to not use "Model.find()" too much. If you place the objects into a container later, for example, that would have to be accounted for in the path. I would suggest to use groups to organize objects instead. The model parameters can define the name of the group and which objects (indexes in the group) to use.

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

Borja Lorenzo avatar image
0 Likes"
Borja Lorenzo answered Felix Möhlmann commented

Hello Felix, tank you for your answer.

Correct,

Ref=SizeRef1 is redundant.

However, I intended to write the expression Puestos1[n] directly, without any previously declared variable (SizeRef1 or Ref), as follows:

Puestos1[n]=Model.find("Puesto"+Linea+"_"+Model.parameters[Linea+"_Puestos_Ref1"].value);

This does not work.


Is that possible?


Thanks in advance

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