question

Abhay Bajpai avatar image
0 Likes"
Abhay Bajpai asked Felix Möhlmann commented

"So.Subnodes" does not list all subnodes of flowitem.


Hello!


Problem #1: For some reason my model's flow item's "so.subnodes" do not show up. Just the first item that was created shows up. What could be the reason behind this?

1695331152189.png


Problem #2: Why does the flow item referred here as "product"? Does that create any issue?

1695331377506.png

ChampionHomes_V8_0.fsm


FlexSim 23.2.0
subnodes array
1695331152189.png (151.2 KiB)
1695331377506.png (149.2 KiB)
· 2
5 |100000

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

Abhay Bajpai avatar image Abhay Bajpai commented ·

Hey so I am sorry I did not explain my issue properly earlier.

At station 2 on the conveyor belt, it is supposed to produce two items (check the circled array) but it only produces 1 item. I believe every station where there are more than one items that need to be created at "Create Object" it only produces one of them I think.

1695419623287.png


@Jason Lightfoot any idea why this happens? Tagging you since you were a huge help for this model.

ChampionHomes_V8_0.fsm

0 Likes 0 ·
1695419623287.png (241.4 KiB)
Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @Abhay Bajpai, was one of Jeanette F's or Felix Möhlmann's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. 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 comment back to reopen your question.

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

The items on the conveyor are nested inside each other. You are only looking at the direct subnodes of the conveyor, which is only item called "Product".

capture.png

You could write a user command that recursively adds all levels of subnodes to an array. (In the example below, the start node (conveyor) is also part of the array at the first position)

treenode curNode = param(1);
Array allNodes = []; for(int i = 1; i <= curNode.subnodes.length; i++) {     allNodes = nestedSubnodesToArray(curNode.subnodes[i]).as(Array); } allNodes.unshift(curNode); return allNodes;

capture.png (2.9 KiB)
· 4
5 |100000

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

Abhay Bajpai avatar image Abhay Bajpai commented ·

Felix,


Should I write this command in the same user command? or a different one?


Also, are "nestedSubnodesToArray" and "unshift" commands found at Command Reference website of FlexSim? Because I could not find them there.

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Abhay Bajpai commented ·

"Unshift" is a method connected to the array class. It adds an element to the start of an array.

"nestedSubnodesToArray" is the name I chose for the user command. As I said, it works recursively, by calling itself, to find all subnodes under a given starting node.

Attached is an example model. Run the simulation to generate some items in the queue, then try the command in the script console.

nested-nodes-to-array-fm.fsm

1 Like 1 ·
Abhay Bajpai avatar image Abhay Bajpai Felix Möhlmann commented ·

So i played with it and it returns the array of all nodes like discussed. Here is what i want to understand since I am a newbie at this.

Q1. How does the script know that i am referring the nodes? Is it through the treenode param? What if i had multiple sources, in that case how will the script know which treenode am I referring to?

Q2. The for loop stops when it reaches to Box. Is it because the box does not have anymore subnode?

Q3. When i changed the quantity to 3 at Source, your script only runs for the 1st token and not for the other two tokens that are created later. Why is that?

0 Likes 0 ·
Show more comments
Jeanette F avatar image
0 Likes"
Jeanette F answered

Hello @Abhay Bajpai,

In the Parts array the second index contains a string that will be used to select the flow item that will be created. It is not able to because the string does not end up matching anything in the flow item bin because there is a 1 at the end of it

1695434048861.png



1695434048861.png (2.1 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.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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