Author Topic: Keeping Track of Plotting Paper  (Read 8317 times)

0 Members and 1 Guest are viewing this topic.

danny

  • Guest
Keeping Track of Plotting Paper
« Reply #30 on: January 27, 2005, 01:56:53 PM »
ok, I got this from theswamp a while back. This routine was written by Craig and its a lisp that works with a dcl file to track plots.  I've just tested it out any got an error message about not finding a newdate block.  Maybe someone can help take a look at this.
Code: [Select]
;;; plotlog.lsp
;;; Usage: This routine was designed to keep a log of all plots by writing the
;;; selections to a text file at G:\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
;;;
;;; CAD Program(s): AutoCAD 14+
;;;
(defun c:plotlog (/ cmd paper billable cm dm task)
  (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 "no" "(progn(setq dm $key)(activate))")
  (action_tile "yes" "(progn(setq dm $key)(go_hpconfig)(activate))")
  (action_tile "bond" "(setq paper $key)")
  (action_tile "vellum" "(setq paper $key)")
  (action_tile "mylar" "(setq paper $key)")
  (action_tile "0" "(progn(setq task $key)(deactivate))")
  (action_tile "1" "(progn(setq task $key)(deactivate))")
  (action_tile "2" "(progn(setq task $key)(deactivate))")
  (action_tile "3" "(progn(setq task $key)(deactivate))")
  (action_tile "4" "(progn(setq task $key)(deactivate))")
  (action_tile "5" "(progn(setq task $key)(deactivate))")
  (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)

Code: [Select]
dcl_settings : default_dcl_settings { audit_level = 3; }

plotlog : dialog {
    label = "Plot Log";
    : boxed_row {
        label = "Check your HPCONFIG";
        : button {
            label = "No";
            mnemonic = "N";
            key = "no";
        }
        : button {
            label = "Yes";
            mnemonic = "Y";
            key = "yes";
        }
    }
    : boxed_radio_row {
        label = "Select Paper Grade";
        mnemonic = "S";
        : radio_button {
            label = "Bond";
            mnemonic = "B";
            key = "bond";
            is_enabled = false;
        }
        : radio_button {
            label = "Vellum";
            mnemonic = "V";
            key = "vellum";
            is_enabled = false;
        }
        : radio_button {
            label = "Mylar";
            mnemonic = "M";
            key = "mylar";
            is_enabled = false;
        }
    }
    : boxed_row {
        label = "Select Task Number";
        mnemonic = "T";
        : radio_row {
            value = "Tsk";
            : radio_button {
                label = ".0";
                key = "0";
                is_enabled = false;
            }
            : radio_button {
                label = ".1";
                key = "1";
                is_enabled = false;
            }
            : radio_button {
                label = ".2";
                key = "2";
                is_enabled = false;
            }
            : radio_button {
                label = ".3";
                key = "3";
                is_enabled = false;
            }
            : radio_button {
                label = ".4";
                key = "4";
                is_enabled = false;
            }
            : radio_button {
                label = ".5";
                key = "5";
                is_enabled = false;
            }
            : radio_button {
                label = "Other";
                mnemonic = "O";
                key = "other";
                is_enabled = false;
            }
        }
    }
    : 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;
        }
    }
}

whdjr

  • Guest
Keeping Track of Plotting Paper
« Reply #31 on: January 27, 2005, 02:37:47 PM »
You have to have the "newdate2" block in the file you are running it on.

danny

  • Guest
