From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting wires to build array through VI Scripting

Solved!
Go to solution

Hi,

 

I have been looking for a way to connect wires to a "build array" node through VI Scripting.

 

I have an array of inputs which have to translate into an array via "build array" node. I successfully added input terminals to "build array" node through VI Scripting. However, the program fails when I try to run a loop to wire all the inputs sequentially. The problem is, all of the input wires at the first element of "build array". Snapshot of code is attached.

 

Please suggest me a way to connect different elements at different inputs of "build array" node.

 

Thank you.

 

Regards

HB 

 

 

0 Kudos
Message 1 of 13
(4,075 Views)

You should be iterating over the terminals of the Build Array node and calling the Connect Wire method of each terminal.

0 Kudos
Message 2 of 13
(4,067 Views)

Thanks for the reply. This is the same I am doing as shown in the snap shot. Please point out where I am missing something.

 

Regards

Hasan

0 Kudos
Message 3 of 13
(4,063 Views)

You are calling Connect Wires on the node itself, not on the individual terminals.  You need to use the Terminals[] property of the node to get the array of terminals (element 0 is the output terminal).

0 Kudos
Message 4 of 13
(4,058 Views)

I am still unable to solve it. It is still connecting the terminals to the 1st element of "build array" node. Please see the edited code and point out the mistake in it. 

 

Thanks

HB

0 Kudos
Message 5 of 13
(4,053 Views)

You'd have to post the code, not the screenshot.  Are you sure it is wiring to the first element?  Wiring in scripting can be tricky, have you tried doing a BD cleanup on the scripted code?  Often wires overlap or run in strange places.

0 Kudos
Message 6 of 13
(4,040 Views)

I'd recommend looking at JKI's Right Click Framework.  One of the plugins it has that I've used in the past is Build Array of References.  At the heart of it will be a subVI for building the array.  It looks like it uses a method for the Terminal object called  "Create Described Wire".

 

Digging into that could give you the main part of the code that you need for what you are trying to do.

 

 

0 Kudos
Message 7 of 13
(4,012 Views)

Hi Darin,

 

Sorry for the inconvenience. I posted screen shot because it is a long VI including many other sub VIs in it. Anyways, I have made the new VI containing only that piece of code where I am having problem. 

 

This VI generates another VI (in stack sequence 0) and creates two numeric control knobs in the new VI (in stack sequence 1). I then want to build an array of these control knobs (in stack sequence 2). I am unable to wire them in different terminals of "build array" node. The 0th stack sequence (nested inside the outer 2nd stack) adds the appropriate number of terminals in "build array" node. The 1st stack sequence (nested inside the outer 2nd stack) is the one where I am doing unknown mistake. 

 

Thanks for your due help.

 

Regards

HB

0 Kudos
Message 8 of 13
(3,986 Views)

Hi Raven,

 

Thanks for your reply. 

 

I have already been through it and following his logic , but still unable to achieve my desired goal. It must be very small logical mistake which I am committing. Please see the attached file in the above comment Problem_HB.vi

 

Thanks

 

Regards

Hasan

0 Kudos
Message 9 of 13
(3,985 Views)
Solution
Accepted by topic author HB.

Running LV12 at the moment, faster to write a quick example than to open LV14 and look at your VI.

 

WireBuildArray.png

Message 10 of 13
(3,955 Views)