xpcb Layout Automation and Scripting Student Workbook 2016 Mentor Graphics Corporation All rights reserved. This document contains information that is trade secret and proprietary to Mentor Graphics Corporation or its licensors and is subject to license terms. No part of this document may be photocopied, reproduced, translated, distributed, disclosed or provided to third parties without the prior written consent of Mentor Graphics.
This document is for information and instruction purposes. Mentor Graphics reserves the right to make changes in specifications and other information contained in this publication without prior notice, and the reader should, in all cases, consult Mentor Graphics to determine whether any changes have been made. The terms and conditions governing the sale and licensing of Mentor Graphics products are set forth in written agreements between Mentor Graphics and its customers. No representation or other affirmation of fact contained in this publication shall be deemed to be a warranty or give rise to any liability of Mentor Graphics whatsoever. MENTOR GRAPHICS MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS MATERIAL INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. MENTOR GRAPHICS SHALL NOT BE LIABLE FOR ANY INCIDENTAL, INDIRECT, SPECIAL, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING BUT NOT LIMITED TO LOST PROFITS) ARISING OUT OF OR RELATED TO THIS PUBLICATION OR THE INFORMATION CONTAINED IN IT, EVEN IF MENTOR GRAPHICS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. U.S. GOVERNMENT LICENSE RIGHTS: The software and documentation were developed entirely at private expense and are commercial computer software and commercial computer software documentation within the meaning of the applicable acquisition regulations. Accordingly, pursuant to FAR 48 CFR 12.212 and DFARS 48 CFR 227.7202, use, duplication and disclosure by or for the U.S. Government or a U.S. Government subcontractor is subject solely to the terms and conditions set forth in the license agreement provided with the software, except for provisions which are contrary to applicable mandatory federal laws. TRADEMARKS: The trademarks, logos and service marks ("Marks") used herein are the property of Mentor Graphics Corporation or other parties. No one is permitted to use these Marks without the prior written consent of Mentor Graphics or the owner of the Mark, as applicable. The use herein of a third- party Mark is not an attempt to indicate Mentor Graphics as a source of a product, but is intended to indicate a product from, or associated with, a particular third party. A current list of Mentor Graphics trademarks may be viewed at: www.mentor.com/trademarks. End-User License Agreement: You can print a copy of the End-User License Agreement from: www.mentor.com/eula. Mentor Graphics Corporation 8005 S.W. Boeckman Road, Wilsonville, Oregon 97070-7777 Telephone: 503.685.7000 Toll-Free Telephone: 800.592.2210 Website: www.mentor.com SupportNet: supportnet.mentor.com/ Send Feedback on Documentation: supportnet.mentor.com/doc_feedback_form Part Number: 073510
Module 1: Introduction... 11 Objectives... 12 Note... 13 Course Key Topics... 14 Terminology... 15 What Is Automation?... 16 What can I do With Automation?... 17 How can You Use Automation?... 18 What Products Support Automation?... 19 Supported Platforms... 20 Languages... 21 Automation Clients... 22 Launching VX Applications... 25 Versioned Automation... 26 Scripting Tools... 28 Help... 29 SupportNet Login/Register... 30 Module 1 Lab: Introduction to Scripting... 31 Module 2: Basic Scripting Concepts... 33 Objectives... 34 Note... 35 Overview VBSCRIPT versus Visual Basic... 36 PCB Script Elements Overview... 37 VBScript Basics Variables... 38 I
Expressions Summary... 41 VBScript I/O Message/Input Boxes... 42 VBScript Basics Miscellaneous... 44 VBScript Basics Conditional Script Control... 46 For...Each and While...Wend Examples... 49 If/Then/Else and For...Next Example... 50 Select Case Example... 51 VBScript Basics Functions and Subroutines... 52 VBScript I/O FileSystemObject... 53 Error Checking... 54 String Manipulations... 55 String Manipulations Example... 56 String Manipulations Results... 57 Module 2 Lab: Basic Scripting... 58 Module 3: Environment/GUI Customizations... 59 Objectives... 60 Startup Scripts... 61 scripts.ini Directory Search... 62 Scripts.ini File Format... 63 Scripts.ini File Format Example... 64 Scripts.ini File Search Rules... 66 Scripts.ini File File Types Executed... 68 Using the Run Command... 69 Using the WDIR Variable... 70 WDIR and xdx Designer (Except DxDesigner.xml)... 71 II
Searching for DxDesigner.xml Support File... 72 Keybindings... 73 Keybinding Files... 74 Shortcut Key Modifiers... 75 Connecting to the Key Binding Server... 76 Xpedition xpcb Layout Keybinding File Example... 77 xdx Designer Keybinding File Example... 78 Module 3 Lab 3.1: Startup Scripts... 79 Command Bar Server... 80 Command Bar Server Objects... 81 Connecting to the Command Bar Server... 82 Adding a New Menu... 83 Adding a Command to a Menu... 84 Command Execution... 85 Adding a Separator... 86 Adding a Sub Menu... 87 "Graying Out" User Menu Items... 89 Deleting a Command... 90 Example in Context Xpedition xpcb Menu Bar... 91 Example in Context xdx Designer... 93 Summary: Adding Menu Entries... 94 Module 3 Lab 3.2: Scripting Menu Changes... 95 Toolbars... 96 Adding an Xpedition xpcb Toolbar Button... 97 Adding a xdx Designer Toolbar Button... 98 III
Toolbar Command Execution... 99 Summary: Adding Toolbar Icons... 101 Things to Consider... 102 Acquiring Environment Information... 103 WDIR Acquisition and Disassemble... 104 Locate/Confirm File Exists in WDIR... 105 Create FileSystem Object for Copy... 106 Quick Reference: xdx Designer Menus... 107 Quick Reference: xdx Designer Toolbars - Default... 108 Quick Reference: xdx Designer Toolbars - Classic... 109 Quick Reference: xdx Designer Addins... 110 Quick Reference Xpedition xpcb Layout... 118 Quick Reference: Xpedition xpcb Layout Toolbars... 119 CommandBarButton Object Model Summary... 123 Module 3 Lab 3.3: Working with Toolbars... 124 Module 4: Object Programming... 125 Objectives... 126 Terminology... 127 Type Library... 129 Object Browsers... 130 VBA Object Browser xdx Designer Example... 132 Objects... 134 Collections... 136 xpcb Layout Example Input/Output/Collections... 139 LockServer (PCB Only)... 140 IV
Finding Objects... 141 Finding Objects xpcb Layout Example... 142 Example xpcb Layout Object Data... 144 Transactions (PCB Only)... 145 Transactions Example 1... 147 Transactions Example 2... 148 Automation Licensing... 149 Review Script Initialization Constructs... 150 Review Conditional Script Control... 151 Review Objects and Collections... 152 Review Input/Output/File System... 153 Review Xpedition xpcb Layout Licensing Construct... 154 Module 4 Lab: Object Programming... 155 Module 5: Designing and Creating Forms... 157 Objectives... 158 Integrated Development Environment (IDE)... 159 Accessing Form Files... 161 Creating a New Form xdx Designer... 162 Opening a Form xdx Designer... 163 Creating a New Form xpcb Layout... 164 Opening a Form xpcb Layout... 165 Creating/Editing Form Graphics... 166 Types of Widgets... 167 Widget Usage... 168 Widget Properties... 169 V
Widget Events... 170 Graphic/Code Statements Suggestions... 171 Form Example Graphics Properties... 172 Form Example Subroutines... 173 Module 5 Lab: Creating and Using Forms... 174 Module 6: xpcb Layout Output Engines... 175 Objectives... 176 Note... 177 Manufacturing Engines... 178 Currently Supported Manufacturing Engines... 179 Future Engines... 180 Common Script Concepts... 181 Add Engine Library Type Examples... 182 Create the Engine Object... 183 COM Version... 184 Example Script Gerber Export Using Predefined Setups... 185 Some Gerber Export Statements No Predefined Setups... 186 Gerber Output Files... 187 Module 6 Lab: Scripting Output Engines... 188 Module 7: xpcb Layout... 189 Objectives... 190 PCB Automation in a Nutshell... 191 Type Libraries... 192 Acquiring the Server in VBScript... 193 PCB Automation Data Model... 195 VI
PCB Automation Hierarchy... 196 Geometry Object... 199 Typical Script Beginnings... 200 Automation Licensing... 201 Document Licensing... 202 Code Example InputBox/Component Collection... 203 Output Result of InputBox/Component Collection... 204 Code Example/Output Results Net Collection Labels... 205 Review VBScript I/O FileSystemObject... 206 Code Example Net/Refdes/Pin Report... 207 Output Result of Net/Refdes/Pin Report... 209 Filters... 210 Non-Filtered Statements... 211 Filtering Statements... 212 Filter Enumerator Example Statements... 213 Example Code Not Using a Filter... 214 Example Code Using a Filter... 215 Module 7 lab 7A: Basic xpcb Layout Scripting... 216 Adding/Modifying Data... 217 PutVia Example... 218 PutVia Example Status Bar and TransactionStart... 219 PutVia Example Operate on the Via... 220 PutVia Example Error Handlers and Prompted For Exit... 221 PutVia Example TransactionEnd... 222 xpcb Events... 223 VII
Events Infinite Loop... 225 Example Code Event; OnSelectionChange... 226 Available Pick Methods... 229 Pick Methods Statements... 230 Pick Object Example... 231 Pick Components Example... 232 Command Object... 233 Motion Graphics... 234 Motion Graphics Form... 235 Motion Graphics and Command Object Example... 236 Writing to the Xpedition xpcb Layout Status Bar... 241 Writing to the Status Bar Example Code /Result... 242 Other Useful Objects and Methods... 243 Accessing Other Editors... 244 Review... 245 Module 7 Lab: Working with Events... 246 Module 8: xdx Designer... 247 Objectives... 248 Typical xdx Designer Script Tasks... 249 xdx Designer Automation in a Nutshell... 250 xdx Designer Type Library... 251 Acquiring the Server in VBScript... 252 xdx Designer Automation Data Model... 254 xdx Designer Automation Hierarchy... 255 xdx Designer Automation Accessing Design Data... 258 VIII
xdx Designer Automation Model Overview... 259 Typical Script Beginnings... 260 Automation Licensing... 261 Scopes... 262 Working With Queries... 263 Schematic Page Decision Tree... 264 Code Example Sheet Component Collection... 265 Flat Design Traversal Decision Tree... 267 Code Example Multi-Sheet Acquiring Net Labels... 268 Hierarchical Design Traversal - Decision Tree... 271 Example Code Hierarchical Traversal... 272 Enumerations... 288 xdx Designer Filters... 289 Adding/Deleting Objects in xdx Designer... 290 Modifying Objects in xdx Designer... 291 xdx Designer Events... 292 xdx Designer Events Members... 294 xdx Designer Events Script Example... 295 xdx Designer Events User Created Commands... 296 xdx Designer Events Register/Bind Command Example... 297 xdx Designer Events UnRegister Command Example... 298 xdx Databook Events... 299 Loading a Script for xdx Databook... 300 xdx Databook Example... 301 The Viewport Object... 303 IX
The Viewport Object Example Code... 304 The Viewport Object Example Code Results... 305 Other Useful Application Controls... 306 Status Bar... 307 VBScript I/O - FileSystemObject... 308 Module 8 Lab: xdx Designer Scripting... 309 X