[SCH Variant] Added option to change the title
- Similar to PCB Variant
This commit is contained in:
parent
f615790ddc
commit
6cf6b08450
|
|
@ -11,7 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Support for Eurocircuits drill adjust to fix small OARs.
|
||||
Option `eurocircuits_reduce_holes`. (#227)
|
||||
- Diff: mechanism to compare using a variant (See #278)
|
||||
- Sch Variant: option to copy the project. Needed for text variables.
|
||||
- Sch Variant:
|
||||
- Option to copy the project. Needed for text variables.
|
||||
- Option to change the title (similar to PCB Variant)
|
||||
|
||||
### Fixed
|
||||
- Problems to compress netlists. (#287)
|
||||
|
|
|
|||
|
|
@ -2806,6 +2806,8 @@ Notes:
|
|||
Disabled by default for compatibility with older versions.
|
||||
- `dnf_filter`: [string|list(string)='_none'] Name of the filter to mark components as not fitted.
|
||||
A short-cut to use for simple cases where a variant is an overkill.
|
||||
- `title`: [string=''] Text used to replace the sheet title. %VALUE expansions are allowed.
|
||||
If it starts with `+` the text is concatenated.
|
||||
- `variant`: [string=''] Board variant to apply.
|
||||
- `category`: [string|list(string)=''] The category for this output. If not specified an internally defined category is used.
|
||||
Categories looks like file system paths, i.e. PCB/fabrication/gerber.
|
||||
|
|
|
|||
|
|
@ -1684,6 +1684,9 @@ outputs:
|
|||
# [string|list(string)='_none'] Name of the filter to mark components as not fitted.
|
||||
# A short-cut to use for simple cases where a variant is an overkill
|
||||
dnf_filter: '_none'
|
||||
# [string=''] Text used to replace the sheet title. %VALUE expansions are allowed.
|
||||
# If it starts with `+` the text is concatenated
|
||||
title: ''
|
||||
# [string=''] Board variant to apply
|
||||
variant: ''
|
||||
# STEP (ISO 10303-21 Clear Text Encoding of the Exchange Structure):
|
||||
|
|
|
|||
|
|
@ -1831,6 +1831,18 @@ class Schematic(object):
|
|||
f.write(')\n')
|
||||
return fname
|
||||
|
||||
def get_title(self):
|
||||
return self.title_block.get('Title', '')
|
||||
|
||||
def set_title(self, title):
|
||||
""" Used only to save a variant """
|
||||
old_title = self.title_block.get('Title')
|
||||
if title is None:
|
||||
del self.title_block['Title']
|
||||
else:
|
||||
self.title_block['Title'] = title
|
||||
return old_title
|
||||
|
||||
def file_names_variant(self, dest_dir):
|
||||
""" Returns a list of file names created by save_variant() """
|
||||
fnames = [os.path.join(dest_dir, 'y.lib'),
|
||||
|
|
|
|||
|
|
@ -1773,6 +1773,15 @@ class SchematicV6(Schematic):
|
|||
fparts = os.path.splitext(file)
|
||||
sch.flat_file = fparts[0]+'_'+str(len(self.sheet_names))+fparts[1]
|
||||
|
||||
def get_title(self):
|
||||
return self.title_ori
|
||||
|
||||
def set_title(self, title):
|
||||
""" Used only to save a variant """
|
||||
old_title = self.title_ori
|
||||
self.title_ori = title
|
||||
return old_title
|
||||
|
||||
def load(self, fname, project, parent=None): # noqa: C901
|
||||
""" Load a v6.x KiCad Schematic.
|
||||
The caller must be sure the file exists.
|
||||
|
|
|
|||
|
|
@ -605,19 +605,28 @@ class VariantOptions(BaseOptions):
|
|||
# Re-enable the modules that aren't for this variant
|
||||
self.apply_3D_variant_aspect(board, enable=True)
|
||||
|
||||
def set_title(self, title):
|
||||
def set_title(self, title, sch=False):
|
||||
self.old_title = None
|
||||
if title:
|
||||
tb = GS.board.GetTitleBlock()
|
||||
self.old_title = tb.GetTitle()
|
||||
if sch:
|
||||
self.old_title = GS.sch.get_title()
|
||||
else:
|
||||
tb = GS.board.GetTitleBlock()
|
||||
self.old_title = tb.GetTitle()
|
||||
text = self.expand_filename_pcb(title)
|
||||
if text[0] == '+':
|
||||
text = self.old_title+text[1:]
|
||||
tb.SetTitle(text)
|
||||
if sch:
|
||||
self.old_title = GS.sch.set_title(text)
|
||||
else:
|
||||
tb.SetTitle(text)
|
||||
|
||||
def restore_title(self):
|
||||
def restore_title(self, sch=False):
|
||||
if self.old_title is not None:
|
||||
GS.board.GetTitleBlock().SetTitle(self.old_title)
|
||||
if sch:
|
||||
GS.sch.set_title(self.old_title)
|
||||
else:
|
||||
GS.board.GetTitleBlock().SetTitle(self.old_title)
|
||||
self.old_title = None
|
||||
|
||||
def sch_fields_to_pcb(self, comps, board):
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ class Sch_Variant_Options(VariantOptions):
|
|||
self.copy_project = False
|
||||
""" Copy the KiCad project to the destination directory.
|
||||
Disabled by default for compatibility with older versions """
|
||||
self.title = ''
|
||||
""" Text used to replace the sheet title. %VALUE expansions are allowed.
|
||||
If it starts with `+` the text is concatenated """
|
||||
super().__init__()
|
||||
|
||||
def get_targets(self, out_dir):
|
||||
|
|
@ -23,7 +26,9 @@ class Sch_Variant_Options(VariantOptions):
|
|||
def run(self, output_dir):
|
||||
super().run(output_dir)
|
||||
# Create the schematic
|
||||
self.set_title(self.title, sch=True)
|
||||
GS.sch.save_variant(output_dir)
|
||||
self.restore_title(sch=True)
|
||||
if self.copy_project:
|
||||
GS.copy_project(os.path.join(output_dir, GS.sch_basename+'.kicad_pcb'))
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ outputs:
|
|||
options:
|
||||
variant: default
|
||||
copy_project: true
|
||||
title: '+ (%V)'
|
||||
|
||||
- name: 'sch_production'
|
||||
comment: "Schematic w/production variant"
|
||||
|
|
@ -36,6 +37,7 @@ outputs:
|
|||
options:
|
||||
variant: production
|
||||
copy_project: true
|
||||
title: '+ (%V)'
|
||||
|
||||
- name: 'sch_test'
|
||||
comment: "Schematic w/test variant"
|
||||
|
|
@ -44,6 +46,7 @@ outputs:
|
|||
options:
|
||||
variant: test
|
||||
copy_project: true
|
||||
title: '+ (%V)'
|
||||
|
||||
- name: 'diff_sch'
|
||||
comment: "Schematic difference with variant"
|
||||
|
|
|
|||
Loading…
Reference in New Issue