Retrive a list of network prints

Hello, dear friends, I’m trying to modify python-node from the package: Archi-lab_Grimshaw → Printing → Local Printers Names.
I need to get the list of network printers.
I have dully tried to replace all PRINTER_ENUM_LOCALs to PRINTER_ENUM_NETWORKs, but this didn’t help xD

Image 689

I don’t have a network printer to test this out , but you could try the below:

Revit_2016-03-12_16-19-26

I found this solution on SO:

Hello, thank you for the reply, but the script returns only local printers…

 

<!–StartFragment–><!–EndFragment–>Image 696

Hi Tuuletin,

Just noticed that your script is not matching with Dimitar’s script.

Untitled1

Hello, Kulkul, seems to be the same. If I add “if p.IsShared”, I will get an empty list. But we somehow find the solution here, thanks to Khasan: http://dynamobim.ru/forums/topic/получить-список-принтеров-через-revit-api/#post-3444

import clr
clr.AddReference(‘System.Drawing’)
import System
n = System.Drawing.Printing.PrinterSettings.InstalledPrinters.Count
prt = []
for i in range(n):
____prt.append(System.Drawing.Printing.PrinterSettings.InstalledPrinters[i])
OUT = prt

1 Like

@tuuletin @Dimitar_Venkov @Kulkul @Konrad_K_Sobon
Archi-Lab local printers node can also get the network printers, although the above post is shorter code.

You need to adjust the value as per below snippet

msvcrt = ctypes.cdll.msvcrt # for malloc, free # Parameters: modify as you need. See MSDN for detail. PRINTER_ENUM_LOCAL = 2
Name = None # ignored for PRINTER_ENUM_LOCAL
Level = 1 # or 2, 4, 5

Change this line
PRINTER_ENUM_LOCAL = 2 …this will list local printers

To
PRINTER_ENUM_LOCAL = 4 …this will list only network printers

To
PRINTER_ENUM_LOCAL = 6 …this will list both local and network printers…

As i said the above code you post is much shorter code which has same results. Just thought sharing this just to answer your first post.

Thanks…FYI