Export to PDF command line help.

gobluejd
Advocate
Advocate

Export to PDF command line help.

gobluejd
Advocate
Advocate

hmsilva Has helped me get a auto PDF generator to work in windows.  The lisp replaces the qsave command and when you type qsave, it auto generates to a specific location and works really good.  I wanted to try on the MAC.  You can see whole convo here.  

 

More specifically he stared helping on the MAC but he is not a mac user.  That convo starts here.

 

I am pretty sure it can be come but need some assistance and hopefully someone can help out.

 

Basically I want to see I can create a PDF completely from the command line and use in the aucaddoc.lsp which I have confirmed loads and works.

 

 

 

 

0 Likes
Reply
Accepted solutions (1)
4,284 Views
60 Replies
Replies (60)

maxim_k
Consultant
Consultant
Hi Jeff,

Which AutoCAD version do you have on your Mac?
I'm asking, because the code in AutoLISP routine you want depends on AutoCAD version: in 2016 version the printing process was changed in compare to 2015 and 2014 versions.

Actually I have the solution and ready to post it, but i want to be sure that it will work in your AutoCAD installation.

Maxim

Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.


Maxim Kanaev
Architect
MARSS

MacACAD | Linkedin

Etiquette and Ground Rules of Autodesk Community
0 Likes

gobluejd
Advocate
Advocate
I am using 2016.
0 Likes

maxim_k
Consultant
Consultant

OK, here it is:

 

This version works without redefinig QSAVE command - after loading yoiu will get ne command QS:

 

