cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Printing in J-Link/VB API - Update

ptc-2245085
1-Newbie

Printing in J-Link/VB API - Update

I was unable to get the API calls to work to print drawings from VB. I
also had problems getting Pro/E to print from a macro with no_graphics
mode turned on.



The solution I finally came up with is to use Pro/E to print to a .plt
file and then run the plotter command (as found in the .pcf file)
directly on the .plt created by Pro/E. It may not be elegant, but it
works with everything I've thrown at it.



The algorithm looks something like:



For each drawing to be printed

____Switch Pro/E's working directory to the directory of the drawing

____Open the drawing

____Run a macro to print the drawing to a .plt file

____Close the active Pro/E window

____Clear all undisplayed models from memory

____Call the plotter command in the appropriate .pcf file to print the
.plt file

____Delete the .plt file



The macro I'm using (on Wildfire 4) is:

~ Activate `main_dlg_cur` `Windows.psh_win_activate`;

~ Command `ProCmdModelPrint`;

~ Activate `print` `print`;

! This is for printers on the initial drop-down list

~ Activate `print` `__PUT THE PRINTER NAME HERE__`;

~ Activate `print` `ToFile` 1;

~ Activate `print` `ToPrinter` 0;

~ Activate `print` `OK`;

~ Update `Print_file` `Filename` `__ENTER THE .PLT FILE PATH HERE (be
sure to escape backslashes)__`;

~ Activate `Print_file` `OK`;



or



~ Activate `main_dlg_cur` `Windows.psh_win_activate`;

~ Command `ProCmdModelPrint`;

~ Activate `print` `print`;

! This is for printers on the more printers list

~ Activate `print` `MorePrinter`;

~ Select `generic_list` `Selections` 1 `__PUT THE PRINTER NAME HERE__`;

~ Activate `generic_list` `OK`;

~ Activate `print` `ToFile` 1;

~ Activate `print` `ToPrinter` 0;

~ Activate `print` `OK`;

~ Update `Print_file` `Filename` `__ENTER THE .PLT FILE PATH HERE (be
sure to escape backslashes)__`;

~ Activate `Print_file` `OK`;



The way you know where a printer will be is that Pro/E lists the first 9
printers alphabetically on the initial drop-down list and then puts the
rest in the more printers list.



For VB.NET, I would use the Process object to execute the plotter
command.



The code for that is:

Dim PlotterProcess as New Process

PlotterProcess.StartInfo.FileName = "cmd.exe"

PlotterProcess.StartInfo.Arguments = "/c " & PlotterCommand & " " &
PlotFilePath

PlotterProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden

PlotterProcess.Start()

PlotterProcess.WaitForExit()

PlotterProcess.Close()



In Java, it can be more complicated. See:
0 REPLIES 0