Title: PCB Automation MARLUG October 2004
1PCB AutomationMARLUGOctober 2004
2Todays Agenda
- Automation overview presentation (40 min)
- Demo of some internal/external scripts - (10 min)
- Question Answer session (10 min)
3What is Automation?
- PCB Automation is actually COM Automation
(Component Object Model). - COM Automation is a Microsoft technology which
allows server applications to expose data and
functionality to be used by automation clients. - COM Automation is also supported on Unix/Linux
platforms through the use of MainWin (Windows
emulator). - Functionality exposed through COM Automation is
language independent. - In addition to exposing data, PCB applications
also have an internal scripting environment to
run automation clients.
4What is Automation NOT?
- Automation is NOT Ample!!! It is not a
transcripting language. - Automation does not define or restrict itself to
a scripting or programming language.
5What can I do with Automation?
- Add needed tool functionality
- Extend capabilities of existing tools
- Customize work environments
- Filter or sort a variety of design elements
- Add new commands reacting to mouse events
- Integrate with other applications
6Who needs Automation Scripting Capabilities?
- Medium to large organizations that need to
streamline their design environment. - Customers that need specialized functionality
that the standard tools do not offer. - Customers that have many downstream applications
that need better integration with the layout
tools.
7Supported Platforms
- Any platform supported by the PCB products also
support automation. - Windows
- Linux
- Sun SPARC
- HP
8What products support Automation?
- Board Station RE
- Expedition PCB
- Fablink XE/XE Pro
- PCB Viewer
- PCB Planner
- SFXRE
9Supported Languages
- COM Automation exposes a language independent
library of functions (some examples). - Perl
- Tcl
- C
- PCB Automation uses the scripting languages
VBScript and JScript. - Both VBScript and JScript can run on all
supported platforms.
10Automation Terminology
- Server Application exposing functionality
- (e.g. ExpeditionPCB, BoardStationRE)
- Client Application/script making requests of
the server - Type Library (Interface) Set of objects,
properties, and methods exposed by a server - (e.g. MGCPCB type library)
11Automation Clients
- PCB Automation clients can be run as internal or
external clients. - Internal clients run in the same process space as
the server and therefore have better performance.
Internal Client
PCB Application
External Client
12Running Internal Automation Clients
- Internal clients can be run through the keyin
edit box on the tool bar. - Users can also drag and drop scripts onto the
application to run them internally.
13Automation Client Locations
- The server will look for scripts in the following
locations and in the following order. - Application bin directory (\vbexppcb\bin)
- Job directory ( in the .pcb file container)
- Users home directory
14Running External Automation Clients
- External clients are run by invoking the client
application or by running the script in a
scripting engine. - The Windows OS has scripting engines available,
however, the mgcscript scripting engine is the
only scripting engine that will work on all
platforms. - To run a script using the mgcscript command
line - mgcscript MyClient.vbs parameters
15Scripting Terminology
- Object A reference to data or possibly a GUI
element in the server - (e.g. Component, Trace, Dialog, etc.)
- Collection A set of objects
- (e.g. Traces, Vias, etc.)
- Property An attribute of an object
- (e.g. width geomObj.Width)
- Method Functional operation on an object
- (e.g. docObj.PutTrace())
16Acquiring the Server in VBScript
- Make a call to acquire the server.
- Clients use program IDs to find a specific
server. - Program IDs are formatted MGCPCB.ltapp_namegtApplic
ation - MGCPCB.ExpeditionPCBApplication
- Clients can create an instance of the server with
CreateObject. - Set pcbApp CreateObject(MGCPCB.ExpeditionPCBA
pplication) - Clients can attach to a running instance of the
server by calling GetObject. - Set pcbApp GetObject(,MGCPCB.ExpeditionPCBApp
lication) - Or
- Set pcbApp GetObject(,MGCPCB.Application)
17Acquiring the Server in a VBScript
- Internal scripts have an understood Application
object and are not required to call GetObject. - External
- Set pcbApp GetObject(,MGCPCB.ExpeditionPCBAppli
cation) - Set pcbDoc pcbApp.ActiveDocument
- Internal
- Set pcbDoc ActiveDocument
18VBScripting (basic statements)
- Dim Use Dim to define a variable of any type
- Dim netObj
- Dim pi
- The equal sign is used to assign a value
to a variable or to check equivalence when used
in an IfThen statement. - pi 3.14
- str A string
- Set Use Set with the equal sign to assign an
object or a collection to a variable - Set netObj docObj.FindNet(GND)
- Call Use Call before a function where the
parameter list is defined in parentheses - Call MyFunc(0)
19VBScripting (continued)
- If Then Else Used to execute one or more
statements. - If condition Thenstatements
- Elseelse statements
- End If
- Function Defines a function and its associated
arguments. - Private Function name (arglist)
- statements
- name expression
- End Function
20VBScripting (and more)
- ForNext Used to repeat a collection of one or
more statements a specified number of times. - For counter start To end Step step
- statements
- Next
- For EachNext Processes all the elements stored
in an array or collection. - For Each object In collection
- statements
- Next
21VBScript I/O
- The MsgBox function is used to display
information in VBScript. - MsgBox(Hello World)
- Use the InputBox function to retrieve information
from the user. - name InputBox(What is your name?)
- Use the FileSystemObject server to read and write
to a file. The program ID for this server is
Scripting.FileSystemObject.
22VBScript Error Checking
- Errors that occur during execution of a VBScript
by default cause the script to abort, therefore
it is wise to output errors to a message box or
to the command prompt. - The On Error Resume Next statement allows the
script to continue running when errors occur and
no error message will be displayed. - The Err object contains information about a
previous occurring error. - Scripts can use the Err object to handle these
errors internally or reformat an error for
display.
23Automation Licensing Requirements
- All PCB Automation clients require licensing code
in order to execute. -
- The license code must be called each time a new
Document object is retrieved from the interface.
The Document object is retrieved when an
ActiveDocument or OpenDocument call is made. - Independent of the client embedded licensing code
Automation also requires a FlexLM license.
24Automation Server Validation
- The licensing code is also referred to as a
validation of the server. Each Document object
must be validated before a client request is
processed. - Validation code sequence
- Get a key from the Document object.
- The key is used to get a license token from the
MGCPCB Automation licensing server. - The license token used to validate the server.
- The Document object is then acquired.
25PCB Automation Data Model
- The MGCPCB data model consists of multiple
objects. Each object has a set of methods and
properties. - Most objects are associated with a data element.
(e.g. Trace, Via, Component, Padstack, etc.) - Some objects are associated with GUI elements.
- (e.g. GUI, Dialog, Button, View, etc.)
26Assigning Objects to a Variable
- Objects are set in variables, after which, the
methods and properties of that object can be
used. - Set an object to a variable first instantiate the
variable and then use Set to assign the object to
that variable. In this example, pcbDoc.FindNet
returns a Net object GND. - Dim gndNetObj
- Set gndNetObj pcbDoc.FindNet(GND)
27Calling Objects
- After an object has been assigned to a variable
the methods and properties associated with that
object can be called using the variable. - Net objects have a Selected property, therefore
to select a net set the property to True. - gndNetObj.Selected True
- The Net object also supports the Name property.
The following example displays the name of the
net in a message box. - MsgBox gndNetObj.Name
28Collection Objects
- Collections are special objects that acts as a
container for objects. Most objects in the
hierarchy have corresponding collections. - Object collection names will end in a s
- (e.g. Traces, Vias, Components, etc.)
- All collections have different types of methods
- (e.g. Add, Remove, Item, Count, and Sort)
- Where appropriate, collections also have the
Selected and Highlighted properties and include
the Delete method.
29Defining Collections
- A collection is generally returned by a property
of the same name. - The Nets property on a Document object will
return a Nets collection. - Dim netsColl
- Set netsColl pcbDoc.Nets
30Using Collection Filters
- Collection filters allow parameters set on
properties to filter the list of objects that is
returned. - These parameters allow clients to filter lists on
an array of varying characteristics. - Layer
- Selection/Highlight status
- Fix/Lock status
- And many others
31Using the Status Bar
- Clients can display information, prompt the user
for input, or display errors. - PCB Automation allows clients to display text in
the status bar.
32Modifying/Adding Data
- The Put functions, found on the Document object,
can be used to add data to the design. - PutTrace()
- PutComponent()
- PutVia()
- When modifying existing data in the interface you
must first collect the attributes of the element,
delete it, and then recreate a new element with
the appropriate modifications.
33Geometry Object
- All objects that reference data having
geometrical attributes will have a Geometry
object. - The Geometry object contains methods and
properties describing the geometric properties of
that element (e.g. IsCircle, IsPath, etc.). - The Geometry also has a PointsArray property,
which returns an X,Y R (radius) array of
doubles defining the vertexes of the geometry.
34Defining Events
- Methods and properties are useful for retrieving
information from the server however it is also
useful to get notification of occurrences in the
server. - Events are calls for the server to notify the
client of actions taking place within the server. - Why are events needed?
- Events allow clients to react to changes in the
server. - They also allow clients to modify behavior of
actions in the server.
35Application/Document Events
- Application object
- OpenDocument
- Quit
- Document object
- OnClosed
- OnSave
- OnSelectionChange
36Command Object
- The majority of a Command object is comprised of
events. - The Command object allows clients to create their
own command, giving them the ability to listen
and react to mouse and keyboard events. - Call the RegisterCommand method on the GUI object
to create your own command.
37Motion Graphics
- Using a Command object with the motion graphics
functions allows users to create interactive draw
functionality. - The View object contains a set of methods for
adding motion graphics to the application.
38Using the LockServer Call
- NOT using the LockServer statement could cause
valuable server performance. - LockServer would typically be used as
- pcbApp.LockServer
- ...
- ltperform your server actions heregt
- pcbApp.UnlockServer
- Use LockServer when making many calls into the
server. This is especially useful when
traversing a large collection of objects.
39Object Browsers
- Object Browsers provide a GUI for viewing
objects, methods, properties, and events defined
in a type library. - Object Browsers can be found in many Microsoft
applications such as Word, Excel and
PowerPoint.
40(No Transcript)