Description MEPrint 1.0.3.1

The module MEPrint is designed to enable support for direct printing with ME10 while bypassing the Printer Manager Dialog for Windows. The primary goal for bypassing the Printer Manager Dialog is batch plotting. With MEPrint loaded it is possible to plot ME10 files without user interaction.

As an example you will also find the 'MEPrint.mac' which lets you plot ME10 files without using the Windows Printer Manager Dialog (use MEPELOOK = 1).

New Features/Fixes

  • Fixed the "Sys_plot_filename" problem on Windows 98, Windows 95
  • Fixed a problem with the "default printer" name length
  • Fixed the "*** File 'MEPrint.dll' is of wrong type" problem
 

Features/Fixes MEPrint 1.0.3.0

  • Print to a specified filename

    Setting the variable Sys_plot_filename to a valid filename lets ME10 directly print to that filename without the Windows Dialog "Print to File".

    e.g. LET Sys_plot_filename "c:\temp\example.prn"

    To disable direct printing to file set the Sys_plot_filename to an empty string.

    e.g. LET Sys_plot_filename ""

    The direct printing functionality can also be enabled/disabled with the following commands:

    ENABLE_MEPRINT_TO_FILE (enable the module)
    DISABLE_MEPRINT_TO_FILE (disable the module)

    Important:

    If the specified file exists the file will be overwritten without a warning. However to prevent damage of  important files writing to files with the attribute "System", "Hidden" or "Read Only" will be denied (an error message will be displayed).

  • Set the printer paper orientation

    For paper orientation portrait set the variable Sys_plot_orientation to 1 
    For paper orientation landscape set the variable Sys_plot_orientation to 2

  • Implemented font substitution for special chacracters in the macros (see init_conv_ltab_mepr in the macros)
  • Support for Windows environments without a "Default Printer"
  • Fixed a major defect which could result in a "Segmentation Violation"
  • The macros have been renamed to the new naming convention "<macro>.m"


Features/Fixes MEPrint 1.0.2.2

  • ENABLE_MEPRINT (enable the MEPrint module)
  • DISABLE_MEPRINT (disable the MEPrint module)
  • Use_fast_lookup 

    The macro variable use_fast_lookup determines the windows printer lookup mode. If the variable is unset (default) or set to to 1 MEPrint will use the Windows Registry to lookup network printers. If you encounter problems during the load of MEPrint you should set use_fast_lookup to 0 before loading MEPrint.
e.g.   LET Use_fast_lookup 0
   LOAD_MODULE '<PATH>\MEPRINT.DLL'
  • Caution: Setting  use_fast_lookup to 0 can slow down the load process of MEPrint noticeable. A better approach is to check that all your installed network printers are valid.
  • Support for ME10 10.50

Additionally some minor defects are fixed.

Requirements

Win NT or Win 2000 or Win 98 or Win 95 and ME10

The MEPrint.DLL is designed to work with every ME10 for Windows. 

Installation

Load the MEPrint.DLL with the following command into ME10:

LOAD_MODULE '<PATH>\MEPRINT.DLL'

Now the MEPrint module is activated.

If you will use MEPrint as a print replacement you must also load the macro 'MEPrint.m'

INPUT '<PATH>\MEPRINT.M' (English version)

 or

INPUT '<PATH>\MEPRINT_GER.M' (German version)

Once loaded you will get a 'MENU 2' button in the plot menu which when clicked transfers you to the 'PLOTTERCONFIG' menu.

IMPORTANT:

If you get an error message during the LOAD_MODULE check that you have installed at least MFC42.DLL file version 6.00.8267.0.  If not download the Windows Library Update from Microsoft.

http://www.microsoft.com/ntworkstation/downloads/Recommended/
ServicePacks/MFCLibrary.asp

This update is for Win95, Win98 and WinNT 4.0

If ME10 does not work check that the ME10 "print_mgr_option_on" is set.

Usage

For printing with the MEPrint module it is necessary to define the ME10 variables 'sys_plot_name' and 'sys_plot_size'.

e.g.  sys_plot_name 'HP DesignJet ColorPro CAD by HP'
  sys_plot_size 9 or sys_plot_size 500,500


The variable sys_plot_name defines the name of the printer and the variable sys_plot_size the printer paper format id or user format.

How it works

After loading the MEPrint module the following macros are created:

  • Refresh_printer_ltabs
  • Create_printer_names_ltab
  • Create_printer_paper_ids_ltab
  • Create_printer_paper_names_ltab
  • Create_printer_capabilities_ltab
  • Must_refresh_printer_ltabs

