Skip to content

Improved symbol property update #16

@petaflot

Description

@petaflot

In the process of making a PCB I figured I'd make my own footprint "for the sake of simplicity" so I had to change about a hundred symbol-footprint associations:

>>> sch=Schematic("fold_passings.kicad_sch")
>>> sch.symbol.JP44.property
<Collection [<PropertyString Reference = 'JP44'>, <PropertyString Value = 'Jumper_2_Bridged'>, <PropertyString Footprint = 'Jumper:SolderJumper-2_P1.3mm_Bridged_RoundedPad1.0x1.5mm'>, <PropertyString Datasheet = '~'>, <PropertyString Description = 'Jumper, 2-pole, closed/bridged'>]>
>>> sch.symbol.JP44.property.elementRemove('Footprint')
>>> sch.symbol.JP44.property.elementAdd('Footprint','compuchair:FoldPassing')
>>> sch.symbol.JP44.property
# no change:
>>> sch.symbol.JP44.property
<Collection [<PropertyString Reference = 'JP44'>, <PropertyString Value = 'Jumper_2_Bridged'>, <PropertyString Footprint = 'Jumper:SolderJumper-2_P1.3mm_Bridged_RoundedPad1.0x1.5mm'>, <PropertyString Datasheet = '~'>, <PropertyString Description = 'Jumper, 2-pole, closed/bridged'>]>
>>> sch.symbol.JP44.property.Footprint.value = 'compuchair:FoldPassing'
# still no change
>>> sch.symbol.JP44.property.Footprint.value = 'compuchair:FoldPassing'
AttributeError: 'str' object has no attribute 'value'
>>> sch.symbol.JP44.property['Footprint'].value = 'compuchair:FoldPassing'
TypeError: list indices must be integers or slices, not str
# make an educated guess on the index
>>> sch.symbol.JP44.property[2].value = 'compuchair:FoldPassing'
# success!

obviously, something a little more intuitive and user-friendly is desired, but I will not go as far as making a suggestion (I'll leave this to those who know the codebase better)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions