TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Andrea on March 11, 2009, 02:31:02 PM

Title: Get Previous PLOT printer name
Post by: Andrea on March 11, 2009, 02:31:02 PM
Hi all,..

anyone know how to get the Printer name of the previous PLOT ?

I've made this code below....but not seem to work.

Code: [Select]
(defun gen_get_lastprinter (/ regkey)
  (setq regkey (strcat "HKEY_CURRENT_USER\\"
                       (vlax-product-key)
                       "\\Profiles\\"
                       (getvar "CPROFILE")
                       "\\Previous plot settings"
               )
  )
  (if (eq (getvar "tilemode") 1)
    (setq lastprinter (vl-registry-read (strcat regkey "\\Model") "Cfg Name"))
    (setq lastprinter (vl-registry-read (strcat regkey "\\Layout") "Cfg Name"))
  )
  lastprinter
)
Title: Re: Get Previous PLOT printer name
Post by: T.Willey on March 11, 2009, 02:59:18 PM
Works for me.

Command: (gen_get_lastprinter)
"z-PdfWriter.pc3"
Title: Re: Get Previous PLOT printer name
Post by: Andrea on March 11, 2009, 03:28:41 PM
Works for me.

Command: (gen_get_lastprinter)
"z-PdfWriter.pc3"

Sorry,..

I mean...the code work. but the result is false.
Title: Re: Get Previous PLOT printer name
Post by: Jeff_M on March 11, 2009, 04:09:34 PM
Andrea, the most recent settings in the Registry are from the last time Acad closed. Any plot done in the current session will not be included in that info until Acad closes. I don't know of any way to get this data at this time.

You could write your own reactor that saves the data for your use whenever the Plot command is fired......
Title: Re: Get Previous PLOT printer name
Post by: Andrea on March 11, 2009, 09:53:06 PM
thanks Jeff,

The way I think is to read the CSV log file .
Code: [Select]
(defun gen_get_lastprinter (/ logfilename plotlogname ofile rl)
  (if (vl-string-search "FR" (strcase (ver)))
    (setq logfilename "Journal de tracé et de publication.CSV")
    (setq logfilename "PlotAndPublishLOG.csv")
  )
  (setq plotlogname (strcat (getvar "LOGFILEPATH") logfilename))
  (if (and plotlogname (findfile plotlogname))
    (progn
      (setq ofile (open (findfile plotlogname) "r"))
      (setq rl (read-line ofile))
           (while rl
             (if (eq (vl-princ-to-string (read rl)) "SH")
               (setq lastrl rl)
             )
             (setq rl (read-line ofile))
           )
           (close ofile)
    )
  )
(nth 14 (CSVparseLisst lastrl))
)

(defun CSVparseLisst (h / symb1 it)
(setq h (vl-string-right-trim "\"" (vl-string-left-trim "\"" h)))
(while (setq symb1 (vl-string-search "," h))
  (setq it (append it (list (substr h 1 (1- symb1)))))
  (setq h (substr h (+ symb1 3)))
)
  it
)


and assure that the options is activated.

Code: [Select]
(vl-load-com)
(setq AcadOutputPref (vla-get-Output (vla-get-Preferences (vlax-get-acad-object))))
(vla-put-ContinuousPlotLog AcadOutputPref :vlax-true)
(vla-put-AutomaticPlotLog AcadOutputPref :vlax-true)

can't find another way.. :?