Skip to content

Commit 4fa5632

Browse files
committed
[Schematic][Added] Support for SHEETNAME, SHEETFILE and SHEETPATH in the title block
1 parent 5990f86 commit 4fa5632

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Some limited support for the VARIANT and VARIANT_DESC variables found
1414
in KiCad 10. They can be used for things like 3D and print_pcb even
1515
for KiCad 6.
16+
- Schematic:
17+
- Support for SHEETNAME, SHEETFILE and SHEETPATH in the title block
1618
- Variants:
1719
- pre_transform filter to KiCad variants
1820
- E/DRC:

docs/source/Changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Added
2727
- Some limited support for the VARIANT and VARIANT_DESC variables found
2828
in KiCad 10. They can be used for things like 3D and print_pcb even
2929
for KiCad 6.
30+
- Schematic:
31+
32+
- Support for SHEETNAME, SHEETFILE and SHEETPATH in the title block
33+
3034
- Variants:
3135

3236
- pre_transform filter to KiCad variants

kibot/kicad/v6_sch.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,29 +2416,33 @@ def _fill_missing_title_block(self):
24162416
def _get_title_block(self, items):
24172417
if not isinstance(items, list):
24182418
raise SchError('The title block is not a list')
2419+
sheet_name = self.sheet_path_h.split('/')[-1]
2420+
if not sheet_name:
2421+
sheet_name = 'Root'
2422+
extra_vars = {'SHEETNAME': sheet_name, 'SHEETPATH': self.sheet_path_h, 'SHEETFILE': self.fname_rel}
24192423
for item in items:
24202424
if not isinstance(item, list) or len(item) < 2 or not isinstance(item[0], Symbol):
24212425
raise SchError('Wrong title block entry ({})'.format(item))
24222426
i_type = item[0].value()
24232427
if i_type == 'title':
24242428
self.title_ori = _check_str(item, 1, i_type)
2425-
self.title = GS.expand_text_variables(self.title_ori)
2429+
self.title = GS.expand_text_variables(self.title_ori, extra_vars=extra_vars)
24262430
elif i_type == 'date':
24272431
self.date_ori = _check_str(item, 1, i_type)
2428-
self.date = GS.expand_text_variables(self.date_ori)
2432+
self.date = GS.expand_text_variables(self.date_ori, extra_vars=extra_vars)
24292433
elif i_type == 'rev':
24302434
self.revision_ori = _check_str(item, 1, i_type)
2431-
self.revision = GS.expand_text_variables(self.revision_ori)
2435+
self.revision = GS.expand_text_variables(self.revision_ori, extra_vars=extra_vars)
24322436
elif i_type == 'company':
24332437
self.company_ori = _check_str(item, 1, i_type)
2434-
self.company = GS.expand_text_variables(self.company_ori)
2438+
self.company = GS.expand_text_variables(self.company_ori, extra_vars=extra_vars)
24352439
elif i_type == 'comment':
24362440
index = _check_integer(item, 1, i_type)
24372441
if index < 1 or index > 9:
24382442
raise SchError('Unsupported comment index {} in title block'.format(index))
24392443
value = _check_str(item, 2, i_type)
24402444
self.comment_ori[index-1] = value
2441-
self.comment[index-1] = GS.expand_text_variables(value)
2445+
self.comment[index-1] = GS.expand_text_variables(value, extra_vars=extra_vars)
24422446
else:
24432447
raise SchError('Unsupported entry in title block ({})'.format(item))
24442448
self._fill_missing_title_block()

0 commit comments

Comments
 (0)