12-19-2022 11:27 AM
When programing in LabVIEW it is sometimes beneficial to paste over an existing control/indicator (by copying the source item selecting the target item and pasting). This keeps all of the "connections" (property nodes, references, connection pane, local variables, etc) that exist for the control but makes it just like the copied source.
Is there a way to do this programmatically using VI scripting?
In a somewhat related question, is it possible to do this paste without changing the target control's name?
Thanks
12-19-2022 12:03 PM
12-19-2022 03:27 PM - edited 12-19-2022 03:27 PM
I saw that but how do you do it with the version of the control you already have modified but isn't saved as a type def?
12-19-2022 03:50 PM
12-21-2022 02:47 PM - edited 12-21-2022 02:51 PM
Ok I think with that help I got it working. Basic idea for anyone else wanting to do this, make the source into a type def temporarily and then replace with that. In my case it was actually preferable to use "Replace No Attributes" which replicates the position and font size of the source's labels (but keeps the text value of the target) as well as probably many other things (one thing I did se was it would replace the boolean text with that of the source whereas the other method would not).
Another question now. Any way to do something similar with decorations? I figure since they have much less critical properties that I could just use a default decoration for the replace but I have a few problems with that, First I don't know how to get the style or PalletteString of the source decoration, second when I choose what should be an appropriate style to replace the decoration with, I always get "Cannot replace this object with the type specified" so maybe the replace isn't supported at all for decorations even though the method exists for them?
One more thing I am trying to reconcile. The main reason for trying to replace a decoration (instead of making a copy of the existing and deleting the old one) is to keep the z-sort order and the grouping, however it looks like you cannot replace even a control that is in a group anyway. You get an error "Cannot replace object inside a group" (at least not with the invoke node, the right click equivalent seems to do it just fine. maybe it ungroups and re-groups however many nested groups there might be?)
Also the copy/paste method works just fine on both controls that are grouped and on decorations (grouped or otherwise. It would be really great if I could mimic or trigger that somehow in my VI scripting.