LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting: Insert node making space

Solved!
Go to solution

There is a node in BD with wire connected to one of its terminals. A new node must be inserted in this wire close to terminal of existing node (invoke node Insert Node). There is no free space in BD thus space must be made first (invoke node MakeSpace).

 

Seems, this is a standard scripting task, but I cannot find any solution in the net. My own attempts to create a wheel are failed. Each my solutions works well only with some BD-s but not with all and even not with most of BD-s.

 

How can I calculate Rect parameter for MakeSpace node and InsertPoint parameter for Insert Node? I have reference to existing node and can easily identify terminal where the target wire is connected. 

 

This is illustration for my question:

 

InsertInWire.gif

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 1 of 5
(1,732 Views)

Hi _Y_,

 

Check the example script attached...

 

It seems the "Make Space" rectangle is equivalent to the rectangle you are drawing with your mouse when adding space manually.

So you can easily calculate it from the position of the Old VI, the width of the New VI, and the spacing you want.

 

For the Insert Point, As I understood, it is the "preferred" position of the center of your new VI.

However if the insertion algorithm detects matching wire data types, it may shift a little the node to minimize wire bends and insert it smoothly.

 

 

0 Kudos
Message 2 of 5
(1,696 Views)

Thank you raphschru, you solution is much better. I used similar approach but used old VI terminal to calculate new positing, did not account width of inserted note, and did some more mistakes.


However, the solution works for clean BD-s but not for crowded. This is an illustration:

 

220812_1.png

220812_2.png

 

First straight segment of the wire is very short. So, the space is made outside its length. Seems, script covering all cases could be too complicated. But I wonder if there is some smart solution?

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 3 of 5
(1,673 Views)
Solution
Accepted by topic author _Y_

If you want to manage arbitrarily messy diagrams, you simply cannot rely on the insertion algorithm of "Insert Node".

As I said, it uses a "preferred" position and automatically assumes which branch of the wire the node should be inserted on.

 

So you need to manually connect/disconnect wires and correctly position the new node.

However making a generic algorithm that will work on any node is hard, you have to detect input/output terminals, take into account their position in the node, etc...

 

Here is an example to insert your specific topology of subVI:

Message 4 of 5
(1,654 Views)

Thank you! It solves my problem.

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
0 Kudos
Message 5 of 5
(1,608 Views)