update fp generators to use relative 3d model paths
This commit is contained in:
parent
667882f48e
commit
179b6df910
|
@ -22,10 +22,12 @@ class Footprint:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
|
lib: Union[Path, str],
|
||||||
description: Optional[str] = None,
|
description: Optional[str] = None,
|
||||||
keywords: Optional[List[str]] = None,
|
keywords: Optional[List[str]] = None,
|
||||||
):
|
):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
self.lib = Path(lib)
|
||||||
self.description = "" if description is None else description
|
self.description = "" if description is None else description
|
||||||
self._pads = []
|
self._pads = []
|
||||||
self._models = []
|
self._models = []
|
||||||
|
@ -80,7 +82,7 @@ class Footprint:
|
||||||
scale: Tuple[float] = (1, 1, 1),
|
scale: Tuple[float] = (1, 1, 1),
|
||||||
):
|
):
|
||||||
self._contents += (
|
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"(offset (xyz {offset[0]} {offset[1]} {offset[2]})) "
|
||||||
f"(scale (xyz {scale[0]} {scale[1]} {scale[2]})) "
|
f"(scale (xyz {scale[0]} {scale[1]} {scale[2]})) "
|
||||||
f"(rotate (xyz {rotate[0]} {rotate[1]} {rotate[2]})) "
|
f"(rotate (xyz {rotate[0]} {rotate[1]} {rotate[2]})) "
|
||||||
|
@ -155,6 +157,6 @@ class Footprint:
|
||||||
")\n"
|
")\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
def write(self, lib: Union[Path, str]):
|
def write(self):
|
||||||
with open(Path(lib) / f"{self.name}.kicad_mod", "w") as f:
|
with open(self.lib / f"{self.name}.kicad_mod", "w") as f:
|
||||||
f.write(self._contents + ")")
|
f.write(self._contents + ")")
|
||||||
|
|
|
@ -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)
|
match = re.match(r"SM(\d\d)B-SRSS-TB", part)
|
||||||
pins = int(match[1])
|
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("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("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")
|
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")),
|
(round2grid(1.8 + 0.010 * INCH), s * round2grid(b / 2 + 0.010 * INCH, "up")),
|
||||||
layer="F.SilkS",
|
layer="F.SilkS",
|
||||||
)
|
)
|
||||||
fp.write(lib)
|
fp.write()
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,9 @@ def footprint(part: str, lib: Optional[Union[Path, str]] = None):
|
||||||
flavor = int(match[2])
|
flavor = int(match[2])
|
||||||
|
|
||||||
if flavor == 10:
|
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("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("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")
|
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),
|
rotate=(0, 0, -90),
|
||||||
)
|
)
|
||||||
fp.add_rect((4.6 - 9.9, -a / 2), (4.6, a / 2), layer="F.Fab")
|
fp.add_rect((4.6 - 9.9, -a / 2), (4.6, a / 2), layer="F.Fab")
|
||||||
fp.write(lib)
|
fp.write()
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -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]
|
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("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("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")
|
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),
|
(center[0], center[1], 0),
|
||||||
rotate=(-90, 0, 90),
|
rotate=(-90, 0, 90),
|
||||||
)
|
)
|
||||||
fp.write(lib)
|
fp.write()
|
||||||
|
|
||||||
elif any([part.startswith(s) for s in ["SSW-"]]):
|
elif any([part.startswith(s) for s in ["SSW-"]]):
|
||||||
# socket
|
# socket
|
||||||
|
|
Loading…
Reference in New Issue
Block a user