update fp generators to use relative 3d model paths

This commit is contained in:
Brendan Haines 2022-10-29 15:35:39 -06:00
parent 667882f48e
commit 179b6df910
4 changed files with 13 additions and 9 deletions

View File

@ -22,10 +22,12 @@ class Footprint:
def __init__(
self,
name: str,
lib: Union[Path, str],
description: Optional[str] = None,
keywords: Optional[List[str]] = None,
):
self.name = name
self.lib = Path(lib)
self.description = "" if description is None else description
self._pads = []
self._models = []
@ -80,7 +82,7 @@ class Footprint:
scale: Tuple[float] = (1, 1, 1),
):
self._contents += (
f' (model "{str(Path(path).resolve())}" '
f' (model "{str(Path(path).relative_to(self.lib))}" '
f"(offset (xyz {offset[0]} {offset[1]} {offset[2]})) "
f"(scale (xyz {scale[0]} {scale[1]} {scale[2]})) "
f"(rotate (xyz {rotate[0]} {rotate[1]} {rotate[2]})) "
@ -155,6 +157,6 @@ class Footprint:
")\n"
)
def write(self, lib: Union[Path, str]):
with open(Path(lib) / f"{self.name}.kicad_mod", "w") as f:
def write(self):
with open(self.lib / f"{self.name}.kicad_mod", "w") as f:
f.write(self._contents + ")")

View File

@ -83,7 +83,7 @@ def footprint(part: str, lib: Optional[Union[Path, str]] = None):
match = re.match(r"SM(\d\d)B-SRSS-TB", part)
pins = int(match[1])
fp = Footprint(part, description=f"connector, JST-SH, 1x{pins:02f}, RA")
fp = Footprint(part, lib=lib, description=f"connector, JST-SH, 1x{pins:02f}, RA")
fp.add_text("reference", "REF**", (5.55 + (0.025 + 0.005) * INCH), 0, rotation=90, layer="F.SilkS")
fp.add_text("value", "VAL**", 4 * 0.025 * INCH, 0, rotation=90, layer="F.Fab")
fp.add_text("user", r"${REFERENCE}**", 2 * 0.025 * INCH, 0, rotation=90, layer="F.Fab")
@ -133,7 +133,7 @@ def footprint(part: str, lib: Optional[Union[Path, str]] = None):
(round2grid(1.8 + 0.010 * INCH), s * round2grid(b / 2 + 0.010 * INCH, "up")),
layer="F.SilkS",
)
fp.write(lib)
fp.write()
else:
raise NotImplementedError

View File

@ -74,7 +74,9 @@ def footprint(part: str, lib: Optional[Union[Path, str]] = None):
flavor = int(match[2])
if flavor == 10:
fp = Footprint(part, description=f"connector, Micro-Fit 3.0, 1x{pins:02f}, RA, press-fit retention clip")
fp = Footprint(
part, lib=lib, description=f"connector, Micro-Fit 3.0, 1x{pins:02f}, RA, press-fit retention clip"
)
fp.add_text("reference", "REF**", -(6.93 + (0.025 + 0.005) * INCH), 0, rotation=90, layer="F.SilkS")
fp.add_text("value", "VAL**", -0.025 * INCH, 0, rotation=90, layer="F.Fab")
fp.add_text("user", r"${REFERENCE}**", 0.025 * INCH, 0, rotation=90, layer="F.Fab")
@ -118,7 +120,7 @@ def footprint(part: str, lib: Optional[Union[Path, str]] = None):
rotate=(0, 0, -90),
)
fp.add_rect((4.6 - 9.9, -a / 2), (4.6, a / 2), layer="F.Fab")
fp.write(lib)
fp.write()
else:
raise NotImplementedError
else:

View File

@ -129,7 +129,7 @@ def footprint(part: str, lib: Optional[Union[Path, str]] = None) -> str:
center = [strobe[0] * (cols - 1) / 2, strobe[1] * (rows - 1) / 2]
fp = Footprint(fp_name, description=description, keywords=keywords)
fp = Footprint(fp_name, lib=lib, description=description, keywords=keywords)
fp.add_text("reference", "REF**", center[0], -2.032, layer="F.SilkS")
fp.add_text("value", "VAL**", center[0] - 0.025 * INCH, center[1], rotation=90, layer="F.Fab")
fp.add_text("user", r"${REFERENCE}**", center[0] + 0.025 * INCH, center[1], rotation=90, layer="F.Fab")
@ -154,7 +154,7 @@ def footprint(part: str, lib: Optional[Union[Path, str]] = None) -> str:
(center[0], center[1], 0),
rotate=(-90, 0, 90),
)
fp.write(lib)
fp.write()
elif any([part.startswith(s) for s in ["SSW-"]]):
# socket