The AWR Design Environment API is implemented as a Component Object Model (COM) Automation-compliant API. This allows the AWR Design Environment application to act as a COM Automation Server whose object model can be controlled from any programming language (such as Visual C++) or scripting engine (such as Visual Basic, Java Script or Perl) that can act as an COM Automation Client, providing you with unlimited ways to extend the capabilities of AWR Design Environment. It allows you to create scripts to do things such as automate complex tasks, and author wizards to do things such as implement add-on tools. Scripts appear in a menu on the main window and Wizards appear as a group in the AWR Design Environment design environment's Project View.
Getting Started
The easiest way to get started is to use the script editor built right into the AWR Design Environment. Figure 1 shows the the location of the toolbar button which opens the built-in scripting environment.
Figure 1: Scripting Editor Toolbar Button
The scripting environment provides a complete integrated development environment (IDE) for script development right in AWR DE. Pressing the scripting editor button will bring up the IDE window shown in Figure 2.
Figure 2: Scripting Editor Window
Within the Script Editor window there are two main sections, the project area which shows a tree view of both global and project local scripts and script editing area where scripts can be entered and edited.
The project tree is broken into two separate tree's at the root:
Script (global.mws) contains scripts which are held in the user profile and are available inside all projects. This is where you store generic scripts which apply to all projects.
Script (<project name>) contains scripts which are local to this particular project and are saved with the project. These will only be available when this particular project is loaded. This is where you can store scripts that apply to this project.
To add a script right-click on either Script(global.mws) or Script(<project name>) and from the context menu select "Insert Module". This will create a new script module in the tree you clicked on and bring up a script window in the script area.
Once you have a script window you can begin by writing code between the Sub Main and End Sub statements in the script window.
The Immediate window (upper half pane) can be used to evaluate expressions interactively. Start by typing a question mark '?' followed by a valid expression and press enter to see the result. In Figure 2, I've entered the following expression:
? Project.BuildNumber
and the response is
3891&
Indicating that the project was created with build number 3891 of the AWR Design Environment.
To get you started try the following short script which creates a schematic and adds a MLIN element to it.
' Code Module Sub Main Dim schem As Schematic Dim elem As Element Set schem = Project.Schematics.Add("MySchematic") Set elem = schem.Elements.Add("MLIN", 0, 0) End Sub
To run this script press the run button on the tool bar which looks like the play button on a VCR or tape recorder.
Figure 3: Run toolbar button just below the Help menu item.