All elements have predefined anchor positions (e.g., a BJT has base, emitter, and collector; two-terminal elements have start, center, and end).
Once an element is placed in a drawing, you can access its anchor positions in two ways:
- Attribute access:
element.anchor_name (e.g., Q.base). - Bracket access:
element['anchor_name'] (useful if the anchor name contains special characters like dots).
Note: Anchor positions are relative to the drawing origin and are only available after the element has been placed in a drawing. You can inspect all available anchors before placement using the .anchors attribute, which returns a dictionary of anchors relative to the element's origin.
with schemdraw.Drawing() as d:
d.config(fontsize=10)
# Assigning to a variable allows anchor access
bjt = elm.BjtNpn()
bjt.label('base', 'base', color='blue')
# Accessing anchors after placement
print(bjt.base)
print(bjt['base'])