Skip to content

Commit

Permalink
[Added] Experimental Altium PCB conversion
Browse files Browse the repository at this point in the history
See #625
  • Loading branch information
set-soft committed May 29, 2024
1 parent bb4e339 commit f0c8e12
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.7.1] - UNRELEASED
### Added
- Experimental Altium PCB conversion (#625)
- Report:
- Solder paste usage stats (#616)
- Support for variants (See #616)
Expand Down
1 change: 1 addition & 0 deletions docs/source/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Versioning <https://semver.org/spec/v2.0.0.html>`__.
Added
~~~~~

- Experimental Altium PCB conversion (#625)
- Report:

- Solder paste usage stats (#616)
Expand Down
4 changes: 2 additions & 2 deletions docs/source/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

- Mandatory

`KiCad Automation tools <https://github.com/INTI-CMNB/KiAuto>`__ :index:`: <pair: dependency; KiCad Automation tools>` v2.3.1 |image10| |PyPi dependency| |Auto-download|
`KiCad Automation tools <https://github.com/INTI-CMNB/KiAuto>`__ :index:`: <pair: dependency; KiCad Automation tools>` v2.3.2 |image10| |PyPi dependency| |Auto-download|

- Mandatory for: `dxf_sch_print`, `gencad`, `hpgl_sch_print`, `netlist`, `pdf_pcb_print`, `pdf_sch_print`, `ps_sch_print`, `render_3d`, `run_drc`, `run_erc`, `step`, `svg_pcb_print`, `svg_sch_print`, `update_xml`, `vrml`
- Mandatory for: `convert_pcb`, `dxf_sch_print`, `gencad`, `hpgl_sch_print`, `netlist`, `pdf_pcb_print`, `pdf_sch_print`, `ps_sch_print`, `render_3d`, `run_drc`, `run_erc`, `step`, `svg_pcb_print`, `svg_sch_print`, `update_xml`, `vrml`
- Optional to:

- Compare schematics for `diff` (v2.2.0)
Expand Down
20 changes: 18 additions & 2 deletions kibot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,15 @@
from .banner import get_banner, BANNERS
from .gs import GS
from . import dep_downloader
from .misc import EXIT_BAD_ARGS, W_VARCFG, NO_PCBNEW_MODULE, W_NOKIVER, hide_stderr, TRY_INSTALL_CHECK, W_ONWIN
from .misc import (EXIT_BAD_ARGS, W_VARCFG, NO_PCBNEW_MODULE, W_NOKIVER, hide_stderr, TRY_INSTALL_CHECK, W_ONWIN,
FAILED_EXECUTE)
from .pre_base import BasePreFlight
from .error import KiPlotConfigurationError, config_error
from .config_reader import (CfgYamlReader, print_outputs_help, print_output_help, print_preflights_help, create_example,
print_filters_help, print_global_options_help, print_dependencies, print_variants_help,
print_errors, print_list_rotations, print_list_offsets)
from .kiplot import (generate_outputs, load_actions, config_output, generate_makefile, generate_examples, solve_schematic,
solve_board_file, solve_project_file, check_board_file)
solve_board_file, solve_project_file, check_board_file, exec_with_retry)
from .registrable import RegOutput
GS.kibot_version = __version__

Expand Down Expand Up @@ -402,6 +403,20 @@ def detect_windows(): # pragma: no cover (Windows)
logger.warning(W_ONWIN+'Running on Windows, this is experimental, please report any problem')


def check_needs_convert():
""" Try to convert Altium PCBs to KiCad.
If successful just use the converted file. """
ext = os.path.splitext(GS.pcb_fname)[1]
if ext.lower() != '.pcbdoc':
return
command = GS.check_tool_dep('convert_pcb', 'KiAuto')
new_name = GS.pcb_basename+'.kicad_pcb'
cmd = [command, 'convert', '-o', new_name, GS.pcb_file, GS.pcb_dir]
cmd, _ = GS.add_extra_options(cmd)
exec_with_retry(cmd, FAILED_EXECUTE)
GS.set_pcb(os.path.join(GS.pcb_dir, new_name))


def main():
set_locale()
ver = 'KiBot '+__version__+' - '+__copyright__+' - License: '+__license__
Expand Down Expand Up @@ -508,6 +523,7 @@ def main():
GS.set_pcb(solve_board_file('.', args.board_file))
# Determine the project file
GS.set_pro(solve_project_file())
check_needs_convert()

# Parse preprocessor defines
parse_defines(args)
Expand Down
11 changes: 11 additions & 0 deletions kibot/pre_convert_pcb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2024 Salvador E. Tropea
# Copyright (c) 2024 Instituto Nacional de Tecnología Industrial
# License: AGPL-3.0
# Project: KiBot (formerly KiPlot)
"""
Dependencies:
- from: KiAuto
role: mandatory
version: 2.3.2
"""
13 changes: 12 additions & 1 deletion src/kibot-check
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ deps = '{\
"extra_arch": null,\
"extra_deb": null,\
"help_option": "--version",\
"importance": 150004,\
"importance": 160004,\
"in_debian": false,\
"is_kicad_plugin": false,\
"is_python": false,\
Expand Down Expand Up @@ -591,6 +591,17 @@ deps = '{\
0\
]\
},\
{\
"desc": null,\
"mandatory": true,\
"max_version": null,\
"output": "convert_pcb",\
"version": [\
2,\
3,\
2\
]\
},\
{\
"desc": null,\
"mandatory": true,\
Expand Down

0 comments on commit f0c8e12

Please sign in to comment.