默认打印机无。。。真正地
你好我收到了公司外的一些图纸。不足为奇的是,他们不使用相同的打印机,更不用说每隔几年更换一次打印服务器。我们已经转而使用PC3文件,这对我有所帮助,但我仍然对一大组需要物理打印机的遗留图形感兴趣。当AutoCAD为其中一个图形启动打印命令时,我会收到一个消息框,基本上说在布局中定义的打印机找不到,它正在替换“无”打印机。
我不知道你的情况,但我会假设如果AutoCAD找不到它正在寻找的打印机,它应该替代我可以打印的东西,你知道。。。像默认打印机?!无论如何我已经设置了一个反应堆来监视打印命令。当plot cammand被称为LISP时,会检查当前plotdevice并将其保存到LISP代码中指定的列表中。如果找到匹配项,则可以跳过其余代码,如果不匹配,则表示图形中的currentplotdevice不是我当前使用的设备。如果不匹配,LISP将用定义为“默认”的代码覆盖当前绘图设备,然后允许plot命令继续。这消除了关于找不到绘图仪和替换无打印机的“错误消息”。
<p>;;; Check if the plotter last saved with the file is in a list of</p><p>;;; current devices.If it is not, change the plot device to a current</p><p>;;; device, If it is, leave things alone.</p><p>;;;</p><p>(defun SwitchDefaultPrinter</p><p> (/ Default ad OldPlotDevicee PlotDevices NonCurrentDevice)</p><p>(setq Default "Black_Laser.pc3") ;Set default printer</p><p>;;create list of current plot devices</p><p>(setq PlotDevices</p><p> (list</p><p> ;;Old System printers turned off</p><p> ;;"\\\\bdn01ps001\\ccc_colorlaser"</p><p> ;;"\\\\bdn01ps001\\color_laser"</p><p> ;;"\\\\bdn01ps001\\drafting_lj8000"</p><p> ;;"\\\\bdn01ps001\\drafting_plotter"</p><p> ;;Current System printers turned off</p><p> ;;"\\\\bdn01ps002\\ccc_colorlaser"</p><p> ;;"\\\\bdn01ps002\\color_laser"</p><p> ;;"\\\\bdn01ap010\\drafting_plotter"</p><p> ;;"\\\\bdn01ps002\\ccc_upper_xerox_wc5755"</p><p> ;;"\\\\bdn01ps002\\drafting_xerox_5550"</p><p> ;Current PC3 Files</p><p> "Black_Laser.pc3"</p><p> "Color_Laser.pc3"</p><p> "Drafting_Plotter.pc3"</p><p> "DWG To PDF.pc3"</p><p> )</p><p>)</p><p>(setq ad (vla-get-activedocument (vlax-get-acad-object)))</p><p>;;Set variable to hold reference to the active document</p><p> </p><p>(setq OldPlotDevice (GetActivePlotDevice ad))</p><p>;;Set variable to hold reference to current plot device</p><p>;;comapre the old plot device to a list of current devices</p><p>(if (= nil (vl-position OldPlotDevice PlotDevices))</p><p> (setq NonCurrentDevice 0) ;Device not found in list</p><p> (setq NonCurrentDevice 1) ;Device found in list</p><p>)</p><p>(if (= 0 NonCurrentDevice) ;if the current device is not in the current list of active devices.</p><p> (progn</p><p> (vla-put-ConfigName (vla-get-ActiveLayout ad) Default)</p><p> ;;Change the plotter name to be used by the active layout</p><p> (setq PrinterSwitched 1)</p><p> )</p><p> ;;other wise leave it alone.</p><p>)</p><p>(if (= nil</p><p> (vl-position</p><p> (vlax-get-property (vla-get-ActiveLayout ad) "StyleSheet")</p><p> (GetPlotStyleTableNames ad)</p><p> )</p><p> ) ;check the list of CTB files for the current requested CTB</p><p> (vlax-put-property</p><p> (vla-get-ActiveLayout ad)</p><p> "StyleSheet"</p><p> "Black_Laser.ctb"</p><p> ;;Current CTB Not found, set CTB file to "Black_Laser.ctb"</p><p> )</p><p> ;;Curerent CTB found, don't worry about it</p><p>)</p><p>(if (= 1 PrinterSwitched)</p><p> (progn</p><p> (if (/= nil (vl-position "11x17" (GetCanonicalMediaNames ad)))</p><p> ;;check list of paper sizes for 11X17</p><p> (vlax-put-property</p><p> (vla-get-ActiveLayout ad)</p><p> "CanonicalMediaName"</p><p> "11x17"</p><p> ;;11X17 found in the list of paper sizes, set paper size to 11x17</p><p> )</p><p> ;;11x17 is not in the list, don't worry about it</p><p> )</p><p> (vlax-put-property</p><p> (vla-get-ActiveLayout ad)</p><p> "CenterPlot"</p><p> -1</p><p> ) ;Set to center the plot on the paper</p><p> (vlax-put-property</p><p> (vla-get-ActiveLayout ad)</p><p> "StandardScale"</p><p> 0</p><p> ) ;Set to "Scale to Fit</p><p> (vlax-put-property (vla-get-ActiveLayout ad) "PlotType" 1)</p><p> ;Set to plot extents</p><p> (vlax-put-property</p><p> (vla-get-ActiveLayout ad)</p><p> "PlotRotation"</p><p> 1</p><p> ) ;Set to print Landscape</p><p> )</p><p>)</p><p>(princ)</p><p>)</p><p> </p><p>(defun GetActivePlotDevice (ad)</p><p>(vla-get-ConfigName</p><p> (vla-get-ActiveLayout ad)</p><p>)</p><p>)</p><p> </p><p>(defun GetCanonicalMediaNames (ad)</p><p>(vla-RefreshPlotDeviceInfo</p><p> (vla-get-activelayout ad)</p><p>)</p><p>(vlax-safearray->list</p><p> (vlax-variant-value</p><p> (vla-GetCanonicalMediaNames</p><p> (vla-item (vla-get-layouts ad) "Model")</p><p> )</p><p> )</p><p>)</p><p>)</p><p> </p><p>(defun GetPlotStyleTableNames (ad)</p><p>(vla-RefreshPlotDeviceInfo</p><p> (vla-get-activelayout ad)</p><p>)</p><p>(vlax-safearray->list</p><p> (vlax-variant-value</p><p> (vla-getplotstyletablenames</p><p> (vla-item (vla-get-layouts ad) "Model")</p><p> )</p><p> )</p><p>)</p><p>)</p><p>[\code]</p><p> </p><p>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.</p><p></p><p>;; Check to see if the printer was switched</p><p>;; If it was restore the old printer referenced in the file</p><p>(if (= PrinterSwitched 1)</p><p> (vla-put-ConfigName (vla-get-ActiveLayout ad) OldPlotDevice)</p><p>)</p><p>[\code]</p><p> </p><p>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.</p><p> </p><p>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.</p><p> </p><p>Thalon</p>
页:
[1]