DWG to PDF

DWG to PDF

gobluejd
Advocate Advocate
5,290 Views
47 Replies
Message 1 of 48

DWG to PDF

gobluejd
Advocate
Advocate

This is what I need to do:

 

Replace the Qsave command with a custom command that every time I save a DWG I want it to create a PDF in the background, save it like the exportpdf command does (names it the same filename - no layout info and save over an existing file if there is one).  It will always be saved to the same directory. 

 

Right now I can use autopublish, but it adds the name of the layout tab.  I need it to be just the acutal file name, for example - test.dwg = test.pdf.

 

Can anyone help me?  

 

0 Likes
Accepted solutions (2)
5,291 Views
47 Replies
Replies (47)
Message 21 of 48

hmsilva
Mentor
Mentor

@gobluejd wrote:
Thanks so much!!! Is it using a certain PC3 file? It is not correctly printing it. It only PDF's a portion of it. I am assuming I just have to set the printing preferences for the correct PC3 file it is using?

You're welcome, Jeff!
Glad I could help!

 

The '-export' command will use the PC3 saved in page setup, or in the plot configuration, if one exist...

I did use a simplistic form, from the '-export' command, if in a layout, 

(command "_.-export" "_P" "_C" "_N" file)

-export to Pdf the 'Current layout', No detailed plot configuration and the file name

if in model,

(command "_.-export" "_P" "_D" "_N" file)

-export to Pdf the Display, No detailed plot configuration and the file name

 

The -export command allows to enter detailed configuration, try the command att the command line and see the the options you have in the detailed configuration...

 

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 22 of 48

gobluejd
Advocate
Advocate

Can this be done on MAC version as well?

0 Likes
Message 23 of 48

hmsilva
Mentor
Mentor

@gobluejd wrote:

Can this be done on MAC version as well?


Hi Jeff,

I'm not a MAC guy...

 

But, if MAC version have the '-export' command, probably the 'vl-filename-base' function will error...

Try to change

(vl-filename-base (getvar 'dwgname))

to

 

(substr (getvar 'dwgname)1 (- (strlen (getvar 'dwgname)) 4))

and test the code in MAC...

 

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 24 of 48

gobluejd
Advocate
Advocate
Ok thanks. The addock file does not exist in MAC version.
0 Likes
Message 25 of 48

hmsilva
Mentor
Mentor

@gobluejd wrote:
Ok thanks. The addock file does not exist in MAC version.

The 'acaddoc.lsp' file is created by us, not during installation.

Try to write one acaddoc.lsp using a text editor, pste the code in itt, and save it in a Support File Search Path.

Restart AutoCAD and type qsave....

 

Henrique

 

EESignature

0 Likes
Message 26 of 48

gobluejd
Advocate
Advocate

Maybe it will work.  I did that, nothing happened, checked command line and this is what it says:

 

Opening an AutoCAD 2013 format file.
Regenerating layout.
Regenerating model.
AutoCAD menu utilities loaded.
AutoCAD menu utilities loaded._.undefine qsave
Command:
Autodesk DWG. This file is a TrustedDWG last saved by an Autodesk application or Autodesk licensed application.
Command:
Command:
Command:
Command:
Command:
Command:
Command:
Command: QSAVE
Unknown command "-EXPORT". Press F1 for help.
Unknown command "P". Press F1 for help.
Unknown command "C". Press F1 for help.
Unknown command "N". Press F1 for help.
Unknown command "DICKERSON\DOCUMENTS\DRAWINGS\PDF\997418.PDF". Press F1 for help.

 

I am guessing I need to add the other text you said earlier and it might work.  Maybe also change the path.

0 Likes
Message 27 of 48

hmsilva
Mentor
Mentor

@gobluejd wrote:

Maybe it will work.  I did that, nothing happened, checked command line and this is what it says:

 

Opening an AutoCAD 2013 format file.

Command: QSAVE
Unknown command "-EXPORT". Press F1 for help.
Unknown command "P". Press F1 for help.
Unknown command "C". Press F1 for help.
Unknown command "N". Press F1 for help.
Unknown command "DICKERSON\DOCUMENTS\DRAWINGS\PDF\997418.PDF". Press F1 for help.

 

I am guessing I need to add the other text you said earlier and it might work.  Maybe also change the path.


Jeff,

in the AutoCAD MAC 2016, help files, the "-export' command exist...

 

you'll have to try in MAC command line to enter -export and see if the command exist...

 

Henrique

EESignature

0 Likes
Message 28 of 48

gobluejd
Advocate
Advocate

I am leaving in 45 mins for the day, so I will not be able to test if you reply later than that. - THanks BTW.

 

I edited the file (attached) and this is still what I get.

 

Opening an AutoCAD 2013 format file.
Regenerating layout.
Regenerating model.
AutoCAD menu utilities loaded.
AutoCAD menu utilities loaded._.undefine qsave
Command:
Autodesk DWG. This file is a TrustedDWG last saved by an Autodesk application or Autodesk licensed application.
Command:
Command:
Command:
Command:
Command:
Command:
Command:
Command: QSAVE Unknown command "-EXPORT". Press F1 for help.
Unknown command "P". Press F1 for help.
Unknown command "C". Press F1 for help.
Unknown command "N". Press F1 for help.
Unknown command "DICKERSON/DOCUMENTS/DRAWINGS/PDF997418.PDF". Press F1 for help.

 

The -export does not work, although this is what is autofilled.

-exporttoautocad

This is prompt.

Command: -EXPORTTOAUTOCAD File format: 2013
Bind xrefs: Yes
Bind type: Insert
Filename prefix: ACAD-
Filename suffix:
Export options [Format/Bind/bind Type/Maintain/Prefix/Suffix/?] <Enter for filename>:

0 Likes
Message 29 of 48

gobluejd
Advocate
Advocate

It does have it!!!!  We were using -export and the command is _export

 

Your code shows:

 

(command "_.-export" "_P" "_D" "_N" file)
(command "_.-export" "_P" "_C" "_N" file)

 

 

0 Likes
Message 30 of 48

hmsilva
Mentor
Mentor

EXPORTTOAUTOCAD is not the command you are looking for...

 

You'll have to find a command in MAC to export the dwg to a .pdf file...

 

Henrique

EESignature

0 Likes
Message 31 of 48

gobluejd
Advocate
Advocate

Do I just remove like this:

 

(command "_export" "_P" "_D" "_N" file)
(command "_export" "_P" "_C" "_N" file)

 

???

0 Likes
Message 32 of 48

hmsilva
Mentor
Mentor

@gobluejd wrote:

Do I just remove like this:

 

(command "_export" "_P" "_D" "_N" file)
(command "_export" "_P" "_C" "_N" file)

 

???


Change the acaddoc.lsp to acaddoc.lsp.old in the ACMAC and the program will not load the code.

I'll try to find if there are a command in MAC to replace the -export command.

 

Henrique

 

EESignature

0 Likes
Message 33 of 48

gobluejd
Advocate
Advocate

Ok - Thanks!  No rush!

 

Here is the command:

 

https://knowledge.autodesk.com/support/autocad-for-mac/learn-explore/caas/CloudHelp/cloudhelp/2015/E...

 

and when you type this in command:

 

_export

 

This pops up:

 

Screen Shot 2016-01-29 at 1.53.46 PM.png.

0 Likes
Message 34 of 48

gobluejd
Advocate
Advocate

Just curious if you have looked more into!

0 Likes
Message 35 of 48

hmsilva
Mentor
Mentor

@gobluejd wrote:

Just curious if you have looked more into!


Sorry Jeff, I'm getting too old...

I forgot to give you some feedback...

 

Yes!

I did stole my youngest son 'mac', and I did try, but definitively, I'm not a 'mac' guy...

 

The 'mac' version have the 'export' command, not the '-export' and if you call the command from a lisp file, the you'll get the command line version.

The prompt sequence is diferent, but you'll have to try it and find the correct prompt sequence...

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 36 of 48

gobluejd
Advocate
Advocate

Interesting.  I can call up _Export on my mac and its not command line:

 

When I type _export in command line this pops up.

 

Screen Shot 2016-01-29 at 1.53.46 PM.png

 

I am confused and what the code is or what to test?

0 Likes
Message 37 of 48

hmsilva
Mentor
Mentor

Try

(command "export")

 

Henrique

EESignature

0 Likes
Message 38 of 48

gobluejd
Advocate
Advocate

I did this:

(command "_.undefine" "qsave")
(defun c:qsave (/ *error* echo file 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 file (strcat "/Users/jeffreydickerson/Desktop/" (substr (getvar 'dwgname)1 (- (strlen (getvar 'dwgname)) 4)) ".pdf"))
(if (= (getvar 'ctab) "Model")
(command "export" "_P" "_D" "_N" file)
(command "export" "_P" "_C" "_N" file)
)
(command "_.qsave")
(*error* nil)
(princ)
)

 

 

 

And get this:

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

0 Likes
Message 39 of 48

hmsilva
Mentor
Mentor

Jeff,

don't test the full code, test only the commandline version of export command, when you get the command working correctly, then use it in the full code...

 

Try to enter a filename in the command

i.e

(command "export" (strcat "/Users/jeffreydickerson/Desktop/" (substr (getvar 'dwgname)1 (- (strlen (getvar 'dwgname)) 4)) ".pdf"))

copy/paste the above code line in the command line...

 

 

Henrique

EESignature

0 Likes
Message 40 of 48

gobluejd
Advocate
Advocate

Ok - I think I get it.  But not sure what to do in my limited lsp/command knowledge.  I understand if I can do everything from command line, then more than likely I can use the acaddock file.  

 

I pasted all the code and get errrors.  

 

Then I tried:

 

(command "export")

I get this:

 

Screen Shot 2016-02-01 at 3.55.10 PM.png 

0 Likes