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.
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.
Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
Interesting in learning all you can about automotive CAN bus communication? Checkout my 12 part CAN Blog series.
Checkout and help contribute to the community driven LabVIEW Wiki.
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
[...] 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.
Well, you already have it and it is called windows explorer . Open the relevant folder and set the view to "large icons" or larger. Now drag any image to your block diagram. Voila!
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).