LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Snippets Manager - Drag snippet from LV exe to block diagram

Hi

I would like to create Snippets Manager which should work like this:

1. You have an app with a list of your snippets (see attachment).

2. You can scroll through all of your snippets and select the one you need for the particular task.

3. You can select the snippet from the list and drag-and-drop to the block diagram of some VI that you work on.

 

I started this project but in couple minutes I realized that I have no idea how to do programmatically attach a snippet to the drag action (that first issue) and then drop that to the block diagram which works in another process (second issue). I thought that this manager should be compiled into the exe.

Does anyone have any experience with such issues and is able to guide me somehow? Included examples with drag-and-drop action are related to transfer between controls inside the same window, so they are not so helpful for me.

 

Alternatively, maybe you have a better idea to manage snippets and mine is not worth any time.

Michał Bieńkowski
CLA, CTA

Someone devote his time to help solve your problem? Appreciate it and give kudos. Problem solved? Accept as a solution so that others can find it faster in the future.
Make a contribution to the development of TestStand - vote on TestStand Idea Exchange.
0 Kudos
Message 1 of 7
(2,471 Views)

A snippet is just a PNG, with the VI embedded as part of the meta data.  So I think the easiest way to go about this would be to find the VI in the PNG, then save it to a temp location, then using scripting add that as a subVI to the VI you dropped it on, then invoke the scripting method of inline which will place the VI's contents on the block diagram.  Shouldn't be too difficult.  The first step is getting the VI out of a png.  For that you'll want to look into the PNG file structure and try to find the sections and meta data.  This is something I swear I've seen done but don't have any example code for it.

 

That being said is this really necessary?  I can drag a PNG from my Windows Explorer window on to a block diagram and have it work fine.  I can get a preview of the images in a folder if I change the icon view too.

Message 2 of 7
(2,462 Views)

Hooovahh perhaps you are right - it is not necessary. One another solution is to include most useful snippets in the pallets (maybe this will make them available also from the QD).

I hoped that maybe someone has some experience with Windows CoreDragDropManager Class or something like that and could provide a clever solution - not that your is not clever, it just looks like a workaround for me 🙂

Michał Bieńkowski
CLA, CTA

Someone devote his time to help solve your problem? Appreciate it and give kudos. Problem solved? Accept as a solution so that others can find it faster in the future.
Make a contribution to the development of TestStand - vote on TestStand Idea Exchange.
0 Kudos
Message 3 of 7
(2,451 Views)

wrote:

[...] The first step is getting the VI out of a png.  For that you'll want to look into the PNG file structure and try to find the sections and meta data.  This is something I swear I've seen done but don't have any example code for it.

[...]

You may have seen this; I wrote it when I realized that the LAVA Code Capture Tool can back-save snippets to versions before LabVIEW could extract them.

 

Spoiler
That brought back memories.  I wrote it ten years ago and it has been downloaded almost 900 times.  The days are long but the years are short.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 4 of 7
(2,446 Views)

Well, you already have it and it is called windows explorer :o. Open the relevant folder and set the view to "large icons" or larger. Now drag any image to your block diagram. Voila! 🙂

Message 5 of 7
(2,425 Views)

Actually your right 😄

 

Michał Bieńkowski
CLA, CTA

Someone devote his time to help solve your problem? Appreciate it and give kudos. Problem solved? Accept as a solution so that others can find it faster in the future.
Make a contribution to the development of TestStand - vote on TestStand Idea Exchange.
0 Kudos
Message 6 of 7
(2,397 Views)

I worked on the same problem years ago. Not a separate executable, but a LabVIEW plug in that enables a multi-clipboard... I got it working, but never actually used it myself. 

 

IIRC, LabVIEW does not allow dropping anything that's not in the palette or isn't a node. So you'd need scripting, but AFAIK it's not possible to get any event from diagrams... So you're going against the stream the entire way... Not sure how I did this back then (drag drop a snippet onto the diagram), but I know it was not easy. And I did it from LabVIEW to LabVIEW. In your case, you'd need to make it work from some exe to LabVIEW. That would make it much more difficult.

 

If you choose to continue with this, I could have a look on how to extract the VI from a PNG. I also did the reverse, so I had snippets available in LabVIEW 7.1. And "my" snippets allowed front panel snippets as well. I'm still puzzled why that's not allowed (as it works fine).

Message 7 of 7
(2,389 Views)