LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running a script on the active VI

Hi All,

 

I've been enjoying learning about VI scripting and have a found some ways to automate some tedious tasks with it. One thing I would like to do with the VI scripts I have created, is to run them on the VI that I'm currently editing.

 

For instance I have this script that wires multiple outputs from one node to multiple inputs of another node.

 

It currently works by first selecting the two nodes on the VI I want to edit, then opening up the VI script, selecting the file path to the VI I want to edit, then running the VI script.

 

Ideally I would like to just stay in the window of the VI I'm editing, select the two nodes, hit a button or shortcut, and have the script do its job on the VI that I'm editing.

 

Does anyone know if this is possible somehow?

 

FYI here's a snippet of my script code just for reference.

 

Thank you,

John

0 Kudos
Message 1 of 7
(2,044 Views)

I'd suggest implementing your scripting as a Quick Drop Keyboard Shortcut or Right-Click Menu Plugin.

 

Here's a presentation I frequently give on all the ways to hook into the LabVIEW editor for your own features. There are links to pages that can explain how to implement a Quick Drop Keyboard Shortcut, Right-Click Plugin, or any other hook you decide to use for your scripting.

 

http://bit.ly/dnattlvhooks

 

Good luck!

Message 2 of 7
(2,038 Views)

Place your tool in

     C:\ ... \LabVIEW xxxx\project\

or

     C:\ ... \LabVIEW xxxx\project\<my menu name>\

 

in your tool use this to open a reference to the active VI.

t.png

Invoke your tool from the LabVIEW menu:

    Tools → my tool name

or

    Tools → <my menu name> → my tool name

"If you weren't supposed to push it, it wouldn't be a button."
Message 3 of 7
(2,035 Views)

Paul,

 

I tried setting this up following your advice, however when I select my tool from the menu, it just opens the front panel to my tool and does nothing. It doesn't attempt to run my script VI.

 

Any idea what I'm doing wrong?

0 Kudos
Message 4 of 7
(2,001 Views)

Forgive me if I'm telling you something you already know, but from what you've described, just highlighting the nodes and doing CTRL+Space, CTRL+W does exactly that. If you have a setup like shown, that's all you have to do to quickly wire every output to every input. It also works if your highlighted output nodes are tunnels from a structure, but unfortunately it looks pretty funky.

Spoiler
FireFistRedhawk_1-1625072202563.pngFireFistRedhawk_2-1625072431889.png

 

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 5 of 7
(1,999 Views)

@JohnMaldonado wrote:

 

...when I select my tool from the menu, it just opens the front panel to my tool and does nothing. It doesn't attempt to run my script VI.


I think you need to set the VI that you launch from the Tools menu to 'Run When Opened' in VI Properties > Execution.

Message 6 of 7
(1,987 Views)

@FireFist-Redhawk wrote:

It also works if your highlighted output nodes are tunnels from a structure, but unfortunately it looks pretty funky.


I'm guessing you're using an older LabVIEW version. In a recent release (2019? 2020?) we updated the Ctrl-Space, Ctrl-W shortcut to perform a cleanup on all scripted wires. 

0 Kudos
Message 7 of 7
(1,986 Views)