Author Topic: Create list of current printers & paper with LISP-VLISP?  (Read 3104 times)

0 Members and 1 Guest are viewing this topic.

septicad

  • Guest
Create list of current printers & paper with LISP-VLISP?
« on: March 20, 2008, 10:48:53 AM »
Is there a way to create a list of the currently installed printers in LISP - and then also determine their associated paper sizes?

To better understand my issue: See a quick movie demostration here of my DCL/LISP code: http://www.septicad.com/temp/sprint.html  [ignore the truetype issues with the latest Bricscad release].

Currently, the user has to physically enter the PrinterName and PaperName, which is cAseSensitIVe - (i.e. hp DeskJet xxx, Letter 8.5" x 11").  The variation in paper size naming from printer to printer is rediculous (Letter - vs - 8.5" x 11" letter size...  Of course the user only has to do this once (its stored in a text file for further use), but still... its a pain to answer these support calls if I don't need to...

Based a previous thread I know that you can add a printer to the list via:

(setq wsn (vlax-create-object "WScript.Network"))
(vlax-invoke wsn 'AddWindowsPrinterConnection "\\\\Server_name\\Printer_name")
(vlax-release-object wsn)


Thanks in advance

Steve Marcotte
SeptiCAD.com

FengK

  • Guest
Re: Create list of current printers & paper with LISP-VLISP?
« Reply #1 on: March 20, 2008, 12:53:52 PM »
if you use or don't mind using doslib, (dos_printers) returns a list of installed printers. have no idea about paper sizes.

VovKa

  • Water Moccasin
  • Posts: 1629
  • Ukraine
Re: Create list of current printers & paper with LISP-VLISP?
« Reply #2 on: March 20, 2008, 01:29:32 PM »
i don't think it's 100% proof, but you can try
Code: [Select]
(vl-load-com)
(defun test ()
  (vl-directory-files
    (vla-get-PrinterConfigPath
      (vla-get-Files (vla-get-Preferences (vlax-get-acad-object)))
    )
    "*.pc3"
    1
  )
)
(defun test1 (ConfigName / ActiveLayoutObj)
  (setq ActiveLayoutObj
(vla-get-ActiveLayout (vla-get-ActiveDocument (vlax-get-acad-object)))
  )
  (vla-RefreshPlotDeviceInfo ActiveLayoutObj)
  (vla-Put-ConfigName ActiveLayoutObj ConfigName)
  (vlax-safearray->list
    (vlax-variant-value (vla-GetCanonicalMediaNames ActiveLayoutObj))
  )
)
;;;(test)
;;;(test1 "PublishToWeb JPG.pc3")

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Create list of current printers & paper with LISP-VLISP?
« Reply #3 on: March 20, 2008, 03:36:35 PM »
This will get the list of printers and location:

http://www.theswamp.org/index.php?topic=20595.msg250546#msg250546

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

septicad

  • Guest
Re: Create list of current printers & paper with LISP-VLISP?
« Reply #4 on: March 20, 2008, 04:49:59 PM »
thanks for the different examples... I tested ronjonp's suggestion...but no go on Bricscad v8... ya, i can't rely on the code unless it works on cheap cad too... thanks for the suggestions.

http://www.theswamp.org/index.php?topic=20595.msg250546#msg250546