Jump to content

Another Create Polymorphic VI


Recommended Posts

So in a recent discussion here the was talks about scripting polymorphic VIs. At the time I was surprised to hear that no one had made scripting code to generate polymorphic VIs. This feeling passed when I realized several people have attempted to generate polymorphic VIs through scripting. There are some on NI's site here, as well as some older ones on Lava as well. Still I didn't realize this until I had taken my own go at it.

So here is a really beta version of my attempt to generate VIs that are 99% the same as another VI, with the small exception that the controls on the front panel have been replaced with a different control.

Attached is my quick and dirty approach. Open "Main Create Wizard.vi" and run the VI, it will prompt you for a VI to use as a template. I have included an OpenG version of the Filter 1D array under the Example Files, I also renamed it so it shouldn't conflict with already installed OpenG code. Then choose the controls that you would like to replace in the new interface by clicking the boolean corresponding to the control connected to the connector pane of the VI you selected. Then choose the control types to replace the selected controls with. These control types are just controls on disk and by adding any control to the folder "Control Types" you will be adding them as an option in this window.

At the moment it is quite limited. You can only replace controls that are on the connector pane, and they all must be replaced with the same control. So you can't do anything fancy like replace one control with a path, and another with a 1D array of a path. I think that wouldn't be too difficult to add but I didn't want to spend too much time on it. The code should then generate a VI for each control type you selected in the same folder as the template VI you selected at the start.

This code relies on some OpenG packages, I'm not sure all of them but File, and Array for sure. Let me know if you have any questions, and feel free to modify and post your updates.

Create Polymorphic VIs hooovahh.zip

Link to comment

OpenG scripts polymorphic VIs for the Array package

So you might like to check out the polymorphizer tool

I haven't looked at in detail for a while but I always thought that it might make a good stand alone tool (at the moment it is just an internal one)

Of course, for the right use case, it would be great to move away from polymorphic VIs in the future and onto generic code aka like this ;)

Link to comment

The OpenG tool look interesting. Was there a reason it wasn't built into a package? Possibly into the Application Control? Or Builder package? I think there are places that the OpenG method, and my method could both be improved. Over the weekend I was thinking about all the stupid things I did in mine that could be much simpler, and support for array of controls could be made simpler too so you just need to make a scalar of the data type then specify the size. Not sure if I'll ever have time to improve my method but I wanted to get it out there for others to look at and possibly improve on.

Link to comment

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.