Printing all options (Python)¶
Printing all options (Python)¶
1# This example shows how to print the active drawing
2# It shows how to set the printer to use as well
3# as all advanced printing options
4
5# Create a local variable for the active database
6db = impact.active_database
7
8# Create a local variable for the output toolbox
9ot = impact.gui.output_toolbox
10
11# Clear the output toolbox
12ot.clear()
13
14drawing = impact.active_drawing
15
16if not drawing.isNone():
17
18 # create a default print options
19 options = impact.creator.print_options()
20
21 options.show_dialog = False
22
23 # always set the PrinterName before other options
24 options.printer_name = "Auto HP LaserJet 6P on SERVER"
25 options.number_of_copies = 1
26 options.source = ipPrintSource.psVisibleLayers
27 options.colour = ipPrintColour.pcColour
28 options.orientation = ipPrintOrientation.poPortrait
29
30 # the two following options are mutually exclusive
31 # options.ignore_line_weights = True
32 options.increase_line_weights_by = 400
33
34 # by default the ReportSettings and GraphicSettings are None
35 options.report_settings = db.find_master_tool_setting("Times", ipMasterSettingType.mstReport)
36 options.graphic_settings = db.find_master_tool_setting("Best", ipMasterSettingType.mst3DGraphics)
37
38 # you can specify a predefined paper size and source
39 options.paper_size = ipPaperSize.psA4
40 options.paper_source = ipPaperSource.psManualFeed
41
42 # other possible PaperSource options
43 # options.paper_source = ipPaperSource.psUpperTray
44 # options.paper_source = psAutomatic
45 # options.paper_source = ipPaperSource.psLowerTray
46 # options.paper_source = ipPaperSource.psMiddleTray
47
48 # specify duplexing if your printer supports it
49 options.paper_duplex = ipPaperDuplex.pdNone
50
51 if drawing.print(options):
52 ot.add("Successfully printed active drawing to " + options.printer_name)
53 else:
54 ot.add("Unable to print to " + options.printer_name)
55else:
56 ot.add("No impact.active_drawing")