Closed monthiller closed 3 weeks ago
Should be fixed by caae92074e520835c0c09c476883f82e14087864.
Long answer:
It had to do with the way the context manager adds elements to the drawing. It can't calculate position of an element when it's instantiated, because a later call to at
or the like will change it's position. So the context manger queues up the element until it's ready to position - "ready" meaning either 1) another Element was instantiated, or 2) a position attribute was requested but not filled in yet, or 3) the context manager exits. Option 2 means Element overrides getattr to check for this case, but that logic didn't extend to IC pins because they are not assigned to the anchor list in the same way.
Note this approach could cause other unexpected behavior, such as this case:
with schemdraw.Drawing():
p = elm.Dot()
elm.Line()
p.at((3,3))
The Dot position is determined at the time the Line is created, so moving it later with at
won't do anything.
Is there a reason why I can't reference the pins of the elm.Ic directly: pin = getattr(custom_ic, k) => error pin = custom_ic.A0 => error elm.Line().at(getattr(custom_ic, k) ).length(2).right().label(v) = OK 2 Tests scripts with error and non-error output provided.
Test script1:
output(error):
Test script1:
output
Your library look pretty amazing. Isn't the point of your library to be able to draw schematics dynamically from external data. I didn't see any example for this use case. The existing example are with hardcoded "labels" and "pin" names...