Author Topic: Report print settings for each layout tab in a directory of drawings  (Read 2924 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
Hey guys,

I have a questions concerning printing. I have to train someone not versed in Autocad how to print out hard copies of our various drawing libraries. These libraries span a 10 year period and are in various states as far as their print settings are concerned. I now have to document this and am looking for an easy way to do so and am wondering if anyone else has written anything to do this already. I would like to output the following information to Excel:

Get all of the layout tab names
Determine if the drawing contains page setups
For each layout tab, What is the active Page setup in the plot dialog.
If the drawing/layout tabs(s) do not contain page setups capture the following settings:

Current Printer Name
Current Plot Style
Current Paper Size
Current Plot Area
Current Fit to Paper check box status
Current Center the plot check Box status

Has anyone written anything that does anything like this?

« Last Edit: April 07, 2009, 11:04:41 AM by Eloquintet »

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Report print settings for each layout tab in a directory of drawings
« Reply #1 on: April 07, 2009, 10:35:52 AM »
Hey guys,

I have a questions concerning printing. I have to train someone not versed in Autocad how to print out hard copies of our various drawing libraries. These libraries span a 10 year period and are in various states as far as their print settings are concerned. I now have to document this and am looking for an easy way to do so and am wondering if anyone else has written anything to do this already. I would like to output the following information to Excel:

Get all of the layout tab names
Determine if the drawings contains page setups
For each layout tab, What is the active Page setup in the plot dialog.
If the drawing/layout tabs(s) do not contain page setups capture the following settings:

Curent Printer Name
Current Plot Style
Current Paper Size
Current Plot Area
Current Fit to Paper check box status
Current Center the plot check Box status

Has anyone written anything that does anything like this?



Maybe this can HELP.
but I did not found a way to capture the number of copies.  ;-(((
Keep smile...

ELOQUINTET

  • Guest
Re: Report print settings for each layout tab in a directory of drawings
« Reply #2 on: April 07, 2009, 11:04:15 AM »
What do you mean when you say number of copies Andrea?

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Report print settings for each layout tab in a directory of drawings
« Reply #3 on: April 07, 2009, 11:22:06 AM »
I mean....if you try to calculate the area printed paper...
there is no way to capture the number of copies...

well..i mean I did not found a way.. :-P

Same with Publish..
see this post
Keep smile...

ELOQUINTET

  • Guest
Re: Report print settings for each layout tab in a directory of drawings
« Reply #4 on: April 07, 2009, 11:47:35 AM »
Number of copies is not the information I am trying to attain so I'm not sure why you mentioned it? Would the routine halt if you can not find all of the values perhaps?

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Report print settings for each layout tab in a directory of drawings
« Reply #5 on: April 07, 2009, 12:26:53 PM »
Number of copies is not the information I am trying to attain so I'm not sure why you mentioned it?
You'r right..I just thought you'r trying to make a program to calculate plot area.

Would the routine halt if you can not find all of the values perhaps?

maybe theses sample can help..
Code: [Select]
;________________________
;;Get the paper size
(setq acadApp (vlax-get-acad-object)
      ThisDwg (vla-get-activedocument acadApp)
      CurLayout (vla-get-activelayout ThisDwg))
(vla-refreshplotdeviceinfo CurLayout)
(vla-getcustomscale CurLayout 'scaleN 'scaleD)
(vla-getpapersize CurLayout 'paperW 'paperH)

scalen
scaleD
paperw
paperH

;__________________________
;;Get the paper size
(vla-get-CanonicalMediaName (vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) 0))


;__________________________
;;Get the paper size
(defun format_papier(imp / def esp n lay lst)
  (if (zerop (getvar "tilemode"))
    (setq esp (vla-get-paperspace (vla-get-ActiveDocument (vlax-get-acad-object))))
    (setq esp (vla-get-modelspace (vla-get-ActiveDocument (vlax-get-acad-object))))
  )
  (setq lay (vla-get-layout esp) def (vla-get-configname lay))
  (if (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-configname (list lay imp))))
    (progn
      (vla-RefreshPlotDeviceInfo lay)
      (setq lst (mapcar '(lambda (x) (vla-GetLocaleMediaName lay x)) (vlax-safearray->list (vlax-variant-value (vla-GetCanonicalMediaNames lay)))))
      (vla-put-configname lay def)
    )
    (setq lst '(""))
  )
  lst
)
(format_papier (vla-get-configname tra))

;_____________________




;;; LastPlot will retrieve the last record set from the plot log
;;; file. This version was written for AutoCAD 2008 and may require
;;; modification before operating correctly on other versions.
;;;
;;; (c) 2007 Bill Kramer - use this at your own risk
;;;
;;;--------------------------------------------------------------------
;;; Start of LastPlot function set.
;;;
;;;
;;; Link up with the primary objects of interest
;;;
(setq AcadObj (vlax-get-acad-object)
      ActiveDoc (vlax-get-property AcadObj 'ActiveDocument)
      )

;;;--------------------------------------------------------------------
;;; GetLayoutObject returns and sets LayoutObject to the currently
;;; active layout.
;;;
(defun GetLayoutObject ()
  (setq LayoutObject
(vlax-get-property
   ActiveDoc
   'ActiveLayout)
   )
  )

;;;--------------------------------------------------------------------
(defun GetPlotConfigs ()
  (setq PlotConfigs
(vlax-get-property
   ActiveDoc
   
   'PlotConfigurations)))
;;;--------------------------------------------------------------------
;;; GetPrefObj returns the prefersences object reference.
(defun GetPrefObj ()
  (setq PrefObj
(vlax-get-property
   AcadObj
   'Preferences)))

;;;--------------------------------------------------------------------
;;; GetPrefOutput returns the preferences object reference.
;;;
(defun GetPrefOutput ()
  (setq PrefOutput
(vlax-get-property
   (getPrefObj)
   'Output)))

;;;--------------------------------------------------------------------
;;; GetPrefFiles returns the file preferences object reference.
;;;
(defun GetPrefFiles ()
  (setq PrefFiles
(vlax-get-property
   (getPrefObj)
   'Files)))

;;;--------------------------------------------------------------------
;;; GetPlotLogName attempts to find the plot log file.
;;;  AutoCAD 2008 - log file is named PlotAndPublishLOG.csv
;;;               - located via preferences PlotLogFilePath setting
;;;
;;; Sets globals PlotLogPath and PlotLogName
;;;
(defun GetPlotLogName ()
  ;;drill into the preferences->output->files for the log file path
  (setq PlotLogPath
(vlax-get-property
   (getPrefFiles)
   'PlotLogFilePath))
  ;;;
  ;;; check if automatic log is enabled
  (if (equal :vlax-true
     (vlax-get-property
       (getPrefOutput)
       'ContinuousPlotLog
       )
     )
    (setq PlotLogName (strcat PlotLogPath "PlotAndPublishLOG.csv"))
    )
  )

;;;--------------------------------------------------------------------
;;; ParseCSV - parses a line read from a COMMA delimited file (CSV).
;;;            Returns a list of the fields
;;;
(defun ParseCSV (LN / sBuf sFlag)
  (setq sBuf "" ;; Initialize as empty string
sFlag (if (= (substr LN 1 1) "\"") ;;string field?
T
nil)
)
  (if sFlag (setq LN (substr LN 2))) ;;skip open quote if string
  ;;
  ;;Process while first character is not a comma
  (while (/= (substr LN 1 1) ",")
    ;;
    (if sFlag ;;string field processing?
      (if (and (/= (substr LN 1 2) "\",") ;;check for end of string
      (/= LN "\"")) ;;last one exception check
(setq sBuf (strcat sBuf ;;add character to sBuf result
   (substr LN 1 1)))
)
      ;; else process non string by adding character to sBuf
      (setq sBuf (strcat sBuf (substr LN 1 1)))
      )
    ;;
    (setq LN (substr LN 2)) ;;Shorten line string LN
    ;;
    ;; Last character in input process check
    (if (= LN "")
      (setq LN ",") ;;set for while loop exit at end of string
      )
    ;;
    ) ;;end of while loop
  ;;
  ;; Check if at the end of the input string.
  ;; If not, build list with result from recursive
  ;;         call with reduced input string.
  ;;
  (if (/= LN ",")
    (cons sBuf    ;;If not done, add sBuf to result from
  (ParseCSV (substr LN 2))) ;;going deeper.
    ;;;
    (list sBuf) ;; If done, return sBuf as list.
    )
  )

;;;--------------------------------------------------------------------
;;;
;;;
(defun C:LastPlot ( / PlotLogName PlotLogPath PlotLog FH LN)
  ;;
  ;; Get the plot log file name, sets PlotLogName variable
  (getPlotLogName)
  ;;
  (if (and PlotLogName (findfile PlotLogName))
    (progn
      (setq FH (open (findfile PlotLogName) "r")) ;;open up for read
      ;;
      ;; Loop through file saving each line in PlotLog
      ;;
      (while (setq LN (read-line FH))
(setq PlotLog
       (cons
(parseCSV LN) ;;Parse text into list data
PlotLog))
)
      ;;
      (close FH) ;;close up the file
      ;;
      ;; we now have the plot log data in a reversed list.
      ;;
      ;; There are THREE lines or records per entry.
      ;; start of the plot, the details, and the finish
      ;;
      ;; First field indicates type of data in record
      ;;  JS - plot starts
      ;;  SH - details
      ;;  JF - plot finish
      ;;  HD - header
      ;;  VR - version number
      ;;
      ;; get the header line
      (setq PlotLogHeader (cdr (assoc "HD" PlotLog)))
      ;;
      ;; since the plot log is currently reversed we can just
      ;; get the first JF/SH/JS records to build our dataset
      ;; it appears all the useful data is in the JS and SH records
      ;; but they need to be merged.
      ;;
      (setq PlotLogLast (mapcar '(lambda (X Y)
   (if (/= X "") X Y))
(cdr (assoc "JS" PlotLog))
(cdr (assoc "SH" PlotLog))
))
      ;;
      (textscr) ;;flip to text view
      ;;
      (prompt "The last plot recorded in the log file...\n")
      (prompt (apply 'strcat
     (mapcar '(Lambda (X Y)
(strcat X " = " Y "\n")
)
     PlotLogHeader
     PlotLogLast
     )
     ))
      )
    )
  (princ)
  )
;;; End of source code - keep on programmin'



Keep smile...

ELOQUINTET

  • Guest
Re: Report print settings for each layout tab in a directory of drawings
« Reply #6 on: April 07, 2009, 01:03:52 PM »
I basically need to write up a document stating what page setup or plot settings to use for all of our libraries then do some training to cover the plot dialog box. I'll take a look at the stuff you posted. Thanks