Skip to main content

Creating components

Component creation

A new component is created by using the create component command and specifying the pins parameter.

my_component = create component:
pins: 2

at my_component

1122J1

The code above creates a component object with 2 pins. The pins are automatically generated with a pin ID of 1 and 2 respectively.

Pin names can also be defined in the symbol object:

my_component = create component:
pins:
1: "anode"
2: "cathode"
at my_component

anode1cathode2J1

Parameter during component creation

The following parameters may be declared during component creation:

NameDescription
pinsIf a single number is specified, the number of pins will be automatically created. Otherwise, pins with the given ID and names will be generated
typeType of component, this may be used to determine the refdes group of the component. Supported values: net, label, res, cap, ind, diode, conn
displaySpecify the graphic to display as the symbol of the component. If unspecified, a default rectangular symbol is generated.
copyIf this is set to 1, whenever this component is referenced, a copy of the component will be created and used instead.
angleSets the default angle of the component's graphical symbol. Please refer to this page on how angles are specified.
paramsA map that specifies parameters of the component. This may be changed after component creation. Please see this page for more information.

Component parameters

Please see the page on component parameters to set parameters such as footprint, value and place.

Component graphical symbol

By default, the graphical symbol for the component is generated automatically. Pins are arranged in a zig-zag arrangement.

Default graphical symbol

my_component = create component:
pins: 10

at my_component

1133557799224466881010J1

Specifying pin positions

The position of each component pin can be specified using the arrange parameter. Specify which pin IDs are to be placed on the left and right sides of the component.

my_component = create component:
pins: 10
arrange:
left: 1, 2, 3, 4
right: 5, 6, 7, 8, 9, 10
at my_component

1122334455667788991010J1

Blank pin positions

To add spaces between pins, use the blank placeholder [<number] to specify a blank pin position.

my_component = create component:
pins: 10
arrange:
left: [1], 1, [2], 2, 3
right: 4, 5, 6, 7, 8, 9, 10
at my_component

1122334455667788991010J1

Component pin types

The pin type of each component can be specified to provide more information about the pin. The following pin types are supported:

ConstantPin typeDescription
anyAnyThe default value for any pin
powerPowerPin is used for supply pins, GND, etc.
inputInputSignal input into pin
outputOutputSignal output of pin
ioInput/OutputSignal input and output of pin

Example:

my_component = create component:
pins:
1: input, "IN"
2: output, "OUT"
3: power, "VCC"
4: power, "GND"

at my_component

IN1VCC3OUT2GND4J1

The above component created has two power pins, one for pin 3 (VCC) and pin 4 (GND). Pin 1 is a signal input pin and pin 2 is a signal output pin.

Drawing custom component graphics

Custom component graphics is drawn using the create graphic command. Specfic drawing commands can be used to draw the component body and also define the placement of component pins.

width = 100
height = 100

my_component = create component:
pins: 2
display: create graphic:
triangle: -width/2, 0, width/2, 0, height
vline: width/2, -height/2, height
hpin: 1, -width/2-100, 0, 100 # anode
hpin: 2, width/2 + 100, 0, -100 # cathode
label: "refdes", 0, -100, "?", fontSize=50, anchor="middle", vanchor="top"

at my_component

12J1

The syntax for drawing commands are as follows: <command>: <arg1>, <arg2>, ...

pin drawing command

pin: <pin ID: number>, <pin start x: number>, <pin start y: number>, <pin end x: number>, <pin end y: number>

With pin type and pin name specified

pin: <pin ID: number>, <pin type: optional>, <pin name: string>, <pin start x: number>, <pin start y: number>, <pin end x: number>, <pin end y: number>

The pin consists of the pin start point and the pin end point. The pin start point is where wires and other components connect to.

Example:

my_component = create component:
pins: 2
display: create graphic:
rect: 0, 0, 200, 100
pin: 1, -200, 0, -100, 0
pin: 2, 200, 0, 100, 0
path: ("M", 125, -50, "L", 200, -50,
"M", 150, -75, "L", 125, -50, "L", 150, -25)
path: ("M", -125, -50, "L", -200, -50,
"M", -150, -75, "L", -125, -50, "L", -150, -25)

at my_component pin 1
wire left 100

at my_component pin 2
wire right 100

12

In the example above, the arrows indicate the direction of the pins. When building circuits, wires and other components are always connected at the start of the pin. In the example above, the wires are connected at side of the pin without the arrow-head.

pin drawing command with pin name

pin: <pin ID: number>, <pin name: string>, <pin start x: number>, <pin start y: number>, <pin end x: number>, <pin end y: number>

This command is used to display a pin name beside the pin. The pin name is placed at the end point of the pin. Specify the pin name as a string after the pin ID.

Example:

my_component = create component:
pins: 2
display: create graphic:
rect: 0, 0, 200, 100
pin: 1, "A", -200, 0, -100, 0
pin: 2, "B", 200, 0, 100, 0
path: ("M", 125, -50, "L", 200, -50,
"M", 150, -75, "L", 125, -50, "L", 150, -25)
path: ("M", -125, -50, "L", -200, -50,
"M", -150, -75, "L", -125, -50, "L", -150, -25)

at my_component pin 1
wire left 100

at my_component pin 2
wire right 200

A1B2

In the above example, the pin name is displayed beside the pins.

Additional properties:

  • Set display_pin_id=0 to skip drawing of pinId beside the pin

hpin drawing command

This command is a simplification of the pin command and is used to draw horizontal pins. hpin: <pin id>, <pin start x: number>, <pin start y: number>, <pin x length>

vpin drawing command

This command is a simplification of the pin command and is used to draw vertical pins. vpin: <pin id>, <pin start x: number>, <pin start y: number>, <pin y length>

rect drawing command

rect: <center x: number>, <center y: number>, <width: number>, <height: number>

label drawing command

label: <label name: string>, <x: number>, <y: number>, <text: string>, <...named parameters>

Currently, only the following named parameters are accepted:

  • fontSize: number
  • anchor: One of "left", "middle", "right",
  • vanchor: One of "top", "middle", "bottom"

hline drawing command

Draws a horizontal line of a given length starting from the point.

hline: <x: number>, <y: number>, <length: number>

vline drawing command

Draws a vertical line of a given length starting from the specified point.

vline: <x: number>, <y: number>, <length: number>

arc drawing command

Draws a section of a circle at a given location and radius. The section is drawn in a clockwise direction from the starting angle to the ending angle.

arc: <center x>, <center y>, <radius>, <starting angle>, <ending angle>

path drawing command

path: <... array of drawing instructions>

The path command is similar to path in the SVG spec.

Example:

path: "M", 0, 0, "L", 10, 10

This path command moves the drawing cursor to (0, 0) and draws a line until (10, 10)

path: "M", 100, 100, "L", 200, 200, "L", 200, 100

This path commands starts at (100, 100), draws a line until (200, 200) and a further line until (200, 100)

At the moment, only the "M" and "L" instructions are supported.