Search the Community
Showing results for tags 'read csv'.
-
Hi all, my lisp knowledge is very limited so I was hoping someone could help mw with this. I have a lisp which I copied from a Autodesk forum (https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-to-pdf-lisp-routine/td-p/5704455) and tweaked a little to suit my needs. It basically plot all layout tabs to PDF (with revision letter at the end of the pdf name). It works just fine. Now, what I want it to do is to instead of printing all layouts, read a csv file "title_block.csv" and only plot to PDF layouts named in that csv file (column B) starting from cell B2. It would be similar to what Lee Mac's UpdateTitleBlockV1-9 does to update title blocks. Any help would be much appreciated Cheers #(vl-load-com) (defun c:demo (/ hms:get_atts filename hnd lst lst1 name otab path ss) (defun hms:get_atts (enm / att obj) (if (or (and (eq (type enm) 'ENAME) (setq obj (vlax-ename->vla-object enm)) (eq (vla-get-hasattributes obj) :vlax-true) ) (and (eq (type enm) 'VLA-OBJECT) (setq obj enm) (eq (vla-get-hasattributes obj) :vlax-true) ) ) (mapcar '(lambda (att) (cons (vla-get-TagString att) (vla-get-TextString att)) ) (vlax-invoke obj "GetAttributes") ) ) ) ;;(cond ((setq path (acet-ui-pickdir "Select directory" (getvar "dwgprefix"))) ; check that pdf directory exists (cond ((setq dwgpre (strcat (getvar "dwgprefix") "PDF")) (if (= (vl-file-directory-p dwgpre) nil) (vl-mkdir dwgpre) ) (setq pdfname (strcat (vl-filename-base (getvar "dwgname")))) ;----------------------------------------------------------------------- (setq otab (getvar 'CTAB)) (foreach layt (layoutlist) (setvar 'CTAB layt) (if (setq ss (ssget "_X" (list '(0 . "INSERT") '(2 . "A1 TITLE NCL - new logo") '(66 . 1) (cons 410 (getvar 'CTAB))))) (progn (setq hnd (ssname ss 0) lst (hms:get_atts hnd) ;lst1 '("DRAWING_NUMBER" "SHEET_NUMBER" "REVISION_NUMBER" "SHEET_SIZE") lst1 '("RV") name "" ) (foreach n lst1 (if (setq a (assoc n lst)) (setq name (strcat name "-" (cdr a))) ) ) (setq sht (strcat(getvar "ctab"))) (setq filename (strcat dwgpre "\\" pdfname "-" sht " Rev " (vl-string-left-trim "-" name) ".pdf")) ;(command "_.-export" "_PDF" "_C" "_YES" "ISO full bleed A3 (420.00 x 297.00 MM)" "_M" "_L" "1:2" "_YES" "A3.ctb" "_YES" filename) (command "_.-PLOT" "Y" ;Detailed plot configuration? [yes/no] Layt ;Enter Layout name or [?],layout1: "Dwg To PDF.pc3" ;Enter an output device name "ISO full bleed A3 (420.00 x 297.00 MM)" ;Enter paper size "M" ;Paper units: "M" for mm "L" ;Enter drawing orientation: "L" for Landscaping "N" ;Upside down? "N" "E" ;"E" for extents "1:2" ;Plot scale: Custom "1:2" "C" ;Counter "c" "Y" ;Plot Style? "y" "A3.ctb" ;Enter plot style: "A3.ctb" "Y" ;Plot line weights? "N" ;plot line scaling? "N" ;Paper space first? "N" ;Hide? filename ;Directory to save "N" ;save changes to page setup? "Y" ;proceed with plot? ); command ) ) ) (setvar 'CTAB otab) ) ) (princ) )#