|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 | # -*- coding: utf-8 -*- |
3 | | -# Copyright (c) 2020-2024 Salvador E. Tropea |
4 | | -# Copyright (c) 2020-2024 Instituto Nacional de Tecnologïa Industrial |
| 3 | +# Copyright (c) 2020-2026 Salvador E. Tropea |
| 4 | +# Copyright (c) 2020-2026 Instituto Nacional de Tecnologïa Industrial |
5 | 5 | # Copyright (c) 2019 Jesse Vincent (@obra) |
6 | 6 | # Copyright (c) 2018-2019 Seppe Stas (@seppestas) (Productize SPRL) |
7 | 7 | # Based on ideas by: Scott Bezek (@scottbez1) |
@@ -240,11 +240,21 @@ def eeschema_plot_schematic_cli(cfg): |
240 | 240 | cmd.append('--exclude-drawing-sheet') |
241 | 241 | if not cfg.background_color and cfg.export_format != 'dxf' and cfg.export_format != 'hpgl': |
242 | 242 | cmd.append('--no-background-color') |
243 | | - if not cfg.all_pages: |
244 | | - if cfg.ki8: |
| 243 | + # pages/all_pages |
| 244 | + if cfg.ki8: |
| 245 | + if cfg.pages: |
| 246 | + cmd.extend(['--pages', cfg.pages]) |
| 247 | + elif not cfg.all_pages: |
245 | 248 | cmd.extend(['--pages', '1']) |
246 | | - else: |
| 249 | + # else: nothing means all pages |
| 250 | + else: |
| 251 | + if cfg.pages: |
| 252 | + logger.error('Pages is available only for KiCad 8+ and the CLI') |
| 253 | + exit(WRONG_ARGUMENTS) |
| 254 | + elif not cfg.all_pages: |
247 | 255 | cmd.append('--plot-one') |
| 256 | + # else: nothing means all pages |
| 257 | + # default_font |
248 | 258 | if cfg.ki9 and cfg.default_font: |
249 | 259 | cmd.extend(['--default-font', cfg.default_font]) |
250 | 260 | cmd.append(cfg.input_file) |
@@ -919,7 +929,11 @@ if __name__ == '__main__': |
919 | 929 | export_parser = subparsers.add_parser('export', help='Export a schematic') |
920 | 930 | export_parser.add_argument('--file_format', '-f', help='Export file format', |
921 | 931 | choices=['svg', 'pdf', 'ps', 'dxf', 'hpgl'], default='pdf') |
922 | | - export_parser.add_argument('--all_pages', '-a', help='Plot all schematic pages in one file', action='store_true') |
| 932 | + |
| 933 | + pages_group = export_parser.add_mutually_exclusive_group() |
| 934 | + pages_group.add_argument('--all_pages', '-a', help='Plot all schematic pages in one file', action='store_true') |
| 935 | + pages_group.add_argument('--pages', type=str, help='Comma separated list of pages (KiCad 8+/CLI)') |
| 936 | + |
923 | 937 | export_parser.add_argument('--monochrome', '-m', help='Black and white output', action='store_true') |
924 | 938 | export_parser.add_argument('--no_frame', '-F', help='No frame and title block', action='store_true') |
925 | 939 | export_parser.add_argument('--output_name', '-o', nargs=1, help='Name of the output file') |
@@ -957,6 +971,7 @@ if __name__ == '__main__': |
957 | 971 | cfg.verbose = args.verbose |
958 | 972 | cfg.video_name = args.command+'_eeschema_screencast.ogv' |
959 | 973 | cfg.all_pages = getattr(args, 'all_pages', False) |
| 974 | + cfg.pages = getattr(args, 'pages') |
960 | 975 | cfg.monochrome = getattr(args, 'monochrome', False) |
961 | 976 | cfg.no_frame = getattr(args, 'no_frame', False) |
962 | 977 | cfg.warnings_as_errors = getattr(args, 'warnings_as_errors', False) |
|
0 commit comments