Skip to content

Commit

Permalink
Merge pull request #73 from afkiwers/default_kicad_symbol
Browse files Browse the repository at this point in the history
KiCad backup symbol support
  • Loading branch information
afkiwers authored Feb 2, 2024
2 parents a4025c1 + 631ca4d commit 40931e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
17 changes: 11 additions & 6 deletions inventree_kicad/KiCadLibraryPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ class KiCadLibraryPlugin(UrlsMixin, AppMixin, SettingsMixin, SettingsContentMixi
'validator': bool,
'default': False,
},
'IMPORT_INVENTREE_ID_FALLBACK': {
'name': _('Also Match Against Part Name'),
'description': _(
'When activated, the import tool will use the part name as fallback if the ID does not return an existing part.'),
'validator': bool,
'default': False,
},
'KICAD_SYMBOL_PARAMETER': {
'name': _('Symbol Parameter'),
'description': _('The part parameter to use for the symbol name.'),
Expand Down Expand Up @@ -114,12 +121,10 @@ class KiCadLibraryPlugin(UrlsMixin, AppMixin, SettingsMixin, SettingsContentMixi
'description': _('This identifier specifies what key the import tool looks for to get the part ID'),
'default': "InvenTree"
},
'IMPORT_INVENTREE_ID_FALLBACK': {
'name': _('Also Match Against Part Name'),
'description': _(
'When activated, the import tool will use the part name as fallback if the ID does not return an existing part.'),
'validator': bool,
'default': False,
'DEFAULT_FOR_MISSING_SYMBOL': {
'name': _('Backup KiCad Symbol'),
'description': _('This backup symbol will be used if none has been defined'),
'default': ""
},
}

Expand Down
5 changes: 4 additions & 1 deletion inventree_kicad/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,14 @@ def get_symbol(self, part):

symbol = self.get_parameter_value(part, template_id, backup_value=symbol)

if not symbol:
symbol = template_id = self.plugin.get_setting('DEFAULT_FOR_MISSING_SYMBOL', "")

# KiCad does not like colons in their symbol names.
# Check if there is more than one colon present, if so rebuild string and honour only the first
# colon. Replace the other colons with underscores.
cnt = symbol.count(':')
if cnt != 1:
if cnt != 1 and len(symbol) != 0:
spilt_str = symbol.split(':')
tmp_str = ""

Expand Down

0 comments on commit 40931e9

Please sign in to comment.