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 Borja Lorenzo commented ·

Hellos @Felix Möhlmann

I have another question related with this topic. I know if I shoul post a new question o following in this discution. Please let me know about that.
The point is:

I have componse an array "Puestos1" that reference several objects.

The name of this object is PuestoLR02_1, up to PuestoLR02_7

So I declare Puestos1 as:

Puestos1[n]=Model.find("PuestoLR02_"+ Model.parameters.LR02_Puestos_Ref1[n]);

The number after of the underscore comes from a parameters table:

1719392156843.png


I have to declare a new variable array "Ref", from which get only the value to compose the whole name

1719392130333.png


Is there other solution to compose this without to declare the variable "Ref"?


Thanks for your comments

0 Likes 0 ·
1719392130333.png (43.9 KiB)
1719392156843.png (45.4 KiB)
Felix Möhlmann avatar image Felix Möhlmann Borja Lorenzo commented ·
You don't need the "Ref" variable. You could paste the expression that defines it directly into the Model.find() function. Or you use the "SizeRef1" array from further up which holds the same values.
0 Likes 0 ·
Borja Lorenzo avatar image Borja Lorenzo Felix Möhlmann commented ·
Nice!!!, it works perfectly.

Thanks Felix.


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

Felix Möhlmann avatar image Felix Möhlmann commented ·

Presumable the model parameter contains an array, so you still need to specify the index.

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

1 Like 1 ·