02-06-2018 08:56 AM - edited 02-06-2018 08:58 AM
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.
02-06-2018 09:06 AM - edited 02-06-2018 09:06 AM
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
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
02-06-2018 09:27 AM - edited 02-06-2018 09:33 AM
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 🙂
02-06-2018 09:32 AM - edited 02-06-2018 09:33 AM
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.
02-06-2018 10:17 AM
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! 🙂
02-07-2018 02:07 AM
Actually your right 😄
02-07-2018 05:28 AM
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).