Electric has two scripting languages: Java (using the Bean Shell) and Python (using Jython). These languages enable you to load custom code that adds functionality to Electric. Neither of these languages is part of the default Electric distribution. You must add them as "plug ins" (see Section 1-5 for more on plug-ins).
To run Java code, use the Run Java Bean Shell Script... command (in menu Tools / Languages). To run Python code, use the Run Jython Script... command. Note that during execution of these pieces of code, Electric may give warning messages about preferences, which can be ignored.
| You can attach code to the Tools / Languages menu by using the Manage Scripts... command. Scripts of code can have mnemonic letters assigned to them (see Section 1-9 for more on mnemonics). | ![]() |
Here are some example programs in the Java Bean Shell. For more information about accessing the internals of Electric, read the Javadoc in the source code.
|
This program searches the current cell, printing all transistors and all exports that start with the letter "a".
Notice that Electric's "Export" object must be a fully-qualified name, because the name "Export" is used for other purposes in the Bean Shell. This also applies to Electric's "EPoint" class. |
|
This program creates a new cell, places a transistor in it, and displays the cell. |
|
This program goes a bit further: it creates a rotated transistor and a contact, wires them together, and exports the contact. The transistor is named "T1." |
|
This program creates a new cell, places a transistor in it, and displays the cell. |
|
This program goes a bit further: it creates a rotated transistor and a contact, wires them together, and exports the contact. The transistor is named "T1." |