question

Muster M avatar image
0 Likes"
Muster M asked hermione12 commented

Create a flow item object by code

I want to create a flow item object with flexscript in my model, so a operator can pick it up from a set location. I found this code snippet, but it can't find the flow item class I guess...

Object item = createinstance(library().find("Box"),model());

I guess I need something else for "library()" ?

FlexSim 21.2.0
flexscriptflexsim 21.2.0create objectflow itemscreateinstance
· 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.

Ryan Clark avatar image Ryan Clark commented ·

Hi @muster.m, was Felix Möhlmann's answer helpful? If so, please click the red "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered hermione12 commented

To create a flowitem you should use

Object item = createcopy(Model.find("/Tools/FlowItemBin/<NameOfTheFlowItem>/1"), model());

Alternatively, you could use a message triggered source in process flow together with a "Create Objects" activity, to generate objects by sending a message to a specified object.

· 5
5 |100000

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

hermione12 avatar image hermione12 commented ·

hi @Felix Möhlmann , if I want to use this above command in a Queue. Where can I use it?

I want to generate an item in the specific queue without using source nor process flow but only code.

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann hermione12 commented ·
At what point in time should the item be created?

In general, you can use the command in any trigger of the queue. To create the item inside the queue, you would then replace the second parameter 'model()' with 'current'.

0 Likes 0 ·
hermione12 avatar image hermione12 Felix Möhlmann commented ·

Yes it is working now.

If I want to create multiple boxes on a Queue without using source. Is it possible using code?

0 Likes 0 ·
Show more comments