CoCreate User Forum  

Go Back   CoCreate User Forum > Applications > CoCreate Drafting

Reply
 
Thread Tools Search this Thread Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 01-06-2006, 04:46 AM
robiman's Avatar
robiman robiman is offline
Registered User
 
Join Date: Jan 2006
Posts: 6
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
Reply With Quote
  #2  
Old 01-06-2006, 08:40 AM
John Scheffel's Avatar
John Scheffel John Scheffel is offline
Administrator
 
Join Date: Sep 2002
Location: San Jose, CA
Posts: 1,288
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).
Attached Files
File Type: txt Set_PDF_name.txt (2.3 KB, 1080 views)
__________________
John Scheffel
Reply With Quote
  #3  
Old 01-08-2006, 10:13 PM
robiman's Avatar
robiman robiman is offline
Registered User
 
Join Date: Jan 2006
Posts: 6
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.
Reply With Quote
  #4  
Old 01-09-2006, 01:15 PM
John Scheffel's Avatar
John Scheffel John Scheffel is offline
Administrator
 
Join Date: Sep 2002
Location: San Jose, CA
Posts: 1,288
Re: ME10 command-line PDF printing

Quote:
Originally Posted by robiman
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.
Using INPUT probably does not work as you think it does. It does not work as I think it should. It may not finish reading the getfname.m file and defining the macro before it goes on to the next line in your customize_p file. This behavior has been the source of a lot of bizarre and hard to debug problems in out startup files.

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
Reply With Quote
  #5  
Old 01-09-2006, 10:16 PM
Henk Stokkel Henk Stokkel is offline
Registered User
 
Join Date: Aug 2005
Location: Netherlands
Posts: 36
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
Attached Files
File Type: m w_plotd.m (5.4 KB, 818 views)
Reply With Quote
  #6  
Old 01-10-2006, 12:59 AM
robiman's Avatar
robiman robiman is offline
Registered User
 
Join Date: Jan 2006
Posts: 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)
Since I'm quite fresh with ME10, I was wondering is this the correct way to retrieve page orientation from ANY .mi file? I run this macro on several test files, and I always got the right orientation.

thanx again
Robert
Reply With Quote
  #7  
Old 02-07-2006, 06:27 AM
MichaelA MichaelA is offline
Registered User
 
Join Date: Feb 2006
Location: Vancouver, WA USA
Posts: 40
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
Reply With Quote
  #8  
Old 02-09-2006, 03:49 AM
robiman's Avatar
robiman robiman is offline
Registered User
 
Join Date: Jan 2006
Posts: 6
Re: ME10 command-line PDF printing

Quote:
Originally Posted by MichaelA
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
Yes, PDF generator works flawlessly, at least for our drawings. To sum up what I did: (all of this code goes to customize_p.m)

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}
2. The next macro (I can't find the original poster - many thanks to him too) retrieves the page orientation, so I can set the paper in the right position (portrait or landscape):
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
3. Now all you have to do is to call this two macros:
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)
4. You must have paper modes A3 and A3P defined in plotdefs file:
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'
5. and finally, from the commandline: me10 -p filename.mi

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?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 09:14 AM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
You Rated this Thread: