Export PDF and DWG in one go with LISP

Export PDF and DWG in one go with LISP

Darkforce_the_ilogic_guy
Advisor Advisor
2,949 Views
15 Replies
Message 1 of 16

Export PDF and DWG in one go with LISP

Darkforce_the_ilogic_guy
Advisor
Advisor

I would like to make a  Lisp code to Autocad , that work like this

 

enter command  Anyname

the user get a dialog box( Enter compony name)

then the user get to select(in windows) what he/she want to export

the  the program save an PDF and a DWG to  X:\export\<Compony name>\<current file name.(fileformat PDF and DXF)

 

is this possible ? and how ?

 

 

***THE POST TITLE HAS BEEN EDITED FOR CLARITY***

 

0 Likes
2,950 Views
15 Replies
  • Save
Replies (15)
Message 2 of 16

pendean
Community Legend
Community Legend
AutoList?
0 Likes
Message 3 of 16

Darkforce_the_ilogic_guy
Advisor
Advisor

with LISP 🙂  I have done a lot of coding in inventor and Excel but it total newbie in autoCAD.  The VBA part seens to be disable in our AUTOCAD.  if there is no way around it .. Then I might uses that as well.

 

But do you know any way in autocad where I can do this  or anything close to it ?

0 Likes
Message 4 of 16

pendean
Community Legend
Community Legend
>>>... The VBA part seens to be disable in our AUTOCAD...<<<
VBA use in AutoCAD requires a free module to be installed first (restart your PC afterwards) https://knowledge.autodesk.com/support/autocad/downloads/caas/downloads/content/download-the-microso...

HTH
0 Likes
Message 5 of 16

Sea-Haven
Mentor
Mentor

Before I post did you google ? There is so many plot pdf lisp out there, need some more info like plot a layout or model ? Title blocks used and so on. Saving the file again google Getfile & lisp, need that to check does pdf exist. 

 

An example

(COMMAND "-PLOT"  "Y"  "" "DWG To PDF"
	       "Iso full bleed A3 (420.00 x 297.00 MM)" "m" "LANDSCAPE"  "N"   "W"  "-6,-6" "807,560" "1=2"  "C"
	       "y" "Acad.ctb" "Y"	"n" "n" "n" pdfName "N" "y"
    )

 

 

0 Likes
Message 6 of 16

Darkforce_the_ilogic_guy
Advisor
Advisor

well. I uses google , youtube and this forum. I did not find somthing that I could use. Your code might be the best I have seens so far.  but still missing a lot as far as I can see ,( Have not test it jet). Some of our _Users would have to make the same PDF and DWG over and over again. And what I want to develope is a easy way.. To save in the rigth folder , in 2 format without have to make 100 click each time. Make it faster and Easy to use.   I have done somthing similar in inventor. but have not delevope a single code in Autocad jet. But I want to change that  and fix this problem the best way I can

0 Likes
Message 7 of 16

Darkforce_the_ilogic_guy
Advisor
Advisor

I have a hard time trying to make it work. I have made some small change so it fit my system .  Can you see what I does wrong ?

 

0 Likes
Message 8 of 16

(COMMAND "-PLOT" "Y" "" "Microsoft Print to PDF" "A4" "m" "LANDSCAPE" "N" "W" "126.5,201.5" "403.5,391.5" "F" "C" "Y" "" "Y" "" "Y" c:\temp\Test.pdf "n" "Y" "Y"


   )

 

bt_0-1643094263733.png

 

0 Likes
Message 9 of 16

I have this code now 

 

(defun c:MExport()(command "-PLOT" "Y" "" "Microsoft Print to PDF" "A4" "M" "L" "N" "L" "F" "C" "Y" "" "Y" "" "N" "N" "Y" "C:\TEMP\Test5.pdf" ""))

 

but it does not save the file .. I still have to select the name and location.. why is it not working ?

 

 I still like to make an input box that will control the location

0 Likes
Message 10 of 16

pendean
Community Legend
Community Legend
Why "Microsoft Print to PDF" as an option?
0 Likes
Message 11 of 16

m_badran
Advocate
Advocate

Try this code

(command "-PLOT"
           "Y"
           ""
           "DWG To PDF.pc3"
           "ISO A4 (210.00 x 297.00 MM)"
           "Millimeters"
           "Landscape"
           "N"
           "Extents"
           "fit"
           "Center"
           "Y"
           "acad.ctb";your plot style name
           "Y"
           "N"
           "N"
           "N"
           ""
           ""
           "Y"
           )
0 Likes
Message 12 of 16

Sea-Haven
Mentor
Mentor
c:\temp\Test.pdf

 

"C:\\temp\\test.pdf" note the "" the \\ allows for spaces in the directory, file name.

 

As you got that to work here is plot a range of layouts for you. Note your title block must always be at a certain point in this code its 0,0.

 

 

0 Likes
Message 13 of 16

Darkforce_the_ilogic_guy
Advisor
Advisor

Well I use "Microsoft Print to PDF" as an option because the one that was in the code i found on the internet did not exists on my PC.  But I believe that "Microsoft Print to PDF" exists on all the computer that will use this code in the future.  in theory I belive I have 3 option for PDF on my computer.  

 

I believe that it does not matter with one I uses as long it is on all computer that will use this code in the future 

0 Likes
Message 14 of 16

pendean
Community Legend
Community Legend
@Anonymous So if they put BULLZIP as a driver, you'd go out there and install that driver because you don't want to type over some code you found on the web?

Change it to one of the built-in PDFs instead for better performance, features and avoid other issues you might stumble on for you and all other AutoCAD users you will share this with, takes about 2-3 seconds to type and maybe 15-30 seconds to test.
0 Likes
Message 15 of 16

You got it wrong .. I change the code because I did not have the one on my computer. I am only in test and delevelop mode now .. I still lag the know how to make it work as I really want. I can always change with driver/printer I want to use later.

My real problem is that I still can´t control save location , and filename as I want Automatically .. I do not want to select it all the time .

I does not want to type the name in all the time , and if possible I want rev. nr. As a part of the file name

I want it to save something like this

X:\\partnummer_R.pdf
X:\\partnummer_R.dwg
I want the user to enter the customer name in .. and the Rev nr to come form the file ... as well as partnumber

0 Likes
Message 16 of 16

Sea-Haven
Mentor
Mentor

Look in Plotpdfa3range and you will see how a pdf name is made the same method for the saveas dwg.

 

Start with (getvar 'dwgname) and (getvar 'dwgprefix).

 

I use "Dwg to pdf" for Autocad, "Plot to pdf" for Bricscad, so using the "Microsoft" version may be a good idea as have no idea using Intellicad & Drafsight what pdf drivers.

0 Likes