question

Flavio Lopes avatar image
0 Likes"
Flavio Lopes asked Felix Möhlmann commented

Operator doesn't adquire resource

After I use the function "Create Object" I use a "Custom Code" to add the new object to a "Group", so it can to be use later as a "Resource". However, when I attempt to "Acquire Resource," the simulation does not recognize the available Resources in the Group and stops.

When I add a object manually to the same Group the simulation is working, so i don't urderstand why is no working with the objects add by the "Custom Code"



Example1.fsm

FlexSim 25.0.4
custom coderesource
example1.fsm (2.8 MiB)
5 |100000

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

João Dias avatar image
0 Likes"
João Dias answered

Good morning Flávio.

Process Flow Resource activities are initialized once during model reset. Therefore, any changes made to a group during the simulation runtime—such as adding objects via Custom Code—won’t be recognized by the "Acquire Resource" activity, which explains the issue you’re seeing.

The best alternative in this case is to use a List activity instead of a Group. Lists allow you to dynamically add and access resources during the simulation, ensuring that newly created items are available when needed. You can check out the documentation for Lists here:

https://docs.flexsim.com/en/19.2/Reference/ProcessFlowObjects/SharedAssets/List/List.html#app

Another option would be to manually update an array with the group members before acquiring the resource, but this requires a bit more logic in Custom Code. Overall, using Lists is usually the simpler and more reliable solution.

5 |100000

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

Flavio Lopes avatar image
0 Likes"
Flavio Lopes answered Felix Möhlmann commented

I change the logic to my model work with "Lists", but now I'm facing a new problem.

I need Pull from list an item based on the label "PierNumber" write on the activity "Assign Label: Calculate Center Pier Number".

1743779189895.png

I tried some options using the "Query / Object / Array", but I couldn't make it work

1743779497868.png


Example.fsm



1743779189895.png (21.5 KiB)
1743779497868.png (10.6 KiB)
example.fsm (2.8 MiB)
· 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 ·

You can use the same query you had in the Acquire activity: "WHERE PierNumber == puller.PierNumber"

(PierNumber label on the pulled value must match the PierNumber label on the puller (token))

More information about SQL can be found in the documentation.

https://docs.flexsim.com/en/25.1/ConnectingFlows/Lists/IntroSQLQueries/IntroSQLQueries.html

https://docs.flexsim.com/en/25.1/Reference/DeveloperAdvancedUser/SQLQueries/SQLQueries.html

0 Likes 0 ·
Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered

The Process Flow Resource activities are initialized once during reset. Changes made to a group during the model run will not influence what can be acquired.

To manage flow items and other objects created during the model run use lists instead. (Personally I would even say always use lists. A Resource linked to a group is essentially just a list with fewer options)

5 |100000

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