BITDRAUGHTY Posted January 23, 2009 Posted January 23, 2009 Does anyone have or know of a lisp that will record every plot that i create and log it in a specific excel spreadsheet so that i can bill the client? thank you Quote
Lee Mac Posted January 23, 2009 Posted January 23, 2009 I'm guessing this can be done by means of a reactor. - (obviously reacting on the "Plot" command), but what kind of data do you want stored in the excel sheet? The document name alone? or more? Thanks Lee Quote
BITDRAUGHTY Posted January 27, 2009 Author Posted January 27, 2009 I'm guessing this can be done by means of a reactor. - (obviously reacting on the "Plot" command), but what kind of data do you want stored in the excel sheet? The document name alone? or more? Thanks Lee The document name date and size of plot mainly. thanks for your response Lee Quote
BITDRAUGHTY Posted January 28, 2009 Author Posted January 28, 2009 The document name date and size of plot mainly. thanks for your response Lee i have this reactor so far and the problem is that since we have upgraded to a newer version of office it has stopped working.i get an error message that says , excel type library not found? my reactor is as follows, (vlr-command-reactor nil '((:vlr-commandWillStart . CollectPlotInfo)) ) (vlr-command-reactor nil '((:vlr-commandEnded . ResetPlotInfo)) ) ;;;(vlr-remove-all) ;************************************************************************************************************************** (defun CollectPlotInfo (calling-reactor endcommandInfo / nlist ) (setq thecommandend (nth 0 endcommandInfo)) (if (= thecommandend "PLOT") (progn (setq Reset nil) (setq n 0) (repeat 20 (setq n (1+ n)) (setq nstring (rtos n 2 0)) (setq nlist (cons nstring nlist)) ) (setq nlist (reverse nlist)) (setq ActiveDoc (vla-get-activedocument (vlax-get-acad-object))) (setq ActiveLayout (vla-get-activelayout ActiveDoc)) (setq Configname (vla-get-Configname activelayout)) (setq CurrPrinter (vla-get-ConfigName activelayout)) (if (wcmatch CurrPrinter "*Plan-Printer*") (alert "The current layout is defaulting to print to the PLAN-PRINTER.\nThe PLAN-PRINTER is for colour plots only.\nIf this plot is black & white change the plot device to OCE PLOTTER.pc3" ) ) (setq Printerlist (vlax-safearray->list (vlax-variant-value (vla-getplotdevicenames activelayout)))) (if (member ConfigName PrinterList) (setq Reset T) ) (setq MediaSize (vla-get-CanonicalMediaName activelayout)) (setq CentrePlot (vla-get-Centerplot activelayout)) (setq Plothidden (vla-get-Plothidden activelayout)) (setq PlotOrigin (vla-get-PlotOrigin activelayout)) (setq PaperUnits (vla-get-PaperUnits activelayout)) (setq PlotRotation (vla-get-PlotRotation activelayout)) (setq PlotType (vla-get-PlotType activelayout)) (if (= PlotType 4)(vla-getwindowtoplot activelayout 'bl 'tr)) (setq PlotViewportBorders (vla-get-PlotViewportBorders activelayout)) (setq PlotWithLineweights (vla-get-PlotWithLineWeights activelayout)) (setq PlotWithPlotStyles (vla-get-PlotWithPlotStyles activelayout)) (setq ScaleLineWeights (vla-get-ScaleLineWeights activelayout)) (setq PlotViewportBorders (vla-get-StandardScale activelayout)) (setq StandardScale (vla-get-StandardScale activelayout)) (setq StyleSheet (vla-get-StyleSheet activelayout)) (setq UseStandardScale (vla-get-UseStandardScale activelayout)) (if (= UseStandardScale :vlax-false)(setq CustomScale (vla-getcustomscale activelayout 'num 'denom))) (SaveChangeToLayout 1) (setq dcl_id (load_dialog "NumberOfPlots.dcl")) (if (not (new_dialog "NumberOfPlots" dcl_id) ) (exit) ) (start_list "NumberOfPlots") (mapcar 'add_list nlist) (end_list) (action_tile "accept" "(setq number (get_tile \"NumberOfPlots\")) (done_dialog)" ) (action_tile "cancel" "(done_dialog)" ) (start_dialog) (unload_dialog dcl_id) ) ) (princ) ) (defun ResetPlotInfo (calling-reactor endcommandInfo / thecommandend FileOpen line DwgPath DriveLetter remainder PathList listpos listend jobnumber logfilepath FileExists recipients_list subject body ) ;PlotLogList (setq thecommandend (nth 0 endcommandInfo)) (if (= thecommandend "PLOT") (progn (setq acadplot (vla-get-plot activedoc)) (setq NumberofPlots (atoi number)) (if ( (progn (vla-put-NumberofCopies acadplot NumberofPlots) (vla-PlotToDevice (vla-get-plot activedoc)) (vla-put-NumberofCopies acadplot 1) ) ) ;;;;original plot log file (setq LogFileName "L:\\PLOT LOGS\\PLOT LOG.log") (setq FileOpen (open LogFileName "r")) (setq line (read-line FileOpen)) (while line (setq line (read-line FileOpen)) (setq PlotLogList (cons (list line) PlotLogList)) ) (setq PlotLogList1 (vl-remove (car PlotLogList) PlotLogList)) (setq PlotLogList (car PlotLogList1)) (close FileOpen) ;;; (foreach PlotLog PlotLogList ;;; (setq DwgPath (car PlotLog)) (setq DwgPath (car PlotLogList)) (setq DriveLetter (substr DwgPath 1 5)) (if (= (strcase DriveLetter) "G:\\P\\") (progn (setq remainder (substr DwgPath 6)) (setq Pathlist (vl-string->list remainder)) (setq listpos 0) (while (/= 92 (nth listpos Pathlist)) (setq listpos (1+ listpos)) ) (setq listend (1+ listpos)) (setq listpos (+ 2 listpos)) (while (/= 92 (nth listend Pathlist)) (setq listend (1+ listend)) ) (setq listend (+ listend 1)) (setq JobNumber (substr remainder listpos (- listend listpos)) ) (setq LogFilePath (strcat "L:\\PLOT LOGS\\" JobNumber ".log") ) ) (setq LogFilePath "L:\\PLOT LOGS\\TRASH.log") ) (setq FileExists (findfile LogFilePath)) (if (not FileExists) (progn (setq FileOpen (open LogFilePath "a")) (write-line "DRAWING NUMBER,LAYOUT PLOTTED,DATE & TIME,PLOTTED BY,PLOTTED TO,MEDIA SIZE,PLOTTED SCALE" FileOpen ) (repeat (+ 1 NumberofPlots) (write-line DwgPath FileOpen)) ;;; (write-line DwgPath FileOpen) (close FileOpen) (setq recipients_list (list "M.Link@TribalPS.co.uk")) (setq subject "New Plot Log folder created") (setq body (strcat "The following job number requires an excel plot log file created\n\n" jobnumber ) ) (create-email recipients_list subject body attachments_list 1) ) (progn (setq FileOpen (open LogFilePath "a")) (repeat (+ 1 NumberofPlots) (write-line DwgPath FileOpen)) ;;; (write-line DwgPath FileOpen) (close FileOpen) ) ) (vl-file-delete LogFileName) (setq FileOpen (open LogFileName "a")) (write-line "DRAWING NUMBER,LAYOUT PLOTTED,DATE & TIME,PLOTTED BY,PLOTTED TO,MEDIA SIZE,PLOTTED SCALE" FileOpen ) (close FileOpen) ;;; ) ;;;;original plot log file (if Reset (progn (vla-put-Configname activelayout Configname) (vla-put-CanonicalMediaName activelayout MediaSize) (vla-put-Centerplot activelayout CentrePlot) (vla-put-Plothidden activelayout Plothidden) ;;; (vla-get-PlotOrigin activelayout PlotOrigin) (vla-put-PaperUnits activelayout PaperUnits) (vla-put-PlotRotation activelayout PlotRotation) (vla-put-PlotType activelayout PlotType) (vla-put-PlotViewportBorders activelayout PlotViewportBorders) (vla-put-PlotWithLineWeights activelayout PlotWithLineweights) (vla-put-PlotWithPlotStyles activelayout PlotWithPlotStyles) (vla-put-ScaleLineWeights activelayout ScaleLineWeights) (vla-put-PlotViewportBorders activelayout PlotViewportBorders) (vla-put-StandardScale activelayout StandardScale) (vla-put-StyleSheet activelayout StyleSheet) (vla-put-UseStandardScale activelayout UseStandardScale) (vla-sendcommand ActiveDoc "regen ") ;;; (vla-sendcommand ActiveDoc (strcat "zoom " "p ")) ) ) ) ) (princ) ) ; Jason Piercey ; [arg] - any value ; if a non nil value is supplied changes are ; saved otherwise changes are not saved. ; (SaveChangeToLayout nil) ; return: T (defun SaveChangeToLayout (arg) (and (vl-registry-write (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "cprofile") "\\Dialogs\\Plot") "SaveChangeToLayout" (if arg "true" "false") ) ) ) Quote
Recommended Posts
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.