View Full Version : Current Plotter?
sthedens
2008-03-21, 03:29 PM
We have a VBA routine that tracks our plotting. When the PLOT command is issued, this routine fires. One of the pieces of information we are trying to retrieve is the name of the printer or plot configuration file the user selected.
The existing code (written by my predecessor) retrieves the ConfigName of the ActiveLayout. However, this is not necessarily the device the user selected from the Plot Dialog. For example, ThisDrawing.ActiveLayout.ConfigName returns "Plot to File.pc3" when the user selected "OCE TDS600.pc3" in the Plot Dialog.
Within VBA, where can I go to get the user's selection rather than the ConfigName associated with the Layout?
Try VBS script:
Option Explicit
' requires references to:
' - Windows Script Host Object Model
' - Microsoft Scripting Runtime
Sub GetPrinterName()
Dim objService As Object
Dim WScript As WshShell
Dim objPrn As Object
Dim comp As String
comp = VBA.Environ("COMPUTERNAME")
Dim objstr As String
Dim prnDesc As String
objstr = "winmgmts:{impersonationLevel=impersonate}!\\" & comp & "\root\CIMV2"
On Error Resume Next
Set objService = GetObject(objstr)
If Err.Number <> 0 Then
WScript.Echo Err.Number & ": " & Err.Description
WScript.Quit
End If
For Each objPrn In objService.ExecQuery("SELECT * FROM Win32_Printer")
If objPrn.Attributes And 4 Then
prnDesc = objPrn.Name
Exit For
End If
Next
Set objService = Nothing
End Sub
~'J'~
sthedens
2008-03-21, 08:07 PM
That will point to a Windows printer. I need it to show me the user's selection from the Plot Dialog Box in AutoCAD. While the potential choices of Plot Devices can be Windows printers, they are more often than not a .pc3 file selection.
In order to get proper plot logging, the user must:
1. Issue the plot command.
2. Change the Plot Device.
3. Select the "Apply to Layout".
4. Cancel the plot.
5. Save the drawing.
6. Re-issue the Plot command.
7. Click "OK".
This is because ThisDrawing.ActiveLayout.ConfigName returns the SAVED plot device associated with the layout, not the CURRENT user selection from the Plot Dialog Box.
We want:
1. Issue the plot command.
2. Change the Plot Device.
3. Click "OK".
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.