question

emanuela.berton avatar image
1 Like"
emanuela.berton asked Lars Jacobsen commented

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

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!

FlexSim 21.1.3
containervisual tool
· 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.

Phil BoBo avatar image Phil BoBo ♦♦ commented ·

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

0 Likes 0 ·
emanuela.berton avatar image emanuela.berton commented ·

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 0 ·
example.png (367.7 KiB)
example.png (435.2 KiB)
Phil BoBo avatar image Phil BoBo ♦♦ emanuela.berton commented ·

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.

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Phil BoBo ♦♦ commented ·

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.

0 Likes 0 ·
1625756152451.png (146.0 KiB)
emanuela.berton avatar image emanuela.berton commented ·

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

0 Likes 0 ·
gdm-json.txt (4.4 KiB)
Phil BoBo avatar image
0 Likes"
Phil BoBo answered Lars Jacobsen commented

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


· 3
5 |100000

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

emanuela.berton avatar image emanuela.berton commented ·

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

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ emanuela.berton commented ·
Yes, I added a case to the dev list to look into this.
0 Likes 0 ·
Lars Jacobsen avatar image Lars Jacobsen Phil BoBo ♦♦ commented ·
It would be great if the connections to a container worked in the same manner as any other object.
0 Likes 0 ·
Lars Jacobsen avatar image
1 Like"
Lars Jacobsen answered Lars Jacobsen commented

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.

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

emanuela.berton avatar image emanuela.berton commented ·
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 0 ·
Lars Jacobsen avatar image Lars Jacobsen emanuela.berton commented ·
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 0 ·