Jump to content
kleber

Read csv file then plot to PDF

Recommended Posts

kleber

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)
)#

 

Share this post


Link to post
Share on other sites
kleber

Hey BIGAL, thanks for suggestion. I'll have a look at them and see if I can come up with something out of it.

Cheers

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...