question

Omar Aguilera Rico avatar image
0 Likes"
Omar Aguilera Rico asked Braydn T commented

Collisions when creating resources using PF

In the picture 1.png you can see that line 47 and 49 are deactivated, and in the tree of each operator if you write the information, but as a string and I need you to write it as a node. So far the solution that I found was the one shown in photo 2.png where you can see that line 47 and 49 are already active, but in the tree of each operator you no longer write all the information in some only places me 0x0 . How can i fix this? Is there a command that converts you from string to node? What I'm trying to achieve is that when more operators are created in Process Flow they detect the members with which they can collide, but by default FlexSim does not add the members in the collision tab, so I made the code shown in the script to help me but I found the problem that I mentioned earlier. When running it like the photo 2 that is the correct one that must be a node the collisionobjects marks me an error.

Only the Operator1_3 if you post the collisions keeping the information on your label "Colisiones".

FlexSim 19.1.1
collision problemmembers
1.png (173.4 KiB)
2.png (175.3 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.

1 Answer

Logan Gold avatar image
1 Like"
Logan Gold answered Braydn T commented

@Omar Aguilera Rico

treenode.find() (or Object.find()) is what is mainly used to convert strings to nodes. You have to pass in the path to the node you want a reference to, relative to the treenode/Object.

For your model, you will probably want to use getvarnode() to get a reference to a variable node in an Object (like the Operator's collisionobjects node). The following example code will get the collisionobjects node of Operator1 in your model and store it in a variable:

Object operator1 = Model.find("Operator1");
treenode collisionObjects = getvarnode(operator1, "collisionobjects");

The other important thing to know is that all the subnodes of collisionobjects are coupling nodes (their datatype is DATATYPE_COUPLING). Each coupling node in the tree is a pointer node that is pointing to a different node in the tree. And the second node is pointing back to the first node. With coupling nodes, when one of the nodes is removed, the other node is also removed so you don't have leftover nodes with a 0x0 reference.

Here is example code that is similar to what FlexSim uses when you add a new Collision Member to a Task Executer in its Collision tab (with updated dot syntax):

treenode operator1 = Model.find("Operator1"); // Change this to reference the first Task Executer (TE)
treenode operator2 = Model.find("Operator1_2"); // Change this to reference the second TE
treenode op1CollisionObjects = getvarnode(operator1, "collisionobjects"); // Get collisionobjects node on first TE
treenode op1NewCollObj = op1CollisionObjects.subnodes.add(); // Add new collisionobjects subnode
op1NewCollObj.dataType = DATATYPE_COUPLING; // Set new subnode's datatype to be coupling
op1NewCollObj.name = getname(operator2); // Name new subnode to name of second TE
treenode op2CollisionObjects = getvarnode(operator2, "collisionobjects"); // Get collisionobjects node on second TE
treenode op2NewCollObj = op2CollisionObjects.subnodes.add(); // Add new collisionobjects subnode
op2NewCollObj.dataType = DATATYPE_COUPLING; // Set new subnode's datatype to be coupling
op2NewCollObj.name = getname(operator1); // Name new subnode to name of first TE
nodejoin(op1NewCollObj, op2NewCollObj); // Join both subnodes together to complete the bidirectional coupling 

It looks like you're trying to reference the two different Operators using for loops in your model, so you should be able to add this example code to your logic after getting a reference to both Operators. Just be sure to change the first two lines to however you are referencing those two Operators. The rest of the code should work after that without needing to modify it.

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

Braydn T avatar image Braydn T commented ·

Hey @Omar Aguilera Rico

I am unsure about this the way you are doing it, but another potential option is A* Navigation and contextdragconnection.

contextdragconnection(obj fromobject, obj toobject, str/num characterpressed) Creates an A or S connection between objects

Description This command mimicks holding the specified letter down on the keyboard, clicking on the fromobject and then dragging to the toobject with the mouse.
Whatever context sensitive action takes place when using the actual keyboard and mouse combinations, will occur when this command is executed.
This command can be used in both Flexscript and C++. Example

contextdragconnection(model().subnodes[5], model().subnodes3], "A");

You could have a script drag an A connection between the A* Navigator and the created object.
0 Likes 0 ·
Omar Aguilera Rico avatar image Omar Aguilera Rico Braydn T commented ·

Hello @Braydn T. The issue goes more for collisions, as a game with the topic of resources and have the sphere of collisions, to create more than three resources by means of Process Flow, for example, four resources, if the sphere is created to a fourth operator, but in the COLLISION tab in the COLLISION MEMBERS window it seems that you have to add them manually. What I am doing is that by means of a code the members that belong to the collisions are added to make it easier if I play with 10 operators or only with 2 operators, only that the route that I have to write in the COLLISION part MEMBERS is written as a string and not as a node. I need it to be written as a node to work properly. You attach the model, which marks error so I commented earlier. Leave the Operators' Tree open, if you can see Operator1_3 in collisionobjects, Operator 1 and Operator 1_2 appear in purple, but in Operator1_2 it only appears in Purple Operator1 the route, and in Operator1_3 in purple, but 0x0 as if there would be nothing, and in the same way for the Operator1 as if there were no node. This is what is marking me wrong. The Number 1 model is the one that passes the previous in the model Number 2 writes the route, but string form. The code with which I execute this is in the Script.

numero-2.fsm

numero-1.fsm

0 Likes 0 ·
numero-2.fsm (41.8 KiB)
numero-1.fsm (41.3 KiB)