(defun c:qs (/ *error* echo pdf_file lst mutt)
(defun *error* (msg)
(if mutt
(setvar 'nomutt mutt)
)
(if echo
(setvar 'cmdecho echo)
)
(cond ((not msg))
((member msg '("Function cancelled" "quit / exit abort")))
((princ (strcat "\n** Error: " msg " ** ")))
)
(princ)
)
(setq mutt (getvar 'nomutt)
echo (getvar 'cmdecho))
(setvar 'cmdecho 0)
(setvar 'nomutt 1)

(setq pdf_file (strcat (getvar "dwgprefix") (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4))))
(setq lst (dictsearch (namedobjdict) "acad_layout"))
(setq lst (dictsearch (cdar lst) (getvar "ctab")))
(if (or (eq (cdr (assoc 2 lst)) "none_device") (eq (cdr (assoc 2 lst)) "None"))
    (command "_plot" "_N" "" "" "" pdf_file "_N" "_Y")
    (command "_plot" "_N" "" "" "" "_Y" pdf_file "_N" "_Y")
)

(command "_.qsave")
(*error* nil)
(princ)
)

 

after executing QS you will get PDF file with the same name as your drawing file in the same folder where this DWG is. Plus current DWG will be saved with QSAVE command.

 

You can use this routine with or without editing Page Setup in Page Setup manager.

 

If the drawing was previously saved after printing in Windows version of AutoCAD or Page Setups in it were edited on another Mac, you need to edit Page setup for all Layouts in the drawing to avoid errors in PDF output.

 

Maxim


Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.


Maxim Kanaev
Architect
MARSS

MacACAD | Linkedin

Etiquette and Ground Rules of Autodesk Community

gobluejd
Advocate
Advocate
Thank you. I am in a meeting most of the day but will test ASAP and let you know.
0 Likes

gobluejd
Advocate
Advocate

I had a few mintues to test.  It appears to work but the command is asking questions each time

 

Printer Name - have to manually enter (defauly is always the OKI)

Plot to file - Y

Create plot file screen comes up - click save. (it then creates)

Then asked to save changes to page setup. click N is default (accept)

Proceed to plot (say No)

Command over.

 

 

Basically it works, but I have to manually enter the above responses.  Typing export and hitting enter is much much quicker.

 

Here is command line screenshot:

 

Screen Shot 2016-02-02 at 10.48.09 AM.png

 

 

0 Likes

maxim_k
Consultant
Consultant
Have you read an alert in bold in my previous post?
Current Page Setup in the file you tested was created in AutoCAD for Windows - that is why my routine works incorrectly.
You need to edit and save current Page Setup for each layout in the drawing, than the routine will work without your interaction.
In theory I can add some code in order to temporary reset Page Setup (plotter name), but nobody can adjust paper sizes which are used in page setups. Unfortunately this is one of the limitations in Windows and Mac versions compatibility.

Maxim

Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.


Maxim Kanaev
Architect
MARSS

MacACAD | Linkedin

Etiquette and Ground Rules of Autodesk Community
0 Likes

gobluejd
Advocate
Advocate

I did read your bold text and was looking for errors - I was not considering what I meantioned as an error.  I will play around with.  I have over 3k drawings and some have various setups etc.

 

Thank you so much for the time you put into this and I hope it helps someone else as well.

0 Likes

maxim_k
Consultant
Consultant
Does paper size in PDF output is important for you? If no and you can live with the same paper size (the default paper size from Mac OS System Preferences -> printers and Scanners pane) for all PDFS, than I can add code which will reset temporary page setup and you don't need to do it manually for each Layout in each drawing.

Maxim

Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.


Maxim Kanaev
Architect
MARSS

MacACAD | Linkedin

Etiquette and Ground Rules of Autodesk Community
0 Likes

gobluejd
Advocate
Advocate

99% of my prints are printed on 8.5x11. The only differnce in that is it may differ between landscape and portrait.

0 Likes

maxim_k
Consultant
Consultant
So, do you need modifications in routine?
I'm asking because now I don't have much time and not sure If I can do this quickly.

Maxim

Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.


Maxim Kanaev
Architect
MARSS

MacACAD | Linkedin

Etiquette and Ground Rules of Autodesk Community
0 Likes

gobluejd
Advocate
Advocate

If it will make the process quicker, yes.  I am in no rush.  Do when you can.

0 Likes

gobluejd
Advocate
Advocate
Just checking in - I know I told you no rush - just want to keep this open as Autodesk keeps sending me "Is this resolved" emails.
0 Likes

maxim_k
Consultant
Consultant
Hi,

If you mean my promise about adding code for resetting pilot device information, than I still have a very limited time, sorry. Can you wait for one - two days?

Maxim

Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.


Maxim Kanaev
Architect
MARSS

MacACAD | Linkedin

Etiquette and Ground Rules of Autodesk Community
0 Likes

gobluejd
Advocate
Advocate

Absolutely, - you are helping me.  It can wait until next week if needed.  I just dont want to keep getting Autodesk emails asking if this is resolved.  

0 Likes

maxim_k
Consultant
Consultant
Hi Jeff,

I need an information from you:
What printing area do you want to get in PDF:
- in Model space: display, limits, window defined in current page setup (if any), Extents or saved model views (if any)?
- in Layout: Layout, Window defined in page setup (if any), Extents or Display?

I'm asking, because if one of the options "What to print" were saved in current page setup, I need to reset it too.

Maxim

Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.


Maxim Kanaev
Architect
MARSS

MacACAD | Linkedin

Etiquette and Ground Rules of Autodesk Community
0 Likes

gobluejd
Advocate
Advocate
I do not print from model space, only layout and is a predefined window 99% of time.
0 Likes

maxim_k
Consultant
Consultant
>>>>only layout and is a predefined window 99% of time
If you want to have output to PDF with predefined window from Layout each time you save drawing (that was the original idea as I remember), than you need at first to define this window in the current page setup of each Layout of each drawing.

Otherwise you will need to define the area you want to plot each time you use my routine, because the default plot area in AutoCAD Layout is "Layout" and AutoCAD (and my routine) cannot know about what part what part of Layout (Window, which is defined by you) you want to save to PDF.

In my routine I can force AutoCAD to save to PDF Layout area, but I don't know which window you want to save in each of the drawing 😞

What do you think about this?

Maxim

Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.


Maxim Kanaev
Architect
MARSS

MacACAD | Linkedin

Etiquette and Ground Rules of Autodesk Community
0 Likes

gobluejd
Advocate
Advocate

I am not sure I am following so bare with me.  Almost 90% of my drawings can be batch plotted as the layout is already predifend. So in any of the drawings, when opened, you can export to PDF and it works, without doing anything.

 

If I understatnd you, you are saying that everytime your command begins, it has to get the window coordinates again, then it may not be worth continuing.

 

Currnently I do everything in Windows, however I like the smoothness of how MAC version runs (clean, nice pan etc etc) and would like to start using this.  RIght now I have about 3k in drawings that co-workers do not need to interact with, just open, PDF it and send with quotes etc.  So the idea was to remove them from having to use a DWG Viewer and the plot process.  I have all the drawings created to PDF, so from this point fwd, everytime I save it prints it PDF so the PDF's they see are updated without me having to remember to PDF it.

 

So If my second paragraph is true, then there is probably no need to move forward as I could just keep using WIN version and the save command you did for me there.

 

I have attached a DWG that contains the LAYOUT that I have in probably 75% of all the drawings.  In case you would need to understand.

0 Likes

maxim_k
Consultant
Consultant
I think I misunderstood you when I read "predefined window".
You mean not "Window" in "What to plot" settings, but rather "Layout".
Is it correct?

Maxim

Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.


Maxim Kanaev
Architect
MARSS

MacACAD | Linkedin

Etiquette and Ground Rules of Autodesk Community
0 Likes