Re: Any BeanShell example for 8.0.1?

Steven Rubin <[email protected]> Thu, 20 Jan 2005 21:25:33 -0800
Newsgroups gmane.comp.cad.electric.general
Message-ID <[email protected]>
At 04:39 PM 1/19/2005, you wrote:
>Since 8.0.0, I have not been able to find any BeanShell script sample. Is 
>there any script we can see for Java version?

When the C version of Electric was in use, it had a Java interpreter with a 
limited interface that could be fully treated in a single chapter of the 
manual.

Now the Java version of Electric has a Java interpreter (the Bean Shell) 
that offers users the complete power of Java.  Any class in Electric which 
offers public methods is available to your code.  This is good news: you 
can do more.

But, really, this is bad news: it is harder to learn.  Now you have to 
study the entire Electric API.  The Electric source code has Javadoc 
comments in it which create a reasonable online manual.  However, that 
manual is not actually included with the download, so you must use the 
Javadoc command to extract it from the source code.

In any case, examples are often helpful, so here is an example.

This code makes a list of the nodes in the current cell:
--------------------------------------------------------------------------
import com.sun.electric.database.hierarchy.Library;
import com.sun.electric.database.hierarchy.Cell;
import com.sun.electric.database.topology.NodeInst;
import com.sun.electric.tool.user.ui.WindowFrame;

// get the cell in the current window
Cell cell = WindowFrame.needCurCell();
if (cell == null) return;

// examine the cell
System.out.println("Cell " + cell.describe() + " has " + cell.getNumNodes() 
+ " nodes:");
for(Iterator it = cell.getNodes(); it.hasNext(); )
{
   NodeInst ni = (NodeInst)it.next();
   System.out.println("   Node " + ni.describe() + " is connected to " + 
ni.getNumConnections() + " arcs");
}
--------------------------------------------------------------------------

    -Steve

_______________________________________________
Discuss-gnu-electric mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/discuss-gnu-electric