Frames
Frames help to visually organize different subgraphs of circuits. These subgraphs are determined during execution of the Circuitscript code and is used by the layout engine to group graphical circuits together.
Frames must completely encapsulate a subgraph/multiple subgraphs, otherwise the graphical output may be incorrect/unpredictable.
It is always a good practice to organize schematics for clarity
Example:
from "std" import *
v5v = supply("5V")
gnd = dgnd()
frame:
..title = "Pull down resistor"
at v5v
wire down 100
add res(10k)
wire down 100
to gnd
frame:
..title = "Decoupling cap"
at v5v
wire down 100
add cap(100n)
wire down 100
to gnd
Header syntax
The title and a few common options can be written directly on the frame line:
frame ["title"] [row|column] [layout]:
- The title must be a string expression. A variable holding a string can be used, for example
frame title:. roworcolumnsets the framedirection. Only one of them can be given.layoutsets bothborderandpaddingto 0, which is useful for frames that only group other frames...borderand..paddinginside the frame body can still override these values.- A modifier can be used without a title, for example
frame row:.
Errors are reported for an unknown modifier, a duplicated modifier, using both row and column, or a title that is not a string.
from "std" import *
v5v = supply("5V")
gnd = dgnd()
frame "Power" column layout:
frame "Pull down resistor":
at v5v
wire down 100
add res(10k)
wire down 100
to gnd
frame "Decoupling cap":
at v5v
wire down 100
add cap(100n)
wire down 100
to gnd
Frame properties
Frame properties can be set by using the double dot (..) operator followed by the property name. This operator must be used immediately after the frame command is called.
title
Specify the title to display in the frame.
from "std" import *
v5v = supply("5V")
gnd = dgnd()
frame:
..title = "Pull down resistor"
at v5v
wire down 100
add res(10k)
wire down 100
to gnd
border
The frame border thickness can be set to draw thicker/thinner borders. Set the frame border to 0 to hide the border.
from "std" import *
v5v = supply("5V")
v3v3 = supply("3V3")
gnd = dgnd()
frame:
..title = "With border"
..border = 5
at v5v
wire down 100
add res(10k)
wire down 100
to gnd
frame:
..title = "With no border"
..border = 0
at v5v
wire down 100
add res(10k)
wire down 100
to gnd
frame:
..title = "With thicker border"
..border = 20
at v5v
wire down 100
add res(10k)
wire down 100
to gnd
width and height
Sets the dimensions of the frame
from "std" import *
v5v = supply("5V")
gnd = dgnd()
frame:
..width = 1500
..height = 1500
at v5v
wire down 100
add res(10k)
wire down 100
to gnd
direction
Specify how subgraphs within the frame should be arranged. There are currently two possible options: row and column. When unspecified, the frame direction is row.
Example for row direction:
from "std" import *
v5v = supply("5V")
v3v3 = supply("3V3")
gnd = dgnd()
frame:
..title = "Pull down resistors"
at v5v
wire down 100
add res(10k)
wire down 100
to gnd
at v3v3
wire down 100
add res(20k)
wire down 100
to gnd
Example for column direction:
from "std" import *
v5v = supply("5V")
v3v3 = supply("3V3")
gnd = dgnd()
frame:
..title = "Pull down resistors"
..direction = "column"
at v5v
wire down 100
add res(10k)
wire down 100
to gnd
at v3v3
wire down 100
add res(20k)
wire down 100
to gnd
align
Sets the horizontal alignment of content within the frame. Possible values are "left", "center", "right".
from "std" import *
v5v = supply("5V")
v3v3 = supply("3V3")
gnd = dgnd()
frame:
..title = "align left"
..direction = "row"
..align = "left"
..width = 1000
at v3v3
wire down 100
add res(20k)
wire down 100
to gnd
frame:
..title = "align center"
..direction = "row"
..align = "center"
..width = 1000
at v3v3
wire down 100
add res(20k)
wire down 100
to gnd
frame:
..title = "align right"
..direction = "row"
..align = "right"
..width = 1000
at v3v3
wire down 100
add res(20k)
wire down 100
to gnd
valign
Sets the vertical alignment of content within the frame. Possible values are "top", "center", "bottom".
from "std" import *
v5v = supply("5V")
v3v3 = supply("3V3")
gnd = dgnd()
frame:
..title = "align top"
..direction = "row"
..valign = "top"
..width = 1000
..height = 2000
at v3v3
wire down 100
add res(20k)
wire down 100
to gnd
frame:
..title = "align center"
..direction = "row"
..valign = "center"
..width = 1000
..height = 2000
at v3v3
wire down 100
add res(20k)
wire down 100
to gnd
frame:
..title = "align bottom"
..direction = "row"
..valign = "bottom"
..width = 1000
..height = 2000
at v3v3
wire down 100
add res(20k)
wire down 100
to gnd
place_default
Sets the default place state for every component inside the frame (and inside sheets, which are frames too). Setting ..place_default = false marks all contained components as not placed: they are left out of the BOM (see Do not install) and flagged as DNP in KiCad exports.
- The value must be a boolean (an expression such as
(variant == "lite")works). Any other value raises an error. - A
..placeset directly on a component always wins over the frame default. - Nested frames inherit the default from the enclosing frame and can override it.
- Nets, graphics and ports are not affected.
This is useful for assembly variants, where a whole block of the circuit is fitted only in some builds:
from "std" import *
v5v = supply("5V")
gnd = dgnd()
frame:
..title = "Fitted"
at v5v
wire down 100
add res(10k)
wire down 100
to gnd
frame:
..title = "Not fitted"
..place_default = false
at v5v
wire down 100
add res(1k)
wire down 100
to gnd
Nested frames and arranging frames
Frames can be nested and combined to visually organize circuits better.
from "std" import *
v3v3 = supply("3V3")
gnd = dgnd()
frame:
..border = 0
..title = "LEDs"
..direction = "row"
frame:
..title = "LED 1"
at v3v3
wire down 100
add res(100)
wire down 100
add led("green") pin 2
wire down 100
to gnd
frame:
..title = "LED 2"
at v3v3
wire down 100
add res(100)
wire down 100
add led("green") pin 2
wire down 100
to gnd
frame:
..title = "LED 3"
at v3v3
wire down 100
add res(100)
wire down 100
add led("green") pin 2
wire down 100
to gnd