How to set "Pass Inputs/Outputs to" in a Visual Tool

How to set "Pass Inputs/Outputs to" in a Visual Tool

emanuela_berton
Not applicable
376 Views
12 Replies
Message 1 of 13

How to set "Pass Inputs/Outputs to" in a Visual Tool

emanuela_berton
Not applicable

[ FlexSim 21.1.3 ]

Hi to all, I need to add objects in a visual tool that I will use as a container. I want to set the property "Pass Inputs to" and "Pass Outputs to" by code because I insert these objects dynamically, according to some external settings. Attached you find an example VisualToolAsContainer.fsmand in the script console you see how I did this. Is it correct or I can do the same operation in a different way? Thanks!

Accepted solutions (1)
377 Views
12 Replies
Replies (12)
Message 2 of 13

lars_jacobsen_ScandiSim
Advocate
Advocate

A more robust syntax is using Object.setProperty, i.e.

s1.setProperty("OutObjects", plane);

q2.setProperty("InObjects", q1);

q0.setProperty("InObjects", plane);

where q0 is a reference to Queue1 outside plane0.

The problem is that the plane attempts to be "smart", which is quite a problem. I.e. you connect from source1 outside the plane to the plane using setProperty. The plane then automatically creates a connect from the plane to Queue1 inside the plane and thus you loose control.

Unless some one else knows a work around, it should be reported to development.

PS: Another option is using sql and insert into.

Message 3 of 13

emanuela_berton
Not applicable
Thanks for your suggestion. I tried with setProperty and as you said I lost control and not all connections between plane and internal objects have been done. So, in order to report this issue to the development, do I do something else (make another post, send other examples, etc.) or this is enough?
0 Likes
Message 4 of 13

lars_jacobsen_ScandiSim
Advocate
Advocate
Let us wait for a few hours to see if some has a better suggestion and if not, I can report it to development.
0 Likes
Message 5 of 13

philboboADSK
Autodesk
Autodesk

How you set that variable is fine. What's the problem?



Phil BoBo
Sr. Manager, Software Development
0 Likes
Message 6 of 13

emanuela_berton
Not applicable

I use this approach in another model where I'm trying to create dinamically a model using also JSON. I created the plane with queue, processors, basicFR in this plane and I connected queue to processor, basicFR, etc. them but I don't connect the plane with first object and the last object with the plane. I only set "Pass Inputs To" and "Pass Output To" because I don't know how many inputs or outputs to this plane I will have. I create other planes with similar configuration and them I connect some of them and I obtain a line with different branches where some planes have more than one input or output. See the picture as example.example.pngWith this model this code doesn't work properly. That's why I asked if there is another way to do this. Attached you find the model.autobuild_master-manu_5.fsm Thanks for help

0 Likes
Message 7 of 13

philboboADSK
Autodesk
Autodesk

I can't replicate the issue in this model. It throws an error because it is missing a json file.

file error: requested file: "D:\1Phil\Downloads\gdm.json" could not be opened

What isn't working properly? Please provide an example with replication steps including what you did, what happened, and what you expected to happen.



Phil BoBo
Sr. Manager, Software Development
0 Likes
Message 8 of 13

philboboADSK
Autodesk
Autodesk

For example, if you run this script, you'll see that it sets the variable properly and then uses it properly to create the internal connection to the processor when you connect the queue to the visual tool.

treenode visualTool = createinstance(node("?VisualTool", library()), model());
setloc(visualTool, 5,0,0);
treenode processor = createinstance(node("?Processor", library()), visualTool);
setloc(processor, 5,0,0);
treenode queue = createinstance(node("?Queue", library()), model());
setvarstr(visualTool, "connectinputs", getname(processor));
contextdragconnection(queue, visualTool, "A");


1625756152451.png

If you have an example where this isn't working properly, please post it and we can explain why it isn't working.

As far as I can tell, everything is working fine.



Phil BoBo
Sr. Manager, Software Development
0 Likes
Message 9 of 13

emanuela_berton
Not applicable

Sorry, I forgot to attach the json file. Here you are. Rename the file to gdm.json gdm_json.txt

0 Likes
Message 10 of 13

philboboADSK
Autodesk
Autodesk
Accepted solution

Your problem has nothing to do with programmatically setting the connectinputs variable.

Your problem is that the connectinputs variable doesn't create internal connections when connected from a Visual Tool to another Visual Tool:

vt-internal-connection.gif

Instead of using those variables that don't do what you want, you can simply create each connection yourself individually:

1625760202072.png



Phil BoBo
Sr. Manager, Software Development
0 Likes
Message 11 of 13

emanuela_berton
Not applicable

I understand, I'll do it. Could be fixed this type of connection in the future? Thanks

0 Likes
Message 12 of 13

philboboADSK
Autodesk
Autodesk
Yes, I added a case to the dev list to look into this.


Phil BoBo
Sr. Manager, Software Development
0 Likes
Message 13 of 13

lars_jacobsen_ScandiSim
Advocate
Advocate
It would be great if the connections to a container worked in the same manner as any other object.
0 Likes