#1
|
||||
|
||||
ME10 command-line PDF printing
Hi
I'm trying to automatically generate PDF files from ME10. I got this far: from the command line I can run me10 -p drawing.mi and I get a nice little PDF file in the working dir. My problem is that I can only set a fixed filename: (customize_p.m) PLOT_DESTINATION DEL_OLD 'x.pdf' PLOTTER_TYPE 'PDF_GENERIC' Is there a way to associate the PDF filename to the .mi filename? Some macro or something? I found some info on retrieving filenames in this thread: http://www.cocreateusers.org/forum/showthread.php?t=5679 But I don't know how to use this information in my case. Please help robert |
#2
|
||||
|
||||
Re: ME10 command-line PDF printing
The attached macro file may help. It contains a macro I wrote which will extract the name of the currently loaded MI file from the full path returned by INQ_ENV. It can optionally remove the file extension (such as ".mi"). After the macro is some code showing how you could use it to set the print output file name to match the loaded MI file name, but replace the .mi extension with .pdf. You can add this code to your customize_p.m file to see if it works (I have not tested it with the -p startup option).
__________________
John Scheffel |
#3
|
||||
|
||||
Re: ME10 command-line PDF printing
Thanks John, it works like a charm! I have one more question: is it possible to put this macro in a seperate file, and call it from "customize_p.m"? I tried to do this, but when I call the macro (before PLOT_DESTINATION line, of course):
INPUT 'getfname.m' I get an error saying that "The macro Amts_file_basename is not defined". I also tried INPUT IMMEDIATE - same result. |
#4
|
||||
|
||||
Re: ME10 command-line PDF printing
Quote:
I think if you use INPUT IMMEDIATE you will need to put it and the following commands within a macro definition then run the macro. I have not used IMMEDITATE much since it won't work with path names containing variables, which is what I mostly use. A bizarre limitation I have never understood.
__________________
John Scheffel |
#5
|
|||
|
|||
Re: ME10 command-line PDF printing
Robiman,
We use the atached macro to plot a lot of files to pdf. Just make a list of the files to be plotted and go ahead. Henk |
#6
|
||||
|
||||
Re: ME10 command-line PDF printing
Thank you Henk, without knowing it you already answered my next question. I was going to ask how to retrieve drawing orientation - portrait or landscape. I took a piece of your code to do the job:
Code:
DEFINE Plot_mode EDIT_PART TOP INQ_ENV 6 LET Plot_sc (INQ 4) INQ_ENV 7 LET Plot_width (((X_OF ((INQ 102)-(INQ 101)))*Plot_sc)-0.001) LET Plot_height (((Y_OF ((INQ 102)-(INQ 101)))*Plot_sc)-0.001) IF (Plot_width>Plot_height) LET Mode 'A3' ELSE LET Mode 'A3P' END_IF END_DEFINE Plot_mode PLOT_FORMAT (Mode) thanx again Robert |
#7
|
|||
|
|||
Re: ME10 command-line PDF printing
Robiman, have you been successful in getting your macro to work? I'm interested in doing a similar function, while saving a .mi file in v11.6 I also want to save a PDF file at the same time. I have some of the info but not enough to make it all work. Can you post your macro to share? Thks
|
#8
|
||||
|
||||
Re: ME10 command-line PDF printing
Quote:
1. The first macro (many thanks to John Scheffel) reads the filename of the drawing, so we can use it later when saving the generated PDF: Code:
DEFINE Atms_extract_basename PARAMETER Input_path PARAMETER Remove_extension LOCAL Input_strlen LOCAL Slash_posn LOCAL Dot_posn LOCAL Substring LOCAL Path_sep LOCAL Strlen LOCAL Basename { The direction of the slash can vary depending on how file was loaded } { Set the path separator based on which is found in the string. } IF (POS Input_path '\') LET Path_sep '\' ELSE LET Path_sep '/' END_IF {Extract the base name from the full path} LET Input_strlen (LEN Input_path) LET Slash_posn (POS Input_path Path_sep) LET Substring Input_path LET Strlen (LEN Substring) LOOP IF (Slash_posn<>0) LET Substring (SUBSTR Substring (Slash_posn + 1) (Strlen - 1)) LET Strlen (LEN Substring) LET Slash_posn (POS Substring Path_sep) LET Basename Substring ELSE LET Basename Substring END_IF EXIT_IF (Slash_posn=0) END_LOOP IF (Remove_extension) LET Dot_posn (POS Basename '.') IF (Dot_Posn<>0) {If no '.' then no extension, just leave as is} LET Substring Basename LET Strlen (LEN Substring) LET Basename '' LOOP LET Basename (Basename + (SUBSTR Substring 1 Dot_posn)) LET Substring (SUBSTR Substring (Dot_posn+1) Strlen) LET Dot_posn (POS Substring '.') LET Strlen (LEN Substring) EXIT_IF (Dot_posn=0) END_LOOP {Remove the last '.'} LET Basename (SUBSTR Basename 1 ((LEN Basename)-1)) END_IF END_IF LET Atms_file_basename Basename END_DEFINE {Atms_extract_basename} Code:
DEFINE Plot_mode EDIT_PART TOP INQ_ENV 6 LET Plot_sc (INQ 4) INQ_ENV 7 LET Plot_width (((X_OF ((INQ 102)-(INQ 101)))*Plot_sc)-0.001) LET Plot_height (((Y_OF ((INQ 102)-(INQ 101)))*Plot_sc)-0.001) IF (Plot_width>Plot_height) LET Mode 'A3' ELSE LET Mode 'A3P' END_IF END_DEFINE Code:
INQ_ENV 0 LET Current_fullpath (INQ 304) Atms_extract_basename Current_fullpath 1 PLOT_DESTINATION DEL_OLD (Atms_file_basename+'.pdf') PLOTTER_TYPE 'PDF_GENERIC' Plot_mode PLOT_FORMAT (Mode) Code:
'A3' 'HPGL_GENERIC,HPGL2_GENERIC,HPGL2_RTL_GENERIC,PDF_GENERIC,POSTSCRIPT_GENERIC' 0 0 425 302 'mono,rgb3,rgb24' '150,300' '150,300' 'me10' 'mode2' 'A3P' 'HPGL_GENERIC,HPGL2_GENERIC,HPGL2_RTL_GENERIC,PDF_GENERIC,POSTSCRIPT_GENERIC' 0 0 302 425 'mono,rgb3,rgb24' '150,300' '150,300' 'me10' 'mode2' As you can see, I only use A3 paper size, so if you want to use all sorts of different paper sizes, you will have to modify "Plot_mode" macro to fit your needs. Now, since this works for printing the PDF, I'm not sure if you can get it to work for saving files in the same way - any ideas from ME10 experts on this subject? |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | Rate This Thread |
|
|