The macro 'Refresh_printer_ltabs' ia a helper macro which invokes the 'Create_* .ltab' macros and sets the 'Must_refresh_printer_ltabs' variable to 0. 

Each 'Create_*_ltab' macro creates a ME10 logical table with the respective name (e.g. 'Create_printer_names_ltab' creates a ME10 logical table with the name 'Printer_names_ltab').  

The variable 'Must_refresh_printer_ltabs' indicates (if set to 1) that something in the windows environment has changed (e.g. a printer has been removed or added).

How to write your own macros for MEPrint

The first step when writing a macro which uses the MEPrint module should be the test of the 'Must_refresh_printer_ltabs' variable. So a macro should always begin with the following macro code:

define foo
  if(Must_refresh_printer_ltabs)
    Refresh_printer_ltabs
  end_if
  ....
end_define

This piece of code ensures that the ME10 logical tables are in sync with Windows.

In the second step you must define the printer. For that it is necessary to choose a printer from the 'Printer_names_ltab'.
 
The table has the following format: 

Row Col Name  
 1   1  'Windows Printer 1'
 2   1  'Windows Printer 2'
 3   1  'Windows Printer 2'


Here a more realistic table:

 
Row Col Name  
 1   1  'LJ 4'
 2   1  'HP DesignJet ColorPro CAD by HP'
 3   1  'HP DesignJet 600 (C2847A)'

For example if you plan to print to the 'HP DesignJet ColorPro CAD by HP' you should write the following code:

 

define foo
  if(must_refresh_printer_ltabs)
    refresh_printer_ltabs
  end_if
  let sys_plot_name (read_ltab 'Printer_names_ltab' 2 1)
...
end_define

Please keep in mind that due to the dynamic behaviour of Windows (printers could be removed or added) it is not guaranteed that the printer
is always on Row 2 Col 1. A better approach is the following:

define foo
  if(must_refresh_printer_ltabs)
    refresh_printer_ltabs
  end_if
  
  select_from_ltab 'Printer_names_ltab' 1 =  
                   'HP DesignJet ColorPro CAD by HP' END
  let printer_name_idx (read_ltab 'sys_select' 1 1)
 
  if(printer_name_idx = '')
    display 'Error: The specified printer cannot be found.'
    cancel
  end_if
 
  let sys_plot_name (read_ltab 'Printer_names_ltab' 
                     printer_name_idx 1)
  ...
end_define
 

This code sequence searches the table for the printer and assigns it to the sys_plot_name variable.

The third step is to set the variable sys_plot_size to the correct paper format. You have two choices:

  • Predefined Windows paper format
  • User defined format

Predefined Windows paper format

Let's start with the Windows paper format. Setting the correct Windows paper format you must do two things:

1. Get the friendly paper name 
2. Determine the paper size id of the chosen friendly paper name

1. Get the friendly paper name

The friendly name is coded in the 'Printer_paper_names_ltab'. The table has the following format:

 
Row Col Name 
 1   1  'Letter'
 2   1  'Letter Small'
 3   1  'Legal'
 .   .  .......
 1   2  'Custom 1: 200 x 200 mm'
 2   2  'Custom 2: 300 x 300 mm'
 3   2  'Custom 3: 400 x 400 mm'
 .   .  ......
 .   .  ......

What does that mean?  The Row is the index of the friendly paper name and the Col is the index of the printer name.

For example: Row 2, Col 2 is related to the paper name 'Custom 2: 300 x 300 mm' and the 'HP DesignJet ColorPro CAD by HP' and Row 3, Col 1 is related to the paper name 'Legal' and the printer name 'LJ 4' (see the more realistic example).

Because MEPrint does (currently) not handle the friendly paper name we must map the friendly name to a Windows paper size id.

2. Determine the paper size id of the chosen friendly paper name

To get the paper size id of the friendly paper name we must use the 'Printer_paper_ids_ltab'. The table has the following format:

Row Col Paper ID
 1   1     1
 2   1     2
 3   1     5
 .   .     .
 1   2   257
 2   2   258
 3   2   259
 .   .    .
 

The Row contains the index of the friendly paper name and the Col the index of the printer name.

For example: Row 2, Col1 2 is related to the paper name 'Custom 2: 300 x 300 mm', the printer 'HP DesignJet ColorPro CAD by HP' and the paper size id 258 (see the more realistic example).

Even if it looks complicated it is very easy to determine the parameters.  Let's focus on the last line of the 'Printer_paper_ids_ltab':

