Jump to content

dropping VIT onto block diagram....


Steve Watts

Recommended Posts

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 :angry:

 

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) :lightbulb:

 

Blockage #2 is that it drops it on the block diagram as a VIT!!!! :angry: :angry: :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

Link to post

So blockage #1 is that VITs don't register on the palette :angry:

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) :lightbulb:

Blockage #2 is that it drops it on the block diagram as a VIT!!!! :angry: :angry: :angry: :angry:

..And that's exactly what happened here :)

 

This is how you can create a VI from the template:

post-17453-0-65147000-1410800457.png

 

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.

Link to post

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.

  • Like 1
Link to post

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.

  • Like 1
Link to post

So blockage #1 is that VITs don't register on the palette :angry:

 

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:

  1. 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.
  2. 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.
  3. 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 by Yair
Link to post
  • 2 weeks later...

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 by Steve Watts
Link to post

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.

Link to post

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 by GregFreeman
Link to post

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.

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.