Jump to content

Recommended Posts

Posted

I have been trying to automate the process of plotting multiple drawings to pdf but without using the exportpdf command. I find the quality to be poor and I have had issued with fields not being updated etc. So I was looking at the possibility of automating CutePDF Writer and I found this article..

http://www.codeproject.com/Articles/46592/Using-the-Free-CutePDF-Writer-without-User-Interve

 

The problem is that I don't know how to use it. And my knowledge of code is, to be fair, brutal. Does anyone know or can anyone tell me if there is a way to run this from a lisp so that the pdf gets saved in the given folder...

 

Thanks.

Posted

Give this a try.

 

;;; PDF's All Tabs to source drawing folder with Tab name.
(defun c:pdf ( / *error* cm fd )
   (defun *error* ( msg )
       (if (= 'int (type cm))
           (setvar 'cmdecho cm)
       )
       (if (= 'int (type fd))
           (setvar 'filedia fd)
       )
       (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
           (princ (strcat "\nError: " msg))
       )
       (princ)
   )
   
   (foreach layoutname (vl-remove "Model" (layoutlist))
     (command "._layout" "set" layoutname)
       (progn
           (setq fd (getvar 'filedia)
                 cm (getvar 'cmdecho)
           )
           (setvar 'filedia 0)
           (setvar 'cmdecho 0)
           
 (command 
 "-plot"
               "_Y" ;; Detailed plot configuration? [Yes/No]:
               ""   ;; Enter a layout name <Current-Layout>:
               "dwg to PDF" ;; Enter an output device name:
               "ARCH expand C (18.00 x 24.00 Inches)" ;; Enter paper size:
               "_I" ;; Enter paper units [inches/Millimeters]:
               "_L" ;; Enter drawing orientation [Portrait/Landscape]:
               "_N" ;; Plot upside down? [Yes/No]:
               "_E" ;; Enter plot area [Display/Extents/Layout/View/Window]:
               "_F" ;; Enter plot scale (Plotted Inches=Drawing Units) or [Fit] <1=1>:
               "_C" ;; Enter plot offset (x,y) or [Center]:
               "_Y" ;; Plot with plot styles? [Yes/No]:
               "TFC.ctb" ;; Enter plot style table name (enter . for none):
               "_Y" ;; Plot with lineweights? [Yes/No]:
               "_N" ;; Scale lineweights with plot scale? [Yes/No]:
               "_N" ;; Plot paper space first? [Yes/No]:
               "_N" ;; Hide paperspace objects? [Yes/No]:
               (strcat  ;; Enter file name:
                   (getvar 'dwgprefix)
                   (cadr (fnsplitl (getvar 'dwgname))) "-" (getvar 'ctab) ".pdf"
               )
               "_N" ;; Save changes to page setup [Yes/No]:
               "_Y" ;; Proceed with plot [Yes/No]:
           )
           (setvar 'cmdecho cm)
           (setvar 'filedia fd)
       )
       (princ "\nCommand not available in Modelspace.")
   )
   (princ)
)

Posted

I use the same method that BrianTFC outlined above. It works great and I use the "dwgn to PDF" driver built-in with AutoCAD. I tried it using the PDFCreator driver but as I recall there were some troubles with it. This method works very well but be sure you get the paper size text set just right. They come in very long, obscure names like "arch full bleed D (24.00 x 36.00 inches)" and you have to enter it just like that or it will not work. You can find these in the drop down menu when you look at the paper sizes manually. Then when your code runs it will select the correct size to print to.

 

Oh yes, I remember one of the other problems with the PDFCreator driver was it printed ok, but the file ended up rotated to the right 90°. This caused the users to complain and as I recall there were some resolution issues. The "dwgn to PDF" driver took care of these two issues.

Posted

BrianTFC, I keep getting an error saying "Command not available in Modelspace." I am definitely in Paperspace though. Any ideas?

 

Edit:

This is the command line dump:

Command: PDF1
._layout
Enter layout option [Copy/Delete/New/Template/Rename/SAveas/Set/?] <set>: set
Enter layout to make current <1>: 1
Command: Unknown command "Y".  Press F1 for help.
Unknown command "N".  Press F1 for help.
Unknown command "N".  Press F1 for help.
Unknown command "N".  Press F1 for help.
Unknown command "PDF".  Press F1 for help.
Unknown command "N".  Press F1 for help.
Unknown command "Y".  Press F1 for help.

Command not available in Modelspace.._layout
Enter layout option [Copy/Delete/New/Template/Rename/SAveas/Set/?] <set>: set
Enter layout to make current <1>: Layout2-1 Regenerating layout.
Regenerating model - caching viewports.

Command: Unknown command "Y".  Press F1 for help.
Unknown command "N".  Press F1 for help.
Unknown command "N".  Press F1 for help.
Unknown command "N".  Press F1 for help.
Unknown command "PDF".  Press F1 for help.
Unknown command "N".  Press F1 for help.
Unknown command "Y".  Press F1 for help.

Command not available in Modelspace.

 

 

Further Edit:

It's like it skipping over the plot command

Posted

No worries. I found my mistake.

Posted
BrianTFC, I keep getting an error saying "Command not available in Modelspace." I am definitely in Paperspace though. Any ideas?

 

The original program was written to plot only the current layout, hence there is a statement to test whether a paperspace layout is active when running the program. BrianTFC has incorrectly altered my code in an attempt to plot all layouts.

Posted

Lee,

 

Yes i altered your code to make it plot all layouts, Actually it works great. if you look at the thread above yours you see that woodman78 found his mistake. Isn't the object of coding to put different codes together to get a routine that you want for what you need?

Posted
Yes i altered your code to make it plot all layouts, Actually it works great. if you look at the thread above yours you see that woodman78 found his mistake. Isn't the object of coding to put different codes together to get a routine that you want for what you need?

 

The message being printed is not woodman78's mistake, this message will always be printed since the modified code still includes part of the original if statement, hence my point about the code being modified incorrectly.

Posted

The mistake that Woodman78 is refering to has nothing to do with the if statement , it had to do with his plot settings. All i did was change it from printing the current tab to a PDF to print all of tabs to a PDF. Like i said it works just fine.

Posted
Like i said it works just fine.

 

Sure it does.

 

BrianTFC, I keep getting an error saying "Command not available in Modelspace." I am definitely in Paperspace though. Any ideas
Posted

My apologies i thought the "Command not available in Modelspace." was a message to let people know that it doesn't work in modelspace. The error's i was refering to were the "unknown......" error's which was his plot setting.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...