Black Pearl Posted August 14, 2010 Report Share Posted August 14, 2010 Name: quick create a new vi from template Submitter: Black Pearl Submitted: 14 Aug 2010 File Updated: 03 Jan 2011 Category: *Uncertified* LabVIEW Version: 7.1 License Type: BSD (Most common) Installation: Copy the contents to LabVIEW xxxx/resource/plugins Abstract: Speed up creating new vi's from templates! It's using the 'new vi'-hook to create the new vi from a custom template. A plugin architecture allows to map different templates to the keyboard. For a quick-start, try Ctrl+N followed by 'H' (without releasing the Ctrl key). Detailed Description: When using New -> Blank VI from the Startup Window File -> New VI from the menu of any vi or the Ctrl+N shortcut the lv_new_vi.vi hook is called.Releasing of the Ctrl key (when using the shortcut) uses the Default.vit. The next key-press k creates a new vi from the template [...]/plugins/lv_new_vis/templates/k.vit. This is case insensitve and only works with a..z and SPACE. If no template is found or if an error occures, the default action of LabVIEW (empty vi) is performed (Failsafe).In addition to normal vi templates it supports global vi templates and control templates.Even more customization is possible using special tags on the vi or vit. Use[...]/plugins/lv_new_vis/tools/lv_new_vi__TagEditor to read and set them:isBD_ToFront? bring the block diagram in front instead of the front panel isRunMe? will instead run the vi in the template folder. Use this for wizards, more sophisticated scripting and other dialogs. Examples (V0.9.3: seperate ogp package): Try the following keys to see the different possibilities: f: normal vi, FP at front b: BD at front g: global vi c: control w: wizard h: help You do not need to delete the demo templates, a w.vit will load even with w_example.vit present. Compatibility: Developed in good old 7.1 and tested with 2010. I don't know if it works nicely with the project explorer and did never try to use it with projects, libraries and classes. Planned Features: * Error logging * Redirections via Config file (I will link the standard templates) (Edit: It's faster to just place them in the templates folder.) V 0.9.1 Fixed issues with the Application Instances of LV8.0 and higher. Wizards are still launched in the diaolog App.Instance, they need to get the default App on their own. V 0.9.2 Changes: Closing all references Beta: Uses VI Activation Event to abort when the user switched to a different app. (See discussion for details). V 0.9.3 Uses VI Activation Event to check Ctrl-Key when user switches from a diffrent application. Now available as packages (ogp). Uses a seperate package for the examples. V 0.9.4 Fixed issues with 0.9.3: After start of LV, Ctrl+N didn't work the first time Enjoy, Felix Click here to download this file 2 Quote Link to comment
jcarmody Posted October 6, 2010 Report Share Posted October 6, 2010 I get this error when I try to save a new VI launched with ctrl-N: The error goes away when I delete lv_new_vi.vi and the lv_new_vi directory from <LabVIEW>\resource\plugins. I've re-downloaded the file from the CR and had the same result. Has anyone else seen this problem? Quote Link to comment
Black Pearl Posted October 10, 2010 Author Report Share Posted October 10, 2010 I was able to reproduce this behaviour. Felix Quote Link to comment
Black Pearl Posted October 10, 2010 Author Report Share Posted October 10, 2010 I found a fix for this issue: * Pass the default application ref from Property Node Application:Default:Application to the application refnum of New VI I'll try to get this done in 7.1, but I guess I'll fail. Felix Quote Link to comment
Black Pearl Posted October 10, 2010 Author Report Share Posted October 10, 2010 I'm stuck at the moment to get this fixed version independent. Way 1: Explicite Open App reference (on localhost): In this case the BDWin.Open is not supported. Way 2: I tried the code from the Code Capture Tool. CCT_Get User App Reference__CCT.vi gives me error 42. Felix Quote Link to comment
shb Posted October 22, 2010 Report Share Posted October 22, 2010 I found a fix for this issue: * Pass the default application ref from Property Node Application:Default:Application to the application refnum of New VI I'll try to get this done in 7.1, but I guess I'll fail. Felix Does it work with Application:Active:Application (short App.ActiveApp) in LabVIEW 7.1? (Then it is opened in the current project in newer LabVIEW versions.) What is the problem in 7.1? A broken VI? Maybe you could load a dynamic VI dependent on the LabVIEW Version. This VI returns the application reference. Or you could use the Vi from CCT and when it fails use the reference "This Application" or the output reference of an application property node. (Please pass the application reference to all all new (and open?) functions.) (And it would be nice if you could create a VIPM plugging. Tell me when you succeed. I fail in 92%. ) Thanks a lot for this tool. Greetings, shb Quote Link to comment
Black Pearl Posted October 23, 2010 Author Report Share Posted October 23, 2010 Finally found the fix in this old post: LAVA Rocks! For LV 8.0 and above I dynamically call <vi.lib>\Utility\allVIsInMemory.llb\Get User Application Reference.vi to get the Default App.Instance. Make sure you download the new V_0.9.1 files. Felix 1 Quote Link to comment
shb Posted October 26, 2010 Report Share Posted October 26, 2010 Finally found the fix in this old post: LAVA Rocks! For LV 8.0 and above I dynamically call <vi.lib>\Utility\allVIsInMemory.llb\Get User Application Reference.vi to get the Default App.Instance. Make sure you download the new V_0.9.1 files. Felix Thank you very much indeed. Quote Link to comment
shb Posted November 30, 2010 Report Share Posted November 30, 2010 Some new feedback: The contained VI "lv_new.vi" destroys the file, "New..." dialog. And it looks like it is not needed. (It took some time to restore the original file...) The dialog does not close when I click on another application while ctrl is pressed, release the ctrl key and return to LabVIEW, except when i press and release ctrl.I suppose to check the platform modifiers instead of the scan code in key up and also in key down to close on esc, ... And eventually check all 5 seconds if the VI is the front most Please close all references. It probably does not change anything, but it looks better in “lv_new_vi Get User App Reference.vi” and probably when calling a wizard. The reference can be closed because the window is open. [*]I like VIPM packages. So I created one out of your code for easy installation for me. Unzip your code and the file in the attached file in the same directory. Then open the directory with the VI Package builder and create the package. Short conclusion: I like this tool! Greetings, shb lv_new_file VIPM Configuration.zip Quote Link to comment
Black Pearl Posted November 30, 2010 Author Report Share Posted November 30, 2010 The contained VI "lv_new.vi" destroys the file, "New..." dialog. And it looks like it is not needed. (It took some time to restore the original file...) Ooops, sorry. That is the 7.1 "New ..." dialog that accidentially slipped in the zip. I'll try to find some time this weekend to play with your other suggestions (VIPM is planned since some time). Felix 1 Quote Link to comment
Black Pearl Posted December 4, 2010 Author Report Share Posted December 4, 2010 Hi shb, I did try to implement your suggestions. All ref's are now closed properly. Concerning the issues when switching to another app, I did try to use the private VI Activation event (therfore I labled this a 'beta release'). Seems to fire once in 7.1, but twice in 8.5. Is it possible for you to test this in other versions? I propably go the offical way and implement it with polling tomorrow. But anyhow, you can download V0.9.2 and test if this matches your use case. I'm still a bit unclear about the Esc-key. Ctrl-N, Ctrl-Esc should not create anything? Concerning VIPM, I failed making a package for 7.1. I'll try with the OpenG package builder if time permits. Well, over the holidays I will have enough time for this and some new tool. Felix Quote Link to comment
shb Posted December 6, 2010 Report Share Posted December 6, 2010 Hello Hi shb, I did try to implement your suggestions. All ref's are now closed properly. Thanks. Concerning the issues when switching to another app, I did try to use the private VI Activation event (therfore I labled this a 'beta release'). Seems to fire once in 7.1, but twice in 8.5. Is it possible for you to test this in other versions? I propably go the offical way and implement it with polling tomorrow. But anyhow, you can download V0.9.2 and test if this matches your use case. I did some tests: LV 8.6 LV 2009 LV 2010 Creating something works. But the event is not called when another application is activated. I'm still a bit unclear about the Esc-key. Ctrl-N, Ctrl-Esc should not create anything? I mean something different. (This is my approach for handling the lost focus.) Do not check the scan code for detecting if the Ctrl key is released. This event is missed when the window does not have the focus. Use PlatMods.Ctl instead. And check this attribute in key down and in key up. Then the window is closed on any key press or release when Ctrl is not pressed. (Esc is only an example.) See also in the snippet I sent in my last post. (The picture does not show everything.) Concerning VIPM, I failed making a package for 7.1. I'll try with the OpenG package builder if time permits. Well, over the holidays I will have enough time for this and some new tool. Felix In this case I wish you nice holidays. Two versions would be OK too (zip for 7.1 and vipm for supported LabVIEW versions). In the meantime I unzip the archive, update the version in VIPM and create my personal package. Simple enough. Greetings, shb Quote Link to comment
shb Posted December 6, 2010 Report Share Posted December 6, 2010 I did some tests: LV 8.6 LV 2009 LV 2010 Creating something works. But the event is not called when another application is activated. Correction: All three versions (8.6.1, 9.0.1, 10.0) work like this: After activating another program, the VI is closed when you click two times on any LabVIEW window. My misunderstanding was that the window would disappear when LabVIEW is deactivated. And obviously I did not do the same clicks when testing the versions. Greetings, shb Quote Link to comment
Black Pearl Posted December 23, 2010 Author Report Share Posted December 23, 2010 Hi shb, I did improve the code dealing with activating another program and check if the Ctrl-Key is still pressed when the VI is Activated (again). Monitoring the Key-up while LV is not the active App won't work (if I don't want to rely on windows). Also I managed to make packages in 7.1. Feedback always welcome. Felix 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.