Steve Watts Posted September 15, 2014 Report Share Posted September 15, 2014 Hi There, this is my first in a while. I started with a pretty simple requirement. I want to drop a variety of template VIs (VIT) onto my block diagram and I want them to act as VITs should do (i.e. come up as an untitled vi to be saved) I want this to happen from the function Palette, because this is where I do most of my work. So blockage #1 is that VITs don't register on the palette Being sneaky I thought I'd make a VI and embed the VIT in it, calling it from the function palette with the Place VI contents (merge VI to us old hands) Blockage #2 is that it drops it on the block diagram as a VIT!!!! :angry: :angry: So it appears my last hope is to do some LabVIEW scripting (I can generate it fine using my standard component building tool), but I still want to be able to drop a VIT off my function palette. So the question is can I drop a vi from my function palette that detects it's been dropped and chucks up a template vi to be saved. It all started so simple, but now I just want to beat the problem down (I hate being restricted) Lots of Love Steve Quote Link to comment
LogMAN Posted September 15, 2014 Report Share Posted September 15, 2014 So blockage #1 is that VITs don't register on the palette A VI template is not intended to be placed inside a VI, therefore you cannot put it on the palette. If you try to put a template into a VI it is like trying to call the template from the VI if that makes sense. Being sneaky I thought I'd make a VI and embed the VIT in it, calling it from the function palette with the Place VI contents (merge VI to us old hands) Blockage #2 is that it drops it on the block diagram as a VIT!!!! :angry: :angry: ..And that's exactly what happened here This is how you can create a VI from the template: If you try to create a project template with more than one *.vit, there is a solution for LabVIEW 2012+ well described over here: http://ekerry.wordpress.com/2012/11/09/creating-and-distributing-custom-templates-with-the-new-create-project-dialog/ There might be other options though. Other than that you can put VIs on the palette and check the "Place VI Contents" option (as you did before). Now if you create an VI and place the content from the palette it is similar to a template function. However this lacks the ability of template hierarchies. Quote Link to comment
hooovahh Posted September 15, 2014 Report Share Posted September 15, 2014 I just have my template be a normal VI set to be merged when dropped from the palette. Why doesn't that solution work for you? Why must the template be a VIT file? Quote Link to comment
ned Posted September 15, 2014 Report Share Posted September 15, 2014 I think his goal is to drop a VI onto the block diagram and have it be created as a new, unsaved VI that already contains some code, similar to what happens when you select some code and do Create SubVI. I can see why this might be neat, but I don't know how you would achieve it. 1 Quote Link to comment
smithd Posted September 16, 2014 Report Share Posted September 16, 2014 I don't mean to be that guy, but I think creating an express VI would get you half-way there. Express VIs can go on the palettes and can contain any code. Once you drop one down, you can right click and select "open front panel", and it will prompt you to convert the VI from an express Vi into a normal VI. You can then save this converted express VI and boom, you have your desired outcome. Negatives that I am aware of: -Your code starts out in humongous express vi form (rather than as an icon). -Your code would, technically, be an express vi. That having been said, if this is a common use case for you I think making some sort of tool would be the cleaner way of doing it. 1 Quote Link to comment
Yair Posted September 16, 2014 Report Share Posted September 16, 2014 (edited) So blockage #1 is that VITs don't register on the palette Actually, they do. You just need to change the filter in the file dialog to show them, but that won't help you, because they will still drop as VITs. I thought I have a vague recollection of a config option which does allow you to change it, but a quick search didn't find anything and I'm probably imagining it. A couple of other options: You could create an XNode which would replace itself when dropped. This will probably do exactly what you want, but if I understand it correctly, you will need to duplicate the XNode for every VIT, because I don't think there's another way to directly associate the node with the VI in the palette. This is similar to the express VI option, but somewhat more friendly. You could create a quick drop shortcut which will take the selected VI(s), instantiate an untitled copy and replace it. This is probably the least work. You could have a single VI which will create a copies of all the VITs that you want when run and then replace itself with all those copies (practically, it would probably have to launch another VI to do the replacing). Of course, that means that it would have to be statically linked and that you would have to delete the VIs you don't want. Edited September 16, 2014 by Yair Quote Link to comment
Steve Watts Posted September 30, 2014 Author Report Share Posted September 30, 2014 (edited) Hmmm, sorry about my silence, I don't appear to be getting notifications. Many thanks for your answers. The use case comes from having colour coded VIs for specific functions, going from the project is too slow. I didn't think of express VIs, this might give me the immediacy I'm after. (I'm after 2-3 clicks with no navigation from the block diagram ideally) A quick drop short-cut could also work nice, although having such things in the function pallette is my preferred option. The issue with a tool is similar to my issue with coming from the project, it means navigating away from the block diagram. I really wasn't expecting this to be so tricky. It's interesting the things that catch you out! Edited September 30, 2014 by Steve Watts Quote Link to comment
hooovahh Posted September 30, 2014 Report Share Posted September 30, 2014 I haven't personally used this QuickDrop but it allows you to take a selection of code and make a template from it. Then that template will be in your palette, and you can drop it down from quick drop. Quote Link to comment
jcarmody Posted September 30, 2014 Report Share Posted September 30, 2014 I haven't personally used this QuickDrop but it allows you to take a selection of code and make a template from it. Then that template will be in your palette, and you can drop it down from quick drop. I use it. I like it. I don't think it's what the OP is looking for. Quote Link to comment
GregFreeman Posted September 30, 2014 Report Share Posted September 30, 2014 (edited) A VI template is not intended to be placed inside a VI, therefore you cannot put it on the palette. If you try to put a template into a VI it is like trying to call the template from the VI if that makes sense. There is one case, however, where I have used this successfully. Functional globals inside a VIT seem to get their own "namespace" of sorts. This allowed me to launch multiple VITs but use a functional global independent to each one. (Ever wanted to reference the same timer in multiple cases in your code...now you can). I know this is unrelated to the original post, but maybe someone will find this convenient. Edited September 30, 2014 by GregFreeman Quote Link to comment
Yair Posted October 1, 2014 Report Share Posted October 1, 2014 Another possible option is to basically build your own palette VI and drop the things from there. You might need some playing around to get the instantiation and dropping correctly because of the instances issue. I don't think you can use the Application class method UI.Place Object on Cursor, because that accepts a path and you want an unsaved instance and a quick test indicates that using a VIT drops the VIT. You'll probably need to use the VI Activation event to remember the last active VI and then instantiate the VIT and add the reference to that VI yourself at some random point. You can probably then highlight and select it. Quote Link to comment
Steve Watts Posted October 6, 2014 Author Report Share Posted October 6, 2014 Thanks all for your responses. If I had the time and patience I think Yair's answer is most intriguing on a variety of levels. I love the idea of a custom palette VI. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.