rete icon indicating copy to clipboard operation
rete copied to clipboard

Uncaught Error: Connection view not found

Open FEskandariGM opened this issue 3 years ago • 0 comments

I have defined a node with multiple outputs similar to this sample code : https://codepen.io/hatead1/pen/GaZYaq But the output connections to other nodes were not created when editing and retrieving the file through editor.fromJson . To solve this problem, I tried to manually connect the corresponding outputs to the adjacent nodes. In order to connect after creating the node and creating the corresponding control, first I created a list of non-exist connections including input_node_id, input_node_port, output_node_id and output_node_port in the json format with the name of Connection and then created the connection manually through the following code.

Connection.forEach(async function (conn) {
      
  
          let out_node = editor.nodes.find(n => n.id == conn.input_node_id);
          let inp_node = editor.nodes.find(n => n.id == conn.output_node_id);
          editor.connect(out_node.outputs.get(conn.input_node_port), inp_node.inputs.get(conn.output_node_port));   
              //this.trigger('connectioncreated', connection);
              setTimeout(() => { editor.view.updateConnections({ node: out_node }); }, 10);
              
              await out_node.update();
               setTimeout(() => { editor.view.updateConnections({ node: out_node }); }, 10);
              
              await inp_node.update();
              setTimeout(() => { editor.view.updateConnections({ node: inp_node }); }, 10);
})

Connections are created, but when in line editor.view.updateConnections , I get the following error message. Uncaught Error: Connection view not found Also, when changing the position of the connection node, it does not move along with the input and output sockets and leaves a fixed view.

When using this.trigger('connectioncreated', connection) by changing the location of the node, the connections are created in the new position, but the previous connections remain in place, and a crowded view of nodes and connections is created.

This problem only occurs for nodes created with this property, that is, multi-output nodes with a changeable number of outputs, and there is no problem when editing through the main editor environment. The problem only occurs when creating a connection manually. What should I do to create connections and change and move when moving and changing the size of the nodes connected to it?

FEskandariGM avatar Jul 23 '22 07:07 FEskandariGM