Jump to content

AutoLISP Script worked on old computer, doesn't function the same on new computer.


jjatho

Recommended Posts

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...