[Filters] Moved _only_smd to be truly internal
- Defined _only_tht and _only_virtual - Simplified the internal filters generation
This commit is contained in:
parent
bda5c159ae
commit
b2f5612b77
|
|
@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Internal templates import
|
||||
- New output:
|
||||
- `vrml` export the 3D model in Virtual Reality Modeling Language (#349)
|
||||
- New internal filters:
|
||||
- `_only_smd` used to get only SMD parts
|
||||
- `_only_tht` used to get only THT parts
|
||||
- `_only_virtual` used to get only virtual parts
|
||||
- Internal templates:
|
||||
- FusionPCB: gerber, drill and compress
|
||||
- Elecrow: gerber, drill and compress
|
||||
|
|
|
|||
|
|
@ -1024,6 +1024,9 @@ The [tests/yaml_samples](https://github.com/INTI-CMNB/KiBot/tree/master/tests/ya
|
|||
- References that match: '^TP[0-9]*' or '^FID'
|
||||
- Part names that match: 'regex': 'mount.*hole' or 'solder.*bridge' or 'solder.*jump' or 'test.*point'
|
||||
- Footprints that match: 'test.*point' or 'mount.*hole' or 'fiducial'
|
||||
- **_only_smd** is used to get only SMD parts
|
||||
- **_only_tht** is used to get only THT parts
|
||||
- **_only_virtual** is used to get only virtual parts
|
||||
- **_rot_footprint** is a default `rot_footprint` filter
|
||||
- **_var_rename** is a default `var_rename` filter
|
||||
- **_var_rename_kicost** is a default `var_rename_kicost` filter
|
||||
|
|
@ -4720,7 +4723,6 @@ They include support for:
|
|||
- _JLCPCB_assembly: _JLCPCB_position+_JLCPCB_bom
|
||||
- _JLCPCB: _JLCPCB_fab+_JLCPCB_assembly
|
||||
- [MacroFab_XYRS](https://help.macrofab.com/knowledge/macrofab-required-design-files): XYRS position file in MacroFab format
|
||||
- _only_smd: Filter to get only the SMD parts
|
||||
- _macrofab_xyrs: Position file in XYRS format compatible with MacroFab.
|
||||
- [P-Ban](https://www.p-ban.com/): contain fabrication outputs compatible with P-Ban
|
||||
- _P-Ban_gerbers: Gerbers. You need to define the layers for more than 8.
|
||||
|
|
|
|||
|
|
@ -566,6 +566,9 @@ The [tests/yaml_samples](https://github.com/INTI-CMNB/KiBot/tree/master/tests/ya
|
|||
- References that match: '^TP[0-9]*' or '^FID'
|
||||
- Part names that match: 'regex': 'mount.*hole' or 'solder.*bridge' or 'solder.*jump' or 'test.*point'
|
||||
- Footprints that match: 'test.*point' or 'mount.*hole' or 'fiducial'
|
||||
- **_only_smd** is used to get only SMD parts
|
||||
- **_only_tht** is used to get only THT parts
|
||||
- **_only_virtual** is used to get only virtual parts
|
||||
- **_rot_footprint** is a default `rot_footprint` filter
|
||||
- **_var_rename** is a default `var_rename` filter
|
||||
- **_var_rename_kicost** is a default `var_rename_kicost` filter
|
||||
|
|
@ -1303,7 +1306,6 @@ They include support for:
|
|||
- _JLCPCB_assembly: _JLCPCB_position+_JLCPCB_bom
|
||||
- _JLCPCB: _JLCPCB_fab+_JLCPCB_assembly
|
||||
- [MacroFab_XYRS](https://help.macrofab.com/knowledge/macrofab-required-design-files): XYRS position file in MacroFab format
|
||||
- _only_smd: Filter to get only the SMD parts
|
||||
- _macrofab_xyrs: Position file in XYRS format compatible with MacroFab.
|
||||
- [P-Ban](https://www.p-ban.com/): contain fabrication outputs compatible with P-Ban
|
||||
- _P-Ban_gerbers: Gerbers. You need to define the layers for more than 8.
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2020-2022 Salvador E. Tropea
|
||||
# Copyright (c) 2020-2022 Instituto Nacional de Tecnología Industrial
|
||||
# Copyright (c) 2020-2023 Salvador E. Tropea
|
||||
# Copyright (c) 2020-2023 Instituto Nacional de Tecnología Industrial
|
||||
# License: GPL-3.0
|
||||
# Project: KiBot (formerly KiPlot)
|
||||
from .registrable import RegFilter, Registrable, RegOutput
|
||||
from .optionable import Optionable
|
||||
from .gs import GS
|
||||
from .misc import (IFILT_MECHANICAL, IFILT_VAR_RENAME, IFILT_ROT_FOOTPRINT, IFILT_KICOST_RENAME, DISTRIBUTORS,
|
||||
IFILT_VAR_RENAME_KICOST, IFILT_KICOST_DNP, IFILT_EXPAND_TEXT_VARS, IFILT_DATASHEET_LINK)
|
||||
from .misc import IFILT_MECHANICAL, DISTRIBUTORS, IFILT_KICOST_DNP, IFILT_KICOST_RENAME
|
||||
from .error import KiPlotConfigurationError
|
||||
from .bom.columnlist import ColumnList
|
||||
from .macros import macros, document # noqa: F401
|
||||
|
|
@ -59,6 +58,30 @@ KICOST_NAME_TRANSLATIONS = {
|
|||
'description': 'desc',
|
||||
'pdf': 'datasheet',
|
||||
}
|
||||
# Some very simple internal filters
|
||||
SIMP_FIL = {'_only_smd': {'comment': 'Internal filter for only SMD parts',
|
||||
'type': 'generic',
|
||||
'exclude_virtual': True,
|
||||
'exclude_tht': True},
|
||||
'_only_tht': {'comment': 'Internal filter for only THT parts',
|
||||
'type': 'generic',
|
||||
'exclude_virtual': True,
|
||||
'exclude_smd': True},
|
||||
'_only_virtual': {'comment': 'Internal filter for only virtual parts',
|
||||
'type': 'generic',
|
||||
'exclude_tht': True,
|
||||
'exclude_smd': True},
|
||||
'_rot_footprint': {'type': 'rot_footprint',
|
||||
'comment': 'Internal default footprint rotator'},
|
||||
'_expand_text_vars': {'type': 'expand_text_vars',
|
||||
'comment': 'Internal default text variables expander'},
|
||||
'_datasheet_link': {'type': 'urlify',
|
||||
'comment': 'Internal datasheet URL to HTML link'},
|
||||
'_var_rename': {'type': 'var_rename',
|
||||
'comment': 'Internal default variant field renamer filter'},
|
||||
'_var_rename_kicost': {'type': 'var_rename_kicost',
|
||||
'comment': 'Internal default variant field renamer filter (KiCost style)'},
|
||||
}
|
||||
|
||||
|
||||
class DummyFilter(Registrable):
|
||||
|
|
@ -219,46 +242,6 @@ class BaseFilter(RegFilter):
|
|||
logger.debug('Creating internal filter: '+str(o_tree))
|
||||
return o_tree
|
||||
|
||||
@staticmethod
|
||||
def _create_var_rename(name):
|
||||
o_tree = {'name': name}
|
||||
o_tree['type'] = 'var_rename'
|
||||
o_tree['comment'] = 'Internal default variant field renamer filter'
|
||||
logger.debug('Creating internal filter: '+str(o_tree))
|
||||
return o_tree
|
||||
|
||||
@staticmethod
|
||||
def _create_var_rename_kicost(name):
|
||||
o_tree = {'name': name}
|
||||
o_tree['type'] = 'var_rename_kicost'
|
||||
o_tree['comment'] = 'Internal default variant field renamer filter (KiCost style)'
|
||||
logger.debug('Creating internal filter: '+str(o_tree))
|
||||
return o_tree
|
||||
|
||||
@staticmethod
|
||||
def _create_rot_footprint(name):
|
||||
o_tree = {'name': name}
|
||||
o_tree['type'] = 'rot_footprint'
|
||||
o_tree['comment'] = 'Internal default footprint rotator'
|
||||
logger.debug('Creating internal filter: '+str(o_tree))
|
||||
return o_tree
|
||||
|
||||
@staticmethod
|
||||
def _create_expand_text_vars(name):
|
||||
o_tree = {'name': name}
|
||||
o_tree['type'] = 'expand_text_vars'
|
||||
o_tree['comment'] = 'Internal default text variables expander'
|
||||
logger.debug('Creating internal filter: '+str(o_tree))
|
||||
return o_tree
|
||||
|
||||
@staticmethod
|
||||
def _create_datasheet_link(name):
|
||||
o_tree = {'name': name}
|
||||
o_tree['type'] = 'urlify'
|
||||
o_tree['comment'] = 'Internal datasheet URL to HTML link'
|
||||
logger.debug('Creating internal filter: '+str(o_tree))
|
||||
return o_tree
|
||||
|
||||
@staticmethod
|
||||
def _create_kibom_dnx(name):
|
||||
type = name[7:10]
|
||||
|
|
@ -314,22 +297,16 @@ class BaseFilter(RegFilter):
|
|||
tree = BaseFilter._create_mechanical(name)
|
||||
elif name.startswith('_kibom_dn') and len(name) >= 10:
|
||||
tree = BaseFilter._create_kibom_dnx(name)
|
||||
elif name == IFILT_VAR_RENAME:
|
||||
tree = BaseFilter._create_var_rename(name)
|
||||
elif name == IFILT_ROT_FOOTPRINT:
|
||||
tree = BaseFilter._create_rot_footprint(name)
|
||||
elif name == IFILT_KICOST_RENAME:
|
||||
tree = BaseFilter._create_kicost_rename(name)
|
||||
elif name == IFILT_VAR_RENAME_KICOST:
|
||||
tree = BaseFilter._create_var_rename_kicost(name)
|
||||
elif name == IFILT_KICOST_DNP:
|
||||
tree = BaseFilter._create_kicost_dnp(name)
|
||||
elif name == IFILT_EXPAND_TEXT_VARS:
|
||||
tree = BaseFilter._create_expand_text_vars(name)
|
||||
elif name == IFILT_DATASHEET_LINK:
|
||||
tree = BaseFilter._create_datasheet_link(name)
|
||||
else:
|
||||
return None
|
||||
tree = SIMP_FIL.get(name)
|
||||
if tree is None:
|
||||
return None
|
||||
tree['name'] = name
|
||||
logger.debug('Creating internal filter: '+str(tree))
|
||||
filter = RegFilter.get_class_for(tree['type'])()
|
||||
filter._internal = True
|
||||
filter.set_tree(tree)
|
||||
|
|
|
|||
|
|
@ -83,13 +83,8 @@ TRY_INSTALL_CHECK = 'Try running the installation checker: kibot-check'
|
|||
|
||||
# Internal filter names
|
||||
IFILT_MECHANICAL = '_mechanical'
|
||||
IFILT_VAR_RENAME = '_var_rename'
|
||||
IFILT_VAR_RENAME_KICOST = '_var_rename_kicost'
|
||||
IFILT_ROT_FOOTPRINT = '_rot_footprint'
|
||||
IFILT_KICOST_RENAME = '_kicost_rename'
|
||||
IFILT_KICOST_DNP = '_kicost_dnp'
|
||||
IFILT_EXPAND_TEXT_VARS = '_expand_text_vars'
|
||||
IFILT_DATASHEET_LINK = '_datasheet_link'
|
||||
# KiCad 5 GUI values for the attribute
|
||||
UI_THT = 0 # 1 for KiCad 6
|
||||
UI_SMD = 1 # 2 for KiCad 6
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ from copy import deepcopy
|
|||
import os
|
||||
import re
|
||||
from .gs import GS
|
||||
from .misc import W_BADFIELD, W_NEEDSPCB, DISTRIBUTORS, IFILT_EXPAND_TEXT_VARS, W_NOPART, W_MISSREF
|
||||
from .misc import W_BADFIELD, W_NEEDSPCB, DISTRIBUTORS, W_NOPART, W_MISSREF
|
||||
from .optionable import Optionable, BaseOptions
|
||||
from .registrable import RegOutput
|
||||
from .error import KiPlotConfigurationError
|
||||
|
|
@ -916,7 +916,7 @@ class BoMOptions(BaseOptions):
|
|||
# Now expand the text variables, the user can disable it and insert a customized filter
|
||||
# in the variant or even before.
|
||||
if self.expand_text_vars:
|
||||
comps = apply_pre_transform(comps, BaseFilter.solve_filter(IFILT_EXPAND_TEXT_VARS, 'KiCad 6 text vars',
|
||||
comps = apply_pre_transform(comps, BaseFilter.solve_filter('_expand_text_vars', 'KiCad 6 text vars',
|
||||
is_transform=True))
|
||||
# We add the main project to the aggregate list so do_bom sees a complete list
|
||||
base_sch = Aggregate()
|
||||
|
|
|
|||
|
|
@ -3,13 +3,6 @@
|
|||
kibot:
|
||||
version: 1
|
||||
|
||||
filters:
|
||||
- name: _only_smd
|
||||
comment: 'Only SMD parts'
|
||||
type: generic
|
||||
exclude_virtual: true
|
||||
exclude_tht: true
|
||||
|
||||
outputs:
|
||||
- name: _macrofab_xyrs
|
||||
comment: "Pick and place file, XYRS style"
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2020-2021 Salvador E. Tropea
|
||||
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
|
||||
# Copyright (c) 2020-2023 Salvador E. Tropea
|
||||
# Copyright (c) 2020-2023 Instituto Nacional de Tecnología Industrial
|
||||
# License: GPL-3.0
|
||||
# Project: KiBot (formerly KiPlot)
|
||||
# The algorithm is from KiCost project (https://github.com/xesscorp/KiCost)
|
||||
# Description: Implements the KiCost variants mechanism.
|
||||
import re
|
||||
from .gs import GS
|
||||
from .misc import IFILT_VAR_RENAME_KICOST, IFILT_KICOST_RENAME, IFILT_KICOST_DNP
|
||||
from .misc import IFILT_KICOST_RENAME, IFILT_KICOST_DNP
|
||||
from .fil_base import BaseFilter
|
||||
from .macros import macros, document, variant_class # noqa: F401
|
||||
from . import log
|
||||
|
|
@ -43,7 +43,7 @@ class KiCost(BaseVariant): # noqa: F821
|
|||
def config(self, parent):
|
||||
super().config(parent)
|
||||
self.pre_transform = BaseFilter.solve_filter(self.pre_transform, 'pre_transform',
|
||||
[IFILT_VAR_RENAME_KICOST, IFILT_KICOST_RENAME], is_transform=True)
|
||||
['_var_rename_kicost', IFILT_KICOST_RENAME], is_transform=True)
|
||||
self.exclude_filter = BaseFilter.solve_filter(self.exclude_filter, 'exclude_filter')
|
||||
self.dnf_filter = BaseFilter.solve_filter(self.dnf_filter, 'dnf_filter', IFILT_KICOST_DNP)
|
||||
self.dnc_filter = BaseFilter.solve_filter(self.dnc_filter, 'dnc_filter')
|
||||
|
|
|
|||
Loading…
Reference in New Issue