Row Col Paper ID
 3   2   259
 

Now do the following:

Look at Row 3 of the 'Printer_paper_names_ltab' and you will find the parameter 'Custom 3: 400 x 400 mm'. Then go to the 'Printer_names_ltab' and look at row 2  and you will find  'HP DesignJet ColorPro CAD by HP'. So the sequence 3 - 2 - 259 stands for:

Printer_paper_name  Custom 3: 400 x 400 mm
Printer_name:  HP DesignJet ColorPro CAD by HP
Printer_paper_id:  259

Here an example which prints to the 'LJ 4' and the paper format 'Legal':

define foo
  if(must_refresh_printer_ltabs)
    refresh_printer_ltabs
  end_if
 
  {Select the printer }
  select_from_ltab 'Printer_names_ltab' 1 = 'LJ 4' END
  let printer_name_idx (read_ltab 'sys_select' 1 1)
 
  if(printer_name_idx = '')
    display 'Error: The specified printer cannot be found.'
    cancel
  end_if
 
  let sys_plot_name (read_ltab 'Printer_names_ltab' 
                     printer_name_idx 1)
  {Select the paper format 'Legal'}
  create_ltab 'Temp_ltab'
  select_from_ltab 'Printer_paper_names_ltab' 
                    printer_name_idx = '*' 'Temp_ltab' END
  select_from_ltab 'Temp_ltab' printer_name_idx = 'Legal' 
                    END
  let paper_name_idx (read_ltab 'sys_select' 1 1)
  delete_ltab 'Temp_ltab'
 
  if(paper_name_idx = '')
    display 'Error: The specified paper format cannot 
                    be found.'
    cancel
  end_if
 
  let sys_plot_size (read_ltab 'Printer_paper_ids_ltab' 
                     paper_name_idx printer_name_idx)  
  ...
end_define

Now the vars are set to 'sys_plot_name' 'LJ 4' and 'sys_plot_size' 5 and the plot can be started with 'plot_start.'

User defined format

The first step when using the user defined format is to check that the specified printer supports the user format. The ME10 logical table 'Printer_capabilities_ltab' contains the necessary information. The table has the following format:

Row Col 1              Col 2              Col 3   ....
 1  SupportsCustomSize SupportsCustomSize ......        

This table contains only one row and the columns tell you if the specified printer supports custom sizes. For example if the Col 2 has the value 'SupportsCustomSize' the printer with index 2 in the printer_names_ltab supports the user defined format.

In the next step you must set the sys_plot_size parameter. The parameter must have the format <user def. format>,<user def. format>. Here an example which sets the user size format to 500 mm x 500 mm:

define foo
  if(must_refresh_printer_ltabs)
    refresh_printer_ltabs
  end_if
  
  select_from_ltab 'Printer_names_ltab' 1 =  
                   'HP DesignJet ColorPro CAD by HP' END
  let printer_name_idx (read_ltab 'sys_select' 1 1)
 
  if(printer_name_idx = '')
    display 'Error: The specified printer cannot be found.'
    cancel
  end_if
 
  let sys_plot_name (read_ltab 'Printer_names_ltab' 
                     printer_name_idx 1)
  {Check if the printer supports user defined formats}
  if((read_ltab 'Printer_capabilities_ltab' 1 
                printer_name_idx) <> 
                'Supports_Custom_Size')
    display 'Error: The specified printer does not support
             user defined paper sizes'
  end_if
  LET Sys_plot_size (pnt_xy 500 500) 
  ......... 
end_define

Again to use user defined formats it is necessary that the printer driver provides support for that feature. Drivers from Microsoft currently do not support this feature.

IMPORTANT: 

Due to a limitation in the Windows DEVMODE data structure the max.
value for paper height and paper width is 3267 mm.

If you need a more detailed example look at the attached 'MEPrint.m'. 

Credits

Gerhard Giessmann providing WebSpace for the MEPrint download on his outstanding WebSite http://www.me10.de

Ralf Roth for tracking down and fixing the “Error: The specified printer cannot be found.” problem. Thanx also for his hints and the macro example regarding font substitution.

Testing and feedback

Matthias Flury CoCreate GmbH, Wim van Geem and the team of Savaco,
Manfred Mosel and Joern Moeller from the arxes Engineering Solutions GmbH 

Misc

Thanks to all the contributors for their help and defect reports.

Support

This tool is completely UNSUPPORTED. However in the case of failures send a detailed error report to the following email address:

Hermann_Dekena@hp.com