How to get Model Input to use for Create Item ?

How to get Model Input to use for Create Item ?

anutt_k
Not applicable
338 Views
6 Replies
Message 1 of 7

How to get Model Input to use for Create Item ?

anutt_k
Not applicable

[ FlexSim 22.1.3 ]

1657529550882.png

Hello, I want to use text to condition for Create Item in 3D.
How can i use "Edit" in dashboards library when it like a text box for get text input and use for Trig 2D Process Flow to do Create Item in 3D. Or can I use other solution.

Example :

text input : B11 to create Box.

text input : P22 to create Pallet.

So,or you have some other solution. You can sharing with here. Thank You Very Much

0 Likes
Accepted solutions (1)
339 Views
6 Replies
Replies (6)
Message 2 of 7

moehlmann_fe
Advocate
Advocate
Accepted solution

You could create an item directly in the 'On Apply' code of the edit field, so it would probably be more convenient to add a button to the dashboard that does this.

First, link the edit field to a node in the model. In the attached model I used a label on Queue1 for this. Now other parts of the model can access the value in the field through that node.

I linked the button to the queue (for an easy reference to the label and because I want to create the item in the queue). In its 'OnPress' code I then create an instance of an object in the FlowItem Bin with the same name as the text in the edit field.

treenode link = node("..>objectfocus+", c);

// Read the label on the queue
string itemName = link.Create;
// Create item in model
Object item = createinstance(Model.find("Tools/FlowItemBin/" + itemName + "/1"), model());
// Move item into queue
moveobject(item, link);

If you dont want to use the name (or rank) of the flowitem directly, you can of course write if-conditions such as the following, to determine the correct item type.

treenode link = node("..>objectfocus+", c);

string itemName = "";
string itemCode = link.Create;
if(itemCode == "B11") {
    itemName = "Box";
}
if(itemCode == "P22") {
    itemName = "Pallet";
}

if(itemName != "") {
    Object item = createinstance(Model.find("Tools/FlowItemBin/" + itemName + "/1"), model());
    moveobject(item, link);
}

CreateItem_Dashboard_fm.fsm

0 Likes
Message 3 of 7

anutt_k
Not applicable

Thank You. It work well.

1657596750693.png

I will get your guid to make input for Model.

0 Likes
Message 4 of 7

anutt_k
Not applicable

And I have one question.

1657597089710.png

What should I do ?

If I want to clear text in edit field when I click the button "Create in Queue".

What command code do I have to write in 'OnApply' of edit field or write in 'OnProcess' of Create in Queue button ?







0 Likes
Message 5 of 7

moehlmann_fe
Advocate
Advocate

Since the label is linked to the edit field, you only have to reset it to an empty string after creating the item in the 'OnPress' of the button.

link.Create = "";
0 Likes
Message 6 of 7

anutt_k
Not applicable

OK. Thank You so much. It work.

And now I wonder. Will it be possible ?

If when edit field have a text (OnApply) it will create Item and text in edit field are clearing (Auto Create).

Such as edit field get a text and I will coding to " delay(300); " then Item will arrive and passing 0.3 sec edit field will clear text inside.

0 Likes
Message 7 of 7

jason_lightfoot_adsk
Autodesk
Autodesk

You can try using coroutines to await a delay, or send a message after the delay, or invoke a process that has a delay or create an event. That 0.3 seconds will be simulated time - not real time. Why do you need it to clear after a delay?

0 Likes