Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Please could somebody help me figure out why my script won't run. I think it has something to do with the
cond
function
(defun c:PDFPRINT ( / atb_blk dwgno rev _cetype) (initget "Current All") (setq _cetype (cond ((getkword "\nEnter print option [Current layout/All layouts] <Current>: ")) ("Current"))) (vl-load-com) (if (not path) (progn ; then clause (setq path (LM:browseforfolder "Select Folder" "" 0)) ); end progn path ) ;end if ;;; (if (setq atb_blk (car (entsel))) ;;; (progn (cond ((= _cetype "Current") (if (setq atb_blk (car (entsel))) (setq dwgno (LM:vl-getattributevalue atb_blk "SUBEPCDWGNO.")) (setq rev (LM:vl-getattributevalue atb_blk "REV")) (COMMAND "ZOOM" "E") (setq psize (papersize)) (princ psize) (COMMAND "-PLOT" "Y" "" "DWG To PDF.pc3" "ISO A0 (841.00 x 1189.00 MM)" "" "" "" "" "" "" "Y" "" "Y" "N" "N" "N" (strcat path "\\" dwgno " Rev "rev ".pdf") ;;""; Name of file "N" "y" ) );end if ) ((= _cetype "All") (setq atb_blk (vla-get-effectivename (vlax-ename->vla-object (car (entsel "\nSelect block: "))))) (foreach lay (layoutlist) (setvar "ctab" lay) (COMMAND "LAYOUT" "SET" lay) (COMMAND "ZOOM" "E") (if (setq ss (ssget "x" (list (cons 0 "INSERT") (cons 2 atb_blk)))) (progn (setq dwgno (LM:vl-getattributevalue atb_blk "SUBEPCDWGNO.")) (setq rev (LM:vl-getattributevalue atb_blk "REV")) (COMMAND "-PLOT" "Y" "" "DWG To PDF.pc3" "ISO A0 (841.00 x 1189.00 MM)" "" "" "" "" "" "" "Y" "" "Y" "N" "N" "N" (strcat path "\\" dwgno " Rev "rev ".pdf"); Name of file "N" "y" ) ) ) ); foreach ) );end cond (princ "\nNothing selected") ) (princ) ) (defun LM:browseforfolder ( msg dir bit / err fld pth shl slf ) (setq err (vl-catch-all-apply (function (lambda ( / app hwd ) (if (setq app (vlax-get-acad-object) shl (vla-getinterfaceobject app "shell.application") hwd (vl-catch-all-apply 'vla-get-hwnd (list app)) fld (vlax-invoke-method shl 'browseforfolder (if (vl-catch-all-error-p hwd) 0 hwd) msg bit dir) ) (setq slf (vlax-get-property fld 'self) pth (vlax-get-property slf 'path) pth (vl-string-right-trim "\\" (vl-string-translate "/" "\\" pth)) ) ) ) ) ) ) (if slf (vlax-release-object slf)) (if fld (vlax-release-object fld)) (if shl (vlax-release-object shl)) (if (vl-catch-all-error-p err) (prompt (vl-catch-all-error-message err)) pth ) ) (defun LM:vl-getattributevalue ( blk tag ) (setq tag (strcase tag)) (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att))) (vlax-invoke (vlax-ename->vla-object blk) 'GetAttributes)) ) (defun papersize (/ psn scale) (setq psn (member '(100 . "AcDbPlotSettings") (dictsearch (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_LAYOUT"))) (getvar "ctab") ) ) ) (if (= (caadr psn) 1) ; Page Setup Name exist (progn (setq scale (if (= 0 (cdr (assoc 72 psn))) 25.4 1.0 ) ) (strcat (rtos (/ (cdr (assoc 44 psn)) scale) 2 2) " x " (rtos (/ (cdr (assoc 45 psn)) scale) 2 2) ) ) ) )
Solved! Go to Solution.