Check that pins exist,

make visible when "hide disconnected" is active
This commit is contained in:
Visa Tuominen 2022-08-15 12:11:28 +03:00
parent 514c26fcc7
commit 304b8df0be

View File

@ -142,7 +142,6 @@ class Connector:
hide_disconnected_pins: bool = False
autogenerate: bool = False
loops: List[List[Pin]] = field(default_factory=list)
loop_color: Optional[Color] = "WH"
ignore_in_bom: bool = False
additional_components: List[AdditionalComponent] = field(default_factory=list)
@ -179,11 +178,13 @@ class Connector:
self.show_pincount = self.style != 'simple' # hide pincount for simple (1 pin) connectors by default
for loop in self.loops:
# TODO: check that pins to connect actually exist
# TODO: allow using pin labels in addition to pin numbers, just like when defining regular connections
# TODO: include properties of wire used to create the loop
if len(loop) != 2:
raise Exception('Loops must be between exactly two pins!')
# check that pins to connect actually exist
if type(loop) == dict:
loop = list(loop.values())[0]
for pin in loop:
if not ((self.pins.count(pin) == 1) or (self.pinlabels.count == 1)):
raise Exception(f"Didn't find exactly one {self.name}:{pin} to loop into")
self.activate_pin(pin)
for i, item in enumerate(self.additional_components):
if isinstance(item, dict):