Jump to content
GregGleason

Send to PDF

Recommended Posts

GregGleason

I have written a send a .dwg to .pdf routine and it is not working.

 

Here are the plot settings.

 

attachment.php?attachmentid=63700&cid=1&stc=1

 

Any ideas?

 

(defun c:SendToPDF ( / *error* vars old s file Fname fsl dwgN)

  (defun *error* ( msg )
     (and old (mapcar 'setvar vars old))
     (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
     (princ (strcat "\n** Error: " msg " **")))
     (princ)
  )

  (setq vars '("CMDECHO" "FILEDIA") old (mapcar 'getvar vars))
  (mapcar 'setvar vars '(0 0))
  (setq dwgN (getvar "dwgname"))
  (setq fsl (strlen dwgn))
  (Setq Fsl (- fsl 4))
  (setq Fname (substr dwgn 1 fsl))
  (setq Fname (strcase fname t))
  (setq file (strcat (getvar 'DWGPREFIX) (substr (setq dwg (getvar 'DWGNAME)) 1 (- (strlen dwg) 4)) ".pdf"))

  (while
     (progn
        (setq s (getstring (strcat "\nEnter Filename for Save <" (getvar 'file) "> : ")))
        
        (cond ( (eq "" s)
        (setq s (getvar 'DWGNAME)) nil)
        
        ( (not (snvalid s))
        (princ "\n** Invalid **")))
     )
  )
(setq path (getvar "dwgprefix"))


; (command "_.saveas" "_2010" (strcat "G:\\Group\\2D AutoCAD\\HDAL Library\\" s))
;(command "_.saveas" "_2007" (strcat path s))
 (command "-plot"         "yes"           ""              "DWG TO PDF.PC3"
          "ANSI expand B (11.00 x 17.00 Inches)" "Inches"        "Landscape"     "yes"           "Extents"
          "yes"           "yes"               "yes"           "monochrome.ctb"       "yes"
          "no"            "no"            "yes"           file            "no"            "Yes"
         )
(mapcar 'setvar vars old)

(princ)
)

Greg

Plt to PDF.jpg

Share this post


Link to post
Share on other sites
rlx

I'm not sure because I haven't tested your routine but does it maybe fail on the paper size? You don't mention... I ask because I had this problem once and after I replaced the spaces in my paper size with underscores it worked...

Share this post


Link to post
Share on other sites
GregGleason
I'm not sure because I haven't tested your routine but does it maybe fail on the paper size? You don't mention... I ask because I had this problem once and after I replaced the spaces in my paper size with underscores it worked...

 

Thanks. I will give that a shot and see what happens.

 

Greg

Share this post


Link to post
Share on other sites
BrianTFC

GregGleason,

 

try this.

 

 

(defun c:Test()
     (vl-load-com)
   
     (if (setq filename (getfiled "Save File Location" ""  "pdf" 1))
 (progn 
     (command "-plot" "yes" "" "DWG To PDF.pc3" "ANSI expand B (11.00 x 17.00 Inches)"
         "inches" "landscape" "yes" "Extents"
         "fit" "center" "yes" "monochrome.ctb" "yes" "a" filename "no" "yes")
               )
         )
     )

Share this post


Link to post
Share on other sites
rlx

Probably Brian's suggestion will work so just show where you went wrong:

 

to make the file name try his :

 (setq file (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".pdf")) 

 

also :

 (setq s (getstring (strcat "\nEnter Filename for Save <" (getvar 'file) "> : "))) 

 

file is not a system variable so it should be :

 (setq s (getstring (strcat "\nEnter Filename for Save <" file "> : "))) 

 

hope this helps

 

gr. Rlx

Share this post


Link to post
Share on other sites
Grrr

2c - I'd store the file lisp variable like this:

(setq file (apply '(lambda (a b c) (strcat a b ".pdf")) (fnsplitl (apply 'strcat (mapcar 'getvar '(dwgprefix dwgname))))))

Share this post


Link to post
Share on other sites
rlx
2c - I'd store the file lisp variable like this:

(setq file (apply '(lambda (a b c) (strcat a b ".pdf")) (fnsplitl (apply 'strcat (mapcar 'getvar '(dwgprefix dwgname))))))

 

make it 20 dollar cause never seen this construct :? haha

Share this post


Link to post
Share on other sites
Grrr
make it 20 dollar cause never seen this construct :? haha

 

Haha.. cheers! :beer:

Share this post


Link to post
Share on other sites
BIGAL

There is a lot more you can do like plot a range of layouts to pdf's, make a single pdf of a range etc. You will need to down load and install ghostscript seperately for the combine routine.

GETVALS3.lsp

plotA3Pdfrange2.lsp

mergepdfs.lsp

Share this post


Link to post
Share on other sites
rlx

AH! now the biting makes sense! fnsplitl is a real function....

NowTheBitingMakesSense.jpg

Share this post


Link to post
Share on other sites
GregGleason
GregGleason,

 

try this.

 

 

(defun c:Test()
     (vl-load-com)
   
     (if (setq filename (getfiled "Save File Location" ""  "pdf" 1))
 (progn 
     (command "-plot" "yes" "" "DWG To PDF.pc3" "ANSI expand B (11.00 x 17.00 Inches)"
         "inches" "landscape" "yes" "Extents"
         "fit" "center" "yes" "monochrome.ctb" "yes" "a" filename "no" "yes")
               )
         )
     )

 

That worked great BrianTFC! I appreciate the help.

 

Greg

Share this post


Link to post
Share on other sites
GregGleason
Probably Brian's suggestion will work so just show where you went wrong:

 

to make the file name try his :

 (setq file (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".pdf")) 

also :

 (setq s (getstring (strcat "\nEnter Filename for Save <" (getvar 'file) "> : "))) 

file is not a system variable so it should be :

 (setq s (getstring (strcat "\nEnter Filename for Save <" file "> : "))) 

hope this helps

 

gr. Rlx

 

I appreciate you taking the time to show me these. THIS is how I learn. Kudos to you, rlx!

 

Greg

Share this post


Link to post
Share on other sites
rlx

Glad both me and BrianTFC were able yo help you

 

:beer:

Share this post


Link to post
Share on other sites
BrianTFC

Greg,

 

Your welcome Greg!! I've leaned a lot from everyone on this site and I'm glad I could finally help someone on here.

 

Brian

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×