Search the Community
Showing results for tags 'default printer'.
-
Hi, I recieve a number of drawings from outside the company. Not too suprissing they don't use that same printers, not to mention IT has a habit of changing print servers every couple of years. We have switched to using PC3 files which has helped some, but I'm still lef with a large set of legacy drawings that called for a physical printer. When AutoCAD start the print command for one of these drawings I get a message box that basicly says that the printer defined in the layout cannot be found and it is substituting the "None" printer. I don't know about you, but I would assume that if AutoCAD can't find the printer it's looking for that it should substitute something I can actually print to, you know... like a default printer?! Anyway... I have prgrammend a reactor to watch for the print command. When the plot cammand is called the LISP then checks the current plotdevice and comares it to a list specified in the LISP code. If a match is found then the rest of the code can be skipped, if no match then that means the currentplotdevice in the drawing is not one I use currently. If no match then the LISP overwrites the current plot device with a code defined "default", and then allow the plot command to continue. This eliminate the "error message" about not finding the plotter and substituting None printer. ;;; Check if the plotter last saved with the file is in a list of ;;; current devices. If it is not, change the plot device to a current ;;; device, If it is, leave things alone. ;;; (defun SwitchDefaultPrinter (/ Default ad OldPlotDevicee PlotDevices NonCurrentDevice) (setq Default "Black_Laser.pc3") ;Set default printer ;;create list of current plot devices (setq PlotDevices (list ;;Old System printers turned off ;;"\\\\bdn01ps001\\ccc_colorlaser" ;;"\\\\bdn01ps001\\color_laser" ;;"\\\\bdn01ps001\\drafting_lj8000" ;;"\\\\bdn01ps001\\drafting_plotter" ;;Current System printers turned off ;;"\\\\bdn01ps002\\ccc_colorlaser" ;;"\\\\bdn01ps002\\color_laser" ;;"\\\\bdn01ap010\\drafting_plotter" ;;"\\\\bdn01ps002\\ccc_upper_xerox_wc5755" ;;"\\\\bdn01ps002\\drafting_xerox_5550" ;Current PC3 Files "Black_Laser.pc3" "Color_Laser.pc3" "Drafting_Plotter.pc3" "DWG To PDF.pc3" ) ) (setq ad (vla-get-activedocument (vlax-get-acad-object))) ;;Set variable to hold reference to the active document (setq OldPlotDevice (GetActivePlotDevice ad)) ;;Set variable to hold reference to current plot device ;;comapre the old plot device to a list of current devices (if (= nil (vl-position OldPlotDevice PlotDevices)) (setq NonCurrentDevice 0) ;Device not found in list (setq NonCurrentDevice 1) ;Device found in list ) (if (= 0 NonCurrentDevice) ;if the current device is not in the current list of active devices. (progn (vla-put-ConfigName (vla-get-ActiveLayout ad) Default) ;;Change the plotter name to be used by the active layout (setq PrinterSwitched 1) ) ;;other wise leave it alone. ) (if (= nil (vl-position (vlax-get-property (vla-get-ActiveLayout ad) "StyleSheet") (GetPlotStyleTableNames ad) ) ) ;check the list of CTB files for the current requested CTB (vlax-put-property (vla-get-ActiveLayout ad) "StyleSheet" "Black_Laser.ctb" ;;Current CTB Not found, set CTB file to "Black_Laser.ctb" ) ;;Curerent CTB found, don't worry about it ) (if (= 1 PrinterSwitched) (progn (if (/= nil (vl-position "11x17" (GetCanonicalMediaNames ad))) ;;check list of paper sizes for 11X17 (vlax-put-property (vla-get-ActiveLayout ad) "CanonicalMediaName" "11x17" ;;11X17 found in the list of paper sizes, set paper size to 11x17 ) ;;11x17 is not in the list, don't worry about it ) (vlax-put-property (vla-get-ActiveLayout ad) "CenterPlot" -1 ) ;Set to center the plot on the paper (vlax-put-property (vla-get-ActiveLayout ad) "StandardScale" 0 ) ;Set to "Scale to Fit (vlax-put-property (vla-get-ActiveLayout ad) "PlotType" 1) ;Set to plot extents (vlax-put-property (vla-get-ActiveLayout ad) "PlotRotation" 1 ) ;Set to print Landscape ) ) (princ) ) (defun GetActivePlotDevice (ad) (vla-get-ConfigName (vla-get-ActiveLayout ad) ) ) (defun GetCanonicalMediaNames (ad) (vla-RefreshPlotDeviceInfo (vla-get-activelayout ad) ) (vlax-safearray->list (vlax-variant-value (vla-GetCanonicalMediaNames (vla-item (vla-get-layouts ad) "Model") ) ) ) ) (defun GetPlotStyleTableNames (ad) (vla-RefreshPlotDeviceInfo (vla-get-activelayout ad) ) (vlax-safearray->list (vlax-variant-value (vla-getplotstyletablenames (vla-item (vla-get-layouts ad) "Model") ) ) ) ) [\code] The problem is... this overwrite the currentplotdevice setting in the drawing. The boss doesn't like this. What I would like to be able to do is make this change, but when the plot command is finished, put back the old "currentplotdevice" so no real change to the cad file is made. I've got this by haveing the folling LISP run when the plot command is finished. [code] ;; Check to see if the printer was switched ;; If it was restore the old printer referenced in the file (if (= PrinterSwitched 1) (vla-put-ConfigName (vla-get-ActiveLayout ad) OldPlotDevice) ) [\code] The problem with this is that it always resets the "currentplotdevice" when the plot command is finished. If I press the "Apply to Layout" button in the plot dialog, I don't want the plot device changed after the plot command is finished. I haven't found a way for my reactor to "watch" for this button press. If I can "catch" this button press I can have the LISP change my variable 'PrinterSwitched' to "0" and this would skip the code to switch the currentplotdevice back, thus making things work the way I want. Sorry for the long post, but I hope I got all of the relevant info into it. Im running Windows 7 & AutoCAD 2012. Any advice and help is greatly appriciated. Thalon
-
- plot
- default printer
-
(and 1 more)
Tagged with: