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: 

Creating control on front panel using VI scripting

Hi,

 

I am trying to create control dynamically on front panel using VI scripting.

Attaching code for creating combo class.

Problem is combo box is created in new VI while I want to create it in same VI in which I have written my code in block diagram.

It is giving an error 1000.

 

Please assist.

0 Kudos
Message 1 of 9
(3,359 Views)

You're not going to be able to script yourself because a VI can't be edited if it is running.

Matt J | National Instruments | CLA
Message 2 of 9
(3,336 Views)

Put another way.  Scripting can only do what you can do.  It is like a robot doing the work you would normally do.  But adding controls to a running VI is not something you can do, it changes the code and needs a recompile, which is why when a VI is running, or reserved to run, edits aren't allowed.

Message 3 of 9
(3,320 Views)

@Hooovahh wrote:

Put another way.  Scripting can only do what you can do.  It is like a robot doing the work you would normally do.  But adding controls to a running VI is not something you can do, it changes the code and needs a recompile, which is why when a VI is running, or reserved to run, edits aren't allowed.


It is possible to fake it out and edit a running VI; but it almost always leads to a LV crash.

"If you weren't supposed to push it, it wouldn't be a button."
Message 4 of 9
(3,306 Views)

@Jacobson-ni wrote:

You're not going to be able to script yourself because a VI can't be edited if it is running.


Thanks @jacobson for your inputs.

0 Kudos
Message 5 of 9
(3,283 Views)

Thank you for your inputs. I think it might not possible to create new objects on same FP.

0 Kudos
Message 6 of 9
(3,276 Views)

Here're some workarounds:

 

1) avoid dynamic controls.

 

For instance, use a tree control, that shows all items (settings?) as tree item. When clicked, show the type of control and let the user edit it.

 

Hard to advice on this without the specific problem.

 

Combined with right click menus, tree controls, listboxes, etc. can be really convenient to solve complex GUI problems.

 

2) use sub panels.

 

Put 2000 (the maximum nr. of dynamic controls) on the FP. Then, position the required nr of subpanels correctly and fill them with predefined controls (or vice versa). You'll have a reference to those controls, and you can get dynamic events from them to do pretty much everything you'd want. SP are surprisingly efficient, there would be hardly no overhead.

 

The only problem is that non-square controls (could just as well be VIs) can block mouse input to controls in the same rectangle (because the subpanel is square).

Message 7 of 9
(3,272 Views)

@Amit_Amrutkar88 wrote:

Thank you for your inputs. I think it might not possible to create new objects on same FP.


Correct there are only a few things that you can change in a VI when it is running:

  • Add/Remove breakpoints
  • Size/Position/Scroll Position of the FP & BD windows
  • Data values of FP controls
  • You can save a running VI (which clears the *)
"If you weren't supposed to push it, it wouldn't be a button."
Message 8 of 9
(3,258 Views)

Just to mention, this terrible inconvenient limitation is resolved in NXG.

 

Not that I'm suggesting to switch to NXG now, but now that this problem will eventually be fixed.

 

Finally...

0 Kudos
Message 9 of 9
(3,233 Views)