LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

print panel to printer.vi

I cannot get the Print Panel to Printer.vi to recognize that a VI contained in a lvlib (LV8) is actually loaded into memory.  This VI exposes the VIPrintPanelToPrinter function from the labview.exe file and the first arg is a string that represents the VI name.   It will not work if I pass   "Library Name.lvlib:Some VI to Print.vi" as an argument. I get error 1004 - the VI is not in memory.  If I save the exact same VI as "Some VI to Print.vi" and call the Print Panel to Printer.vi with "Some VI to Print.vi", everythine is fine.  Also, I understand that this function call into labview.exe is how "File->Print" is called from the LabVIEW menu - at least it used to be.  So, can someone tell me how to represent the VI name passed into Print Panel to Printer.vi when the VI I want to print is in a lvlib?

Thanks

Mark
0 Kudos
Message 1 of 7
(2,856 Views)
Hello,
 
It sounds like the error is accurate - if the VI isn't in memory, it can't be printed.  How about opening the VI (which you can do programmatically), then printing the VI, and then closing the VI (again this can be done programmatically)?
 
I think that will do the trick for you!
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 2 of 7
(2,840 Views)

Nope, I'm pretty sure that's not the problem - the VI is definitely in memory - the front panel is open.  The problem seems to come from the fact that neither the fully qualified name "Library Name.lvlib:Some VI to Print.vi"  or the short name "Some VI to Print.vi" allow the function to find the vi if the vi is in a lvlib.  If not in a lvlib, the name of the vi works fine as the argument and the panel prints.

Thanks,

Mark

0 Kudos
Message 3 of 7
(2,830 Views)

Hello,

Ok, this could be a bug then, or at least something which should be considered and potentially changed.  I'll attempt to recreate this now, but just for sanity, please post a screenshot or a simple example so I make sure to do EXACTLY what you're doing, in an attempt to recreate the problem.

Thanks and looking forward to your post!

Best Regards,

JLS

Best,
JLS
Sixclear
0 Kudos
Message 4 of 7
(2,815 Views)
JLS,

Thanks for the interest in my question - I also posed this question to NI and the application engineer sent this as part of his reply     

"As you know, lvlibs are brand new in LabVIEW 8, and the VIPrintPanelToPrinter function is quite ancient and hasn't been commonly used since the introduction of VI Server. Based off of our initial investigation, it appears that the VIPrintPanelToPrinter function does not have the infrastructure to accommodate lvlibs and I have created a bug report for R&D to investigate this issue further and to attempt to fix it for future releases."

So the short answer is it can't be done.  But does anybody have a way they handle print dialogs (which is why I want to use the Print Panel to Printer.vi - it can open a native Windows print dialog) that works for them?  I would be curious to see how others do it.

0 Kudos
Message 5 of 7
(2,807 Views)
Hello,
 
No problem - I'm an engineer at NI as well 😉  In any event, I just tried printing a VI which was in a library using an example I wrote, and it worked - here's how:
 
Instead of printing the VI directly, the example VI I wrote will simply get the image data for the front panel of the VI which you would like to print, then sends that data to a picture control (with the option to coerce the data to greyscale, where you can choose the lightest and darkest greyscale colors to use), and then prints the front panel of the VI which contains the picture control (which isn't in a library).
 
In any event, you just have to give the path to your VI in the example, then click run (deselect the greyscale option if you'd like) - you'll be prompted for the printer to use if you leave the printer string blank.
 
Perhaps this can serve as a workaround in the meantime, and it can of course be used programmatically 🙂
 
Here's the link to that example program on the web: (and you don't have to print in greyscale, there's a toggle switch to enable and disable that)
 
Best,
JLS
Sixclear
Message 6 of 7
(2,794 Views)


@mesmith-nm wrote:
JLS,

Thanks for the interest in my question - I also posed this question to NI and the application engineer sent this as part of his reply     

"As you know, lvlibs are brand new in LabVIEW 8, and the VIPrintPanelToPrinter function is quite ancient and hasn't been commonly used since the introduction of VI Server. Based off of our initial investigation, it appears that the VIPrintPanelToPrinter function does not have the infrastructure to accommodate lvlibs and I have created a bug report for R&D to investigate this issue further and to attempt to fix it for future releases."

So the short answer is it can't be done.  But does anybody have a way they handle print dialogs (which is why I want to use the Print Panel to Printer.vi - it can open a native Windows print dialog) that works for them?  I would be curious to see how others do it.


The way I have solved this in the past (not because of LabVIEW 8 but because my print dialog needed additional options, was to create my own print dialog. Agreed it does not look like the fancy XP print dialog with pretty icons for all the printers but it does work and give my users the specific control they need. You have two Application property nodes, one returns the currently available printers and the other returns or sets the currently used printer. This is enough to create a printer dialog in which you can select the printer to use. Then have a LabVIEW front panel setup to be the printout you want and configure it to print when it completes. Make that VI initilialize all controls properly and then finish. From you own print dialog call this print VI.

Takes a bit time, does not be a native print dialog (but what do you want, most of the other option you can choose there besides of the printer to use do not have any effect on the printing really), and it works like a charm.

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 7
(2,718 Views)