Keeping Track of Plotting Paper
« Reply #32 on: January 27, 2005, 03:43:45 PM »
sorry...didn't insert the intire code.
Code: [Select]
;;; plotlog.lsp
;;; Usage: This routine was designed to keep a log of all plots by writing the
;;; selections to a text file at G:\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
;;;
;;; CAD Program(s): AutoCAD 14+
;;;
(defun c:plotlog (/ cmd paper billable cm dm task)
  (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 "no" "(progn(setq dm $key)(activate))")
  (action_tile "yes" "(progn(setq dm $key)(go_hpconfig)(activate))")
  (action_tile "bond" "(setq paper $key)")
  (action_tile "vellum" "(setq paper $key)")
  (action_tile "mylar" "(setq paper $key)")
  (action_tile "0" "(progn(setq task $key)(deactivate))")
  (action_tile "1" "(progn(setq task $key)(deactivate))")
  (action_tile "2" "(progn(setq task $key)(deactivate))")
  (action_tile "3" "(progn(setq task $key)(deactivate))")
  (action_tile "4" "(progn(setq task $key)(deactivate))")
  (action_tile "5" "(progn(setq task $key)(deactivate))")
  (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
             )
  (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 "G:\plotlog.txt" "a"))
  ;(setq fil (getfiled "Select Plot Log file :" "G:\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 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

danny

  • Guest
Keeping Track of Plotting Paper
« Reply #33 on: January 27, 2005, 03:48:15 PM »
whdjr
Quote
You have to have the "newdate2" block in the file you are running it on.

 :?  don't know what the block is for.  tried to create a dummy block with the name newdate2 but it still don't work.  It must be looking for a certain attribute within the block.

dubb

  • Swamp Rat
  • Posts: 1105
Keeping Track of Plotting Paper
« Reply #34 on: January 27, 2005, 04:06:18 PM »
great...ive loaded this routine. but how do load it in cad...do i just copy the code and save it as plotlog.lsp and load it in cad? i had done it this way, but it seems like its not writing the file plotlog.txt. althogh i have already changed the G:\ to my drive on the network. is this the right way?

danny

  • Guest
Keeping Track of Plotting Paper
« Reply #35 on: January 27, 2005, 06:20:19 PM »
I'm stuck too!  What CAD version are you using?

dubb

  • Swamp Rat
  • Posts: 1105
Keeping Track of Plotting Paper
« Reply #36 on: January 27, 2005, 07:04:00 PM »
im using 2004

danny

  • Guest
Keeping Track of Plotting Paper
« Reply #37 on: January 27, 2005, 07:08:24 PM »
mee too..
I've loaded the lisp and I got the dcl in the search path, but the command needs a newdate2 block.  Thats as far as I got.  No plotlog.txt yet.

dubb

  • Swamp Rat
  • Posts: 1105
Keeping Track of Plotting Paper
« Reply #38 on: February 03, 2005, 01:25:21 PM »
has anybody took a look at this one? i wish i knew enough to get this program working. it seems like  a very useful tool.

whdjr

  • Guest
Keeping Track of Plotting Paper
« Reply #39 on: February 04, 2005, 09:14:45 AM »
It's never gonna work without the block that is missing.  The program is missing "NEWDATE2" block that has attributes in it the code retreives.  If you don't have the block then you should probably contact the author and ask about the block.  The author's name is at the beginning of the code. :)

Craig

  • Guest
Keeping Track of Plotting Paper
« Reply #40 on: February 05, 2005, 12:07:03 AM »
I'm so sorry guys, the program was posted for you to make adjustments to fit your own needs. I'm sorry about this...my bad.

Craig

  • Guest
Keeping Track of Plotting Paper
« Reply #41 on: February 05, 2005, 12:14:18 AM »
Okay, here is a link to the file.
http://www.theswamp.org/lilly_pond/craig/newdate2.dwg?nossi=1

We have a program when we setup our drawings that will automatically insert the newdate2.dwg file onto our plot sheets. You can write one yourself or insert it manually to see the program work. Again, my bad on that. I posted that awhile back....you did some digging to find it, November 3rd, 2003  :D

Craig

  • Guest
Keeping Track of Plotting Paper
« Reply #42 on: February 05, 2005, 12:16:35 AM »
BTW, do understand it's setup to gather our job number, sheet size, date and a few other items. You have to customize for your own needs.

Also, you will need to create a plotlog.txt file and put it in a path you specify within your own network. Look for the follwing lines within the code and you will have to adjust to fit your requirements.

(setq fil1 (open "H:\plotlog.txt" "a"))

In our text file we keep this header across the top:
Job Number - Paper Used - Sheet Size - Square Feet - Month - Day - Year - Task Number

Craig

  • Guest
Keeping Track of Plotting Paper
« Reply #43 on: February 05, 2005, 12:27:37 AM »
Make sure when doing this you will have two programs, plotlog.lsp and plotlog.dcl. The DCL file is this:
Code: [Select]
dcl_settings : default_dcl_settings { audit_level = 3; }

plotlog : dialog {
    label = "Plot Log";
    : boxed_row {
        label = "Check your HPCONFIG";
        : button {
            label = "No";
            mnemonic = "N";
            key = "no";
        }
        : button {
            label = "Yes";
            mnemonic = "Y";
            key = "yes";
        }
    }
    : boxed_radio_row {
        label = "Select Paper Grade";
        mnemonic = "S";
        : radio_button {
            label = "Bond";
            mnemonic = "B";
            key = "bond";
            is_enabled = false;
        }
        : radio_button {
            label = "Vellum";
            mnemonic = "V";
            key = "vellum";
            is_enabled = false;
        }
        : radio_button {
            label = "Mylar";
            mnemonic = "M";
            key = "mylar";
            is_enabled = false;
        }
    }
    : boxed_row {
        label = "Select Task Number";
        mnemonic = "T";
        : radio_row {
            value = "Tsk";
            : radio_button {
                label = ".0";
                key = "0";
                is_enabled = false;
            }
            : radio_button {
                label = ".1";
                key = "1";
                is_enabled = false;
            }
            : radio_button {
                label = ".2";
                key = "2";
                is_enabled = false;
            }
            : radio_button {
                label = ".3";
                key = "3";
                is_enabled = false;
            }
            : radio_button {
                label = ".4";
                key = "4";
                is_enabled = false;
            }
            : radio_button {
                label = ".5";
                key = "5";
                is_enabled = false;
            }
            : radio_button {
                label = "Other";
                mnemonic = "O";
                key = "other";
                is_enabled = false;
            }
        }
    }
    : 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;
        }
    }
}

The other should be saved as plotlog.lsp

Craig

  • Guest
Keeping Track of Plotting Paper
« Reply #44 on: February 05, 2005, 07:48:40 AM »
I just thought about this as well this early Saturday morning, we have our plot button/icon setup as such:

^C^Cplotlog;_plot

That way, you force the user to activate the plotlog.lsp first and then after they hit OK or Cancel it will go onto the regular plot dialogue.

The other thing about the plotlog.dcl, this is custom to what our needs are so what we do is select the paper we're using and the task number, being one job number for us might have 3-4 tasks under...ex. would be a job number 25001 and in the plotlog it would show up as 25001 or 25001.0, can't remember  :oops: , and if we have some other task under 25001 we would select the number given it and in the plotlog file you would see 25001.3, 25001.4 etc...

Hope this helps most of you out.