Component orientation
The orientation of the component is important for the visual organization of the circuit. A well-organized circuit improves the understanding of the overall circuit's function and purpose. Each component has an "angle" modifier that can be changed to set the component's orientation.
Component angle
The component's angle can be set by specifying the angle: modifier when the component is created.
Example:
from "std" import *
v5v = supply("5V")
gnd = dgnd()
at v5v
wire down 100
add res(10k) angle:0
wire down 100
to gnd
at v5v
wire down 100
add res(10k) angle:90
wire down 100
to gnd
at v5v
wire down 100
add res(10k) angle:180
wire down 100
to gnd
Component angle from wires
The component's angle can also be automatically assigned based on the first wire that is connected to it.
Example:
from "std" import *
v5v = supply("5V")
gnd = dgnd()
at v5v
wire down 100
branch:
wire down 100
add res(10k)
wire down 100
to gnd
branch:
wire right 100
add res(10k)
wire right 100 to gnd
branch:
wire left 100
add res(10k)
wire left 100 to gnd
In the example above, the orientation/angle of R1 is set 90 degrees. This is because the first wire that connects to R1 has a down orientation.
R2 has an angle of 0 degrees as the first wire that connects to it has an orientation of right. R3 is automatically flipped horizontally as the wire that it is connected to has an orientation of left.
Flipping components
A component can be mirrored with the flip: modifier. flip:"x" mirrors the symbol horizontally (left and right swap) and flip:"y" mirrors it vertically (top and bottom swap).
The axis must be written as a string. The unquoted form (flip:x) is no longer supported; use flip:"x" instead.
When angle: and flip: are used together, the component is rotated first and then mirrored, the same order KiCad uses. In the example below, the last component is rotated by 90 degrees and the rotated symbol is then mirrored left-to-right, so the OUT and EN pins swap sides.
def part():
return create component:
pins:
1: "IN"
2: "OUT"
3: "EN"
arrange:
left: 1
right: 2, 3
frame:
..direction = "row"
at part()
at part() flip:"x"
at part() angle:90
at part() angle:90 flip:"x"
Before Circuitscript 0.12.1 the flip was applied before the rotation. A single flip combined with a 90 or 270 degree angle now mirrors in the opposite direction, so existing designs that combine the two may need the flip axis changed.
When a wire forces a flipped component to turn around, Circuitscript keeps the user's flip visible: it mirrors the component along the pin's axis if possible, and falls back to a 180 degree rotation otherwise.