LabVIEW APIs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

[Scripting] Copy control from running VI

Hey all,

I have an interesting situation that I can't figure out how to do.  I want to take a control from a running VI and replicate it on a new VI (with the same colors, properties, etc).  However using the TopLevelDiagram:Make Selection and Copy selection methods, you can only copy from a VI in edit mode.  Does anyone have other ideas on how to accomplish replicating a control using VI Scripting?

Thanks for the help,

David

0 Kudos
Message 1 of 6
(6,699 Views)

Why can't you get a refnum to the control you want to copy, read it's properties, create a new control, and set the properties?

Message 2 of 6
(3,570 Views)

I can get you close, but not the exact control...

The forum won't let me post images at the moment... I'm not sure why... so I posted the image of the diagram here:

http://forums.ni.com/t5/LabVIEW/Create-Control-From-Reference/m-p/1539816/thread-id/570676/highlight...

Message 3 of 6
(3,570 Views)

Just use the VI's Create by Reference method. I added a snippet in AQ's thread.


___________________
Try to take over the world!
Message 4 of 6
(3,570 Views)

Hey thanks everyone for the advice.

Steve:  This would definitely work, just requires more work when I was pretty certain there was a much simpler method.

AQ:  This copies the data type of the control only, I was looking to copy all of the properties, class type, colors etc. 

tst:  This seems to do exactly what I was looking for!

Attached is the VI example in case anyone stumbles across this later on...

0 Kudos
Message 5 of 6
(3,570 Views)

*head smack* I forgot about that method. Good catch, tst.

Message 6 of 6
(3,570 Views)