Skip to content

Commit

Permalink
Fix LCSC numbers appearing on silkscreen (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
whmountains authored Oct 11, 2024
1 parent 1343670 commit a39bf1d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,19 @@ def get_lcsc_value(fp):

def set_lcsc_value(fp, lcsc: str):
"""Set an lcsc number to the first matching propertie of the footprint, use LCSC as property name if not found."""
lcsc_field = "LCSC"
lcsc_field = None
for field in fp.GetFields():
if re.match(r"lcsc|jlc", field.GetName(), re.IGNORECASE) and re.match(
r"^C\d+$", field.GetText()
):
lcsc_field = field.GetName()
fp.SetField(lcsc_field, lcsc)
lcsc_field = field

if lcsc_field:
fp.SetField(lcsc_field.GetName(), lcsc)
else:
fp.SetField("LCSC", lcsc)
field = fp.GetFieldByName("LCSC")
field.SetVisible(False)

def get_valid_footprints(board):
"""Get all footprints that have a valid reference (drop all REF**)."""
Expand Down

0 comments on commit a39bf1d

Please sign in to comment.