Even better, here is our latest code you can replace the older one with. This one has also been re-written to ignore the program altogether if the NEWDATE stamp is missing. Basically, the box won't pop-up when we try to plot drawings we get from architects.
Plotlog.lsp
;;; plotlog.lsp
;;; Usage: This routine was designed to keep a log of all plots by writing the
;;; selections to a text file at H:\plotlog.txt. It inserts the following into
;;; the plot log:
;;; Job Number - Paper Used - Sheet Size - Square Feet - Month - Day - Year - Task Number
;;;
;;; Written By: Craig Boggan
;;; Created: February 12, 2003
;;;
;;; Updated: April 30, 2003
;;; Added task number to job number
;;; Updated: September 1, 2004
;;; Added the lines of code to ignore entire program if the newdate block is not on the drawing
;;; This keeps from having to select an extra box when plotting architects drawings just for viewing
;;;
;;; CAD Program(s) Tested: AutoCAD 14+
;;;
(defun c:plotlog (/ cmd paper billable cm dm task oPlot number_plots)
(setq ndate (ssget "x" '((0 . "INSERT") (2 . "NEWDATE2"))))
(if (= ndate nil)
(no_date1)
(plog)
);;end if
(princ)
);;end plotlog
(defun no_date1 ()
(princ "Drawing not setup to use Plotlog ")
);;end defun no_date
(defun plog ()
(VL-LOAD-COM)
(OR KBSG:ACADAPP (SETQ KBSG:ACADAPP (VLAX-GET-ACAD-OBJECT)))
(OR KBSG:ACTIVEDOC (SETQ KBSG:ACTIVEDOC (VLA-GET-ACTIVEDOCUMENT KBSG:ACADAPP)))
(setq oPlot (vla-get-plot KBSG:ACTIVEDOC ))
(vlax-dump-object oPlot T)
(setq number_plots (vla-get-NumberofCopies oPlot))
(setq cmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
;;;;;;Begin dialog box
(setq dcl_id (load_dialog "plotlog.dcl"))
(if (not (new_dialog "plotlog" dcl_id))
(exit);;if dialog not found..exit
);;end if
(action_tile "bond" "(setq paper $key)")
(action_tile "vellum" "(setq paper $key)")
(action_tile "mylar" "(setq paper $key)")
(action_tile "0" "(setq task $key)")
(action_tile "1" "(setq task $key)")
(action_tile "2" "(setq task $key)")
(action_tile "3" "(setq task $key)")
(action_tile "4" "(setq task $key)")
(action_tile "5" "(setq task $key)")
(action_tile "other" "(progn(setq insert_other $key)(activate_other))")
(action_tile "insert" "(setq task $value)")
(action_tile "cancel" "(progn(setq cm $key)(done_dialog))")
(action_tile "ok" "(progn(setq cm $key)(done_dialog))")
(start_dialog)
(unload_dialog dcl_id)
;;;;;;End dialog box
(if (= cm "cancel")
(princ "\nPlotlog aborted by user ")
);;end if
(if (= cm "ok")
(check_newdate2);;if OK is selected on dialog box go to sub-routine check_newdate2
);;end if
(setvar "cmdecho" cmd)
(princ)
);;end defun plotlog
;;-------------------------------------------------------------
;; This checks to make sure the newdate stamp is on the drawing
;; before going any further. If it's not found, the program will
;; end with no errors showing across the command line
;;--------------------------------------------------------------
(defun check_newdate2 (/ find_block)
(setq find_block (ssget "x" '((0 . "INSERT") (2 . "NEWDATE2"))))
(if (= find_block nil)
(alert "\nNewdate block not found...Exiting ")
);;end if
(if (/= find_block nil)
(check_box)
);;end if
);;end defun check_newdate2
(defun go_hpconfig ()
(c:hpconfig)
);;end defun go_hpconfig
;;-------------------------------------------------------------
;; This checks to see which radio buttons were selected on the
;; dialog box and sets the appropriate values
;;--------------------------------------------------------------
(defun check_box ()
(if (= paper "bond")
(progn
(setq paper "Bond")
(start_plotlog)
);;end progn
);;end if
(if (= paper "vellum")
(progn
(setq paper "Vellum")
(start_plotlog)
);;end progn
);;end if
(if (= paper "mylar")
(progn
(setq paper "Mylar")
(start_plotlog)
);;end progn
);;end if
);;end defun check_box
;;---------------------------------------------------------
;; This is section is where the program gathers most of its
;; data and writes it to a plotlog text file
;;---------------------------------------------------------
(defun start_plotlog (/ dwg_name check_date job_number index
fb1 fb2 sheet_size count
sheet_length sheet1 sheet2
square_feet plotlog_line
fil f date1 year
month day date2 time
time1 time2 time3
)
(repeat number_plots
(setq dwg_name (getvar "dwgname"))
(setq check_date (substr dwg_name 1 1));;this finds out if it was in 1999 or 2000+
(if (= check_date "9")
(setq job_number (strcat "9" (substr dwg_name 2 4)));;this creates the job number
);;end if
(if (= check_date "0")
(setq job_number (strcat "2" (substr dwg_name 2 4)));;this creates the job number
);;end if
(setq index 0)
(setq fb1 (entget (ssname find_block index)));;gets first list from block
(setq fb2 (entget(entnext(entnext(entnext(cdr(assoc -1 fb1)))))));;gets sub-list from same block to find sheet size
(setq sheet_size (cdr(assoc 1 fb2)))
;;---------------------------------------------------------
;; This section find the "," between the sheet size numbers
;;---------------------------------------------------------
(setq sf sheet_size
count 1
);end setq
(while
(not
(wcmatch (substr sf count 2) "*`,")
);end not
(setq count (1+ count))
);end while
;;-------------------------
;; End of searching for ","
;;-------------------------
(setq sheet_length (strlen sheet_size));;total length of sheet size extracted
(setq sheet1 (*(atof(substr sheet_size 1 count))));;extracts out first number
(setq sheet2 (atof(substr sheet_size (+ count 2) sheet_length)));;extracts out second number
(setq square_inch (/(* sheet1 sheet2)12));;multiplies two sheet numbers then divides by 12 to get square inch
(if (= paper "Bond")
(setq price (strcat "$"(rtos(* square_inch 0.047)2 2)))
);;end if
(if (= paper "Vellum")
(setq price (strcat "$"(rtos(* square_inch 0.11)2 2)))
);;end if
(if (= paper "Mylar")
(setq price "Unknown")
);;end if
(setq square_feet (rtos(/(* sheet1 sheet2)12)))
(setq sheet_size (strcat (rtos sheet1 2 0)"x"(rtos sheet2 2 0)))
(setq date1 (rtos(getvar "cdate")2 0))
(setq year (substr date1 1 4));; Extracts out the year from the CDATE variable
(setq date1 (substr date1 5 8))
(setq month (substr date1 1 2));; Extracts out the month by number from the CDATE variable
;; Check what month is active at the time of extraction
(if (= month "01")
(setq month "January")
)
(if (= month "02")
(setq month "February")
)
(if (= month "03")
(setq month "March")
)
(if (= month "04")
(setq month "April")
)
(if (= month "05")
(setq month "May")
)
(if (= month "06")
(setq month "June")
)
(if (= month "07")
(setq month "July")
)
(if (= month "08")
(setq month "August")
)
(if (= month "09")
(setq month "September")
)
(if (= month "10")
(setq month "October")
)
(if (= month "11")
(setq month "November")
)
(if (= month "12")
(setq month "December")
)
(setq day (substr date1 3 4));; Extracts out the day from the CDATE variable
(setq time1 (rtos(getvar "cdate")2 4))
(setq time2 (strlen time1))
(setq time3 (substr time1 (- time2 3) time2))
(setq time (strcat(substr time3 1 2)":"(substr time3 3 4)))
(setq job_task_number (strcat job_number "." task))
(setq plotlog_line (strcat job_task_number "," paper "," sheet_size "," square_feet "," month " " day " " year "," time "," price))
(setq fil1 (open "h:/plotlog.txt" "a"))
;(setq fil (getfiled "Select Plot Log file :" "h:\plotlog" "txt" 8))
(if (= fil1 nil)
(progn
(princ "\nPlotlog.txt is missing from H:\ drive ")
(exit)
);;end progn
);;end if
;(setq f (open fil "a"))
(write-line plotlog_line fil1)
(close fil1)
);;end repeat
);;end defun start_plotlog
(defun activate ()
(if (/= dm nil);if selected
(progn
(mode_tile "bond" 0);enable
(mode_tile "vellum" 0);enable
(mode_tile "mylar" 0);enable
(mode_tile "0" 0);enable
(mode_tile "1" 0);enable
(mode_tile "2" 0);enable
(mode_tile "3" 0);enable
(mode_tile "4" 0);enable
(mode_tile "5" 0);enable
(mode_tile "other" 0);enable
);;end progn
);;end if
);end activate
(defun activate_other ()
(if (/= insert_other nil);if selected
(progn
(mode_tile "insert" 0);enable
)
(progn
(mode_tile "insert" 1);disable
)
);;end if
);end activate_other
(defun deactivate ()
(mode_tile "insert" 1)
);;end defun deactivate
Plotlog.dcl
dcl_settings : default_dcl_settings { audit_level = 3; }
plotlog : dialog {
label = "Plot Log";
: boxed_radio_row {
label = "Select Paper Grade";
mnemonic = "S";
: radio_button {
label = "Bond";
mnemonic = "B";
key = "bond";
}
: radio_button {
label = "Vellum";
mnemonic = "V";
key = "vellum";
}
: radio_button {
label = "Mylar";
mnemonic = "M";
key = "mylar";
}
}
: boxed_row {
label = "Select Task Number";
mnemonic = "T";
: radio_row {
value = "Tsk";
: radio_button {
label = ".0";
key = "0";
}
: radio_button {
label = ".1";
key = "1";
}
: radio_button {
label = ".2";
key = "2";
}
: radio_button {
label = ".3";
key = "3";
}
: radio_button {
label = ".4";
key = "4";
}
: radio_button {
label = ".5";
key = "5";
}
: radio_button {
label = "Other";
mnemonic = "O";
key = "other";
}
}
}
: boxed_row {
alignment = right;
fixed_width = true;
width = 10;
: edit_box {
label = "Task Number";
mnemonic = "I";
key = "insert";
alignment = centered;
fixed_width = true;
width = 10;
is_enabled = false;
}
}
: row {
key = "YN";
alignment = centered;
fixed_width = true;
width = 27;
: button {
label = "Add to Plotlog";
mnemonic = "A";
key = "ok";
fixed_width = true;
width = 10;
}
: button {
label = "Skip Plotlog";
mnemonic = "S";
key = "cancel";
fixed_width = true;
is_cancel = true;
width = 5;
is_default = true;
}
}
}