jjatho Posted July 10, 2013 Share Posted July 10, 2013 Here's the code: (defun C:PDFPUBLISH() (command "ctab" "model") (command "_autoPUBLISH" "") (setq acadObject (vlax-get-acad-object)) (setq acadDocument (vla-get-ActiveDocument acadObject)) (setq dProps (vlax-get-Property acadDocument 'SummaryInfo)) (vla-GetCustomByKey dProps "project" 'project) (vla-GetCustomByKey dProps "revision" 'revisionnumber) (command "ctab" "model") (setq time (rtos (getvar "CDATE") 2 6)) (setq yr (substr time 1 4)) (setq mo (substr time 5 2)) (setq dy (substr time 7 2)) (setq hr (substr time 10 2)) (setq mn (substr time 12 2)) (setq sc (substr time 14 2)) (setq dwgname (GETVAR "dwgname")) (setq len (strlen dwgname)) (setq dwgname (substr dwgname 1 (- len 4))) (setq oldpdfname (strcat (getvar "dwgprefix") "DWF and PDF\\" dwgname ".pdf")) (setq newpdfname (strcat (getvar "dwgprefix") "DWF and PDF\\" project " - rev" revisionnumber " - " yr "-" mo "-" dy "@" hr "." mn "." sc ".pdf")) (vl-file-rename oldpdfname newpdfname) (princ) ) ;End defun PDFPUBLISH Basically I have the file structure on the new computer set identical to the old one, yet this script doesn't produce a pdf file the way it used to. Now I end up with a different filetype (Can't recall type off the top of my head) that is placed in the same folder as the .dwg instead of the "DWF and PDF" folder located where the .dwg is. Unfortunately I'm on a computer without AutoCAD right now so I can't test it, but I suspect it has to do with the _autoPUBLISH command and some kind of settings related to it. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 10, 2013 Share Posted July 10, 2013 Try this untested program: (defun c:pdfpublish ( / sum old pro pth rev ) (setvar 'ctab "Model") (setq sum (vla-get-summaryinfo (vla-get-activedocument (vlax-get-acad-object)))) (if (and (setq pro (getcustombykey sum "project")) (setq rev (getcustombykey sum "revision")) ) (progn (vl-mkdir (setq pth (strcat (getvar 'dwgprefix) "DWF and PDF"))) (command "_.autopublish" "_L" pth) (if (findfile (setq old (strcat pth "\\" (vl-filename-base (getvar 'dwgname)) ".pdf"))) (vl-file-rename old (strcat pth "\\" pro " - rev" rev " - " (menucmd "m=$(edtime,$(getvar,date),yyyy-mo-dd@hh.mm.ss)") ".pdf")) (princ (strcat "\nFile \"" old "\" not found.")) ) ) (princ "\nCustom properties not found.") ) (princ) ) (defun getcustombykey ( sum key / rtn ) (vl-catch-all-apply 'vla-getcustombykey (list sum key 'rtn)) rtn ) (vl-load-com) (princ) Quote Link to comment Share on other sites More sharing options...
jjatho Posted July 10, 2013 Author Share Posted July 10, 2013 Thanks but I found the solution. Since it was a new AutoCAD installation I didn't have my old settings quite right. Under options, then Plot and Publish, then Automatic Publish Settings I changed everything over to match what I had before and my original script works just fine now. Thanks though! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 10, 2013 Share Posted July 10, 2013 Nevertheless, I recommend that you look over my code as there are several improvements which may be made to your code with regards to error trapping and improving the code concision & readability. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.