Download as pdf or txt
Download as pdf or txt
You are on page 1of 1104

v13

API Scripting Guide

ni.com/awr
API Scripting Guide
NI AWR Design Environment v13 Edition

1960 E. Grand Avenue, Suite 430


El Segundo, CA 90245
USA
Phone: +1 310.726.3000
Fax: +1 310.726.3005
Website: www.ni.com/awr
awr.support@ni.com
U.S. Technical Support phone: 888.349.7610

LEGAL NOTICES

2017 National Instruments. All rights reserved.

Trademarks

Analog Office, APLAC, AWR, AWR Design Environment, AXIEM, Microwave Office, National Instruments, NI, ni.com and TX-Line
are registered trademarks of National Instruments. Refer to the Trademarks section at ni.com/trademarks for other National Instruments
trademarks.
Other product and company names mentioned herein are trademarks or trade names of their respective companies.

Patents

For patents covering NI AWR software products/technology, refer to ni.com/patents.

The information in this guide is believed to be accurate. However, no responsibility or liability is assumed by National Instruments for its
use.
Table of Contents
NI AWR Scripting Guide ..................................................................................................................... 11
Introduction .............................................................................................................................. 11
The Script Development Environment ............................................................................................ 13
Developing a Script ................................................................................................................... 113
Working with Schematics ........................................................................................................... 172
Working with Netlists ............................................................................................................... 1134
Working with EM Structures ...................................................................................................... 1135
Working with Graphs ............................................................................................................... 1192
Optimizing, Tuning, and Yield ................................................................................................... 1238
DataSets ................................................................................................................................ 1253
Layout ................................................................................................................................... 1267
Variables and Equations ............................................................................................................ 1545
Sweeper Object ....................................................................................................................... 1566
Working with System Diagrams ................................................................................................. 1569
Libraries Collection of Objects ................................................................................................... 1584
SwitchLists Collection of Objects ............................................................................................... 1588
Scripting the NI AWR SDE Externally ........................................................................................ 1589
Working with the Windows Collection of Objects .......................................................................... 1594
Working with the Job Scheduler queues Collection of Objects .......................................................... 1595
Working with Folders and Files Collection of Objects ..................................................................... 1597
Working with Design Notes Collection of Objects .......................................................................... 1608
Working with Wizards via the API .............................................................................................. 1611
AWR Design Environment Component API ............................................................................................. 21
Introduction ............................................................................................................................... 21
Objects List ............................................................................................................................... 21
Enumerations List ..................................................................................................................... 212
Count ...................................................................................................................................... 218
Add ........................................................................................................................................ 223
Remove ................................................................................................................................... 228
Clear ....................................................................................................................................... 231
Name ...................................................................................................................................... 232
Value ...................................................................................................................................... 235
Activate .................................................................................................................................. 235
NewWindow ............................................................................................................................ 236
Print ....................................................................................................................................... 236
Caption ................................................................................................................................... 237
Delete ..................................................................................................................................... 237
Exists ...................................................................................................................................... 238
Copy ...................................................................................................................................... 242
Ccopy ..................................................................................................................................... 242
Update .................................................................................................................................... 243
Import ..................................................................................................................................... 243
LinkTo .................................................................................................................................... 244
Coptions .................................................................................................................................. 244
Application .............................................................................................................................. 245
Project .................................................................................................................................... 252
ProjectFile ............................................................................................................................... 271
ProjectFiles .............................................................................................................................. 271
ControlBar ............................................................................................................................... 271

API Scripting Guide iii


Contents

ControlBars ............................................................................................................................. 272


DataFile .................................................................................................................................. 273
DataFiles ................................................................................................................................. 274
DataSetProperty ........................................................................................................................ 275
DataSetProperties ...................................................................................................................... 276
DataSet ................................................................................................................................... 276
DataSets .................................................................................................................................. 277
DataSetFolder .......................................................................................................................... 278
DataSetFolders ......................................................................................................................... 278
OutputFile ............................................................................................................................... 279
OutputFiles .............................................................................................................................. 279
Frequency ................................................................................................................................ 280
Frequencies .............................................................................................................................. 280
Element ................................................................................................................................... 281
Elements ................................................................................................................................. 283
SelectedElements ...................................................................................................................... 285
EquationExpression ................................................................................................................... 286
EquationExpressions .................................................................................................................. 287
Equation .................................................................................................................................. 287
Equations ................................................................................................................................ 289
GlobalDefinitionDocument ......................................................................................................... 290
GlobalDefinitionDocuments ........................................................................................................ 291
OutputEquationDocument ........................................................................................................... 292
OutputEquationDocuments ......................................................................................................... 294
Goal ....................................................................................................................................... 294
DisplayPrecision ....................................................................................................................... 295
Graph ..................................................................................................................................... 295
Graphs .................................................................................................................................... 298
Axis ....................................................................................................................................... 299
Axes ..................................................................................................................................... 2100
Trace ..................................................................................................................................... 2101
Traces ................................................................................................................................... 2102
Legend .................................................................................................................................. 2102
MarkerOptions ........................................................................................................................ 2102
MarkerDisplay ........................................................................................................................ 2103
AutoSearchMarker ................................................................................................................... 2103
OffsetMarker .......................................................................................................................... 2104
Marker .................................................................................................................................. 2104
Markers ................................................................................................................................. 2106
LineMarker ............................................................................................................................ 2106
LineMarkers ........................................................................................................................... 2107
Measurement .......................................................................................................................... 2108
Measurements ......................................................................................................................... 2109
Netlist ................................................................................................................................... 2110
Netlists .................................................................................................................................. 2111
Node ..................................................................................................................................... 2113
Nodes .................................................................................................................................... 2113
OptGoals ............................................................................................................................... 2113
Parameter ............................................................................................................................... 2114
Parameters ............................................................................................................................. 2115
ParameterDefinition ................................................................................................................. 2116

iv NI AWR Design Environment


Contents

ParameterDefinitions ................................................................................................................ 2116


ParameterFrame ...................................................................................................................... 2116
LayoutParameterFrame ............................................................................................................. 2117
ProcessLibrary ........................................................................................................................ 2117
ProcessLibraries ...................................................................................................................... 2118
ProcessLibraryInfo .................................................................................................................. 2119
ProcessLibraryInfos ................................................................................................................. 2119
Property ................................................................................................................................. 2119
Properties ............................................................................................................................... 2119
Schematic .............................................................................................................................. 2120
Schematics ............................................................................................................................. 2134
Subcircuits ............................................................................................................................. 2144
Subsystems ............................................................................................................................ 2145
Ports ..................................................................................................................................... 2145
ElectricalNets ......................................................................................................................... 2145
NamedConnectors ................................................................................................................... 2146
SymbolNode .......................................................................................................................... 2146
SymbolNodes ......................................................................................................................... 2146
SymbolShape .......................................................................................................................... 2147
SymbolShapes ........................................................................................................................ 2147
SymbolRecord ........................................................................................................................ 2147
Symbol .................................................................................................................................. 2149
Symbols ................................................................................................................................ 2150
Unit ...................................................................................................................................... 2152
Units ..................................................................................................................................... 2152
SweepValue ............................................................................................................................ 2152
SweepValues .......................................................................................................................... 2152
SweepVariable ........................................................................................................................ 2153
SweepVariables ....................................................................................................................... 2153
Window ................................................................................................................................. 2153
Windows ............................................................................................................................... 2154
WireNet ................................................................................................................................. 2155
WireSegment .......................................................................................................................... 2156
Wires .................................................................................................................................... 2157
SelectedWires ......................................................................................................................... 2158
YieldGoals ............................................................................................................................. 2159
Option ................................................................................................................................... 2159
Options .................................................................................................................................. 2160
SystemDiagram ....................................................................................................................... 2160
SystemDiagrams ..................................................................................................................... 2167
DesignNote ............................................................................................................................ 2172
DesignNotes ........................................................................................................................... 2174
Simulator ............................................................................................................................... 2174
Attribute ................................................................................................................................ 2175
Attributes ............................................................................................................................... 2175
BoundaryModel ...................................................................................................................... 2176
Boundary ............................................................................................................................... 2176
LayoutParameter ..................................................................................................................... 2176
LayoutParameters .................................................................................................................... 2177
ObjectName ........................................................................................................................... 2178
ObjectNames .......................................................................................................................... 2178

API Scripting Guide v


Contents

ComplexNumber ..................................................................................................................... 2178


ComplexNumbers .................................................................................................................... 2179
Offset .................................................................................................................................... 2179
Offsets .................................................................................................................................. 2180
Point ..................................................................................................................................... 2180
Points .................................................................................................................................... 2180
Size ...................................................................................................................................... 2180
Sizes ..................................................................................................................................... 2181
Vertex ................................................................................................................................... 2181
Vertices ................................................................................................................................. 2181
Vertex3D ............................................................................................................................... 2182
CellInstance ........................................................................................................................... 2182
CellInstances .......................................................................................................................... 2183
Cell ....................................................................................................................................... 2183
Cells ..................................................................................................................................... 2185
CellLibrary ............................................................................................................................. 2186
CellLibraries .......................................................................................................................... 2187
EMLayerMapEntry .................................................................................................................. 2188
EMLayerMapEntries ................................................................................................................ 2188
EMLayerMapping ................................................................................................................... 2189
EMLayerMappings .................................................................................................................. 2189
LayerMapEntry ....................................................................................................................... 2190
LayerMapEntries ..................................................................................................................... 2190
LayerMapping ........................................................................................................................ 2191
LayerMappings ....................................................................................................................... 2191
LayerExportEntry .................................................................................................................... 2192
LayerExportEntries .................................................................................................................. 2192
LayerExportMapping ............................................................................................................... 2193
LayerExportMappings .............................................................................................................. 2193
DrawingLayer ......................................................................................................................... 2194
DrawingLayers ....................................................................................................................... 2195
LayerSetup ............................................................................................................................. 2196
DrillTool ................................................................................................................................ 2196
DrillTools .............................................................................................................................. 2197
ModifierDefDrawingObjects ..................................................................................................... 2197
ModifierDefRecord .................................................................................................................. 2198
ModifierDefRecords ................................................................................................................ 2199
ShapeModifierRecord .............................................................................................................. 2199
ShapeModifierRecords ............................................................................................................. 2199
ShapeModifier ........................................................................................................................ 2200
ShapeModifiers ....................................................................................................................... 2200
DesignRule ............................................................................................................................ 2201
DesignRules ........................................................................................................................... 2201
DesignRuleError ..................................................................................................................... 2203
DesignRuleErrors .................................................................................................................... 2203
LVSError ............................................................................................................................... 2204
LVSErrors .............................................................................................................................. 2205
LVSSchemHighlight ................................................................................................................ 2206
LVSSchemHighlights ............................................................................................................... 2206
LVSNetHighlight .................................................................................................................... 2207
LVSNetHighlights ................................................................................................................... 2207

vi NI AWR Design Environment


Contents

DesignRuleChecker ................................................................................................................. 2208


LayoutVsSchematicChecker ...................................................................................................... 2209
DRCErrorsWindow .................................................................................................................. 2209
LVSErrorsWindow .................................................................................................................. 2210
DRCErrorShape ...................................................................................................................... 2210
DRCErrorShapes ..................................................................................................................... 2210
ConnectivityHighlighter ........................................................................................................... 2211
DrawingObject ........................................................................................................................ 2212
DrawingObjects ...................................................................................................................... 2214
PolygonRecord ....................................................................................................................... 2217
PolygonWriter ........................................................................................................................ 2220
PathRecord ............................................................................................................................. 2221
PathWriter .............................................................................................................................. 2222
SelectedDrawingObjects ........................................................................................................... 2224
GroupDrawingObjects .............................................................................................................. 2225
EMStructureInfo ..................................................................................................................... 2226
EMInitializationRecord ............................................................................................................ 2226
EMStructure ........................................................................................................................... 2226
EMStructures .......................................................................................................................... 2245
ExternalEditor ........................................................................................................................ 2262
EM3DStructure ....................................................................................................................... 2264
EM3DStructures ..................................................................................................................... 2265
Face ...................................................................................................................................... 2267
Faces .................................................................................................................................... 2268
Layout ................................................................................................................................... 2268
CellEditor .............................................................................................................................. 2273
CellEditors ............................................................................................................................. 2276
Enclosure ............................................................................................................................... 2277
MaterialLayer ......................................................................................................................... 2277
MaterialLayers ........................................................................................................................ 2277
ShapeSubObject ...................................................................................................................... 2278
ShapeSubObjects ..................................................................................................................... 2278
ShapeSegment ........................................................................................................................ 2279
ShapeSegments ....................................................................................................................... 2279
ShapeArcSegment ................................................................................................................... 2279
ShapeArcSegments .................................................................................................................. 2280
Shape .................................................................................................................................... 2280
Shapes ................................................................................................................................... 2280
DrawingSubObject .................................................................................................................. 2283
DrawingSubObjects ................................................................................................................. 2284
DrawingSegment ..................................................................................................................... 2285
DrawingSegments ................................................................................................................... 2286
DrawingArcSegment ................................................................................................................ 2286
DrawingArcSegments .............................................................................................................. 2286
Snapshot ................................................................................................................................ 2286
LibraryElement ....................................................................................................................... 2290
LibraryElements ...................................................................................................................... 2290
Library .................................................................................................................................. 2291
Libraries ................................................................................................................................ 2291
MeasurementInfo .................................................................................................................... 2291
MeasurementInfos ................................................................................................................... 2292

API Scripting Guide vii


Contents

Model ................................................................................................................................... 2292


Models .................................................................................................................................. 2293
LayoutCell ............................................................................................................................. 2293
LayoutCells ............................................................................................................................ 2294
Optimizer ............................................................................................................................... 2294
Synthesizer ............................................................................................................................. 2297
Sweeper ................................................................................................................................. 2298
TuneVariable .......................................................................................................................... 2298
TuneVariables ......................................................................................................................... 2299
Tuner .................................................................................................................................... 2299
ControlBarItem ....................................................................................................................... 2301
ControlBarItems ...................................................................................................................... 2301
MenuBar ............................................................................................................................... 2302
MenuBars .............................................................................................................................. 2302
Menu .................................................................................................................................... 2302
Menus ................................................................................................................................... 2303
MenuItem .............................................................................................................................. 2303
MenuItems ............................................................................................................................. 2304
HotkeyTable ........................................................................................................................... 2304
HotkeyTables .......................................................................................................................... 2304
Hotkey .................................................................................................................................. 2305
Hotkeys ................................................................................................................................. 2305
CommandTable ....................................................................................................................... 2306
CommandTables ...................................................................................................................... 2306
Command .............................................................................................................................. 2307
Commands ............................................................................................................................. 2307
DrawingShape ........................................................................................................................ 2308
DrawingShapes ....................................................................................................................... 2309
Argument ............................................................................................................................... 2311
Arguments ............................................................................................................................. 2311
FlightLine .............................................................................................................................. 2311
FlightLines ............................................................................................................................. 2311
NetShape ............................................................................................................................... 2312
NetShapes .............................................................................................................................. 2312
PhysicalNet ............................................................................................................................ 2313
PhysicalNets ........................................................................................................................... 2314
RouteRecord .......................................................................................................................... 2315
Route .................................................................................................................................... 2316
Routes ................................................................................................................................... 2317
RouteObject ........................................................................................................................... 2318
RouteObjects .......................................................................................................................... 2319
RouteSegment ........................................................................................................................ 2319
RouteSegments ....................................................................................................................... 2320
RouteVia ............................................................................................................................... 2320
RouteVias .............................................................................................................................. 2321
RouteGuide ............................................................................................................................ 2322
RouteGuides ........................................................................................................................... 2322
Extent ................................................................................................................................... 2322
Extents .................................................................................................................................. 2322
Pin ........................................................................................................................................ 2323
Pins ...................................................................................................................................... 2323

viii NI AWR Design Environment


Contents

LayoutModeSet ....................................................................................................................... 2324


LayoutModeSets ..................................................................................................................... 2326
ParameterDefaultValue ............................................................................................................. 2327
ParameterDefaultValues ............................................................................................................ 2327
LayoutProcessDefinition ........................................................................................................... 2328
LayoutProcessDefinitions ......................................................................................................... 2329
ProcessLayerInfo ..................................................................................................................... 2330
ProcessLayerInfos ................................................................................................................... 2330
ProcessTypeInfo ...................................................................................................................... 2331
ProcessTypeInfos .................................................................................................................... 2332
ProcessBridgeInfo ................................................................................................................... 2333
ProcessBridgeInfos .................................................................................................................. 2333
FontInfo ................................................................................................................................ 2334
FontInfos ............................................................................................................................... 2334
ProcessProperty ...................................................................................................................... 2334
ProcessProperties .................................................................................................................... 2335
ProcessViaType ....................................................................................................................... 2336
ProcessViaTypes ..................................................................................................................... 2336
BusNetName .......................................................................................................................... 2337
BusNetNames ......................................................................................................................... 2338
BundleBit .............................................................................................................................. 2338
BundleBits ............................................................................................................................. 2338
BundleBus ............................................................................................................................. 2339
BundleBuses .......................................................................................................................... 2339
BundleInfo ............................................................................................................................. 2339
BundleInfos ............................................................................................................................ 2339
EditHandle ............................................................................................................................. 2340
EditHandles ............................................................................................................................ 2340
SelectFilterItem ....................................................................................................................... 2340
SelectFilterItems ..................................................................................................................... 2340
SelectFilter ............................................................................................................................. 2341
CSelectFilters ......................................................................................................................... 2341
MathUtil ................................................................................................................................ 2341
StackupUtil ............................................................................................................................ 2346
ZipArchiveItem ....................................................................................................................... 2348
ZipArchiveItems ..................................................................................................................... 2348
ZipArchiveWriter .................................................................................................................... 2349
BrowseForFolderDialog ........................................................................................................... 2350
FileFilterEntry ........................................................................................................................ 2351
FileFilterEntries ...................................................................................................................... 2351
FilePathEntry .......................................................................................................................... 2352
FilePathEntries ........................................................................................................................ 2352
FilePathDialog ........................................................................................................................ 2353
FileUtil .................................................................................................................................. 2354
FileAttribute ........................................................................................................................... 2356
FileAttributes .......................................................................................................................... 2356
ScriptRoutine .......................................................................................................................... 2356
ScriptRoutines ........................................................................................................................ 2357
ScriptModule .......................................................................................................................... 2357
ScriptModules ........................................................................................................................ 2357
SimulationResult ..................................................................................................................... 2358

API Scripting Guide ix


Contents

SimulationResults .................................................................................................................... 2358


SimulationFilter ...................................................................................................................... 2358
SimulationFilters ..................................................................................................................... 2361
SwitchList .............................................................................................................................. 2362
SwitchLists ............................................................................................................................ 2362
ConnectionRule ...................................................................................................................... 2363
ConnectionRules ..................................................................................................................... 2364
CrossoverRuleEntry ................................................................................................................. 2364
CrossoverRuleEntries ............................................................................................................... 2365
CrossoverRule ........................................................................................................................ 2365
CrossoverRules ....................................................................................................................... 2366
ProcessViaFillEntry ................................................................................................................. 2366
ProcessViaFillEntries ............................................................................................................... 2367
ProcessViaFenceEntry .............................................................................................................. 2368
ProcessViaFenceEntries ............................................................................................................ 2369
ProcessViaLineType ................................................................................................................. 2370
ProcessViaLineTypePair ........................................................................................................... 2370
ProcessViaLineTypePairs .......................................................................................................... 2370
CellMapping .......................................................................................................................... 2371
CellMappings ......................................................................................................................... 2371
EMPortTermination ................................................................................................................. 2371
EMPortTerminations ................................................................................................................ 2372
EMPort .................................................................................................................................. 2372
EMPorts ................................................................................................................................ 2373
CellInfo ................................................................................................................................. 2374
SweepLabel ............................................................................................................................ 2374
SweepLabels .......................................................................................................................... 2374
LayoutInfo ............................................................................................................................. 2374
ComponentTest ....................................................................................................................... 2375
ComponentTests ...................................................................................................................... 2375
StatusItem .............................................................................................................................. 2376
StatusItems ............................................................................................................................. 2377
StatusGroup ........................................................................................................................... 2377
StatusGroups .......................................................................................................................... 2377
StatusWindow ......................................................................................................................... 2378
Status .................................................................................................................................... 2378
CursorInfo ............................................................................................................................. 2379
View ..................................................................................................................................... 2379
Views .................................................................................................................................... 2381
ThreeDView ........................................................................................................................... 2381
ThreeDViews .......................................................................................................................... 2383
EmbeddedDesign .................................................................................................................... 2383
EmbeddedDesigns ................................................................................................................... 2384
EMail .................................................................................................................................... 2384
FileInfo ................................................................................................................................. 2385
FileInfos ................................................................................................................................ 2385
FolderInfo .............................................................................................................................. 2386
FolderInfos ............................................................................................................................. 2386
ProjectTreeView ...................................................................................................................... 2387
TreeNode ............................................................................................................................... 2387
TreeNodes .............................................................................................................................. 2389

x NI AWR Design Environment


Contents

ProjectItem ............................................................................................................................. 2389


ProjectItems ........................................................................................................................... 2389
UserFolder ............................................................................................................................. 2390
UserFolders ............................................................................................................................ 2390
WizardDoc ............................................................................................................................. 2391
WizardDocs ............................................................................................................................ 2392
Wizard .................................................................................................................................. 2392
Wizards ................................................................................................................................. 2393
Annotation ............................................................................................................................. 2393
Annotations ............................................................................................................................ 2394
RegressionTester ..................................................................................................................... 2394
RegressionResult ..................................................................................................................... 2396
JobEntry ................................................................................................................................ 2396
JobEntries .............................................................................................................................. 2397
JobQueue ............................................................................................................................... 2397
JobQueues ............................................................................................................................. 2397
JobSchedulerQuery .................................................................................................................. 2398
JobMonitor ............................................................................................................................. 2398
PageSetup .............................................................................................................................. 2398
RoutePropertyInfo ................................................................................................................... 2399
mwFeatureTypeFlags ............................................................................................................... 2399
mwShapeToolFlags .................................................................................................................. 2399
mwAlignToolFlags .................................................................................................................. 2400
mwProjectToolFlags ................................................................................................................ 2400
mwLinearSolveType ................................................................................................................ 2401
mwNonLinearSolveType .......................................................................................................... 2401
mwEMSolverType ................................................................................................................... 2401
mwEMSolverToleranceLevel ..................................................................................................... 2402
mwEMMeshDensity ................................................................................................................ 2402
mwColor ............................................................................................................................... 2402
mwGraphColorIndex ................................................................................................................ 2406
mwGraphLineStyleIndex .......................................................................................................... 2406
mwGraphLineWeightIndex ........................................................................................................ 2407
mwGraphLegendStyleIndex ...................................................................................................... 2407
mwGraphYieldRangeStyle ........................................................................................................ 2407
mwGraphYieldDisplayStyle ...................................................................................................... 2407
mwLayoutViewDetails ............................................................................................................. 2408
mwLayoutSelectMode .............................................................................................................. 2408
mwLayoutRouteGravity ........................................................................................................... 2408
mwSysNoiseModeling .............................................................................................................. 2408
mwLayoutSnapMode ............................................................................................................... 2408
mwInterpolationMethod ........................................................................................................... 2409
mwInterpolationCoords ............................................................................................................ 2409
mwInstanceExportOptions ........................................................................................................ 2409
mwFaceInsetOptions ................................................................................................................ 2409
mwPortFaceConnectTypes ........................................................................................................ 2410
mwPathEndTypeOptions ........................................................................................................... 2410
mwPathMiterTypeOptions ......................................................................................................... 2411
mwRectangleAttributes ............................................................................................................ 2411
mwPolygonAttributes ............................................................................................................... 2411
mwLayoutCellAttributes ........................................................................................................... 2411

API Scripting Guide xi


Contents

mwLayoutShapeAttributes ........................................................................................................ 2411


mwLayoutPinAttributes ............................................................................................................ 2412
mwLayoutRoutePathAttributes .................................................................................................. 2412
mwLayoutNetShapeAttributes ................................................................................................... 2412
mwLayoutCellShapeAttributes ................................................................................................... 2412
mwLayoutSubcircuitAttributes ................................................................................................... 2412
mwLayoutGroupAttributes ........................................................................................................ 2413
mwLayoutLayerAttributes ......................................................................................................... 2413
mwLayoutMagnificationAttributes ............................................................................................. 2413
mwLayout3DPlacementAttributes .............................................................................................. 2413
mwLayoutOrientationAttributes ................................................................................................. 2413
mwLayoutCellStretcherAttributes ............................................................................................... 2413
mwLayoutDragLayoutObjectAttributes ....................................................................................... 2414
mwLayoutFontAttributes .......................................................................................................... 2414
mwSchematicFontAttributes ...................................................................................................... 2414
mwLayoutTextAttributes .......................................................................................................... 2414
mwLayoutDimensionLineAttributes ............................................................................................ 2415
mwLayoutRulerAttributes ......................................................................................................... 2415
mwLayoutPolyAttributes .......................................................................................................... 2415
mwLayoutEllipseAttributes ....................................................................................................... 2416
mwLayoutPathAttributes .......................................................................................................... 2416
mwLayoutPolylineAttributes ..................................................................................................... 2416
mwLayoutArcAttributes ........................................................................................................... 2416
mwLayoutFaceAttributes .......................................................................................................... 2417
mwLayoutDrillHoleAttributes .................................................................................................... 2417
mwEmExtractAtrributes ........................................................................................................... 2417
mwEllipseAttributes ................................................................................................................ 2417
mwArcAttributes ..................................................................................................................... 2417
mwPolylineAttributes ............................................................................................................... 2418
mwPathAttributes .................................................................................................................... 2418
mwArrayCellAttributes ............................................................................................................ 2418
mwCellStretcherAttributes ........................................................................................................ 2418
mwSymbolTextAttributes .......................................................................................................... 2419
mwSymbolPathAttributes ......................................................................................................... 2419
mwLayoutConnectionLineTypes ................................................................................................ 2419
mwSpiceExtractionModelLevel .................................................................................................. 2420
mwINetModelingLevel ............................................................................................................. 2420
mwModelCompatibilityVersion .................................................................................................. 2420
mwRouteObstructionLevel ........................................................................................................ 2420
mwModelExtractType .............................................................................................................. 2421
mwDrawingTextAttributes ........................................................................................................ 2421
mwDefaultFaceAlignType ......................................................................................................... 2421
mwApplicationAttributeType ..................................................................................................... 2421
mwApplicationDirectoryType .................................................................................................... 2422
mwApplicationFileType ............................................................................................................ 2423
mwLayoutCellExportOptions .................................................................................................... 2423
mwObjectSelectFilters .............................................................................................................. 2423
mwLayoutObjectSelectFilters .................................................................................................... 2424
mwModelPropertyFlags ............................................................................................................ 2424
mwViewVisiual ....................................................................................................................... 2425
mwNetViaSizeOpts .................................................................................................................. 2426

xii NI AWR Design Environment


Contents

mwDefRouteConnModelTypes .................................................................................................. 2426


mwEMPortFlags ..................................................................................................................... 2426
mwSmithGridAttributes ............................................................................................................ 2426
mwPolarGridAttributes ............................................................................................................. 2427
mwRectGridAttributes .............................................................................................................. 2428
mwPlot3DGridAttributes .......................................................................................................... 2428
mwTabularGridAttributes .......................................................................................................... 2430
mwSimStateFlags .................................................................................................................... 2430
mwShowFileFlags ................................................................................................................... 2430
mwShapePreprocessorAttributes ................................................................................................ 2430
mwBooleanEngineVersions ....................................................................................................... 2431
mwBooleanCornerStyles ........................................................................................................... 2431
mwWindowState ..................................................................................................................... 2431
mwOptimizerSetting ................................................................................................................ 2431
mwStatisticalDist .................................................................................................................... 2432
mwVarPropMode .................................................................................................................... 2432
mwEquationVariableType ......................................................................................................... 2432
mwEquationDataType .............................................................................................................. 2432
mwUnitType ........................................................................................................................... 2433
mwParameterStyle ................................................................................................................... 2434
mwParameterStyleSetting ......................................................................................................... 2434
mwParamDefDataType ............................................................................................................. 2434
mwParameterDefinitionFlagType ............................................................................................... 2434
mwNodeType ......................................................................................................................... 2435
mwNodeDataType ................................................................................................................... 2436
mwNodeFlags ......................................................................................................................... 2436
mwDisplayModeType .............................................................................................................. 2436
mwPropertyDataType ............................................................................................................... 2436
mwShapeType ........................................................................................................................ 2437
mwFillStyle ............................................................................................................................ 2437
mwLineStyle .......................................................................................................................... 2438
mwShapeSubObjectType .......................................................................................................... 2438
mwShapeArcDirection ............................................................................................................. 2439
mwPathEndType ..................................................................................................................... 2439
mwPathMiterType ................................................................................................................... 2439
mwTextAlignment ................................................................................................................... 2439
mwFaceAlignment ................................................................................................................... 2440
mwFaceMultiLayerProperty ...................................................................................................... 2440
mwFaceShapeType .................................................................................................................. 2440
mwFaceGroupType .................................................................................................................. 2440
mwWindowType ..................................................................................................................... 2441
mwWindowTileDirection .......................................................................................................... 2441
mwDimensionTextLocation ....................................................................................................... 2442
mwDimensionArrowLocation .................................................................................................... 2442
mwLayoutRulerTickLocation .................................................................................................... 2442
mwRouteObjectType ................................................................................................................ 2442
mwRouteSegmentEndStyleType ................................................................................................. 2442
mwRouteViaDirectionType ....................................................................................................... 2443
mwRouteSegmentEndOffsetType ............................................................................................... 2443
mwDrawingArcDirection .......................................................................................................... 2443
mwShapeNetType ................................................................................................................... 2443

API Scripting Guide xiii


Contents

mwObjectIncludeType .............................................................................................................. 2443


mwDesignRuleType ................................................................................................................. 2444
mwDesignRuleState ................................................................................................................. 2444
mwDesignRuleErrorFileFormat .................................................................................................. 2444
mwAreaAddType .................................................................................................................... 2445
mwDesignViewType ................................................................................................................ 2445
mwComponentTestResultType ................................................................................................... 2445
mwLayoutSnapType ................................................................................................................ 2445
mwLayoutWindowType ............................................................................................................ 2445
mwRouteTopologyType ............................................................................................................ 2446
mwRouteStatusType ................................................................................................................ 2446
mwRouteBendStyleType ........................................................................................................... 2446
mwNetViaMode ...................................................................................................................... 2446
mwRouteConnModel ............................................................................................................... 2447
mwViewFrom ......................................................................................................................... 2447
mwViewAutoRotate ................................................................................................................. 2447
mwLVSHighlightLoc ............................................................................................................... 2447
mwShapeModifierType ............................................................................................................ 2448
mwShapeModifierPriority ......................................................................................................... 2448
mwEMPortType ...................................................................................................................... 2448
mwEMGroupType ................................................................................................................... 2448
mwEMShapePortType .............................................................................................................. 2449
mwPlacementJustfication .......................................................................................................... 2449
mwUnionShapesType ............................................................................................................... 2449
mwIntersectShapesType ............................................................................................................ 2449
mwExclusiveOrShapesType ...................................................................................................... 2450
mwCellExportFormat ............................................................................................................... 2450
mwLayoutParamDataType ........................................................................................................ 2450
mwDrawingSubObjectType ....................................................................................................... 2450
mwElementType ..................................................................................................................... 2450
mwSubcktGroundType ............................................................................................................. 2451
mwModelParseType ................................................................................................................. 2451
mwSchematicExportFormat ....................................................................................................... 2451
mwSchematicNetlistExportFormat .............................................................................................. 2451
mwDrawingShapeType ............................................................................................................. 2451
mwDiagramLockLevel ............................................................................................................. 2452
mwEmbeddedDocType ............................................................................................................. 2452
mwSystemExportFormat ........................................................................................................... 2452
mwHatchStyle ........................................................................................................................ 2453
mwBoundaryModelType ........................................................................................................... 2453
mwEmSimulator ..................................................................................................................... 2453
mwEMInputDataXMLType ....................................................................................................... 2454
mwGraphType ........................................................................................................................ 2454
mwMeasDataType ................................................................................................................... 2454
mwThickness .......................................................................................................................... 2455
mwScaleType ......................................................................................................................... 2455
mwDashStyle ......................................................................................................................... 2455
mwTraceSymbols .................................................................................................................... 2455
mwPlotAxis ........................................................................................................................... 2456
mwTraceStyle ......................................................................................................................... 2456
mwTraceSteppedColorStyle ...................................................................................................... 2456

xiv NI AWR Design Environment


Contents

mwMarkerSearchMode ............................................................................................................ 2457


mwMarkerSearchDirection ........................................................................................................ 2457
mwMarkerSearchVariable ......................................................................................................... 2457
mwMarkerType ....................................................................................................................... 2457
mwMarkerAutoSearchMode ...................................................................................................... 2457
mwMarkerOffsetMode ............................................................................................................. 2458
mwMarkerSymbolType ............................................................................................................ 2458
mwGraphMarkerType .............................................................................................................. 2458
mwGraphMarkerFormat ........................................................................................................... 2459
mwPrecisionMode ................................................................................................................... 2459
mwPrecisionStyle .................................................................................................................... 2459
mwLineMarkerType ................................................................................................................. 2459
mwLineMarkerTrackType ......................................................................................................... 2459
mwDataFileType ..................................................................................................................... 2460
mwCellLibraryType ................................................................................................................. 2460
mwOptGoalType ..................................................................................................................... 2460
mwLayoutExportFormat ........................................................................................................... 2460
mwViaSpacingType ................................................................................................................. 2461
mwViaFillStaggerMode ............................................................................................................ 2461
mwViaAlignType .................................................................................................................... 2461
mwNetlistType ........................................................................................................................ 2461
mwYieldGoalType ................................................................................................................... 2462
mwSymbolShapeType .............................................................................................................. 2462
mwSymbolType ...................................................................................................................... 2462
mwSymbolSelectMode ............................................................................................................. 2462
mwUnitMultType .................................................................................................................... 2463
mwErrorType ......................................................................................................................... 2463
mwEMInitType ....................................................................................................................... 2463
mwModelPriorityType .............................................................................................................. 2464
mwLibraryElementType ........................................................................................................... 2464
mwDockBorder ....................................................................................................................... 2464
mwDockState ......................................................................................................................... 2465
mwStatusItemCategory ............................................................................................................. 2465
mwJobStatusType .................................................................................................................... 2465
mwShowFileType .................................................................................................................... 2466
mwPageSetupOrientation .......................................................................................................... 2466
mwPageSetupDetailLevel ......................................................................................................... 2466
mwPrintPaperSize ................................................................................................................... 2466
mwPrintPaperSource ................................................................................................................ 2469
mwSystemSimulatorState ......................................................................................................... 2470
mwProjectVersionType ............................................................................................................. 2470
mwProjectItemType ................................................................................................................. 2470
mwProjectTemplateType ........................................................................................................... 2471
mwDataSetFlags ..................................................................................................................... 2471
mwExternalEditorType ............................................................................................................. 2472
mwEECmdShow ..................................................................................................................... 2472
Index .......................................................................................................................................... Index1

API Scripting Guide xv


Contents

xvi NI AWR Design Environment


NI AWR Scripting Guide
The NI AWR Design EnvironmentTM (NI AWRDE) is an object-oriented application that contains an Integrated
Development Environment (IDE). An IDE is a multi-purpose development tool that allows programmers to manage NI
AWRDE Projects. The program also includes a scripting tool that features its own IDE, has its own main window, runs
its own threads, and manipulates the current project's components, such as collections of objects, their properties and
methods. This allows you to write scripts that control the program asynchronously.

You can create scripts for the NI AWRDE using the VBA script language, Visual Basic, C++, Java Script, Perl and other
languages.

This document contains many working scripts with problems and solutions and explains the basic concepts of NI AWRDE
scripting while providing you with coding examples. It also provides information on the most useful objects, properties,
and methods for creating scripts in the NI AWR Script Development Environment (NI AWR SDE). Selected objects and
properties are supplied with detailed explanations and examples to demonstrate various approaches to problem solving.

Introduction
The NI AWR Design Environment (NI AWRDE) exposes a Component Object Model (COM) Automation Application
Programming Interface (API). The API provides unlimited ways to extend the capabilities of the software from
programming languages such as Visual Basic (including VBScript and VBA), Java Script, Visual C++, and the Windows
Scripting Host. Using the NI AWRDE object model you can create scripts and author wizards for automating common
or complex tasks.

The NI AWRDE has a built-in Visual Basic-compatible Script Development Environment (SDE) accessible by choosing
Tools > Scripting Editor. Within the SDE you can write macros or small programs. The SDE is described further in The
Script Development Environment.

The NI AWRDE also allows authored code to be tightly integrated into its framework with Wizard components. With
a Wizard component, your code is compiled into a DLL and is loaded by the program when it starts. Wizards are run
from within the program and can save data inside the Project file. The Wizards feature is described further in Wizards.

Benefits of the COM Automation API


The COM Automation API approach provides many benefits to NI AWRDE users, enabling the program to be an
extremely powerful design and analysis system. These benefits are described in the following sections.

Easy Integration with Other Applications

Applications (like NI AWR's) that are implemented as COM Automation Servers share a common API that allows them
to be easily integrated with any other COM Automation Servers via a single COM Automation Client such as a Visual
Basic script. This COM Automation Client has control over all of the COM Automation Servers installed on the machine.
Each COM Automation Server runs in its own process space, while the COM automation mechanism takes care of
transferring information across processes. Any data extracted from the object model of one application object can be
used within the object model of any other application object.

The following figure shows how a single COM Automation Client is used to control a number of other applications
including the NI AWRDE. This COM Automation Client can be the NI AWRDE built-in scripting engine, or it can be
an external automation client. The built-in scripting engine allows you to execute scripts from within the program
environment.

API Scripting Guide 11


Introduction

In the traditional approach to adding a scripting engine to an application, the scripting engine runs within and is tightly
embedded in the application, as shown in the following figure. The API can only be used to control a single Instance of
the application itself. While useful for automating tasks within the application, it does not allow the application to be
integrated with other applications using a common scripting language.

A Non-Proprietary Solution

Scripting languages are typically proprietary languages that are unique to the application, requiring users to learn
specialized syntax that may not be well-documented. With the COM automation approach, you have a choice of languages
such as Visual Basic and C++ that are standard, well-supported, and well-documented.

An Object-Oriented Solution

The COM automation approach is designed for use with object-oriented applications. A COM Automation Server exposes
the underlying object model of the application as objects within the scripting or programming environment, and allows
you to use powerful object-oriented software techniques in the scripts or programs that control these applications. An
object-oriented API allows direct manipulation of the underlying objects via an unlimited set of operations.

In contrast, flat functional APIs require that all operations performed on the underlying software application be performed
through a set of functions that manipulate the underlying objects in the application. The limited set of functions in the
flat API restricts the operations that can be performed on the underlying object model.

Capabilities of the COM Automation API


You can use the COM Automation API both to automate tasks within and extend the capabilities of the NI AWRDE.

The COM Automation API allows you to:

Create scripts to automate tasks within the program, and then optionally assign the scripts to function keys.
Author design wizards that add functionality to the program, such as a synthesis capability.
Customize the program to address your own design problems.

12 NI AWR Design Environment


The Script Development Environment

Integrate third-party tools1 with the program to perform types of analysis not offered by the NI AWRDE, such as
thermal analysis on physical layout.
Use the program as a design framework that ties together different COM-compliant applications which can leverage
the tools that are built into the framework. For example, the NI AWRDE can be one of several COM-compliant
applications integrated to create a completely automated manufacturing or testing system.
Create a Bill of Materials or other type of documentation that can be generated from the program's design database.

The Script Development Environment


NI AWR's Script Development Environment (SDE) allows you to create and execute macros and utilities to automate
complex tasks from within the NI AWRDE. The SDE supports scripting in Visual Basic, and includes syntax highlighting
and powerful debugging capabilities.

The Scripting Editor contains BASIC script modules that you can run from the program by choosing Scripts > Global
Scripts or Scripts > Project Scripts directly, or from within the SDE. The script modules are designated as either Global
or Project scripts.

NOTE: Do not manually edit (add, remove, or change) the scripting files included in the NI AWRDE installation.
Changes to these files are permissible only through the NI AWR SDE.

Components of the Script Development Environment


To open the SDE, choose Tools > Scripting Editor or click the Scripting Editor toolbar button. The NI AWR SDE window
opens and a View MWOffice button displays on the SDE toolbar to provide a convenient way to switch back to the main
NI AWRDE window.

1
Future enhancements to the COM Automation API will allow the integration of third-party simulation tools.

API Scripting Guide 13


The Script Development Environment

If the Scripting Editor button does not display, right-click the Wizards node in the Project Browser and choose Manage
Wizards to display the Addin Manager dialog box. Ensure that the AWR Scripting IDE check box is selected and that
ScriptingIDE.dll is in your \Wizards subdirectory. The major components of the SDE are described in the following
table:

Name Description
Project Script Project Browser (or simply, Project Browser). Allows you to create scripts
to automate tasks within the NI AWRDE. The scripts display as two subnodes.
The first subnode, Global, contains global modules. The second subnode,
Projectname.emp, contains project-specific modules.

Menus A set of menus displays only if the SDE is active: File, Edit, View, Insert, Debug,
Run and Help.

Most of the menu choices and commands are also available as buttons on the
toolbar.
Script workspace The area in which you design, run, and debug scripts.
Immediate window The area in which you can print the results of a running script and watch the
value of the variables during the debugging process.
Toolbars (Debug and Edit) A row of buttons that provides shortcuts for editing, running, and debugging
scripts; creating new Code Modules; accessing VBA Object Browser Help;
adding available references to a Project; and for accessing Immediate, Watch
and Quick Watch Windows.

To view a tool tip for a particular toolbar command, pass the cursor over the
button.
DCVal DC Value (Used for DC analysis)

Global and Project Scripts


Scripts can be either global, or specific to a Project. If a script is general purpose and can be used with many projects,
you should save it as a global script. If the script only works with a specific Project, you should save it as a project script.

Project scripts are saved in the Project, so if you copy your Project file to another machine, your scripts are automatically
included. The Projectname.emp subnode contains project-specific modules with the Project root name. These subnodes
can also contain folders for Object and Code modules. Project scripts are included in a Project by creating a new script
or importing an existing script.

Global scripts are available to all Projects. The Global subnode contains global scripts that are stored separately in
individual *.bas files located in specific folders on your computer. Scripts shipped with the program installer are located
at $AWR/Scripts. You should save to the appdatauser/Scripts folder any Global scripts that you add. To locate this folder,
choose Help > Show Files/Directories to open the Directories dialog box, then double-click the ScriptsUser folder. You
can add a new *.bas file to your appdatauser/Scripts folder, then right-click the Global node and choose Check For New
Files to make the new script available.

To define more than one global script folder, add the following line in your User.ini file:

[File Locations]
Scripts=$DEFAULT;<path>

14 NI AWR Design Environment


The Script Development Environment

where <path> is the full or relative path to the folder to search for additional *.bas files. You can add more than one
path by separating paths with semi-colons. PDKs can also specify a Scripts file location, so scripts can be shipped with
PDKs and loaded automatically as global scripts.

You can also store a script as a .bas file individually by right-clicking the script in the Project Browser and choosing
Export scriptname. You can import a script to any Project by right-clicking the script in the Project Browser and choosing
Import.

Both nodes each contain sets of folders grouping the different module types together. The NI AWRDE SDE supports
two types of modules: Object Modules and regular Code Modules.

The language used in scripts is SAX Basic, a subset of Microsoft Visual Basic for Applications. SAX Basic language
online Help is available by pressing F1.

Importing Scripts
In the SDE, you can Import scripts by right mouse click on the Object Modules and choose Import from the Right Click
Menu. This command open Import dialog. You need to find the directory where the script is and double - mouse click
on the *.bas file, like in the following picture:

API Scripting Guide 15


The Script Development Environment

After that the Module script will be opened in the SDE. Keep in mind that if you want to Import the Global script you
should right - mouse click on the Object Modules under the Global section of the SDE tree. If you want script to be saved
in the project you need to save the project after importing the script.

Running Scripts
In the SDE, you can run scripts by:

Right-clicking the module name and choosing Run Sub Main


Choosing Run > Run Sub from the SDE menu
Clicking the Run button on the toolbar

You can also run scripts directly from the main program menu by choosing Scripts. Scripts display either under Scripts
> Project Scripts or Scripts > Global Scripts, depending on the script location. The list that displays is in the format <module
name>(<sub name>). Any Sub in a given module that takes no input arguments is available in this list. You can hide any
such sub by using the "Private" declaration before the name of the sub function. For example, the following figure shows
a macro named "example" that has three sub functions, a,b, and c.

16 NI AWR Design Environment


The Script Development Environment

Notice that the third sub is declared private. If you choose Scripts > Project Scripts you can access only the first two sub
functions as shown in the following figure.

You can control how scripts display in the Scripts menu. Above any Sub you can add a line that defines the folder in
which to display the script. This line is in the form '$MENU=name where name is the desired folder name. The name
of the sub displays under that folder. You can use the folder name "hidden" to prevent that sub from displaying. For
example, you can add the line "' $MENU=Data" to display this script under the Data sub menu. Only one level of folders
is allowed. When you use this syntax the script is only in this folder; it is no longer in the Scripts > Project Scripts or
Scripts > Global Scripts folders. Because of this structure, NI AWR recommends that you write your scripts with one Sub
Main that uses the hidden folder tag, and then give your code a meaningful name that you then call from the Sub Main.
This is because you need a Sub Main to run the script from the SDE, but you want a meaningful name when running the
script from the Scripts menu. The following example scripting code demonstrates these various concepts.

' $MENU=hidden
sub main
Delete_Unassociated_iNets
end sub
' $MENU=Layout
Sub Delete_Unassociated_iNets
End sub

The following figure shows how this script displays in the NI AWRDE menu.

Notice that there is a folder named Layout and a script named "Delete_Unassociated_iNets" under that folder.

You can use menu, toolbar, or hotkey customizations to run any macro. See Customizing Toolbars and Menus and
Customizing Hotkeys for details on customizing these objects. When customizing, look for the Categories setting equal
to Macros.

API Scripting Guide 17


The Script Development Environment

Code Modules
Code modules contain procedures that run from start to finish when executed. This is useful for creating macros or
procedures for automating tasks that you would normally perform manually.

When you run a code module, a special procedure, Sub Main, is executed. This procedure can in turn call other procedures
with the module.

To create a module, right-click the Global or Projectname.emp node and choose Insert Module where <Projectname> is the
name of your current Project. A new module is added to the node. To edit the module code, right-click the module and
choose View Code to display the module in the Code Editor.

When you are ready to run the code, click the Run button on the toolbar. The Sub Main in your module begins executing.
To debug your code, choose View > Toolbars > Debug to display the Debug toolbox. Use the appropriate "step" buttons
on the Debug toolbar.

Object Modules
An Object module runs code in response to events generated by the NI AWRDE object. Object modules do not have a
Sub Main that executes when they run. Instead, they contain special functions called Event Handlers that execute in
response to events that objects start. When run, the Basic engine waits for an event to occur, such as adding a Schematic
to the Project. When the event occurs, the associated Event Handler code executes.

The NI AWRDE automatically adds an Object module to the Object Modules node for each available object that starts
events. The ThisProject subnode represents the currently open Project and displays when the Project is open. You can
add or remove other modules from the Object Modules node as you create and remove items from the Project.

To enter code that responds to an event, right-click the object module that starts the event and choose View Code to open
the module in the Code Editor. In the Code Editor window, select the object that starts the event from the Object list, and
then select an event from the Proc list. After you select an event, a handler procedure is added to the module and you
can add any additional code you want to execute. The following figures show this process.

18 NI AWR Design Environment


The Script Development Environment

Before the code can respond to events you must run the module by clicking the Run button on the toolbar. When you
open a Project, the Object modules are automatically set to Run mode. You cannot edit modules while they are running;
to make changes to the event procedures you must click the Reset button on the toolbar. When you are done editing,
click the Run button to start the module. Your event code is not executed while the module is stopped.

API Scripting Guide 19


The Script Development Environment

Next time you open the project with the macro running the dialog box should appear from the beginning asking if you
would like to Enable or Disable macros. If you set option "Always use the settings and do not warn again" the dialog
will never pops up again. So, if you will need to change the settings and to have the dialog back there should be an entry
in the user.ini file. Search for the project name in the user.ini and remove the entry for warning about the script. The
setting also may be in the mwoffice.ini file:

[test_project.emp]
EnableMacros=-1

The properties and methods of the object associated with the Object module are available as global keywords. You can
also access these properties and methods using the Me operator or the object name. For example, when editing code in
the ThisProject module the properties and methods of the Project object are exposed as global keywords. Because an
object module is associated with a specific Instance of an object, accessing a property gets the object's current value.
The following code fragments show the different syntax styles that you can use to save the Project when you add a new
Schematic.
Handle the NewSchematic event
Private Sub Project_NewSchematic(Schematic
As Schematic)
Use the Object name to call the Save method
ThisProject.Save
End Sub

Handle the NewSchematic event


Private Sub Project_NewSchematic(Schematic
As Schematic)
Use the Me operator to call the Save method
Me.Save
End Sub

Handle the NewSchematic event


Private Sub Project_NewSchematic(Schematic
As Schematic)
Use the global keyword to call the Save method
Save
End Sub

Working with Scripts


You can create a module by right-clicking the Projectname.emp node and choosing Insert Module. A blank "Projectname.emp
Module#" code module displays. Only one code module can be active at a time, and only one code module can run at a
time. The name of the active module displays in the title bar after the Project name.

To rename a script, right-click the Module# subnode and choose Rename Module#.

To delete a script, right-click the Module# subnode and choose Remove Module#.

To save a script, click the Save button on the toolbar.

Save your Project and the script is saved inside the Project *.emp file.

To import a script into an NI AWRDE Project, right-click the Projectname.emp node, choose Import and select the file
from the Import dialog box. The imported script name displays in the Project Browser.

110 NI AWR Design Environment


The Script Development Environment

To export a script, right-click the Module# subnode and choose Export Module#. Module# is saved as a *.bas file.

Creating References
To work with different automation clients and their objects, you should create a reference to a COM components type
library using the following steps in the SDE:

1. Click the References button on the toolbar.

A list of references similar to those shown in the following figure displays.


2. Select the check box next to the reference you want to add.
3. If the desired reference is not listed, click the Browse button and locate the type of library you want to use.

Note that the NI AWRDE object library is selected by default.

After loading a type library, you can use the objects, properties, and methods in your VBA code.

Getting Help
When typing code, press the F1 key to display Help for the specific word the cursor is over. If the cursor is over a
component that belongs to the NI AWR API, the NI AWRDE Help opens to the appropriate section, otherwise the Sax
Basic Help opens. See the AWR Design Environment Component API for the component specific Help section.

VBA Object Browser


A VBA scripting language that uses the standard Visual Basic syntax features one generic object type, the Collection
object (a set of related objects).

You can use the VBA Object Browser to view a list of the component's classes, properties, methods, and events.

To open the Object Browser in the SDE, click the Object Browser button on the toolbar or choose View > Object Browser.

The following figure shows the Object Browser with the NI AWRDE (MWOffice) type library selected.

API Scripting Guide 111


The Script Development Environment

An object-oriented API exposes all NI AWR SDE Elements as objects. When the Object Browser opens, it displays in
Library a list of all NI AWR SDE classes included in the current VBA Project. You can select a single component -
MWOffice, or All Libraries (SAX Basic). The Object Browser exposes all of the object classes available from the Automation
component. Select a class to display its methods and properties in Methods/Properties. You can see for example, what
data types are returned by various methods and properties, or what parameters a particular method expects. The collections
are also included in that list.

Debugging Scripts
You can see the results of a running script in the Immediate window if you insert into your script a "Debug.Print" method
for printing variable values, or you can use the Immediate window to watch the variable values when debugging the
script.

112 NI AWR Design Environment


Developing a Script

To watch the value of the variable during the debugging process, place the cursor on the variable you want to watch,
right-click and choose Quick Watch. You can watch the highlighted value of the variable during the debugging process
if you insert a breakpoint, run the script, and place the cursor over the variable when the script stops.

To insert a breakpoint, do one of the following:

With the cursor on the operator you want to stop, right-click and choose Toggle Break.
Click the Code Module window on the left side of the operator you need to stop.
Press F9.
Choose Debug > Toggle BreakPoint.

To explore each command execution step-by-step, or just after cycle execution, use the following Debug menu commands:

Step Into F8
Step Over Shift + F8
Run To Cursor Ctrl + F8
Clear All Breakpoints Ctrl + Shift + F9
Toggle Breakpoint F9

Printing Scripts
To print a script, do one of the following:

Right-click the Module# subnode and choose Print.

With the Code Module active, choose File > Print.


Click the Print button on the toolbar.
Press Ctrl + P.

Developing a Script
Using a Code Module at Startup
The preferred method for starting NI AWRDE scripts is to use a Sub Main procedure. To create a Sub Main procedure,
you must insert a Code Module into your Project. A new Code Module contains Sub Main and End Sub lines. You can
enter VBA code in the new module and reference any Objects and Forms that you need.

You can write Functions and Sub procedures in your code and use them as usual. Note that the program terminates when
the Sub Main procedure is completed.

Using Variables and Data Types

You can use any of the varieties of data types that the VBA language offers, even a Variant data type.

Be careful when using a Variant data type if you are not sure that every item of variant data has a subtype that corresponds
to one of the major data types.

VBA allows the implicit declaration of variables. However, it is good programming practice to explicitly declare any
variables and constants you want to use by using the Dim, Private, or Public statements with the following syntax:

API Scripting Guide 113


Developing a Script

Dim VariableName As datatype

Private VariableName As datatype

Public VariableName As datatype

You can explicitly declare variables as shown in the following script:

'Code Module
Sub Main
Dim a As Boolean, b As Byte, c As Complex
Dim d As Decimal, e As Double, i As Integer
Dim l As Long, s As String
Dim o As Object
Dim f As Single
Dim v As Variant
Private k As Integer
Public st As String
End Sub

VBA handles a lot of data type conversion in the background; you don't need to do it explicitly.

If you know how many values you need to store in an array, you can declare it with a Dim statement as follows:

Dim vals(5) As Double

This Dim statement creates an array named "vals" with six Elements, because all VBA arrays start with location 0.

To populate an array, use the following code:

For i = 0 To 5
vals (i) = i*1e8
Next i

If you try to access the Element at a location greater than 5, you receive an "Array out of range" error message.

If you do not know in advance how many Elements you need, declare a dynamic array using the following code:

Dim ival () As Integer

When you determine the size of a dynamic array further in your code, you can specify the number of Elements using a
ReDim statement as follows:

ReDim ival (4) As Integer

There is no limit to the number of times you can re-dimension a dynamic array. To keep the data, use a Preserve keyword
to avoid losing data during re-dimensions.

ReDim Preserve ival(10)

114 NI AWR Design Environment


Developing a Script

ReDim creates a new array. The Preserve keyword copies the data from the old array to the new array. Note that you
always lose the data if you resize your array by contracting it.

For a more detailed explanation, see your VB and VBA fundamentals documentation.

To declare and re-dimension a multi-dimensional array, use the following statement:

Dim vals(0,0) As Double


Dim vals(5,5) As Double
ReDim vals(10,10) As Double
ReDim Preserve ival(10,10)

Global Properties and Methods the API Provides in the SDE

To make scripts easier to develop, the properties and methods of the global MWOffice application object are added to
the Global namespace in the SDE. The API is designed as a rooted hierarchy with all objects accessible from one global
MWOffice Application object. Because you are working in the context of the MWOffice application when in the SDE,
making these accessible from the global namespace makes it simpler to access objects associated with the application.
It also makes it easier to use the Immediate window in the SDE to evaluate expressions. For example, to get a count of
the models currently loaded into the system you can type:

Models.Count

rather than

MWOffice.Models.Count

Both lines work, the first is just shorter. Likewise, you'll often use the MWOffice.Project object to access information
in the currently loaded Project. Again, you can directly access this object from the global namespace. With a Schematic
called "MySchematic", you could get a count of the Schematic Elements using:

Project.Schematics("MySchematic").Elements.Count

Again, you could have used:

MWOffice.Project.Schematics("MySchematic").Elements.Count

and obtained the same result. You might want to use the "MWOffice." portion in the case of a namespace conflict. NI
AWR tries to avoid these conflicts, however occasionally a method or property name may match with either a global
from the SDE or another library reference in your Project. In these cases you can clarify which property or method you
intend by using the application portion "MWOffice." before the property or method name.

Option Explicit

You can use an Option Explicit statement to reduce the number of bugs in your code caused by other than spelling errors.
For example, when you work with the SDE you are able to access the properties and methods directly without qualifying
them with a "MWOffice." prefix. This works unless you have a collision with reserved basic VBA words. The following
are two examples.

Example 1:

API Scripting Guide 115


Developing a Script

Debug.Print "Left = ";MWOffice.Project.Application.Left

The first statement should refer to the MWOffice.Left property, however, a syntax error displays because an MWOffice
reference is omitted and the corresponding VBA Left() function should include parentheses.

If you are not sure about possible collisions, always use the explicit prefix of the reference library:

Debug.Print "Left = ";MWOffice.Left

Example 2:

In the following statement, the value is not what was expected because we just created a new variable named Count that
has no type and no value. Remember that you do not need to declare variables before they are used in VBA; the program
automatically creates new variables as they are used.

Debug.Print "Count = "; Count

Use an "Option Explicit" declaration at the top of the file to avoid this problem:

'Code Module
Option Explicit
Sub Main
Dim a As Boolean
End Sub

A compile-time error is generated if an undeclared variable is encountered.

Referencing Subs and Functions in Other Files

If you want to reference sub routines or functions in other .bas files, there are several options. This can be a good way
to track common groups of code you want to reuse and easily update. The disadvantage to these approaches is that you
cannot debug into any referenced functions.

To reference subs and functions in a stand-alone file, use the following in your script:

'#Uses "global.bas"
Sub main

End Sub

The path to the file can be an absolute path or a path relative to the NI AWR Project file in which you are working.

Alternatively, you can reference subs and functions in another script loaded in the SDE for that type (Global or Project)
by using the following in your script:

'#Uses "*global"
Sub main

End Sub

116 NI AWR Design Environment


Developing a Script

Notice a few differences. There is no path to the file. You use a "*" before the name. You do not use the .bas extension
for the file.

NOTE: You cannot reference items in a Project level script in Global scripts, nor items in a Global level script in Project
scripts.

Declaring Object Variables

Object classes are the type of objects that an Automation server makes available for you to control. Object classes have
a defined set of properties, methods, and events that dictate how Instances of that object class look and act. When you
write Automation code, you manipulate objects that are Instances of object classes. Objects are created at run-time and
are then destroyed when no longer needed, or when the application ends.

The NI AWRDE provides a Component Object Model (COM) library that contains many objects and allows a number
of methods to perform operations with them. If you want access to a different type library and all objects in that library,
you need to set a reference to the library by choosing Edit > References and selecting an available reference.

The program follows the convention of using plural names to denote collections.

To use the object's library you must declare an object variable, which creates an Instance of the object as follows:

Dim le As MWOffice.LibraryElement
Dim s As Schematic
Dim em As EMStructure
Dim l As Layout
Dim c As Cell
Dim ap As Application
Dim ax As Axis
Dim cl As CellLibrary
Dim w As Window
Dim v As Vertex
Dim myObject As Object

In this example, "Schematics" denotes a collection of Schematic objects, and "EMStructures" denotes a collection of
EMStructure objects.

If you use a different type library, for example Excel, you need to explicitly address that library:

Dim wBook As Excel.Workbook


Dim applExc As Excel.Application

NOTE: Don't forget to make a reference to Excel before using this declaration.

You have created variables that are referred to your objects.

After you declare an object variable, you must assign an object reference to a real Instance of the class before you can
use the object's methods, properties, and events. To assign an object reference to a real Instance of the class, use the Set
statement. For example, to produce an early bound reference to the object:

Set s = Project.Schematics.Add("Filter")
Set em = Project.EMStructures.Add("EM Lange")

API Scripting Guide 117


Developing a Script

If you declare a generic Object you must use either CreateObject or GetObject functions to produce a late bound reference
to the object.

The Collection Object

As previously stated, VBA features one generic object type, the Collection object. Typically its members are other objects
and other collection of objects. Generally, you can use the following methods to work with a Collection:

Add - adds an item to the Collection


Count - returns the number of items in the Collection
Item - retrieves a member from the Collection by its index or special name (key)
Remove - deletes a member from the Collection by index or special name (key).

Note that a Collection is similar to an array, except that the lower bound of a Collection object's index is always 1.

In addition, most Collections use the Item method as default, so the following expressions are really equivalent:

MWOffice.Windows(2).Close
MWOffice.Windows.Item(2).Close

You can iterate the members of Collections using the "For Each ... Next" statement as follows:

'Code Module
Sub Main
Dim eqn As Equation
For Each eqn In Project.GlobalEquations
Debug.Print eqn.Expression
Next eqn
End Sub

You can iterate through a collection by obtaining its Count property value, which returns the number of items in the
Collection, and by executing a "For ... Next" loop as follows:

'Code Module
Sub Main
Dim eqn As Equation
For i = 1 to Project.GlobalEquations.Count
Debug.Print eqn.Expression
Next i
End Sub

You can remove a member from the Collection by its index or special name. Note that after you remove a member the
number of members decreases, so the next loop does not work.

'Code Module
Sub Main
Dim eqn As Equation
For i = 1 to Project.GlobalEquations.Count
Project.GlobalEquations.Remove.(i)
Next i
End Sub

118 NI AWR Design Environment


Developing a Script

The following is the correct script:

'Code Module
Sub Main
Dim eqn As Equation
For i = 1 to Project.GlobalEquations.Count
Project.GlobalEquations.Remove.(1)
Next i
End Sub

For an overview of the NI AWRDE SDE collections and objects, see the "AWR Design Environment Component API".

Event Handler

Scripts are packaged in two forms, Code Modules, in which you enter procedural code, and Object Modules, in which
you enter event handlers. Object Modules do not have a "Sub Main" that executes when you click the Run button on the
toolbar. Instead, the Object Module contains special functions, called event handlers, which execute in response to events
that are fired by an object. When you click the Run button on the toolbar, the basic engine waits for an event to occur,
such as adding a Schematic to a Project. When the event occurs, the event handler code for the event executes.

To add an event handler, double-click the ThisProject node under the Project level Object Modules node. In the Script
Editor window, choose Project as the Object. In Proc, choose the event you wish to handle. The event handler function
declaration is inserted into the Code Editor. You can now add your code to customize the handler. Event handlers must
be running in order to respond to events. Project event handlers are automatically started when the Project opens.

To edit event handler code, you must stop execution. "ThisProject" represents the currently open Project and exists as
long as the Project is open. You can add or remove modules from the Object Modules node.

The NI AWRDE SDE API contains the following events:

AfterSave
AfterSimulate
AfterSystemSimulate
BeforeClose
BeforeSave
BeforeSimulate
BeforeSystemSimulate
CellLibraryAfterRemove
CellLibraryAfterRename
CellLibraryBeforeRemove
CellLibraryBeforeRename
DataFileAfterRemove
DataFileAfterRename
DataFileBeforeRemove
DataFileBeforeRename
EMStructureAfterRemove

API Scripting Guide 119


Developing a Script

EMStructureAfterRename
EMStructureBeforeRemove
EMStructureBeforeRename
GraphAfterRemove
GraphAfterRename
GraphBeforeRemove
GraphBeforeRename
GraphNewMeasurement
NetlistAfterRemove
NetlistAfterRename
NetlistBeforeRemove
NetlistBeforeRename
New
NewCellLibrary
NewDataFile
NewSchematic
NewEMStructure
NewGraph
NewNetlist
NewOptGoal
NewOutputFile
NewProcessDefinition
NewSchematis
NewSystemDiagram
NewYieldGoal
Open
OptGoalAfterChange
OptGoalAfterRemove
OptGoalAfterToggleEnable
OptGoalBeforeChange
OptGoalBeforeRemove
OptGoalBeforeToggleEnable
OptimizerIteration
OptimizerStarted
OptimizerStopped
OutputFileAfterRemove

120 NI AWR Design Environment


Developing a Script

OutputFileAfterRename
OutputFileBeforeRemove
OutputFileBeforeRename
ProcessDefinitionAfterChange
ProcessDefinitionAfterRemove
ProcessDefinitionBeforeChange
ProcessDefinitionBeforeRemove
SchematicAfterRemove
SchematicAfterRename
SchematicBeforeRemove
SchematicBeforeRename
SchematicNewElement
SystemDiagramAfterRemove
SystemDiagramAfterRename
SystemDiagramBeforeRemove
SystemDiagramBeforeRename
SystemDiagramNewElement
YieldAnalysisIteration
YieldAnalysisStarted
YieldAnalysisStoppeed
YieldGoalChange
YieldGoalAfterRemove
YieldGoalAfterChange
YieldGoalAfterToggleEnable
YieldGoalBeforeRemove
YieldGoalBeforeChange
YieldGoalBeforeToggleEnable

The following is example code for processing an event:

'Project Module
Private Sub Project_AfterSave()
MsgBox "After save"
End Sub

The following example script shows how to use events for calculating simulation time:

' Project Module


Private Sub Project_BeforeSimulate(Cancel As Boolean)
Dim tim_beg, tim_fin As Double

API Scripting Guide 121


Developing a Script

Dim s,st As String


s = "C:\tmp\tim_beg.txt"
Open s For Output As #1
' Debug.Print Timer
tim_beg = Timer
Debug.Print "tim_beg = ";tim_beg
Print #1, tim_beg
End Sub
' Project Module
Private Sub Project_AfterSimulate()
Dim tim_beg, tim_fin, time_sum As Double
Dim s,st As String
'Debug.Print Timer
tim_fin = Timer
Debug.Print "tim_fin = ";tim_fin
s = "C:\tmp\tim_beg.txt"
Open s For Input As #1
Input #1, tim_beg
Close #1
time_sum = tim_fin - tim_beg
Debug.Print "time for simulation = ";time_sum
st = "C:\tmp\simtim.txt"
Open st For Append As #2
Print #2, time_sum
Close #2
End Sub

The following is a script for testing events:

' Project Module


Private Sub Project_AfterSave()
MsgBox "AfterSave"
End Sub
Private Sub Project_AfterSimulate()
MsgBox "AfterSimulate"
End Sub
Private Sub Project_AfterSystemSimulate()
MsgBox "AfterSystemSimulate"
End Sub
Private Sub Project_BeforeClose(Cancel As Boolean)
MsgBox "BeforeClose"
End Sub
Private Sub Project_BeforeSave(Cancel As Boolean)
MsgBox "BeforeSave"
End Sub
Private Sub Project_BeforeSimulate(Cancel As Boolean)
MsgBox "BeforeSimulate"
End Sub
Private Sub Project_BeforeSystemSimulate(Cancel As Boolean)
MsgBox "BeforeSystemSimulate"
End Sub
Private Sub Project_NewSchematic(Schematic As Schematic)
MsgBox "NewSchematic"
End Sub
Private Sub Project_SchematicAfterRemove(ByVal SchematicName As String)
MsgBox "SchematicAfterRemove"

122 NI AWR Design Environment


Developing a Script

End Sub
Private Sub Project_SchematicAfterRename(Schematic As Schematic, ByVal OldName As String)
MsgBox "SchematicAfterRename"
End Sub
Private Sub Project_SchematicBeforeRemove(Schematic As Schematic, Cancel As Boolean)
MsgBox "SchematicBeforeRemove"
End Sub
Private Sub Project_SchematicBeforeRename(Schematic As Schematic, ByVal NewName As String, Cancel A
MsgBox "SchematicBeforeRename"
End Sub
Private Sub Project_SchematicNewElement(Schematic As Schematic, Element As Element)
MsgBox "SchematicNewElement"
End Sub

As previously explained, before event handling, modules must be grouped in a ThisProject node. You may now add your
code to customize the handler. Event handlers must be running in order to respond to events. Project event handlers are
automatically started when the Project opens. To edit event handler code you must stop execution.

If you save this code under the Projectname.emp node, the event functions only in the current Project. If you save this
code under the Global node, the script functions in all Projects.

You can write your own code to customize events.

While working with the event handler, if you choose an event and write some code, ensure that the code is correct. For
example, if the event is in Project Open and the event imports a file to the program and the name of the file is incorrect,
upon opening the Project, your OnProjectOpen handler calls Import, which returns an error. Click OK to respond to the
error. The application appears hung, but is actually at a breakpoint in your script which is being called by MWOffice.
To continue, open the ThisProject module and press F8 to resume the script. MWOffice will continue to run normally.
NOTE: NI AWR includes project_New event to compliment the project_Open event handler. You can use this event
when loading new Projects.

Working with Object Modules

The properties and methods of the object associated with the Object Module are available as global keywords. You can
access these properties and methods using the Me operator or the object name. For example, when editing code in the
ThisProject module, the properties and methods of the Project object are exposed as global keywords. Because an Object
Module is associated with a specific Instance of an object, accessing a property gets the object's current value.

The following code fragments show the different syntax styles you can use to save the Project when you add a new
Schematic.

'Handle the NewSchematic event


Private Sub Project_NewSchematic(Schematic As MWOffice.Schematic)
'Use the Object name to call the Save method
ThisProject.Save
End Sub
'Handle the NewSchematic event
Private Sub Project_NewSchematic(Schematic As MWOffice.Schematic)
'Use the Me operator to call the Save method
Me.Save
End Sub
'Handle the NewSchematic event
Private Sub Project_NewSchematic(Schematic As MWOffice.Schematic)
'Use the global keyword to call the Save method

API Scripting Guide 123


Developing a Script

Save
End Sub

Specifying Global Project Settings


You can specify global settings for the units within all Schematics in a Project, and for simulation frequency within the
Project. You can configure all options in the Project using the Options collection.

Configuring Global Project Units

The core object in the NI AWR SDE is the Project. The NI AWR SDE exposes all of its features as Collections of objects
under the Project Object. The NI AWR SDE Units Collection allows access to the Global Project Units. This script
includes access to the BaseUnitString property of a Unit which provides a string value for the BaseUnit of each unit type.
There is also access to the unit description field via unit property description that gives a full string description of the
unit type, for example, "voltage" or "length" etc.

'Code Module
Sub Main
Dim iCount As Double
Debug.Clear
Dim un As Unit
iCount = Project.Units.Count
Debug.Print "iCount = ";iCount
For Each un In Project.Units
Debug.Print un.MultType;un.MultValue;un.Type;un.UnitString
Debug.Print "Base Unit Str = " & un.BaseUnitString
Debug.Print "Description = " & un.Description
Next un
End Sub

This script generates the following output:

iCount = 17
6 1 0

8 1000000 1 MHz

1 0.000000000001 2 pF

2 0.000000001 3 nH

6 1 4 ohm

6 1 5 S

11 0.0000254 6 mil

11 0.0000254 7 mil

15 1 8 DegC

19 1.74532925199433E-02 9 Deg

2 0.000000001 10 ns

6 1 11 V

124 NI AWR Design Environment


Developing a Script

4 0.001 12 mA

20 1 13 dBm

4 0.001 14 mW

6 1 15 dB

6 1 16

This code finds each unit object in the Project and prints the values of all units' properties:

MultType - Returns/sets a value that specifies the multiplier type of a Unit object
MultValue - Returns the multiplier of a Unit object
Type - Returns a value that specifies the unit type of a Unit object
UnitString - Returns a string that characterizes the actual name of the unit

Note that the value is returned in the default unit. For example, the default value for capacitance is pF because the
Schematic's default unit is pF.

To modify the Global Project Units, use the following script:

'Code Module
Sub Main
Dim unit_Ind As mwUnitType
Debug.Clear
Debug.Print Project.Units.Item(mwUT_Frequency).MultType
Debug.Print Project.Units.Item(mwUT_Capacitance).MultType
Project.Units.Item(mwUT_Frequency).MultType = mwUMT_Mega
Project.Units.Item(mwUT_Capacitance).MultType = mwUMT_n
Debug.Print "After changing"
Debug.Print Project.Units.Item(mwUT_Frequency).MultType
Debug.Print Project.Units.Item(mwUT_Capacitance).MultType
End Sub

This script generates the following output:

After changing

You can assign any unit's values for the Project. To convert all units to MKS, use the MultValue property. To make a
calculation in MKS, use the MultValue property as a multiplier. The MultValue is the value needed to go from user units
to base units so:

Base Units = User Units * Mult Value

API Scripting Guide 125


Developing a Script

or:

User Units = Base Units / Mult Value

For example, for a capacitance scale factor to convert, the value would be 1 e -12.

Property Type (DataType - mwUnitType) determines what type of unit object to use. For example, for frequency, you
can use GHz, MHz, KHz, or Hz.

Dim p As parameter
Dim ut As mwUnitType
Dim m As Measurement
ut = p.UnitType
multiplier = MWOffice.Project.Units(ut).MultValue
fstart = CDbl(edStart.Text)
m.xValue = fStart * multiplier

In this example, edStart.Text is the start frequency that you enter into the window's text field.

This code calculates the measurement for a start frequency.

Note that to set SystemDiagram.Elements(1).parameters("RATE") using ValueAsDouble, the right-hand side value needs
to be in MKS units. In the code:

SystemDiagrams(1).Elements(1).parameters("RATE").ValueAsDouble=1

The RATE parameter is set to "1" Hz. To set the RATE to "1" GHz use:

SystemDiagrams(1).Elements(1).parameters("RATE").ValueAsDouble= 1e9

One feature of the Units collection is that the index variable of the Units.Item() method is a "mwUnitType" so intellisense
in the scripting environment helps you pick the correct value:

The following are Intellisense displaying options for unit type:

Unit Type Type Index

mwUT_None 0
mwUT_Frequency 1
mwUT_Capacitance 2
mwUT_Inductance 3
mwUT_Resistance 4
mwUT_Conductance 5
mwUT_Length 6
mwUT_LengthEnglish 7
mwUT_Temperature 8
mwUT_Angle 9
mwUT_Time 10

126 NI AWR Design Environment


Developing a Script

mwUT_Voltage 11
mwUT_Current 12
mwUT_PowerLog 13
mwUT_Power 14
mwUT_DB 15
mwUT_String 16
mwUT_Scaler 17
mwUT_DBOnlyPower 18
mwUT_WattsOnlyPower 19

Using the multiplication factors and Unit Strings makes it easy to convert value to user units, display them correctly,
and later convert user inputs back to base units for your API application.

Configuring Global Project Frequency

The following script modifies the Project frequency:

'Code Module
Sub Main
'Sets Frequencies to the project
Debug.Clear
Dim vals(20) As Double
Dim freq As Frequency
'Prints all project Frequencies
For Each freq In Project.Frequencies
Debug.Print freq.Value
Next freq
'Trying to manipulate frequency data
For i=0 To 19
vals(i)=2*i*1e8 'Change this statement to set frequency you want
Next i
Project.Frequencies.Clear
Project.Frequencies.AddMultiple(vals)
Debug.Print "After changing "
For Each freq In Project.Frequencies
Debug.Print freq.Value
Next freq
Project.Frequencies.Add(1050000000)
Debug.Print "After setting project frequency "
For Each freq In Project.Frequencies
Debug.Print freq.Value
Next freq
End Sub

To override global Project frequency settings for a particular Schematic, use the following script:

'Code Module
Sub Main
'Sets Frequencies to the Schematic level
Debug.Clear

API Scripting Guide 127


Developing a Script

Dimvals(20) As Double
Dimsch As Schematic
Dimfreq As Frequency
Setsch = Project.Schematics("LINPAR 2 lines")
ForEach freq In sch.Frequencies
Debug.Print freq.Value
Next freq
sch.UseProjectFrequencies = False
For i=0 To 19
vals(i) = 2*i*1e8
Next i
sch.Frequencies.AddMultiple(vals)
sch.Frequencies.Add(1050000000)
Debug.Print "After changing "
For Each freq In sch.Frequencies
Debug.Print freq.Value
Next freq
sch.UseProjectFrequencies = True
Debug.Print "After setting project frequency "
For Each freq In sch.Frequencies
Debug.Print freq.Value
Next freq
End Sub

To override global Project frequency settings for a particular EM structure, use the following script:

'Code Module
Sub Main
Dim Ems As EMStructure
Dim Freq As Frequency
'Clear the output window.
Debug.Clear
For Each Ems In Project.EMStructures
'Print the name of the EMStructure for references.
Debug.Print "EmStructure Name = " & Ems.Name
Debug.Print "Use Project Frequencies="& Ems.UseProjectFrequencies
Debug.Print "Frequency Count= "& Ems.Frequencies.Count
'Try setting the use project frequencies to a value that it is currently not.
Ems.UseProjectFrequencies = False
Debug.Print
'Print the current frequencies.
Debug.Print "*** Frequencies ***"
ListStructureFreqs(Ems)
Debug.Print
Ems.Frequencies.Add(4.0e9)
'Print the current frequencies.
Debug.Print "*** Frequencies ***"
ListStructureFreqs(Ems)
Debug.Print
Ems.Frequencies.Remove(1)
'Print the current frequencies.
Debug.Print "*** Frequencies ***"
ListStructureFreqs(Ems)
Debug.Print
Next Ems
End Sub

128 NI AWR Design Environment


Developing a Script

Sub ListStructureFreqs(ByRef EMStruct As EMStructure)


Dim Freq As Frequency
Dim index As Integer
index = 0
For Each Freq In EMStruct.Frequencies
Debug.Print "Freq[" & index & "] = " & Freq.Value
index = index + 1
Next Freq
End Sub

The last script generates the following output:

EmStructure Name = EM Structure 1


Use Project Frequencies = False
Frequency Count = 3
*** Frequencies ***
Freq[0] = 1000000000
Freq[1] = 2000000000
Freq[2] = 3000000000
*** Frequencies ***
Freq[0] = 1000000000
Freq[1] = 2000000000
Freq[2] = 3000000000
Freq[3] = 4000000000
*** Frequencies ***
Freq[0] = 2000000000
Freq[1] = 3000000000
Freq[2] = 4000000000

Accessing the Global Definitions

Sometimes it is useful to define a global data Element and have all Schematics reference the same Element. This is useful
is when all the Schematics use the same substrate. You can add a substrate definition to the global data definitions and
then all of the Elements in your Schematics can use that substrate.

You can access the Global Definitions as Project.GlobalDataElements object. This object works much like a simplified
Schematic, so you can add Elements and equations in the same way you add them to a Schematic. You can add a substrate
object with the Add() method specifying the MSUB name and the location to place the substrate Element.

' Add substrate to the global data definitions


Set elem = Project.GlobalDefinitionDocuments(_Index).DataElements.Add("MSUB", 0, 0)

After you add the substrate definition to the global definitions you can create a Schematic and add some Elements to
reference it.

' Create schematic with MLIN element that references global substrate
Set schem = Project.Schematics.Add("MySchematic")
Set elem = schem.Elements.Add("MLIN", 0, 0)
schem.Elements.Add("PORT",elem.Nodes(1).x, elem.Nodes(1).y)
schem.Elements.Add("PORT",elem.Nodes(2).x,elem.Nodes(2).y,180)

API Scripting Guide 129


Developing a Script

When you want to define a data Element or equation for all Schematics to use, place that Element in the
Project.GlobalDataElements to make it available to all Elements from all Schematics in the Project.

Remove an Element:

Project..GlobalDefinitionDocuments(1).DataElements.Remove("MSUB.SUB1")

Remove all Elements:

Project.GlobalDataElements.RemoveAll

API methods for accessing the expression values for global equations.

Those methods are for accessing the expression values of equations for equation objects in Global Definition Documents.

Sub PrintExpressionValue(ByRef expr As EquationExpression)

Debug.Print expr.Expression
If (expr.DataType = mwEDT_Real) Then
Debug.Print "Real Value = " & expr.ValueAsDouble
End If

If (expr.DataType = mwEDT_String Or expr.DataType = mwEDT_Real Or expr.DataType = mwEDT_RealVecto


Debug.Print "String Value = " & expr.ValueAsString
End If

If (expr.DataType = mwEDT_Complex Or expr.DataType = mwEDT_Real) Then


Debug.Print "Complex Value = { Re = " & expr.ValueAsComplex.Real & ", Imag = " & expr.ValueAsCom
End If

If (expr.DataType = mwEDT_RealVector) Then


Debug.Print "Vector Values = ";
For i = LBound(expr.ValueAsDoubleVector) To UBound(expr.ValueAsDoubleVector)
Debug.Print expr.ValueAsDoubleVector(i) & ", ";
Next i
Debug.Print ""
End If
Debug.Print

End Sub

Configuring Global Settings

You can override global Project settings and set your own options for the following main NI AWR SDE objects: Project,
SystemDiagram, Schematic, and EMStructure. You can print a list of all options and properties for a particular object.

'Code Module
Sub Main
Debug.Clear
Dim opt As Option
Dim i As Long

130 NI AWR Design Environment


Developing a Script

i = 0
For Each opt In MWOffice.Options
i = i + 1
Debug.Print i;vbTab;opt.Name;vbTab;opt.Description;vbTab;opt.DataType;vbTab;opt.Value;vbTab
Next opt

This code generates the list of options, for example:

1 ShowTopLevelOnly - Returns/sets if the Project should display only top level Schematic nodes. 11 True True

2 OptionNodesInProject - Returns/sets if options nodes should display in the Project Browser. 11 False False

3 CollapseProjectTreeOnOpen - Returns/sets if the Project Browser should be collapsed on open. 11 False False

4 EvironmentOptionsInProject - Returns/sets if the environment options should be displayed in the Project Browser. 11
False False

5 SaveRevisions - Returns/sets if revisions are to be saved. 11 False False

This code finds each Option object in the Project and prints values of all options' properties:

Name - Returns/Sets the name used in code to identify an object

Value - Returns/Sets the value of an Option object

DataType - Returns the data type of the Option object

Description - Returns the description of the Option object

DefaultValue - Returns the default value of the Option object.

Through the Project Object you can access different object's options, for example, Layout options, but on the Project
level you can apply only to all Layouts.

To modify the options, you can enter the code:

MWOffice.Options(2).Value = True

or using the following:

Project.Options("EnableInterpolation").Value=True

You can change options for the whole Collection of objects (EMStructures, SystemDiagrams) and for the particular
Schematic, SystemDiagram, or EMStructure.

Option modification at the individual system diagram and EMStructure levels is available only if the UseProjectDefaults
property is set to "False". The following is an example that sets options at the SystemDiagram level:

'Code Module
Sub Main
Dim Sys As SystemDiagram
For Each Sys In Project.SystemDiagrams
Debug.Print "System Name = " & Sys.Name

API Scripting Guide 131


Developing a Script

'Set the options to use the local system diagram options.


Sys.UseProjectOptions = False
'Print the current value of the Sample Rate.
Debug.Print Sys.Options.Item("SampleRate")
'Double the sample rate.
Sys.Options.Item("SampleRate") = 2 * Sys.Options.Item("SampleRate")
'Print the updated value.
Debug.Print Sys.Options.Item("SampleRate")
Next Sys
End Sub

Three consecutive runs of this script produce the following output:

System Name = MySystem

16

System Name = MySystem

16

32

System Name = MySystem

32

64

The Sample rate gets doubled at each run.

Note that you can omit the default Item property. The following two lines are equivalent:

Debug.Print Sys.Options.Item("SampleRate")
Debug.Print Sys.Options("SampleRate")

Accessing Application Arguments

The following code shows how to access Application Arguments:

Dim arg As Argument


Dim argStr As String
For Each arg In MWOffice.Arguments
argStr = arg.Value
Debug.Print argStr
Next arg
Debug.Print "Global Arguments:"
For Each arg In Arguments
argStr = arg.Value
Debug.Print argStr
Next arg

132 NI AWR Design Environment


Developing a Script

This code generates the following output:

C:\Documents and Settings\UserName\My Documents\MWO_10\5380_1_10\MWOffice.exe


Global Arguments:
C:\Documents and Settings\UserName\My Documents\MWO_10\5380_1_10\MWOffice.exe

Accessing Application Directories

The following script shows how to access Application Directories:

' Code Module


Sub Main
Dim atr As Attribute
Dim dirName As String
Dim dirValue As String
Debug.Clear
For Each atr In MWOffice.Directories
Debug.Print atr.Name;vbTab;atr.ValueAsString
Next atr
End Sub

This script generates the following output:

AppDir C:\Documents and Settings\mariyetta\My Documents\MWO_10\5382_2_10


AppData C:\Documents and Settings\mariyetta\Local Settings\Application Data\AWR\Design Environment\
AppDataUser C:\Documents and Settings\mariyetta\Local Settings\Application Data\AWR\Design Environm
AppDataCommon C:\Documents and Settings\All Users\Application Data\AWR\Design Environment\10.0
TempFile C:\Documents and Settings\mariyetta\Local Settings\Application Data\AWR\Design Environment
AppDataLog C:\Documents and Settings\mariyetta\My Documents
AppDataLibraryCache C:\Documents and Settings\All Users\Application Data\AWR\Design Environment\10.
Examples C:\Documents and Settings\mariyetta\My Documents\MWO_10\5382_2_10\examples
Libraries C:\Documents and Settings\mariyetta\My Documents\MWO_10\5382_2_10\library
EmModels C:\Documents and Settings\mariyetta\My Documents\MWO_10\5382_2_10\em_models
Models C:\Documents and Settings\mariyetta\My Documents\MWO_10\5382_2_10\models
Cells C:\Documents and Settings\mariyetta\My Documents\MWO_10\5382_2_10\cells
Symbols C:\Documents and Settings\mariyetta\My Documents\MWO_10\5382_2_10\symbols
Signals C:\Documents and Settings\mariyetta\My Documents\MWO_10\5382_2_10\signals
Textures C:\Documents and Settings\mariyetta\My Documents\MWO_10\5382_2_10\textures
Data C:\Documents and Settings\mariyetta\My Documents\MWO_10\5382_2_10\data
HSpice C:\Documents and Settings\mariyetta\My Documents\MWO_10\5382_2_10\analog
TestResults C:\Documents and Settings\mariyetta\Local Settings\Application Data\AWR\Design Environm
EmModelsUser C:\Documents and Settings\mariyetta\Local Settings\Application Data\AWR\Design Environ
Logs C:\Documents and Settings\mariyetta\My Documents
LibraryCache C:\Documents and Settings\All Users\Application Data\AWR\Design Environment\10.0\libca
Analog C:\Documents and Settings\mariyetta\My Documents\MWO_10\5382_2_10\analog
Projects C:\aaJune
Scripts C:\Documents and Settings\mariyetta\My Documents\MWO_10\5382_2_10\scripts
ScriptsUser C:\Documents and Settings\mariyetta\Local Settings\Application Data\AWR\Design Environm
CurrentProject C:\Documents and Settings\mariyetta\My Documents\API_Tests\Application
Documents C:\Documents and Settings\mariyetta\My Documents
DesignKits C:\Documents and Settings\mariyetta\My Documents\MWO_10\5382_2_10

API Scripting Guide 133


Developing a Script

Accessing Application Files

The following script shows how to access Application Files:

' Code Module


Sub Main
Dim atr As Attribute

Debug.Clear
For Each atr In MWOffice.Files

Debug.Print atr.Name;vbTab;atr.ValueAsString
Next atr

End Sub

This script generates the following output:

Temporary C:\Documents and Settings\UserName\Local Settings\Application Data\AWR\Design Environment


CommonIni C:\Documents and Settings\All Users\Application Data\AWR\Design Environment\10.0\mwoffice
UserIni C:\Documents and Settings\UserName\Local Settings\Application Data\AWR\Design Environment\1
Customizations C:\Documents and Settings\mariyetta\Local Settings\Application Data\AWR\Design Envir
DataCache C:\Documents and Settings\All Users\Application Data\AWR\Design Environment\10.0\dedata.c
License C:\Documents and Settings\UserName\My Documents\Dist\MWO\AWRd.lic
Executable C:\Documents and Settings\UserName\My Documents\MWO_10\5382_2_10\MWOffice.exe
EMSightCache C:\Documents and Settings\All Users\Application Data\AWR\Design Environment\10.0\emsig
MWOfficeExe C:\Documents and Settings\UserName\My Documents\MWO_10\5382_2_10\mwoffice.exe
Project C:\Documents and Settings\UserName\My Documents\API_Tests\Application\api_connectivity.emp

Accessing to the fields of the Page Setup dialog.

We added a PageSetup object to the API accessible from the Application which provides access to fields such as Margins,
Orientation, PaperSize, Scaling, ScaleFactor and Detail level.

Accessing Attributes from the MWOffice Collection

The following script shows how to access Global Attributes:

' Code Module


Sub Main
Dim atr As Attribute
Debug.Clear
For i = 1 To MWOffice.Attributes.Count
Set atr = MWOffice.Attributes(i)

Debug.Print atr.Name;vbTab;atr.Value;vbTab;atr.ValueAsString;vbTab;atr.Type
Next i

End Sub

This script generates the following output:

134 NI AWR Design Environment


Developing a Script

IniFilePath C:\Documents and Settings\All Users\Application Data\AWR\Design Environment\10.0\mwoffi


EnvIniFilePath C:\Documents and Settings\UserName\Local Settings\Application Data\AWR\Design Enviro
ClientDirectory C:\Documents and Settings\All Users\Application Data\AWR\Design Environment\10.0 C:
BuildNumber 5380 5380 3
AppVersion 10.00b full build 5380 Rev1 (67860) 10.00b full build 5380 Rev1 (67860) 6
AppVersionShort 10.00 10.00 6
AppStreamVersion 1000 1000 3
AppName AWR Design Environment AWR Design Environment 6
AppNameDetailed AWR Design Environment 10 Internal (ANO-229, VSS-350) SN:2 AWR Design Environment 1
FoundaryProcName Generic_GenBic35 Generic_GenBic35 6
TestMode False 0 0
RegressionCaptureMode False 0 0

Accessing Application Properties from the MWOffice Collection

The following script shows how to access Application Properties:

' Code Module


Sub Main
Dim appPath As String
appPath = Application.Path
Debug.Clear
Debug.Print Application.Path
Debug.Print Application.AppName;vbTab;Application.Caption
Debug.Print Application.Version;vbTab;Application.ExeName
Debug.Print Application.TypeLibVersion
Dim ret As VbFileAttribute
ret = GetAttr(appPath) And vbDirectory
Debug.Print ret

End Sub

This script generates the following output:

C:\Documents and Settings\UserName\My Documents\MWO_10\5382_2_10\


AWR Design Environment tt11346_Symmetry_example.emp - AWR Design Environment (10.00.5382) [Generic_
10 MWOffice.exe
10
16

Accessing Application LayoutCells Collection

The following script shows how to access the Application LayoutCells collection:

' Code Module


Sub Main
Dim cels As LayoutCells
Dim label As String
Dim cel As LayoutCell
Dim cel2 As LayoutCell

API Scripting Guide 135


Developing a Script

Debug.Clear
Set cels = MWOffice.LayoutCells

For i = 1 To MWOffice.LayoutCells.Count
Set cel = MWOffice.LayoutCells.Item(i)
Set cel2 = MWOffice.LayoutCells.Item(cel.Name)
Debug.Print cel.Name;vbTab;cel.ModuleName;vbTab;cel.Description;vbTab;cel.NumberNodes;vbTab;cel.P
Debug.Print cel2.Name;vbTab;cel2.ModuleName;vbTab;cel2.Description;vbTab;cel2.NumberNodes;vbTab;c
Next i
End Sub

This script generates the following output (fragment):

AIRIND* Cel_defs.dll Flat Wire Circular Spiral 2 1


AIRIND* Cel_defs.dll Flat Wire Circular Spiral 2 1
AWR_MESFET_FET* Cel_defs.dll AWR_MMIC FET Cell 3 0
AWR_MESFET_FET* Cel_defs.dll AWR_MMIC FET Cell 3 0
AWR_MMIC_VIA2* Cel_defs.dll AWR_MMIC_VIA2 2 0
AWR_MMIC_VIA2* Cel_defs.dll AWR_MMIC_VIA2 2 0
AWR_PCB_INET_VIA* Cel_defs.dll AWR_PCB_INET_VIA 2 0
AWR_PCB_INET_VIA* Cel_defs.dll AWR_PCB_INET_VIA 2 0
AWR_PCB_VIA* Cel_defs.dll PCB Via Cell 2 0
AWR_PCB_VIA* Cel_defs.dll PCB Via Cell 2 0
AWR_RFIC_VIA* Cel_defs.dll AWR_RFIC_VIA 2 0
AWR_RFIC_VIA* Cel_defs.dll AWR_RFIC_VIA 2 0
BCLIN* Cel_defs.dll BroadSide Coupled Lines with Offset cell 4 0
BCLIN* Cel_defs.dll BroadSide Coupled Lines with Offset cell 4 0
BCLIN2* Cel_defs.dll BroadSide Coupled Lines with Offset cell improved 4 0
BCLIN2* Cel_defs.dll BroadSide Coupled Lines with Offset cell improved 4 0

Accessing MWOffice CellMapping

The following script shows how to access MWOffice CellMapping:

' Code Module


Sub Main
Dim cellMaps As CellMappings
Dim label As String
Dim cellMap As CellMapping
Dim mapName As String
Dim cellName As String

Debug.Clear
Set cellMaps = MWOffice.CellMappings

For Each cellMap In cellMaps


mapName = cellMap.ElementName
cellName = cellMap.CellName

Debug.Print cellName;vbTab;mapName
Next cellMap

136 NI AWR Design Environment


Developing a Script

End Sub

This script generates the following output (fragment):

AIRIND* AIRIND
BGA* BGA
BORDCAP* BORDCAP
BWIRES2* BWIRES
BWIRES_ML* BWIRES2
CPWTRACE* CPTRACE
CPWLIN* CPW1LINE
CPW2LINA* CPW2LINA
CPW2LINE* CPW2LINE
CPW3LINA* CPW3LINA
CPWABRG* CPWABRGX
CPWALINE* CPWALINE
CPWBEND* CPWBENDX
CPWEG* CPWEG
CPWGAP* CPWGAP
CPWLIN* CPWLINE
CPWLIN* CPWLINX
CPWOC* CPWOC
CPWCS* CPWSC
CPWTAPER* CPWTAPER
CPWTEE* CPWTEEX
DICAP* DICAP
SHORT* DPWRSMP
MTRACENET* ELENET
ENCLOSURE* ENCLOSURE
RECT_PIN* EXP_PIN
MLIN* FM1LIN
CLIN_ASYM_2* FM2CLIN
FMCIND* FMCIND

Accessing a PageSetup object of the application

With PageSetup object we have access to all the fields in the Page Setup dialog such as Margins, Orientation, PaperSize,
Scaling, ScaleFactor and Detail level.

The following shows an example of accessing the fields in the PageSetup object, setting them to new values and printing
a page with the new values. In the example we change the default Landscape to Portrait, change the right and left margins
from 0.5 inches to 2.0 inches:

' Code Module


Sub Main
Debug.Clear
PrintPageSetup

' Change the setup to Portrait with larger margins


MWOffice.PageSetup.LeftMargin = 2.0
MWOffice.PageSetup.RightMargin = 2.0
MWOffice.PageSetup.Orientation = mwPSO_Portrait
MWOffice.PageSetup.PaperSize = mwPPS_Letter

API Scripting Guide 137


Developing a Script

PrintPageSetup

' Uncomment to print an example page.


Project.Schematics("Schematic 1").PrintOut

End Sub

Sub PrintPageSetup
Debug.Print "Left Margin = " & MWOffice.PageSetup.LeftMargin
Debug.Print "Right Margin = " & MWOffice.PageSetup.RightMargin
Debug.Print "Top Margin = " & MWOffice.PageSetup.TopMargin
Debug.Print "Bottom Margin = " & MWOffice.PageSetup.BottomMargin
Debug.Print "Orientation = " & MWOffice.PageSetup.Orientation
Debug.Print "Scale Output = " & MWOffice.PageSetup.ScaleOutput
Debug.Print "Scale Factor = " & MWOffice.PageSetup.ScaleFactor
Debug.Print "Detail Level = " & MWOffice.PageSetup.DetailLevel
Debug.Print "Paper Size = " & MWOffice.PageSetup.PaperSize
Debug.Print "Paper Source = " & MWOffice.PageSetup.PaperSource
Debug.Print ""
End Sub

The output looks like:

Left Margin = 0.5


Right Margin = 0.5
Top Margin = 0.5
Bottom Margin = 0.5
Orientation = 1
Scale Output = False
Scale Factor = 1
Detail Level = 0
Paper Size = 0
Paper Source = 12

Left Margin = 2
Right Margin = 2
Top Margin = 0.5
Bottom Margin = 0.5
Orientation = 0
Scale Output = False
Scale Factor = 1
Detail Level = 0
Paper Size = 0
Paper Source = 12

This method we can use for printing Schematic, SystemDiagrams and EMStructures.The method PrintOut() doesn't take
any arguments and likely prints the 2D view of the EMStructure. PrintOutEx(), takes an argument o f type
mwDesignViewType which has options for mwDVT_DesignView2D and mwDVT_DesignView3D. So we recommend
to use PrintOutEx to print either the 2D view or the 3D view of the EM structure document.

New Project Pane: Enumerate User Folders

The following script shows how to enumerate User Folders in a new Project pane:

138 NI AWR Design Environment


Developing a Script

' Code Module


Sub Main
Debug.Clear
EnumProjectItems1 MWOffice.Project.UserFolders
Debug.Clear
EnumProjectItems2 MWOffice.Project.UserFolders
Debug.Clear
EnumFolderSchematics1 MWOffice.Project.UserFolders
Debug.Clear
EnumFolderSchematics2 MWOffice.Project.UserFolders
Debug.Clear
DumpUserFolder MWOffice.Project.UserFolders, " "
End Sub

' Enum the project items in a folder


Sub EnumProjectItems1(obFolder As MWOffice.UserFolder)
Dim obProjectItem As MWOffice.ProjectItem
For Each obProjectItem In obFolder.ProjectItems
Debug.Print obProjectItem.Type
Debug.Print obProjectItem.Name
Next obProjectItem
End Sub
' Enum the project items in a folder as an object, this allows calling
' a method common to all project items in the folder
Sub EnumProjectItems2(obFolder As MWOffice.UserFolder)
Dim obObject As Object
For Each obObject In obFolder.ProjectItems
Debug.Print obObject.Name
obObject.NewWindow
Dim obProjectItem As MWOffice.ProjectItem
Set obProjectItem = obObject
Debug.Print obProjectItem.Type
Next obObject
End Sub
' Executes a method on all the schematics in a folder by checking the project item type
Sub EnumFolderSchematics1(obFolder As MWOffice.UserFolder)
Dim obProjectItem As MWOffice.ProjectItem
For Each obProjectItem In obFolder.ProjectItems
If obProjectItem.Type = MWOffice.mwPIT_Schematic Then
Dim obSchematic As MWOffice.Schematic
Set obSchematic = obProjectItem
Debug.Print obSchematic.Name
obSchematic.NewWindow
End If
Next obProjectItem
End Sub
' Executes a method on all the schematics in a folder by casting project item to schematic
' and checking for error.
Sub EnumFolderSchematics2(obFolder As MWOffice.UserFolder)
On Error Resume Next
Dim obSchematic As MWOffice.Schematic
For Each obSchematic In obFolder.ProjectItems
If Not obSchematic Is Nothing Then
Debug.Print obSchematic.Name
obSchematic.NewWindow
End If

API Scripting Guide 139


Developing a Script

Set obSchematic = Nothing


Next obSchematic
End Sub

' Print the items in the given folder to the output window
Sub DumpUserFolder(obParentFolder As MWOffice.UserFolder, ByVal Tabs As String)
' Display the Name
Debug.Print Tabs & obParentFolder.Name
Tabs = Tabs + " ";
' Display the ChildFolders
Dim obUserFolder As MWOffice.UserFolder
For Each obUserFolder In obParentFolder.Folders
DumpUserFolder obUserFolder, Tabs
Next obUserFolder
' Display the ProjectItems
Dim obProjectItem As MWOffice.ProjectItem
For Each obProjectItem In obParentFolder.ProjectItems
DumpProjectItem obProjectItem, Tabs
Next obProjectItem
End Sub
' Dump a project item to the output window
Sub DumpProjectItem(obProjectItem As MWOffice.ProjectItem, Tabs As String)
' Display the Name
Debug.Print Tabs & obProjectItem.Name
End Sub

The ProjectItem method is another example of accessing the User Folder Project item type from the API. It returns the
actual object, in this case a Schematic or Graph, and any methods of those objects can be called directly. To call methods
of the secondary ProjectItem interface you must first assign the Schematic or Graph to a ProjectItem so VB knows to
use the alternate interface.

' Code Module


Sub Main
Debug.Clear
For i = 1 To Project.UserFolders.Folders.Count
Debug.Print Project.UserFolders.Folders(i).Name
For j = 1 To Project.UserFolders.Folders(i).ProjectItems.Count
Dim obProjectItem As MWOffice.ProjectItem
Set obProjectItem = Project.UserFolders.Folders(i).ProjectItems(j)
Debug.Print vbTab & obProjectItem.Name
Debug.Print vbTab & obProjectItem.Type
Next j
Next i
End Sub

The following code creates a number of User folders on a couple levels and then places items from the object into the
folders at various levels. The resulting structure is then traversed and output to verify the structure is created correctly.

' Code Module


Sub Main
Dim folder As UserFolder
Dim subFolder As UserFolder

' Get a count before we start

140 NI AWR Design Environment


Developing a Script

Debug.Print "User Folders Count Before = " & Project.UserFolders.Folders.Count

' Build the project folder structure.


BuildFolderStructure

' Get a count of the project folders after


Debug.Print "User Folders Count After = " & Project.UserFolders.Folders.Count

' Output the details of the project folder structure.


For Each folder In Project.UserFolders.Folders
PrintFolder folder, " "
Next folder

End Sub

Sub BuildFolderStructure
Set folder = Project.UserFolders.Folders.Add("Folder1")
folder.ProjectItems.Add(Project.Schematics("Schematic 1"))

Set folder = Project.UserFolders.Folders.Add("Folder2")


Set subFolder = folder.Folders.Add("SubFolder1")
subFolder.ProjectItems.Add(Project.Schematics("Schematic 2"))
subFolder.ProjectItems.Add(Project.Schematics("Schematic 3"))

Set subFolder = folder.Folders.Add("SubFolder2")


subFolder.ProjectItems.Add(Project.SystemDiagrams("System Diagram 1"))
subFolder.ProjectItems.Add(Project.SystemDiagrams("System Diagram 2"))

Set subFolder = folder.Folders.Add("SubFolder3")


subFolder.ProjectItems.Add(Project.EMStructures("EM Structure 1"))
subFolder.ProjectItems.Add(Project.EMStructures("EM Structure 2"))

Set folder = Project.UserFolders.Folders.Add("Folder3")


folder.ProjectItems.Add(Project.SystemDiagrams("System Diagram 1"))

End Sub

Sub PrintFolder(ByRef folder As UserFolder, spacing As String)


Dim subFolder As UserFolder
Dim projItem As ProjectItem

Debug.Print spacing & "Name = " & folder.Name


If folder.Parent Is Nothing Then
Debug.Print spacing & "Parent = None"
Else
Debug.Print spacing & "Parent = " & folder.Parent.Name
End If

Debug.Print spacing & "ProjectItems = " & folder.ProjectItems.Count


For Each projItem In folder.ProjectItems
PrintProjectItem projItem, spacing & " "
Next projItem

Debug.Print spacing & "SubFolders = " & folder.Folders.Count


For Each subFolder In folder.Folders

API Scripting Guide 141


Developing a Script

PrintFolder subFolder, spacing & " "


Next subFolder

End Sub

Sub PrintProjectItem(ByRef projItem As ProjectItem, spacing As String)


Debug.Print spacing & "Item Name = " & projItem.Name
Debug.Print spacing & "Item Type = " & projItem.Type
End Sub

New Project Pane: Add Project Item To Folder

The following script shows how to add a Project item to a folder in a new Project pane. The script assumes you have the
Project items it is adding. You can update the script to Remove everything from the Project, then add a "Schematic 1",
"System Diagram 1" and so on, to successfully add the items.

' Code Module


Sub Main
Debug.Clear
MWOffice.Project.UserFolders.Folders.RemoveAll
MWOffice.Project.UserFolders.ProjectItems.RemoveAll
AddItemsToFolder MWOffice.Project.UserFolders
EnumNodes MWOffice.Project.UserFolders.TreeNode.Children, " "
End Sub
Sub AddItemsToFolder(obUserFolder As MWOffice.UserFolder)
obUserFolder.Folders.RemoveAll
obUserFolder.ProjectItems.RemoveAll
' Add a child folder to add the items to
Dim obChildFolder As MWOffice.UserFolder
Set obChildFolder = obUserFolder.Folders.Add("test")
' Add a sub folder
obChildFolder.Folders.Add "Child1"
' Note the Project needs to have these items in it or the Add will fail
' Add the project items
obChildFolder.ProjectItems.Add Project.Schematics("Schematic 1")
obChildFolder.ProjectItems.Add Project.SystemDiagrams("System Diagram 1")
obChildFolder.ProjectItems.Add Project.EMStructures("EM Structure 1")
obChildFolder.ProjectItems.Add Project.Netlists("Netlist 1")
obChildFolder.ProjectItems.Add Project.DataFiles("Data File 1")
obChildFolder.ProjectItems.Add Project.Graphs("Graph 1")
obChildFolder.ProjectItems.Add Project.Annotations(1)
' obChildFolder.ProjectItems.Add Project.Graphs(1).Measurements(1)
obChildFolder.ProjectItems.Add Project.OptGoals(1)
obChildFolder.ProjectItems.Add Project.YieldGoals(1)
obChildFolder.ProjectItems.Add Project.OutputFiles(1)
obChildFolder.ProjectItems.Add Project.Wizards("AWR Load Pull Wizard")
' obChildFolder.ProjectItems.Add Project.Wizards("AWR Load Pull Wizard").WizardInstances(1)
obChildFolder.ProjectItems.Add Project.DesignNotes(1)
obChildFolder.ProjectItems.Add Project.GlobalEquations
obChildFolder.ProjectItems.Add Project.OutputEquations
' Select the Schematic added to the folder
Dim obProjectItem As MWOffice.ProjectItem
Set obProjectItem = obChildFolder.ProjectItems.Item("Schematic 1")
Debug.Print obProjectItem.Name
Debug.Print obProjectItem.TreeNode.Text

142 NI AWR Design Environment


Developing a Script

obProjectItem.TreeNode.Select
' Expand the Schematic node
Dim obTreeNode As MWOffice.TreeNode
Set obTreeNode = obProjectItem.TreeNode
obTreeNode.Expand True
End Sub
Sub EnumNodes(Nodes As MWOffice.TreeNodes, Indent As String)
Dim Node As MWOffice.TreeNode
For Each Node In Nodes
If Node.Visible Then
' Debug.Print Indent & Node.Name
Debug.Print Indent & Node.Text
End If
EnumNodes Node.Children, Indent + " "
Next Node
End Sub

Accessing the User Folder Project Item Type

The following script is incorrect. It tries to loop through a Project folder and print the item type in the folder.

' Code Module


Sub Main
Debug.Clear
For i = 1 To Project.UserFolders.Folders.Count
For j = 1 To Project.UserFolders.Folders(i).ProjectItems.Count
Debug.Print vbTab & Project.UserFolders.Folders(i).ProjectItems(j).Name
Debug.Print vbTab & Project.UserFolders.Folders(i).ProjectItems(j).Type
Next j
Next i
End Sub

The ProjectItem method returns the actual object, in this case a Schematic or Graph, and you can directly call any methods
of those objects. The problem in the code is that it attempts to call methods of the secondary ProjectItem interface. To
call methods of this interface you must first assign the Schematic or Graph to a ProjectItem so VB knows to use the
alternate interface. The following script is correct:

' Code Module


Sub Main
Debug.Clear
For i = 1 To Project.UserFolders.Folders.Count
Debug.Print Project.UserFolders.Folders(i).Name
For j = 1 To Project.UserFolders.Folders(i).ProjectItems.Count
Dim obProjectItem As MWOffice.ProjectItem
Set obProjectItem = Project.UserFolders.Folders(i).ProjectItems(j)
Debug.Print vbTab & obProjectItem.Name
Debug.Print vbTab & obProjectItem.Type
Next j
Next i
End Sub

This script generates the following output:

API Scripting Guide 143


Developing a Script

template
linear
0
nonlinear_one_tone
0
nonlinear_two_tone
0
power sweep
5
s11 and s22
5
s21 and S12
5
two tone spectrum
5

New Project Pane: Enumerate Project Browser

The following script shows how to enumerate the Project Browser.

' Code Module


Sub Main
Debug.Clear
' EnumNodes MWOffice.Project.TreeView.Nodes, " "
Dim obBranch As MWOffice.TreeNode
Set obBranch = MWOffice.Project.TreeView.Nodes(1)
Debug.Print obBranch.Text
EnumNodes obBranch.Children, " "
Set obBranch = MWOffice.Project.TreeView.Nodes(2)
Debug.Print vbCrLf & obBranch.Text
EnumNodes obBranch.Children, " "
End Sub
Sub EnumNodes(Nodes As MWOffice.TreeNodes, Indent As String)
Dim Node As MWOffice.TreeNode
For Each Node In Nodes
If Node.Visible Then
' Debug.Print Indent & Node.Name
Debug.Print Indent & Node.Text
End If
EnumNodes Node.Children, Indent + " "
Next Node
End Sub

Determining if a Document is Embedded or Linked

The following script shows some Embedded and FilePath properties for System Diagrams, Schematics, and EMStructures
so you can determine which documents are embedded and which are linked. FilePath provides a path to the linked files.

' Code Module


Sub Main
Dim sys As SystemDiagram
Dim schem As Schematic

144 NI AWR Design Environment


Developing a Script

Dim Em As EMStructure

Debug.Clear
Debug.Print "Systems:"
For Each sys In Project.SystemDiagrams
Debug.Print sys.Embedded & ", " & sys.Name & ", " & sys.FilePath
Next sys
Debug.Print

Debug.Print "Schematics:"
For Each schem In Project.Schematics
Debug.Print schem.Embedded & ", " & schem.Name & ", " & schem.FilePath
Next schem
Debug.Print

Debug.Print "EMStructures:"
For Each Em In Project.EMStructures
Debug.Print Em.Embedded & ", " & Em.Name & ", " & Em.FilePath
Next Em

End Sub

Running the script shows that three of the items are embedded and three are linked in the Project. For the linked items,
the FilePath is also printed. This script generates the following output:

Systems:
False, External System Diagram 1, C:\Documents and Settings\mariyetta\My Documents\API_Tests\Embedd
True, System Diagram 1,

Schematics:
False, External Schematic 1, C:\Documents and Settings\mariyetta\My Documents\API_Tests\Embedded_Li
True, Schematic 1,

EMStructures:
True, EM Structure 1,
False, External EM Structure 1, C:\Documents and Settings\mariyetta\My Documents\API_Tests\Embedded

Providing access to collection of installed PDKs :

We can access to collection of installed PDKs (the list under File > New With Library...). The new collection is available
from: MWOffice.AvailableProcessLibraries. The script shown further is accessing to the process libraries available on
the system based on the ProcessLibraryManager which is the same place libraries are accessed for New With Library
menu item:

' Code Module


Sub Main
Dim procInfo As ProcessLibraryInfo

Debug.Clear
Debug.Print "Library Count = " & MWOffice.AvailableProcessLibraries.Count

For Each procInfo In MWOffice.AvailableProcessLibraries


Debug.Print procInfo.Name & ", " & procInfo.Version & ", " & procInfo.Description

API Scripting Guide 145


Developing a Script

Next procInfo
End Sub

Providing a Message to the Status Window:

To display a message in the Status Window you need to associate the message with one of the following groups:

Ungrouped
Addin Manager
Application
Open Access Runtime
Netlist import

' Code Module


Sub Main
Dim grp As StatusGroup
Set grp = MWOffice.Status.Groups("Open Access Runtime")
grp.Items.Add(mwRIC_Info, "Test Script Message")
End Sub

The default is the "Ungrouped" group, so to add a message to the top level use just ":"

' Code Module


Sub Main
MWOffice.Status.Items.Add(mwRIC_Error, "Text Message")
End Sub

The following is another example of adding an error message to the Status Window:

Dim StatusGroup As MWOffice.StatusGroup


Dim StatusItem As MWOffice.StatusItem

Set StatusGroup = MWOffice.Status.Groups.Add("MyGroup", MWOffice.Project)


Set StatusItem = StatusGroup.Items.Add(mwRIC_Error, "This is a test http://www.ni.com/awr error
Set StatusItem = StatusGroup.Items.Add(mwRIC_Error, "A file link file://""r:\my documents\source

API supports opening and closing the status result window on the AWR mainframe window. API also is able to control
the state of the status window with a StatusWindow object associated with the Application.Status object which includes
a visible property that can be used to control the visible state of the Status Results window of the application.

The following is an example of using the mwoffice.status.search() method to look for errors. This method includes the
group name as part of what is searched, so, if the user includes a group name or a portion of the group name the items
in that group will be output:

' Code Module


Sub Main
Dim s As Schematic
Dim sis As StatusItems
Debug.Clear

146 NI AWR Design Environment


Developing a Script

Set s = Project.Schematics(1)
Set sis = MWOffice.Status.Search(s.Name,mwRIC_Error)
Debug.Print "Number of sim errors found by search: " & sis.Count

End Sub

Working with Data Files

The NI AWR SDE allows a number of methods of working with DataFile Collections of objects. You can open a new
DataFile, Import, Export, and LinkTo DataFile Collections of objects.

In the NI AWR SDE you can import data files via the API. Each data file that you import displays as a subnode of Data
Files in the Project Browser. The type of imported data file in the NI AWR SDE API is defined by constants as follows:

mwDFT_SNP - S-parameter files; Value = 0.


mwDFT_RAW - Raw data file format; Value = 1.
mwDFT_IV - DC-IV data file format (*.ivd); Value = 2.
mwDFT_TXT - text data file format (*.txt, *.csv, *.lp*, *.sp*); Value = 3.
mwDFT_MDIF - MDIF format data file (*.mdf); Value = 4.

To add a data file to a Project, use the following code:

Dim dt As DataFile
Set dt = Project.DataFiles.Add("SGA-3586","C:\MyScripts\Test_Data\SGA-3586.s2p",True,mwDFT_SNP)

This code adds the "SGA-3586" data file in the Project Browser as a subnode of the Data Files node.

Set dt = Project.DataFiles.Add("forward","forward.ivd",True, mwDFT_IV)

This code adds the "forward" IV data file as a subnode of the Data Files node. Note that you need to specify the file path.
If your file is in the Project or Program directory you can use the following code:

MWOffice.Path
Project.Path

To import a data file into a Project, use the following code. Note that the script uses FileSystemObject for importing
files from the Scripting folder. When using FileSystemObject, do not forget to reference the Scripting Runtime library.

Dim fld As Scripting.Folder


Dim fso As Scripting.FileSystemObject
Dim fil As Scripting.File
Dim fString As String
Dim selPath As String

Set fso = New Scripting.FileSystemObject


fString = "{"

selPath = GetFilePath("*.S2P", "*.S2P")


selPath = Left(selPath, InStrRev(selPath, "\") - 1)

For Each fil In fso.GetFolder(selPath).Files

API Scripting Guide 147


Developing a Script

If Right(fil.Name, 3) = "S2P" Then


Project.DataFiles.Import(fil.Name, selPath & "\" & fil.Name, mwDFT_SNP)
fString = fString + Chr$(34) + fil.Name + Chr$(34) + ","
End If
Next fil

fString = Left(fString, InStrRev(fString, ",") -1)


Project.GlobalEquations.Add("Caps = " + fString+ "}",0,-100)

After adding DataFile to the NI AWRDE you can write code and use all methods and properties that the API exposes to
perform the following operations:

Delete a DataFile from the Project using the Remove method

To delete the "Schem1" DataFile enter:

Project.DataFiles.Remove(Index)

where Index is the number of the DataFile or

Project.DataFiles.Remove("Name")

where Name is the Name of the DataFile.

Delete All Data Files:

The following code does not work. Assume that there are four data files in the Project that you want to remove. After
the code deletes two files, only two files remain. As the loop iterates, the next time it tries to delete a file, it tries to
delete the third file, which now does not exist, so an error is generated.

For i = 1 To Project.DataFiles.Count
Project.DataFiles.Remove(i)
Next i

The following code does work:

For i = Project.DataFiles.Count to 1 Step -1


Project.DataFiles.Remove(i)
Next i

Rename a DataFile in the Project using the Name property as follows:

Set dt = Project.DataFiles(1)
dt.Name = "MyName"

148 NI AWR Design Environment


Developing a Script

Set the read-only state of a data file through the ReadOnly property of the DataFile object.property as follows:

Project.DataFiles("MyName").ReadOnly = True

Enter the information into a new DataFile or change the content of the DataFile:

Project.DataFiles(1).DataAsText ="6100000000 -8.60 140.00 10.93 -18.21 -14.00 7.00 -8.51 108.90"

View the content of the DataFile using the PrintOut method or print DataFile to the Immediate Window using the
Debug.Print method:

Debug.Print Project.DataFiles(1).DataAsText

The DataFile object method called DataAsText is a read-write method. With this method you could do something like:

Dim d1,d2 as DataFile


Dim content as String

Set d1 = Project.DataFiles(1);
content = d1.DataAsText

The method also supports write so you could add a content from one DataFile to another:

d2.DataAsText = content

Access Datafile options. The API contains the Options collection of the DataFiles collection that provides access to
the options displayed on the Raw Data Format and MDIF Files tabs of the Data File Options dialog box. The API has an
object, associated with the Data Files node in the Project. That object has an Options property associated with the
DataFiles collection and allows getting and setting options for raw data files and MDIF variable sorting order.

' Code Module


Sub Main

Project.DataFiles.Options(1)=0
Project.DataFiles.Options(2)=1
Project.DataFiles.Options(3) = 19
Project.DataFiles.Options(4) = 9
Project.DataFiles.Options(5) = 4
Project.DataFiles.Options(6) = 50
Project.DataFiles.Options(7)=True
Project.DataFiles.Options(8) = False
Project.DataFiles.Options(9) = False
fn = Project.Path & "tt14344_4port.prn"
Project.DataFiles.Import("test",fn,mwDFT_RAW)
End Sub

API Scripting Guide 149


Developing a Script

The following script prints DataFiles Options:

' Code Module


Sub Main
Dim opt As Option

Debug.Clear
For Each opt In Project.DataFiles.Options
Debug.Print opt.Name & " = " & opt.Value & ", " & opt.Description
Next opt
End Sub

This script generates the following output before settings:

DataFileType = 1, Raw data format default type.


DataFileFormat = 0, Raw data format default format.
DataFileAngleUnitMult = 19, Raw data format default angle unit multiplier type. These values can
DataFileFreqUnitMult = 6, Raw data format default frequency unit multiplier type. These values ca
DataFileMatrixSize = 1, Raw data format default matrix size.
DataFileRefImpedance = 1, Raw data format default reference impedance.
DataFileOrderRowMajor = False, Raw data format default order to row major.
DataFileMatrixFormat = False, Raw data format default matrix size to one per line.
DataFileIsDb = False, Raw data format default values are in Db.
DataFileVariableSortOrder = 0, MDIF File default variable sort order.

This script generates the following output after settings:

DataFileType = 0, Raw data format default type.


DataFileFormat = 1, Raw data format default format.
DataFileAngleUnitMult = 19, Raw data format default angle unit multiplier type. These values can
DataFileFreqUnitMult = 9, Raw data format default frequency unit multiplier type. These values ca
DataFileMatrixSize = 4, Raw data format default matrix size.
DataFileRefImpedance = 50, Raw data format default reference impedance.
DataFileOrderRowMajor = True, Raw data format default order to row major.
DataFileMatrixFormat = False, Raw data format default matrix size to one per line.
DataFileIsDb = False, Raw data format default values are in Db.
DataFileVariableSortOrder = 0, MDIF File default variable sort order.

The following code displays in the Debug window the type of each data file loaded in the program:

'This helps distinguish touchstone, from raw data, from regular text files.
Dim dat As DataFile
Sub Main
Debug.Clear
Debug.Print "filename";vbTab;"data type"
'Debug.Print ""
For Each dat In Project.DataFiles
Select Case dat.Type
Case 0

150 NI AWR Design Environment


Developing a Script

Debug.Print dat.Name;vbTab; " Touchstone"


Case 1
Debug.Print dat.Name;vbTab; " Raw Data"
Case 2
Debug.Print dat.Name;vbTab; " IV Data"
Case 3
Debug.Print dat.Name;vbTab; " Text File"
End Select
Next dat

Add a DataFile to a Graph:

Dim i As Integer
Dim grafName As String
grafName="ModelError"
Project.Graphs.Add(grafName,mwGT_Rectangular)
Project.Graphs.Item(grafName).Legend.Visible=False
For i=1 To Project.DataFiles.Count
Project.Graphs.Item(grafName).Measurements.Add (Project.DataFiles.Item(i).Name,"DB(SModel
'Project.Graphs.Item(grafName).Measurements.Add (Project.DataFiles.Item(i).Name,"K")
'Project.Graphs.Item(grafName).Measurements.Add (Project.DataFiles.Item(i).Name,"S[2,2]")
'Project.Graphs.Item(grafName).Measurements.Add (Project.DataFiles.Item(i).Name,"S[1,1]")
'Project.Graphs.Item(grafName).Measurements.Add (Project.DataFiles.Item(i).Name,"S[1,2]")
Next i

The API also exposes the following methods to add data files to the Elements collection:

* Add DataFile

The following code adds DataFile to the Schematic("MySchematic").Elements, and the "Schem1.s2p" subnode displays
under the Schematic("MySchematic") node:

'Add Data File Element


'Demonstrates how to add a data file element to the schematic using the API 'method
'Schematic.Elements.AddDataFile().
Dim schem As Schematic
Dim elem As Element
Dim dataPath As String
'Get a reference to the schematic
Set schem = Project.Schematics("MySchematic")
'Add a data file element to the schematic
'(This will cause the data file to also be added to our project data files).
dataPath = "C:\MyScripts\Test_Data\SGA-3586.s2p"
schem.Elements.AddDataFile(dataPath, 0, 0)

* AddModuleFile - adds a nonlinear model from the nonlinear library

The following script adds a model file Element to "MySchematic":

Sub Main
'Add Model File Element
'This script demonstrates how to add a model file element using the API 'method
'Schematic.Elements.AddModelFile().

API Scripting Guide 151


Developing a Script

Dim schem As Schematic


Dim elem As Element
Dim mdlPath As String
'Get a reference to the schematic
Set schem = Project.Schematics("MySchematic")
'Place a non-linear GBJT model element.
mdlPath = "C:\MWO_1835\Library\Models\Nonlinear\GettingStarted\GBJT\BLT11_chip.mdl"
schem.Elements.AddModelFile(mdlPath, 0, 0)
End Sub

* AddSubcircuits - adds a subcircuit

The following code adds a subcircuit to a Schematic:

Dim schem As Schematic


Set schem = Project.Schematics("MySchematic")
schem.Elements.AddSubcircuit("MySubcircuit", 0, 0)

The following code also adds a Subcircuit to a Schematic Subcircuits collection (both methods are identical).

project.Schematics(2).Subcircuits.Add("A",0,0)

Note that "MySchematic" Schematic and "MySubcircuit" subcircuit must already exist, as in the following code:

Dim sch As Schematic


Project.Schematics.Add("MySchematic")
Set sch = Project.Schematics.Add("MySubcircuit")
sch.Elements.Add("Port",0,0)
Set sch = Project.Schematics("MySchematic ")
Dim e As Element
Set e = sch.Elements.AddSubcircuit("MySubcircuit ",1000,0,0,False,"",mwSG_Normal)

In this example, mwSG_Normal is a MWOffice.mwSubcktGroundType.

* AddXMLComponent - adds a component from the XML library.

The following script adds two XML file components to a Schematic:

'Code Module
Sub Main
'Add XML Component
'Demonstrates adding two XML file components to a schematic using the ' API method Schematic.Eleme
Dim schem As Schematic
Dim elem As Element
Dim xPath As String
'Get a reference to the schematic
Set schem = Project.Schematics("MySchematic")
'Place an initial resister XML componentschem.Elements.AddXMLComponent ("$LIB_DIR\Motorola\METLDMO
End Sub

152 NI AWR Design Environment


Developing a Script

You must explicitly write the x and y coordinates on the code if you add DataFile to a Schematic. These coordinates
show the NI AWR SDE where to put the model, subcircuit, and XMLComponent on the schematic.

You can explore the hierarchy of libraries using the following code:

Debug.Print MWOffice.Application.Libraries("Circuit Elements").Libraries("XML Libraries").Name


Debug.Print MWOffice.Application.Libraries("Circuit Elements").Libraries("XML Libraries")
.Libraries(1).Name
Debug.Print MWOffice.Application.Libraries("Circuit Elements").Libraries("XML Libraries")
.Libraries(1).Libraries(2).Name
Debug.Print MWOffice.Application.Libraries("Circuit Elements").Libraries("XML Libraries")
.Libraries(1).Libraries(2).Libraries(4).Name
Debug.Print MWOffice.Application.Libraries("Circuit Elements").Libraries("XML Libraries")
.Libraries(1).Libraries(2).Libraries(4).Libraries(1).Name
Debug.Print MWOffice.Application.Libraries("Circuit Elements").Libraries("XML Libraries")
.Libraries(1).Libraries(2).Libraries(4).Libraries(1).Libraries(3).Name

To code test libraries, use the following script:

'Code Module
'Globals
Dim x As Double, y As Double
'Main routine
Sub Main
Dim objLibs As Libraries
Dim objLib As Library
Dim schem As Schematic
Dim Message As String
On Error Resume Next
x = 0
y = 0
Debug.Clear
Set schem = Project.Schematics("MySchematic")
'Set objLibs = MWOffice.Application.Libraries("Circuit Elements").Libraries("XML Libraries").
Libraries("Johanson Technology").Libraries
Set objLibs = MWOffice.Application.Libraries("Circuit Elements").Libraries("XML Libraries").
Libraries(1).Libraries(2).Libraries(4).Libraries(1).Libraries
For Each objLib In objLibs
ProcessLibrary objLib, schem
Next objLib
End Sub
Sub ProcessLibrary (ByRef objLib As Library, ByRef schem As Schematic)
Dim objLibrary As Library
Dim objElem As LibraryElement
For Each objElem In objLib.LibraryElements
Debug.Print objElem.Name
schem.Elements.AddLibraryElement(objElem.BrowserPath, x, y)
x = x + 1000
If (x > 50000) Then
x = 0
y = y + 1000
End If
' Debug.Print schem.Elements(1).Name
schem.Elements.Remove(1)
Next objElem

API Scripting Guide 153


Developing a Script

'Recurse down into the children


For Each objLibrary In objLib.Libraries
ProcessLibrary objLibrary, schem
Next objLibrary
End Sub

To print library parts, use the following script:

' Code Module


Sub Main
Debug.Clear
Call Print_Library(MWOffice.Libraries("XML Libraries").Libraries("*TSMC CR018").Libraries, 0)
End Sub
Function Print_Library(ByRef objLibs As Libraries, depth As Integer)
Dim objLib As Library
Dim libElem As LibraryElement
Dim libEleName As String
For Each objLib In objLibs
Debug.Print String(depth, vbTab) & Replace(objLib.Name, " ", "_");
depth = depth + 1
For Each libElem In objLib.LibraryElements
Debug.Print String(depth, vbTab) & libElem.Name
Next libElem
' Next if there is a sub library process it.
If (objLib.Libraries.Count > 0) Then
Call Print_Library (objLib.Libraries, depth)
End If
depth = depth - 1
Next objLib
End Function

To load a new library use NI AWR SDE access to the NewWithProcessLibary function.

Working With Output Files

If we need to create an output file using api we need first to look how we create an output file in AWR DE. We use
ADD/Modify Output File Dialog. In our API code we need to provide values for all parameters used at this dialog.

The following scripts demonstrate how to add some types of data files to the Project, and the method, and property to
print out the Output DataFile string.

For the NPORTF export output file:

' Code Module


Sub Main
Dim parType(3) As String
Dim datType(3) As String
Dim measStr As String
Dim outfile As OutputFile
Dim parTyped As String
Dim datTyped As String
Dim prec As String
Dim schName(5) As String
Dim import As String
Dim filext(3) As String

154 NI AWR Design Environment


Developing a Script

Debug.Clear

parType(1) = "1" '"S"


parType(2) = "2" '"Y"
parType(3) = "3" '"Z"
datType(1) = "1" '"RI"
datType(2) = "2" '"MA"
datType(3) = "3" '"DB"

schName(1) = "NPORTF_S_dB"
schName(2) = "NPORTF_S_Mag"
schName(3) = "NPORTF_S_Real"
schName(4) = "NPORTF_Y_Mag"
schName(5) = "NPORTF_Z_Mag"

filext(1) = Chr$(46) & "s1p" & Chr$(44) & "1"


filext(2) = Chr$(46) & "y1p" & Chr$(44) & "1"
filext(3) = Chr$(46) & "z1p" & Chr$(44) & "1"
prec = "5"
import = ""

measStr = "NPORTF(" & parType(1) & "," & datType(3) & "," & prec & ",50,1,1," & schName(1) & filex

Set outfile = Project.OutputFiles.Add(schName(1), measStr)


Debug.Print measStr

prec = "8"
measStr = "NPORTF(" & parType(1) & "," & datType(2) & "," & prec & ",40,1,1," & schName(2) & filex

Set outfile = Project.OutputFiles.Add(schName(2), measStr)


Debug.Print measStr

prec = "5"
measStr = "NPORTF(" & parType(1) & "," & datType(1) & "," & prec & ",50,1,1," & schName(3) & filex

Set outfile = Project.OutputFiles.Add(schName(3), measStr)


Debug.Print measStr

measStr = "NPORTF(" & parType(2) & "," & datType(2) & "," & prec & ",50,1,1," & schName(4) & filex

Set outfile = Project.OutputFiles.Add(schName(4), measStr)


Debug.Print measStr

measStr = "NPORTF(" & parType(3) & "," & datType(2) & "," & prec & ",50,1,1," & schName(5) & filex

Set outfile = Project.OutputFiles.Add(schName(5), measStr)


Debug.Print measStr

End Sub

The output for the script will be as following:

NPORTF(1,3,5,50,1,1,NPORTF_S_dB.s1p,1)

API Scripting Guide 155


Developing a Script

NPORTF(1,2,8,40,1,1,NPORTF_S_Mag.s1p,1)

NPORTF(1,1,5,50,1,1,NPORTF_S_Real.s1p,1)

NPORTF(2,2,5,50,1,1,NPORTF_Y_Mag.y1p,1)

NPORTF(3,2,5,50,1,1,NPORTF_Z_Mag.z1p,1)

NOTE:Keep in mind that the option to Write into Project Data Files should be checked if you need to import output
files back to the project and look at the results in the graph (See last "1" in filext() array). You need to be aware that the
files imported end up having 1 appended to the names because they are automatically renamed in MWOffice because
the name of the data file is the exact same as the name of the source schematic. You can set the results graph measurements
accordingly to avoid errors.

The following script demonstrates how to set Output Files for System Diagram RFA_TDR measurement:

' Code Module


Sub Main
Dim meas As String
Dim sch_name As String
Dim intp, outtp As String
Dim output_type As String
Dim prec As String
Dim output_tpe As String
Dim meas_Str As String
Dim modif As String

Debug.Clear
sch_name = Project.SystemDiagrams(1).Name
meas = "RFA_TDF("
intp = "PORT_1"
outtp = "PORT_2"
output_type = "NL_F,Power"
prec = "6"

modif = "dB("

meas_Str = modif & meas & intp & "," & outtp & ",0" & "," & prec & "," & Chr$(34) & "PORT_use_RFA_

Set outfile = Project.OutputFiles.Add(sch_name, meas_Str)

Debug. Print Project.OutputFiles(1).Name

End Sub

The output for the script will be as following:

F Chain:DB(RFA_TDF(PORT_1,PORT_2,0,6,"PORT_use_RFA_TDF_test",0))

The example for VNA power sweep:

156 NI AWR Design Environment


Developing a Script

' Code Module


Sub Main
Dim meas As String
Dim sch_name As String
Dim intp, outtp As String
Dim output_type As String
Dim prec As String
Dim output_tpe As String
Dim fil_name As String
Dim meas_Str As String

sch_name = Project.SystemDiagrams(1).Name
meas = "RFA_TDF("
intp = "TP.IN"
outtp = "TP.OUT"
output_type = "NL_F,Power"
prec = "6"
fil_name = "swept_output_RFA_TDF_test"
meas_Str = meas & intp & "," & outtp & ",0" & "," & prec & "," & Chr$(34) & "swept_output_RFA_TDF_

Set outfile = Project.OutputFiles.Add(sch_name, meas_Str)

Debug. Print Project.OutputFiles(1).Name


End Sub

The output for the script will be as following:

Pwr Sweep:RFA_TDF(VNA.VNA1,VNA.VNA1,1,6,"VNA_pwr_sweep_RFA_TDF_test",0)

The example for VNA frequency sweep:

sch_name = Project.SystemDiagrams(1).Name
meas = "RFA_TDF("
intp = "VNA.VSA1"
outtp = "VNA.VSA1"
output_type = "NL_F,Power"
prec = "6"

meas_Str = meas & intp & "," & outtp & ",0" & "," & prec & "," & Chr$(34) & "VNA_freq_sweep_RFA_TD

Set outfile = Project.OutputFiles.Add(sch_name, meas_Str)

Debug. Print Project.OutputFiles(1).Name

The output for the script will be as following:

Freq Sweep:RFA_TDF(VNA.VSA1,VNA.VSA1,0,6,"VNA_freq_sweep_RFA_TDF_test",0)

API Scripting Guide 157


Developing a Script

Creating And Editing Symbols Via the API

The NI AWR SDE API allows you to access the Symbols Collection. You can create and edit Symbols, and export them
to a Symbol (.syf) file. You can also import existing Symbols into your Project and edit them.

To create a new Symbol, use an intermediate object called a Symbol record. All Shapes need to be added to the Symbol
record object. The following multi-step process is required:

1. From the Symbols collection, request the creation of a Symbol record.


2. Add Shapes and nodes for the Symbol to the Symbol record object.
3. Pass the Symbol record object along with a name to the CreateSymbol method on the Symbols collection.

The following code shows an example of creating a Schematic Symbol using AddNode, AddLine, Add Polygon, and
AddText methods:

'Note that the distance between grid points on a Schematic


'is 100 drawing units
Sub Main
Dim symb As Symbols
Dim sm As Symbol
Dim srec As SymbolRecord
Set symb = Project.Symbols
Set srec = symb.CreateSymbolRecord
'Create an array of x,y points for the polygon
Dim myArray() As Long
ReDim myArray(9)
'Point 1
myArray(0) = 0
myArray(1) = 0
'Point 2
myArray(2) = 600
myArray(3) = 0
'Point 3
myArray(4) = 600
myArray(5) = 400
'Point 4
myArray(6) = 0
myArray(7) = 400
'Point 5
myArray(8) = 0
myArray(9) = 0
'Draw the polygon
srec.AddPolygon(myArray)
'Draw line at node 1
srec.AddLine(-200,200,0,200)
'Draw line at node 2
srec.AddLine(600,200,800,200)
'Add text to the symbol
srec.AddText(50, 150, 0, 0, "My Symbol")
'Add nodes to the symbol
srec.AddNode(-200, 200, 100, -100,True)
srec.AddNode(800, 200, -100, -100,True)
Set sm = symb.CreateSymbol("CustomSymbol",srec)
Debug.Clear

158 NI AWR Design Environment


Developing a Script

Debug.Print " *** Symbol Info *** "


Debug.Print "Name = " & sm.Name
Debug.Print "Node Count = " & sm.Nodes.Count
'Save the symbol to a symbol file
symb.SaveToFile("C:\My6scripts\Symbol\customSymbols.syf")
End Sub

This code generates the following output in the Immediate window:

*** Symbol Info ***


Name = CustomSymbol
Node Count = 2

You can also use the AddArc, AddEllipse, and AddPolyline methods.

In the NI AWRDE you can choose Project > Circuit Symbols > Manage Symbols and select the Symbol named
"CustomSymbol" from the list to view the new Symbol, as shown in the following figure.

The Symbol created with this code is saved to a customSymbols.syf file. You can also use Export and Import methods
from Symbol Collection.

API Scripting Guide 159


Developing a Script

You can create multiple Symbols with different names, with the same set of Shapes, because the Symbol name is associated
with the Shapes and nodes in the Symbol record in the CreateSymbol call.

To set the default Symbol name for a Schematic, use the following option from the Schematic Options collection:

Set schem = Project.Schematics("Schematic 1")


schem.Options("SchematicSymbolName").Value = "MSTEP@system.syf"

160 NI AWR Design Environment


Developing a Script

Method Project.Symbols.GetDefaultSymbol (long NumNodes) returns a Symbol object representing the default for the
number of nodes. The following script is an example of getting the default Symbol for a given number of nodes:

Sub Main
Dim Symb As Symbol
Dim SymbShape As SymbolShape
Dim Index As Integer
Debug.Clear
Set Symb = Project.Symbols.GetDefaultSymbol(2)
Debug.Print "Symbol Name = " & Symb.Name
Debug.Print "Symbol Nodes Count = " & Symb.Nodes.Count
Debug.Print "Symbol Shape Count = " & Symb.Shapes.Count
Index = 1
For Each SymbShape In Symb.Shapes
Debug.Print "Shape " & Index & " point count = " & SymbShape.Points.Count
Index = Index + 1
Next SymbShape
End Sub

This script generates the following output:

Symbol Name = defaultSymbolName_param_2@Factory


Symbol Nodes Count = 2
Symbol Shape Count = 6
Shape 1 point count = 2
Shape 2 point count = 2
Shape 3 point count = 2
Shape 4 point count = 2
Shape 5 point count = 2
Shape 6 point count = 2

As the previous examples show, a Symbol object contains Shapes and Nodes collections, allowing you to access the
SymbolShapes and SymbolNodes of a Symbol object. From a SymbolShape object you can get the type, points, and
attributes of a Shape. From a SymbolNode object you can get the x and y offset into the Symbol as well as the node label
text. From the Symbol.Boundary object you can get Left, Right, Top, and Bottom of the Boundary for the Symbol.

The API exposes the Symbol property of an Element object, so you can change the Symbol associated with an electrical
Element.

To access the Shapes of a Symbol associated with a Schematic Element, you need to get the name of the Symbol from
the Element and then use the name as an index for a Symbols collection associated with the Project. This gives you a
Symbol object from which you can get the Shapes and nodes.

'Code Modules
Sub Main
Dim Sch As Schematic
Dim Ele As Element
Debug.Clear
For Each Sch In Project.Schematics
Debug.Print "Schematic = " & Sch.Name
For Each Ele In Sch.Elements
Debug.Print "Element Name = " & Ele.Name
OutputSymbolDetails(Ele.Symbol)

API Scripting Guide 161


Developing a Script

Next Ele
Debug.Print
Next Sch
Debug.Print
End Sub
Sub OutputSymbolDetails(ByRef SymbolName As String)
Dim Sym As Symbol
Dim Shp As SymbolShape
Dim Attr As Attribute
Dim Nde As SymbolNode
Dim i As Integer

Set Sym = Project.Symbols.Item(SymbolName)


Debug.Print "Symbol Name = " & Sym.Name
Debug.Print "ShapeCount = " & Sym.Shapes.Count
Debug.Print "Node Count = " & Sym.Nodes.Count
Debug.Print "Project Symb = " & Sym.ProjectSymbol
Debug.Print "Referenced = " & Sym.Referenced
Debug.Print "Select Mode = " & Sym.SelectMode
Debug.Print "Symbol Type = " & Sym.SymbolType
Debug.Print
Debug.Print " *** Shapes ***"
i = 1
For Each Shp In Sym.Shapes
Debug.Print "Shape[" & i & "] Type = " & Shp.Type
OutputShapePoints(Shp)
OutputShapeAttribute(Shp)
i = i + 1
Debug.Print
Next Shp
Debug.Print
Debug.Print " *** Nodes ***"
i = 0
For Each Nde In Sym.Nodes
Debug.Print "Node[" & i & "] = (" & Nde.x & ", " & Nde.y & " ) "
i = i + 1
Next Nde
Debug.Print
End Sub
Sub OutputShapePoints(ByRef Shp As SymbolShape)
Dim Pt As Point
Dim i As Integer
i = 0
For Each Pt In Shp.Points
Debug.Print "Point[" & i & "] = (" & Pt.x & ", " & Pt.y & ")"
i = i + 1
Next Pt
End Sub
Sub OutputShapeAttribute(ByRef Shp As SymbolShape)
Dim at As Attribute
Dim i As Integer
i = 0
For Each at In Shp.Attributes
Debug.Print "Attr[" & i & "] = (" & at.Name & ", " & at.Type & ")";
Debug.Printat.Value;vbTab;at.ValueAsString;vbTab;at.ReadOnly
i = i + 1

162 NI AWR Design Environment


Developing a Script

Next at
End Sub

The following output is an example of the generated result:

Schematic = Schematic 1
Element Name = PORT.P1
Symbol Name = Port@system.syf
ShapeCount = 6
Node Count = 1
*** Shapes ***
Shape[1] Type = 0
Point[0] = (0, 0)
Point[1] = (-100, 0)
Shape[2] Type = 0
Point[0] = (-100, 0)
Point[1] = (-200, -100)
Shape[3] Type = 0
Point[0] = (-200, -100)
Point[1] = (-250, -100)
Shape[4] Type = 0
Point[0] = (-250, -100)
Point[1] = (-250, 100)
Shape[5] Type = 0
Point[0] = (-250, 100)
Point[1] = (-200, 100)
Shape[6] Type = 0
Point[0] = (-200, 100)
Point[1] = (-100, 0)
*** Nodes ***
Node[0] = (0, 0 )

The following script deletes the created Symbol:

Option Explicit
Sub Main
'make a new symbol record
Dim symrec As SymbolRecord
Set symrec = Project.Symbols.CreateSymbolRecord
'draw a box and add 2 nodes
symrec.AddLine(0, 0, 1000, 0)
symrec.AddLine(1000, 0, 1000, 1000)
symrec.AddLine(1000, 1000, 0, 1000)
symrec.AddLine(0, 1000, 0, 0)
symrec.AddNode(0,500, 50, 50, True)
symrec.AddNode(1000, 500, 50, 50, True)
'make a new symbol, find an available name, create it with the symbol record
Dim newSym As Symbol
Dim symbName As String
symbName = NewSymbName("NewSymbol")
Set newSym = Project.Symbols.CreateSymbol(symbName, symrec)
'make a schematic, add an MLIN, and set the new symbol as the mlin symbol
Dim sch As Schematic
Set sch = Project.Schematics.Add("newSchem")
sch.Elements.Add("MLIN", 0, 0, 0, False, symbName)

API Scripting Guide 163


Developing a Script

'delete the schematic, try to delete the symbol


Project.Schematics.Remove(sch.Name)
Project.Symbols(symbName).Delete
End Sub
Function NewSymbName(symName As String) As String
Dim i As Integer
i = 1
If Project.Symbols.Exists(symName) Then
While Project.Symbols.Exists(symName & i)
i = i + 1
Wend
NewSymbName = symName i
Else
NewSymbName = symName
End If
End Function
The following code deletes unused symbols from the symbols collection:
' Code Module
Option Explicit
Sub Main
Debug.Clear
Dim sy As Symbol
For Each sy In Project.Symbols
If sy.Referenced =False Then
If InStr(sy.Name, "@") = 0 Then
sy.Delete
End If
End If
Next sy
End Sub

The following script creates a symbol with edge select only mode enabled. The newly created symbol associates with
an element in a schematic and code prints out the attributes of the symbol after it is created:

Sub Main
Dim symbName As String

symbName = "MySymbol"
schemName = "MySchematic"

CreateProjectSymbol(symbName)
CreateSymbolElement symbName, schemName
PrintSymbolDetails(symbName)
PrintElementDetails(schemName)

End Sub
Sub CreateProjectSymbol(symbName As String)
Dim symbRec As SymbolRecord
Dim symb As Symbol

If Project.Symbols.Exists(symbName) Then
Project.Symbols.Remove(symbName)
End If

' Create a new symbol and make it selectable by edge only


Set symbRec = Project.Symbols.CreateSymbolRecord

164 NI AWR Design Environment


Developing a Script

symbRec.AddNode(0, 0, 50, -50, True)


symbRec.AddNode(1000, 0, -100, -50, True)
symbRec.AddLine(0, 0, 300, 0)
symbRec.AddLine(700, 0, 1000, 0)
symbRec.AddEllipse(300, -200, 700, 200)
symbRec.AddArc(350, -25, 650, 125, 0, 50, 1000, 50)
symbRec.AddEllipse(350, -125, 450, 25)
symbRec.AddEllipse(550, -125, 650, 25)

' Set this symbol to be edge select only.


symbRec.SelectMode = mwSM_EdgeSelect
Project.Symbols.CreateSymbol("MySymbol", symbRec)

End Sub

Sub CreateSymbolElement(symbName As String, schemName As String)


Dim schem As Schematic
Dim elem As Element

If Project.Schematics.Exists("Schematic 1") Then


Project.Schematics.Remove("Schematic 1")
End If

Set schem = Project.Schematics.Add(schemName)


schem.Elements.Add("MLIN", 0, 0, 0, False, symbName)
End Sub

Sub PrintSymbolDetails(symbName As String)


Dim symb As Symbol

Set symb = Project.Symbols(symbName)


Debug.Print "Name = " & symb.Name
Debug.Print "Nodes = " & symb.Nodes.Count
Debug.Print "Project Symb = " & symb.ProjectSymbol
Debug.Print "Referenced = " & symb.Referenced
Debug.Print "Select Mode = " & symb.SelectMode
Debug.Print "Shape Count = " & symb.Shapes.Count
Debug.Print "Symbol Type = " & symb.SymbolType
Debug.Print ""

End Sub

Sub PrintElementDetails(schemName As String)


Dim schem As Schematic
Dim elem As Element

Set schem = Project.Schematics(schemName)


Debug.Print "Schematic = " & schem.Name
For Each elem In schem.Elements
Debug.Print "Element Name = " & elem.Name
Debug.Print "Element Symbol = " & elem.Symbol
Debug.Print ""
Next elem
End Sub

To extract the Shapes for a Symbol associated with a SystemDiagram Element, use the following script:

API Scripting Guide 165


Developing a Script

'Code Module
Sub Main
Dim Sys As SystemDiagram
Dim Ele As Element
Debug.Clear
For Each Sys In Project.SystemDiagrams
Debug.Print "SystemDiagram = " & Sys.Name
For Each Ele In Sys.Elements
Debug.Print "Element Name = " & Ele.Name
OutputSymbolDetails(Ele.Symbol)
Next Ele
Debug.Print
Next Sys
Debug.Print
End Sub

The OutputSymbolDetails(Ele.Symbol) function is described in the previous example.

To export a Symbol to the Project, use the Export method and show the full path to the .syf file.

To create Symbols for use in Schematics, see the following code:

Set symbRec = Project.Symbols.CreateSymbolRecord

' Add nodes and shapes to the symbol record.


symbRec.AddNode(0, 0, 50, 50, True)
symbRec.AddNode(1000, 0, -50, 50, True)
symbRec.AddEllipse(300, -200, 700, 200)
symbRec.AddLine(0, 0, 300, 0)
symbRec.AddLine(700, 0, 1000, 0)
symbRec.AddText(100, -50, 500, 50, "Graphics")
symbRec.AddMetaText(600, -50, 1000, 50, "MetaText")

' Create the symbol


Project.Symbols.CreateSymbol("MySymbol", symbRec)

' Create a Schematic and Place an element using our new symbol.
Dim schem As Schematic
Dim elem As Element
Set schem = Project.Schematics.Add("MySchematic")

' Mlin used because it has two ports, the model used
' is not important to this demonstration.
schem.Elements.Add("MLIN", 0, 0, 0, False, "MySymbol")

The API also supports Symbol (via the Options collection) for EM and System Diagrams and DataFiles:

' Code Module


Sub Main
Dim op As Option
For Each op In Project.DataFiles(1).Options
Debug.Print op.Name;vbTab;op.Description
Next op

166 NI AWR Design Environment


Developing a Script

End Sub

The API has access to the default Symbol for DataFiles (in the Options collection "SchematicSymbolName").

SchematicSymbolName also sets the default Symbol name used when a Document is placed as a Subcircuit.

The following script uses a system symbol and associates it with an element which is different than the default system
symbol for that element, so, that it's clear that the symbol was explicitly associated rather than just having the default:

' Code Module


Sub Main
Dim symbName As String

symbName = "TLINE@System.syf"
schemName = "MySchematic"

' Access a project symbol and use it on an element in schematic.


CreateSymbolElement symbName, schemName
PrintSymbolDetails(symbName)
PrintElementDetails(schemName)

End Sub

Sub CreateSymbolElement(symbName As String, schemName As String)


Dim schem As Schematic
Dim elem As Element

If Project.Schematics.Exists("Schematic 1") Then


Project.Schematics.Remove("Schematic 1")
End If

' Create a RES element but associate a MLIN symbol with it.
Set schem = Project.Schematics.Add(schemName)
schem.Elements.Add("RES", 0, 0, 0, False, symbName)
End Sub

Sub PrintSymbolDetails(symbName As String)


Dim symb As Symbol

Set symb = Project.Symbols(symbName)


Debug.Print "Name = " & symb.Name
Debug.Print "Nodes = " & symb.Nodes.Count
Debug.Print "Project Symb = " & symb.ProjectSymbol
Debug.Print "Referenced = " & symb.Referenced
Debug.Print "Select Mode = " & symb.SelectMode
Debug.Print "Shape Count = " & symb.Shapes.Count
Debug.Print "Symbol Type = " & symb.SymbolType
Debug.Print ""

End Sub

Sub PrintElementDetails(schemName As String)


Dim schem As Schematic
Dim elem As Element

API Scripting Guide 167


Developing a Script

Set schem = Project.Schematics(schemName)


Debug.Print "Schematic = " & schem.Name
For Each elem In schem.Elements
Debug.Print "Element Name = " & elem.Name
Debug.Print "Element Symbol = " & elem.Symbol
Debug.Print ""
Next elem
End Sub

The following code looks for symbol names in a project:

For Each s In Project.Symbols


Debug.Print s.Name & ",";
For Each n In s.Nodes
Debug.Print " number=" & n.LabelText & " x="& n.x & " y=" & n.y &",";
Next n
Next s

The following code prints out boundary property for the symbols shapes. The code creates a symbol with a number of
different shapes in it and then traverses the shapes of the resulting symbol and dumps the boundary values of each shape
:

' Code Module


Sub Main
Dim symbName As String

symbName = "MySymbol"
schemName = "MySchematic"
CreateProjectSymbol(symbName)
CreateSymbolElement symbName, schemName
PrintSymbolDetails(symbName)
PrintElementDetails(schemName)

End Sub

Sub CreateProjectSymbol(symbName As String)


Dim symbRec As SymbolRecord
Dim symb As Symbol

If Project.Symbols.Exists(symbName) Then
Project.Symbols.Remove(symbName)
End If

' Create a new symbol and make it selectable by edge only


Set symbRec = Project.Symbols.CreateSymbolRecord
symbRec.AddNode(0, 0, 50, -50, True)
symbRec.AddNode(1000, 0, -100, -50, True)
symbRec.AddLine(0, 0, 300, 0)
symbRec.AddLine(700, 0, 1000, 0)
symbRec.AddEllipse(300, -200, 700, 200)
symbRec.AddArc(350, -25, 650, 125, 0, 50, 1000, 50)
symbRec.AddEllipse(350, -125, 450, 25)
symbRec.AddEllipse(550, -125, 650, 25)

168 NI AWR Design Environment


Developing a Script

Project.Symbols.CreateSymbol("MySymbol", symbRec)
End Sub

Sub CreateSymbolElement(symbName As String, schemName As String)


Dim schem As Schematic
Dim elem As Element

If Project.Schematics.Exists("Schematic 1") Then


Project.Schematics.Remove("Schematic 1")
End If

Set schem = Project.Schematics.Add(schemName)


schem.Elements.Add("MLIN", 0, 0, 0, False, symbName)
End Sub

Sub PrintSymbolDetails(symbName As String)


Dim symb As Symbol
Dim symbShape As SymbolShape
Dim pt As Point
Dim attrIndex As Integer
Dim ptIndex As Integer
Dim attr As Attribute
Dim bnd As Boundary

Set symb = Project.Symbols(symbName)


Debug.Print "Name = " & symb.Name
Debug.Print "Nodes = " & symb.Nodes.Count
Debug.Print "Project Symb = " & symb.ProjectSymbol
Debug.Print "Referenced = " & symb.Referenced
Debug.Print "Select Mode = " & symb.SelectMode
Debug.Print "Symbol Type = " & symb.SymbolType
Debug.Print "Node 1 Pos = { x = " & symb.Nodes(1).x & ", y = " & symb.Nodes(1).y & " }"
Debug.Print ""
Debug.Print "Shape Count = " & symb.Shapes.Count
For Each symbShape In symb.Shapes
Set bnd = symbShape.Boundary
Debug.Print "Shape Type = " & symbShape.Type
Debug.Print "Points Count = " & symbShape.Points.Count
Debug.Print "Attrs Count = " & symbShape.Attributes.Count
Debug.Print "Boundary = { left = " & bnd.Left & ", top = " & bnd.Top & ", right = " & bnd.R
Debug.Print ""
Next symbShape

Debug.Print ""

End Sub

Sub PrintElementDetails(schemName As String)


Dim schem As Schematic
Dim elem As Element

Set schem = Project.Schematics(schemName)


Debug.Print "Schematic = " & schem.Name
For Each elem In schem.Elements
Debug.Print "Element Name = " & elem.Name
Debug.Print "Element Symbol = " & elem.Symbol
Debug.Print ""

API Scripting Guide 169


Developing a Script

Next elem
End Sub

The following code creates symbol with offset.In the code symbols created with the standard symbol record API methods
also get offset such that the resulting symbol has node 1 at 0,0. This code intentionally applies an offset to each symbol
coordinate including the node positions and then verifies that the nodes and shapes have been correctly offset to remove
the intentional offset and place node 1 at 0,0:

' Code Module


Sub Main
Dim symbName As String

symbName = "MySymbol"
schemName = "MySchematic"

CreateProjectSymbol(symbName)
CreateSymbolElement symbName, schemName
PrintSymbolDetails(symbName)
PrintElementDetails(schemName)

End Sub

Sub CreateProjectSymbol(symbName As String)


Dim symbRec As SymbolRecord
Dim symb As Symbol
Dim off As Integer

If Project.Symbols.Exists(symbName) Then
Project.Symbols.Remove(symbName)
End If

off = 100

' Create a new symbol and make it selectable by edge only


Set symbRec = Project.Symbols.CreateSymbolRecord
symbRec.AddNode(0 + off, 0 + off, 50, -50, True)
symbRec.AddNode(1000 + off, 0 + off, -100, -50, True)
symbRec.AddLine(0 + off, 0 + off, 300 + off, 0 + off)
symbRec.AddLine(700 + off, 0 + off, 1000 + off, 0 + off)
symbRec.AddEllipse(300 + off, -200 + off, 700 + off, 200 + off)
symbRec.AddArc(350 + off, -25 + off, 650 + off, 125 + off, 0, 50, 1000, 50)
symbRec.AddEllipse(350 + off, -125 + off, 450 + off, 25 + off)
symbRec.AddEllipse(550 + off, -125 + off, 650 + off, 25 + off)
Project.Symbols.CreateSymbol("MySymbol", symbRec)

End Sub

Sub CreateSymbolElement(symbName As String, schemName As String)


Dim schem As Schematic
Dim elem As Element

If Project.Schematics.Exists("Schematic 1") Then


Project.Schematics.Remove("Schematic 1")
End If

170 NI AWR Design Environment


Developing a Script

Set schem = Project.Schematics.Add(schemName)


schem.Elements.Add("MLIN", 0, 0, 0, False, symbName)
End Sub

Sub PrintSymbolDetails(symbName As String)


Dim symb As Symbol
Dim symbShape As SymbolShape
Dim pt As Point
Dim attrIndex As Integer
Dim ptIndex As Integer
Dim attr As Attribute

Set symb = Project.Symbols(symbName)


Debug.Print "Name = " & symb.Name
Debug.Print "Nodes = " & symb.Nodes.Count
Debug.Print "Project Symb = " & symb.ProjectSymbol
Debug.Print "Referenced = " & symb.Referenced
Debug.Print "Select Mode = " & symb.SelectMode
Debug.Print "Symbol Type = " & symb.SymbolType
Debug.Print "Node 1 Pos = { x = " & symb.Nodes(1).x & ", y = " & symb.Nodes(1).y & " }"
Debug.Print ""
Debug.Print "Shape Count = " & symb.Shapes.Count
For Each symbShape In symb.Shapes
Debug.Print "Shape Type = " & symbShape.Type
Debug.Print "Points Count = " & symbShape.Points.Count
ptIndex = 1
For Each pt In symbShape.Points
Debug.Print "Point[" & ptIndex & "] = { x = " & pt.x & ", y = " & pt.y & " }"
ptIndex = ptIndex + 1
Next pt

Debug.Print "Attribute Count = " & symbShape.Attributes.Count


For Each attr In symbShape.Attributes
Debug.Print "Attribute = " & attr.Name & " = " & attr.Value
Next attr
Debug.Print ""
Next symbShape

Debug.Print ""

End Sub

Sub PrintElementDetails(schemName As String)


Dim schem As Schematic
Dim elem As Element

Set schem = Project.Schematics(schemName)


Debug.Print "Schematic = " & schem.Name
For Each elem In schem.Elements
Debug.Print "Element Name = " & elem.Name
Debug.Print "Element Symbol = " & elem.Symbol
Debug.Print ""
Next elem
End Sub

API Scripting Guide 171


Working with Schematics

When the symbol object is created the cached objects are offset so that node 1 will be located at 0,0 and the other shape
will be relative to this according to their original locations.

Working with InvokeCommand() via the API

The NI AWR SDE API allows you to access all api commands that can be used with InvokeCommand() statement. You
can run the following script and see all commands names. The text file will be under C: directory. You can also set the
Path you need in the code

Option Explicit
'Description=Returns a text file with a categorized list of every API command. Currently set to pu
' Code Module
Sub Main
Open("c:\commands.txt") For Output As #1
Dim objTable As CommandTable
Dim cmd As Command

For Each objTable In MWOffice.CommandTables


Print #1, "Table = " & objTable.Name

For Each cmd In objTable.Commands


Print #1, cmd.Name
Next cmd
Print #1, ""
Next objTable

End Sub

Working with Schematics


The core object in the NI AWR SDE is the Project. From the Project object you can access the Circuit Schematics
collection of objects. The code finds each Schematic in the Project (it iterates through the whole collection of Schematic
objects) and prints its name in the Immediate window:

Dim s As Schematic
For Each s In Project.Schematic
Debug.Print s.Name
Next s

You can access a specific Schematic by name or by index like each Element in the collection of objects:

Dim s As Schematic
Set s = Project.Schematics("Master")

or

Set s = Project.Schematic(1)

This code assigns the Schematic named "Master" to the variable s or you can say that s is a reference to the Schematic
named "Master".

172 NI AWR Design Environment


Working with Schematics

After you have a reference to a specific Schematic object you can perform the following actions:

Set Options to the Schematic


Set Frequencies to the Schematic
CopyToClipboard
Export Schematic
ExportNetlist
Work with the Schematic Elements collection
Work with the Schematic Equations collection
Work with the Schematic Layout object
PrintOut a particular Schematic
Put Schematic in a new Window
Work with the collection of Schematic WireSegment objects

Specifying Schematic Options


You can configure Schematic options for a particular Schematic via the Schematic object, or you can use the default
options set for all circuits within the Project.

Configuring Local Schematic Options and Set Frequencies

As described in a previous section, you can configure via the API Schematic options that control all specific settings for
a particular Schematic. You can explore the whole collection of Schematic options and set a particular option to a new
value.

'Code Module
Sub Main
Dim scm As Schematic
Dim opt As Option
Debug.Clear
Set scm = Project.Schematics("Filter")
For Each opt In scm.Options
Debug.Print opt.Name;vbTab;opt.Value
Next opt
End Sub

This script generates the following output:

NumberTone1Harmonics 4
NumberTone2Harmonics 4
NumberTone3Harmonics 4
MaximumHarmonicIterations 1000
RelativeConvergenceError 0.001
AbsoluteConvergenceError 0.0000001
HarmonicZeroTolerance 0.001
HarmonicExponentialZeroTolerance 0.0001
NyquistSampleMixSetting 0
LimitHarmonicOrder True
MaximumHarmonicOrder 9

API Scripting Guide 173


Working with Schematics

OversamplingRate 2
UseFrequencyMap False
LinearSolveType 0
UseIncrementalSolve True
SourceStepSizeDb 2
SourceStepReduceDb 40
UseSourceStepping True
SpiceModelLevel 3
iNetModelLevel 0
ModelVersionNumber 650
Hideparameters False
HideparameterUnits False
HideparameterIfEmpty False
HideparameterVarName False
LeftJustifyparameters False
BoldparameterFont False
HideElementNames False
BoldElementFont False
LeftJustifyElementName True
HideSecondaryparameters True
SymbolLineThickness 0
BlackAndWhite False
DependentparametersInBaseUnits False
SignificantparameterDigits 4
parameterZeroThreshold 1E-30

The key to changing options at the individual Schematic level is to make sure the UseProjectDefaults property is set to
"False". The following example sets them at the Schematic level:

Sub Main
Dim s As Schematic
For Each s In Project.Schematics
Debug.Print "Schematic Name = " & s.Name
'Set the options to use the local schematic options.
s.UseProjectOptions = False
'Print the current value of the MaximumHarmonicOrder
Debug.Print s.Options.Item("MaximumHarmonicOrder")
'Double the MaximumHarmonicOrder.
s.Options.Item("MaximumHarmonicOrder") = 2 * s.Options.Item("MaximumHarmonicOrder")
'Print the updated value.
Debug.Print s.Options.Item("MaximumHarmonicOrder")
Next s
End Sub

The output shows that the MaximumHarmonicOrder is doubled each time.

Schematic.Options :
Project.Schematics.Options.Count = : 18
Schematic Name = Filter
9
18
Schematic Name = New Schematic
9
18
Schematic Name = Schematic 1

174 NI AWR Design Environment


Working with Schematics

9
18

The key to changing frequencies at the individual Schematic level is to make sure the UseProjectFrequencies property
is set to "False".

The method which sets the state for options associated with a document includes the dynamically loaded options. This
addresses the additional pages, like the APLAC Sim, HSPICE Sim, and Spectre tabs on the Options dialog box.

Configuring Global Circuit Options

To set the defaults for the whole Schematics collection (Global Circuit Options) on the Project level you need to access
the Options collection directly from the Schematics collection.

Sub Main
Dim op As Option
Debug.Clear
For Each op In Project.Schematics.Options
Debug.Printop.Name;vbTab;op.Value;vbTab;op.Description
Next op
End Sub

You can make modifications as in the previous example.

Project.Schematics.Options("HarmonicZeroTolerance") = 0.005

Creating, Importing, and Deleting Schematics


To create a Schematic, you use the Add method, which takes one argument (the name of the Schematic you want to add).
The following code creates a new Schematic with the name "Filter" and references the new Schematic:

Set s = Project.Schematics.Add("Filter")

If a Schematic named "Filter" already exists, the new Schematic is named "Filter1".

To delete a Schematic by name, enter:

Project.Schematics.Remove("Filter")

To import a Schematic into the Project, enter:

Project.Schematics.Import("Filter1",Project.Path + "Filter.sch")

This fragment of code finds the file (with the extension *.sch) and adds the Schematic to the Project Browser under the
name "Filter1". This method and the "LinkTo" method accept a Name under which you create the Project Browser node
and File Path to the import.

To link to a file that contains the Schematic, use the following code:

Setrf=Project.Schematics.LinkTo("Filter1",Project.Path + "Filter.sch")

API Scripting Guide 175


Working with Schematics

This code adds a Schematic object link to the collection from a file (the linked schematic file has a *.sch extension) and
returns a reference to the created object.

NOTE: The Import method embeds the document into the Project while the LinkTo method retains a reference and
displays the reference in the Project Browser node name.

You can also perform a Copy to Clipboard operation in the script by using the CopyToClipboard method.

Project.Schematics("Filter").CopyToClipboard

When the script stops, the "Filter" Schematic stays on the Clipboard.

Exporting a Schematic

To export a Schematic from the Project, enter:

Project.Schematics("Filter").Export(Project.Path+ "Filter",mwSEF_AWR DESchematicFile)

This code finds the Schematic ("Filter") and writes a Filter.sch file to the Project directory.

To export a netlist from the Project, enter:

Project.Schematics("Filter").ExportNetlist(Project.Path+ "Filter",mwNEF_AWR DENetlistFile)

In the ExportNetlist example, the method takes two arguments (FilePath as String is the location in which you want to
place the NetList, and Constant defines the type of Schematic netlist export format).

To print the entire Schematic on paper, enter:

Project.Schematics("Filter").PrintOut

Working with Elements


Browsing Elements

The API allows you to browse through a comprehensive database of hierarchical groups of electrical models and print
out all information about the model, such as name, description, category, symbol name, company name, and model level.
You can browse through Elements manually within the Element Browser, and programmatically via the API.

Sub Main
On Error Resume Next
Debug.Clear
Dim m As Model
Dim sch As Schematic
Set sch = Project.Schematics("Test")
If sch Is Nothing Then
Set sch = Project.Schematics.Add("Test")
End If
For Each m In MWOffice.Models
If Left(m.Name,1) <> "_" Then
sch.Elements.Add(m.Name,0,0)

176 NI AWR Design Environment


Working with Schematics

sch.Elements.Remove(1)
Debug.Print m.Name;vbTab;"Cat-ry=";m.Category(1);vbTab;"Levels=";m.Levels;vbTab;Module=";
m.Module;vbTab;"Symbol= ";m.Symbol;vbTab;"Version = ";m.Version
Debug.Print "Company = ";m.Company;vbTab;"Description =";m.Description;vbTab;"HelpContext=";m.He
End If
Next m
End Sub

The following is the portion of output generated by this script:

MPSUB Cat-ry = MPSUB Levels = 1 Module = unknown Symbol= MPSUB@MLINES.SYF Version = 1 Company
Company = AWR Description = Microstrip Substrate Definition HelpContext = 5110 HelpFile = MSUB2
Company = AWR Description = Two-Layer Microstrip Substrate Definition HelpContext = 5505 HelpF

Note that HelpFile in this example is empty.

Working with the Elements Collection

You can programmatically perform the same operations with Elements as you can manually:

Getting the selected Schematic Elements

Adding Elements to a Schematic at a determined position

Rotating and flipping Elements

Editing Element parameter values

API operations on vector instances of an element.

Accessing the Element Options collection

Using variables and equations for parameter values

Enabling and selecting Elements

Working with the Nodes collection

Getting the Selected Schematic Elements

The following function returns the selected Elements in the active Schematic for use with scripts that work on selected
Schematic Elements. This code uses the active Schematic function. The NI AWRDE supports getting the collection of
selected Elements directly, so enumerating the Elements is no longer necessary:

Dim ele as Element


Dim sch As Schematic

Set sch = awrGetActiveSchematic()

For Each ele in sch.SelectedElements


...

You can now perform the following:

API Scripting Guide 177


Working with Schematics

Function awrSchGetSelected() As Element()


Dim elementList() As Element
Dim curElement As Element
Dim sch As Schematic
Dim i As Integer
i=1

Set sch = awrGetActiveSchematic()

'need an initial dimension so use total element count


ReDim elementList(sch.Elements.Count)

For Each curElement In sch.Elements


If curElement.Selected = True Then
Set elementList(i) = curElement
i = i+1
End If
Next curElement
' now we know how many element we have so resize array
ReDim Preserve elementList(i-1)

awrSchGetSelected = elementList
End Function

The following is an example of using this function:

Dim el() As Element

el = awrSchGetSelected()

For j=1 To UBound(el)


Debug.Print el(j).Name
Next j

The following is an example of using DisplayMode Function that returns False or True:

' Code Module


Sub Main
Dim lay As Layout
Dim schem As Schematic
Dim objDraw As DrawingObject
Dim elem As Element

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
Set schem = Project.Schematics("SCH1")

For Each elem In schem.Elements


Debug.Print elem.DisplayMode(mwDMT_ObjectMarked)
Debug.Print elem.DisplayMode(mwDMT_BuddySelected)
Debug.Print elem.DisplayMode(mwDMT_BuddyUnselected)
Next elem

178 NI AWR Design Environment


Working with Schematics

End Sub

Adding Elements to a Schematic

Once you have access to a Schematic you can iterate through the Elements collection as usual:

Dim sch As Schematic


Dim ele as Element
Set sch = Project.Schematics("Filter")
For Each ele In sch.Elements
Debug.Print ele.Name
Next ele

You can create a new Schematic by adding all Elements:

Dim Schem As Schematic


Set Schem = Project.Schematics.Add("Master")
Dim Eles As Elements
Set Eles = Schem.Elements
Dim Ele As Element
dx = 2000
dy = 800
For i = 0 To 9
For j = 0 To 270 Step 90
Set Ele = Eles.Add("RES",dx*i,0,j)
Next j
Next i

This code example creates a new Schematic named "Master" and places resistors on it.

Note that the Add method contains the Element x and y coordinates. In this example, each resistor connects to its neighbor
without a wire. To connect Elements via wire you need to use the Wires collection of objects.

The following script shows how to use InvokeCommand() methods to add an Element to schematic and Undo/Redo the
adding:

Sub Main
Dim schem As Schematic

Set schem = Project.Schematics("SCH1")

PrintElementState schem, "Before Add Element"

schem.InvokeCommand("InsertElement", Array("MLIN", 100, 100, 0), ret)


Debug.Print ret
PrintElementState schem, "After Add Element"
schem.SelectedElements.AddAll
schem.InvokeCommand("EditFreeze")
schem.InvokeCommand("EditUndo")
schem.InvokeCommand("EditRedo")

End Sub

API Scripting Guide 179


Working with Schematics

Sub PrintElementState(ByRef schem As Schematic, title As String)


Dim elem As Element
Dim count As Integer

coutn = 0
Debug.Print " *** " & title & " *** "
Debug.Print "Element Count = " & schem.Elements.Count
Debug.Print "Elements: "
For Each elem In schem.Elements
Debug.Print " Name = " & elem.Name
Next elem
Debug.Print ""

End Sub

Note that to Undo the adding we need to Select All Elements in schematic and Freeze all Elements.

The following script shows how use the API InvokeCommand method to InsertWire. This method should be used if we
need to use Undo method after inserting a wire in some cases, because only command invocations support Undo:

' Code Module


Sub Main
Dim schem As Schematic
Dim port1 As Element
Dim port3 As Element
Dim x1 As Long
Dim x2 As Long
Dim y1 As Long
Dim y2 As Long
Dim ret As Variant

Debug.Clear
Set schem = Project.Schematics("Schematic 1")
Set port1 = schem.Elements("PORT.P1")
Set port3 = schem.Elements("PORT.P3")

x1 = port1.Nodes(1).x
y1 = port1.Nodes(1).y
x2 = port3.Nodes(1).x
y2 = port3.Nodes(1).y

PrintFlightLines schem, "Before Insert Wire"

schem.InvokeCommand("InsertWire", Array(x1, y1, x2, y2), ret)


Debug.Print ret

PrintFlightLines schem, "After Insert Wire"


schem.InvokeCommand("EditUndo")
PrintFlightLines schem, "After Undo"

End Sub

Sub PrintFlightLines(ByRef schem As Schematic, title As String)


Dim phys As PhysicalNet

180 NI AWR Design Environment


Working with Schematics

Debug.Print title
Debug.Print "Flight Lines"
For Each phys In schem.Layout.PhysicalNets
Debug.Print phys.Name & ", Flight Line Count = " & phys.FlightLines.Count
Next phys
Debug.Print

End Sub

This script inserts the wire via InvokeCommand between the node on Port 1 and the node on Port 3, then checks for
flight lines and then undo the wire insertion and checks again for flight lines.

The following script shows how to create Electrical Nets (Do not forget to use the updateConnectivity() command):

' Code Module


Sub Main
Debug.Clear
If Project.Schematics.Exists("OneMlin") Then
Project.Schematics.Remove("OneMlin")
End If
Dim S As Schematic
Set S = Project.Schematics.Add("OneMlin")
Dim M As Element
Dim P1 As Element
Dim P2 As Element
Set M = S.Elements.Add("MLIN", 0, 0, 0, False)
Set P1 = S.Elements.Add("PORT", -1000, 0, 0, False)
Set P2 = S.Elements.Add("PORT", 2000, 0, 180, False)
Debug.Print S.ElectricalNets.Count
Dim W1 As WireSegment
Dim W2 As WireSegment
Set W1 = S.Wires.Add(-1000, 0, 0,0)
Debug.Print "Number of Wires = " & S.Wires.Count
S.UpdateConnectivity
Debug.Print S.ElectricalNets.Count
Set W2 = S.Wires.Add(1000, 0, 2000, 0)
Debug.Print "Number of Wires = " & S.Wires.Count
S.UpdateConnectivity
Debug.Print S.ElectricalNets.Count
End Sub

Do you know what is SetupConnectivity method, and how does that differ from UpdateConnectivity? SetupConnectivity
ensures that the node numbers are assigned on the node elements of a schematic so after rewiring things this will ensure
that the numbers are unique for simulation. Update connectivity forces an update to the electrical nets ensuring that they
keep track of the elements that are connected together. They are the electrical side of the connectivity for layout. For
example, the layout knows which PCells to draw flight lines to because the electrical nets in the schematic tell it what
elements are connected together. The electrical nets also provide the schematic side of inets, the electrical net is the
element for the inet layout.

Use the LockUpdates property when you are adding more then 500 Elements to the Schematic. This property locks wire
connectivity updating and speeds Element addition.

To add a named port to a Schematic, use the following script:

API Scripting Guide 181


Working with Schematics

' Module: AddNamedPort


' Add a named port object and then set the named parameter to a specific value
Sub Main
Dim schem As Schematic
Dim port As Element
Debug.Clear
' Get a reference to an existing schematic in the project.
Set schem = Project.Schematics("MySchematic")
Debug.Print schem.Name
' Add a MLIN element for the named port to connect to.
schem.Elements.Add("MLIN", 0, 0)
' Add a named port element
Set port = schem.Elements.Add("PORT_NAME", 0, 0)
' Change the value of the named port name parameter
Debug.Print port.parameters("Name").ValueAsString
port.parameters("Name").ValueAsString = "MyName"
Debug.Print port.parameters("Name").ValueAsString
' Add a second named port to the other end of the mlin
Set port = schem.Elements.Add("PORT_NAME", 1000, 0, 180)
' Change the value of the named port name parameter
Debug.Print port.parameters("Name").ValueAsString
port.parameters("Name").ValueAsString = "MyName2"
Debug.Print port.parameters("Name").ValueAsString
End Sub

This script generates the following output:

MySchematic
PCONN1
MyName
PCONN1
MyName2

To set the Port name, use the following code:

port.Parameters("Name").ValueAsString = "IN[0:3]"

182 NI AWR Design Environment


Working with Schematics

The following code demonstrates how to create a Bus:

Dim schem As Schematic


Dim elem1 As Element
Dim elem2 As Element
Dim x1, y1, x2, y2 As Integer
Set schem = Project.Schematics.Add("MySchematic")
Set elem1 = schem.Elements.Add("MLIN", 0, 0)

API Scripting Guide 183


Working with Schematics

Set elem2 = schem.Elements.Add("MLIN", 2000, 0)


x1 = elem1.Nodes(2).x
y1 = elem1.Nodes(2).y
x2 = elem2.Nodes(1).x
y2 = elem2.Nodes(1).y
elem1.VectorInstanceName = "[0:10]"
elem2.VectorInstanceName = "[0:10]"
schem.Wires.AddBusNet(x1, y1, x2, y2, "B1[0:10]", x1, y1 - 200)

To access the Bus and Bundle information shown in the following figure, use the following script:

' Module name: BusNetNameInfo


' This module outputs information about buses and bundles in the design schematic
' MySchematic associated with this project.
Sub Main
Dim schem As Schematic
Dim objWire As WireSegment
Dim index As Integer
Debug.Clear
Set schem = Project.Schematics("MySchematic")
Debug.Print schem.Name

184 NI AWR Design Environment


Working with Schematics

' Check each of the wires for an Associated BusNetName


index = 1
For Each objWire In schem.Wires
Debug.Print "Wire [" & index & "] ";
Debug.Print "x1 = " & objWire.x1 & ", y1 = " & objWire.y1 & " ";
Debug.Print "x2 = " & objWire.x2 & ", y2 = " & objWire.y2 & " ";
Debug.Print "Has BusNetName = " & objWire.HasBusNetName
' If the wire segment has a BusNetName object associated with it then print details.
If (objWire.HasBusNetName) Then
PrintBusNetName(objWire.BusNetName)
End If
index = index + 1
Next objWire
End Sub
' Print detailed information about the bus net name object.
Sub PrintBusNetName(ByRef objBus As BusNetName)
Dim objBundle As BundleInfo
Debug.Print
Debug.Print " *** BusNetName information *** "
Debug.Print "BusNetName = " & objBus.Name
Debug.Print "Base Pos x = " & objBus.BasePosition.x & ", y = " & objBus.BasePosition.y
Debug.Print "Bit Count = " & objBus.BitCount
Debug.Print "Priority = " & objBus.Priority
Debug.Print "Rot Angle = " & objBus.RotationAngle
Debug.Print "Flipped = " & objBus.Flipped
' Call to print the bundle information details.
PrintBundleInformation(objBus.BundleInfo)
End Sub
' Print detailed information about the bundle information
Sub PrintBundleInformation(ByRef objBundle As BundleInfo)
Dim objBit As BundleBit
Dim objBus As BundleBus
Dim index As Integer
Debug.Print
Debug.Print " *** Bundle Information *** "
Debug.Print "BundleName = " & objBundle.Name
Debug.Print "Bit Count = " & objBundle.Bits.Count
Debug.Print "Bus Count = " & objBundle.Buses.Count
Debug.Print
Debug.Print " *** Bits *** "
For Each objBit In objBundle.Bits
Debug.Print "Name = " & objBit.Name & ", ";
Debug.Print "Bus Name = " & objBit.BusName & ", ";
Debug.Print "Bit Index = " & objBit.BitIndex & ", "
Next objBit
Debug.Print
Debug.Print " *** Buses *** "
For Each objBus In objBundle.Buses
Debug.Print objBus.Name
Next objBus
End Sub

This script generates the following output:

MySchematic
Wire [1] x1 = -800, y1 = -200 x2 = 700, y2 = -200 Has BusNetName = True

API Scripting Guide 185


Working with Schematics

*** BusNetName information ***


BusNetName = B1[0:10]
Base Pos x = -50, y = -200
Bit Count = 11
Priority = 0
Rot Angle = 0
Flipped = False
*** Bundle Information ***
BundleName = B1[0:10]
Bit Count = 11
Bus Count = 1
*** Bits ***
Name = B1:0, Bus Name = B1, Bit Index = 0,
Name = B1:1, Bus Name = B1, Bit Index = 1,
Name = B1:2, Bus Name = B1, Bit Index = 2,
Name = B1:3, Bus Name = B1, Bit Index = 3,
Name = B1:4, Bus Name = B1, Bit Index = 4,
Name = B1:5, Bus Name = B1, Bit Index = 5,
Name = B1:6, Bus Name = B1, Bit Index = 6,
Name = B1:7, Bus Name = B1, Bit Index = 7,
Name = B1:8, Bus Name = B1, Bit Index = 8,
Name = B1:9, Bus Name = B1, Bit Index = 9,
Name = B1:10, Bus Name = B1, Bit Index = 10,
*** Buses ***
B1

To add a bus net name to a wire, use the following code:

Dim schem As Schematic


Dim elem1 As Element
Dim elem2 As Element
Dim seg As WireSegment

Set schem = Project.Schematics("SCH1")


Set elem1 = schem.Elements("MLIN.TL1")
Set elem2 = schem.Elements("MLIN.TL2")

' Add a wire connecting the elements.


Set seg = schem.Wires.Add(elem1.Nodes(2).x, elem1.Nodes(2).y, elem2.Nodes(1).x, elem2.Nodes(1).y)

If (seg.HasBusNetName) Then
PrintBusNetName seg.BusNetName, "Before Add"
Else
Debug.Print "Before No Bus Net Name"
Debug.Print ""
End If

seg.AddBusNetName("MyBusNet", seg.x1, seg.y1)

If (seg.HasBusNetName) Then
PrintBusNetName seg.BusNetName, "After Add"
Else
Debug.Print "After No Bus Net Name"
Debug.Print , ""
End If

186 NI AWR Design Environment


Working with Schematics

To set Wire Net Selected property use the following code:

Dim schem As Schematic


Dim wNet As WireNet

Set schem = Project.Schematics("SCH1")

Set wNet = schem.Wires(1).ParentNet

PrintWireSelectState schem, wNet, "Initial State"

wNet.Wires(1).Selected = True
PrintWireSelectState schem, wNet, "Set First Selected"

wNet.Wires(2).Selected = True
PrintWireSelectState schem, wNet, "Set Second Selected"

Sub PrintWireSelectState(ByRef schem As Schematic, ByRef wNet As WireNet, title As String)


Dim propCount As Integer
Dim objWire As WireSegment

Debug.Print title

' Test getting the selected state for each wire segment.
propCount = 0
For Each objWire In schem.Wires
If objWire.Selected Then
propCount = propCount + 1
End If
Next objWire

' Print our resulting counts.


Debug.Print "Selected Wires Prop Count = " & propCount
Debug.Print "Selected Wires Collection = " & schem.SelectedWires.Count
Debug.Print "WireNet Wires Count = " & wNet.Wires.Count
Debug.Print "Wires Collection Count = " & schem.Wires.Count

' Check that the prop count and the collection count agree.
If propCount = schem.SelectedWires.Count Then
Debug.Print "Prop Selected Count Matches Selected Wires Count"
Else
Debug.Print "Prop Selected Count Does Not Match Selected Wires Count"
End If

End Sub

The previous code is selecting wires through the SelectedWires collection using the Selected property from a segment
from a wire net

To print out each object's font size, use the following code:

Dim sch As Schematic


For Each sch In Project.Schematics
For i =1 To sch.DrawingShapes.Count

API Scripting Guide 187


Working with Schematics

If sch.DrawingShapes(i).Type = 5 Then
Debug.Print sch.DrawingShapes(i).Attributes(2).ValueAsString & ": " & sch.DrawingShapes(i).Attr
End If
Next i
Next sch

The following code demonstrates ElementVector Instance Access. The vector instance property isnt really part of the
parameters. It is an individual property but we allow editing it through the ID parameter on the element. Normally it is
edited through the Element Properties dialog Vector tab. So, this is the same property we are accessing through the
element.VectorInstanceName property in the API. You can set the VectorInstranceName property to the same values
that would go into this dialog. Here is the example code:

Dim schem As Schematic


Dim elem As Element
Debug.Clear
Set schem = Project.Schematics("Schematic 1")
Debug.Print schem.Name
Set elem = schem.Elements.Add("MLIN", 0, 0)
Debug.Print "Vect Inst Name Before = " & elem.VectorInstanceName
elem.VectorInstanceName = "[1:5]"
Debug.Print "Vect Inst Name After = " & elem.VectorInstanceName
Debug.Print "Drawing Object Count = " & elem.DrawingObjects.Count

This code generates the following output:

Schematic 1
Vect Inst Name Before = [0:3]
Vect Inst Name After = [1:5]
Drawing Object Count = 5

Associate the cell with the layout of the Schematic Element

You can create a cell for some element like inductor and associate created cell with the layout of inductor Element, for
example:

Dim Ele As Element


Dim cellName As String
Dim schName As String

noOfInductors = 1

' create GDSII Library


Set MyCellLib = Project.CellLibraries.Add("Inductors",mwCLT_GDSII)

' create schematic for EM extraction


schName = "My_IND"

Set schem = Project.Schematics.Add(schName)

Set Ele = schem.Elements.Add("IND",0,0,0,False,"")

' create each inductor in the GDSII library


' associate the new cell with the layout of the schematic inductor (IND) element
' use the extract process to update the EM document

188 NI AWR Design Environment


Working with Schematics

For n = 1 To noOfInductors
' create cell instance
Debug.Print "define cell name"
cellName = "IND_" + CStr(n)
Debug.Print "Create new cell: " + cellName
Set MyCell = MyCellLib.Cells.Add(cellName)

' define cell geometry there

' associate the new cell with the layout of the schematic inductor (IND) element
Ele.CellName = cellName
Next n

Changing the Symbol Associated with a Schematic Element

You can change the Symbol associated with a Schematic Element, for example:

Sub Main
Dim Schem As Schematic
Dim Ele As Element
Debug.Clear
Set Schem = Project.Schematics("Master")
Debug.Print Schem.Elements(1).Symbol
Schem.Elements(1).Symbol = ("C:\My6scripts\Symbol\customSymbols.syf")
Debug.Print Schem.Elements(1).Symbol
End Sub

This script generates the following output:

Resistor@SYSTEM.SYF
C:\My6scripts\Symbol\customSymbols.syf

To change the Symbol node LabelText, use the following code:

Dim sym_node AsSymbolNode


Set sym_node = symbolRecord.AddNode(x, y, tdx, tdy, tVis)
Sym_node.LabelText = "IN[0:3]"

Note:We allow schematic and system diagram symbols to have rotated text. Currently the rotation can only be specified
using the new API method AddText2. (Rotated text cannot yet be added through the symbol editor GUI.) We still display
the text in the schematic in only two orientations (left-to-right or bottom-to-top). After the rotation via API when drawing
text in the symbol editor,we display it at the specified angle and correctly calculate the bounding box.

To Set/Get Default Symbol Name on a Schematic, you can use the Schematic option that sets the name of the Schematic
symbol. For example, the following script sets the symbol name to MSTEP@system.syf:

Set schem = Project.Schematics("Schematic 1")


schem.Options("SchematicSymbolName").Value = "MSTEP@system.syf"

API Scripting Guide 189


Working with Schematics

Accessing Font attribute of text in schematic

You can access the Font attribute of text in schematic as in the following example:

' Code Module


Sub Main
Debug.Clear
Debug.Print Project.Schematics(1).DrawingShapes(1).Attributes("Font").Value

End Sub

The output will be:

Times New Roman

Rotating and Flipping Elements

To rotate an Element you must explicitly set the optional Angle parameter to a specified value as in the previous example.
You can omit the Angle parameter by default.

To flip the Element you must explicitly set the optional Flipped parameter to "True". You can omit the Flipped parameter
by default.

Enabling and Selecting Elements

To disable an Element, set the Enable property to "False". To select an Element, set the Selected property to "True". You
can use these settings, for example, to highlight a found Element after successfully searching a large Schematic, or all
Schematics in the Project.

Dim sch As Schematic


Dim sParName As String
Dim ele As Element
Dim par As parameter
sParName = "TL102"
For Each sch In Project.Schematics
For Each ele In sch.Elements
If ele.parameters.Count > 0 Then
Set par = ele.parameters(1)
If(par.ValueAsString = sParName) Then
Ele.Enabled = False
Debug.Print "Found it"
End if
End if
Next ele
Next sch

Editing Element Parameter Values

When working with Elements, you normally want to access the parameter values of each Element. Each parameter has
several properties, the most important of which are the parameter Name and ValueAsDouble, which returns the numeric
value.

190 NI AWR Design Environment


Working with Schematics

The following example demonstrates how to iterate through the collections of Elements and collection of parameters.

Dim ele As Element


Dim par As parameter
Dim sch As Schematic
Debug.Clear
Set sch = Project.Schematics("Filter")
For Each ele In sch.Elements
l=l+1
Debug.Print "Element ";l;": ";ele.Name;vbTab;"Symbol = ";ele.Symbol;
vbTab;ele.RotationAngle;vbTab;"x = ";ele.x;vbTab;"y = ";ele.y
If ele.parameters.Count > 0 Then
k = 0
For Each par In sch.Elements(l).parameters
k = k + 1
Debug.Print k;" : ";par.Name;vbTab;
par.ValueAsDouble;vbTab;par.ValueAsString
Next par
End If

API Scripting Guide 191


Working with Schematics

Debug.Print
Next ele

This code generates the following output:

Element 1: IND.L1 Symbol = Inductor@SYSTEM.SYF 0 x = -700 y = -300


1 : ID 0 L1
2 : L 0.00000002541 25.41
Element 2: CAP.C1 Symbol = Capacitor@SYSTEM.SYF 0 x = -1700 y = -300
1 : ID 0 C1
2 : C 3.988E-14 0.03988
Element 6: GND Symbol = Ground@SYSTEM.SYF 0 x = 300 y = 700
Element 8: PORT.P1 Symbol = Port@SYSTEM.SYF 0 x = -1700 y = -300
1 : P 1 1
2 : Z 50 50

Note that the value is returned in the default unit. In C1, the value is 0.03988 pF since the default unit in the Schematic
is set to "pF". As discussed previously, you can access default units via Project.Units. You can determine the capacitance
scale factor with the following statement:

Project.Units(mwUT_Capacitance).MultValue

You can also set parameter values:

Dim Z0 As Double
Dim g As Double
Dim ele As Element
Dim schem As Schematic
Dim p As parameter
Z0 = 50
g = 1
Set schem = Project.Schematics("Filter")
Set ele =schem.Elements.Add("PORT",dx*j,0,0)
ele.parameters("Z").ValueAsDouble=g*Z0
Set ele = schem.Elements.Add("CAP",dx,0,-90)
ele.parameters("C").ValueAsDouble= 2*g
Set ele =schem.Elements.Add("Res",0,0,0)
Set p = ele.parameters("R")
p.ValueAsString = "X"

This example sets parameter values for different Elements and demonstrates how to access the value of a parameter as
either a number (ValueAsDouble) or a string (ValueAsString).

If an Instance of a subcircuit is placed in a Schematic you must have inherited Connection access:

Dim schem As Schematic


Dim elem As Element
Dim param As parameter
Debug.Clear
Set schem = Project.Schematics("Schematic 2")
Debug.Print schem.Name
For Each elem In schem.Elements
Debug.Print elem.Name

192 NI AWR Design Environment


Working with Schematics

For Each param In elem.parameters


Debug.Print param.Name
If InStr(1, param.Name, "PCONN") <> 0 Then
param.ValueAsString = "Schematic 3"
End If
Next param
Next elem

This code generates the following output:

Schematic 2
SUBCKT.S1
ID
NET
M
PCONN1
PCONN2
PCONN3

Difference Between ValueAsDouble and ValueAsString

Element parameters accept a range of different types on the right side of the equal sign. These can be integers, enumerations,
doubles, equations, strings, or other. The right side of the equation is not always a valid double or even convertible to a
double value, however, a large percentage of the parameter values have a double value, so it is convenient to be able to
ask for the double value directly. The primary differences are:

"ValueAsString" gives you the literal text on the right side of the equation regardless of the type.
"ValueAsDouble" scales the value into base MKS units if the parameter value can be evaluated to a double value or
gives you zero otherwise.

The following script outputs the parameter values for the following Schematic:

API Scripting Guide 193


Working with Schematics

Sub Main
Dim schem As Schematic
Dim param As Parameter
Dim elem As Element
Debug.Clear
Set schem = Project.Schematics("MySchematic")
Set elem = schem.Elements(1)
For Each param In elem.Parameters
If (param.ParameterDefinition.DataType <> mwPDDT_DataModel And param.ParameterDefinition.DataTyp
Debug.Print param.Name & " Value As Double = " & param.ValueAsDouble & " Value As String = " & p
End If
Next param
End Sub

This script generates the following output:

ID Value As Double = 0 Value As String = TL1


W Value As Double = 0.00005 Value As String = W1 + 10
L Value As Double = 0.0005 Value As String = 500

The first line in the output gives the output for the ID parameter. The parameter ID has no double value equivalent, so
while ValueAsString is returned as TL1, the ValueAsDouble returned is zero.

The second line in the output gives the values for the width parameter. On the Schematic, the width parameter value is
derived from the equation W1 = 40. ValueAsString gives the equation string for the parameter. ValueAsDouble evaluates
the equation, scales the value from user units to base MKS units, and outputs the value in meters.

The third line in the output gives the values for the length parameter. Here ValueAsString gives the value 500, which is
the length value in user units of microns. ValueAsDouble scales the value to base MKS units and prints the length in
meters. Another key difference between the two regards setting the values for parameters. You can use ValueAsDouble
only to set the parameter to a double value, whereas you can use ValueAsString to set the parameter right-hand side
(RHS) text to any value. To set the width parameter to a different equation value you could use:

param.ValueAsString = "W1 + 15"

Displaying or Hiding an Element Parameter Object Using a Style Property

You can set the Style property for the Element parameter object to allow a display/hide parameter. The following script
demonstrates how to use the Style property to hide the variable name for all Elements of all Schematics in the Project.

' Code Module


Sub Main
Dim schem As Schematic
Dim elem As Element
Dim param As parameter
Debug.Clear
For Each schem In Project.Schematics
Debug.Print "Schematic = " & schem.Name
For Each elem In schem.Elements
Debug.Print "Element = " & elem.Name
For Each param In elem.parameters
Debug.Print "param = " & param.Name

194 NI AWR Design Environment


Working with Schematics

param.Style(mwPS_HideVarName) = mwPSS_SetStyle
Next param
Next elem
Next schem
End Sub

Accessing a complex value of Element Parameter

Element parameters can be complex. Use Parameter.ValuesAsComplex property on the parameter object to provide
access to complex parameter values. The following is an example of some code that can traverse the elements of a
schematic and produce values for double and complex parameter types:

' Code Module


Sub Main
Dim schem As Schematic
Dim elem As Element
Dim param As Parameter

Debug.Clear
For Each elem In Project.Schematics("Schematic 1").Elements
Debug.Print elem.Name
For Each param In elem.Parameters
Debug.Print "Param Name = " & param.Name
Debug.Print "Value as String = " & param.ValueAsString
If (param.ParameterDefinition.DataType = mwPDDT_Complex) Then
Debug.Print "Value as Complex = " & param.ValueAsComplex.Real & ", " & param.ValueAsComplex.Ima
Else
Debug.Print "Value as Double = " & param.ValueAsDouble
End If
Debug.Print

Next param
Next elem

End Sub

This script generates the following output:

PORT.P1
Param Name = P
Value as String = 1
Value as Double = 1

Param Name = Z
Value as String = z
Value as Complex = 50, 10

Param Name = PIN_ID


Value as String =
Value as Double = 0

API Scripting Guide 195


Working with Schematics

API operations on vector instances of an element.

Element parameters can be a vector. The first code shows how setting and unsetting the vector instance name on the
element will created/remove the vector instances in layout:

' Code Module


Sub Main
Dim lay As Layout
Dim schem As Schematic
Dim objDraw As DrawingObject
Dim ele As Element

Set schem = Project.Schematics("SCH1")


Set lay = schem.Layout
Set ele = schem.Elements("MLIN.TL1")

PrintDrawingObjectState ele, lay, "Before Change Vector Instance Name"

' Set the vector instance name to create 10 vector instances


ele.VectorInstanceName = "[0:9]"

PrintDrawingObjectState ele, lay, "After Change Vector Instance Name"

ele.VectorInstanceName = ""

PrintDrawingObjectState ele, lay, "After Reset Vector Instance Name"

End Sub

Sub PrintDrawingObjectState(ByRef ele As Element, ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject
Dim bnd As Boundary

Debug.Print title
Debug.Print "Element Name = " & ele.Name
Debug.Print "Element Vect Inst Name = " & ele.VectorInstanceName
Debug.Print "Element Vect Inst Count = " & ele.VectorInstanceCount

Debug.Print "Drawing Objects State: "


For Each objDraw In lay.DrawingObjects
If (objDraw.TypeBits = 256) Then
Set bnd = objDraw.Boundary
Debug.Print "Type = " & objDraw.TypeBits
Debug.Print "Boundary = { left = " & bnd.Left * 1e6 & ", top = " & bnd.Top * 1e6 & ", right = "
Debug.Print "Base Pos = { x = " & objDraw.BasePosition.x * 1e6 & ", y = " & objDraw.BasePosition
End If
Next objDraw
Debug.Print ""

End Sub

The second example of code shows how changing the vector instance name multiple times and then performing move
commands between the changes is handled correctly during undo:

196 NI AWR Design Environment


Working with Schematics

' Code Module


Sub Main
Dim lay As Layout
Dim schem As Schematic
Dim objDraw As DrawingObject
Dim ele As Element

Set schem = Project.Schematics("SCH1")


Set lay = schem.Layout
Set ele = schem.Elements("MLIN.TL1")

PrintDrawingObjectState ele, lay, "Before Change Vector Instance Name"

' Set the vector instance name to create 10 vector instances


ele.Parameters("ID").ValueAsString = "TL1[0:9]

PrintDrawingObjectState ele, lay, "After Change Vector Instance Name"

ele.Parameters("ID").ValueAsString = "TL1"

PrintDrawingObjectState ele, lay, "After Reset Vector Instance Name"

End Sub

See previous code for PrintDrawingObjectState ele, lay, "After Reset Vector Instance Name" subroutine

Accessing a Sweep Variable and Value

To access a Sweep Variable and Value, use the following script:

' Code Module


Sub Main
Dim schem As Schematic
Dim swpVar As SweepVariable
Dim swpVal As SweepValue
Debug.Clear
Set schem = Project.Schematics("Schematic 1")
Debug.Print schem.SweepVariables.Count
For Each swpVar In schem.SweepVariables
Debug.Print swpVar.Name
For Each swpVal In swpVar.Values
Debug.Print swpVal.ValueAsDouble & ", " & swpVal.ValueAsString
Next swpVal
Debug.Print
Next swpVar
End Sub

Determine the native type of a Element Parameter object

Each of the Element Parameters has a reference to an object called a ParameterDefinition. A ParameterDefinition is
associated with the model for the object and describes the attributes of the parameters that will be associated with elements
representing that model. So, each model includes an array of parameter definitions that act like templates for creating
the parameters associated with an Element representing the model. To get information about the type of the Parameter
object we need to look at the ParameterDefinition or template from which it was created. For example, let's create a script

API Scripting Guide 197


Working with Schematics

that adds a schematic, MLIN element to that schematic, and then prints some information about the parameters for that
element.

' Code Module


Sub Main
Dim schem As Schematic
Dim elem As Element
Dim param As Parameter
Dim paramDef As ParameterDefinition

Debug.Clear
Set schem = Project.Schematics.Add("MySchematic")
Set elem = schem.Elements.Add("MLIN", 0, 0)

For Each param In elem.Parameters


Debug.Print param.Name & " = " & param.ValueAsString;
Debug.Print " Data Type = " & param.ParameterDefinition.DataType
Next param

End Sub

If you run this program you can get the following output:

ID = TL1 Data Type = 4


W = 20 Data Type = 0
L = 200 Data Type = 0
MSUB = Data Type = 5

While this is useful and provides values for the data type it would be nicer if we had some enumerations. In the object
browser we can see that the ParameterDefinition.DataType is a property of type mwParamDefDataType which has the
following definition:

enum mwParamDefDataType
{
mwPDDT_Real,
mwPDDT_Complex,
mwPDDT_Integer,
mwPDDT_String,
mwPDDT_ElementName,
mwPDDT_DataModel,
mwPDDT_InfoString,
mwPDDT_None,
mwPDDT_Enumeration,
mwPDDT_RealVector,
mwPDDT_FileName
} mwParamDefDataType;

If you place a . after the DataType property in the scripting environment, the Intellisense shows parameter definition
types as a list of the possible values. This is useful if you want to control flow based on a specific data type, like printing

198 NI AWR Design Environment


Working with Schematics

only double values. If you want to print the data type you need to create a mapping function to map from the type value
to a string. A quick mapping function might look as follows:

Function ParameterDefTypeName(id As Integer) As String


Dim ret As String

Select Case id
Case mwPDDT_Real
ret = "mwPDDT_Real"
Case mwPDDT_Complex
ret = "mwPDDT_Complex"
Case mwPDDT_Integer
ret = "mwPDDT_Integer"
Case mwPDDT_String
ret = "mwPDDT_String"
Case mwPDDT_ElementName
ret = "mwPDDT_ElementName"
Case mwPDDT_DataModel
ret = "mwPDDT_DataModel"
Case mwPDDT_InfoString
ret = "mwPDDT_InfoString"
Case mwPDDT_None
ret = "mwPDDT_None"
Case mwPDDT_Enumeration
ret = "mwPDDT_Enumeration"
Case mwPDDT_RealVector
ret = "mwPDDT_RealVector"
Case mwPDDT_FileName
ret = "mwPDDT_FileName"
Case Default
ret = "Unkown"
End Select

ParameterDefTypeName = ret

End Function

And then you can use this in the main body of the code:

' Code Module


Sub Main
Dim schem As Schematic
Dim elem As Element
Dim param As Parameter
Dim paramDef As ParameterDefinition

Debug.Clear
Set schem = Project.Schematics.Add("MySchematic")
Set elem = schem.Elements.Add("MLIN", 0, 0)

For Each param In elem.Parameters


Debug.Print param.Name & " = " & param.ValueAsString;
Debug.Print " Data Type = " & ParameterDefTypeName(param.ParameterDefinition.DataType)
Next param

API Scripting Guide 199


Working with Schematics

End Sub

Which produces the following output:

ID = TL1 Data Type = mwPDDT_ElementName


W = 20 Data Type = mwPDDT_Real
L = 200 Data Type = mwPDDT_Real
MSUB = Data Type = mwPDDT_DataModel

So, the detailed type information about a parameter is available from the ParameterDefinition which acts as a template
to create the parameter when the Element is created and the parameter object includes a reference back to it's
ParameterDefinition object.

Accessing a "Secondary" Element Parameter Type

To filter hidden parameters out of the parameter list, use the following script:

' Code Module


Sub Main
Dim objMod As Model
Dim paramDef As parameterDefinition
Debug.Clear
Set objMod = Models("MTRACE")
Debug.Print objMod.Name
For Each paramDef In objMod.parameterDefinitions
If paramDef.DefinitionFlag(mwPDF_Secondary) Then
Debug.Print paramDef.Name & " <- Secondary"
Else
Debug.Print paramDef.Name
End If
Next paramDef
End Sub

To access Element display mode settings, use the following script:

' Code Module


Sub Main
Dim lay As Layout
Dim schem As Schematic
Dim elem As Element

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
Set schem = Project.Schematics("SCH1")

For Each elem In schem.Elements


Debug.Print elem.DisplayMode(mwDMT_ObjectMarked)
Debug.Print elem.DisplayMode(mwDMT_BuddySelected)
Debug.Print elem.DisplayMode(mwDMT_BuddyUnselected)
Next elem

1100 NI AWR Design Environment


Working with Schematics

End Sub

Accessing a complete set of Element Parameters

To access a complete set of Element Parameters, use the following script:

Sub Main
Dim schem As Schematic
Dim elem As Element
Dim elemNode As Node

Debug.Clear
Set schem = Project.Schematics("SCH1")

For Each elem In schem.Elements


PrintElementParameters(elem)
Debug.Print "----"
Debug.Print ""
Next elem

End Sub

Sub PrintElementParameters(ByRef elem As Element)


Dim param As Parameter

"Element = " & elem.Name


For Each param In elem.Parameters
Debug.Print " Param Name = " & param.Name
Debug.Print " Constrain = " & param.Constrain
Debug.Print " Description = " & param.Description
Debug.Print " Distribution = " & param.Distribution
Debug.Print " HasError = " & param.HasError
Debug.Print " Independent = " & param.Independent
Debug.Print " LowerConstraint = " & param.LowerConstraint
Debug.Print " Optimize = " & param.Optimize
Debug.Print " OptimizeYield = " & param.OptimizeYield
Debug.Print " ReadOnly = " & param.ReadOnly
Debug.Print " StatVariation = " & param.StatVariation
Debug.Print " StatVariation2 = " & param.StatVariation2
Debug.Print " StepSize = " & param.StepSize
Debug.Print " Style (Bold Font) = " & param.Style(mwPS_BoldFont)
Debug.Print " Style (Hide) = " & param.Style(mwPS_Hide)
Debug.Print " Style (Hide Empty) = " & param.Style(mwPS_Hide)
Debug.Print " Style (Hide Secondary)= " & param.Style(mwPS_HideIfSecondary)
Debug.Print " Style (Hide Units) = " & param.Style(mwPS_HideUnits)
Debug.Print " Style (Hide Var Name) = " & param.Style(mwPS_HideVarName)
Debug.Print " Style (Left Just) = " & param.Style(mwPS_LeftJustify)
Debug.Print " TolInPercent = " & param.TolInPercent
Debug.Print " Tune = " & param.Tune
Debug.Print " UnitType = " & param.UnitType
Debug.Print " UpperConstraint = " & param.UpperConstraint
Debug.Print " HasError = " & param.HasError
Debug.Print " ValueAsString = " & param.ValueAsString
Debug.Print ""

API Scripting Guide 1101


Working with Schematics

Next param

End Sub

Accessing an Element SPICE Model Extraction Settings

The following code sets the SPICE model extraction level for an Element. Note that for the Element value to be different
than the Project value, you need to use elem.UseDefaultModelOptions = false so that the individual element is allowed
to be different:

' Code Module


Sub Main
Dim elem As Element
Dim opt As Option

Debug.Clear
Set elem = Project.Schematics("Schematic 1").Elements(1)

For Each opt In elem.Options


Debug.Print opt.Name & ", " & opt.Value
Next opt

elem.UseDefaultModelOptions = False

elem.Options("SpiceModelLevel").Value = 2

End Sub

Accessing the Element Options Collection

To access the Element Options collection, use the following code:

Dim sch As Schematic


Dim ele As Element
Set sch = Project.Schematics(1)
Set ele = sch.Elements(1)
Debug.Print ele.Options.Count
Debug.Print ele.Options(1).Name;vbTab;ele.Options(2).Name

Enabling EM Extraction through API Element Options Collection

To enable EM Extraction, use the following code:

Dim sch As Schematic


Dim el as Element
Set sch = Project.Schematics(1)
Set el = sch.Elements(1)
el.Options("ExtractModelType").Value = 1

Accessing the Element Properties Collection

To access the Element Properties collection, use the following script:

Option Explicit

1102 NI AWR Design Environment


Working with Schematics

Sub Main
Debug.Clear
Dim e As Element
Dim s As Schematic
Set s = Project.Schematics(1)
Dim i As Integer
For Each e In s.Elements
Debug.Print e.Name
For i = 1 To e.Properties.Count
Debug.Print e.Properties(i).Name & vbTab & e.Properties(i).Value
Next i
Next e
End Sub

This script generates the following output:

PORT.P1
EM_Extract_Group EM_Extract
EM_Extract_Tool
PartNumber
PartHelpPath
XmlPath
PORT.P2
EM_Extract_Group EM_Extract
EM_Extract_Tool
PartNumber
PartHelpPath
XmlPath
PORT.P3
EM_Extract_Group EM_Extract
EM_Extract_Tool
PartNumber
PartHelpPath
XmlPath
PORT.P4
EM_Extract_Group EM_Extract
EM_Extract_Tool
PartNumber
PartHelpPath
XmlPath

API supports default value property for properties associated with a schematic element to the Property object. API
provides a read-only DefaultValue property that is populated with the default options for an element to provide access
to the original default value. For all properties if the default value is not available the current regular value is returned
as the default value. This can be used usually to check the simulator option values through EXTRACT block element
properties. If the value is non-default, we can reset it back to default via API. So we can add this to the code in previous
example:

Debug.Print e.Properties(i).Name & vbTab & e.Properties(i).Value & vbTab &e.Properties(i).Defau

API supports parameterized XML elements specified by data file elements that also include parameterized values. We
expand the types of files that can be used to specify the model and still include the possibility of parameterization. Make
the recursive add XML component call for additional model file data types as well.

API Scripting Guide 1103


Working with Schematics

The following script loops through properties and looks for the xmlPaths:

' Code Module


Sub Main
Dim prop As Property
Dim ele As Element
Dim sch As Schematic
Dim xmlFile As String
Dim xmlFolderPath As String
Dim xmlCompPath As String
Dim xmlPath As String

Debug.Clear

For Each sch In Project.Schematics


For Each ele In sch.Elements
Debug.Print "-----------------------------------------------------------------------"
Debug.Print ele.Name
For Each prop In ele.Properties
If prop.Name = "XmlFile" Then
xmlFile = prop.Value
If xmlFile = "" Then Debug.Print "xmlFile: Nothing"
If xmlFile ne "" Then Debug.Print "xmlFile: " & prop.Value
ElseIf prop.Name = "XmlFolderPath" Then
xmlFolderPath = prop.Value
If xmlFolderPath = "" Then Debug.Print "xmlFolderPath: Nothing"
If xmlFolderPath ne "" Then Debug.Print "xmlFolderPath: " & prop.Value
ElseIf prop.Name = "XmlCompPath" Then
xmlCompPath = prop.Value
If xmlCompPath = "" Then Debug.Print "xmlCompPath: Nothing"
If xmlCompPath ne "" Then Debug.Print "xmlCompPath: " & prop.Value
ElseIf prop.Name = "XmlPath" Then
xmlPath = prop.Value
If xmlPath = "" Then Debug.Print "XmlPath: Nothing"
If xmlPath ne "" Then Debug.Print "XmlPath: " & prop.Value
End If
Next
Next
Next

End Sub

To change the De-Embedding Method property for AXIEM Async, use the following code:

' Project Module

Private Sub Project_Open()


Dim sch As Schematic
Dim ele As Element

Project.Simulator.Analyze
Debug.Clear

Set sch = Project.Schematics("Schematic 1")

1104 NI AWR Design Environment


Working with Schematics

Set ele = sch.Elements("EXTRACT.EX1")

'Debug.Print "De-embedding Before Change: "; ele.Properties("AXIEM Async:eDeEmbeddingMethod").Valu

ele.Properties("AXIEM Async:UseDefault").Value = True

'Debug.Print "De-embedding After Change: "; ele.Properties("AXIEM Async:eDeEmbeddingMethod").Value

End Sub

By enumerating the properties (Element.Properties), you can access useful properties such as EM_Extract_Group for
iNets. This is sort of confusing having Options, Parameters and Properties on an Element. The Parameters and Options
collections have a fixed set of entries which can be set or retrieved but the Properties collection has a slightly different
use model. The Properties collection provides a collection into which properties can be added. So, basically it's like the
Properties collection allows you to associate properties with specific names onto an element which others can look for
later to see if something has a specific property. What this means is that if an object doesn't have a specific property that
you want to set, what you need to do is add the property, it also takes a default value when you add it so you can set it
while adding it. If the object has the property and it not at the value you want then you can change it. For example, the
following code checks to see if the property "EM_Extract_Group" exists on the element. If this check returns False then
it adds the property and in this case it is the default "EM_Extract" , so, that it will be changed later and we can see that
it gets changed:

' Code Module


Sub Main

Debug.Clear

Project.Schematics(1).Elements(1).Options("ExtractModelType").Value = 1

' If the property doesn't exist then add it.


If Project.Schematics(1).Elements(1).Properties.Exists("EM_Extract_Group") = False Then
Project.Schematics(1).Elements(1).Properties.Add("EM_Extract_Group", "EM_Extract")
End If

' Should have the property at this point.


Project.Schematics(1).Elements(1).Properties("EM_Extract_Group").Value = "OK"

End Sub

This script changes the value to "OK" on the first run, without the need to manually edit the value first. What happens
when you edit it and change it from the system default is that the property is created. Here in script we are doing the
same thing, we are creating the property.

You can also access the User Attributes property. See Adding User Attributes in XML Files for more information.

The following example shows API access to the first user attribute of Name=Cost, and Value=$20:

Debug.Print Project.Schematics(1).Elements(1).Properties(1).Name ' This will display "User:Cost"

Debug.Print Project.Schematics(1).Elements(1).Properties(1).Value 'This will display "$20"

You can add a user attribute through the API. Note that you need to include "User:" in the command to add the user
attributes correctly. The following example adds a user attribute of Name=Person, Value=Ideen:

API Scripting Guide 1105


Working with Schematics

Set ele=Project.Schematics(1).Elements(1)
ele.Properties.Add("User:Person","Ideen")

You can delete the same user attributes as follows:

ele.Properties.Remove("User:Person")

The following code example takes the partnumbers for each element and assigns them as user attributes for the same
part:

Dim ele As Element


Dim sch As Schematic
For Each sch In Project.Schematics
For Each ele In sch.Elements
If ele.PartNumber="" Then

Else
ele.Properties.Add("User:Partnumber",ele.PartNumber)

End If
Next ele
Next sch

We have API access to User Attributes via the 'Properties' collection to Schematics, System diagrams, and EM structures
:

' Code Module


Sub Main
Dim sch As Schematic
Dim sys As SystemDiagram
Dim ems As EMStructure
Dim ele As Element
Dim prop As Property
Debug.Clear

Project.EMStructures(1).Export("User_attr_test_Interdigital Filter")
Set ems = Project.EMStructures.Import(Project.Path + "User_attr_test_Interdigital Filter.EML")
Debug.Print "EMStructure Name = ";ems.Name
For Each prop In ems.Properties
If InStr(prop.Name,"EM Layer 2") Then
Select Case Replace(prop.Name,"User:","")
Case "EM Layer 2"
Debug.Print "EM Layer 2 = ";prop.Value
End Select
End If
Next prop

Project.Schematics(1).Export(Project.Path + "User_attr_test_sch",mwSEF_MWOSchematicFile)
Set sch = Project.Schematics.Import("User_attr_test_sch",Project.Path + "User_attr_test_sch.sch")
Debug.Print "Schematic Name = ";sch.Name

1106 NI AWR Design Environment


Working with Schematics

For Each prop In sch.Properties

Select Case Replace(prop.Name,"User:","")


Case "MSUB"
Debug.Print "Cost = ";prop.Value
Case "STACKUP"
Debug.Print "STACKUP = ";prop.Value
Case "Wire"
Debug.Print "Wire = ";prop.Value
End Select

Next prop

Project.SystemDiagrams(1).Export(Project.Path + "User_attr_test_sys",mwSYF_MWOSystemFile)
Set sys = Project.SystemDiagrams.Import("User_attr_test_sys",Project.Path + "User_attr_test_sys.sy

Debug.Print "System Diagram Name = ";sys.Name

For Each prop In sys.Properties


Select Case Replace(prop.Name,"User:","")
Case "NOISE"
Debug.Print "NOISE = ";prop.Value
Case "Cost"
Debug.Print "Cost = ";prop.Value
End Select

Next prop

End Sub

Using Variables and Equations for Parameter Values

The NI AWR SDE API allows you to reference a variable in an Element parameter by specifying the variable name as
its new value. After making this reference you need to define the variable by creating equations for the Schematic. See
Variables And Equations for more information.

To add a referenced Equation to schematic use the following code:

' Add three equations each one references the previous.


schem.Equations.Add2("X=5", 0, 0)
schem.Equations.Add2("Y=X", 0, 100)
schem.Equations.Add2("Z=Y", 0, 200)

To access Equation subexpression use the following code:

Dim schem As Schematic


Dim eqn As Equation
Dim expr As EquationExpression

Debug.Clear
Set schem = Project.Schematics("SCH1")
For Each eqn In schem.Equations

API Scripting Guide 1107


Working with Schematics

For i = 1 To eqn.NumSubexpressions
Debug.Print eqn.Subexpression(i)
Next i
Next eqn

To access the Equation by variable name use the following code:

' Remove three equations.


schem.Equations.Remove("X")
schem.Equations.Remove("Y")
schem.Equations.Remove("Z")

API provides methods for obtaining equation expression values which are of type Real, String, and Array and located
in Schematic or Layout:

Sub Main
Dim schem As Schematic
Dim eqn As Equation
Dim expr As EquationExpression

Debug.Clear
Set schem = Project.Schematics("SCH1")
For Each eqn In schem.Equations
For Each expr In eqn.Expressions
PrintExpressionValue expr
Next expr
Next eqn

End Sub

Sub PrintExpressionValue(ByRef expr As EquationExpression)

Debug.Print expr.Expression
If (expr.DataType = mwEDT_Real) Then
Debug.Print "Real Value = " & expr.ValueAsDouble
End If

If (expr.DataType = mwEDT_String Or expr.DataType = mwEDT_Real Or expr.DataType = mwEDT_RealVecto


Debug.Print "String Value = " & expr.ValueAsString
End If

If (expr.DataType = mwEDT_Complex Or expr.DataType = mwEDT_Real) Then


Debug.Print "Complex Value = { Re = " & expr.ValueAsComplex.Real & ", Imag = " & expr.ValueAsCom
End If

If (expr.DataType = mwEDT_RealVector) Then


Debug.Print "Vector Values = ";
For i = LBound(expr.ValueAsDoubleVector) To UBound(expr.ValueAsDoubleVector)
Debug.Print expr.ValueAsDoubleVector(i) & ", ";
Next i
Debug.Print ""
End If

1108 NI AWR Design Environment


Working with Schematics

Debug.Print

End Sub

Adding a Subcircuit to a Schematic

Subcircuit allows you to include a circuit block within a Schematic. The circuit block can be a Schematic (as in the
following example), a Netlist, a DataFile, or an EMStructure.

Importing DataFiles Describing Subcircuits

To import a DataFile for use as subcircuit in a Schematic, see Working with Data Files. Once added, the DataFile
displays in the Element Browser under the Subcircuits category. Only after this step can you place a Subcircuit into
Schematic. You have access to the Data File Options at the Document level. Changing values at this level requires you
to set "DataFile.UseProjectOptions" to "False".

Project.DataFiles("mdif_loc").Options("EnableInterpolation").Value=True

Adding Subcircuit Elements

The Subcircuit collection is added to the Schematic for Subcircuits, Ports, NamedConnectors and Electrical Nets, and
to the Subsystems collections also for Subsystems and Ports.

Each Subcircuit has a NET parameter that names the Schematic that is the Subcircuit, although it might be a Data File
also. To access the Elements inside, you do not need to go through all of the Schematics. You can get the NET parameter
and use it as an index into the Schematics collection to get the Schematic, and then go through the Elements of the
Schematic. A Subcircuit is really just an Element that references another Schematic. The Element has a Parameters
collection; in that collection is a parameter named NET, the value of which is the name of a Schematic or Data File being
used as the Subcircuit. The Schematics collection can take a string name as the index, so you can go directly from the
value of the NET parameter to the Schematic the Subcircuit represents. This is the way the software works for simulation.
The NET parameter defines the Schematic to use to simulate the Subcircuit.

In addition, all the collections in the system now have methods that should help in quickly testing if a NET value is a
Data File, Schematic, or EM structure.

To place a Subcircuit in a Schematic use the AddSubcircuit() method:

Option Explicit
' Code Module
Sub Main
Dim s As Schematic
Dim s_Top As Schematic
Dim y As Double
y = 0
Set s_Top = Project.Schematics("Test Schematics")
For Each s In Project.Schematics
If s.Name <> s_Top.Name Then
Debug.Print s.Name & " " & s.Elements.Count
s.Elements.Add("PORT",0,0)
s_Top.Elements.AddSubcircuit(s.Name,0,y)
y = y + 500
End If

API Scripting Guide 1109


Working with Schematics

Next s
End Sub

One more example of placing a Subcircuit in a Schematic using the AddSubcircuit() method. In the code we rotating
Subcirquit:

Dim schem1 As Schematic


Dim schem2 As Schematic
Dim elem As Element

Debug.Clear
Set schem1 = Project.Schematics("SCH1")
Set elem = schem1.Elements("MLIN.TL3")

schem1.Elements.AddSubcircuit("SCH2", elem.Nodes(1).x, elem.Nodes(1).y, 180)


schem1.Elements.AddSubcircuit("SCH2", elem.Nodes(2).x, elem.Nodes(2).y)

After placing the Subcircuit, you can edit the Subcircuit parameter values (you can edit any Schematic Element parameter
value and change the position of the parameter Frame).

The following example lists all Subcircuit parameters:

I=0
Set CurrentSchm = Project.Schematics(schIndex)
For Each elem In CurrentSchm.Elements
If elem.Enabled = True Then
If Left(elem.Name,6) = "SUBCKT" Then
For Each par in elem.parameters
I = I + 1
y =elem.parameters(I).ValueAsString
Debug.Print y
Next par
End If
End If
Next elem

Sometimes when we add element to Subcircuit the element is added not in a position to connect to the nodes of the
subcircuit. The following example is the script that uses the element and gets the position of the node we want to hit
when adding the ground:

' Code Module


Sub Main
Dim schem As Schematic
Dim elem As Element

Set schem = Project.Schematics("Schematic 1")


Set elem = schem.Elements("SUBCKT.S1")

schem.Elements.Add("GND", elem.Nodes(3).x, elem.Nodes(3).y) End Sub


End Sub

Here we are using the position of the element node to provide the coordinates for the placement of the GND element.

1110 NI AWR Design Environment


Working with Schematics

Updating a Schematic Subcircuit Instance

If you add a port to Schematic "a", which is included in Subcircuit "b", you must update the Subcircuit instances in
Schematic "b".

The following code adds a Port to Schematic "a" and then updates the Subcircuit instances in Schematic "b". Note that
you need to select the Subcircuit instances before invoking the command.

Dim s, sc As Schematic
Dim e As Element
Dim g As Graph
Set s = Project.Schematics("a")

API Scripting Guide 1111


Working with Schematics

For Each e In s.Elements


If (InStr(e.Name,"MLIN")) Then
s.Elements.Add("PORT",e.Nodes(2).x,e.Nodes(2).y,180)
End If
Next e

Set s = Project.Schematics("b")

For Each e In s.Subcircuits


s.SelectedElements.Add(e)
Next e
s.InvokeCommand("UpdateInstance")

Set sc = Project.Schematics("b")

For Each e In sc.Elements


If (InStr(e.Name,"SUBCKT.S1")) Then
sc.Elements.Add("PORT",e.Nodes(1).x,e.Nodes(1).y,0)
sc.Elements.Add("PORT",e.Nodes(2).x,e.Nodes(2).y,180)
End If
Next e

Processing Schematic Hierarchy

For some applications you might need to set a top level Schematic and then find all objects in all Schematics below it:

' Code Module


Sub Main
Dim sch As Schematic
Debug.Clear
Set sch = Project.Schematics("top")
process_hierarchy(sch)
End Sub
Function process_hierarchy(s As Schematic)
Dim ele As Element
Dim ns As Schematic
Debug.Print "Schematic = " & s.Name
For Each ele In s.Elements
Debug.Print vbTab & "Element = " & ele.Name
If InStr(ele.Name,"SUBCKT") Then
nt = Mid(ele.Parameters(2).ValueAsString,2,Len(ele.Parameters(2).ValueAsString)-2)
End If
End If
Next ele
End Function

This works by recursively calling the same function, called "process_hierarchy" in this case. The script works by setting
a top level Schematic and then calling the function and passing the Schematic into the function. In the function, it looks
at all Elements. If they are a Subcircuit, it determines if the Subcircuit net refers to a Schematic (since it could be a
Netlist, S-parameter file, or EM structure, etc.). If it is a Schematic, the process hierarchy function is called again with
the new Schematic object.

This example of processing hierarchy uses the Schematic.Subcircuits collection to find all of the .SUBCKT Elements:

1112 NI AWR Design Environment


Working with Schematics

Function ProcessHierarchy(ByRef s As Schematic) As Boolean


Dim e As Element
For Each e in s.Elements
'do stuff
Next e
Dim subName as String
For Each e In s.Subcircuits
subName = Replace(e.Parameters("NET").ValueAsString, """", "")
If Project.Schematics.Exists(subName) Then
ProcessHierarchy(Project.Schematics(subName))
End If
Next e
End Function

Accessing Parameter Definition Properties

To print the parameter definition and get the flag determining whether the parameter affects Layout, use the following
script. Note that on the parameter of the Subcircuit it prints TRUE if the parameter affects the Layout:

Sub Main
Dim schem As Schematic
Sub Main
Dim schem As Schematic
Dim elem As Element
Dim param As Parameter
Dim def As ParameterDefinition

Debug.Clear
Set schem = Project.Schematics("top")

For Each elem In schem.Elements


Debug.Print "Element = " & elem.Name
For Each param In elem.Parameters

Set def = param.ParameterDefinition


Debug.Print " Param Name = " & param.Name
Debug.Print " Affects Layout = " & def.DefinitionFlag (mwPDF_NoAffectLayout)
Next param
Next elem
End Sub

To get and set the AffectsLayout property using the Equation object, use the following script:

Sub Main
Dim schem As Schematic
Dim eqn As Equation
Debug.Clear
Set schem = Project.Schematics("sub")
For Each eqn In schem.Equations
Debug.Print "Variable Type = " & eqn.VariableType
Debug.Print "Affects Layout = " & eqn.AffectsLayout
If eqn.AffectsLayout Then
eqn.AffectsLayout = False

API Scripting Guide 1113


Working with Schematics

End If
Next eqn
End Sub

Adding Wires to a Schematic


After you put Elements into a Schematic you need to connect Element nodes with a wire. If you know the nodes locations
you can directly attach wires:

Sub Main
Debug.Clear
Dim schem As Schematic
Set schem = Project.Schematics.Add("Master")
schem.Elements.Add("Res",0,0,0)
schem.Elements.Add("Res",2000,0,0)
Dim w As WireSegment
Dim ww As WireSegment
Dim ntw As WireSegment
Set w = schem.Wires.Add(1000,0,1000,1000)
Set w = schem.Wires.Add(1000,1000,2000,1000)
Set w = schem.Wires.Add(2000,1000,2000,0)
Set ww = schem.Wires.Add(1000,0,1000,-1000)
Set ww= schem.Wires.Add(1000,-1000,3000,-1000)
Set ww = schem.Wires.Add(3000,-1000,3000,0)
schem.Wires.Cleanup
Debug.Print "Count = ";schem.Wires.Count
For Each w In schem.Wires
Debug.Print "x1 = ";w.x1;vbTab;"y1 = ";w.y1;vbTab;"x2 = ";w.x2;vbTab;
"y2 = "; w.y2
Next w
End Sub

This script generates the following output:

Count = 6
x1 = 1000 y1 = 0 x2 = 1000 y2 = 1000
x1 = 1000 y1 = 1000 x2 = 2000 y2 = 1000
x1 = 2000 y1 = 1000 x2 = 2000 y2 = 0
x1 = 1000 y1 = 0 x2 = 1000 y2 = -1000
x1 = 1000 y1 = -1000 x2 = 3000 y2 = -1000
x1 = 3000 y1 = -1000 x2 = 3000 y2 = 0

Notice that when printing wires coordinates you just iterate through the Wire collection. At the end of the script is a line
"schem.Wires.Cleanup" method. The call to the Cleanup method should cause the wire to connect properly.

NOTE: Hierarchical updates are not the same through the user interface (UI) as they are in the API. The UI typically
has complete connections, whereas in the API you can enter the segment pieces until the connection is complete. The
benefit is that when a wire is added it is not clear that the connectivity is complete (there may be additional wires needed).
As a result, you need to add one additional line after all the wiring changes are complete:

sch.UpdateConnectivity

1114 NI AWR Design Environment


Working with Schematics

You do not need to clean up the wires because when added through the API they are added a segment at a time, so until
all segments are added there are dangling segments. The API uses a method on the wires collection to trigger a recondition
call that cleans-up the wires:

Dim schem As Schematic


Dim elem1 As Element
Dim elem2 As Element
Dim wiresBefore As Integer
Dim wiresAfter As Integer

Set schem = Project.Schematics("SCH1")


Set elem1 = schem.Elements("MLIN.TL1")
Set elem2 = schem.Elements("MLIN.TL2")

wiresBefore = schem.Wires.Count

' Add a wire connecting the elements.


schem.Wires.Add(elem1.Nodes(2).x, elem1.Nodes(2).y, elem2.Nodes(1).x, elem2.Nodes(1).y)

' Add a dangling wire.


schem.Wires.Add(elem2.Nodes(1).x, elem2.Nodes(1).y, elem2.Nodes(1).x, elem2.Nodes(1).y - 1000)

wiresAfter = schem.Wires.Count

' Clean up the dangling wire.


schem.Wires.Cleanup

wiresAfterClean = schem.Wires.Count

Debug.Print "Wires Before = " & wiresBefore


Debug.Print "Wires After = " & wiresAfter
Debug.Print "Wires After Clean = " & wiresAfterClean

API supports WireSegments() collection of objects. NI AWR SDE provides Delete() method on the wire segment, which
can be called on a wire segment to delete it. NI AWR SDE also provides a Remove(Index) type call on the Wires
collection, which can be used to remove a segment from the collection by index, and methods for the x and y coordinates
of wire segment ends in the schematic api. We had methods for getting and setting the values, which can be used to move
the location of a wire endd:

' Code Module


Sub Main
Dim schem As Schematic
Dim wireSeg As WireSegment

Set schem = Project.Schematics("SCH1")


For Each wireSeg In schem.Wires
Debug.Print "x1 = " & wireSeg.x1 & ", ";
Debug.Print "y1 = " & wireSeg.y1 & ", ";
Debug.Print "x2 = " & wireSeg.x2 & ", ";
Debug.Print "y2 = " & wireSeg.y2

Next wireSeg

API Scripting Guide 1115


Working with Schematics

schem.Wires(1).x2 = schem.Wires(1).x2 + 100e-6


End Sub

You can print out the connection counts for the ends of wire segments in a case to see if segments are connected:

For Each ws In schem.Wires


Debug.Print "Wire Segment " & index & " :"
Debug.Print "Num Connected Node 1 = " & ws.NumConnected1
Debug.Print "Num Connected Node 2 = " & ws.NumConnected2
Debug.Print ""
index = index + 1
Next ws

Working with the Nodes Collection

If node coordinates are unknown in advance, you need to obtain them from the Elements of the Schematic. Before getting
the node numbers from the Elements you must call SetupConnectivity.

SetupConnectivity ensures that the connectivity for the Elements of a Schematic is set up and consistent; this is, the node
numbers are set. In Netlist terms this means that all of the Elements connected to a given node have the same node
number.

The same is true for NI AWR SDE Schematics; all the Element nodes that are wired together have the same node number.
The call to SetupConnectivity causes this numbering to occur and establishes the node numbers for the Element nodes.
Getting the node numbers from the Schematic Elements is helpful when translating a Schematic into a netlist.

Ideally, you want the system to know when you make a call that requires the connectivity to be set up and just do it for
you, however this means that for each call to get the information off of each node, the system needs to check that the
connectivity is set up. For efficiency, the system provides a way for you to do so at the beginning.

The following example is a script that goes through the Schematics and the Schematic Elements and the nodes, and
outputs the information for each node. When it gets the Schematic from the Project, the first thing it does is call to set
up the connectivity. It is difficult to see, but when it runs on a Schematic all the Elements nodes connected together have
the same node number.

' Code Module


Sub Main
Dim objNode As Node
Dim objElem As Element
Dim objSchem As Schematic
Dim index As Integer
Debug.Clear
' Get a reference to our schematic.
For Each objSchem In Project.Schematics
Debug.Print "Processing Schematic " & objSchem.Name
' Setup the connectivity so the node numbers are established.
objSchem.SetupConnectivity
' For Each element
For Each objElem In objSchem.Elements
Debug.Print "Processing Nodes for " & objElem.Name
' Output the node information for this element.
index = 1

1116 NI AWR Design Environment


Working with Schematics

For Each objNode In objElem.Nodes


Debug.Print "Node Index = " & index
Debug.Print "Node Number = " & objNode.NodeNumber
Debug.Print "Port Number = " & objNode.PortNumber
Debug.Print "Node x = " & objNode.x
Debug.Print "Node y = " & objNode.y
index = index + 1
Debug.Print
Next objNode
Debug.Print
Next objElem
Next objSchem
End Sub

This script generates the following output:

Processing Schematic Master


Processing Nodes for RES.R1
Node Index = 1
Node Number = 2
Port Number = 0
Node x = 0
Node y = 0
Node Index = 2
Node Number = 1
Port Number = 0
Node x = 1000
Node y = 0
Processing Nodes for RES.R2
Node Index = 1
Node Number = 1
Port Number = 0
Node x = 2000
Node y = 0
Node Index = 2
Node Number = 1
Port Number = 0
Node x = 3000
Node y = 0

The following script uses basic functionality for accessing the elements of the nodes collection on the wire segments of
a schematic. The script reads the property values for each node on each wire segment of a schematic with multiple wire
nets and outputs the values:

Dim schem As Schematic


Dim ws As WireSegment

Set schem = Project.Schematics("SCH1")

For Each ws In schem.Wires


PrintSegmentNodes(ws)
Next ws

Sub PrintSegmentNodes(ByRef ws As WireSegment)


Dim nd As Node

API Scripting Guide 1117


Working with Schematics

Dim index As Integer

Debug.Print "Nodes for Wire Segment From {x = " & ws.x1 & ", y = " & ws.y1 & "} to { x = " & ws.x2
index = 1
For Each nd In ws.Nodes
Debug.Print "Node[" & index & "]:"
Debug.Print "Connected = " & nd.Connected
Debug.Print "NodeNumber = " & nd.NodeNumber
Debug.Print "PortNumber = " & nd.PortNumber
Debug.Print "Type = " & nd.Type
Debug.Print "x = " & nd.x
Debug.Print "y = " & nd.y
index = index + 1
Next nd

Debug.Print ""

The following is the example of the output:

Nodes for Wire Segment From {x = -1200, y = -100} to { x = -500, y = -100 }


Node[1]:
Connected = True
NodeNumber = 1
PortNumber = 0
Type = 0
x = -1200
y = -100
Node[2]:
Connected = True
NodeNumber = 1
PortNumber = 0
Type = 0
x = -500
y = -100

Nodes for Wire Segment From {x = -500, y = -100} to { x = 300, y = -100 }


Node[1]:
Connected = True
NodeNumber = 1
PortNumber = 0
Type = 0
x = -500
y = -100
Node[2]:
Connected = True
NodeNumber = 1
PortNumber = 0
Type = 0
x = 300
y = -100

Nodes for Wire Segment From {x = -500, y = -100} to { x = -500, y = 900 }


Node[1]:
Connected = True
NodeNumber = 1
PortNumber = 0

1118 NI AWR Design Environment


Working with Schematics

Type = 0
x = -500
y = -100
Node[2]:
Connected = True
NodeNumber = 1
PortNumber = 0
Type = 0
x = -500
y = 900

Working with the ElectricalNets Collection

To work with the ElectricalNets collection of objects and print all property values for the ElectricalNet parameters to
the Debug window, use the following script:

' Code Module


Sub Main
Debug.Clear
Dim sch As Schematic
Dim en As Element
Dim pr As parameter
For Each sch In Project.Schematics
Debug.Print sch.Name
Debug.Print "ElectricalNets.Count = :";sch.ElectricalNets.Count
For Each en In sch.ElectricalNets
Debug.Print en.Name
For Each pr In en.parameters
Debug.Print pr.Name
Debug.Print pr.Constrain;vbTab;pr.Description;vbTab;pr.Distribution
Debug.Print pr.LowerConstraint;vbTab;pr.UpperConstraint;vbTab;pr.Optimize;vbTab;pr.OptimizeYiel
Debug.Print pr.ReadOnly ;vbTab;pr.StatVariation;vbTab;pr.Style(mwPS_BoldFont);vbTab;pr.TolInPe
Debug.Print pr.Tune;vbTab;pr.UnitType;vbTab;pr.UseStatistics;vbTab;pr.ValueAsString ';vbTab;pr
Debug.Print
Next pr
Next en
Debug.Print
Next sch
Set en = Project.Schematics(1).ElectricalNets(1)
For Each pr In en.parameters
Debug.Print pr.Name
Debug.Print pr.Constrain
pr.Constrain = Not pr.Constrain
Debug.Print "After changing: ";pr.Constrain
Next pr
Debug.Print pr.Name
End Sub

Implementations for the Add() and RemoveAll methods in the WireNet, Wires collection.

These methods allow you to remove all the wire segments associated with a wire net. We have problems if we allow the
segments to be deleted one by one as the wire cleanup code gets out of sync with what the API is doing but if we do a
whole wire net at a time it works fine as we can remove all the segments in the net before trying to clean up the connectivity.
The wirenet is the parent for all wire segments within a single connection, this allows the removal of all the wire segments
associated with a single connection node with something like the following:

API Scripting Guide 1119


Working with Schematics

' Code Module


Sub Main
Dim schem As Schematic
Dim wireSeg As WireSegment
Dim parentNet As WireNet

Set schem = Project.Schematics("Schematic 1")


Set wireSeg = schem.Wires(1) ` Find the segment somehow (maybe by xy node location)
Set parentNet = wireSeg.ParentNet
parentNet.Wires.RemoveAll

End Sub

The following code locates a specific wire net by the node position of a segment. Gets the parent net for the segment
and then removes all the wires in that wire net. The code includes some additional wires in different nets and the count
change is check to ensure that we just removed the wires associated with the wire net and not all wires:

' Code Module


Sub Main
Dim schem As Schematic
Dim wireSeg As WireSegment
Dim targetSeg As WireSegment
Dim bFound As Boolean
Dim wiresBefore As Integer
Dim wiresAfter As Integer

Set schem = Project.Schematics("SCH1")

bFound = False
For Each wireSeg In schem.Wires
If (wireSeg.x1 = -500 And wireSeg.y1 = -100) Then
Set targetSeg = wireSeg
bFound = True
End If
Next wireSeg

wiresBefore = schem.Wires.Count

' Delete the wires associated with a single wire net.


If bFound Then
targetSeg.ParentNet.Wires.RemoveAll
End If

wiresAfter = schem.Wires.Count

Debug.Print "Wires Before = " & wiresBefore


Debug.Print "Wires After = " & wiresAfter
End Sub

The following code verifies that adding a wire to the wires collection associated with a particular wire net works correctly:

Set schem = Project.Schematics("SCH1")

1120 NI AWR Design Environment


Working with Schematics

Set elem1 = schem.Elements("MLIN.TL1")


Set elem2 = schem.Elements("MLIN.TL2")

wiresBefore = schem.Wires.Count

' Add a wire connecting the elements.


schem.Wires.Add(elem1.Nodes(2).x, elem1.Nodes(2).y, elem2.Nodes(1).x, elem2.Nodes(1).y)

wiresAfter = schem.Wires.Count

API highlight improvements.

We added a support for controlling net highlight through the wire net objects associated with a schematic. This makes
it easier to highlight the wires associated with a particular node of an element on the schematic side. The highlight also
pertains to the physical net and so highlights objects associated with the physical net in layout.

The first example shows how to highlight cross probing between wire nets and associated physical nets:

' Code Module


Sub Main
Dim schem As Schematic
Dim lay As Layout
Dim phys As PhysicalNet

Set schem = Project.Schematics("SCH1")


Set lay = schem.Layout
Set phys = lay.PhysicalNets(1)

phys.HighlightNet(True, mwCLR_Azure)
PrintHighlightState schem, "Highlight On"
phys.HighlightNet(False)
PrintHighlightState schem, "Highlight Off

End Sub

Sub PrintHighlightState(ByRef schem As Schematic, Title As String)


Dim ws As WireSegment
Dim lay As Layout
Dim phys As PhysicalNet

Debug.PrintTitle
Debug.Print"Wire Count = " & schem.Wires.Count
For Each ws In schem.Wires
Debug.Print"Wire Highlight = " & ws.ParentNet.NetHighlight;
If (ws.ParentNet.NetHighlight) Then
Debug.Print", Color = " & ws.ParentNet.NetHighlightColor
Else
Debug.Print""
End If
Next ws

Set lay = schem.Layout


Debug.Print "Phys Net Count = " & lay.PhysicalNets.Count
For Each phys In lay.PhysicalNets
Debug.Print "Phys Net Highlight = " & phys.NetHighlight;

API Scripting Guide 1121


Working with Schematics

If (phys.NetHighlight) Then
Debug.Print ", Color = " & phys.NetHighlightColor
Else
Debug.Print""
End If
Next phys
Debug.Print""

End Sub

The following code shows how to use InvokeCommand() to highlight on to certain color and highlight off:

Set lay = Project.Schematics("SCH1").Layout

PrintHighlightState lay

lay.PhysicalNets("ELENET2.EN1").Routes(1).Selected = True
' Turn on highlight (initially color red).
lay.InvokeCommand("NetHighlightOn", Array(255))
PrintHighlightState lay

' Change color to green.


lay.InvokeCommand("NetHighlightColor", Array(65280))

PrintHighlightState lay

' Finally Turn Highlight off.

lay.InvokeCommand("NetHighlightOff")

PrintHighlightState lay

The code for PrintHighlightState lay was shown in a previous example.

The following code shows the schematic side commands for highlighting nets based on selected wire segments:

' Code Module


Sub Main
Dim schem As Schematic
Dim elem As Element
Dim ws As WireSegment
Dim x1 As Integer
Dim y1 As Integer
Dim x2 As Integer
Dim y2 As Integer

Set schem = Project.Schematics("SCH1")


Set elem = schem.Elements("MLIN.TL1")
x = elem.Nodes(1).x
y = elem.Nodes(1).y

For Each ws In schem.Wires


If ((ws.x1 = x And ws.y1 = y) Or (ws.x2 = x And ws.y2 = y)) Then

1122 NI AWR Design Environment


Working with Schematics

If (Not ws.ParentNet.NetHighlight) Then


ws.ParentNet.HighlightNet(True, mwCLR_Red)
End If
End If
Next ws

x = elem.Nodes(2).x
y = elem.Nodes(2).y

For Each ws In schem.Wires


If ((ws.x1 = x And ws.y1 = y) Or (ws.x2 = x And ws.y2 = y)) Then
If (Not ws.ParentNet.NetHighlight) Then
ws.ParentNet.HighlightNet(True, mwCLR_Green)
End If
End If
Next ws

PrintHighlightState schem, "Highlight On"

For Each ws In schem.Wires


If ws.ParentNet.NetHighlight Then
ws.ParentNet.HighlightNet(False)
End If
Next ws
PrintHighlightState schem, "Highlight Off
End Sub

Sub PrintHighlightState(ByRef schem As Schematic, Title As String)


Dim ws As WireSegment
Dim lay As Layout
Dim phys As PhysicalNet

Debug.Print Title
Debug.Print "Wire Count = " & schem.Wires.Count
For Each ws In schem.Wires
Debug.Print "Wire Highlight = " & ws.ParentNet.NetHighlight;
If (ws.ParentNet.NetHighlight) Then
Debug.Print ", Color = " & ws.ParentNet.NetHighlightColor
Else
Debug.Print ""
End If
Next ws

Set lay = schem.Layout


Debug.Print "Phys Net Count = " & lay.PhysicalNets.Count
For Each phys In lay.PhysicalNets
Debug.Print "Phys Net Highlight = " & phys.NetHighlight;
If (phys.NetHighlight) Then
Debug.Print ", Color = " & phys.NetHighlightColor
Else
Debug.Print ""
End If
Next phys
Debug.Print ""

End Sub

API Scripting Guide 1123


Working with Schematics

The following code shows another way to highlight wires using properties:

' Code Module


Sub Main
Dim schem As Schematic
Dim wn As WireNet
Set schem = Project.Schematics("SCH1")
Set wn = schem.Wires(1).ParentNet

wn.HighlightNet(True, mwCLR_Azure)

PrintHighlightState schem, "Highlight On"

wn.HighlightNet(False)

PrintHighlightState schem, "Highlight Off

End Sub

Sub PrintHighlightState(ByRef schem As Schematic, Title As String)


Dim ws As WireSegment
Dim lay As Layout
Dim phys As PhysicalNet

Debug.Print Title
Debug.Print "Wire Count = " & schem.Wires.Count
For Each ws In schem.Wires
Debug.Print "Wire Highlight = " & ws.ParentNet.NetHighlight;
If (ws.ParentNet.NetHighlight) Then
Debug.Print ", Color = " & ws.ParentNet.NetHighlightColor
Else
Debug.Print ""
End If
Next ws

Set lay = schem.Layout


Debug.Print "Phys Net Count = " & lay.PhysicalNets.Count
For Each phys In lay.PhysicalNets
Debug.Print "Phys Net Highlight = " & phys.NetHighlight;
If (phys.NetHighlight) Then
Debug.Print ", Color = " & phys.NetHighlightColor
Else
Debug.Print ""
End If
Next phys
Debug.Print ""

End Sub

The following code shows how to use InvokeCommand() to highlight wires on schematic

' Code Module


Sub Main
Dim schem As Schematic

1124 NI AWR Design Environment


Working with Schematics

Dim wn As WireNet

Set schem = Project.Schematics("SCH1")

If (schem.Windows.Count = 0) Then
schem.NewWindow(mwWT_Schematic)
End If
schem.Activate
schem.SelectedWires.RemoveAll
schem.SelectedWires.Add(schem.Wires(1))

schem.InvokeCommand("NetHighlightOn", Array(255))

PrintHighlightState schem, "Highlight On"

schem.InvokeCommand("EditUndo")

PrintHighlightState schem, "Highlight Undo"

schem.InvokeCommand("EditRedo")

PrintHighlightState schem, "Highlight Redo"

End Sub

Sub PrintHighlightState(ByRef schem As Schematic, Title As String)


Dim ws As WireSegment
Dim lay As Layout
Dim phys As PhysicalNet

Debug.Print Title
Debug.Print "Wire Count = " & schem.Wires.Count
For Each ws In schem.Wires
Debug.Print "Wire Highlight = " & ws.ParentNet.NetHighlight;
If (ws.ParentNet.NetHighlight) Then
Debug.Print ", Color = " & ws.ParentNet.NetHighlightColor
Else
Debug.Print ""
End If
Next ws

Set lay = schem.Layout


Debug.Print "Phys Net Count = " & lay.PhysicalNets.Count
For Each phys In lay.PhysicalNets
Debug.Print "Phys Net Highlight = " & phys.NetHighlight;
If (phys.NetHighlight) Then
Debug.Print ", Color = " & phys.NetHighlightColor
Else
Debug.Print ""
End If
Next phys
Debug.Print ""

End Sub

The following code shows one more example how to use InvokeCommand() to highlight wires on schematic

API Scripting Guide 1125


Working with Schematics

' Code Module


Sub Main
Dim schem As Schematic
Dim wn As WireNet

Set schem = Project.Schematics("SCH1")


If (schem.Windows.Count = 0) Then
schem.NewWindow(mwWT_Schematic)
End If
schem.Activate

schem.SelectedWires.RemoveAll
schem.SelectedWires.AddAll

schem.InvokeCommand("NetHighlightOn", Array(255))

PrintHighlightState schem, "Highlight On"

schem.InvokeCommand("NetHighlightAllOff")

PrintHighlightState schem, "Highlight Off

schem.InvokeCommand("EditUndo")

PrintHighlightState schem, "Highlight Undo Highlight Off"

schem.InvokeCommand("EditRedo")

PrintHighlightState schem, "Highlight Redo Highlight Off"

End Sub

The code for PrintHighlightState schem, "Text" was shown bwfore.

The following code shows how to use InvokeCommand() to highlight color for wires on schematic. The command to be
invoked with a color values for the selected wires in the schematic:

' Code Module


Sub Main
Dim schem As Schematic
Dim wn As WireNet

Set schem = Project.Schematics("SCH1")

If (schem.Windows.Count = 0) Then
schem.NewWindow(mwWT_Schematic)
End If
schem.Activate

schem.SelectedWires.RemoveAll
schem.SelectedWires.Add(schem.Wires(1))

schem.InvokeCommand("NetHighlightOn", Array(255))

1126 NI AWR Design Environment


Working with Schematics

PrintHighlightState schem, "Highlight On Red"

schem.InvokeCommand("NetHighlightColor", Array(mwCLR_Green))

PrintHighlightState schem, "Highlight Color Green"

schem.InvokeCommand("EditUndo")

PrintHighlightState schem, "Highlight Undo Color Green"

schem.InvokeCommand("EditRedo")

PrintHighlightState schem, "Highlight Redo Color Green"

End Sub

The code for PrintHighlightState schem, "Text" was shown before.

Working with the Schematic Elements Ports Collection

The following code works with the ElementsPorts collection and prints all port parameter properties to the Debug window:

Dim sch As Schematic


Dim en As Element
Dim pr As parameter
For Each sch In Project.Schematics
For Each en In sch.Ports
Debug.Print en.Name
For Each pr In en.parameters
Debug.Print pr.Name
Debug.Print pr.Constrain;vbTab;pr.Description;vbTab;pr.Distribution
Debug.Print pr.LowerConstraint;vbTab;pr.UpperConstraint;vbTab;pr.Optimize;vbTab;pr.OptimizeYiel
Debug.Print pr.ReadOnly ;vbTab;pr.StatVariation;vbTab;pr.Style(mwPS_BoldFont);vbTab;pr.TolInPe
Debug.Print pr.Tune;vbTab;pr.UnitType;vbTab;pr.UseStatistics;vbTab;pr.ValueAsString ';vbTab;pr
Debug.Print
Next pr
Next en
Debug.Print
Next sch
Set en = Project.Schematics(1).Ports(1)
For Each pr In en.parameters
Debug.Print pr.Name
Debug.Print pr.Constrain
pr.Constrain = Not pr.Constrain
Debug.Print "After changing: ";pr.Constrain
Next pr

Working with the NamedConnectors Collection

A Named Connector is an Element that provides connectivity by name, so any two or more Named Connectors in a
Schematic with the same name form a connection. For example, in the following script two Named Connectors are added
to the nodes of the Elements you want to connect. To ensure correct connection, the named connectors are given a name
that is unique in the Schematic, but matches between the two so they are connected together by having the same name:

API Scripting Guide 1127


Working with Schematics

' Code Module


Sub Main
Dim schem As Schematic
Dim ele1 As Element, ele2 As Element, ele3 As Element, ele4 As Element
Dim nconn1 As Element, nconn2 As Element
Set schem = Project.Schematics("Schematic 2")
' Add four elements
Set ele1 = schem.Elements.Add("MLIN", 0, 1000, -90)
Set ele2 = schem.Elements.Add("MLIN", 0, 0, 90)
Set ele3 = schem.Elements.Add("MLIN", -1000, 0, 180)
Set ele4 = schem.Elements.Add("MLIN", 1000, 0, 0)
' Add wire connecting the first two elements.
schem.Wires.Add(ele1.Nodes(1).x, ele1.Nodes(1).y, ele2.Nodes(1).x, ele2.Nodes(1).y)
' Add named connectors to connect the second two elements.
Set nconn1 = schem.Elements.Add("NCONN", ele3.Nodes(1).x, ele3.Nodes(1).y)
Set nconn2 = schem.Elements.Add("NCONN", ele4.Nodes(1).x, ele4.Nodes(1).y)
' Set the connector name property to match so they connect.
nconn1.Parameters("Name").ValueAsString = "ele3_ele4"
nconn2.Parameters("Name").ValueAsString = "ele3_ele4"
End Sub

A named connector is useful when you need to make a large number of connections at different locations within a
Schematic to a single pin or port, such as with a power or clock signal line. The following script works with the
NamedConnectors collection and prints the NamedConnector properties to the Debug window:

' Code Module


Sub Main
Debug.Clear
Dim sch As Schematic
Dim en As Element
Dim pr As Parameter
Dim nd As Node
Dim pp As Property
Dim atr As Attribute
Dim op As Option
For Each sch In Project.Schematics
Debug.Print sch.Name
Debug.Print "Subcircuits.Count = :";sch.NamedConnectors.Count
For Each en In sch.NamedConnectors
Debug.Print en.Name;vbTab;en.CellName;vbTab;en.Enabled;vbTab;en.Flipped;vbTab;en.Height;vbTab;en
Debug.Print en.NameVisible;vbTab;en.ParameterFrame.Height;vbTab;en.ParameterFrame.Left
Debug.Print en.ParameterFrame.Top;vbTab;en.ParameterFrame.Width;vbTab;en.ParameterFrame.x;vbTab;
Debug.Print en.PartNumber;vbTab;en.RotationAngle;vbTab;en.Selected;vbTab;en.Symbol
Debug.Print en.Top;vbTab;en.UseDefaultModelOptions;vbTab;en.Width;vbTab;en.x;vbTab;en.y
Next en
For Each en In sch.NamedConnectors
Debug.Print en.Name
For Each pr In en.Parameters
Debug.Print pr.Name
Debug.Print pr.Constrain;vbTab;pr.Description;vbTab;pr.Distribution
Debug.Print pr.LowerConstraint;vbTab;pr.UpperConstraint;vbTab;pr.Optimize;vbTab;pr.OptimizeYiel
Debug.Print pr.ReadOnly
Debug.Print pr.Tune;vbTab;pr.UnitType;vbTab;pr.UseStatistics;vbTab;pr.ValueAsString
Debug.Print
Next pr

1128 NI AWR Design Environment


Working with Schematics

Next en
Debug.Print
Next sch
Set en = Project.Schematics(1).NamedConnectors(1)
'
For Each nd In en.Nodes
Debug.Print " NodeNumber = ";nd.NodeNumber;vbTab;"nd.PortNumber = ";nd.PortNumber;vbTab;nd.x;vbTa
Next nd
'
For Each op In en.Options
Debug.Print op.Name;vbTab;op.Description;vbTab;op.Value;vbTab;op.DataType;vbTab;op.DefaultValue
Next op
End Sub

The following example script prints information for the Named Connectors collection of objects:

Sub PrintNamedConnectorsInfo(ByRef Sch As Schematic)


Dim par As Parameter

For n = 1 To Sch.NamedConnectors.Count

Debug.Print Sch.NamedConnectors(n).Name
For Each par In Sch.NamedConnectors(n).Parameters
Debug.Print par.Name;vbTab;vbTab;par.ValueAsString;vbTab;par.ValueAsDouble
Next par

Next n
End Sub

This script generates the following output:

Schematic Name = 665a_FlexIO


NCONN.NC228
ID NC228 0
Name a,b 0
NCONN.NC110
ID NC110 0
Name a 0
NCONN.NC106
ID NC106 0
Name b 0
Schematic Name = padcage_esd

Working with the Schematic DrawingObjects Collection

We can add different shapes collection to schematic design documents. The following code shows how to add different
shapes correctly to the schematic document's drawing shapes collection, how to remove and delete shapes, and how the
attributes of shapes can be enumerated:

' Code Module


Sub Main
Dim schem As Schematic
Dim pts(3) As Long
Dim count As Integer

API Scripting Guide 1129


Working with Schematics

pts(0) = 0
pts(1) = 0
pts(2) = 500
pts(3) = 500

Set schem = Project.Schematics("SCH1")


PrintDrawingShapes schem, "Before Add Rectangle"

schem.DrawingShapes.AddArc(0, 500, 500, 0, 0, 250, 1000, 250)


schem.DrawingShapes.AddRectangle(0, 0, 500, 500)
schem.DrawingShapes.AddArrow(pts)
schem.DrawingShapes.AddEllipse(0, 0, 500, 500)
schem.DrawingShapes.AddText(0, 0, 300, "Graphics")

Moving Shapes
For Each objShape In schem.DrawingShapes
objShape.Move(500, 500)
Next objShape

PrintDrawingShapes schem, "After Add Shapes"


'Removing shape
count = schem.DrawingShapes.Count
If count >= 4 Then
schem.DrawingShapes.Remove(4)
End If

count = schem.DrawingShapes.Count
If count >= 2 Then
schem.DrawingShapes.Remove(2)
End If

PrintDrawingShapes schem, "Schematic Drawing Shapes after Remove"

Deleting Shapes
For Each objShape In schem.DrawingShapes
objShape.Delete
Next objShape

End Sub

Sub PrintDrawingShapes(ByRef schem As Schematic, title As String)


Dim dwShape As DrawingShape
Dim shpPoint As Point
Dim index As Integer
Dim attr As Attribute

Debug.Print title
Debug.Print "Drawing Shape Count = " & schem.DrawingShapes.Count
For Each dwShape In schem.DrawingShapes
Debug.Print "Shape Type = " & dwShape.Type
Debug.Print "Shape Type Bits = " & dwShape.TypeBits
Debug.Print "Shape Base Pos = " & " { x = " & dwShape.BasePosition.x & ", y = " & dwShape.B
Debug.Print "Shape Flipped = " & dwShape.Flipped
Debug.Print "Shape Rotation Ang = " & dwShape.RotationAngle
Debug.Print "Shape Point Count = " & dwShape.Points.Count

1130 NI AWR Design Environment


Working with Schematics

index = 1
For Each shpPoint In dwShape.Points
Debug.Print " Point[ " & index & " ] = { x = " & shpPoint.x & ", y = " & shpPoint.y & " } "
index = index + 1
Next shpPoint

Debug.Print "Shape Attr Count = " & dwShape.Attributes.Count


For Each attr In dwShape.Attributes
Debug.Print " " & attr.Name & " = " & attr.Value
Next attr
Next dwShape

Debug.Print ""

End Sub

Opening a Schematic in a New Window


To open a Schematic in a new Window, use the following script:

' Copying Schematic to a new Window


Sub Main
Debug.Clear
Dim s As Schematic
Dim w As Window
Set w = Project.Schematics("Filter").NewWindow(mwWT_Schematic)
Debug.Print w.Caption
End Sub

In this script, constant mwWT_Schematic determines the Window type for the Schematic.

The output contains the new Window name:

Filter:1

The new Window displays in the workspace.

Accessing embedded design views in Schematics


To access embedded design views in Schematic, use the following script:

Dim emb As EmbeddedDesign


Dim schem As Schematic

Set schem = project.Schematics(Sch)

For Each emb In schem.EmbeddedDesigns


PrintEmbeddedDetails emb
Next emb

End Sub

Sub PrintEmbeddedDetails(ByRef emb As EmbeddedDesign)

API Scripting Guide 1131


Working with Schematics

Debug.Print "Design Name = " & emb.DesignName


Debug.Print "Extension = " & emb.Extension
Debug.Print "X Pos = " & emb.x
Debug.Print "Y Pos = " & emb.y
Debug.Print "Width = " & emb.Width
Debug.Print "Height = " & emb.Height
Debug.Print ""
End Sub

After running the script we can have output like the following:

Design Name = Graph 1


Extension = grd
X Pos = -3900
Y Pos = -2800
Width = 2400
Height = 1700

Design Name = Graph 2


Extension = grd
X Pos = -1200
Y Pos = -2800
Width = 2300
Height = 1700

Design Name = SCH1


Extension = lay
X Pos = 1400
Y Pos = -2600
Width = 2100
Height = 1400

To add embedded design to Schematic use the following code:

schem.EmbeddedDesigns.Add("EMS1", mwEDT_EMLayout, 0, 0, 2000, 1000)


schem.EmbeddedDesigns.Add("Graph 1", mwEDT_Graph, 0, 0, 2000, 1000)
schem.EmbeddedDesigns.Add("Graph 2", mwEDT_Graph, 2000, 0, 2000, 1000)
schem.EmbeddedDesigns.Add("SCH1",mwEDT_SchematicLayout, 0, 0, 2000, 1000)
schem.EmbeddedDesigns.Add("SCH2",mwEDT_Schematic, 0, 0, 2000, 1000)

To move embedded design in Schematic use the following code:

If (schem.EmbeddedDesigns.Count > 0) Then


' Move the base position of the embedded layout design
Set emb = schem.EmbeddedDesigns(1)
emb.x = 500
emb.y = 500
End If

To remove embedded design in Schematic use the following code:

1132 NI AWR Design Environment


Working with Schematics

Dim index As Integer


index = 0
Set schem = Project.Schematics("SCH1")

For i = 1 To schem.EmbeddedDesigns.Count
If (schem.EmbeddedDesigns(i).DesignName = "SCH1") Then
index = i
End If
Next i

Dim bRes As Boolean


If (index ne 0) Then
bRes = schem.EmbeddedDesigns.Remove(index)
Debug.Print "Remove Returned: " & bRes
End If

To remove All embedded design in Schematic use the following code:

Dim bRet As Boolean


bRet = schem.EmbeddedDesigns.RemoveAll
Debug.Print "Remove All Returned: " & bRet

To resize layout embedded design in Schematic use the following code:

Dim emb As EmbeddedDesign

Set schem = Project.Schematics("SCH1")

If (schem.EmbeddedDesigns.Count > 0) Then


' Resize the embedded design to make it larger.
Set emb = schem.EmbeddedDesigns(1)
emb.Width = emb.Width + 1000
emb.Height = emb.Height + 1000
End If

Similar types of embeddings are supported for System Diagrams as well.

Performing Simulations
In addition to working with Schematics, you can perform simulation through the API. To start a simulation, use the
following code:

Project.Simulator.Analyze

Note that the statement after Project.Simulator.Analyze works only after the simulation is complete.

API Scripting Guide 1133


Working with Netlists

Working with Netlists


Creating and Importing Netlists
The Circuit Schematics node in the Project Browser contains a subnode for each Netlist that you create or import into the
program manually or via the API. To create and import a Netlist into a Project, use the following script:

' Code Module


Sub Main
Debug.Clear
Dim net As Netlist
Dim Path As String
Set net = Project.Netlists.Import
("filter","c:\myscripts\test_netlist\filter.net",True,mwNLT_AWR)
i = 0
For Each net In Project.Netlists
i = i +1
Debug.Print "Name = ";Project.Netlists.Item(i).Name;vbTab;"FileName = ";
Project.Netlists.Item(i).Filename;vbTab;Project.Netlists.Item(i).embedded
Debug.Print Project.Netlists.Item(i).DataAsText
Debug.Print
Next net
Dim nt As String
Project.Netlists.Add("newnet").DataAsText = "DIM IND NH CAP PF RES
OH VAR ca=0.03988 la#0.8 25.41 5.2"
End Sub

This script iterates through the Netlists collection and prints out Netlist properties:

Name = filter FileName = c:\myscripts\test_netlist\filter.net True

The following are constants that define different types of Netlists that you can import into an NI AWRDE Project:

mwNLT_AWR - the AWR netlist format, value = 0


mwNLT_SPICE - SPICE format, value = 1
mwNLT_TSTONE, Touchstone format, value = 2.

We have SimulationDirty and SimulationState properties for datafiles and netlists in the API.

Specifying Netlist Options


Netlist Options include settings that control how the harmonic balance simulator performs its calculations, what type of
solver is applied to linear simulations, and simulation frequencies. For more information see Specifying Netlist Options.

Adding Data to a Netlist


In the previous example the statement

Project.Netlists.Add("newnet").DataAsText = "DIM IND NH CAP PF RES OH VAR ca=0.03988 la#0.8 25.

adds Data to a Netlist.

1134 NI AWR Design Environment


Working with EM Structures

You can also display the object in a new Window:

Project.Netlists(2).NewWindow

Printing a Netlist
You can print the contents of a Netlist using the PrintOut method. You can also print DataAsText to the Immediate
Window, and you can determine the Name and FileName of the Netlist.

Working with EM Structures


The API exposes the Electromagnetic (EM) structures collection of objects. A common task is to list all EMStructures
and print the names of all EMStructures in a Project.

Dim em As EMStructure
For Each em In Project.EMStructures
Debug.Print "EMStructure Name : ";em.Name
Next em

After you have a reference to an EMStructure, you can access the Frequencies and Options Collection for the particular
EMStructure. You can also access the EMStructure Enclosure object, and the Shapes and MaterialLayers collections.

EMStructure Options Collection of Objects


Configuring Global EM Structure Options

You can use the Project global settings for the EMStructure.

To loop through the whole collection of the EMStructures Options, use the following code:

Dim opt As Option


Debug.Print "EMStructures Options Count = " & Project.EMStructures.Options.Count
For Each opt In Project.EMStructures.Options
Debug.Print "Option Name " & opt.Name
Debug.Print "Option Data Type " & opt.DataType
Debug.Print "Option Default Value " & opt.DefaultValue
Debug.Print "Option Description " & opt.Description
Debug.Print "Option Value" & opt.Value
Next opt

The following is the section of output this code generates:

EMStructures Options Count = 46


Option Name UseFastFrequencySweep
Option Data Type 11
Option Default Value False
Option Description Returns/sets if fast frequency sweep should be used.
Option ValueFalse
Option Name DeembedPorts
Option Data Type 11
Option Default Value True
Option Description Returns/sets if ports and feed lines should be de-embeded.

API Scripting Guide 1135


Working with EM Structures

Option ValueTrue
Option Name ComputeLoadedCurrents
Option Data Type 11
Option Default Value True
Option Description Returns/sets if loaded currents should be computed.
Option ValueTrue
Option Name UseSameSizeBox
Option Data Type 11
Option Default Value False
Option Description Returns/sets if the same size box should be used for de-embeded circuit.
Option ValueFalse
Option Name SaveResultsInDocument
Option Data Type 11
Option Default Value False
Option Description Returns/sets if the results should be saved in the EM document.
Option ValueFalse
Option Name MaxDifferentialOrder
Option Data Type 3
Option Default Value 12
Option Description Returns/sets the maximum differential order computed.
Option Value12
Option Name MatrixSolverType
Option Data Type 3
Option Default Value 0
Option Description Returns/sets the matrix solver type used for analysis.
Option Value0

The following script shows how to deal with EM Options that are array:

'Save EM option values to dictionary object


Dim opt As Option
Dim optarray() As String
Dim optstg As String
Dim dict As New Dictionary

Debug.Clear

'Collect up EM options and values. Save in dictionary. Can't use option name as key since there

For i = 1 To Project.EMStructures.Options.Count

Set opt = Project.EMStructures.Options(i)

If IsArray(opt.Value)=True Then
'If option is an array, must convert it to string
ReDim optarray(UBound(opt.Value))
For n = 0 To UBound(opt.Value)
optarray(n) = opt.Value(n)
Next n
optstg = Join(optarray)
dict.Add(i,optstg)
Else
'Add option value to dictionary
dict.Add(i,opt.Value)

End If

1136 NI AWR Design Environment


Working with EM Structures

Next i

For i = 1 To Project.EMStructures.Options.Count
Set opt = Project.EMStructures.Options(i)
Debug.Print opt.Name & vbTab & dict(i)
Next i

The following statement shows how to access settings for JobScheduler:

Debug.Print Project.EMStructures.Options("AWR_JobSchedulerMaxProcs").Value

Configuring Local EMStructure Options and Frequencies

You can configure particular settings. To change the default options set the Use Project Options property to "False".

To loop through the EMStructure "EMStructure 1" Options, use the following code:

Dim opt As Option


Dim em As EMStructure
Set em = Project.EMStructures("EM Structure 1")
Debug.Print em.Name;" Options :"
For Each opt In em.Options
Debug.Print "Option : ";i;vbTab;"Name ";em.Options(i).Name;vbTab; "Value = ";em.Options(i).Value;
Debug.Print "Description = ";em.Options(i).Description
Next opt

The following is a simple example of changing an option value. Note that "ems.UseProjectOptions = False" is done
before the value is changed:

' Code Module


Sub Main
Dim ems As EMStructure
Dim opt As Option
Debug.Clear
Set ems = Project.EMStructures("EM Structure 1")
Debug.Print ems.Name
ems.UseProjectOptions = False
Debug.Print ems.Options("InterpolationWindowSize").Value
ems.Options("InterpolationWindowSize").Value = 10
ems.Options("EnableInterpolation").Value=True
Debug.Print ems.Options("InterpolationWindowSize").Value
Debug.Print ems.Options("EnableInterpolation").Value
End Sub

The following example is the section of output for "EMStructure 1":

em.Options.Count = 35
Option : 1 Name AnimateUseLogColorScale Value = True DataType = 11 DefaultValue = True
Description = Returns/sets if a color log scale should be used for animation.
Option : 2 Name AnimateActiveCurrentLayer Value = True DataType = 11 DefaultValue = True
Description = Returns/sets if only currents on the active layer should be animated.
Option : 3 Name AnimateActive2DLayerOnly Value = False DataType = 11 DefaultValue = False

API Scripting Guide 1137


Working with EM Structures

Description = Returns/sets if only the active layer should be animated.


Option : 4 Name AnimateCurrentXComponents Value = True DataType = 11 DefaultValue = True
Description = Returns/sets if the X current components should be animated.

The following is a simple example of accessing an option via name of the option:

Set em_base = Project.EMStructures.Item(1)


nOpt = em_base.Options.Count
For iOpt = 1 To em_base.Options.Count
Set em_opt = em_base.Options.Item(iOpt)
optionName = em_opt.Name
Debug.Print optionName;vbTab;"Value = ";em_opt.Value;vbTab;"Default Value= ";em_opt.DefaultValue
If(optionName = "LT_MOM_ACC_RATIO") Then
optionName =optionName
End If
If(optionName = "eMCO_LT_MOM_ACC_RATIO") Then
optionName =optionName
End If
em_opt.Value = em_opt.DefaultValue

Next iOpt

The following example is the part of output:

AWR_JobSchedulerMaxProcs Value = 0 Default Value= 0


AWR_JobSchedulerMinProcs Value = 1 Default Value= 1
AWR_JobSchedulerThreadsPerProc Value = 1 Default Value= 1
AWR_JobSchedulerJobOSPriority Value = 0 Default Value= 0
Mesh_meshDensity Value = 2 Default Value= 2
Mesh_maxX Value = 100 Default Value= 100
Mesh_maxY Value = 100 Default Value= 100
Mesh_minX Value = 1 Default Value= 1
Mesh_minY Value = 1 Default Value= 1
Mesh_conformalCells Value = 0 Default Value= 0
Mesh_trngleCells Value = 0 Default Value= 0
SpecGlobalEquations Value = Global Definitions Default Value= Global Definitions
Solver types Value = 0 Default Value= 0

To check the "Deembed port/feed line" option, use the following code:

Debug.Print "DeembedPorts = ";em.Options.Item("DeembedPorts")

You also can set the Value and DefaultValue for the Option getting the Option by name or by index.

By default, EM simulations occur at the Project frequencies. You also can set your own Frequencies for simulation of a
particular EMStructure by setting "Use Project Frequency" to False and specifying the desired frequencies.

' Code Module


Sub Main
Dim Ems As EMStructure

1138 NI AWR Design Environment


Working with EM Structures

Dim Freq As Frequency


' Clear the output window.
Debug.Clear
For Each Ems In Project.EMStructures
' Print the name of the EMStructure for references.
Debug.Print "EmStructure Name = " & Ems.Name
Debug.Print "Use Project Frequencies = " & Ems.UseProjectFrequencies
Debug.Print "Frequency Count = " & Ems.Frequencies.Count
' Try setting the use project frequencies to a value that it is currently not.
Ems.UseProjectFrequencies = True
Debug.Print
' Print the current frequencies.
Debug.Print "*** Frequencies ***"
ListStructureFreqs(Ems)
Debug.Print
Ems.Frequencies.Add(4.0e9)
' Print the current frequencies.
Debug.Print "*** Frequencies ***"
ListStructureFreqs(Ems)
Debug.Print
Ems.Frequencies.Remove(1)
' Print the current frequencies.
Debug.Print "*** Frequencies ***"
ListStructureFreqs(Ems)
Debug.Print
Next Ems
End Sub
Sub ListStructureFreqs(ByRef EMStruct As EMStructure)
Dim Freq As Frequency
Dim index As Integer
index = 0
For Each Freq In EMStruct.Frequencies
Debug.Print "Freq[" & index & "] = " & Freq.Value * 1e-9 & "GHz"
index = index + 1
Next Freq
End Sub

This script generates the following output:

EmStructure Name = EM Structure 1


Use Project Frequencies = False
Frequency Count = 3
*** Frequencies ***
Freq[0] = 1 GHz
Freq[1] = 2 GHz
Freq[2] = 3 GHz
*** Frequencies ***
Freq[0] = 1 GHz
Freq[1] = 2 GHz
Freq[2] = 3 GHz
Freq[3] = 4 GHz
*** Frequencies ***
Freq[0] = 2 GHz
Freq[1] = 3 GHz
Freq[2] = 4 GHz

API Scripting Guide 1139


Working with EM Structures

This example also shows how to remove a frequency from the Project.

Note that because the EM document uses project defaults it returns 3 freqs when you query it. If you set Use Project
Frequencies = False it returns 4 freqs when you query it because the EM document has its own 4 freqs, while the project
has 3 freqs.

Locking EM Structure documents within a project.

We add support for Locking EM Structure objects in the API using methods similar to what is available in the Schematic
and System Diagram objects.

The following script shows how to access the lock level property:

Dim ems As EMStructure

Debug.Clear
Set ems = Project.EMStructures("EMS1")
Debug.Print "Name = " & ems.Name
Debug.Print "Lock Level = " & ems.LockLevel
Debug.Print "Lock Edit = " & ems.LockDiagram(mwDLL_LockedForEdit, "test")
Debug.Print "Lock Level = " & ems.LockLevel
Debug.Print "Unlock Edit = " & ems.LockDiagram(mwDLL_Unlocked, "test")
Debug.Print "Lock Level = " & ems.LockLevel
End Sub

Modifying Settings for EMSight and AXIEM tabs for EMStructure Options

The EMStructure.Simulator options show the following Simulator types:

enum mwEmSimulator {
mwEMS_AwrAxiem,
mwEMS_AwrAxiem32,
mwEMS_AwrAxiem64,
mwEMS_AwrEmSight,
mwEMS_AwrAnalyst,
mwEMS_AwrAce,
mwEMS_SonnetEm,
mwEMS_ZelandIe3d,
mwEMS_OeaNetan,
//mwEMS_HelicVelocerf,
} mwEmSimulator;

The top value mwEMS_AwrAxiem equates to AXIEM Async.

You can access solver level options at the Project level. This allows access to options for specific EM solvers from the
EMStructures.Options collection to set the default "project level" options for different solvers. You can also save changes
to a specific structure's solver options when you access the options through an EMStructure. To see these structure-specific
changes, you must turn off UseProjectDefaults at the structure level or the Project level defaults are returned instead.

The following shows which options you can access from specific tabs:

1140 NI AWR Design Environment


Working with EM Structures

Option : 1 Name UseFastFrequencySweep Value = False DataType = 11 DefaultValue = False


Description = Returns/sets If fast Frequency sweep should should be used.

Option : 2 Name DeembedPorts Value = True DataType = 11 DefaultValue = True


Description = Returns/sets If Ports And feed lines should be de-embeded.

Option : 3 Name ComputeLoadedCurrents Value = True DataType = 11 DefaultValue = True


Description = Returns/sets If loaded currents should be computed.

Option : 4 Name UseSameSizeBox Value = False DataType = 11 DefaultValue = False


Description = Returns/sets If the same Size box should be used For de-embeded circuit.

Option : 5 Name SaveResultsInDocument Value = False DataType = 11 DefaultValue = False


Description = Returns/sets If the results should be saved In the EM document.

Option : 6 Name MaxDifferentialOrder Value = 12 DataType = 3 DefaultValue = 12


Description = Returns/sets the maximum differential order computed.

Option : 7 Name MatrixSolverType Value = 0 DataType = 3 DefaultValue = 0


Description = Returns/sets the matrix solver Type used For analysis.

Option : 8 Name UseSinglePrecision Value = False DataType = 11 DefaultValue = False


Description = Returns/sets If Single precision should be used To save memory.

Option : 9 Name FreqSweepErrorTolerance Value = 1 DataType = 3 DefaultValue = 1


Description = Returns/sets If fast Frequency sweep Error tolerance level.

Option : 10 Name UseRelativeError Value = False DataType = 11 DefaultValue = False


Description = Returns/sets If relative Error should be used.

Option : 11 Name IterativeSolverTolerance Value = 1 DataType = 3 DefaultValue = 1


Description = Returns/sets the iterative solver Error tolerance level.

Option : 12 Name AFSEnable Value = False DataType = 11 DefaultValue = False


Description = Returns/sets If advanced Frequency sweep should be enabled.

Option : 13 Name AFSErrorTypeRelative Value = False DataType = 11 DefaultValue = False


Description = Returns/sets If the Error Type should be relative Or absolute.

Option : 14 Name AFSErrorTolerance Value = -40 DataType = 5 DefaultValue = -40


Description = Returns/sets the Error tolerance For the advanced Frequency sweep In dB.

Option : 15 Name AFSGridPointCount Value = 200 DataType = 3 DefaultValue = 200


Description = Returns/sets the number of grid Points used For the advanced Frequency sweep.

Option : 16 Name AFSMaxPointCount Value = 200 DataType = 3 DefaultValue = 200


Description = Returns/sets the advance Frequency sweep maximum Point count.

Option : 17 Name AFSSpecifyBand Value = False DataType = 11 DefaultValue = False


Description = Returns/sets With To use a specified band For the advanced Frequency sweep.

Option : 18 Name AFSBandStartFrequency Value = 0 DataType = 5 DefaultValue = 0


Description = Returns/sets the start Frequency For the advanced Frequency sweep band.

Option : 19 Name AFSBandStopFrequency Value = 0 DataType = 5 DefaultValue = 0


Description = Returns/sets the Stop Frequency For the advanced Frequency sweep band.

API Scripting Guide 1141


Working with EM Structures

Option : 20 Name AnimateUseLogColorScale Value = True DataType = 11 DefaultValue = True


Description = Returns/sets If a color Log scale should be used For animation.

Option : 21 Name AnimateActiveCurrentLayer Value = True DataType = 11 DefaultValue = True


Description = Returns/sets If only currents On the Active layer should be animated.

Option : 22 Name AnimateActive2DLayerOnly Value = False DataType = 11 DefaultValue = False


Description = Returns/sets If only the Active layer should be animated.

Option : 23 Name AnimateCurrentXComponents Value = True DataType = 11 DefaultValue = True


Description = Returns/sets If the X current components should be animated.

Option : 24 Name AnimateCurrentYComponents Value = True DataType = 11 DefaultValue = True


Description = Returns/sets If the Y current components should be animated.

Option : 25 Name Animate2DFramesPerCycle Value = 16 DataType = 3 DefaultValue = 16


Description = Returns/sets the number of 2D animation frames per cycle.

Option : 26 Name Animate3DFramesPerSycle Value = 16 DataType = 3 DefaultValue = 16


Description = Returns/sets the number of 3D animation frames per cycle.

Option : 27 Name AnimateLocScaleFactor Value = 4 DataType = 3 DefaultValue = 4


Description = Returns/sets the Log color scale factor To be used In the animation.

Option : 28 Name AnimationLightenFactor Value = 4 DataType = 3 DefaultValue = 4


Description = Returns/sets the lighten color scale factor For the animation.

Option : 29 Name AnimateStandaingWave Value = False DataType = 11 DefaultValue = False


Description = Returns/sets If standing waves should be displayed In the animation.

Option : 30 Name AnimationHideArrows Value = False DataType = 11 DefaultValue = False


Description = Returns/sets If current arrows should be hidden during animation.

AXIEM, OEA, and ACE options are identifiable in the following output:

Option Name = AXIEM:USE_CAUCHY_SWP Option Description = AXIEM:USE_CAUCHY_SWP Value = 1

Option Name = AXIEM:MESH_MIN_EDGE_DIM Option Description = AXIEM:MESH_MIN_EDGE_DIM Value = 1000

Option Name = AXIEM:eAxiem_AFS_Options Option Description = AXIEM:eAxiem_AFS_Options DataType = 3 V

Option Name = AXIEM:AFS_TOL Option Description = AXIEM:AFS_TOL Value = -30

Option Name = ACE:XOVER_CALC_METH Option Description = ACE:XOVER_CALC_METH Value = 0

Option Name = ACE:Show Simplified Stackup Option Description = ACE:Show Simplified Stackup Value =

Option Name = VeloceRF:GROUND_FACTOR Option Description = VeloceRF:GROUND_FACTOR Value = 20

Option Name = OEA:SimMode Option Description = OEA:SimMode Value = 4

Option Name = OEA:MinTimeConst Option Description = OEA:MinTimeConst Value = 0.1

1142 NI AWR Design Environment


Working with EM Structures

The solver options used for EMSight and AXIEM include options for Advanced Frequency Sweep (AFS). The API
options for the solver set include the AFS options as well as the standard solver options. The following enables/disables
the AFS. You can also access the other AFS group options.

To find the option by its ID, use the following script:

' Project Module


' Code Module
Private Sub Project_BeforeSimulate(Cancel As Boolean)
Dim em As EMStructure
Dim o As Option

Debug.Clear

Set em = Project.EMStructures(1)
Set o = get_axiem_option_by_ID(em,20095)
Debug.Print o.Value
o.Value=.2
End Sub
Function get_axiem_option_by_ID(em As EMStructure, id As Integer) As Option
Dim o As Option

For Each o In em.Options


If o.Id=id Then
Set get_axiem_option_by_ID = o
Exit Function
End If
Next o
End Function

The script sets the absolute size for the edge mesh.

The following are additional example scripts for changing AXIEM options:

Dim em As EMStructure

Project.Simulator.Analyze

Set em = Project.EMStructures("Stand_Alone")

Debug.Clear
Debug.Print "Edge Mesh Before Change: "; em.Options("eAX_meshEdgeMeshing").Value
Debug.Print "Decimation Before Change: "; em.Options("eAX_MESH_DECIMATION_OPTIONS").Value

em.Options("eAX_meshEdgeMeshing") = True
em.Options("eAX_MESH_DECIMATION_OPTIONS") = 0

Debug.Print "Edge Mesh After Change: "; em.Options("eAX_meshEdgeMeshing").Value


Debug.Print "Decimation After Change: "; em.Options("eAX_MESH_DECIMATION_OPTIONS").Value

To access the AFS options, use the following script:

' Code Module


Sub Main

API Scripting Guide 1143


Working with EM Structures

Dim emStruct As EMStructure


Dim opt As Option

Debug.Clear
Set emStruct = Project.EMStructures("EM Structure 1")
Debug.Print emStruct.Options("AFSEnable").Value
emStruct.UseProjectOptions = False
emStruct.Options("AFSEnable").Value = True
Debug.Print emStruct.Options("AFSEnable").Value
End Sub

Other AFS options (for example, the AFS band, and error type and tolerance) should display as "AFS...".

Creating or Importing EMStructures


There are three methods of initialization. Default which doesn't require any addition information. Stackup which requires
a Global Definitions Document and and Stackup Instance name. And LPF which requires a LPF Process Definition name
and the name of an EM Mapping in that LPF to use for the initialization.

To create an EMStructure with Default method you need to use the Add command, which takes one argument (the name
of the EMStructure you want to add). For example, to create a new EMStructure with the name "MyEMStructure", enter:

Project.EMStructures.Add("MyEMStructure")

This function does not overwrite an existing EMStructure. If an EMStructure named "MyEMStructure" already exists,
the new EMStructure is named "MyEMStructure 1".

To reference a created EMStructure, use the following code:

Dim em As EMStructure
Set em = Project.EMStructures.Add("MyEMStructure")

To create an EMStructure with a specific simulator, use the following code:

Project.EMStructures.AddEx("New",mwEMS_AwrAnalyst)

The following are constants that define the different types of electromagnetic simulators:

mwEMS_AwrAxiem 0
mwEMS_AwrAxiem32 1
mwEMS_AwrAxiem64 2
mwEMS_AwrEmSight 3
mwEMS_AwrAnalyst 4
mwEMS_AwrAce 5
mwEMS_SonnetEm 6
mwEMS_ZelandIe3d 7
mwEMS_OeaNetan 8
mwEMS_CST 9
mwEMS_HFSSAsync 10
mwEMS_CSTAsync 11

1144 NI AWR Design Environment


Working with EM Structures

mwEMS_SonnetAsync 12

Note that there are different constants when a new EM document is created through the API with AXIEM specified as
the simulator.

To create EM Structure with Initialization Options we use two steps. The first step is using the method
EMStructures.CreateInitRecord() that creats an instance of an EMInitRecord and returns it to the user. This can be filled
out and then passed to a second method AddInit() which will create an EmStructure and then use the information inside
the Initialization record to perform the requested initialization.

The following is the example of code that creats EM Structure initialized from STACKUP element:

Dim struct As EMStructure


Dim initRec As EMInitializationRecord

Set initRec = Project.EMStructures.CreateInitRecord


initRec.Type = mwEMI_Stackup
initRec.GlobalDocumentName = "Global Definitions"
initRec.StackupName = "STACKUP.SUB1"

Set struct = Project.EMStructures.AddInit("EMStructure1", mwEMS_AwrAxiem, initRec)

The following is the example of code that creats EM Structure initialized from LPF:

Dim struct As EMStructure


Dim initRec As EMInitializationRecord

Set initRec = Project.EMStructures.CreateInitRecord


initRec.Type = mwEMI_Default
initRec.ProcessDefinitionName = "Default"
initRec.EMMappingName = "Default"

Set struct = Project.EMStructures.AddInit("EMStructure1", mwEMS_AwrAxiem, initRec)

To delete an existing EMStructure by name, use the following code:

Project.EMStructures.Remove ("MyEMStructure")

To import an EMStructure, use the following code:

Project.EMStructures.Import("MyEMStructure.eml")

Note that the MyEMStructure file has an *.eml extension. This code adds EMStructure to the collection from a file and
returns the reference to the created EMStructure. This means that on creating a new EMStructure, the Project Browser
displays the imported EMStructure and its subnodes under the EM Structures node.

If you want to access an EMStructure without copying it into the Project you can link to an EMStructure. To link to an
EMStructure, use the following code:

API Scripting Guide 1145


Working with EM Structures

Project.EMStructures.LinkTo("MyEMStructure.eml")

When you link to an EMStructure the file must always be available for the Project to read.

Drawing EMStructures
Working with an Enclosure

The API exposes the Enclosure object to work with the EMStructure. The Enclosure object specifies boundary conditions
and dielectric materials for each layer of the EMStructure.

References to boundary conditions mean the BoundaryModel that is associated with the EMStructure Enclosure, and
exists only at the top and bottom of an EMStructure. It provides access to a Type enumeration for the Boundary Type.
The following are constants that define different types of boundary models:

Name

Value
mwBMT_PerfectConductor

0
mwBMT_SpecifiedMaterial

1
mwBMT_ApproximateOpen

2
mwBMT_InfiniteWaveguide

You cannot set the Boundary Type; you can only print the Type using the API.

Debug.Print enc.EnclosureTop.Type;vbTab;enc.EnclosureBottom.Type

The Enclosure properties describe the dimensions and resolution of the rectangular enclosure.

You can modify the Enclosure xDimension, yDimension, xDivisions, and yDivisions. Note that setting the number of
divisions in the X and Y direction specifies the grid. To output the Height, XCellSize, and YCellSize of the Enclosure
object, use the following script:

Sub Main
Dim emStruct As emStructure
Debug.Clear
For Each emStruct In Project.EMStructures
Debug.Print "Em Structure Name = " & emStruct.Name
PrintEnclosureInfo(emStruct.Enclosure)
Next emStruct
End Sub
Sub PrintEnclosureInfo(ByRef encl As Enclosure)
Debug.Print
Debug.Print "Enclosure Info:"

1146 NI AWR Design Environment


Working with EM Structures

Debug.Print " - Enclosure Height = " & encl.Height * 1e6 & " um"
Debug.Print " - Enclosure XDimension = " & encl.XDimension * 1e6 & " um"
Debug.Print " - Enclosure YDimension = " & encl.YDimension * 1e6 & " um"
Debug.Print " - Enclosure XDivisions = " & encl.XDivisions
Debug.Print " - Enclosure YDivisions = " & encl.YDivisions
Debug.Print " - Enclosure XCellSize = " & encl.XCellSize * 1e6 & " um"
Debug.Print " - Enclosure YCellSize = " & encl.YCellSize * 1e6 & " um"
Debug.Print
Debug.Print "Top: - ";
PrintBoundaryModel(encl.EnclosureTop)
Debug.Print "Bottom: - ";
PrintBoundaryModel(encl.EnclosureBottom)
Sub PrintBoundaryModel(ByRef bm As BoundaryModel)
Debug.Print "Boundary Model"
Debug.Print " - Type = " & BoundaryModelTypeToString(bm.Type)
Debug.Print
End Sub
Function BoundaryModelTypeToString(bmType As Integer) As String
Dim ret As String
Select Case bmType
Case mwBMT_PerfectConductor
ret = "mwBMT_PerfectConductor"
Case mwBMT_SpecifiedMaterial
ret = "mwBMT_SpecifiedMaterial"
Case mwBMT_ApproximateOpen
ret = "mwBMT_ApproximateOpen"
Case mwBMT_InfiniteWaveguide
ret = "mwBMT_InfiniteWaveguide"
Case Else
ret = "Unknown"
End Select
BoundaryModelTypeToString = ret
End Function

This script generates the following output:

Em Structure Name = EM Structure 1

Enclosure Info:

- Enclosure Height = 605 um

- Enclosure XDimension = 800 um

- Enclosure YDimension = 800 um

- Enclosure XDivisions = 80

- Enclosure YDivisions = 80

- Enclosure XCellSize = 10 um

- Enclosure YCellSize = 10 um

Top: - Boundary Model

API Scripting Guide 1147


Working with EM Structures

- Type = mwBMT_PerfectConductor

Bottom: - Boundary Model

- Type = mwBMT_PerfectConductor

The BoundaryModel also provides access to a Conductor Material:

' Code Module


Sub Main
Debug.Clear
Dim Ems As EMStructure
Dim enc As Enclosure
Set Ems = Project.EMStructures("MyEMStructure1")
Debug.Print Ems.Name
Set enc = Ems.Enclosure
Debug.Print "Material.Name = =";enc.EnclosureTop.Material.Name
Debug.Print "Material.Color = ";enc.EnclosureTop.Material.Color
Debug.Print "Material.Thickness = ";enc.EnclosureTop.Material.Thickness
Debug.Print enc.EnclosureTop.Material.ReadOnly
Debug.Print "ExcessSurfaceReactance = "; enc.EnclosureTop.Material.ExcessSurfaceReactance
Debug.Print "HighFrequencyLoss = "; enc.EnclosureTop.Material.HighFrequencyLoss
Debug.Print "LowFrequencyLoss = "; enc.EnclosureTop.Material.LowFrequencyLoss
Debug.Print "Conductivity = ";enc.EnclosureTop.Material.Conductivity
End Sub

This script generates the following output:

MyEMStructure1
Material.Name = =Perfect Conductor
Material.Color = 32896
Material.Thickness = 0
True
ExcessSurfaceReactance = 0
HighFrequencyLoss = 0
LowFrequencyLoss = 0
Conductivity = 0

Note that you have access only to the Material of the Enclosure Top and Enclosure Bottom and both Materials are
ReadOnly properties.

To copy a Schematic Layout to an EM structure you need to set the Enclosure first.

The following is a workaround using an NI AWR SDE script that copies the Schematic Layout to the Clipboard and
pastes it to the EMStructure.

' Code Module


Sub Main
Debug.Clear
Dim lay As Layout
Dim layoutList(20) As String
Dim em As emStructure
Dim enc As Enclosure
Dim snap As Snapshot

1148 NI AWR Design Environment


Working with EM Structures

Dim bound As Boundary


Dim b,t,l,r,encX As Double
Dim encY As Double
b=0.0
t=0.0
l=0.0
r=0.0
For Each s In Project.Schematics
layoutList( i ) = s.Name
i = i+ 1
Next s
i=1
Begin Dialog UserDialog 400,203 ' %GRID:10,7,1,1
ListBox 50,35,300,91,layoutList(),.ListBox1,3 'Select Circuit Schematic
OKButton 80,154,90,21
CancelButton 230,154,90,21
End Dialog
Dim dlg As UserDialog
Dialog dlg
layoutIndex = dlg.ListBox1 + 1
Set lay = Project.Schematics( layoutIndex ).Layout
Set snap = lay.CreateSnapshot
Debug.Print lay.Name
Debug.Print lay.Boundary.Bottom;lay.Boundary.Left;lay.Boundary.Right;lay.Boundary.Top
Dim sh As Shape
Dim firstBound As Boolean
firstBound = True
For Each sh In snap.Shapes
Set bound = sh.Boundary
If firstBound = True Then
firstBound = False
b = bound.Bottom
l = bound.Left
r = bound.Right
t = bound.Top
End If
If Not (bound Is Nothing) Then
Debug.Print "Bottom ";sh.Boundary.Bottom;" Left ";sh.Boundary.Left;" Right ";sh.Boundary.Right;"
If ( bound.Bottom > b ) Then
b = bound.Bottom
End If
If ( bound.Left < l ) Then
l = bound.Left
End If
If ( bound.Right > r ) Then
r = bound.Right
End If
If ( bound.Top < t ) Then
t = bound.Top
End If
End If
Debug.Print b;" ";l;" ";r;" ";t
Next sh
'encX = ( b - t ) / Project.Units.Item(mwUT_Length).MultValue
encY = ( t - b ) / Project.Units.Item(mwUT_Length).MultValue
encX = ( r - l ) / Project.Units.Item(mwUT_Length).MultValue
Debug.Print encX;" ";encY

API Scripting Guide 1149


Working with EM Structures

Begin Dialog UserDialog 450,189 ' %GRID:10,7,1,1


TextBox 290,42,80,14,.TextBox1
TextBox 290,70,80,14,.TextBox2
OKButton 110,147,90,21
CancelButton 250,147,90,21
Text 90,42,170,14,"XDimension of enclosure",.Text1
Text 90,70,170,14,"YDimension of enclosure",.Text2
Text 70,7,310,21,"Modify Enclosure Dimensions",.Text3,2
Text 390,42,40,14,Project.Units.Item(mwUT_Length).UnitString,.Text4
Text 390,70,40,14,Project.Units.Item(mwUT_Length).UnitString,.Text5
End Dialog
Dim dlg2 As UserDialog
dlg2.TextBox1 = CStr( encX )
dlg2.TextBox2 = CStr( encY )
Dialog dlg2
encX = CDbl( dlg2.TextBox1 ) * Project.Units.Item(mwUT_Length).MultValue
encY = CDbl( dlg2.TextBox2 ) * Project.Units.Item(mwUT_Length).MultValue
Dim emName As String
emName = "em" + lay.Name
Set em = Project.EMStructures.Add( emName )
Set enc = em.Enclosure
enc.XDimension = encX
enc.YDimension = encY
Debug.Print enc.XDimension;" ";enc.YDimension
Debug.Print Project.Units.Item(mwUT_Length).MultValue
lay.CopyToClipboard
em.Paste(0,0)
End Sub

Working with the Material Layers Collection of Objects

After you have an EMStructure, you can access all of the MaterialLayers in the EMStructure and access all MaterialLayer
properties. You can also add a new MaterialLayer. After accessing the properties you can change the Dielectric Constant,
Loss Tangent, Thickness, and Bulk Conductivity. The following script demonstrates these capabilities:

' Add material layer


Sub Main
Dim Ems As EMStructure
Dim Mat As MaterialLayer
Dim index As Integer
' Clear the output window.
Debug.Clear
' Traverse the emstructures and material layers.
For Each Ems In Project.EMStructures
Debug.Print "Em Structure Name = " & Ems.Name
' List out the material layers of reference.
Debug.Print "Material Layer Count = " & Ems.MaterialLayers.Count
index = 0
For Each Mat In Ems.MaterialLayers
Debug.Print "Material # " & index
index = index + 1
Next Mat
' Attempt the add a new material layer.
Set Mat = Ems.MaterialLayers.Add()
PrintMateralProperties(Mat)
' List out the material properties again with the new layer.

1150 NI AWR Design Environment


Working with EM Structures

Debug.Print "Material Layer Count = " & Ems.MaterialLayers.Count


index = 0
For Each Mat In Ems.MaterialLayers
Debug.Print "Material # " & index
index = index + 1
Next Mat
Next Ems
End Sub
' Print out the properties of a material layer.
Sub PrintMateralProperties(ByRef Mat As MaterialLayer)
Debug.Print "Bulk Conductivity = " & Mat.BulkConductivity
Debug.Print "Dielectric Constant = " & Mat.DielectricConstant
Debug.Print "Hatch = " & Mat.Hatch
Debug.Print "Loss Tangent = " & Mat.LossTangent
Debug.Print "Thickness = " & Mat.Thickness
Debug.Print "Via Hatch = " & Mat.ViaHatch
Debug.Print "View Scale = " & Mat.ViewScale
End Sub

This script generates the following output:

Em Structure Name = MyEMStructure1


Material Layer Count = 2
Material # 0
Material # 1
Bulk Conductivity = 0
Dielectric Constant = 1
Hatch = 7
Loss Tangent = 0
Thickness = 9.99999974737875E-05
Via Hatch = 6
View Scale = 1
Material Layer Count = 3
Material # 0
Material # 1
Material # 2
Em Structure Name = EM S
Material Layer Count = 3
Material # 0
Material # 1
Material # 2
Bulk Conductivity = 0
Dielectric Constant = 1
Hatch = 7
Loss Tangent = 0
Thickness = 9.99999974737875E-05
Via Hatch = 6
View Scale = 1
Material Layer Count = 4
Material # 0
Material # 1
Material # 2
Material # 3

Access to the MaterialLayers collection allows you to get and to change hatch patterns used for conductors placed on a
layer, as shown in the following script:

API Scripting Guide 1151


Working with EM Structures

' List material layer hatch patterns


Sub Main
Dim Ems As EMStructure
Dim Mat As MaterialLayer
Debug.Clear
For Each Ems In Project.EMStructures
Debug.Print "Em Structure = " & Ems.Name
For Each Mat In Ems.MaterialLayers
Debug.Print "Material Hatch = " & HatchIDToName(Mat.Hatch)
Debug.Print "Material Via Hatch = " & HatchIDToName(Mat.ViaHatch)
Next Mat
Next Ems
End Sub
Function HatchIDToName(Id As Integer) As String
Dim hatch As String
Select Case (Id)
Case mwHS_None
hatch = "mwHS_None"
Case mwHS_Solid
hatch = "mwHS_Solid"
Case mwHS_Horizontal
hatch = "mwHS_Horizontal"
Case mwHS_Vertical
hatch = "mwHS_Vertical"
Case mwHS_ForwardDiagonal
hatch = "mwHS_ForwardDiagonal"
Case mwHS_BackwardDiagonal
hatch = "mwHS_BackwardDiagonal"
Case mwHS_Cross
hatch = "mwHS_Cross"
Case mwHS_DiagonalCross
hatch = "mwHS_DiagonalCross"
Case Else
hatch = "mwHS_Unknown"
End Select
HatchIDToName = hatch
End Function

This script generates the following output:

Em Structure = MyEMStructure1
Material Hatch = mwHS_DiagonalCross
Material Via Hatch = mwHS_Cross
Material Hatch = mwHS_Horizontal
Material Via Hatch = mwHS_Vertical
Material Hatch = mwHS_ForwardDiagonal
Material Via Hatch = mwHS_BackwardDiagonal
Em Structure = EM S
Material Hatch = mwHS_DiagonalCross
Material Via Hatch = mwHS_Cross
Material Hatch = mwHS_Horizontal
Material Via Hatch = mwHS_Vertical
Material Hatch = mwHS_Cross
Material Via Hatch = mwHS_DiagonalCross

1152 NI AWR Design Environment


Working with EM Structures

Material Hatch = mwHS_ForwardDiagonal


Material Via Hatch = mwHS_BackwardDiagonal

To modify the ViewScale factor that scales the thickness of the layers, use the following script:

' Material layers view scale


Sub Main
Dim Ems As EMStructure
Dim Mat As MaterialLayer
'Clear debug window.
Debug.Clear
For Each Ems In Project.EMStructures
Debug.Print "Em Structure = " & Ems.Name
For Each Mat In Ems.MaterialLayers
' Print the original view scale for reference.
Debug.Print "OldViewScale = " & Mat.ViewScale
' Set a new view scale.
Mat.ViewScale = 10
' Print the new view scale.
Debug.Print "NewViewScale = " & Mat.ViewScale
Next Mat
Next Ems
End Sub

This script generates the following output:

Em Structure = MyEMStructure1
OldViewScale = 1
NewViewScale = 10
OldViewScale = 1
NewViewScale = 10
OldViewScale = 1
NewViewScale = 10
Em Structure = EM S
OldViewScale = 1
NewViewScale = 10
OldViewScale = 1
NewViewScale = 10
OldViewScale = 5
NewViewScale = 10
OldViewScale = 1
NewViewScale = 10

Working with Shapes

You can draw Shapes in an EMStructure. Arguments to the Add Shape functions take drawing layer names directly to
the Layout Editor instead of the EM Editor.

The EMStructure object has a collection of Shapes that you can add with the Layout Editor. You can draw conductors,
vias, via-ports, and edge-ports.

When Shapes are added by the function they are added onto the Layer for which the Name is distinctively defined in
code.

API Scripting Guide 1153


Working with EM Structures

The function that adds Shapes has a string argument called layerName. This argument is interpreted as the layer Name
on which the shape is to be added (For example, "Thick Metal").

When you draw edge ports they must be associated with a conductor, so when using the AddPort or AddFace methods
you must draw the conductor first, and the points of the face must match the conductor points for the side to which it is
associated.

The following script demonstrates how to add an edge port:

' Code Module


Sub Main
Dim struct As emStructure
Debug.Clear
Set struct = Project.EMStructures("EM Structure 1")
Debug.Print struct.Name
' Edge ports need to be associated with a conductor
' so add a rectangle conductor first
struct.Shapes.AddRectangle(0,0,100e-6,100e-6,"Thick Metal")
' Now add the edge port and make sure the points align
' with points on the conductor it is to be associated with.
struct.Shapes.AddFace(0,0,0,100e-6)

To add a Via object to the EMStructure, you can draw a via using the regular Draw commands, and specify a layer that
has its mapping set up for a via. To add a ViaPort object, you can use the AddFace methods and match the points of the
face to the via points for the side with which it is associated.

' Code Module


Sub Main
Dim emStruct As emStructure
Debug.Clear
Debug.Print Project.EMStructures.Count
Set emStruct = Project.EMStructures("EM Structure 1")
Debug.Print emStruct.Name
'Add a via
emStruct.Shapes.AddRectangle(0,0,100e-6,100e-6,"Via")
'Add a rectangle(Encode layer Name into layerName argument)
'"Tantalum" means place on layer a conductor material Tantalum
objStruct.Shapes.AddRectangle(100e-6, 100e-6, 100e-6, 100e-6, "Tantalum")
' Add a polygon
Dim pnts(7) As Double
pnts(0) = 200e-6
pnts(1) = 200e-6
pnts(2) = 350e-6
pnts(3) = 200e-6
pnts(4) = 300e-6
pnts(5) = 300e-6
pnts(6) = 200e-6
pnts(7) = 300e-6
' Layer name is interpreted as material (
' material name must be in material list
objStruct.Shapes.AddPolygon(pnts, "Tantalum")
' Add an edge conductor
objStruct.Shapes.AddRectangle(0, 100e-6, 100e-6, 100e-6, "Cap Bottom")
' Add an edge port

1154 NI AWR Design Environment


Working with EM Structures

' Must draw conductor first and points must match conductor points
objStruct.Shapes.AddFace(0, 100e-6, 0, 200e-6)
End Sub

The following script prints the EMStructures DrawingLayers Names:

' Code Module


Sub Main
Dim emStruct As emStructure
Dim objShape As Shape
Set emStruct = Project.EMStructures("EM Structure 1")
For Each objShape In emStruct.Shapes
Debug.Print objShape.DrawingLayer.Name
Next objShape
End Sub

To access all Shapes in an EMStructure, use the following script:

' Code Module


' Verify operations on the EMStructurs shapes collection.
Sub Main
Dim Ems As EMStructure
Dim Shp As Shape
' Clear the output window.
Debug.Clear
' Process the shapes of each em structure.
For Each Ems In Project.EMStructures
Debug.Print "Em Structure = " & Ems.Name
Debug.Print "Shape Count = " & Ems.Shapes.Count
' Print a list of shapes for the structure.
Debug.Print "**** Shapes ****"
For Each Shp In Ems.Shapes
Debug.Print ShapeIDToName(Shp.Type)
Next Shp
Debug.Print
Next Ems
End Sub
' Convert a shape type identifier to a name.
Function ShapeIDToName(id As Integer) As String
Dim sName As String
Select Case (id)
Case mwST_Rectangle
sName = "mwST_Rectangle"
Case mwST_Polygon
sName = "mwST_Polygon"
Case mwST_Path
sName = "mwST_Path"
Case mwST_Ellipse
sName = "mwST_Ellipse"
Case mwST_Text
sName = "mwST_Text"
Case mwST_DrillHole
sName = "mwST_DrillHole"
Case mwST_Port
sName = "mwST_Port"

API Scripting Guide 1155


Working with EM Structures

Case Else
sName = "mwST_Unknown"
End Select
' Return the shape type name.
ShapeIDToName = sName
End Function

This script generates the following output:

Em Structure = MyEMStructure1
Shape Count = 6
**** Shapes ****
mwST_Polygon
mwST_Polygon
mwST_Polygon
mwST_Polygon
mwST_Polygon
mwST_Polygon
Em Structure = EM2lines
Shape Count = 4
**** Shapes ****
mwST_Polygon
mwST_Polygon
mwST_Polygon
mwST_Polygon

To access the Boolean command Simplify Shapes for EM Structure Shapes use InvokeCommand() method. The name
for this command is not quite what you'd expect from the external name. The command which is exposed to the user as
"Simplify Shapes..." is internally "ProcessEmShapes". This is because it calls the Shape Preprocessor to process the
shapes of an EM design. Since this command is a single shot command (meaning it doesn't need arguments) we can
invoke it using the internal name "ProcessEmShapes":

' Code Module


Sub Main
Dim em As EMStructure

Set em = Project.EMStructures("EM Structure 1")

em.InvokeCommand("ProcessEmShapes")

End Sub

The script would invoke the "Simplify Shapes..." command on the shapes in "EM Structure 1".

You can access the Shapes Attributes and Vertex collections with the following script:

' Code Module


Sub Main
Dim Shp As Shape
Dim attr As Attribute
Dim v As Vertex
' Clear the output window.
Debug.Clear
' Process the shapes of each em structure.

1156 NI AWR Design Environment


Working with EM Structures

Set Ems = Project.EMStructures("EM2lines")


Debug.Print "Em Structure = " & Ems.Name
Debug.Print "Shape Count = " & Ems.Shapes.Count
' Print a list of shapes for the structure.
Debug.Print "**** Shapes ****"
For Each Shp In Ems.Shapes
For Each attr In Shp.Attributes
Debug.Print attr.Name
Next attr
For Each v In Shp.Vertices
Debug.Print v.x;vbTab;v.y
Next v
Next Shp
End Sub

This script generates the following output:

Em Structure = EM2lines
Shape Count = 4
**** Shapes ****
LayerIndex
0 -0.00000946
0 -0.00000954
0.00001 -0.00000954
0.00001 -0.00000946
LayerIndex
0.000009608 -0.000009496
0.00001 -0.000009496
0.00001 -0.000009504
0.000009608 -0.000009504
LayerIndex
0.000009608 -0.000009492
0.000009608 -0.000009508
0.0000096 -0.0000095
LayerIndex
0.00001 -0.000009484
0.000010032 -0.000009484
0.000010032 -0.000009516
0.00001 -0.000009516

Each Shape is associated with Boundary Top, Bottom, Left, and Right properties:

Dim Shp As Shape


Set Ems = Project.EMStructures("EM2lines")
For Each Shp In Ems.Shapes
Debug.Print "Boundary.Bottom = ";Shp.Boundary.Bottom;
vbTab;"Boundary.Top = ";Shp.Boundary.Top
Debug.Print "Boundary.Left = ";Shp.Boundary.Left;vbTab;"Boundary.Right = ";Shp.Boundary.Right
Next Shp

EM Structure INFO Object

The API provides access to the EMStructure.Info values for Solve Time/Frequency, Total Solve Time, Memory
Requirement, Physical Memory, and MeshSize. The scope of these settings is the structure as whole.

API Scripting Guide 1157


Working with EM Structures

Dim Ems As EMStructure


For Each Ems In Project.EMStructures
Debug.Print "Em Structure = " & Ems.Name
Debug.Print "CacheSize = ";Ems.Info.CacheSize
Debug.Print "MemoryRequirement=";Ems.Info.MemoryRequirement
Debug.Print "MeshSize = ";Ems.Info.MeshSize
Debug.Print "PhysicalMemory = ";Ems.Info.PhysicalMemory
Debug.Print "TimePerFrequency = ";Ems.Info.TimePerFrequency
Debug.Print "TotalTime = ";Ems.Info.TotalTime
Next Ems

This code generates the following output:

Em Structure = EM2lines
CacheSize = 12800000 MemoryRequirement = 148864
MeshSize = 68 PhysicalMemory = 267698176
TimePerFrequency = 5.0430303948619 TotalTime = 10.0860607897238

Exploring EXTRACT Element Properties

The API provides access to the EXTRACT Element Properties. To view the Properties, use the following script:

Sub Main
Debug.Clear
Dim e As Element
Dim s As Schematic
Set s = Project.Schematics(1)
Set e = s.Elements("EXTRACT.EX1")
Dim i As Integer
For i = 1 To e.Properties.Count
Debug.Print e.Properties(i).Name & vbTab & e.Properties(i).Value
Next i
'e.Properties("AXIEM:Greens Function Accuracy").Value = 1
'e.Properties("AXIEM:Basis Integration Accuracy").Value = 5
'e.Properties("AXIEM:Moment Integration Method").Value = 0
End Sub

This script generates the following output:

AXIEM:ACA_REPORT 0
AXIEM:ACA_TOL 1.000000e-008
AXIEM:ACA_TOL_ZV_ZS_RATIO 2.000000e+001
AXIEM:AFS_MAX_PTS 40
AXIEM:AFS_TOL -3.000000e+001
AXIEM:Analytical Integration Singular Part of Greens Function 1
AXIEM:Basis Integration Accuracy 0
AXIEM:CACHED_ASSEMBLER 4224
AXIEM:CACHE_THRESHOLD_MULT 8.000000e+000
AXIEM:CBF_MAX_DIA_GRP 1.000000e-003
AXIEM:CBF_MAX_ELEM_GRP 50
AXIEM:COMPRESS_LOG 0
AXIEM:CONDUCTIVE_PEC 1.000000e-006
AXIEM:COND_NUM 0

1158 NI AWR Design Environment


Working with EM Structures

AXIEM:ClusterTree_maxNumElem 40
AXIEM:ClusterTree_minNumElem 5
AXIEM:DCIM SImage Loc Threshold 1.000000e-005
AXIEM:DCIM SImage Mag Threshold 1.000000e-003
AXIEM:DCIM T1 3.000000e+000
AXIEM:DCIM T2 1.000000e+002
AXIEM:DCIM_AutoStep1_Threshold 1.000000e-005
AXIEM:DROP_TOL 1.000000e-003
AXIEM:FILL_IN 1.000000e+002
AXIEM:FILL_IN_A 100
AXIEM:GMRES_TOL 1.000000e-007
AXIEM:GRNS_FNCT_DIAG 79
AXIEM:GRN_FNCT_PREC 2
AXIEM:Greens Function Accuracy 1
AXIEM:Greens Function Method 1
AXIEM:H_ETA_ZV_ZS_RATIO 1.000000e+000
AXIEM:H_MATRIX_DIAG 22
AXIEM:H_MAX_ELE_ZV_ZS_RATIO 1.000000e+000
AXIEM:H_Matrix_Eta 4.000000e+000
AXIEM:ILU_TOL 1.000000e-003
AXIEM:Include Scalar Potential Components 1
AXIEM:Include Static Image Components 1
AXIEM:Include Vector Potential Components 1
AXIEM:LOOP_TREE_SCALE_FACT 3.000000e+003
AXIEM:LT_ACA_RATIO 1.000000e+003
AXIEM:LT_MOM_ACC_RATIO 5.000000e-001
AXIEM:LowFSolverGauge 1.000000e-003
AXIEM:MAX_ITER 2000
AXIEM:MAX_NZ_ROW_A 200
AXIEM:MAX_NZ_ROW_R 1.000000e+002
AXIEM:MESH_BASIS_TYPES 511
AXIEM:MESH_DIAG 48742527
AXIEM:MESH_MIN_EDGE_RATIO 1.000000e+000
AXIEM:MESH_RATIO 1.000000e+001
AXIEM:MTX_CALC_DIAG 96
AXIEM:MTX_CALC_SOLVE_TYPE 3
AXIEM:MTX_COMPRESSION_DIAG 133184
AXIEM:Matrix Assembly Mode 1
AXIEM:Moment Integration Method 2
AXIEM:Number GPOF Samples 120
AXIEM:OCT_TREE_MAX_LEV 20
AXIEM:OPTIONS_TO_LOG 0
AXIEM:PC_TOL_REDUCE 1.000000e+003
AXIEM:PRECOND_DIAG 4100
AXIEM:PREC_GEN_E_PER_ROW 160
AXIEM:PRINT_MATRIX 0
AXIEM:Point Match Weighting Method 0
AXIEM:RANK_LOG 0
AXIEM:RCP_MAX_DIA_GRP 1.000000e-003
AXIEM:RCP_MAX_ELEM_GRP 50
AXIEM:REORDER 0
AXIEM:SUBSPACE_SIZE 400
AXIEM:SVD Absolute Limit 1.000000e-008
AXIEM:SVD Threshold 1.000000e-006
AXIEM:SVD_REL_TO_ACA 1.000000e+001
AXIEM:SVD_REPORT 0
AXIEM:Surface Wave Extraction 0

API Scripting Guide 1159


Working with EM Structures

AXIEM:USE_CROSS_TERMS 0
AXIEM:USE_DIRECT_BELOW 2000
AXIEM:Use EMSight Mesher 0
AXIEM:VERT_MESH_LAYERS 1
AXIEM:eACAPivotStrategy 1
AXIEM:eAxiemExtendTo0Flag 0
AXIEM:eAxiem_AFS_Options 6
AXIEM:eDeEmbeddingMethod 1
Bus_VectorInst_Name
EMSight:AFSdBDiff -4.000000e+001
EMSight:AFSnComparePts 200
EMSight:BandStart 1.500000e+010
EMSight:BandStop 1.500000e+010
EMSight:MaxSimPts 200
EMSight:SpecifyBand 0
EMSight:UseAFS 0
EMSight:UseRelErrorAFS 0
EMSight:deembed 1
EMSight:diffOrder 12
EMSight:fastFreqSweep 0
EMSight:iter_tolerance 1
EMSight:loadCurrents 1
EMSight:relError 0
EMSight:sameSizeBox 0
EMSight:saveCurInDoc 0
EMSight:singlePrec 0
EMSight:solveType 0
EMSight:tolerance 1
EMSocketOptions:errTol -4.000000e+001
EMSocketOptions:errorType 1
EMSocketOptions:numGridPoints 500
EMSocketOptions:saveAntenna 0
EMSocketOptions:saveCurrents 0
EMSocketOptions:saveFields 0
EMSocketOptions:useAdvFreqSweep 0
EMSocketOptions:useNativeEditor 0
EM_Extract_Group EM_Extract
EM_Extract_Tool
FreqOptions:1 1.500000e+010
FreqOptions:UseDefault 0
FreqOptions:nFreqs 1
InterPOptions:ForcePassive 0
InterPOptions:UseDefault 1
InterPOptions:interpCoord 0
InterPOptions:method 0
InterPOptions:numbInterpPoints 200
InterPOptions:splineOrder 3
InterPOptions:windowSize 6
MeshOptions:UseConformalCells 0
MeshOptions:UseDefault 1
MeshOptions:UseDiagonalCells 0
MeshOptions:maxX 100
MeshOptions:maxY 100
MeshOptions:meshDecimation 2
MeshOptions:meshDensity 2
MeshOptions:meshEdgeMeshing 1
MeshOptions:meshFreq 0.000000e+000

1160 NI AWR Design Environment


Working with EM Structures

MeshOptions:meshMaxAspectRatio 10
MeshOptions:meshZeroThickness 1
MeshOptions:minX 1
MeshOptions:minY 1
SpiceExtract:Element 4
SpiceExtract:YMatrix 8
PartNumber
PartHelpPath
XmlPath

The following code shows how to change EXTRACT Element properties:

Dim sch As Schematic


Dim ele As Element

Project.Simulator.Analyze
Debug.Clear

Set sch = Project.Schematics("Schematic 1")


Set ele = sch.Elements("EXTRACT.EX1")

Debug.Print "De-embedding Before Change: "; ele.Properties("AXIEM Async:eDeEmbeddingMethod").Value

ele.Properties("AXIEM Async:eDeEmbeddingMethod").Value = 1

Debug.Print "De-embedding After Change: "; ele.Properties("AXIEM Async:eDeEmbeddingMethod").Value

Debug.Print "Decimation Before Change: "; em.Options("eAX_MESH_DECIMATION_OPTIONS").Value

em.Options("eAX_MESH_DECIMATION_OPTIONS") = 0

Debug.Print "Decimation After Change: "; em.Options("eAX_MESH_DECIMATION_OPTIONS").Value

Accessing the AddExtraction Command

The following code shows how to do do EM extraction in api

' Code Module


Sub Main
Dim sch As Schematic
Dim extractEle As Element
Dim ele As Element
Set sch = Project.Schematics("16_Way_Power_Divider")
Set extractEle = sch.Elements.Add("EXTRACT",0,-1000,0,False,"")

' select the AXIEM solver for the EM analysis


extractEle.Parameters.Item("Simulator").ValueAsString = "5"

' set up simulator first as this determines the available parameters


extractEle.Parameters.Item("X_Cell_Size").ValueAsDouble = 20e-6
extractEle.Parameters.Item("Y_Cell_Size").ValueAsDouble = 20e-6

' extractEle.Parameters.Item("EM_Doc").ValueAsString = """ extractName """


extractEle.Parameters.Item("STACKUP").ValueAsString = """SUB1"""
extractEle.Parameters.Item("Explicit_Ground").ValueAsDouble = 1

API Scripting Guide 1161


Working with EM Structures

' set the model to be EM rather than closed form


ele.Options("ExtractModelType").Value = 1

Debug.Print "Extract now"


sch.AddExtraction

End Sub

Accessing the ShowMesh Command

The following describes how to do a 'mesh only' simulation through the API, when projects are too large for a full
simulation. You can perform a mesh-only simulation (for AXIEM) with project.EMStructures(x).CreateMesh. 2D
Annotation is automatically added when you run CreateMesh (if it did not exist). You still must add the 3D mesh
annotation if desired. Notice that this works with AXIEM.

' Code Module


Sub Main
Project.Annotations.Add("AXIEM_SPP_v5c:DIAGNOSE_MESH(1)[T]")
Project.EMStructures(1).CreateMesh
End Sub

Simulating a Specific EM Document

The following describes how to simulate one EM document only. After simulation, a Data Set named "EM_Sim_DS0"
is created.

Dim sch As Schematic


Set sch = Project.Schematics("16_Way_Power_Divider")

sch.AddExtraction

Project.EMStructures(1).Simulate("EM_Sim_DS0")

Wait(5)

Note that the API command is asynchronous. To verify whether or not a second simulation runs with the same EM
Structure, you must wait until the first simulation is complete and the Data Set is created.

Accessing an EM Schematic

An EMStructure document object has access to the Schematic properties. The following script shows how to see Schematic
Elements and access the parameters for those Elements. This script also shows how to access the Schematic Layout
drawing objects and attributes for the drawing objects.

' Code Module


Sub Main
Dim em As EMStructure
Dim schem As Schematic
Dim elem As Element
Dim param As Parameter
Dim lay As Layout

1162 NI AWR Design Environment


Working with EM Structures

Dim objDraw As DrawingObject


Dim attr As Attribute
Debug.Clear
For Each em In Project.EMStructures
Debug.Print "Structure name = " & em.Name
' Access schematic information.
Set schem = em.Schematic
Debug.Print "Schematic name = " & schem.Name
Debug.Print "Element Count = " & schem.Elements.Count
For Each elem In schem.Elements
Debug.Print " " & elem.Name
Debug.Print " Param Count = " & elem.Parameters.Count
For Each param In elem.Parameters
Debug.Print " " & param.Name
Next param
Debug.Print
Next elem
' Access layout information.
Set lay = schem.Layout
Debug.Print "Layout Name = " & lay.Name
Debug.Print "Drawing object Count = " & lay.DrawingObjects.Count
For Each objDraw In lay.DrawingObjects
Debug.Print " " & objDraw.TypeBits
For Each attr In objDraw.Attributes
Debug.Print " " & attr.Name & " = " & attr.Value
Next attr
Next objDraw
Next em
End Sub

Accessing the Ports Collection of the EMStructure Object

You can access a Ports collection object directly at the EMStructure level. As previously noted, you have access to
EMPorts by traversing to the DrawingObjects ports were associated with, but this is an inconvenient programming model
when you only need to traverse the ports. It is convenient for adding a port to a specific shape, but inconvenient if you
only want to know the ports of an EMStructure without traversing all the Drawing objects in the design.

The following code is an example of traversing the ports:

' Code Module


Sub Main
Dim emp As EMPort
Dim prts As EMPorts

Debug.Clear
Set prts = Project.EMStructures("EM Structure 1").Ports
Debug.Print prts.Count

For Each emp In prts


Debug.Print emp.Number
Next emp

End Sub

The following code is an example of Removing a Port:

API Scripting Guide 1163


Working with EM Structures

' Code Module


Sub Main
Dim emp As EMPort
Dim prts As EMPorts

Debug.Clear
Set prts = Project.EMStructures("EM Structure 1").Ports
Debug.Print prts.Count
prts.Remove(2)
Debug.Print prts.Count

End Sub

The following code is an example Deleting port in a multiport group. If EM ports are associated (attached) with the
rectangles that difficult to locate, and delete (port will go with them) try the following script:

' Code Module


Sub Main
Dim ems As EMStructure
Dim objDraw As DrawingObject
Dim delObj1 As DrawingObject
Dim delObj2 As DrawingObject
Dim index As Integer

Debug.Clear
Set ems = Project.EMStructures("MultiPort")
Debug.Print ems.Name

index = 1
For Each objDraw In ems.DrawingObjects
If (objDraw.EMPorts.Count > 0) Then
If (index = 1) Then
Set delObj1 = objDraw
index = index + 1
ElseIf (index = 2) Then
Set delObj2 = objDraw
index = index + 1
End If
End If
Next objDraw

If (index > 1) Then


Debug.Print "Delete Object 1"
delObj1.Delete
End If

If (index > 2) Then


Debug.Print "Delete Object 2"
delObj2.Delete
End If

End Sub

What this script does is look for DrawingObjects that have at least one EM port associated with them and then gets a
reference to the DrawingObject. Script uses a reference so we don't delete the objects while looping over them. It might

1164 NI AWR Design Environment


Working with EM Structures

work but it is safer to finish looping before deleting the objects. The final step is to use the DrawingObject.Delete()
method on each drawing object you have a reference to to delete the objects.

The following code is an example of Removing All Ports:

' Code Module


Sub Main
Dim emp As EMPort
Dim prts As EMPorts

Debug.Clear
Set prts = Project.EMStructures("EM Structure 1").Ports
Debug.Print prts.Count
prts.RemoveAll
Debug.Print prts.Count

End Sub

The following code is an example of Adding a Port:

' Code Module


Sub Main
Dim emp As EMPort
Dim prts As EMPorts

Debug.Clear
Set prts = Project.EMStructures("EM Structure 1").Ports
Debug.Print prts.Count
prts.Add(mwSPT_EdgePort, -10e-6, 350e-6, -640e-6, 350e-6)

Debug.Print prts.Count

End Sub

If the raw placement is too difficult you can use DrawingObject.EMPorts.Add, which adds it to a specific shape. Notice
that we have direct access to Drawing objects in the EM Structures.

The following code is an example of accessing Port properties:

' Code Module


Sub Main
Dim em As EMStructure
Dim p As EMPort

Debug.Clear

Set em = Project.EMStructures("get")
For Each p In em.Ports
Debug.Print "port number = " & p.Number
Debug.Print vbTab & "port deembed = " & p.Deembed
Debug.Print vbTab & "port termination real= " & p.Termination.Impedance.Real
Debug.Print vbTab & "port termination imaginary= " & p.Termination.Impedance.Imaginary
Debug.Print vbTab & "port deembedding distance = " & p.ReferencePlaneDist

API Scripting Guide 1165


Working with EM Structures

Next p
End Sub

The following are more examples of accessing Port properties:

' Code Module


Sub Main
Dim emp As EMPort
Dim ems As EMStructure

Debug.Clear
Set ems = Project.EMStructures("EMS1")
Debug.Print ems.Name

For Each emp In ems.Ports


Print_Port_Attributes(emp)
Debug.Print
Next emp
End Sub

Sub Print_Port_Attributes(ByRef emp As EMPort)


Debug.Print "Conductor = " & emp.Conductor
Debug.Print "Deembed = " & emp.Deembed
Debug.Print "Entity ID = " & emp.EntityID
Debug.Print "Flags = " & emp.Flags
Debug.Print "Group Num = " & emp.GroupNumber
Debug.Print "Group Type= " & emp.GroupType
Debug.Print "Layer = " & emp.Layer
Debug.Print "Line Type = " & emp.LineType
Debug.Print emp.NetID
Debug.Print emp.Number
Debug.Print emp.PhysicalThickness
Debug.Print emp.ReferencePlaneDist
Debug.Print emp.Thickness

Print_ComplexNumber "Excitation: ", emp.Excitation


Print_ComplexNumber "Impdedance: ", emp.Impedance
Print_Termination "Termination:", emp.Termination
Print_Vertices "Vertices: ", emp.Vertices

End Sub

Sub Print_ComplexNumber(Title As String, ByRef ex As ComplexNumber)


Debug.Print Title
Debug.Print " Angle = " & ex.Angle
Debug.Print " Magnitude = " & ex.Magnitude
End Sub

Sub Print_Termination(Title As String, ByRef term As EMPortTermination)


Debug.Print Title
Debug.Print " ExcitationAngle = " & term.ExcitationAngle
Debug.Print " ExcitationSize = " & term.ExcitationSignalSize
Debug.Print " ExcitationPort = " & term.ExcitationPort
Print_ComplexNumber " Excitation Impedance:", term.Impedance
End Sub

1166 NI AWR Design Environment


Working with EM Structures

Sub Print_Vertices(Title As String, ByRef verts As Vertices)


Dim vtx As Vertex

Debug.Print Title
For Each vtx In verts
Debug.Print "{ x = " & vtx.x & ", y = " & vtx.y & " } "
Next vtx
End Sub

This code produces the following output:

EMS1
Conductor =
Deembed = True
Entity ID = -1
Flags = 0
Group Num = 0
Group Type= 0
Layer = 2
Line Type = -1
0
2
0
0
0
Excitation:
Angle = 0
Magnitude = 0
Impdedance:
Angle = 0
Magnitude = 50
Termination:
ExcitationAngle = 0
ExcitationSize = 1
ExcitationPort = False
Excitation Impedance:
Angle = 0
Magnitude = 50
Vertices:
{ x = 0.00023, y = 0.00013 }
{ x = 0.00023, y = -0.0002 }
{ x = 0.00023, y = 0.00013 }
{ x = 0.00023, y = -0.0002 }
{ x = 0.00023, y = 0.00013 }

Conductor =
Deembed = True
Entity ID = -1
Flags = 0
Group Num = 0
Group Type= 0
Layer = 2
Line Type = -1
0
1

API Scripting Guide 1167


Working with EM Structures

0
0
0
Excitation:
Angle = 0
Magnitude = 1
Impdedance:
Angle = 0
Magnitude = 50
Termination:
ExcitationAngle = 0
ExcitationSize = 1
ExcitationPort = True
Excitation Impedance:
Angle = 0
Magnitude = 50
Vertices:
{ x = -0.00039, y = -0.0002 }
{ x = -0.00039, y = 0.00013 }
{ x = -0.00039, y = -0.0002 }
{ x = -0.00039, y = 0.00013 }
{ x = -0.00039, y = -0.0002 }

Conductor =
Deembed = False
Entity ID = -1
Flags = 0
Group Num = 0
Group Type= 0
Layer = 2
Line Type = -1
0
3
0
0
0
Excitation:
Angle = 0
Magnitude = 0
Impdedance:
Angle = 0
Magnitude = 50
Termination:
ExcitationAngle = 0
ExcitationSize = 1
ExcitationPort = False
Excitation Impedance:
Angle = 0
Magnitude = 50
Vertices:
{ x = -0.00008, y = -0.0002 }
{ x = -0.00008, y = 0.00013 }
{ x = -0.00008, y = -0.0002 }
{ x = -0.00008, y = 0.00013 }
{ x = -0.00008, y = -0.0002 }

1168 NI AWR Design Environment


Working with EM Structures

When analyzing output you can notice that EM ports are defined with 5 Vertices. EM ports points you query for are not
what you think they are. You may think EM port has two points. It should return only two points. But thats not the query
was set up for. There are always 5 points returned when you query EM port as shown below:

enum { Point1Index = 1, Point2Index, CondPt1Index, CondPt2Index, RefPlanePtIndex };

1st point and 2nd point are the EM ports edge vertices.3rd and 4th point are EM ports shapes edge vertices. 5th point
is reference plane vertex if EM port has ref plane. Often time, 1st and 2nd points are the same 3rd and 4th points. If they
are different, then its sign of problem.

The following script shows the problem when working with the complex type for Magnitude and Angle values:

' Code Module


Sub Main
Dim em As EMStructure
Dim p As EMPort

Debug.Clear

Set em = Project.EMStructures("get")
For Each p In em.Ports
Debug.Print "port number = " & p.Number
Debug.Print vbTab & "port deembed = " & p.Deembed
Debug.Print vbTab & "port termination real= " & p.Termination.Impedance.Real
Debug.Print vbTab & "port termination imaginary= " & p.Termination.Impedance.Imaginary
Debug.Print vbTab & "port deembedding distance = " & p.ReferencePlaneDist
Next p
End Sub

This script produces the following output:

port number = 7
port deembed = True
port termination real= 50
port termination imaginary= 0
port deembedding distance = 0
port number = 5
port deembed = True
port termination real= 50
port termination imaginary= 0
port deembedding distance = 0
port number = 3
port deembed = True
port termination real= 35
port termination imaginary= 2
port deembedding distance = 0.00001
port number = 1
port deembed = False
port termination real= 50
port termination imaginary= 0
port deembedding distance = 0
port number = 2
port deembed = False

API Scripting Guide 1169


Working with EM Structures

port termination real= 50


port termination imaginary= 0
port deembedding distance = 0
port number = 4
port deembed = True
port termination real= 50
port termination imaginary= 0
port deembedding distance = 0
port number = 6
port deembed = True
port termination real= 50
port termination imaginary= 0
port deembedding distance = 0

The following script sets parameters for the termination Excitation ports:

Sub Main
Dim em As EMStructure
Dim p As EMPort

Debug.Clear

Set em = Project.EMStructures("set")
For Each p In em.Ports
If p.Number=1 Then
Debug.Print "p.Number = 1"
Debug.Print "Termination.ExcitationPort: "; p.Termination.ExcitationPort
p.Termination.ExcitationPort=True
Debug.Print "After setting Termination.ExcitationPort: "; p.Termination.ExcitationPort
'p.Excitation.Magnitude=20
ElseIf p.Number=2 Then
Debug.Print "p.Number = 2"
Debug.Print "Termination.ExcitationPort: "; p.Termination.ExcitationPort
p.Termination.ExcitationPort=True
Debug.Print "p.Termination.ExcitationSignalSize: ";p.Termination.ExcitationSignalSize
p.Termination.ExcitationSignalSize=20.000 ' setting 20.026 in UI.
Debug.Print "p.Termination.ExcitationAngle: ";p.Termination.ExcitationAngle
p.Termination.ExcitationAngle=45
'p.Termination.Impedance.Magnitude=45
' p.Termination.Impedance.Angle=10
'p.Excitation.Magnitude=10.0
'p.Impedance.Magnitude=45
Debug.Print "After setting Termination.ExcitationPort: ";p.Termination.ExcitationPort
Debug.Print "p.Termination.ExcitationSignalSize: ";p.Termination.ExcitationSignalSize
Debug.Print "p.Termination.ExcitationAngle: ";p.Termination.ExcitationAngle
End If
Next p
End Sub

This script produces the following output:

p.Number = 1
Termination.ExcitationPort: True
After setting Termination.ExcitationPort: True
p.Number = 2

1170 NI AWR Design Environment


Working with EM Structures

Termination.ExcitationPort: True
p.Termination.ExcitationSignalSize: 20
p.Termination.ExcitationAngle: 45
After setting Termination.ExcitationPort: True
p.Termination.ExcitationSignalSize: 20
p.Termination.ExcitationAngle: 45

In the script get you can get most of the information, specifically the termination.impedance.real. In the set script,
however, the commands that did not work are commented out. The main problem is that in the complex type used for
these values, the Magnitude and Angle properties are read-only so you cannot assign them. The Read/Write properties
on these are the Real and Imaginary properties. Another problem is that the UI display is in dBm, however the API takes
value in base units. You can make the Magnitude and Angle values writeable, but there is a problem. You can convert
between Real and Imaginary and Magnitude and Angle, but the values are normally kept in Real/Image inside the system.
The assignment of Real and Imaginary is independent; you can assign either Real or Imaginary and the values are always
retained. However, when values are held in Real/Imaginary, assigning an Angle without any Magnitude is not retained,
so the assignment requires that the Magnitude be assigned before an Angle is applied. The following are some helpful
equations:

Function RealValue(Mag As Double, Ang As Double) As Double


RealValue = Mag * Cos(Ang * MathUtil.PI/180.0)
End Function

Function ImagValue(Mag As Double, Angle As Double) As Double


ImagValue = Mag * Sin(Ang * MathUtil.PI/180.0)
End Function

Function WattsFromDbm(PowDbm As Double) As Double


WattsFromDbm = (10.0 ^ (PowDbm/20.0))
End Function

The following is example of setting excitation Port impedance. The script outputs the port state before and after updating
the impedance values and sets the values to two different states to ensure the updated are registered correctly. The state
of the ports are dumped out at each stage:

' Code Module


Sub Main
Dim lay As Layout
Set lay = Project.Schematics("SCH1").Layout

Debug.Print lay.Name

Print_Ports_Status lay, "*** Before Setting Impedance ***"


Update_Port_Impedance lay, 75, 0
Print_Ports_Status lay, "*** After Setting Impedance 75, 0 ***"
Update_Port_Impedance lay, 45, 0
Print_Ports_Status lay, "** After Setting Impedance 45, 0 ***"

End Sub

Sub Update_Port_Impedance(ByRef lay As Layout, real As Double, imag As Double)


Dim objDraw As DrawingObject
Dim emp As EMPort

API Scripting Guide 1171


Working with EM Structures

For Each objDraw In lay.DrawingObjects


For Each emp In objDraw.EMPorts
emp.Impedance.Real = real
emp.Impedance.Imaginary = imag
Next emp
Next objDraw

End Sub

Sub Print_Ports_Status(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject
Dim emp As EMPort

Debug.Print title

For Each objDraw In lay.DrawingObjects


For Each emp In objDraw.EMPorts
Print_Port_Attributes(emp)
Debug.Print ""
Next emp
Next objDraw
Debug.Print ""

End Sub

Copy/Paste an EM Structures with Ports using EMStructure.InvokeCommand()

Note that the arguments to the em.InvokeCommand() call must be passed as an array if arguments are required. This
command takes (x, y, rotation, flip) as arguments also, so, we need additional entries. One for the rotation angle in degrees
and Boolean to indicate if they should be flipped when placed or not. Keep in mind that when using the em.Activate
command, the command will give an error if there isn't already an existing view. In the following code an If-Then added,
that checks for this case and adds a view before the em.Activate call:

' Code Module


Sub Main
Dim em As EMStructure
Dim emprt As EMPort

Debug.Clear

Set em = Project.EMStructures("Copy")

em.InvokeCommand("EditSelectAll")
em.InvokeCommand("EditCopy")

Set em = Project.EMStructures("Paste")

em.InvokeCommand("EditPaste", Array(0, 0, 0, False))

If (em.Windows.Count = 0) Then
em.NewWindow
End If

em.Activate

1172 NI AWR Design Environment


Working with EM Structures

For Each emprt In em.Ports


Debug.Print emprt.Conductor
Debug.Print emprt.Deembed
Debug.Print emprt.EntityID
Debug.Print emprt.Excitation
Debug.Print emprt.Flags
Debug.Print emprt.GroupNumber
Debug.Print emprt.GroupType
Debug.Print emprt.Impedance
Debug.Print emprt.Layer
Debug.Print emprt.LineType
Debug.Print emprt.NetID
Debug.Print emprt.Number
Debug.Print emprt.PhysicalThickness
Debug.Print emprt.ReferencePlaneDist
Debug.Print emprt.Termination
Debug.Print emprt.Thickness
Debug.Print emprt.Type
Dim vr As Vertex
For Each vr In emprt.Vertices
Debug.Print vr.x
Debug.Print vr.y
Next vr
Next emprt

End Sub

Boolean intersection operation on EM Structures Ports using EMStructure.InvokeCommand()

The following code uses EMStructure.InvokeCommand("ShapeIntersect") and checks the location of the ports before
and after the boolean operation:

' Code Module


Sub Main
Dim ems As EMStructure

Debug.Clear
Set ems = Project.EMStructures("EMS1")
Debug.Print ems.Name

PrintPortLocations ems, "Before Invoke Command"

ems.SelectedObjects.AddAll
ems.InvokeCommand("ShapeIntersect")

PrintPortLocations ems, "After Invoke Command"

End Sub

Sub PrintPortLocations(ByRef ems As EMStructure, title As String)


Dim objDraw As DrawingObject
Dim emp As EMPort
Dim vtx As Vertex
Dim index As Integer

API Scripting Guide 1173


Working with EM Structures

Debug.Print title
index = 1
For Each objDraw In ems.DrawingObjects
Debug.Print "Drawing Object[" & index & "] Ports: "
For Each emp In objDraw.EMPorts
Debug.Print "Port Number = " & emp.Number
Debug.Print "Vertices: "
For Each vtx In emp.Vertices
Debug.Print " Vertex Loc { x = " & vtx.x * 1e6 & ", y = " & vtx.y * 1e6 & " }"
Next vtx
Next emp
Debug.Print ""
index = index + 1
Next objDraw
End Sub

Accessing an EM Layout

An EMStructure document object has access to the Schematic object. The following script shows how to get EM Schematic
Layout document and how to work with EM Shapes using the same methods as for a Schematic Layout.

' Code Module


Sub Main
Dim schem As Schematic
Dim lay As Layout
Dim em As EMStructure

' Get the schematic and layout for that schematic.


Set em = Project.EMStructures(1)
Debug.Print schem.Name

Set lay = em.Schematic.Layout

' Select first pair of objects in the layout.

lay.SelectedObjects.AddFromArea(70e-6,-30e-6,280e-6,140e-6,mwAAT_ContainedObjects)
lay.SelectedObjects.AddFromArea(-80e-6,20e-6,90e-6,90e-6,mwAAT_ContainedObjects)

' Invoke the EditorAlignRight on the resulting selected shapes.

lay.InvokeCommand("EditorMakeSameSize")

lay.SelectedObjects.RemoveAll

End Sub

In general commands that require input will need some arguments to be supplied when they are invoked via
InvokeCommand. At some point in the past these may have put the user into path input mode and required the user do
digitize points, but that is not the intended behavior. That was because the command had not been modified to take
arguments and work correctly with InvokeCommand. All commands which require input either from the user or from a
dialog should take arguments that supply the values when Invoked via InvokeCommand through the API. The intended
behavior is that commands that require input should get the input via arguments supplied as an argument array in the
second argument of invoke command. A reason is that in general API and UI should be separate unless the script explicitly
creates a dialog using script, as mixing the two can cause scripts to hang. If the arguments are not correct for the command

1174 NI AWR Design Environment


Working with EM Structures

the InvokeCommand() will fail to invoke the command but provides a usage statement as a return value which indicates
how the command is to be invoked. So for example, we can get the usage statement from the InsertPath command using
the following program::

' Code Module


Sub Main
Dim ems As EMStructure
Dim arg As Variant
Dim ret As Variant
Debug.Clear
Set ems = Project.EMStructures("EM Structure 1")
ems.InvokeCommand("InsertPath", arg, ret)
Debug.Print ret
End Sub

Here we are providing a dummy arg value, and a return variant argument, and then printing what to get back. For this
command the return statement has the following string:

Error: Invalid Arguments, Usage: InsertPolygon(VARIANT argArray), where argsArray = Array(int numXY
double x2, double y2, ... , double xn, double yn)

The InsertPath and InsertPolygon are sharing the same error string but regardless this indicates that we need a number
to deall how many XY values we are supplying and then the XY values. So, the command should be invoked as follows:

' Code Module


Sub Main
Dim ems As EMStructure
Dim ret As Variant
Debug.Clear
Set ems = Project.EMStructures("EM Structure 1")
ems.InvokeCommand("InsertPath", Array(4, 0.0, 0.0, 100e-6, 0.0 ), ret)
Debug.Print ret
End Sub

Here we use Array() to pack multiple arguments into an variant argument for the command. When we invoke the command
this way we get a path from x = 0.0, y = 0.0 to x = 100e-6, y = 0.0 The format for invoking the "InsertPolygon is similar
but would requires a minimum of three points:

' Code Module


Sub Main
Dim ems As EMStructure
Dim ret As Variant
Debug.Clear
Set ems = Project.EMStructures("EM Structure 1")
ems.InvokeCommand("InsertPolygon", Array(6, 0.0, 0.0, 100e-6, 0.0, 50e-6, 50e-6 ), ret)
Debug.Print ret
End Sub

API Scripting Guide 1175


Working with EM Structures

The following script shows how to draw a Circle to a specific EM Layer and Material in EM layout document. For this
we need to go to the Layout tab when the EM was active to set the material for example to 1oz CU so it would create a
layer, that shows up as a +LAY_2_1oz Cu_COND layer in the lower window. The created layer appears to be some
special EM layer so it is not accessible through the Project.ProcessDefinitions(1).LayerSetup. For the version that uses
the command set the layer we should use Project.LayerSetup.DrawingLayers.ActiveLayer to set and get the active layer.
For the version that uses the API DrawingObjects.AddEllipse() method we couldn't add to the shapes collection by adding
to the DrawingObjects collection. We can use the attributes collection on the drawing object to get the layer names back
because the shapes collection do not have access the special EM layer. So, the Circle will be drawn at the layer as
+LAY_2_1oz Cu_COND after running the script:

Code Module
Sub Main
Dim lay As Layout
Dim ret As Variant
Dim dl As DrawingLayer
Dim objDraw As DrawingObject
Debug.Clear
Set lay = Project.EMStructures(1).Schematic.Layout

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If

lay.Activate

' Invoke the command to create the rectangle object.


Set dl = Project.LayerSetup.DrawingLayers("+LAY_2_1oz Cu_COND")
Project.LayerSetup.DrawingLayers.ActiveLayer = dl
Debug.Print "Setting Layer = " & dl.Name
Debug.Print "Active Layer = " & Project.LayerSetup.DrawingLayers.ActiveLayer.Name
lay.InvokeCommand("InsertCircle", Array(0, 0, 100e-6, 100e-6), ret)
Debug.Print ret

Debug.Print lay.Name
Debug.Print "DrawingObjects Count = " & lay.DrawingObjects.Count
For Each objDraw In lay.DrawingObjects
PrintDrawingObject objDraw
Debug.Print ""
Next objDraw

End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " & drawingObj.InfoText
Debug.Print "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)

End Sub

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Debug.Print "Parameters:"
For Each param In params

1176 NI AWR Design Environment


Working with EM Structures

Debug.Print param.Name & " = " & param.ValueAsString


Next param

End Sub

To print out the Drawing Layer Names use the following code:

Sub Main
Dim lay As DrawingLayer

For Each lay In Project.LayerSetup.DrawingLayers


Debug.Print lay.Name
Next lay

End Sub

The following script shows how to Copy / Paste a cell object which is plated to EM layout document:

' Code Module


Sub Main
Dim ems As EMStructure
Dim ret As Variant

Set ems = Project.EMStructures("EM Structure 1")


ems.SelectedObjects.AddAll

ems.InvokeCommand("EditCopy")
ems.InvokeCommand("EditPasteFlatten", Array(0,0), ret)
Debug.Print ret

End Sub

This code selects all the elements, copies them into the clipboard and then pastes them back into the EM design using
the EditPasteFlatten command and the coordinate x=0.0 y=0.0. Looking at the EM Layout afterward the original shapes
are still there but there is also an additional copy. In the additional copy the plated line cell has been turned into 3
rectangles indicating that it was flattened.

The following script shows Stretch Area command working on a polygon in an EM Schematic Layout document using
the InvokeCommand() method. The script will find the area definition shape that should be set before the script run (see
picture below), and then invoke the Stretch Area command to stretch the EM structure with the port in that area. Stretch
area command defined by ShapeStretch takes 4 arguments to define a rectangular selection region for the vertices to
be stretched and then two arguments to define the dx and dy:

Dim em As EMStructure
Dim lay As Layout
Dim objDraw As DrawingObject
Dim sh As Shape
Dim ret As Variant
Dim xyArray(1) As Double

API Scripting Guide 1177


Working with EM Structures

Debug.Clear
xyArray(0)= 1e-3
xyArray(1)= 0

Set lay = Project.EMStructures("Stretch_Area").Schematic.Layout


lay.InvokeCommand("EditSelectAll")
lay.SelectedObjects.AddAll
lay.InvokeCommand("ShapeStretch",xyArray,ret)
lay.Refresh

The following script shows how to stretch Shapes for EM Structure Layout using Edit Handles Move Command:

' Code Module


Sub Main
Dim ems As EMStructure
Dim lay As Layout
Dim objDraw As DrawingObject
Dim eh As EditHandle

Debug.Clear

Set ems = Project.EMStructures("X")


Set lay = ems.Schematic.Layout

'Check info text, to make sure correct drawing object is being stretched.
For Each objDraw In lay.DrawingObjects
'Debug.Print objDraw.InfoText
If InStr(objDraw.InfoText,"+LAY_3_Lay4_COND") > 0 Then
'Select middle edit handle on left side of rectangle
Set eh = objDraw.EditHandles(8)
'Move edit handle 50mils in x direction
eh.Move(50*25.4/1e6, 0)
End If
Next objDraw

'Make doc dirty to trigger resimulation

1178 NI AWR Design Environment


Working with EM Structures

Project.EMStructures(1).Changed =True
Project.EMStructures(1).Update
ems.Schematic.Layout.Refresh
End Sub

Whenever you change the EM layout through API, you should do this:

ems.Changed =True
ems.Update

The following script shows how to provide InvokeCommand() for Union Shapes for EM Structure Layout:

Set lay = Project.EMStructures("Union").Schematic.Layout


lay.InvokeCommand("EditSelectAll")
lay.SelectedObjects.AddAll
lay.InvokeCommand("ShapeUnion")

The following script shows how to provide Shape Mirror for EM Structure Layout.There are several Mirror type commands
in the command table. For the EM Structure layout we should use the following command and the arguments for the
command are x1, y1, x2, y2 of the mirror line:

' Code Module


Sub Main
' Project Module
'Private Sub Project_BeforeSimulate(Cancel As Boolean)
Dim lay As Layout
Dim objDraw As DrawingObject

Debug.Clear
Set lay = Project.EMStructures("EM Structure 1").Schematic.Layout
For Each objDraw In lay.DrawingObjects
objDraw.Selected = True
Next objDraw

Dim retVal As Variant


lay.InvokeCommand("EditMirror", Array(150e-6, -10e-6, 150e-6, 200e-6), retVal)
Debug.Print retVal

End Sub

The following script shows how to rotate shapes in an EM Schematic Layout document using the same methods as for
a Schematic Layout:

' Code Module


Sub Main
Dim em As EMStructure
Dim ret As Variant

Set em = Project.EMStructures("EM Structure 1")


em.Schematic.Layout.SelectedObjects.AddAll
em.Schematic.Layout.InvokeCommand("EditRotate", Array(0, 0, 90), ret)

API Scripting Guide 1179


Working with EM Structures

End Sub

Providing assistive interactive scripts

We added method to several document level objects in the API to allow commands to be started, similar to the way
InvokeCommand works but without supplying the arguments, so, the command can be completed interactively by the
user. There have been a few instances in the past where there have been requests to develop assistive scripts which help
the user accomplish a task but require input from the user to perform the desired actions. The model for the standard API
methods is not to have interaction with any UI elements other than updating them to reflect the results of changes the
methods have made. The same goes for InvokeCommand(), the method is intended to be a parametric API for completing
tasks using command objects, so the model for InvokeCommand is to supply any input required to complete the command
as arguments to the method in a variant array. These new StartCommand methods provides a mechanism to support
starting commands that would place the user into an interactive mode to complete the command.

Accessing EM3D Structures Properties

We have support in the API for EM3D Structures Properties.

The code should look something like in the following example:

Dim ems As EM3DStructure

For Each ems In Project.EM3DStructures


PrintEMSProperties ems
ems.Enabled = False
Next ems

End Sub

Sub PrintEMSProperties(ByRef ems As EM3DStructure)


Print #1, "Name = " & ems.Name
Print #1, "Changed = " & ems.Changed
Print #1, "Embedded = " & ems.Embedded
Print #1, "Enabled = " & ems.Enabled
End Sub

The following code shows access to View > Visual > Shapes Merged option:

' Code Module


Sub Main
Dim schem As Schematic
Dim view3D As ThreeDView

Debug.Clear
Set schem = Project.Schematics("Via_on_Plane")
If (schem.Layout.ThreeDViews.Count = 0) Then
schem.NewWindow(mwWT_Schematic3DLayout)
End If

Set view3D = schem.Layout.ThreeDViews(1)


Debug.Print "Merge Shapes = " & view3D.ShapesMerged

1180 NI AWR Design Environment


Working with EM Structures

' Toggle the value.


view3D.ShapesMerged = Not view3D.ShapesMerged

Debug.Print "Merge Shapes = " & view3D.ShapesMerged

End Sub

Changing color in 3D editor

We can send a script to 3D editor to change material color. Usually the script is written with Pyton commands:

Sub Main
Dim em3d As EM3DStructure
Dim extEd As ExternalEditor
Dim cmds As String

Dim ele As Element


Dim mName As Parameter
Dim mColor As Parameter
Dim mat_array() As String
Dim color_array() As String

Debug.Clear

'send a script to 3D editor to change material color


Set em3d = Project.EM3DStructures("3D EM Structure 1")
Set extEd = em3d.OpenExternalEditor(mwEET_OrionEditor, mwEECS_Hide)
cmds = Project.DataFiles("change_mat_color").DataAsText
extEd.RunScript(cmds)
extEd.Save
extEd.Close
em3d.Update

Set ele = Project.EM3DStructures(1).Schematic.Elements("STACKUP.SUB")

Set mName = ele.Parameters("MatName")


Set mColor = ele.Parameters("Color")

x = Replace$(mName.ValueAsString, """", "")


x = Replace$(x, "{", "")
x = Replace$(x, "}", "")
mat_array = Split(x, ",")

x = Replace$(mColor.ValueAsString, "{", "")


x = Replace$(x, "}", "")
color_array = Split(x, ",")

'Print out material color on MWO side


For i = 0 To UBound(mat_array)
Debug.Print "MatName: " & mat_array(i) & vbTab & "Color: " & color_array(i)
Debug.Print "MatName: " & mat_array(i) & vbTab & "Color: " & color_array(i)
Next i

em3d.Enabled=False

API Scripting Guide 1181


Working with EM Structures

End Sub

Editing multiple parameters on a parameterized 3D EM Orion subcircuit

We have support in the API to both Lock and Unlock the parameterized layout. When the call to unlock is made api also
provides update of the layout.

Multi-edits should look something like in the following code:

Dim em As EMStructure
Dim sch As Schematic
Dim ele As Element
Dim param As Parameter

Debug.Clear

Set sch = Project.EMStructures("horz_wave_port").Schematic


Set ele = sch.Elements("SUBCKT.S1")

ele.LockParameterizedLayout = True
ele.Parameters("InLen").ValueAsDouble=400
ele.Parameters("DieLen").ValueAsDouble=400
ele.Parameters("OutLen").ValueAsDouble=400
ele.LockParameterizedLayout = False

Where the call ele.LockParameterizedLayout = False at the end both Unlocks the layout and requests for it to be updated.

Accessing Equations Directly on an EM Structure Object

You can access equations directly on an EM Structure object as shown in the following code:

Project.EMStructures(1).Equations

You also can access equations as shown in the following code:

Project.EMStructures(1).Schematic.Layout.Equations

Addition of a StackupUtil interface of MWOffice.

We Implemented stackup utility API functions.

Simple example usage:

Sub Main
Dim su As StackupUtil
Set su = MWOffice.StackupUtil
Dim s As Element
Set s = Project.EMStructures(1).Schematic.Elements("STACKUP.SUB")

su.SetStackup(s)

1182 NI AWR Design Environment


Working with EM Structures

su.ClearStackup()

su.AddDielectricMaterial("AIR", 1.0, 0.0)


su.AddDielectricMaterial("FR4", 4.5, 0.035)
su.AddConductorMaterial("COPPER", 59590000)

su.InsertDielectricLayer("AIR", 1, 0.0002032)
su.InsertDielectricLayer("FR4", 2, 0.0002032)
su.InsertDielectricLayer("FR4", 3, 0.0002032)
su.InsertDielectricLayer("FR4", 4, 0.0002032)
su.InsertDielectricLayer("AIR", 5, 0.0002032)

su.MapConductor("Cap Bottom", "COPPER", 3.04800e-5, 3)


su.MapVia("Via", "COPPER", 2, 4)
End Sub

Displaying the EM Stackup for AXIEM

To help visualize EM Stackups you can use the Show_EM_Stackup.bas script.

To access SPP rules converted from options, use the EM Stackup Element:

Dim em As EMStructure
Dim ele As Element
Dim p As Parameter

Set em = Project.EMStructures(1)
Set ele = em.Schematic.Elements("STACKUP.SUB")

Debug.Print ele.Parameters("SppRules").ValueAsString

Dim rules() As String


rules = Split(Trim(ele.Parameters("SppRules").ValueAsString), vbCrLf)
Debug.Print UBound(rules)

Example of the rules output:

"!build up layers for air bridge


BOOLEAN_OPS "temp1" "Thick Metal" AND "Air Bridge"
BOOLEAN_OPS "tmtemp" "Thick Metal" SUBTRACT "temp1"
RESIZE "temp2" "temp1" 2000
BOOLEAN_OPS "temp3" "temp2" AND "Thick Metal"
REPLACE "Thick Metal" "tmtemp"
BOOLEAN_OPS "em_air_bridge_via" "temp3" AND "Thick Metal"
REPLACE "Air Bridge" "temp3"
LDELETE "temp1"
!resize via
RESHAPE_CIRCLES_DIVS 8 "Via"
!attempt to clean up plated lines.
!LIST mylist "Nitride Etch" "Cap Bottom" "Thick Metal"
!try to snap out plated lines, gets cap bottom and nitride lined up, but not thick metal
BOOLEAN_OPS "temp3" "Cap Bottom" AND "Nitride Etch"
RESIZE "em_thick_metal" "temp3" 3000

API Scripting Guide 1183


Working with EM Structures

BOOLEAN_OPS "cb_temp" "Cap Bottom" SUBTRACT "em_thick_metal"


REPLACE "Cap Bottom" "cb_temp"
BOOLEAN_OPS "ne_temp" "Nitride Etch" SUBTRACT "em_thick_metal"
REPLACE "Nitride Etch" "ne_temp"
BOOLEAN_OPS "tm_temp" "Thick Metal" SUBTRACT "em_thick_metal"
REPLACE "Thick Metal" "tm_temp"

"
28

If the STACKUP Element is in a Global Definitions document, access to SPP Rules is slightly different:

' Code Module


Sub Main
Debug.Clear
Dim p As Parameter, e As Element
Set e =Project.GlobalDefinitionDocuments(1).DataElements("STACKUP.with_nitride1")

For Each p In e.Parameters


'Debug.Print p.Name
Next p
Debug.Print e.Parameters("SppRules").ValueAsString
Dim rules() As String
rules = Split(Trim(e.Parameters("SppRules").ValueAsString), vbCrLf)
Debug.Print UBound(rules)

End Sub

Adding a STACKUP Element to Global Definitions and Showing the Parameters.

To add a STACKUP Element to Global Definitions and show the parameters, use the following script:

' Code Module


Sub Main
Dim elem As Element
Dim param As Parameter

Set elem = Project.GlobalDefinitionDocuments(1).DataElements.Add("STACKUP", 0, 0)


For Each param In elem.Parameters
Debug.Print param.Name
Next param

End Sub

This script generates the following output:

Name
DieT
DieInd
DScale
GndInd

1184 NI AWR Design Environment


Working with EM Structures

GndCond
TrcName
T
W
MinW
MatInd
TScale
EtchAng
Surf
LTName
LayName
LayInd
LtGInd
LtUInd
TrcInd
TrcUInd
TrcGInd
LTFlags
ViaCell
VPName
ViaLay
VProp
MatName
MatType
Color
ErZ
ErX
ErY
UrZ
UrX
UrY
SigmaZ
SigmaX
SigmaY
TanDZ
TanDX
TanDY
TanMZ
TanMX
TanMY
ErZEQ
ErXEQ
ErYEQ
UrZEQ
UrXEQ
UrYEQ
TanDZEQ
TanDXEQ
TanDYEQ
TanMZEQ
TanMXEQ
TanMYEQ
ResSq
ResF
React
LpfName
emMapName

API Scripting Guide 1185


Working with EM Structures

ResSqEQ
ReactEQ
SppRules

You can create the stackup, but there is no method via the API to create the EM document with that stackup from the
Global Definitions as part of the initialization.

Copying an EMStructure to a New Window

To copy an EMStructure to a new Window, use the following script:

' Copying EMStructure to a new Window


Sub Main
Debug.Clear
Dim Ems As EMStructure
Dim w As Window
Set w = Project.EMStructures("EM2lines").NewWindow(mwWT_EmStructure)
Debug.Print w.Caption
End Sub

The output contains the new Window Name:

EM2lines:1

The new Window displays in the workspace.

You can copy an EMStructure to the Clipboard using the CopyToClipboard method.

Set emStruct = Project.EMStructures(1)


emStruct.CopyToClipboard
' After copying EMStructure somewhere in the script we can Paste EMStructure
Debug.Print "Attempting to paste";
If (emStruct.CanPaste) Then
emStruct.Paste(0, 0)
Else
MsgBox("Can Paste Returned False, is the clipboard empty?")
End If
Debug.Print "....Complete"
End Sub

You can copy an EMStructure to another EM Structure using the Invoke Command method:

' Code Module


Sub Main
Dim em As EMStructure
Dim emprt As EMPort

Debug.Clear

Set em = Project.EMStructures("Copy")

em.InvokeCommand("EditSelectAll")
em.InvokeCommand("EditCopy")

1186 NI AWR Design Environment


Working with EM Structures

Set em = Project.EMStructures("Paste")

em.InvokeCommand("EditPaste", Array(0, 0, 0, False))

If (em.Windows.Count = 0) Then
em.NewWindow
End If

em.Activate

For Each emprt In em.Ports


Debug.Print emprt.Type
Next emprt

End Sub

Note that the arguments to the em InvokeCommand() call must be passed as an array if arguments are required. Also
this command takes (x, y, rotation, flip) as arguments so we need two additional entries. One for the rotation angle in
degrees and Boolean to indicate if they should be flipped when placed or not. We use the em.Activate command, so, this
will not give an error if there isn't already an existing view. We added an If-Then above that checks for this case and
added a view before the em.Activate call.

Activating an EM Structure
To activate an EM structure, use the following code:

Dim emStruct As emStructure


Set emStruct = Project.EMStructures(1)
Debug.Print "Activating emStructure " & emStruct.Name;
If (emStruct.Windows.Count = 0) Then
emStruct.NewWindow(mwLWT_Layout2D)
End If
emStruct.Activate

Excluding EM Structures from Simulation (Toggle Enable)


To prevent an EMStructure from simulating, use the following script:

' Toggle EMStructure Enabled


Sub Main
Dim Ems As EMStructure
' Process each of the emstructures in the project.
For Each Ems In Project.EMStructures
Debug.Print "EM Structure Name = " & Ems.Name
Debug.Print "Enabled = " & Ems.Enabled
' Try setting the emstructure state to the opposite of current state.
Ems.Enabled = Not Ems.Enabled
Debug.Print "Enabled = " & Ems.Enabled
Next Ems
End Sub

This script generates the following output:

API Scripting Guide 1187


Working with EM Structures

EM Structure Name = MyEMStructure1


Enabled = True
Enabled = True
EM Structure Name = EM2lines
Enabled = False
Enabled = False

Exporting EM Structures
The following script demonstrates the API ability to Export an EMStructure:

' Export EMStructure


Sub Main
Dim struct As EMStructure
For Each struct In Project.EMStructures
' Print the structure name for reference
Debug.Print "Structure Name = " & struct.Name
' Attempt to export the EMStructure.
struct.Export(struct.Name & ".eml")
' Now attempt to re-import it.
Project.EMStructures.Import("MyEMStructure.eml")
Next struct
End Sub

The following script demonstrates the API method EMStructure.ExportEMInputDataXML(string path) to export EM
input data in XML format. There are two examples od code. First example provides a call on the EM Structure object
to allow the EM Input data to be exported in XML format in standard EM socket XML format. The second example
provides a call on the EM Structure object to allow the EM Input data to be exported in XML format in simplified EM
Socket XML format.

' Code Module


Sub Main
Dim exPath As String
Dim ems As EMStructure

exPath = Project.Path & "EMStructureExport.xml"


Set ems = Project.EMStructures("EM Structure 1")
ems.ExportEmInputDataXML exPath
End Sub

To export Simplfied EM Socket Data we need to use extra argument mwEIX_EMSocketSimplifiedDataFile:

' Code Module


Sub Main
Dim exPath As String
Dim ems As EMStructure

exPath = Project.Path & "EMStructureExport.xml"


Set ems = Project.EMStructures("EM Structure 1")
ems.ExportEmInputDataXML exPath, mwEIX_EMSocketSimplifiedDataFile

1188 NI AWR Design Environment


Working with EM Structures

End Sub

Outputting .emi Data


The following script demonstrates the API ability to output EMI Input data information:

Sub Main
Dim em As EMStructure
Debug.Clear
Set em = Project.EMStructures("em")
em.SelectedObjects.AddAll
Debug.Print "Start"
em.InvokeCommand("AwrOutputEMInputData")
Debug.Print "Done"
End Sub

It is no longer necessary to go through the Schematic and Layout from the EM Structure. The calls for em.SelectedObjects
and em.InvokeCommand can be performed directly on the EM Structure object

Note that SPP is triggered when outputting the .emi data. You can set a timer for before and after simulation events to
time the SPP rules process run.

Dim t1 As Double
Dim t2 As Double

Private Sub Project_AfterSimulate()


Dim t As Double
Dim fn As String
Dim emDoc As String

'Enter your EM Document name here


emDoc="AE_sch2_Doc"
'--------------------------------

GenEmData(emDoc)
t2 = Timer
t = awr_timer(t1,t2)
fn = AWR_get_perf_file
Open fn For Append As #1
tks = Split(Project.Name,".")
Print #1, Chr(34) & tks(0)& "@sim_time" & Chr(34) & vbTab & t
Close #1
End Sub

Private Sub Project_BeforeSimulate(Cancel As Boolean)


t1 = Timer
End Sub
Function GenEmData(emName As String)
Dim em As EMStructure
Set em = Project.EMStructures(emName)
em.InvokeCommand("AwrOutputEMInputData")

End Function

API Scripting Guide 1189


Working with EM Structures

Function awr_timer(tstart As Double, tstop As Double) As Double


tt = tstop-tstart
If tt lt 0 Then 'means had rollover at midnight.
tt = tt + 86400
End If
awr_timer = tt
End Function
Function AWR_get_perf_file() As String
Dim objFileSystem As Scripting.FileSystemObject
Set objFileSystem = New Scripting.FileSystemObject

bd = MWOffice.BuildNumber ' need to be able to get minor number, need that in the API.
'folder location
pth = MWOffice.Directories(2).ValueAsString & "\testresults\"
'pth = "C:\AWR_PerfLogs\"
'check to make sure path exists, more for testing than running code.
If objFileSystem.FolderExists(pth) = False Then
objFileSystem.CreateFolder(pth)
End If

fn = pth & "DesEnv_B" & MWOffice.BuildNumber & "_R" & MWOffice.BuildRevision & ".per"
If objFileSystem.FileExists(fn) = False Then
Open fn For Output As #1
Print #1, """Name""" & vbTab & """Time(s)$T"""
Close #1
End If
AWR_get_perf_file = fn
End Function

Exploring the EMStructures Window Collection


The following code demonstrates the API ability to Explore the EMStructures Window collection of objects:

Dim emStruct As emStructure


Dim win As Window
Dim index As Integer
Debug.Clear
Set emStruct = Project.EMStructures(1)
Debug.Print "Em Structure " & emStruct.Name & " Windows: "
index = 1
For Each win In emStruct.Windows
Debug.Print "Window[" & index & "] = " & win.Caption
index = index + 1
Next win

Working with 3D EM Editor


The following code demonstrates the API ability to access Python script:

Sub Main
If Project.EM3DStructures.Exists("My3DStructure") Then
Else
Dim em3d As EM3DStructure
Dim extEd As ExternalEditor

1190 NI AWR Design Environment


Working with EM Structures

Dim cmds As String

Set em3d = Project.EM3DStructures.Add("My3DStructure")


Set extEd = em3d.OpenExternalEditor(mwEET_OrionEditor, mwEECS_Hide)
cmds = Project.DataFiles("analyst_python_script_no_v").DataAsText
extEd.RunScript(cmds)
extEd.Save
extEd.Close
em3d.Update
End If
End Sub

The Python script is in DataFile node of the project tree and is a text data:

import analyst
Model_1 = analyst.GetModel()
VariableManager_1 = Model_1.GetVariableManager()
Variable_1 = VariableManager_1.NewVariable("inner_length", "1.5 cm", "new variable for Height", "0"
Variable_2 = VariableManager_1.NewVariable("inner_radius", "0.1 cm", "new variable for Radius", "0"
Structure_1 = Model_1.GetStructure()
Geometry_1 = Structure_1.GetGeometry()
Solid_1 = Geometry_1.Cylinder("Cylinder_1", "World", "Air", "0, 0, 0", "0, 0, 1", "inner_length", "
Solid_1.SetExMaterial("Perfect Conductor")
Variable_3 = VariableManager_1.NewVariable("outer_height", "1.1 cm", "new variable for Height", "0"
Variable_4 = VariableManager_1.NewVariable("outer_to_inner_ratio", "0.632455532033676 cm", "new var
Variable_4.SetExValue("4")
Solid_2 = Geometry_1.Cylinder("Cylinder_2", "World", "Perfect Conductor", "0, 0, 1.35525271560688e-
Solid_2.SetExMaterial("Air")
ViewConfig_1 = Geometry_1.GetViewConfig()
ViewConfig_1.SetIsolated(None)
Variable_6 = VariableManager_1.NewVariable("outer_radius", "outer_to_inner_ratio*inner_radius", "my
ViewConfig_1.SetIsolated(Solid_2.Get_IIsolatable())
SolidOperation_2 = Solid_2.Get_ISolid().GetOperation(0)
SolidOperation_2.Get_ICylinder().SetExRadius("outer_radius")
Variable_4.SetExValue("5")
ViewConfig_1.SetIsolated(Solid_1.Get_IIsolatable())
Camera_1 = ViewConfig_1.Get_IView3DConfig().GetCamera()
AttributeSet_1 = Structure_1.GetAttributeSet(0)
RF_Port_1 = AttributeSet_1.NewExcitation("RF_Port")
Application_1 = Solid_1.Get_ISolid().ApplyAttributeFace(RF_Port_1, 0, 2)

The next Script changes color in 3D editor, then checks the color from MWO:

' This code checks that changes to a material color in 3D editor is transferred back to MWO
Dim em3d As EM3DStructure
Dim extEd As ExternalEditor
Dim cmds As String

Dim ele As Element


Dim mName As Parameter
Dim mColor As Parameter
Dim mat_array() As String
Dim color_array() As String

Debug.Clear

API Scripting Guide 1191


Working with Graphs

'send a script to 3D editor to change material color


Set em3d = Project.EM3DStructures("3D EM Structure 1")
Set extEd = em3d.OpenExternalEditor(mwEET_OrionEditor, mwEECS_Hide)
cmds = Project.DataFiles("change_mat_color").DataAsText
extEd.RunScript(cmds)
extEd.Save
extEd.Close
em3d.Update

Set ele = Project.EM3DStructures(1).Schematic.Elements("STACKUP.SUB")

Set mName = ele.Parameters("MatName")


Set mColor = ele.Parameters("Color")

x = Replace$(mName.ValueAsString, """", "")


x = Replace$(x, "{", "")
x = Replace$(x, "}", "")
mat_array = Split(x, ",")

x = Replace$(mColor.ValueAsString, "{", "")


x = Replace$(x, "}", "")
color_array = Split(x, ",")

'Print out material color on MWO side


For i = 0 To UBound(mat_array)
Debug.Print "MatName: " & mat_array(i) & vbTab & "Color: " & color_array(i)
Next i

em3d.Enabled=False

The Python script is in DataFile node of the project tree and is a text data:

Model_1 = analyst.GetModel()
Structure_1 = Model_1.GetStructure()
Geometry_1 = Structure_1.GetGeometry()
ViewConfig_1 = Geometry_1.GetViewConfig()
MaterialManager_1 = Geometry_1.GetMaterialManager()
Material_4 = MaterialManager_1.Get("geeamaterial")
ViewConfig_1.Get_IView3DConfig().AddIsolated((Material_4.Get_IIsolatable()))
Material_4.Get_IAttribute().SetExColor("255, 0, 38, 255")

Working with Graphs


The NI AWR SDE allows you to choose measurements to display the results of simulation in graphical form. When you
create a Graph via the API, the graph displays in the Graphs node of the Project Browser.

Creating a New Graph


The core object in the NI AWR SDE is a Project. From the Project object, you can access the Graphs collection of objects.
The following code example adds a new Graph to the Graphs collection:

Dim gs As Graphs

1192 NI AWR Design Environment


Working with Graphs

Dim g As Graph
Set gs = Project.Graphs
Set g = gs.Add("New Graph",mwGT_Rectangular)

The "Add" function does not overwrite an existing Graph. If the Graph named "New Graph" already exists, the new
Graph is named "New Graph1".

This example uses the Add method, which takes two arguments (the name of the Graph you want to add, and the constant
that defines the Graph type).

Constants that define different types of graphs available via the API are shown in the following table:

Name Value
mwGT_Polar 1
mwGT_SmithChart 2
mwGT_Rectangular 3
mwGT_Tabular 4
mwGT_Antenna 5
mwGT_Histogram 6
mwGT_ThreeDim 7
mwGT_Constellation 8

You can set all types of Graphs that are shown in the table.

In the previous example, "g" is the created reference to the "New Graph". After running the script, a new subnode named
"New Graph" displays under the Graphs node in the Project Browser.

To Add a measurement to the graph using the HSPICE simulator, use the following code:

Dim gs As Graphs
Dim g As Graph
Set gs = Project.Graphs
Set g = gs.Add("New Graph",mwGT_Rectangular)
g.Measurement.Add("TOP.HS","S(2,2)")

To Return the index of the plot axis for the measurement (you can also set the Index), use the following code:

Debug.Print m.AxisIndex

To Delete an existing Graph by name, use the following code:

Project.Graphs. Remove ("New Graph")

A "New Graph" subnode displays in the Project Browser.

API Scripting Guide 1193


Working with Graphs

Working with the Graph Collection


Copying and Printing Graphs

The NI AWR SDE allows you to Copy a graph (including tabular graph) to the Clipboard.

Project.Graphs. ("New Graph").CopyToClipboard

Method PrintOut sends the Graph object to the current printer.

Project.Graphs. ("New Graph").PrintOut

Modifying the Graph Display

You can configure how Graphs display. You can change settings such as colors, fonts, labels, traces, Axes collection
properties, Border Properties, Title, and TickMarks properties.

The following are examples of code to access different Graph objects and properties.

Printing Graph Name and Type

To print the graph name and type, use the following code:

Dim g As Graph
Set g = Project.Graphs(1)
Print #1, "Graph";
Debug.Print "Name=" & g.Name;
Debug.Print "Type=" & g.Type;

Printing Graph Attributes

The API provides access to the Attributes collection of objects for all types of Graphs. The Attributes collection provide
named values that correspond to the values you can set when accessing the Options dialog box for a grid. All of the
options available in the Graph Options dialog boxes are available through the Graph.Attributes collection.

' Code Module


Sub Main
Dim grp As Graph
Dim atr As Attribute

Debug.Clear
For Each grp In Project.Graphs
For Each atr In grp.Attributes
Debug.Print atr.Name;vbTab;atr.Type;vbTab;atr.Value;vbTab;atr.ValueAsString
Next atr
Next grp
End Sub

This script generates the following output:

1194 NI AWR Design Environment


Working with Graphs

ChartStyle 2 0 0
GraticuleColor 2 0 0
MajorDivisionsColor 2 9 9
MinorDivisionsColor 2 9 9
XAxisLineStyle 2 0 0
LeftYAxisLineStyle 2 0 0
RightYAxisLineStyle 2 0 0
ShowTickMarks 0 True -1
TickMarkSize 5 3 3
UseDefaultXLabel 0 True -1
DefaultXLabel 6
ChartStyle 2 0 0
DefaultSweepRange 0 False 0
SweepDisplayMin 5 30000000000 30000000000
SweepDisplayMax 5 40000000000 40000000000
ImdedanceGridVisible 0 True -1
AdmittanceGridVisible 0 False 0
ValuesVisible 0 True -1
AutoSize 0 False 0
ChartSize 2 1 1
AutoContour 0 False 0
ContourDensity 2 1 1
GraticuleColor 2 0 0
ImdedanceColor 2 9 9
AdmittanceColor 2 9 9
ImpedanceLineStyle 2 0 0
AdmittanceLineStyle 2 0 0
SweepMinimum 5 30000000000 30000000000
SweepMaximum 5 1 1
ChartStyle 2 0 0
GraticuleColor 2 0 0
MajorDivisionsColor 2 9 9
MinorDivisionsColor 2 9 9
XAxisLineStyle 2 0 0
LeftYAxisLineStyle 2 0 0
RightYAxisLineStyle 2 0 0
ShowTickMarks 0 True -1
TickMarkSize 5 3 3
UseDefaultXLabel 0 True -1
DefaultXLabel 6

We can use attributes collection for setting the sweep minimum and sweep maximum on Smith chart Graph:

Sub Main
Debug.Clear
Dim g As Graph

Set g = Project.Graphs(1)

g.Attributes("SweepMinimum").Value = 200000

End Sub

API Scripting Guide 1195


Working with Graphs

Printing Graph Options

To print graph options, use the following script:

' Code Module


Sub Main
Dim g As Graph
Dim ax As Axes

Set g = Project.Graphs(1)
write_props g

End Sub

Sub write_props(g As Graph)


Dim font As New StdFont
On Error Resume Next
Debug.Print "Properties";
Debug.Print "BorderColor=" & g.BorderColor;
Debug.Print "BorderWeight=" & g.BorderWeight;
Debug.Print "TickMarksVisible=" & g.TickMarksVisible;
Debug.Print "Title=" & g.Title;
Set font = g.TitleFont
Debug.Print "TitleFont=" & font.Bold & "," & font.Charset & "," & font.Italic
Debug.Print "Font Name: &font.Name & "," & font.Size & "," & font.Strikethrough & "," & font.Und
Debug.Print "TitleVisible=" & g.TitleVisible;
Debug.Print "Height=" & g.Height;
Debug.Print "Left=" & g.Left;
Debug.Print "Top=" & g.Top;
Debug.Print "Width=" & g.Width;
Debug.Print "sweep_digits=" & g.SweepPrecision.Digits;
Debug.Print "sweep_mode=" & g.SweepPrecision.Mode;
Debug.Print "sweep_style=" & g.SweepPrecision.Style;
Debug.Print "data_digits=" & g.DataPrecision.Digits;
Debug.Print "data_mode=" & g.DataPrecision.Mode;
Debug.Print "data_style=" & amp; g.DataPrecision.Style;
End Sub

Printing Four "x" and "y" Points for the Graph "Arc"

The following script prints out all "x" and "y" points for the "arc" on the Graph.

' Code Module


Sub Main
Dim ds As DrawingShape

Set ds = Project.Graphs(1).DrawingShapes(1)
For i = 1 To ds.Points.Count
Debug.Print "Point " & i
Debug.Print vbTab & "x= " & ds.Points(i).x
Debug.Print vbTab & "y= " & ds.Points(i).y
Next i
End Sub

1196 NI AWR Design Environment


Working with Graphs

Setting Graph Axes

You can set the left or right axis of a trace on a graph through the NI AWR SDE. Trace objects are children of a Graph
object. The MWOffice Graphs collection has two graph forms: the first has four individual measurements, and the second
has a single measurement but has an "All Sources" data source. You can set the axis of each trace individually on the
first form; however, when you try to set the axis of a single trace on the second form, it applies it to ALL of the traces.
If you have access to the individual traces, you should not be able to set the axis of each individually. The axis is applied
to each measurement object. This is not logical, but is because the left/right property is really for a measurement.

' Code Module


Sub Main
Dim g As Graph
Dim nm As String
Debug.Clear
Set g = Project.Graphs(1)
cnt = g.Traces.Count
For i = 1 To cnt
nm = g.Traces(i).Name
Debug.Print "Name = ";nm
If i > 1 Then
g.Traces(i).PlotAxis = mwPA_Right
Else
g.Traces(i).PlotAxis = mwPA_Left
End If
Next i
End Sub

Note that Rectangular graphs support multiple left and right y-axes that you can specify through the NI AWR SDE using
the PlotAxis property of the Trace object. This method sets the axis on which to plot the Trace as shown in the previous
script.

Modifying Graph Axes

To modify graph axes, use the following script:

' Axes properties


Sub Main
Dim gp As Graph
Dim ax As Axis
For Each gp In Project.Graphs
'Print the graph name for reference.
Debug.Print "Name = " & gp.Name
' Set some properties
For Each ax In gp.Axes
' Print the values for reference.
Debug.Print "Gridline Labels Visible = " & ax.GridlineLabelsVisible
Debug.Print "Label Units Visible = " & ax.LabelUnitsVisible
Debug.Print "Axis Major GridLine Color = " & ax.MajorGridlinesColor
Debug.Print "Axis Major Gridline Weight = " & ax.MajorGridlinesWeight
Debug.Print "Axis Minor Gridline Color = " & ax.MinorGridlinesColor
' Set the values
ax.GridlineLabelsVisible = False
ax.LabelUnitsVisible = False
ax.MajorGridlinesColor = RGB(0, 0, 0)

API Scripting Guide 1197


Working with Graphs

ax.MajorGridlinesWeight = mwFat
ax.MinorGridlinesColor = RGB(0, 0, 0)
' Now Print values to check.
Debug.Print "Gridline Labels Visible = " & ax.GridlineLabelsVisible
Debug.Print "Label Units Visible = " & ax.LabelUnitsVisible
Debug.Print "Axis Major GridLine Color = " & ax.MajorGridlinesColor
Debug.Print "Axis Major Gridline Weight = " & ax.MajorGridlinesWeight
Debug.Print "Axis Minor Gridline Color = " & ax.MinorGridlinesColor
Next ax
Next gp
End Sub

This script generates the following output:

Name = Graph 1
Gridline Labels Visible = True
Label Units Visible = True
Axis Major GridLine Color = 12632256
Axis Major Gridline Weight = 1
Axis Minor Gridline Color = 12632256
Gridline Labels Visible = False
Label Units Visible = False
Axis Major GridLine Color = 0
Axis Major Gridline Weight = 5
Axis Minor Gridline Color = 0
Gridline Labels Visible = True
Label Units Visible = False
Axis Major GridLine Color = 0
Axis Major Gridline Weight = 5
Axis Minor Gridline Color = 0
Gridline Labels Visible = False
Label Units Visible = False
Axis Major GridLine Color = 0
Axis Major Gridline Weight = 5
Axis Minor Gridline Color = 0
Gridline Labels Visible = True
Label Units Visible = False
Axis Major GridLine Color = 0
Axis Major Gridline Weight = 5
Axis Minor Gridline Color = 0
Gridline Labels Visible = False
Label Units Visible = False
Axis Major GridLine Color = 0
Axis Major Gridline Weight = 5
Axis Minor Gridline Color = 0

You can manipulate and set all of the properties listed above.

Dim grp As Graph


Debug.Clear
Set grp = Project.Graphs(1)
Debug.Print grp.Axes.Item(1).Name;" ";grp.Axes.Item(2).Name
If grp.Axes.Item(1).AutoScale=False Then
grp.Axes.Item(1).AutoScale=True
grp.Axes.Item(1).MajorGridlinesAutoStep=True

1198 NI AWR Design Environment


Working with Graphs

grp.Axes.Item(2).AutoScale=True
grp.Axes.Item(2).MajorGridlinesAutoStep=True
Else
grp.Axes.Item(1).AutoScale=False
grp.Axes.Item(1).MaximumScale=3
grp.Axes.Item(1).MinimumScale=1
grp.Axes.Item(1).MajorGridlinesAutoStep=False
grp.Axes.Item(1).MajorGridlinesStep=1.25
grp.Axes.Item(2).AutoScale=False
grp.Axes.Item(2).MaximumScale=2.25
grp.Axes.Item(2).MinimumScale=0
grp.Axes.Item(2).MajorGridlinesAutoStep=False
grp.Axes.Item(2).MajorGridlinesStep=1.75
grp.Traces.Item(1).Weight=mwMedium
End If
Debug.Print grp.Axes.Item(2).MajorGridlinesStep;" ";grp.Axes.Item(1).MajorGridlinesStep

You can access all axes properties that are in the following script:

' Code Module


Sub Main
Dim g As Graph
Dim ax As Axes

Set g = Project.Graphs(1)
For Each ax In g.Axes
write_axes ax
Next ax
End Sub

Sub write_axes(ax As Axis)


Dim font As New StdFont

On Error GoTo problem:


Debug.Print "Axes";
Debug.Print "Name=" & ax.Name;
Debug.Print "AutoScale=" & ax.AutoScale;
Debug.Print "GridlineLabelsColor=" & ax.GridlineLabelsColor;
Set font = ax.GridlineLabelsFont
Debug.Print "GridlineLabelsFont=" & font.Bold & "," & font.Charset
Debug.Print font.Italic & "," & font.Name & "," & font.Size
Debug.Print font.Strikethrough & "," & font.Underline & "," & font.Weight;
Debug.Print "GridlineLabelsVisible=" & ax.GridlineLabelsVisible;
Debug.Print "LabelColor=" & ax.LabelColor;
Set font = ax.LabelFont
Debug.Print "LabelFont=" & font.Bold & "," & font.Charset & "," & font.Italic
Debug.Print font.Name & "," & font.Size & "," & font.Strikethrough
Debug.Print font.Underline & "," & font.Weight;
Debug.Print "LabelText=" & ax.LabelText;
Debug.Print "LabelUnitsVisible=" & ax.LabelUnitsVisible;
Debug.Print "LabelVisible=" & ax.LabelVisible;
Debug.Print "MajorGridlinesAutoStep=" & ax.MajorGridlinesAutoStep;
Debug.Print "MajorGridlinesColor=" & ax.MajorGridlinesColor;
Debug.Print "MajorGridlinesDashStyle=" & ax.MajorGridlinesDashStyle;
Debug.Print "MajorGridlinesStep=" & ax.MajorGridlinesStep;

API Scripting Guide 1199


Working with Graphs

Debug.Print "MajorGridlinesVisible=" & ax.MajorGridlinesVisible;


Debug.Print "MajorGridlinesWeight=" & ax.MajorGridlinesWeight;
Debug.Print "MaximumScale=" & ax.MaximumScale;
Debug.Print "MinimumScale=" & ax.MinimumScale;
Debug.Print "MinorGridlinesAutoStep=" & ax.MinorGridlinesAutoStep;
Debug.Print "MinorGridlinesColor=" & ax.MinorGridlinesColor;
Debug.Print "MinorGridlinesDashStyle=" & ax.MinorGridlinesDashStyle;
Debug.Print "MinorGridlinesStep=" & ax.MinorGridlinesStep;
Debug.Print "MinorGridlinesVisible=" & ax.MinorGridlinesVisible;
Debug.Print "MinorGridlinesWeight=" & ax.MinorGridlinesWeight;
Debug.Print "ScaleType=" & ax.ScaleType;

problem:
Resume Next
End Sub

End Sub

You can also add and remove graph axes. In addition you have API access to non-rectangular graphs and can set values
for all types of graphs, for example, Axes(1).Minimumscale and Axes(1).Maximumscale as in the following script:

' Code Module


Sub Main
Dim grp As Graph
Debug.Clear
For Each grp In Project.Graphs
If grp.Type = mwGT_SmithChart Then
' If grp.Type = mwGT_Rectangular Then
Debug.Print grp.Axes(1).MinimumScale; vbTab; vbTab; grp.Axes(1).MaximumScale
grp.Axes(1).AutoScale = False
grp.Axes(1).MinimumScale = 30
grp.Axes(1).MaximumScale = 40
Debug.Print grp.Axes(1).MinimumScale; vbTab; vbTab; grp.Axes(1).MaximumScale
End If
Next grp
End Sub

To set the initial range you need to run at least one simulation before running the script. This script generates the following
output:

20 50
30 40

Accessing YSample Measurement X-axis Values

You have access to AxisPointLabels for the measurements, which allows access to string values used for axis label points.
The following is an example of accessing the AxisLabelPoints:

' Code Module


Sub Main
Dim g As Graph
Dim count As Integer

1200 NI AWR Design Environment


Working with Graphs

Set g = Project.Graphs("yield_vals")
Debug.Clear
count = g.Measurements(1).AxisPointLabelCount
For i = 1 To count
Debug.Print g.Measurements(1).AxisPointLabel(i)
Next i
End Sub

Running this on the test project after 100 iterations of yield analysis produces the following in the debug window:

@BPF_Half\@BPF_Half\S1
@BPF_Half\@BPF_Half\S2
@BPF_Half\@BPF_Half\S4
@BPF_Half\@BPF_Half\W0
@BPF_Half\@BPF_Half\W1
@BPF_Half\@BPF_Half\W2
BPF_Half\TMM 10_1\Er
BPF_Half\TMM 10_1\H

Accessing simulator string from the measurements collection

The following script gets simulator string from the measurements collection:

Sub Main
Dim m As Measurement
Dim mi As MeasurementInfo

Set m = Project.Graphs(1).Measurements(1)
Debug.Print m.Source

Set mi = MWOffice.MeasurementInfos("S")
Debug.Print mi.SimId
End Sub

The source name will be the simdoc name plus any simulator tags, disabled sweeps, etc. The SimId off the measurement
info is the simulator type. LIN for linear, NLN nonlinear, SYS for VSS, etc.

Modifying Graph Borders

To modify graph borders, use the following script:

' Graph Border Color


Sub Main
Dim gp As Graph
Dim bv As Boolean
' Clear the output window
Debug.Clear
For Each gp In Project.Graphs
' Print the current values for reference.
Debug.Print "Name = " & gp.Name
Debug.Print "Color = " & gp.BorderColor
' Update the value and print
gp.BorderColor = RGB(128, 128, 128)
Debug.Print "Color = " & gp.BorderColor

API Scripting Guide 1201


Working with Graphs

'Update one more time and print.


gp.BorderColor = RGB(0, 0, 0)
Debug.Print "Color = " & gp.BorderColor
Next gp
End Sub

This script generates the following output:

Name = Graph 1
Color = 0
Color = 8421504
Color = 0

The following example toggles the Border Visible property:

' Graph Border Visible


Sub Main
Dim gp As Graph
Dim bv As Boolean
For Each gp In Project.Graphs
Debug.Print gp.Name
Debug.Print gp.BorderVisible
' Toggle the border visible property
If gp.BorderVisible Then
gp.BorderVisible = False
Else
gp.BorderVisible = True
End If
' Print the result of the changed border visible property
Debug.Print gp.BorderVisible
Next gp
End Sub

Working with the Traces Collection

The following script is using measurement.tracevalue property for iterating through traces

' Code Module


Sub Main
Debug.Clear

Dim info As String


Dim m As Measurement
Set m = Project.Graphs(1).Measurements(1)
Dim sls As SweepLabels
Dim sl As SweepLabel

Debug.Print "X and Y Values"


For trace_index = 1 To m.TraceCount
Set sls = m.SweepLabels(trace_index)
Debug.Print "Trace " & trace_index
info = ""
For i = 1 To sls.Count
info = info & sls(i).Name & "=" & sls(i).Value & ","

1202 NI AWR Design Environment


Working with Graphs

Next
For i = 1 To m.XPointCount
Debug.Print vbTab & info & "x=" & m.XValue(i) & ",y=" & m.YValue(i,trace_index)
Next
Next trace_index
Debug.Print

Debug.Print "Trace Values"


For trace_index = 1 To m.TraceCount
Set sls = m.SweepLabels(trace_index)
Debug.Print "Trace " & trace_index
info = ""
For i = 1 To sls.Count
info = info & sls(i).Name & "=" & sls(i).Value & ","
Next
For i = 1 To UBound(m.TraceValues(trace_index),1)
Debug.Print vbTab + info & "x=" & m.TraceValues(trace_index)(i,1) & ",y=" & m.TraceValues(trace_
Next
For i = 1 To UBound(m.TraceValues(trace_index),2)
Debug.Print vbTab & info & "y=" & m.TraceValues(trace_index)(i,2)
Next
Next trace_index

End Sub

This script generates the following output:

X and Y Values
Trace 1
R1=25,R2=10,x=1000000000,y=35
R1=25,R2=10,x=2000000000,y=35
Trace 2
R1=30,R2=10,x=1000000000,y=40
R1=30,R2=10,x=2000000000,y=40
Trace 3
R1=25,R2=20,x=1000000000,y=45
R1=25,R2=20,x=2000000000,y=45
Trace 4
R1=30,R2=20,x=1000000000,y=50
R1=30,R2=20,x=2000000000,y=50

Trace Values
Trace 1
R1=25,R2=10,x=1000000000,y=35
R1=25,R2=10,x=2000000000,y=35
R1=25,R2=10,y=35
R1=25,R2=10,y=35
Trace 2
R1=30,R2=10,x=1000000000,y=40
R1=30,R2=10,x=2000000000,y=40
R1=30,R2=10,y=40
R1=30,R2=10,y=40
Trace 3
R1=25,R2=20,x=1000000000,y=45
R1=25,R2=20,x=2000000000,y=45
R1=25,R2=20,y=45

API Scripting Guide 1203


Working with Graphs

R1=25,R2=20,y=45
Trace 4
R1=30,R2=20,x=1000000000,y=50
R1=30,R2=20,x=2000000000,y=50
R1=30,R2=20,y=50
R1=30,R2=20,y=50

To modify the trace Color and DashStyle, use the following script:

' Traces properties


Sub Main
Dim gp As Graph
Dim tr As Trace
Debug.Clear
For Each gp In Project.Graphs
Debug.Print "Graph Name = " & gp.Name
For Each tr In gp.Traces
' Print initial values.
Debug.Print "Color = " & tr.Color
Debug.Print "Dash Style = " & tr.DashStyle
' Update the values.
tr.Color = RGB(255, 0, 0)
tr.DashStyle = mwLineSolid
' Print updated values.
Debug.Print "Color = " & tr.Color
Debug.Print "Dash Style = " & tr.DashStyle
Next tr
Next gp
End Sub

The following script prints measurements and trace information:

' Code Module


Sub Main
Dim g As Graph

Set g = Project.Graphs(1)
'print measurement and trace info
i = 1
For Each m In g.Measurements
Set t = g.Traces(i)
Debug.Print "Measurement" & vbTab & m.Source & vbTab & m.Type
Debug.Print t.MeasurementName & vbTab & t.DefaultStyle & vbTab & t.CompatibleStyle
Debug.Print t.Color & vbTab & t.DashStyle & vbTab & t.FrequencyArrows
Debug.Print t.LegendText & vbTab & t.LegendText2 & vbTab & t.PlotAxis
Debug.Print t.Style & vbTab & t.Symbol & vbTab & t.SymbolInterval
Debug.Print t.SymbolSize & vbTab & t.SymbolVisible & vbTab & t.TextVisible
Debug.Print t.Visible & vbTab & t.Weight & vbTab & t.SymbolIntervalAuto & vbTab & m.AxisIndex
i = i+1
Next m
End Sub

The following code sets trace thickness:

1204 NI AWR Design Environment


Working with Graphs

Sub trace_thickness(g As Graph, a As Integer)


Dim tr As Trace
If a = 0 Then
c=1
ElseIf a = 1 Then
c=0
Else
c = -1
End If
For Each tr In g.Traces
nw =tr.Weight+c
If nw < 1 Then
nw = 1
ElseIf nw > 5 Then
nw = 5
End If
tr.Weight=nw
Next tr
End Sub

To export trace data from a Graph object, use the Graph.ExportTraceData() method which takes an export file name and
then attempts to export the data to that file name.

Project.Graphs("GRPH1").ExportTraceData(fwrite)

Modifying the Graph Legend

The following script shows how to access the Graph Legend object:

' Code Module


Sub Main
Dim gp As Graph
Dim lg As Legend
Debug.Clear
For Each gp In Project.Graphs
Debug.Print "Graph Name = " & gp.Name
Set lg = gp.Legend
' Print initial values.
Debug.Print "Color = " & lg.Color
Debug.Print "BorderVisible = " & lg.BorderVisible
Debug.Print "Font = " & lg.Font
Debug.Print "Height = " & lg.Height;vbTab;"Width = " & lg.Width
Next gp
End Sub

This script generates the following output:

Graph Name = Graph 1


Color = 0
BorderVisible = True

API Scripting Guide 1205


Working with Graphs

Font = Arial
Height = 800 Width = 1141

The following script shows how to access Graph Legend object properties:

' Code Module


Sub Main
Dim g As Graph

Set g = Project.Graphs(1)
Set font = g.Legend.Font
Debug.Print "Legend" & vbTab & g.Legend.BorderShadow & vbTab & g.Legend.BorderVisible
Debug.Print g.Legend.Color & vbTab & font.Bold & "," & font.Charset
Debug.Print font.Italic & "," & font.Name & "," & font.Size & "," & font.Strikethrough
Debug.Print font.Underline & "," & font.Weight & vbTab & g.Legend.Height & vbTab & g.Legend.Left
Debug.Print g.Legend.Text2Visible & vbTab & g.Legend.TextVisible & vbTab & g.Legend.Top
ebug.Print g.Legend.Visible & vbTab & g.Legend.Width

End Sub

The following script resizes a Graph Legend:

' Code Module


Sub Main
For Each Graph In Project.Graphs
Graph.Legend.Text2Visible = False
Graph.Legend.Text2Visible = True
Graph.Legend.TextVisible = False
Graph.Legend.TextVisible = True
Graph.Legend.Left = 0
Graph.Legend.Width = Graph.Width '3000
Graph.Legend.Top = 3000
Graph.Legend.Height = 700
Project.Graphs.Item(1).Legend.Text2Visible = False
Project.Graphs.Item(1).Legend.Text2Visible = True
Next Graph
End Sub

The following code shows how to access legend text for graphs

API has properties that specify if we use Default values or not for setting Graph Legend Text. Boolean properties names
are: UseDefaultLegendText and UseDefaultLegendText2. The code allows you to access legend text properties and
values:

Debug.Print Project.Graphs(1).Traces(1).LegendText
Debug.Print Project.Graphs(1).Traces(1).LegendText2

Debug.Print Project.Graphs(1).Traces(1).UseDefaultLegendText
Debug.Print Project.Graphs(1).Traces(1).UseDefaultLegendText2

1206 NI AWR Design Environment


Working with Graphs

Working with Markers

The following script shows how to add Marker object to a graph trace:

' Code Module


Sub Main
Dim gph As Graph

Set gph = Project.Graphs("Graph 1")


gph.Markers.Add("SCH1:DB(|S(2,1)|)", 1, 2e9)
PrintMarkerProperties(gph)

End Sub

Sub PrintMarkerProperties(ByRef gph As Graph)


Dim mk As Marker

' Print marker details.


Debug.Print gph.Name & " Marker Properties: "
Debug.Print "Marker Count = " & gph.Markers.Count
For Each mk In gph.Markers
PrintMarkerDetails mk

' Check by name lookup access.


If gph.Markers.Exists(mk.Name) Then
Debug.Print mk.Name & " exists by name succeeded."
Else
Debug.Print mk.Name & " exists by name failed."
End If

Dim mk2 As Marker


Set mk2 = gph.Markers(mk.Name)
If mk2 Is Nothing Then
Debug.Print mk.Name & " Get item by Name failed."
Else
Debug.Print mk.Name & " get item by name succeeded."
End If

Debug.Print "---"
Debug.Print ""

Next mk

Debug.Print " ---------------------- "


Debug.Print ""
End Sub

Sub PrintMarkerDetails(ByRef mk As Marker)


Debug.Print "Name = " & mk.Name
Debug.Print "Measurement = " & mk.Measurement
Debug.Print "Ref Marker = " & mk.ReferenceMarker
Debug.Print "Sweep Value = " & mk.SweepValue
Debug.Print "Display Height = " & mk.Display.Height
Debug.Print "Display Left = " & mk.Display.Left
Debug.Print "Display Top = " & mk.Display.Top
Debug.Print "Display Width = " & mk.Display.Width

API Scripting Guide 1207


Working with Graphs

End Sub

The following script shows how to add Marker Trace:

' Code Module


Sub Main
Dim g As Graph
' Add markers to the first and second trace
Set gph = Project.Graphs("Graph 1")
gph.Markers.AddEx("SCH1:DB(|S(2,1)|)", 1, 2e9, 1)
gph.Markers.AddEx("SCH1:DB(|S(2,1)|)", 1, 2e9, 2)

PrintMarkerProperties(gph)

End Sub

In the script the PrintMarkerProperties(gph) code is already shown above

The following script shows how to access Marker object properties and options:

' Code Module


Sub Main
Dim g As Graph
Dim mkr As Marker
Dim lmkr As LineMarker
Dim ds as DrawingShape

For Each mkr In g.Markers


Debug.Print "Marker" & vbTab & mkr.Measurement & vbTab & mkr.Name
Debug.Print mkr.ReferenceMarker & vbTab & mkr.SweepValue
Next mkr

'add line markers here


For Each lmkr In g.LineMarkers
Debug.Print "Line_Marker" & vbTab & lmkr.Axis & vbTab & lmkr.Name
Debug.Print lmkr.Number & vbTab & lmkr.Track & vbTab & lmkr.Type & vbTab & lmkr.UnitType
Debug.Print lmkr.Value & vbTab & lmkr.Visible
Next lmkr

'print marker options

' Print marker options details.


Debug.Print g.Name & " Marker Options: "
Debug.Print "Normalized = " & g.Markers.Options.Normalized
Debug.Print "Color = " & g.Markers.Options.Color
Debug.Print "ConnectorVisible = " & g.Markers.Options.ConnectorVisible
Debug.Print "ConnectorWeight = " & g.Markers.Options.ConnectorWeight
Debug.Print "DataMarkersInLegend = " & g.Markers.Options.DataMarkersInLegend
Debug.Print "DisplayFormat = " amp; &.Markers.Options.DisplayFormat
Debug.Print "DisplayType = " & g.Markers.Options.DisplayType
Debug.Print "EnableParameterMarkers = " & g.Markers.Options.EnableParameterMarkers
Debug.Print "FrequencyVisible = " & g.Markers.Options.FrequencyVisible

1208 NI AWR Design Environment


Working with Graphs

Debug.Print "Options.MarkerSymbol = " & g.Markers.Options.MarkerSymbol


Debug.Print "ParameterMarkersInLegend = " & g.Markers.Options.ParameterMarkersInLegend
Debug.Print "RefImpedance = " & g.Markers.Options.RefImpedance
Debug.Print "RefMarkerAllTraces = " & g.Markers.Options.RefMarkerAllTraces
Debug.Print "SymbolSize = " & g.Markers.Options.SymbolSize
Debug.Print "SymbolVisible = " & g.Markers.Options.SymbolVisible
Debug.Print "TiedToLabel = " & g.Markers.Options.TiedToLabel
Debug.Print "Transparent = " & g.Markers.Options.Transparent
Debug.Print " ---------------------- "
Debug.Print ""

'print drawing shape objects.


For Each ds In g.DrawingShapes
Debug.Print "Drawing_Shape" & vbTab & ds.Type & vbTab & ds.BasePosition.x
Debug.Print ds.BasePosition.y & vbTab & ds.Flipped & vbTab & ds.RotationAngle;
If ds.Type=mwDST_Text Then
Debug.Print ds.Attributes(1).ValueAsString & vbTab & ds.Attributes(2).ValueAsString
Debug.Print ds.Attributes(3).ValueAsString & vbTab & ds.Attributes(4).ValueAsString
Debug.Print ds.Attributes(5).ValueAsString
Else
Debug.Print vbTab & ds.Points.Count;
For p = 1 To ds.Points.Count
Debug.Print ds.Points(p).x & vbTab & ds.Points(p).y;
Next p
Print #1
End If
Next ds

End Sub

The following script will display the value of every trace at each marker's x value:

' Place regulars Markers (Not vert Or horiz), and run this script.
' It will display the value of every trace at each marker's x value.
' Size of display text is controlled by "size" variable, below.
' WARNING: this script will remove all drawing objects (user added text/graphics).

' Code Module


Sub Main
Dim gr As Graph
Dim wn As Window
Dim ds As DrawingShape
Dim mk As Marker
Dim ms As Measurement
Dim ny As Long
Dim xi As Long
Dim yi As Long
Dim md() As Double
Dim tr As Trace
Dim xv As Double
Dim size_scale As Integer

Debug.Clear

Size = 75

API Scripting Guide 1209


Working with Graphs

' Make sure the active window is a graph and has at least one trace marker.
For Each wn In Windows
If wn.Active Then
If wn.Type = mwWT_Graph Then Set gr = Project.Graphs(wn.Caption)
Exit For
End If
Next wn
If wn.Type ne mwWT_Graph Then
MsgBox("Active window must be a graph.")
Exit Sub
ElseIf gr.Markers.Count = 0 Then
MsgBox("Graph must contain at least one trace marker.")
Exit Sub
End If

' Clean up old text


For Each ds In gr.DrawingShapes
ds.Delete
Next ds

' For each marker, for each measurement, for each curve,
' interpolate y value at xv, and place that value as text at that location.
For Each mk In gr.Markers
xv = mk.SweepValue
For Each ms In gr.Measurements
ny = ms.YDataDim
ReDim md(ny) As Double
For yi = 1 To ny
md(yi) = LInterp(ms.XValues,ms.YValues(yi),xv)
' Debug.Print xv;vbTab;md(yi)
gr.DrawingShapes.AddText(gr.GridToLogicalCoordinateX(xv/Project.Units(mwUT_Frequency).MultValue
' Debug.Print gr.GridToLogicalCoordinateX(xv/Project.Units(mwUT_Frequency).MultValue);vbTab;gr.G
Next yi
Next ms
Next mk

End Sub
' Use provided xvals and yvals value arrays to interpolate new y for x
' Warning: not very bright, expects x to be within range of xvals and yvals.
' Probably won't work for traces where xvals is non-monotonic
Function LInterp(xvals() As Double, yvals() As Double, x As Double) As Double
Dim y As Double
Dim xi As Double
Dim xi0 As Double
Dim xmin As Double
Dim xmax As Double

xmin = xvals(0)
xmax = xvals(0)
For i = 1 To UBound(xvals)
xi = xvals(i)
xi0 = xvals(i-1)
If x = xi Then
y = yvals(i)
' Debug.Print xi0; vbTab; yvals(i-1)
' Debug.Print xi; vbTab; yvals(i);vbTab;y

1210 NI AWR Design Environment


Working with Graphs

ElseIf (x > xi0) And (x lt xi) Then


y = yvals(i) - ( (xvals(i)-x) * ( (yvals(i)-yvals(i-1)) / (xvals(i)-xvals(i-1)) ) )
' Debug.Print xi0; vbTab; yvals(i-1)
' Debug.Print xi; vbTab; yvals(i);vbTab;y
End If
If xvals(i) lt xmin Then xmin = xvals(i)
If xvals(i) > xmax Then xmax = xvals(i)
Next i
If (x lt xmin) Or (x > xmax) Then
MsgBox("X value for interpolation is outside of data range. Y set to zero.",vbOkOnly,"Trouble")
y = 0
' Debug.Print "Trouble!"
End If
LInterp = y

End Function

Please, keep in mind that the script above should not be used for all graphs and measurements

The following code shows how to change the size of Graph's markers using a script:

' Code Module


Sub Main
Dim gph As Graph
Dim mk As Marker

Debug.Clear

Set gr = Project.Graphs("Graph 1")

' Print marker details.


Debug.Print gr.Name & " Marker Properties: "
Debug.Print gr.Name & " Marker Properties: "

For Each mk In gr.Markers


Debug.Print "Name = " & mk.Name
Debug.Print "Measurement = " & mk.Measurement
Debug.Print "Ref Marker = " & mk.ReferenceMarker
Debug.Print "Sweep Value = " & mk.SweepValue
Debug.Print "Display Height = " & mk.Display.Height

mk.Display.Height = 500

Debug.Print "Display Height after changing = " & mk.Display.Height


Debug.Print "Display Left = " & mk.Display.Left

mk.Display.Left = mk.Display.Left + 10

Debug.Print "Display Left after changing = " & mk.Display.Left


Debug.Print "Display Top = " & mk.Display.Top

mk.Display.Top = mk.Display.Top + 10

Debug.Print "Display Top after changing = " & mk.Display.Top


Debug.Print "Display Width = " & mk.Display.Width

API Scripting Guide 1211


Working with Graphs

mk.Display.Width = mk.Display.Width + 10
Debug.Print "Display Width = " & mk.Display.Width
Next mk
End Sub

The following code shows how to move marker label using a script. This example is moving the Marker Label up and
to the right:

' Code Module


Sub Main
Dim mk As Marker

Set mk = Project.Graphs("Graph 1").Markers(1)


Debug.Print mk.Name

' Move the marker label up and to the right.


mk.Display.Left = mk.Display.Left + 100
mk.Display.Top = mk.Display.Top - 100

End Sub

The following script shows API support for moving marker to min and max values along a trace. Test places two markers
then moves them to max and minimum values along two traces. At each placement the details of the marker object state
are printed out :

Option Explicit
' Code Module
Sub Main
Dim gph As Graph
Dim m1 As Marker
Dim m2 As Marker

' Add markers to the first and second trace


Set gph = Project.Graphs("Graph 1")
Set m1 = gph.Markers.AddEx("SCH1:DB(|S(2,1)|)", 1, 1.5e9, 1)
Set m2 = gph.Markers.AddEx("SCH1:DB(|S(2,1)|)", 1, 1.5e9, 2)

PrintMarkerProperties gph, "Initial placement feq = 1.5 GHz"

m1.SweepValue = 2e9
m2.SweepValue = 2e9

PrintMarkerProperties gph, "First placement feq = 2.0 GHz"

m1.SweepValue = 2.5e9
m2.SweepValue = 2.5e9

PrintMarkerProperties gph, "Second placement feq = 2.0 GHz"


End Sub

Sub PrintMarkerProperties(ByRef gph As Graph, title As String)


Dim mk As Marker

1212 NI AWR Design Environment


Working with Graphs

Debug.Print title

' Print marker details.


Debug.Print gph.Name & " Marker Properties: "
Debug.Print "Marker Count = " & gph.Markers.Count
For Each mk In gph.Markers
PrintMarkerDetails mk

' Check by name lookup access.


If gph.Markers.Exists(mk.Name) Then
Debug.Print mk.Name & " exists by name succeeded."
Else
Debug.Print mk.Name & " exists by name failed."
End If

Dim mk2 As Marker


Set mk2 = gph.Markers(mk.Name)
If mk2 Is Nothing Then
Debug.Print mk.Name & " Get item by Name failed."
Else
Debug.Print mk.Name & " get item by name succeeded."
End If

Debug.Print "---"

Next mk
Debug.Print ""
End Sub

Sub PrintMarkerDetails(ByRef mk As Marker)


Debug.Print "Name = " & mk.Name
Debug.Print "Measurement = " & mk.Measurement
Debug.Print "Ref Marker = " & mk.ReferenceMarker
Debug.Print "Sweep Value = " & mk.SweepValue
Debug.Print "Trace Index = " & mk.TraceIndex
Debug.Print "Max Trace = " & mk.TraceIndexMax
End Sub

The following script shows API support for moving marker to min and max values along a trace. Test places two markers
then moves them to max and minimum values along two traces. At each placement the details of the marker object state
are printed out as in previous script:

Option Explicit
' Code Module
Sub Main
Dim gph As Graph
Dim m1 As Marker
Dim m2 As Marker

' Add markers to the first and second trace


Set gph = Project.Graphs("Graph 1")
Set m1 = gph.Markers.AddEx("SCH1:DB(|S(2,1)|)", 1, 1.5e9, 1)
Set m2 = gph.Markers.AddEx("SCH1:DB(|S(2,1)|)", 1, 1.5e9, 2)

API Scripting Guide 1213


Working with Graphs

PrintMarkerProperties gph, "Initial placement feq = 1.5 GHz"

m1.MoveToMaximum
m2.MoveToMaximum

PrintMarkerProperties gph, "Max placement"

m1.MoveToMinimum
m2.MoveToMinimum

PrintMarkerProperties gph, "Min placement"


End Sub

We have support to the API grid marker object. Those changes include the ability to set the Sweep Value for a marker
and allow the marker to be moved within a grid.

The following code shows how to move marker to a certain position:

' Code Module


Sub Main
Dim gph As Graph
Dim m1 As Marker
Dim m2 As Marker

' Add markers to the first and second trace


Set gph = Project.Graphs("Graph 1")
Set m1 = gph.Markers.AddEx("SCH1:DB(|S(2,1)|)", 1, 1.5e9, 1)
Set m2 = gph.Markers.AddEx("SCH1:DB(|S(2,1)|)", 1, 1.5e9, 2)

PrintMarkerProperties gph, "Initial placement feq = 1.5 GHz"

m1.SweepValue = 2e9
m2.SweepValue = 2e9

PrintMarkerProperties gph, "First placement feq = 2.0 GHz"

m1.SweepValue = 2.5e9
m2.SweepValue = 2.5e9

PrintMarkerProperties gph, "Second placement feq = 2.0 GHz"

End Sub

In the script the PrintMarkerProperties(gph) code is already shown above. Markers.AddEx() method takes a trace index
in addition to all the parameters that Add() took previously. In the code we place two markers and then move them twice
by assigning into the sweep value properties. Each time the markers is placed the state of the marker object is printed
out.

The following code shows how to move marker to Minimum / Maximum:

Dim gph As Graph


Dim m1 As Marker
Dim m2 As Marker

1214 NI AWR Design Environment


Working with Graphs

' Add markers to the first and second trace


Set gph = Project.Graphs("Graph 1")
Set m1 = gph.Markers.AddEx("SCH1:DB(|S(2,1)|)", 1, 1.5e9, 1)
Set m2 = gph.Markers.AddEx("SCH1:DB(|S(2,1)|)", 1, 1.5e9, 2)

PrintMarkerProperties gph, "Initial placement feq = 1.5 GHz"

m1.MoveToMaximum
m2.MoveToMaximum

PrintMarkerProperties gph, "Max placement"

m1.MoveToMinimum
m2.MoveToMinimum

PrintMarkerProperties gph, "Min placement"

End Sub

Sub PrintMarkerProperties(ByRef gph As Graph, title As String)


Dim mk As Marker

Debug.Print title

' Print marker details.


Debug.Print gph.Name & " Marker Properties: "
Debug.Print "Marker Count = " & gph.Markers.Count
For Each mk In gph.Markers
PrintMarkerDetails mk

' Check by name lookup access.


If gph.Markers.Exists(mk.Name) Then
Debug.Print mk.Name & " exists by name succeeded."
Else
Debug.Print mk.Name & " exists by name failed."
End If

Dim mk2 As Marker


Set mk2 = gph.Markers(mk.Name)
If mk2 Is Nothing Then
Debug.Print mk.Name & " Get item by Name failed."
Else
Debug.Print mk.Name & " get item by name succeeded."
End If

Debug.Print "---"
Debug.Print ""

Next mk

Debug.Print " ---------------------- "


Debug.Print ""
End Sub

Sub PrintMarkerDetails(ByRef mk As Marker)


Debug.Print "Name = " & mk.Name

API Scripting Guide 1215


Working with Graphs

Debug.Print "Measurement = " & mk.Measurement


Debug.Print "Ref Marker = " & mk.ReferenceMarker
Debug.Print "Sweep Value = " & mk.SweepValue
Debug.Print "Trace Index = " & mk.TraceIndex
Debug.Print "Max Trace = " & mk.TraceIndexMax
End Sub

We improved trace access in the graph marker objects so that the marker trace index can be specified via the trace index
property and the max trace index property returns the number of traces available in the measurement data. The
Marker.TraceIndex property reports and set the trace index and provides an indication of the range of values that can be
assigned to the marker. The following code shows how to switch graph Marker trace:

' Code Module


Sub Main
Dim gph As Graph
Dim m1 As Marker

' Add markers to the first and second trace


Set gph = Project.Graphs("Graph 1")
Set m1 = gph.Markers.AddEx("SCH1:DB(|S(2,1)|)", 1, 2e9, 1)

PrintMarkerProperties gph, "Initial placement on trace 1"

m1.TraceIndex = 2

PrintMarkerProperties gph, "Second placement on trace 2"

End Sub

For the PrintMarkerProperties gph code please look at the previous code.

The following code shows how to search marker:

' Code Module


Sub Main
Dim gph As Graph
Dim m1 As Marker

Set gph = Project.Graphs("Graph 1")


Set m1 = gph.Markers.Add("SCH1:DB(|S(2,1)|)", 1, 1e9)
PrintMarkerProperties gph, "Initial Placement freq = 1.0 GHz"

m1.Search(-0.0035)

PrintMarkerProperties gph, "Searh for value v = -0.0035"

m1.Search(-0.004)

PrintMarkerProperties gph, "Searh for value v = -0.004"

End Sub

1216 NI AWR Design Environment


Working with Graphs

For the PrintMarkerProperties gph code please look at the previous code.

The following code shows how to access Smith Chart Markers Options. Please keep in mind that it should be AfterSimulate
Event:

Private Sub Project_AfterSimulate()


Dim gph As Graph

For Each gph In Project.Graphs

PrintMarkerOptions(gph)

Next gph
End Sub
Sub PrintMarkerOptions(ByRef gph As Graph)
Dim mk As Marker
Dim op As Option
' Print marker options details.
Debug.Print gph.Name & " Marker Options: "
Debug.Print "Normalized = " & gph.Markers.Options.Normalized
Debug.Print "Color = " & gph.Markers.Options.Color
Debug.Print "ConnectorVisible = " & gph.Markers.Options.ConnectorVisible
Debug.Print "ConnectorWeight = " & gph.Markers.Options.ConnectorWeight
Debug.Print "DataMarkersInLegend = " & gph.Markers.Options.DataMarkersInLegend
Debug.Print "DisplayFormat = " & gph.Markers.Options.DisplayFormat
Debug.Print "DisplayType = " & gph.Markers.Options.DisplayType
Debug.Print "EnableParameterMarkers = " & gph.Markers.Options.EnableParameterMarkers
Debug.Print "FrequencyVisible = " & gph.Markers.Options.FrequencyVisible
Debug.Print "Options.MarkerSymbol = " & gph.Markers.Options.MarkerSymbol
Debug.Print "ParameterMarkersInLegend = " & gph.Markers.Options.ParameterMarkersInLegend
Debug.Print "RefImpedance = " & gph.Markers.Options.RefImpedance
Debug.Print "RefMarkerAllTraces = " & gph.Markers.Options.RefMarkerAllTraces
Debug.Print "SymbolSize = " & gph.Markers.Options.SymbolSize
Debug.Print "SymbolVisible = " & gph.Markers.Options.SymbolVisible
Debug.Print "TiedToLabel = " & gph.Markers.Options.TiedToLabel
Debug.Print "Transparent = " & gph.Markers.Options.Transparent

Debug.Print " ---------------------- "


Debug.Print ""
End Sub

The output can look as the following:

Marker Options:
Normalized = True
Color = 0
ConnectorVisible = True
ConnectorWeight = 0
DataMarkersInLegend = False
DisplayFormat = 0
DisplayType = 3
EnableParameterMarkers = True
FrequencyVisible = True
Options.MarkerSymbol = 9

API Scripting Guide 1217


Working with Graphs

ParameterMarkersInLegend = True
RefImpedance = 50
RefMarkerAllTraces = False
SymbolSize = 5
SymbolVisible = True
TiedToLabel = True
Transparent = False
----------------------

Norm50_Refl_dBmagAng Marker Options:


Normalized = True
Color = 0
ConnectorVisible = True
ConnectorWeight = 0
DataMarkersInLegend = False
DisplayFormat = 2
DisplayType = 0
EnableParameterMarkers = True
FrequencyVisible = True
Options.MarkerSymbol = 9
ParameterMarkersInLegend = True
RefImpedance = 50
RefMarkerAllTraces = False
SymbolSize = 5
SymbolVisible = True
TiedToLabel = True
Transparent = False
----------------------

DeNorm100_imped_ReIm Marker Options:


Normalized = False
Color = 0
ConnectorVisible = True
ConnectorWeight = 0
DataMarkersInLegend = False
DisplayFormat = 0
DisplayType = 1
EnableParameterMarkers = True
FrequencyVisible = True
Options.MarkerSymbol = 9
ParameterMarkersInLegend = True
RefImpedance = 100
RefMarkerAllTraces = False
SymbolSize = 5
SymbolVisible = True
TiedToLabel = True
Transparent = False
----------------------

DeNorm20_admit_MagAng Marker Options:


Normalized = False
Color = 0
ConnectorVisible = True
ConnectorWeight = 0
DataMarkersInLegend = False
DisplayFormat = 1
DisplayType = 2

1218 NI AWR Design Environment


Working with Graphs

EnableParameterMarkers = True
FrequencyVisible = True
Options.MarkerSymbol = 9
ParameterMarkersInLegend = True
RefImpedance = 20
RefMarkerAllTraces = False
SymbolSize = 5
SymbolVisible = True
TiedToLabel = True
Transparent = False
----------------------

The following code shows how to access marker font information:

' Code Module


Sub Main
Dim g As Graph
Dim font As New StdFont
Dim clr As Integer

Debug.Clear
'get graph
Set g = Project.Graphs(1)

'get font information from graph axes 1 (x-axis) label font.


Set font = g.Axes(1).LabelFont
'print out font information, note Color is separate.
Debug.Print "Bold=" & font.Bold
Debug.Print "Character Set=" & font.Charset
Debug.Print "Italic=" & font.Italic
Debug.Print "Name=" & font.Name
Debug.Print "Size=" & font.Size
Debug.Print "Strikethrough=" & font.Strikethrough
Debug.Print "Underline=" & font.Underline
Debug.Print "Weight=" & font.Weight
'color is a separate seting.
Debug.Print "Color=" & g.Axes(1).LabelColor

'set new font characteristics.


font.Bold=True
font.Charset=0
font.Italic=True
font.Name="Times New Roman"
font.Size=35
font.Strikethrough=True
font.Underline=True
font.Weight=800
clr = 1234

'set graph items to use new font


g.Axes(1).LabelFont = font
g.Axes(1).LabelColor= clr
g.Axes(1).GridlineLabelsFont=font
g.Axes(1).GridlineLabelsColor= clr
g.Legend.Font=font

API Scripting Guide 1219


Working with Graphs

g.Legend.Color= clr
g.TitleFont=font
g.TitleColor= clr

End Sub

Editing Graph Fonts

Graph fonts are Type objects, so they are handled differently than most other graph settings. The following code snippet
shows how to get and set font information. You can make a Project with any graph and run this code to see labels, legend,
and title font changes. You must add a new reference to get the StdFont type. Choose Edit > References and then select
the OLE Automation reference. If there is more than one reference, select the highest numbered reference.

' Code Module


Sub Main
Dim g As Graph
Dim font As New StdFont
Dim clr As Integer

Debug.Clear
'get graph
Set g = Project.Graphs(1)

'get font information from graph axes 1 (x-axis) label font.


Set font = g.Axes(1).LabelFont
'print out font information, note Color is separate.
Debug.Print "Bold=" & font.Bold
Debug.Print "Character Set=" & font.Charset
Debug.Print "Italic=" & font.Italic
Debug.Print "Name=" & font.Name
Debug.Print "Size=" & font.Size
Debug.Print "Strike through=" & font.Strikethrough
Debug.Print "Underline=" && font.Underline
Debug.Print "Weight=" & font.Weight

1220 NI AWR Design Environment


Working with Graphs

'color is a separate setting.


Debug.Print "Color=" & g.Axes(1).LabelColor

'set new font characteristics.


font.Bold=True
font.Charset=0
font.Italic=True
font.Name="Times New Roman"
font.Size=35
font.Strikethrough=True
font.Underline=True
font.Weight=800
clr = 1234

'set graph items to use new font


g.Axes(1).LabelFont = font
g.Axes(1).LabelColor= clr
g.Axes(1).GridlineLabelsFont=font
g.Axes(1).GridlineLabelsColor= clr
g.Legend.Font=font
g.Legend.Color= clr
g.TitleFont=font
g.TitleColor= clr

End Sub

The following figure shows the graph before you run the code.

The following figure shows the graph after you run the code.

API Scripting Guide 1221


Working with Graphs

The following shows the example output:

Bold=False
Character Set=0
Italic=False
Name=Arial
Size=18
Strike through=False
Underline=False
Weight=400
Color=0

Working with Graph Titles

The following script hides the Title if it was visible before running the script:

' Code Module


Sub Main
Dim gp As Graph
Debug.Clear
For Each gp In Project.Graphs
Debug.Print "Graph Name = " & gp.Name
' Print initial values.
Debug.Print "Title = " & gp.Title
Debug.Print "TitleColor = " & gp.TitleColor
Debug.Print "TitleFont = " & gp.TitleFont
Debug.Print "TitleVisible = " & gp.TitleVisible
' Toggle the Title visible property
If gp.TitleVisible Then
gp.TitleVisible = False
Else

1222 NI AWR Design Environment


Working with Graphs

gp.TitleVisible = True
End If
' Print the result of the changed Title visible property
Debug.Print "After changing";vbTab;gp.TitleVisible
Next gp
End Sub

This script generates the following output:

Graph Name = Graph 1


Title = Graph 1
TitleColor = 0
TitleFont = Times New Roman
TitleVisible = True
After changing False

Setting LabelText

You must set the Label.Visible property to "True" before setting LabelText. The following code allows you to toggle
the Visible property to set LabelText:

Project.Graphs(1).Axes(1).LabelVisible = True
Debug.Print Project.Graphs(1).Axes(1).LabelText
Project.Graphs(1).Axes(1).LabelText = "test setting label"
Debug.Print Project.Graphs(1).Axes(1).LabelText

Note that each Axis has its own label.

Setting the Color property

You can set the Color property to the following objects:

Axis::LabelColor
Axis::GridlineLabelsColor
Graph::TitleColor
Legend::Color
Trace::TextColor
Trace::LegendKeyColor

The code can look like:

MWOffice.Project.Graphs("Graph 1").TitleColor = MWOffice.Project.Graphs("Graph 2").TitleColor


ax.MajorGridlinesColor = RGB(0, 0, 0)
tr.Color = RGB(255, 0, 0)

Displaying a Graph in a New Window

To display a Graph in a new Window, use the following code:

API Scripting Guide 1223


Working with Graphs

Project.Graphs("Graph 1").NewWindow

A new Window named "Graph 2" is added to the Project workspace.

Use the ViewAll method for the Window object when calling this on a GraphWindow to view the entire graph inside
the display window.

To Copy a Graph to the Clipboard, use the following code:

Dim g As Graph
'simulate project
Project.Simulator.Analyze
gname ="One Tone Load Line"
Set g = Project.Graphs(gname)
stg = Join(Array(vbLf,"Graph - ",g.Name,vbLf),"")
g.CopyToClipboard

Renaming a Graph

To rename a graph, use the following script:

' Test the graph rename api.


Sub Main
Dim gp As Graph
Dim nm As String
For Each gp In Project.Graphs
nm = GetNewGraphName(gp.Name)
If nm <> "" Then
gp.Name = nm
End If
Next gp
End Sub
' Query the user for a new graph name.
Function GetNewGraphName(CurrentName As String) As String
Dim result As Integer
Dim Caption As String
Caption = "Renaming Graph: " & CurrentName
Begin Dialog UserDialog 400,126 ' %GRID:10,7,1,1
OKButton 290,7,100,21
CancelButton 290,35,100,21
Text 20,14,250,14,Caption,.Text1
Text 40,77,90,14,"New Name:",.Text2
TextBox 140,77,220,14,.NewGraphName
End Dialog
Dim dlg As UserDialog
dlg.NewGraphName = CurrentName
result = Dialog(dlg)
If (result <> 0) Then
GetNewGraphName = dlg.NewGraphName
Else
GetNewGraphName = ""
End If
End Function

1224 NI AWR Design Environment


Working with Graphs

When you run this script a dialog box displays to ask you to enter the new name for the Graph.

Measurements Collection of Objects


A measurement is data that is computed by a simulation and plotted on a graph. The measurements associated with a
Graph display as subnodes of that Graph in the Project Browser.

Adding a New Measurement

The following is an example of adding Measurements to Rectangular and Tabular Graphs.

Dim Schem As Schematic


Set Schem = Project.Schematics.Add("Master")
Dim Eles As Elements
Set Eles = Schem.Elements
Dim Ele As Element
dx = 2000
Debug.Clear
Set Ele = Eles.Add("RES",dx,0,1)
'Shows set frequency with array
Dim vals(11) As Double
For i=0 To 10
vals(i) = i*1e9
Next i
Project.Frequencies.AddMultiple(vals())
Eles.Add("Port",dx,0,1)
Eles.Add("Port",dx + 1000,0,180)
Dim gs As Graphs
Dim g As Graph
Dim gt As Graph
Set gs = Project.Graphs
Set g = gs.Add("New Graph",mwGT_Rectangular)
Set gt = gs.Add("Tabular",mwGT_Tabular)
Dim meas As Measurement
g.Measurements.Add("Master","DB(|S(1,1)|)")
gt.Measurements.Add("Master","DB(|S(1,1)|)")
Project.Simulator.Analyze
Set meas = Project.Graphs("New Graph").Measurements(1)
cPoints = meas.XPointCount
For i=1 To cPoints
Debug.Print i;": ";measXValue;vbTab;meas.YValue(i,1)
Next i
Debug.Print "YDataDim = ";meas.YDataDim

In this example, the Graph values are read and printed in the Immediate Window. Note that the Graphs were plotted after
running Project.Simulator.Analyze. Note that your script does not step through this statement until the simulation is
complete.

After running this code, the Project Browser displays the new measurement under the corresponding graph. The name
of the new measurement complies with the standard measurement naming conventions. The YdataDim property returns
Y-dimensions of the Measurement object.

The following script plots all S-parameters in both polar and rectangular formats on four separate Graphs:

API Scripting Guide 1225


Working with Graphs

Sub Main
Dim g As Graph
schName = Project.Schematics(1).Name
Set g = Project.Graphs.Add("S11 and S22",mwGT_SmithChart)
g.Measurements.Add(schName,"S(1,1)")
g.Measurements.Add(schName,"S(2,2)")
Set g = Project.Graphs.Add("S21 and S12",mwGT_Polar)
g.Measurements.Add(schName,"S(2,1)")
g.Measurements.Add(schName,"S(1,2)")
Set g = Project.Graphs.Add("Gain and Isolation",mwGT_Rectangular)
g.Measurements.Add(schName,"DB(|S(2,10|)")
g.Measurements.Add(schName,"DB(|S(1,2)|)")
Set g = Project.Graphs.Add("Return Loss",mwGT_Rectangular)
g.Measurements.Add(schName,"DB(|S(1,1)|)")
g.Measurements.Add(schName,"DB(|S(2,2)|)")
End Sub

NOTE: You can edit measurements via the API. You can change the Name, Source, and Type properties. You can also
remove a specific measurement from the collection. The following code either returns or sets the value of the string
variable to which they correspond:

Projects.Graphs(item).Measurements(item).Type
Projects.Graphs(item).Measurements(item).Source
Projects.Graphs(item).Measurements(item).Name

Disabling a Measurement for Simulation

To disable a Measurement, set the Enabled property to "False".

Dim gra As Graph


Dim mea As Measurement
Set gra = Project.Graphs(1)
Set mea = gra.Measurements(1)
Debug.Print "Enabled = ";mea.Enabled
mea.Enabled = False
Debug.Print "After disabling measurement:"
Debug.Print "Enabled = ";mea.Enabled

This code generates the following output:

Enabled = True
After disabling measurement
Enabled = False

Simulating All Measurements for Individual Graph

To simulate all measurements for an individual Graph, use the following code:

Example of Simulation of all measurements for certain Graph

Dim res As Boolean


Debug.Clear

1226 NI AWR Design Environment


Working with Graphs

res = Project.Graphs("graph1").SimulateMeasurements

Debug.Print res

This method provides simulation from the graph level. Results are False if the simulation does not occur.

Simulating Individual Measurement for Specific Graph

To simulate individual measurements for a specific Graph, use the following code:

Example of Simulation of certain measurement in Graph


Dim meas As Measurement
Dim res As Boolean
Debug.Clear

Set meas = Project.Graphs("graph1").Measurements(1)


Debug.Print meas.Name

res = meas.SimulateMeasurement

Debug.Print res

This method allows you to simulate a single measurement. Results are False if the simulation does not occur.

Measurement Data Types

You can set the DataType of the measurement object. The NI AWR SDE offers the following DataTypes (constants that
define different measurement data types):

Name Value
mwMDT_UnKnown 0
mwMDT_ReflectionData 1
mwMDT_AdmittanceData 2
mwMDT_ImpedanceData 3
mwMDT_GainCircleData 4
mwMDT_NoiseData 5
mwMDT_StabilityData 6
mwMDT_CurveTraceData 7
mwMDT_SpectrumData 8
mwMDT_SourceMapData 9
mwMDT_HistogramData 10
mwMDT_MultiTraceData 11
mwMDT_LoadPullContour 12
mwMDT_DiscreteTimeData 13

API Scripting Guide 1227


Working with Graphs

Measurement Types

The NI AWR SDE offers access to the MeasurementInfos collection of objects. This collection allows you to retrieve
all information regarding Measurement names, Types, categories, and DataUnitTypes. The following script outputs full
information:

' Code Module


Sub Main
Debug.Clear
Dim i As Integer
Dim measInfo As MeasurementInfo
Dim measInfo2 As MeasurementInfo

For i = 1 To MWOffice.MeasurementInfos.Count

Set measInfo = MWOffice.MeasurementInfos.Item(i)


Set measInfo2 = MWOffice.MeasurementInfos.Item(measInfo.Name)
Debug.Print measInfo.Name;vbTab;measInfo.HelpContext;vbTab;measInfo.Category;vbTab;measInfo2.Desc
Debug.Print measInfo2.Name;vbTab;measInfo2.Description;vbTab;measInfo2.Category

Next i

End Sub

This script generates the following partial output:

PDF 8058 System\Statistics Probability Density Function


PDF Probability Density Function System\Statistics
DLY_PROP 8083 System\Tools Static Signal Delay Properties
DLY_PROP Static Signal Delay Properties System\Tools
EsN0_PROP 8082 System\Tools Static Power/Noise Ratio Properties
EsN0_PROP Static Power/Noise Ratio Properties System\Tools
FRQ_PROP 8067 System\Tools Frequency Properties
FRQ_PROP Frequency Properties System\Tools
NOISE_PROP 8085 System\Tools Static Noise Properties
NOISE_PROP Static Noise Properties System\Tools
PHS_PROP 8084 System\Tools Static Phase Rotation Properties
PHS_PROP Static Phase Rotation Properties System\Tools
PWR_PROP 8081 System\Tools Static Signal Power Properties
PWR_PROP Static Signal Power Properties System\Tools
S_HIST 8032 System\_Obsolete System Histogram
S_HIST System Histogram System\_Obsolete
IS97_RHO 0 System\_PRE_RELEASE IS-97 rho measurement
IS97_RHO IS-97 rho measurement System\_PRE_RELEASE
YSens 6192 Yield Component Sensitivity Histogram
YSens Component Sensitivity Histogram Yield
DCA_M 6271 Annotate Annotate DC values to V_PROBE, I_METER, and V_METER
DCA_M Annotate DC values to V_PROBE, I_METER, and V_METER Annotate
DCIA 6273 Annotate Annotate DC input current for all elements
DCIA Annotate DC input current for all elements Annotate
DCVA_E 6270 Annotate DC voltage for two-terminal elements
DCVA_E DC voltage for two-terminal elements Annotate
DCVA_N 6272 Annotate Annotate DC voltage for all nodes
DCVA_N Annotate DC voltage for all nodes Annotate
DC_IDENSA 6275 Annotate Annotate current density

1228 NI AWR Design Environment


Working with Graphs

DC_IDENSA Annotate current density Annotate


DC_IE 6321 Annotate Annotate DC terminal currents on the element
DC_IE Annotate DC terminal currents on the element Annotate
DC_PWRA 6276 Annotate Annotate DC power for all elements
DC_PWRA Annotate DC power for all elements Annotate

For a complete description of the measurements for each Measurement Type, see Microwave Office Measurement
Catalog.

The following is an example of adding different types of Graphs and Measurements to the Project:

Dim source As String


Dim m As MeasurementInfo
Set g=Project.Graphs.Add(m.Name+" Re",gt)
g.Measurements.Add(source,"Re("+m.Name+"(1,2))")
g.Measurements.Add(source,"DB(Re("+m.Name+"(1,2)))")
Set g=Project.Graphs.Add(m.Name+" Im",gt)
g.Measurements.Add(source,"Im("+m.Name+"(1,2))")
g.Measurements.Add(source,"DB(Im("+m.Name+"(1,2)))")
Set g=Project.Graphs.Add(m.Name+" Mag",gt)
g.Measurements.Add(source,"|"+m.Name+"(1,2)|")
g.Measurements.Add(source,"DB(|"+m.Name+"(1,2)|)")
Set g=Project.Graphs.Add(m.Name+" Ang",gt)
g.Measurements.Add(source,"Ang("+m.Name+"(1,2))")
g.Measurements.Add(source,"DB(Ang("+m.Name+"(1,2)))")

Here "gt" is the mwGT_GraphType, for example mwGT_Rectangular, or mwGT_Tabular.

"Source" is the particular data source name, for example "Filter", or "All Sources"; m.Name is the MeasurementInfo.Name
.

You can output the Source, Type, and UnitType of the Measurement object.

The following script provides some information about Graph measurements:

NOTE:This technicue has some issues, see next section "Reading Graph Values"

Option Explicit
' Code Module
Sub Main
Dim g As Graph
Dim m As Measurement
Debug.Clear
For Each g In Project.Graphs
Debug.Print g.Name & ":"
For Each m In g.Measurements
Debug.Print " Meas name: " & m.Name
Debug.Print " X axis display units: " & Project.Units(m.UnitType(1)).UnitString
Debug.Print " First 5 x-axis values: "
Dim i As Integer
For i = 1 To 5
Debug.Print " " & m.XValue(i)
Next i
Next m

API Scripting Guide 1229


Working with Graphs

Next g
End Sub

This script generates the following output:

S11:
Meas name: Schematic 1:DB(|S(1,1)|)
X axis display units: GHz
First 5 x-axis values:
1000000000
2000000000
3000000000
4000000000
5000000000
Vtime:
Meas name: Schematic 1:Vtime(PORT_1,1)[1]
X axis display units: ns
First 5 x-axis values:
0
1
2
3
4

The following script outputs HelpContext for all models and all Measurements in the NI AWR SDE to the modelhelp.csv
and meashelp.csv files.

Sub Main
Dim m As Model
Dim mcol As Models
Dim ms As Measurementinfo
Dim mscol As Measurementinfos
Debug.Clear
Set mcol = MWOffice.Models
Set mscol = MWOffice.Measuremantinfos
Debug.Print mcol.Count
Open "modelhelp.csv" For Output As #1
Open "meashelp.csv" For Output As #2
For Each m In mcol
If Left$(m.Name)<> "_" Then
Debug.Print m.Name;",";m.HelpContext
Print #1,m.Name; ;",";m.HelpContext
End If
Next m
Debug.Print mscol.Count
For Each ms In mscol
If Left$(ms.Name)<> "_" Then
Debug.Print ms.Name;",";ms.HelpContext
Print #1,ms.Name; ;",";ms.HelpContext
End If
Next ms
Close #1
Close #2
End Sub

1230 NI AWR Design Environment


Working with Graphs

Deleting Measurements

To delete all Measurements from the first Graph in a Project enter the following code:

Project.Graphs(1).Measurements.RemoveAll

To delete specific Measurements from a specified Graph, use the following example:

Set g = Project.Graphs.("S11 and S22")


g.Measurements.(schName,"S(1,1)").Remove

To delete a specific Graph, use the following example:

Set g = Project.Graphs.("S11 and S22")


g.Remove

Working with the Annotations Collection of Objects

To use the Annotations Collection, use the following code:

Set anns = Project.Annotations


For Each ann In anns
If (((ConvertDisabled = False) And (ann.Enabled)) Or (ConvertDisabled)) Then
eqn = ann.Name
newEqn = parseEqn(eqn,False)
If (shouldWriteMeas(eqn,newEqn)) Then
ann.Name = newEqn
End If
End If
Next ann

Post-Processing Measurements and Configuring the Results

Reading Graph Values

In the following example the results of the simulation display in the Immediate Window.

Set gs = Project.Graphs
Set g = gs.Add("New Graph",mwGT_Rectangular)
Set gt = gs.Add("Tabular",mwGT_Tabular)
Dim meas As Measurement
g.Measurements.Add("Master","DB(|S(1,1)|)")
gt.Measurements.Add("Master","DB(|S(1,1)|)")
Project.Simulator.Analyze
Set meas = Project.Graphs("New Graph").Measurements(1)cPoints = meas.XPointCount
For i=1 To cPoints
Debug.Print i;": ";meas.XValue(i);vbTab;meas.YValue(i,1)
Next i
Debug.Print "YDataDim = ";meas.YDataDim

NOTE:When developing Measurements via the NI AWR SDE, for "generated x-axis" measurements like Vtime and
Vharm, the x-data is not stored in the "X-values" because if the measurement has more than one trace (for example,

API Scripting Guide 1231


Working with Graphs

Vtime that is swept over frequency), the x-data values are different for each trace. In these cases, the X-values are just
continuous integers representing the index. The real X-values are interspersed with the Y-values.

This technicue has issues. For the following graph measurements and the script:

Sub Main
Debug.Clear
' Old way
Dim spar As Measurement, vtime As Measurement
Set spar = Project.Graphs("Spar").Measurements(1)
Set vtime = Project.Graphs("Vtime").Measurements(1)
' Let's print the x-values for both measurements
Debug.Print spar.XPointCount
For i = 1 To spar.XPointCount
Debug.Print spar.XValue(i)
Next i
Debug.Print vtime.XPointCount
For i = 1 To vtime.XPointCount
Debug.Print vtime.XValue(i) ' it prints 0 to N-1
Next i
End Sub

The x-values for the s-parameter measurement are as expected (1e9,2e9). The x-values for the time measurements are
clearly wrong, they go from 0 to #pts-1. The time measurement has two traces with different x-values for each trace. As
such, the x-data is forced to be interspersed with the y-data.

1232 NI AWR Design Environment


Working with Graphs

So, when accessing the measurements with unique x-data:

Debug.Print vtime.YDataDim
For i = 1 To vtime.YDataDim
Debug.Print vtime.YValue(501, i)
Next i

The vtime measurement has four y-data-dims. Printing the last point in the trace for each of the four dims gives us a
clue:

4
0.000000002 'Last x-val, trace1
0.201081551113916 'Last y-val, trace1
0.000000001 'Last x-val, trace2
0.201081551113916 'Last y-val, trace2

The y-data-dim concept is overloaded. It represents:

Dimensionality of data. 1 for real, 2 for complex, 4 for circles, 17 for Smap!
The number of traces in the measurement. Plotting a real measurement that has four sweep values gives a y-data-dim
of 4, but a complex measurement would be 8 if they share x-values.
For unique x-value measurements, like Vtime, the y-data-dim is 2*#traces because each trace has and x vector and a
y vector interspersed within the y-data.
We dont even see a way in the API to determine which measurements use shared vs. unique data.

Using TraceValues() - a new read-only property, for accessing the x/y values associated with a trace on a 2D graph

New TraceValues() property for accessing the x/y values associated with a trace on a 2D graph are shown in the following
code:

Sub Main
PrintAllTraces("Spar")
End Sub
Sub PrintAllTraces(graph_name As String)
Debug.Clear
Dim dv() As Double
Dim m As Measurement
Set m = Project.Graphs(graph_name).Measurements(1)
Dim trace_index As Integer
Dim nx, ny As Integer
Dim ix, iy As Integer
Debug.Print "#Traces=" & m.TraceCount
For trace_index = 1 To m.TraceCount
Debug.Print "trace" & trace_index
dv = m.TraceValues(trace_index)
nx = UBound(dv,1) 'first dimension is x-axis
ny = UBound(dv,2) 'second dimension is x/y-data
Debug.Print "#x = " & nx
Debug.Print "#y = " & ny
For iy = 1 To ny

API Scripting Guide 1233


Working with Graphs

Debug.Print "y" & iy


For ix = 1 To nx
Debug.Print "x(" & ix & ")=" &dv(ix,iy)
Next ix
Next iy
Next trace_index
End Sub

Output for real Spar measurement:

#Traces=1
trace1
#x = 2
#y = 2
y1
x(1)=1000000000
x(2)=2000000000
y2
x(1)=0.899230342395372
x(2)=0.89923034239537

Output for complex Spar measurement:

#Traces=1
trace1
#x = 2
#y = 3
y1
x(1)=1000000000
x(2)=2000000000
y2
x(1)=-0.845705590327905
x(2)=-0.845705590327905
y3
x(1)=-0.307794372485185
x(2)=-0.307794372485185

Handles shared/unique x-values.Output for Vtime (last x-point only, for brevity):

#Traces=2
trace1
#x = 501
#y = 2
y1
x(501)=0.000000002
y2
x(501)=-9.73331267194979E-02
trace2
#x = 501
#y = 2
y1
x(501)=0.000000001

1234 NI AWR Design Environment


Working with Graphs

y2
x(501)=-9.73331267194979E-02

Remember that X-data is always row 1.

Keep in mind that if a Measurement is based on a complex modifier, or if the equation Measurement does not use it
directly in the script, you use a real modifier instead. The behavior for "generated x-axis" Measurements like Vtime and
Vharm is handled automatically by Measurements, but equations cannot assume they are representing a single
Measurement.

Accessing the Parametric Sweep Value

In the following picture you can see that two sweep dimensions, four traces produced:

To get the values for Parametric Sweep Access use the following code:

Sub Main
Debug.Clear

API Scripting Guide 1235


Working with Graphs

Dim m As Measurement
Set m = Project.Graphs(1).Measurements(1)
Dim sls As SweepLabels
Dim sl As SweepLabel
For trace_index = 1 To m.TraceCount
Set sls = m.SweepLabels(trace_index)
Debug.Print "Trace " & trace_index
For Each sl In sls
Debug.Print sl.Name & "=" & sl.Value & " (" & sl.UnitType & ")"
Next sl
Next trace_index
End Sub

Sweep labels correspond with exactly what you see in the parameter markers on the previous picture.

The Debug Output will look as the following:

Trace 1
R1=25 (0)
R2=10 (0)
Trace 2
R1=30 (0)
R2=10 (0)
Trace 3
R1=25 (0)
R2=20 (0)
Trace 4
R1=30 (0)
R2=20 (0)

You can use OutputEquations to assign the results of a Measurement to a variable, which can be used in other equations
like any other variable. The results computed in equations can be plotted like any other Measurement. For details see
Variables and Equations.

Access to a Results Reporting Service

To access a results reporting service, use the following code:

Debug.Print Project.ErrorState

ErrorState gives 0,1,2 states of errors depending on results of simulation.

Accessing embedded design views in Graphs

To access embedded design views in Graph, use the following script:

Dim emb As EmbeddedDesign


Dim grph As Graph

Set grph = Project.Graphs("Graph 1")

For Each emb In grph.EmbeddedDesigns

1236 NI AWR Design Environment


Working with Graphs

PrintEmbeddedDetails emb
Next emb

End Sub

Sub PrintEmbeddedDetails(ByRef emb As EmbeddedDesign)


Debug.Print "Design Name = " & emb.DesignName
Debug.Print "Extension = " & emb.Extension
Debug.Print "X Pos = " & emb.x
Debug.Print "Y Pos = " & emb.y
Debug.Print "Width = " & emb.Width
Debug.Print "Height = " & emb.Height
Debug.Print ""
End Sub

To add embedded design to Graph use the following code:

grph.EmbeddedDesigns.Add("EMS1", mwEDT_EMLayout, 0, 0, 2000, 1000)


grph.EmbeddedDesigns.Add("Graph 1", mwEDT_Graph, 0, 0, 2000, 1000)
grph.EmbeddedDesigns.Add("Graph 2", mwEDT_Graph, 2000, 0, 2000, 1000)
grph.EmbeddedDesigns.Add("SCH1",mwEDT_SchematicLayout, 0, 0, 2000, 1000)
grph.EmbeddedDesigns.Add("SCH2",mwEDT_Schematic, 0, 0, 2000, 1000)

To move embedded design in Graph use the following code:

If (grph.EmbeddedDesigns.Count > 0) Then


' Move the base position of the embedded layout design
Set emb = grph.EmbeddedDesigns(1)
emb.x = 500
emb.y = 500
End If

To remove embedded design in Graph use the following code:

Dim index As Integer


index = 0
Set grph = Project.Graphs("Graph 1")

For i = 1 To grph.EmbeddedDesigns.Count
If (grph.EmbeddedDesigns(i).DesignName = "Graph 1") Then
index = i
End If
Next i

Dim bRes As Boolean


If (index ne 0) Then
bRes = grph.EmbeddedDesigns.Remove(index)
Debug.Print "Remove Returned: " & bRes
End If

API Scripting Guide 1237


Optimizing, Tuning, and Yield

To remove All embedded design in Graph use the following code:

Dim bRet As Boolean


bRet = grph.EmbeddedDesigns.RemoveAll
Debug.Print "Remove All Returned: " & bRet

To resize layout embedded design in Graph use the following code:

Dim emb As EmbeddedDesign

Set grph = Project.Graphs("Graph 1")

If (grph.EmbeddedDesigns.Count > 0) Then


' Resize the embedded design to make it larger.
Set emb = grph.EmbeddedDesigns(1)
emb.Width = emb.Width + 1000
emb.Height = emb.Height + 1000
End If

Optimizing, Tuning, and Yield


Specifying Parameter Values for Tuning, Optimizing, and Constraining
You can select a variable or parameter for optimization by setting the optimization property.

The following example iterates through the entire Schematics collection and Elements parameters collections. It also
outputs the values of the Optimize, Constrain, and Tune properties.

' Code Module


Sub Main
Debug.Clear
Dim sch As Schematic
Dim ele As Element
Dim par As parameter
Dim l As Long
Dim k As Long
Dim i As Long
i = 0
For Each sch In Project.Schematics
i = i + 1
l = 0
For Each ele In sch.Elements
l=l+1
If ele.parameters.Count > 0 Then
k = 0
For Each par In sch.Elements(l).parameters
k = k + 1
If par.Optimize Then
Debug.Print
Debug.Print "Schematic Name = ";
Project.Schematics(i).Name;String(10," ");"Element ";

1238 NI AWR Design Environment


Optimizing, Tuning, and Yield

ele.Name;String(10," ");"parameter = ";par.Name


Debug.Print "Optimize = ";par.Optimize;vbTab;"Constrain = ";
par.Constrain;"Tune = ";vbTab;par.Tune
Debug.Print "LowerConstraint =";par.LowerConstraint;
vbTab;"UpperConstraint = ";par.UpperConstraint
Debug.Print "OptimizeYield = ";par.OptimizeYield;
vbTab;"StatVariation = "; par.StatVariation;vbTab;
"TolInPercent = ";par.TolInPercent
End If
Next par
End If
Next ele
Next sch
End Sub

The output in the Immediate Window shows that you can access all of the properties via the API.

Schematic Name = Filter Element CAP.C2 parameter = C Optimize = True Constrain=False Tune = Tru
OptimizeYield = False StatVariation = 0 TolInPercent = False
Schematic Name = Filter Element IND.L3 parameter = L Optimize = True Constrain = FalseTu
OptimizeYield = True StatVariation=0.000000003 TolInPercent = False

You can set parameter properties (such as Optimize, or Tune, or Constrain) to "True" and select the setting in the Variable
Browser.

The following example shows how to toggle off the Optimize property in all Element parameters in the Project.

Sub Main
'Seeking for Elements and for parameters
Debug.Clear
Dim sch As Schematic
Dim ele As Element
Dim par As parameter
Dim eqn As Equation
Dim l As Long
Dim k As Long
Dim i As Long
i = 0
For Each sch In Project.Schematics
i = i + 1
l = 0
For Each ele In sch.Elements
l=l+1
If ele.parameters.Count > 0 Then
k = 0
For Each par In sch.Elements(l).parameters
k = k + 1
If par.Optimize Then
Debug.Print
Debug.Print "Schematic Name = ";Project.Schematics(i).Name;String(10," ");
"Element ";ele.Name;String(10," ");"parameter = ";par.Name
par.Optimize = False
End If
Next par
' Seeking in Equations

API Scripting Guide 1239


Optimizing, Tuning, and Yield

For Each eqn In sch.Equations


If eqn.Optimize Then
Debug.Print"SchematicName= ";Project.Schematics(i).Name;String(10," ");
"Equation ";eqn.Expression
eqn.Optimize = False
End If
Next eqn
End If
Next ele
Next sch
End Sub

This script generates the following output.

Schematic Name = Filter Element CAP.C2 parameter = C


Schematic Name = Filter Element IND.L3 parameter = L

You can set parameter properties to Tune and do some tuning as in the following code:

Private Sub Project_BeforeSimulate(Cancel As Boolean)


Dim var As Variant
For i = 1 To Project.Tuner.Variables.Count
Debug.Print Project.Tuner.Variables(i).Name
Next i
Project.Tuner.Variables(1).TuneUp
Project.Tuner.Variables(1).TuneUp

End Sub

You can access tune variables properties as in the following code:

Sub Main
Dim tune As Tuner
Dim var As TuneVariable
Dim var2 As TuneVariable

Set tune= Project.Tuner


For Each var In tune.Variables

' Verify property access.


PrintTuneVarProperties(var)

' Test lookup by name


Set var2 = tune.Variables(var.Name)
If (var2 Is Nothing) Then
Debug.Print "Tune variable " & var.Name & " Lookup by name failed"
Else
Debug.Print "Tune variable " & var.Name & " Lookup by name succeeded"
End If

If (tune.Variables.Exists(var.Name)) Then
Debug.Print "Tune variable " & var.Name & " Exists by name succeeded"
Else
Debug.Print "Tune variable " & var.Name & " Exists by name failed"

1240 NI AWR Design Environment


Optimizing, Tuning, and Yield

End If

Debug.Print ""

Next var

End Sub

Sub PrintTuneVarProperties( ByRef var As TuneVariable)


Debug.Print "Name = " & var.Name
Debug.Print "Nominal = " & var.Nominal * 1e6
Debug.Print "Maximum = " & var.Maximum * 1e6
Debug.Print "Minimum = " & var.Minimum * 1e6
Debug.Print "Step = " & Round(var.Step * 1e6, 2)
End Sub

To change tune variables:

Set elem = Project.Schematics("Schematic 1").Elements("MLIN.TL1")


Set tune = Project.Tuner
tune.Variables("TL1:W").Nominal = 20e-6

To add tune variables:

Set elem = Project.Schematics("Schematic 1").Elements("MLIN.TL1")


elem.Parameters("W").Tune = True
elem.Parameters("L").Tune = True

To remove tune variables:

Set elem = Project.Schematics("Schematic 1").Elements("MLIN.TL1")


elem.Parameters("W").Tune = False
elem.Parameters("L").Tune = False

To restore tune variables:

Dim elem As Element


Dim tune As Tuner
Set elem = Project.Schematics("Schematic 1").Elements("MLIN.TL1")
Set tune = Project.Tuner
tune.Save("MyState")

tune.Variables("TL1:W").Maximum = 250e-6
tune.Variables("TL1:L").Maximum = 25e-6

tune.Variables("TL1:W").Nominal = 15e-6
tune.Variables("TL1:L").Nominal = 80e-6

tune.Variables("TL1:W").Minimum = 3e-6

API Scripting Guide 1241


Optimizing, Tuning, and Yield

tune.Variables("TL1:L").Minimum = 25e-6

tune.Variables("TL1:W").Step = 0.2e-6
tune.Variables("TL1:L").Step = 2e-6

tune.Restore("MyState")

Optimization
Working with Optimization Goals

You can optimize your Project via a script. For example, you can automate a complex optimization where a set of goals
is iterated through while several optimizations are performed. In the following example, five optimization goals are set
and optimized simultaneously:

Disables the group delay goal


Optimizes for 200 iterations
Displays the error function
Disables other than group delay goals and enables the group delay goal
Changes to the random optimizer

Optimizing for 200 more iterations

From a design viewpoint this optimization sequence is not very beneficial, although it does identify the core optimization
functionality. For the optimization goals, it also demonstrates an alternative way to loop through a collection.

Dim og As Goal
' disable the group delay goal, enable others
For Each og In Project.OptGoals
If (og.MeasName = "GD[2,1]") Then
og.Enable = False
Else
og.Enable = True
End If
Next og
' setup optimizer
Project.Optimizer.Type = 6
Project.Optimizer.Iterations = 200 ' returns number of current iterations
Debug.Print Project.Optimizer.Type ' check the type of optimizer
Project.Optimizer.Start ' run optimizer
' set the optimizer type
Project.Optimizer.Type = "Random (Local)"
Debug.Print Project.Optimizer.Type
For i=1 To 10
Project.Optimizer.Iterations=5000
Project.Optimizer.Start
Wait .5
Debug.Print i;":";Project.Optimizer.Cost
Wait .5
Project.Optimizer.Save (Format(i))
Project.Optimizer.Revert ("Initial")' swap the optimization goals
Next i

1242 NI AWR Design Environment


Optimizing, Tuning, and Yield

For Each og In Project.OptGoals


If (og.MeasName = "GD[2,1]") Then
og.Enable = True
Else
og.Enable = False
End If
Next og

The following script sets a sloped goal in which both values are different than the original values:

'Setting optimizer goals


Sub Main
Dim objGoal As Goal
Set objGoal = Project.OptGoals(1)
Debug.Clear
objGoal.yStart = 1.0
objGoal.yStop = 1.0
Debug.Print objGoal.xStart;
Debug.Print objGoal.xStop
Debug.Print objGoal.yStart;
Debug.Print objGoal.yStop
' Setting new borders for Optimization Goal
objGoal.yStart = 2.0
objGoal.yStop = 3.0
Debug.Print objGoal.xStart;
Debug.Print objGoal.xStop
Debug.Print objGoal.yStart;
Debug.Print objGoal.yStop
End Sub

The following is an output example:

-3.40282346638529E+38 3.40282346638529E+38
1 1
-3.40282346638529E+38 3.40282346638529E+38
2 3

Note that in the examples, all Optimizer Goals were previously set in the Project.

Constants that define different types of optimization goals are shown in the following table:

Name Value
mwOGT_Equals 0
mwOGT_LessThan 1
mwOGT_GreaterThan 2

Adding Optimizer Goals

The following script creates a Graph with Measurements and adds two Optimizer Goals that display as subnodes of the
Optimizer Goals node in the Project Browser.

Sub Main

API Scripting Guide 1243


Optimizing, Tuning, and Yield

'Check_OptGoals
Debug.Clear
Dim gs As Graphs
Dim g As Graph
Dim gg As Graph
Dim m As Measurement
Dim og As Goal
Dim ogg As Goal
' Adding Graphs to the project
Set gs = Project.Graphs
Set g = gs.Add("Graph 1",mwGT_Rectangular)
'Creating measurements
g.Measurements.Add("Filter","|S(1,1)|")
g.Measurements.Add("Filter","|S(2,1)|") 'works
Set og = Project.OptGoals.Add("Filter","|S(1,1)|",mwOGT_LessThan,1,2,
4.8e+09,5.2e+09,mwUT_Frequency,0.3,0.3,mwUT_DB)
Set ogg= Project.OptGoals.Add("Filter","|S(2,1)|",mwOGT_GreaterThan,1.3,2,
4.8e+09,5.2e+09,mwUT_Frequency,0.97,0.97,mwUT_DB)
og.Weight = 0.06
og.xStart = -10
og.L = 0
Debug.Print "CircuitName = ";og.CircuitName;vbTab;"MeasName = ";og.MeasName
Debug.Print "Weight = ";og.Weight;vbTab;"Name = ";og.Name
Debug.Print "xStart = ";og.xStart;vbTab;"xStop = ";og.xStop
Debug.Print "yStart = ";og.yStart;vbTab;"yStop = ";og.yStop
Debug.Print "Cost = ";og.Cost;vbTab;"Enable = ";og.Enable;vbTab;"L = ";og.L
Debug.Print
Debug.Print "CircuitName = ";ogg.CircuitName;vbTab;"MeasName = ";ogg.MeasName
Debug.Print "Weight = ";ogg.Weight;vbTab;"Name = ";ogg.Name
Debug.Print "xStart = ";ogg.xStart;vbTab;"xStop = ";ogg.xStop
Debug.Print "yStart = ";ogg.yStart;vbTab;"yStop = ";ogg.yStop
Debug.Print "Cost = ";ogg.Cost;vbTab;"Enable = ";ogg.Enable;vbTab;"L = ";ogg.L
Project.Simulator.Analyze
End Sub

This script generates the following output:

CircuitName = Filter MeasName = |S(1,1)|


Weight = 5.99999986588955E-02 Name = Filter:|S(1,1)|<0.3 [w=0.06,Range=-10..5.2e+009]
xStart = -10 xStop = 5200000000
yStart = 0.3 yStop = 0.3
Cost = 4.19983849111097E-02 Enable = True L = 0
CircuitName = Filter MeasName = |S(2,1)|
Weight = 1.29999995231628 Name = Filter:|S(2,1)|>0.97 [w=1.3,Range=4.8e+009..5.2e+009]
xStart = 4800000000 xStop = 5200000000
yStart = 0.97 yStop = 0.97
Cost = 1.58635245487479E-04 Enable = True L = 2

Note that in this script X an Y are added in Base Units.

Also, any units types are ignored when adding Optimization/Yield Goals through the API.

One more example of code that adds Yield Goals:

Project.YieldGoals.Add("Schematic 1", "DB(|S(2,1)|)", mwOGT_LessThan, -3.40282346638529E+38, 3.402

1244 NI AWR Design Environment


Optimizing, Tuning, and Yield

mwUT_Scaler, 0, 0, mwUT_Scaler)
Project.YieldGoals.Add("Schematic 1", "DB(|S(1,1)|)", mwOGT_LessThan, -3.40282346638529E+38, 3.402
mwUT_Scaler, -10, -10, mwUT_Scaler)

You can calculate TotalCost using the following script:

Sub Main
Debug.Clear
Project.Simulator.Analyze
Debug.Print "TotalCost = ";Project.OptGoals.TotalCost
Project.Optimizer.Start
Wait 10
Project.Optimizer.Stop
Debug.Print "Optimizer.Cost = ";Project.Optimizer.Cost
End Sub

This script generates the following output:

TotalCost = 4.22384419132002E-02
Optimizer.Cost = 4.21570201565972E-02

You can print out all Opt Goal details using the following script:

Sub Main
Debug.Clear
Dim objGoal As Goal

Debug.Print "Project Opt Goals, Count = " & Project.OptGoals.Count


For Each objGoal In Project.OptGoals
PrintOptGoalDetails objGoal
Next objGoal
End Sub
Sub PrintOptGoalDetails(ByRef objGoal As Goal)
Debug.Print "Name = " & objGoal.Name
Debug.Print "Circuit = " & objGoal.CircuitName
Debug.Print "Cost = " & objGoal.Cost
Debug.Print "Enable = " & objGoal.Enable
Debug.Print "Measruement = " & objGoal.MeasurementName
Debug.Print "Tags = " & objGoal.Tag
Debug.Print "Weight = " & objGoal.Weight
Debug.Print "xStart = " & objGoal.xStart
Debug.Print "xStop = " & objGoal.xStop
Debug.Print "yStart = " & objGoal.yStart
Debug.Print "yStop = " & objGoal.yStop

If Project.OptGoals.Exists(objGoal.Name) Then
Debug.Print "Lookup Exists by Name Succeded"
Else
Debug.Print "Lookup Exists by Name Failed"
End If

Dim objGoal2 As Goal


Set objGoal2 = Project.OptGoals(objGoal.Name)
If objGoal2 Is Nothing Then

API Scripting Guide 1245


Optimizing, Tuning, and Yield

Print #1, "Lookup Item by Name Failed"


Else
Print #1, "Lookup Item by Name Succeeded"
End If
End Sub

Deleting Optimizer Goals

To delete an Optimizer Goal, use the following code:

Project.OptGoals.Remove(1)

Disabling Optimizer Goals

To disable Optimizer Goals, set the Enable property to "False".

Project. OptGoals(1).Enable = False

Changing Opt or Yield Goal Measurements

To access to the optimizer goal measurement objects use the folowing code. The code simply shows access to the
measurement name, source, type and enabled state:

Sub Main
Dim objGoal As Goal

Debug.Print "Project Opt Goals, Count = " & Project.OptGoals.Count


For Each objGoal In Project.OptGoals
PrintOptGoalMeasDetails objGoal
Next objGoal
End Sub

Sub PrintOptGoalMeasDetails(ByRef objGoal As Goal)


Dim meas As Measurement
Debug.Print "Goal Measurement Details: "
Set meas = objGoal.Measurement
Debug.Print "Goal Name = " & objGoal.Name
Debug.Print "Meas Name = " & meas.Name
Debug.Print "Meas Enabled = " & meas.Enabled
Debug.Print "Meas Source = " & meas.Source
Debug.Print "Meas Type = " & meas.Type
Debug.Print ""
End Sub

For the Yield Goals use the same code, but use Project.YieldGoals collection of objects

The Goal CircuitName and MeasurementName properties are writable. The following is a fragment of the code:

Set gs = Project.Graphs
writeLog(vbNewLine + vbNewLine + "Measurements" + vbNewLine)
For Each g In gs
Set ms = g.Measurements
For Each m In ms

1246 NI AWR Design Environment


Optimizing, Tuning, and Yield

If (((ConvertDisabled = False) And (m.Enabled)) Or (ConvertDisabled)) Then


eqn = m.Name
newEqn = parseEqn(eqn,False)
If (shouldWriteMeas(eqn,newEqn)) Then
m.Name = newEqn
End If
End If
Next m
Next g

Set oes = Project.OutputEquations


writeLog(vbNewLine + vbNewLine + "Output Equations" + vbNewLine)
For Each oe In oes
For i=1 To oe.NumSubexpressions
If (((ConvertDisabled = False) And (oe.Enabled)) Or (ConvertDisabled)) Then
eqn = oe.Subexpression(i)
If isMeas(eqn) Then
newEqn = parseEqn(eqn,False)
If (shouldWriteMeas(eqn,newEqn)) Then
oe.Subexpression(i) = newEqn
End If
End If
End If
Next i
Next oe

Set opts = Project.OptGoals


writeLog(vbNewLine + vbNewLine + "Opt Goals" + vbNewLine)
For Each opt In opts
If (((ConvertDisabled = False) And (opt.Enable)) Or (ConvertDisabled)) Then
eqn = opt.Name
eqn = getGoalMeas(eqn)
newEqn = parseEqn(eqn,True)
If (shouldWriteMeas(eqn,newEqn)) Then
If (isPlotVsMeas(eqn)) Then
newEqn = Right(newEqn,Len(newEqn)-1)
opt.MeasurementName = newEqn
Else
opt.CircuitName = newEqn
End If
End If
End If
Next opt

Set ylds = Project.YieldGoals


writeLog(vbNewLine + vbNewLine + "Yield Goals" + vbNewLine)
For Each yld In ylds
If (((ConvertDisabled = False) And (yld.Enable)) Or (ConvertDisabled)) Then
eqn = yld.Name
eqn = getGoalMeas(eqn)
newEqn = parseEqn(eqn,True)
If (shouldWriteMeas(eqn,newEqn)) Then
If (isPlotVsMeas(newEqn)) Then
newEqn = Right(newEqn,Len(newEqn)-1)
yld.MeasurementName = newEqn
Else
yld.CircuitName = newEqn

API Scripting Guide 1247


Optimizing, Tuning, and Yield

End If
End If
End If
Next yld

Set anns = Project.Annotations


writeLog(vbNewLine + vbNewLine + "Annotations" + vbNewLine)
For Each ann In anns
If (((ConvertDisabled = False) And (ann.Enabled)) Or (ConvertDisabled)) Then
eqn = ann.Name
newEqn = parseEqn(eqn,False)
If (shouldWriteMeas(eqn,newEqn)) Then
ann.Name = newEqn
End If
End If
Next ann

scriptEnd()

Optimization Methods

The following script demonstrates how to output all Optimization Methods in the NI AWR SDE:

' Code Module


Sub Main
Debug.Clear
For i = 1 To Project.Optimizer.TypeCount
Debug.Print i;vbTab;Project.Optimizer.TypeName(i)
Next i
End Sub

This script generates the following output:

1 Pointer - Robust Optimization


2 Pointer - Train an Optimizer
3 Pointer - Run Trained Optimizer
4 Pointer - Gradient Optimization
5 Random (Local)
6 Gradient Optimization
7 Conjugate Gradient
8 Simplex Optimizer
9 Genetic (Uniform Mutation)
10 Genetic (Gaussian Mutation)
11 Simulated Annealing (Simplex)
12 Simulated Annealing (Local)
13 Random (Global)
14 Direction Set Method

During a developing process it could be a change in the order in which the optimizer objects are produced. The key for
this is that the optimizer properties are accessible through the API and there doesn't seem to be a problem with accessing
the properties just a change in the order.

You can set the value, which specifies the type of Optimizer.

1248 NI AWR Design Environment


Optimizing, Tuning, and Yield

Project.Optimizer.Type=8
Debug.Print "Optimizer.Type =";Project.Optimizer.Type

This generates the following output:

Optimizer.Type = 8

NOTE! Project.Optimizer.Type numbers are different; older scripts may not function as expected. This script sets different
numbers for optimizers in versions 9.06 and 10:

' Code Module


Sub Main
Debug.Clear
' Project.Optimizer.Type = "Random (Local)"
Project.Optimizer.Type = 5
End Sub

The workaround is to specify optimizers by name (use a commented line instead). Existing scripts set a different optimizer
than expected. This is not an error; you should never reference these by index because the order may change and new
optimizers may be added. Always reference them by name as shown in the following example code:

Project.Optimizer.Type=find_opt_type("Simplex Optimizer")
Function find_opt_type(nm As String) As Integer
Dim typ As Integer
typ = -1
For i = 1 To Project.Optimizer.TypeCount
If nm = Project.Optimizer.TypeName(i) Then
typ = i
End If
Next i
If typ = -1 Then
MsgBox ("could not find optimizer name specified:" & nm)
End If
find_opt_type = typ
End Function

Accessing Optimizer Properties

The following script queries the properties of a couple of basic optimizer types we expect to be included in the system.
(Random and Gradient) and prints the properties for these optimizers:

' Code Module


Sub Main
Dim opt As Optimizer

Set opt = Project.Optimizer


opt.Type = 4 ' Should be Random (Local)
PrintOptimizerProperties opt, "Properties for Random (Local)"

opt.Type = 5 ' Should be Gradient Optimization

API Scripting Guide 1249


Optimizing, Tuning, and Yield

PrintOptimizerProperties opt, "Properties for Gradient Optimization"

End Sub

Sub PrintOptimizerProperties(ByRef opt As Optimizer, title As String)


Dim prop As Property
Debug.Print title
Debug.Print "Optimizer Type = " & opt.Type
Debug.Print "Type Name = " & opt.TypeName(opt.Type)
Debug.Print "Cancel On Stop = " & opt.CancelOnStop
Debug.Print "Show All Update = " & opt.ShowAllUpdates
Debug.Print "Stop At Min = " & opt.StopAtMin
Debug.Print "Stop on Error = " & opt.StopOnErr
Debug.Print "Properties Count = " & opt.Properties.Count
For Each prop In opt.Properties
Debug.Print " " & prop.Name & " = " & prop.Value
Next prop
Debug.Print ""
End Sub

The output could look as the following:

Properties for Random (Local)


Optimizer Type = 4
Type Name = Random (Local)
Cancel On Stop = True
Show All Update = True
Stop At Min = True
Stop on Error = True
Properties Count = 0

Properties for Gradient Optimization


Optimizer Type = 5
Type Name = Gradient Optimization
Cancel On Stop = True
Show All Update = True
Stop At Min = True
Stop on Error = True
Properties Count = 2
Converge Tolerance = 0.0001
Step Size = 0.00001

Accessing User Settings for Optimizer

The following script demonstrates how to to get settings stored in the User ini file:

' Code Module


Sub Main
Debug.Print MWOffice.UserSetting("Optimizer", "GoalsPropSettings")
End Sub

The Output will looks like:

{0, 0, 0}, {1, 1, 102}, {1, 2, 71}, {1, 3, 47}, {1, 4, 62}, {1, 5, 27}, {1, 6, 58}, {1, 7, 59}, {1

1250 NI AWR Design Environment


Optimizing, Tuning, and Yield

Yield Analysis
Setting Statistical Properties

To set the statistical properties for an Element, use the following code:

Dim par As parameter


Project.Schematics(1).Elements(1).Par.UseStatistics = True

If UseStatistics is not selected (set to "False") the statistical properties are ignored during a yield optimization.

Set the OptimizeYield property to "True" to allow modification of the nominal value of the parameter during a yield
optimization. If the parameter value is also constrained (the Constrain property is set to "True"), then the yield optimizer
uses UpperConstraint and LowConstraint properties to ensure that the nominal value is not changed to an unacceptable
value. You can also set the StatVariation and Distribution properties.

Adding Yield Goals

Constants that define different types of yield goals are shown in the following table.

Name Value
mwYGT_LessThan 0
mwYGT_GreaterThan 1

The following script creates Yield Goals displaying as subnodes of the Yield Goals node in the Project Browser.

Sub Main
'Check_Yield.bas
Debug.Clear
Dim gs As Graphs
Dim g As Graph
Dim m As Measurement
Dim yg As YieldGoals
' Adding Graphs to the project
Set gs = Project.Graphs
Set g = gs.Add("Graph 1",mwGT_Rectangular)
'Adding measurement to the Graph
g.Measurements.Add("MCLIN","|S(2,1)|")
Set yg = Project.YieldGoals
yg.Add("MCLIN","|S(2,1)|",mwYGT_GreaterThan,1e9,10e9,mwUT_Frequency,0.3,0.3,mwUT_None)
yg.Item(1).L = 2
Debug.Print "CircuitName = ";yg.Item(1).CircuitName;vbTab;"MeasName = ";
yg.Item(1).MeasName
Debug.Print "Weight = ";yg.Item(1).Weight;vbTab;"Name = ";yg.Item(1).Name
Debug.Print "xStart = ";yg.Item(1).xStart;vbTab;"xStop = ";yg.Item(1).xStop
Debug.Print "yStart = ";yg.Item(1).yStart;vbTab;"yStop = ";yg.Item(1).yStop
Debug.Print "Cost = ";yg.Item(1).Cost;vbTab;"Enable = ";
yg.Item(1).Enable;vbTab;"L = ";yg.Item(1).L
Debug.Print
Project.YieldAnalyser.Start
Wait 10
Project. YieldAnalyser.Stop

API Scripting Guide 1251


Optimizing, Tuning, and Yield

Debug.Print "TotalCost = ";yg.TotalCost


End Sub

This script generates the following example output:

CircuitName = MCLIN MeasName = |S(2,1)|


Weight = 1 Name = MCLIN:|S(2,1)|>0.3 [w=1,Range=1e+009..1e+010]
xStart = 1000000000 xStop = 10000000000
yStart = 0.3 yStop = 0.3
Cost = 1.07838197619884E-02 Enable = True L = 2
TotalCost = 1.07838197619884E-02

We added a continue method to the Project.YieldAnalzyer interface which appears to perform the same operations as if
the continue button was pressed on the Yield Analysis dialog. In the following code the yield iterations begin to count
up, then pause, and then continue from that point onward. We can get graphs to display updates when the ShowAllUpdates
flag is set. Setting the ShowAllUpdates in the optimizer is supposed to provide feedback in the graph views on the
simulation progress and this makes this option work with yield as well as optimization:

' Code Module


Sub Main
Project.YieldAnalyzer.ShowAllUpdates = True
' Start, Stop, and Continue Yield.
Project.YieldAnalyzer.Start
Wait(3)
Project.YieldAnalyzer.Stop
Wait(2)
Project.YieldAnalyzer.Continue
Wait(10)
Project.YieldAnalyzer.Stop
End Sub

The following script finds Yield type before performing Yield Analysis:

Sub Main

MWOffice.Project.YieldAnalyzer.NewWindow
Project.YieldAnalyzer.MaxIterations=8
Project.YieldAnalyzer.Type=find_yield_type("Yield Analysis")
Project.YieldAnalyzer.MaxIterations=10
Project.YieldAnalyzer.Start

End Sub
Function find_yield_type(nm As String) As Integer
Dim typ As Integer

typ = -1
For i = 1 To Project.YieldAnalyzer.TypeCount
If nm = Project.YieldAnalyzer.TypeName(i) Then
typ = i
End If
Next i
If typ = -1 Then

1252 NI AWR Design Environment


DataSets

MsgBox ("could not find yield analyzer name specified:" & nm)
End If
find_yield_type = typ
End Function

NOTE: To see graph updates, display the Yield Analyzer window before starting the Yield Analysis.

MWOffice.Project.YieldAnalyzer.NewWindow
MWOffice.Project.YieldAnalyzer.Start

Accessing Yield Goals Type

API has read-only property for accessing the Yield Goal Type. If you want to change the type, you'll need to delete and
then add a new goal. To access the type use the following code:

For i =1 To Project.YieldGoals.Count
Debug.Print Project.YieldGoals(i).Type
Next i

The property returns the type of the Yield Goal (>, <, =)

Performing Continue Yield Analysis

API provides equivalent of the Yield Analysis Continue button on the optimizer. To support Continue method for
optimizer in API we need to initialize the graphics to display cached yield traces in the graphs if the optimizer has been
set into the Show All Updates mode. Setting the ShowAllUpdates in the optimizer is supposed to provide feedback in
the graph views on the simulation progress and this makes this option work with yield as well as optimization. You need
to open the Yeild window and run the following program. The yield iterations will begin to count up, then pause and
then continue from that point onward:

' Code Module


Sub Main
Project.YieldAnalyzer.ShowAllUpdates = True
' Start, Stop, and Continue Yield.
Project.YieldAnalyzer.Start
Wait(3)
Project.YieldAnalyzer.Stop
Wait(2)
Project.YieldAnalyzer.Continue
Wait(10)
Project.YieldAnalyzer.Stop
End Sub

DataSets
Working with the DataSets Collection
Graph data sets allow you to store all data on the active graphs for a project. You can automatically save this data when
closing a project, and restore the data when reopening the project. The reopened project displays the data from the last
simulation.

To work with the DataSets collections you need to use the DataSetFolders collection of objects.

API Scripting Guide 1253


DataSets

With the Project.DataSetFolders(1).TreeNode object you can Expand and Collapse the node, and Select and make the
TreeNode object visible.

There are DataSet properties and methods. You can pin and unpin the DataSet object, and give it a new name. You can
also Import a DataSet object.

The following script adds Output Equations and Measurements pointing to older DataSets, and plots on Graph:

' Code Module


Sub Main
'add Output Equations and Measurements pointing to older DataSets, and plot on graph

Dim gr As Graph
Dim meas As Measurement
Dim oeqndoc As OutputEquationDocument

Debug.Clear
Set oeqndoc = Project.OutputEquationDocuments(1)
oeqndoc.Equations.Add("old_oe = em1.@EM_Sim_DS0:S(1,1)",0,200)

Set gr = Project.Graphs("Older_DS")
gr.Measurements.Add("em1.@EM_Sim_DS0","S(1,1)")
gr.Measurements.Add("Output Equations","Eqn(old_oe)")

End Sub

The following script sets a name to DataSet:

' Code Module


Sub Main
Dim dsetf As DataSetFolder
Dim dset As DataSet

Set dsetf = Project.DataSetFolders("em1")


Set dset = dsetf.DataSets("EM_Sim_DS2")

dset.Name = "CurrentDS
End Sub

The following script Updates All Dependents and Updates Results:

' Code Module


Sub Main

Dim dsetfs As DataSetFolders


Dim dset As DataSet

'Enable "Update All Dependants" and point to old datasets


Set dsetfs = Project.DataSetFolders
dsetfs.UpdateDependents=True

Set dset = dsetfs("em2").DataSets("EM_Sim_DS0")


dset.UpdateResults

1254 NI AWR Design Environment


DataSets

End Sub

The following script finds the number of Data Sets created in a Project:

' Project Module

Private Sub Project_Open()


Dim x As Integer
Project.Schematics(1).Elements("SUBCKT.S1").Parameters("L").ValueAsString="400"
Project.Simulator.Analyze
Project.Schematics(1).Elements("SUBCKT.S1").Parameters("L").ValueAsString="800"
Project.Simulator.Analyze
Project.Schematics(1).Elements("SUBCKT.S1").Parameters("L").ValueAsString="400"
Project.Simulator.Analyze
Project.Schematics(1).Elements("SUBCKT.S1").Parameters("L").ValueAsString="800"
Project.Simulator.Analyze

'find number of data sets


x = num_data_sets()
stg = "1" & vbTab & x
Project.DataFiles(1).DataAsText=stg
End Sub
Function num_data_sets() As Integer
Dim objFileSystem As Scripting.FileSystemObject
Dim objFolder As Scripting.Folder
Dim objFile As Scripting.File

Set objFileSystem = New Scripting.FileSystemObject

cnt = 0
tks = Split(Project.Name,".")
pth = Project.Path & "DATA_SETS\" & tks(0) & "\"
Debug.Print pth
Set objFolder = objFileSystem.GetFolder(pth)
For Each objFile In objFolder.Files
Debug.Print objFile.Name
If InStr(objFile.Name,".dsf") Then
cnt = cnt +1
End If
Next objFile
num_data_sets=cnt

End Function

The following script created two Data Sets and pins the old Data Sets:

Private Sub Project_Open()

Dim emdoc As EMStructure


Dim sch As Schematic
Dim ele As Element

API Scripting Guide 1255


DataSets

Dim dsetfs As DataSetFolders


Dim dset As DataSet

'Modify EM layout and generate 2 data sets


Set emdoc = Project.EMStructures("em2")
Set sch = emdoc.Schematic
For Each ele In sch.Elements
'Debug.Print ele.Name
If ele.Name = "VIA1P.V1" Then
ele.Enabled = True
End If
Next ele
Project.Simulator.Analyze

For Each ele In sch.Elements


'Debug.Print ele.Name
If ele.Name = "VIA1P.V1" Then
ele.Enabled = False
End If
Next ele
Project.Simulator.Analyze

'Pin old ds
Set dsetfs = Project.DataSetFolders
Set dset = dsetfs("em2").DataSets("EM_Sim_DS0")
dset.Pin

End Sub

The following script Imports Data Sets and Updates the Clock:

' Code Module


Sub Main

Dim ds As DataSet
Dim fPath As String

fPath = Project.Path + "EM Structure 1.DS0.dsf"


Set ds = Project.DataSetFolders.Import(fPath)
ds.UpdateClock()

End Sub

The Import command returns a Dataset object (the one that was just imported). For the script to run successfully the
Project and Dataset should be in the same directory.

Seting DataSets Pinned Option


Code similar to the following can be used to make DataSets Pinned:

' Code Module


Sub Main()
Project.Optimizer.MaxIterations = 10

1256 NI AWR Design Environment


DataSets

Project.Optimizer.Type=find_opt_type("Simplex Optimizer")
'Project.Optimizer.StopAtMin=True
Project.Optimizer.Start
End Sub
Function find_opt_type(nm As String) As Integer
Dim typ As Integer

typ = -1
For i = 1 To Project.Optimizer.TypeCount
If nm = Project.Optimizer.TypeName(i) Then
typ = i
End If
Next i
If typ = -1 Then
MsgBox ("could not find optimizer name specified:" & nm)
End If
find_opt_type = typ
End Function

Private Sub Project_OptimizerStopped(Optimizer As MWOffice.Optimizer)


For i = 1 To Project.DataSetFolders(1).DataSets(1).SubDataSets.Count
Debug.Print Project.DataSetFolders(1).DataSets(1).SubDataSets(i).Name
If InStr(Project.DataSetFolders(1).DataSets(1).SubDataSets(i).Name, "Opt1_LIN_AP") Then
Project.DataSetFolders(1).DataSets(1).SubDataSets(i).Pinned=True
End If
Next i
End Sub

Getting the list of names of current data sets in folder


Code similar to the following can be used to get the list of names of current data sets in folder:

' Code Module


Sub Main()
Dim emdoc As EMStructure
Dim sch As Schematic
Dim gr As Graph
Dim dfile As DataFile
Dim dsname As String

' Modify Var to generate data sets


Set emdoc = Project.EMStructures("em1")
Set sch = emdoc.Schematic

Set eqn = sch.Equations("L1")

eqn.Expression = "L1 = 50"


Project.Simulator.Analyze
'get active data set at this point.
dsname = get_current_data_set(Project.DataSetFolders(emdoc.Name).Name)

eqn.Expression = "L1 = 100"


Project.Simulator.Analyze

' add measurement on old data set

API Scripting Guide 1257


DataSets

Set gr = Project.Graphs("Older_DS")
gr.Measurements.Add("em1.@"&dsname,"S(1,1)")

' Simulate 1 more time - 1st DS should not auto delete


eqn.Expression = "L1 = 150"
Project.Simulator.Analyze

'Count # of data sets and plot to datafile/graph


cnt = Project.DataSetFolders("em1").DataSets.Count

Set dfile = Project.DataFiles("Dataset_Count")


dfile.DataAsText = "1"+vbTab + Str(cnt)

End Sub
Function get_current_data_set(folder As String) As String
'returns a comma separated list of names of current data sets in folder provided. If no current w
Dim ds As DataSet
Dim ans As String

ans = ""
If Project.DataSetFolders.Exists(folder) = False Then
ans = "no_folder"
Else

For Each ds In Project.DataSetFolders(folder).DataSets


If ds.Current=True Then
If ans = "" Then
ans = ds.Name
Else
ans = ans & "," & ds.Name
End If
End If
Next ds
End If
get_current_data_set = ans
End Function

Importing the EM simulation data sets into a folder


Code similar to the following can be used to Import DataSets results after EM simulation:

' Code Module


Sub Main()
Dim dset As DataSet
Dim dsets As DataSets

Dim fn As String
Dim measn As String

'Simulate, generate 1st data set, and get its path


Project.Simulator.Analyze
Set dsets = Project.DataSetFolders("import_em_sim_ds").DataSets
Set dset = dsets(1)
fn = dset.Filename

1258 NI AWR Design Environment


DataSets

'Import the 1st data set - it should get automatically renamed


Set dset = Project.DataSetFolders.Import(fn)

measn = "import_em_sim_ds.@" & dsets(2).Name


Project.Graphs("Graph 1").Measurements.Add(measn,"S(1,1)")

'import 2nd data set w/diff response - it should get automatically renamed
fn = Project.Path + "import_em_sim_ds.DS0.dsf"
Set dset = Project.DataSetFolders.Import(fn)

measn = "import_em_sim_ds.@" & dsets(3).Name


Project.Graphs("Graph 1").Measurements.Add(measn,"S(1,1)")

To rename current simulation DataSet use the following code:

Dim dsetf As DataSetFolder


Dim dset As DataSet

Set dsetf = Project.DataSetFolders("em1")


Set dset = dsetf.DataSets("EM_Sim_DS2")

dset.Name = "CurrentDS"

How to use "Update All Dependants" for EM DataSets:

' Code Module


Sub Main

Dim emdoc As EMStructure


Dim sch As Schematic
Dim ele As Element

Dim dsetfs As DataSetFolders


Dim dset As DataSet

Dim gr As Graph

'Modify EM layout and generate 2 data sets


Set emdoc = Project.EMStructures("em2")
Set sch = emdoc.Schematic
For Each ele In sch.Elements
'Debug.Print ele.Name
If ele.Name = "VIA1P.V1" Then
ele.Enabled = True
End If
Next ele
Project.Simulator.Analyze

For Each ele In sch.Elements


'Debug.Print ele.Name
If ele.Name = "VIA1P.V1" Then
ele.Enabled = False
End If

API Scripting Guide 1259


DataSets

Next ele
Project.Simulator.Analyze

'Disable "Update All Dependants" and point to old ds


Set dsetfs = Project.DataSetFolders
dsetfs.UpdateDependents=False

Set dset = dsetfs("em2").DataSets("EM_Sim_DS0")


dset.UpdateResults

'Plot Graph data Points To Data File


For Each gr In Project.Graphs
If InStr(gr.Name,"Results") = 0 Then
graph_to_dfile(gr)
End If
Next gr

End Sub
Function graph_to_dfile(gr As Graph)

Dim meas As Measurement


Dim graph_file As String
Dim dfname As String

For Each gr In Project.Graphs


If InStr(gr.Name,"Results") = 0 Then

xcnt = 0
dfname = "df_" + gr.Name

graph_file = Project.Path + gr.Name + ".txt"

'deletes the text file if it exists from before


delete_if_exists(graph_file)

Set meas = gr.Measurements(1)


xcnt = meas.XPointCount
ydim = meas.YDataDim

'Write meas data to data file


Open graph_file For Output As #1
For i = 1 To xcnt
Select Case ydim
Case 1
Print #1, meas.XValue(i) & vbTab & meas.YValue(i,1)
Case 2
Print #1, meas.XValue(i) & vbTab & meas.YValue(i,1) &vbTab & meas.YValue(i,2)
Case Else
Debug.Print "case not found"
End Select
Next i
Close #1

'deletes the data file if it exists from before


If Project.DataFiles.Exists(dfname) Then
Project.DataFiles.Remove(dfname)
End If

1260 NI AWR Design Environment


DataSets

'imports the text file to Data Files


import_text_file(graph_file,dfname)

'deletes the text file after import


delete_if_exists(graph_file)

End If
Next gr
End Function

Working with Yield data sets


Code similar to the following can be used to work with Yield DataSets results:

' Code Module


Sub Main()
Private Sub Project_AfterSimulate()
Debug.Print Project.DataSetFolders(1).DataSets.Count
Project.DataFiles(1).DataAsText = Project.DataFiles(1).DataAsText & vbLf & "2 " & vbTab & Project.
End Sub

Private Sub Project_Open()


' Wait(1)
MWOffice.Project.YieldAnalyzer.NewWindow
Project.YieldAnalyzer.MaxIterations=10
Project.YieldAnalyzer.Type=find_yield_type("Yield Analysis")

Project.YieldAnalyzer.MaxIterations = 6
Project.YieldAnalyzer.Start

End Sub

Function find_yield_type(nm As String) As Integer


Dim typ As Integer

typ = -1
For i = 1 To Project.YieldAnalyzer.TypeCount
If nm = Project.YieldAnalyzer.TypeName(i) Then
typ = i
End If
Next i
If typ = -1 Then
MsgBox ("could not find yield analyzer name specified:" & nm)
End If
find_yield_type = typ
End Function

Private Sub Project_YieldAnalysisStopped(YieldAnalyzer As MWOffice.Optimizer)


Debug.Print Project.DataSetFolders(1).DataSets.Count
Project.DataFiles(1).DataAsText = "1 " & vbTab & Project.DataSetFolders(1).DataSets.Count
End Sub

API Scripting Guide 1261


DataSets

Accessing information provided by the data set dialog for the SimInfo and SimLogInfo
pages.
API has basic access to the information provided by the data set dialog for the SimInfo and SimLogInfo pages. The
information provided in these dialog is just string information extracted from the log so the output values from the API
are just string values.

To access the DataSets Info use the following code:

' Code Module


Sub Main
Dim dsf As DataSetFolder
Dim ds As DataSet

For Each dsf In Project.DataSetFolders


Debug.Print "Folder = " & dsf.Name
For Each ds In dsf.DataSets
Debug.Print "Sim Info:"
Debug.Print ds.SimInfo
Debug.Print "Log Info:"
Debug.Print ds.LogInfo
Next ds
Next dsf
End Sub

Output example:

Folder = EM Structure 1
Sim Info:
Document Name - EM Structure 1
Mesh Freq = 2 GHz
# of Facets = 495
# of Unknowns = 944
# of Nets = 1
# of Ports = 2

As we mentioned before, the information provided in the dialog is just string information extracted from the log. If you
want to extract actual numeric values they will need to be parsed from the API returned string. Simple example parsing
script:

' Code Module


' Attempt to extract numeric value from Sim info, returns -1.0 on failure.

Function GetSimValue(info As String, target As String) As Double


Dim strVal As String
Dim retVal As Double

retVal = -1.0
pos = InStr(1, info, target)
If (pos > 0) Then
pos2 = InStr(pos, info, vbLf)

1262 NI AWR Design Environment


DataSets

If (pos2 > 0) Then


pos = pos + Len(target)
strVal = Mid(info, pos, pos2 - pos - 1)
strVal = LTrim(RTrim(strVal))
retVal = CDbl(strVal)
End If
End If

GetSimValue = retVal

End Function

Accessing properties of the data set as a DataSetProperty set collection.


Getting information from the Sim Info might require parsing the text if you want a specific value where getting the value
from the properties might be easier. For example in one case you can check the Facet Count, Unkown Count etc. that
were included in the properties as well as the sim info. The properties collection is a Name/Value pair type thing so if
the thing you want is there you can use name lookup to get the value. Also properties.Exists("name") can be used with
a name to see if a property exists.

Keep in mind that The DataSet.Properties collection returns a child object of type DataSetProperty rather than type
Property. That should provide the correct type to match the child elements.So youll need to dimension it as:

Dim prop As DataSetProperty

The following code is an example of what was mentioned above:

' Code Module


Sub Main
Dim dsf As DataSetFolder
Dim ds As DataSet
Dim dsp As DataSetProperty
Dim dsp2 As DataSetProperty
Dim bError As Boolean

bError = False
For Each dsf In Project.DataSetFolders
Debug.Print "Folder = " & dsf.Name
For Each ds In dsf.DataSets
For Each dsp In ds.Properties

Set dsp2 = ds.Properties(dsp.Name)


If (dsp2 Is Nothing) Then
Debug.Print "Lookup property " & dsp.Name & " by name failed"
bError = True
End If

If (Not ds.Properties.Exists(dsp.Name)) Then


Debug.Print "Exists property " & dsp.Name & " by name failed"
bError = True
End If
Next dsp

API Scripting Guide 1263


DataSets

'Print some values that should be consistent from run to run.


Debug.Print "NumPorts = " & ds.Properties("NumbPorts").Value
Debug.Print "SimType = " & ds.Properties("SimType").Value
Debug.Print "Facets = " & ds.Properties("Facet Count").Value
Debug.Print "Unknowns = " & ds.Properties("Unknown Count").Value

Next ds
Next dsf

' Print some final status.


If (bError) Then
Debug.Print "Some errors were encountered during property lookups."
Else
Debug.Print "All properties looked up successfully"
End If
End Sub

One more example of using the DataSets Properties in the following code:

' Code Module


Sub Main
Dim ems As EMStructure
Dim simlog, info, target As String
Dim mesh As Integer
Dim ds As DataFile
Dim dset As DataSet
Dim prop As DataSetProperty

Debug.Clear

Set ems = Project.EMStructures("em1")

Set dset = Project.DataSetFolders("em1").DataSets(1)

' Debug.Print dset.Name;vbTab;dset.SimInfo

For Each prop In dset.Properties


Debug.Print prop.Name;vbTab;prop.Value
Next prop
End Sub

Output example:

NumbPorts 2
SimType 7
AWRCorp Version Info 12.0.7408.7
Computer Name MARIYETTA-DT
User Name mdaylis
Operating System Microsoft Windows 7 Business Edition, 64-bit Service Pack 1 (build 7601)
Processor Information architecture:9, level:6, model:60, stepping:3, processors:8
Available Memory (MB) 15.9410705566406

1264 NI AWR Design Environment


DataSets

Clock Speed (GHz) 3.312802


Physical Processors 1
Physical Cores 4
Virtual Cores 8
Total Sim Freqs 0
Reserve Threads 8
Peak Memory Usage (MB) 35.668
Facet Count 5842
Unknown Count 10241
Max SqrtArea Ratio 279.506035940691
Max Aspect Ratio 400.000000001842
Total Simulation Time(s) 1.943937915570091
Meshing Time (s) 0.743937911170061
Dataset Write Time (s) 0.750860449854836

Accessing DataSets Flags


We use api data set property to get flags associated with a data set. This property requires an argument to determine
which flag it is returning the state for:

' Code Module


Sub Main
Dim dsf As DataSetFolder
Dim ds As DataSet
Dim dsp As DataSetProperty
Dim dsp2 As DataSetProperty
Dim bError As Boolean

bError = False
For Each dsf In Project.DataSetFolders
Debug.Print "Folder = " & dsf.Name
For Each ds In dsf.DataSets
For Each dsp In ds.Properties
Debug.Print dsp.Name & " = " & dsp.Value
Next dsp
Next ds
Next dsf
End Sub

The following code is an example of accessing Datasets Flags:

' Code Module


Sub Main
Dim dsf As DataSetFolder
Dim ds As DataSet
Dim dsp As DataSetProperty
Dim dsp2 As DataSetProperty
Dim bError As Boolean

bError = False
For Each dsf In Project.DataSetFolders
Debug.Print "Folder = " & dsf.Name

API Scripting Guide 1265


DataSets

For Each ds In dsf.DataSets


'Print some flags that should be consistent from run to run.
Debug.Print "Is Partial Data Set = " & ds.Flags(mwDSF_IsPartialDataSet)
Debug.Print "For Optimization = " & ds.Flags(mwDSF_ForOptimization)
Debug.Print "For Tuning = " & ds.Flags(mwDSF_ForTuning)
Debug.Print "For Yield = " & ds.Flags(mwDSF_ForYield)
Debug.Print "Incomplete Data Set = " & ds.Flags(mwDSF_IncompleteDataSet)
Debug.Print "Includes 3D Model = " & ds.Flags(mwDSF_IncludesG3DModel)
Debug.Print "Includes Geometry = " & ds.Flags(mwDSF_IncludesGeometry)
Debug.Print "In Memory Data Set = " & ds.Flags(mwDSF_InMemoryDataSet)
Debug.Print "Mesh Only = " & ds.Flags(mwDSF_MeshOnly)
Debug.Print "Disable Auto Delete = " & ds.Flags(mwDSF_DisableAutoDelete)
Next ds
Next dsf

' Print some final status.


If (bError) Then
Debug.Print "Some errors were encountered during property lookups."
Else
Debug.Print "All properties looked up successfully"
End If

Output example:

Folder = EM Structure 1
Is Partial Data Set = False
For Optimization = False
For Tuning = False
For Yield = False
Incomplete Data Set = False
Includes 3D Model = False
Includes Geometry = True
In Memory Data Set = False
Mesh Only = False
Disable Auto Delete = False
All properties looked up successfully

The DataSet.Flags property is a parameterized property which means that it takes an argument to specify which flag the
property should represent. For example the property can be used as follows to check if a data set is partial or complete
using the mwDSF_IsPartialDataSet as an argument for the flags property:

' Code Module


Sub Main
Dim dsf As DataSetFolder
Dim ds As DataSet

Debug.Clear
For Each dsf In Project.DataSetFolders
For Each ds In dsf.DataSets
Debug.Print ds.Name
If (ds.Flags(mwDSF_IsPartialDataSet)) Then
Debug.Print " Partial Data Set"
Else

1266 NI AWR Design Environment


Layout

Debug.Print " Complete Data Set"


End If
Next ds
Next dsf
End Sub

Accessing SubDataSets
We provide a property on the DataSet object for accessing children of the data set as a DataSet collection.

SubDataSets method to the DataSet object allows access to the children of a data set and will list the data sets and then
associated with each the sub data sets for that data set. The structure is now recursive so that if any sub data sets have
children they should be accessible as well. For example in the following code:

' Code Module


Sub Main
Dim ds As DataSet
Dim sds As DataSet

Debug.Clear
Debug.Print Project.DataSetFolders(1).DataSets.Count
For Each ds In Project.DataSetFolders(1).DataSets
Debug.Print ds.Name
Debug.Print ds.Filename
For Each sds In ds.SubDataSets
Debug.Print " " & sds.Name
Debug.Print " " & sds.Filename
Next sds
Next ds
End Sub

The script will list the data sets and then associated with each the sub data sets for that data set. The structure is now
recursive so that if any sub data sets have children they should be accessible as well.

The output will be like the following:


1
Opt3_LIN_AP_DS0
C:\Users\User1\Documents\2014\Jan\18317\DATA_SETS\LPF_lumped\LPF.DS0#4.dsf

Layout
Layout as Another View of the Schematic
Layout View and Schematic View are two different views of the same database. To get reference to a Layout object,
you must first get reference to the Schematic object.

The following example is a simple script demonstrating that the Schematic and Layout have the same name.

' Code Module


Sub Main

API Scripting Guide 1267


Layout

Dim s As Schematic
Dim l As Layout
For Each s In Project.Schematics
Debug.Print "Schematic Name = ";s.Name;vbTab;"Layout Name = ";
s.Layout.Name
Next s
End Sub

This script output may display as follows:

Schematic Name = device_with_vias Layout Name = device_with_vias


Schematic Name = xml cap Layout Name = xml cap
Schematic Name = prematch Layout Name = prematch
Schematic Name = wilinkinson_for_em Layout Name = wilinkinson_for_em
Schematic Name = circuit Layout Name = circuit

Layout Particulars
Drawing Objects

A Layout object consists of Drawing objects. Each Drawing object points back to the Schematic Element it represents
(if one exists), to the cell, which implements it (if one exists), and to the Shapes of which it consists. From the Shapes,
you can find the type of Shape, the Layer, and other Shape information.

The following example shows how to get the Shapes type from the Drawing Object:

' Code Module


Sub Main
Dim l As Layout
Dim d As DrawingObject
Set l = Project.Schematics("Layout EtchFactor").Layout
For Each d In l.DrawingObjects
Dim s As Shape
For Each s In d.Shapes
Select Case s.Type
Case mwST_Rectangle
Debug.Print " Rectangle"
Case mwST_Polygon
Debug.Print " Polygon"
Case mwST_Port
Debug.Print " Port"
Case Else
Debug.Print s.Type
End Select
Next s
Next d
End Sub

This script generates the following example output:

Port
Port
Polygon
Polygon

1268 NI AWR Design Environment


Layout

Port
Port
Port
Polygon
Polygon

The following is the full script that gets the DrawingObject Type string:

' Code Module


Sub Main
Debug.Clear
Dim sch As Schematic
Set sch = Project.Schematics("Schematic 1")

Debug.Print sch.Layout.DrawingObjects.Count
Dim a As Attribute, d As DrawingObject

For Each d In sch.Layout.DrawingObjects


If Not d.Element Is Nothing Then
Debug.Print "Element = " & d.Element.Name;vbTab;d.Visible
Else
Debug.Print "Element = nothing"
End If

Debug.Print "Typebits =" & GetDwgObjTypeString(d)


Debug.Print
Next d
'For Each a In sch.Layout.DrawingObjects(2).Attributes
' Debug.Print a.Name & " " & a.ValueAsString
'Next
End Sub

Public Function GetDwgObjTypeString(d As DrawingObject) As String


Dim tb As Long, ts As String
tb = d.TypeBits

ts = ts & IIf(tb And MWOffice.mwOSF_None,"None ", "")


ts = ts & IIf(tb And MWOffice.mwOSF_Graphics,"Graphics ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_Equation,"Equation ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_Text,"Text ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_CommonElement,"CommonElement ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_Wire,"Wire ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_Annotation,"Annotation ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_iNet,"iNet ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_MovableProbe,"MovableProbe ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_LayCell,"LayCell ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_SubCell,"SubCell ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_ParamFrame,"ParamFrame ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_BySize,"BySize ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_CellPort,"CellPort ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_AreaPin,"AreaPin ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_LayPort,"LayPort ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_ByPositionFixed,"ByPositionFixed ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_BySize2,"BySize2 ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_ArtworkCell,"ArtworkCell ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_EMPort,"EMPort ", "")

API Scripting Guide 1269


Layout

ts = ts & IIf(tb And MWOffice.mwOSF_EMSubCell,"EMSubCell ", "")


ts = ts & IIf(tb And MWOffice.mwOSF_LayModifier,"LayModifier ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_PinObject,"PinObject ", "")
ts = ts & IIf(tb And MWOffice.mwOSF_InstObject,"InstObject ", "")

GetDwgObjTypeString = ts

End Function

API has access to the array attributes added to Artwork cells and disassociated PCell objects. Here is the example of the
code for layout mosaic artwork cell attributes:

Dim lay As Layout


Dim physNet As PhysicalNet

Set lay = Project.Schematics("SCH1").Layout

For Each objDraw In lay.DrawingObjects


If (objDraw.TypeBits = 131072) Then
For Each attr In objDraw.Attributes
Debug.Print attr.Name & " = " & attr.Value
Next attr
End If
Debug.Print
Next objDraw

For the layout mosaic pCell attributes the objDraw.TypeBits = 256

Navigating CellPort Faces Coordinates

If a Project has an EM document with Ports and a Schematic, and the EM document is placed in the Schematic as a
Subcircuit, and you need to know the CellPort Faces coordinates, you can use the following code. This code creates Cells
from the Layout and navigates through the faces coordinates:

Dim cl As CellLibrary
Dim lay As Layout
Dim objDraw As DrawingObject
Dim objShape As Shape
Dim vtx As Vertex
Dim objFace As Face
Dim cel As Cell

Set schem = Project.Schematics("Sch1")


Set lay = schem.Layout
lay.CreateCell("Lib","Cell",mwOIT_AllObjects,True)

pth = Project.Path

Set cl = Project.CellLibraries(1)
For Each cl In Project.CellLibraries
For Each cel In cl.Cells
Debug.Print cl.Name;vbTab;cel.Name
Debug.Clear

1270 NI AWR Design Environment


Layout

Next cel
Next cl

Debug.Print schem.Name

For Each objDraw In cel.EditCell.DrawingObjects


Debug.Print objDraw.InfoText
Debug.Print "BasePosition x = " & objDraw.BasePosition.x & ", y = " & objDraw.BasePosition.y
Debug.Print "RotationAngle = " & objDraw.RotationAngle

For Each objShape In objDraw.Shapes


Debug.Print "Shape Type = " & objShape.Type
Debug.Print "Shape Vertices: "

For Each vtx In objShape.Vertices


Debug.Print "Vertex x = " & vtx.x & ", y = " & vtx.y
Next vtx

For Each objFace In objDraw.Faces


Debug.Print "Port Number";vbTab;objFace.PortNumber
Debug.Print "Face Vertices: "

For Each vtx In objFace.Vertices


Debug.Print "Vertex x = " & vtx.x & ", y = " & vtx.y
Next vtx
Set vtx = objFace.LeftEnd
Debug.Print "Left End Vertex x = " & vtx.x & ", y = " & vtx.y

Set vtx = objFace.RightEnd


Debug.Print "Right End Vertex x = " & vtx.x & "amp;, y = " & vtx.y
Next objFace

Next objShape
Next objDraw

Accessing Element pCells and Searching for Port Connect Type

The following script navigates through all APLAC elements and prints the connect type if the element is a port or a pin.

' Code Module


Sub Main
Dim m As Model
Dim s As Schematic
Dim l As Layout
Dim Dob As DrawingObject
Dim e As Element
Dim sh As Shape
Debug.Clear

'On Error GoTo Problem:

Set s = Project.Schematics(1)
Set l = Project.Schematics(1).Layout

For Each m In MWOffice.Models

API Scripting Guide 1271


Layout

If InStr(m.CategoryPath ,"aplac")=False Then


Set e = s.Elements.Add(m.Name,0,0)
Debug.Print e.Name
'Debug.Print s.Layout.Name
If e.CellName lt; gt; "" Then
l.Refresh
For Each Dob In l.DrawingObjects
For Each sh In Dob.Shapes
'Debug.Print sh.Type
If sh.Type =mwST_Port Or sh.Type=mwST_Pin Then
Debug.Print "Connect Type :"; sh.Attributes("ConnectType").Value
End If
Next sh
Next Dob
End If
s.Elements.RemoveAll
End If
Next m
Exit Sub
End Sub

This script generates the following partial example output:

MTAPER.MT1
Connect Type: 100
Connect Type: 100
MTAPER$.MT1
MTRACE2.X1
Connect Type: 100
Connect Type: 100
PC1LIN.TL1
Connect Type: 100
Connect Type: 100
SIGCMOS.TL1
_MLEFX_T.MO1
ABRIDGE.TL1
MDRSTUB2.ST1
Connect Type: 200
Connect Type: 200
MGAP2.TL1
Connect Type: 0
Connect Type: 0
MGAP2$.TL1
MGAPX.TL1
Connect Type: 0
Connect Type: 0
MGAPX$.TL1
MOPEN.TL1
Connect Type: 0

Printing out gds cell linetype info

The following script navigates through attributes and prints out the connect type info of gds cell.

1272 NI AWR Design Environment


Layout

Option Explicit
Sub Main
Debug.Clear
Dim c As Cell, cl As CellLibrary

Set cl = Project.CellLibraries(1)
Set c= cl.Cells(1)
Dim s As Shape, a As Attribute

For Each s In c.Shapes


Debug.Print s.Attributes.Count & ", " & s.DrawingLayer.Name
For Each a In s.Attributes
Debug.Print vbTab & a.Name & " = " & a.ValueAsString
Next a
Next s
End Sub

This script generates the following example output:

2, Metal1
LayerIndex = 26
Area = 0.000000000276
2, Metal1
LayerIndex = 26
Area = 0.000000000276
2, NiCr
LayerIndex = 27
Area = 0.000000004
2, Default
PortNumber = 1
ConnectType = 7
2, Default
PortNumber = 2
ConnectType = 7

Accessing Outline Points of Paths and Polygon Shapes

The Shape objects have a Vertices collection that includes a PolyVertices collection that provides access to the outline
points of the Paths and other polygon Shapes. This provides a method for API users to easily get the results from
Path-to-Polygon conversions. It also provides a method for getting points to use in overlap and connectivity checking,
as shown in the following script:

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject
Dim objShape As Shape
Dim vtx As Vertex

Debug.Clear

API Scripting Guide 1273


Layout

Set lay = Project.Schematics("Schematic 1").Layout

For Each objDraw In lay.DrawingObjects


For Each objShape In objDraw.Shapes
PrintVertices objShape.Vertices, "Vertexes:"
Debug.Print
PrintVertices objShape.PolyVertices, "PolyVertices:"

Next objShape
Next objDraw
End Sub

Sub PrintVertices(ByRef vt As Vertices, ByRef title As String)


Dim index As Integer
Debug.Print title
index = 1
For Each vtx In vt
Debug.Print "P[" & index & "] = {" & vtx.x * 1e6 & ", " & vtx.y * 1e6 & "}"
index = index + 1
Next vtx
End Sub

This script generates the following output:

Vertexes:
P[1] = {-283, -93}
P[2] = {135, -93}
P[3] = {135, 164}
P[4] = {403, 164}

PolyVertices:
P[1] = {-303, -113}
P[2] = {155, -113}
P[3] = {155, 144}
P[4] = {423, 144}
P[5] = {423, 184}
P[6] = {115, 184}
P[7] = {115, -73}
P[8] = {-303, -73}

Accessing Hierarchical Path Information for Shapes Produced from Drawing Objects

To get all of the drawing primitives ("Shapes") required to reproduce a Layout, you iterate through the Drawing Objects
associated with the Layout, and for each of these, iterate through the Shapes that form them. NI AWR has a method
whereby Shape objects with hierarchy return the hierarchical Path to the Element with the pCell that created the Shape.
The following script prints the hierarchical Path property for Shape Objects produced from PCells. This works for
Subcircuits, and for Subcircuits that are parameterized. API provides a hierarchical path for both PCells and Shapes that
come from a Subcircuit. The Shapes will have the Subcircuit object and vector instance number as the path and for those
there as PCells will have the full path to the PCell object in its parent document and its vector instance number. For
example: Schematic 1:SUBCKT.S2,0/EM Structure 1 (AXIEM - Async):MLIN.TL1,0 Schematic 1:SUBCKT.S2,0
indicates that SUBCKT.S2 has two shapes one that is a dump shape that comes directly from the Subcircuit and one that
is provided from a PCell MLIN.TL1 inside the EM Structure 1 document. Dumb shapes down in subcircuits will now
provide the path to the subcircuit as their hier path:

1274 NI AWR Design Environment


Layout

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject
Dim shp As Shape

Debug.Clear
Set lay = Project.Schematics("top").Layout
For Each objDraw In lay.DrawingObjects
For Each shp In objDraw.Shapes
If (shp.Type ne 6) Then
Debug.Print "Shape, Type = " & shp.Type & ", Path = " & shp.HierarchicalPath
End If
Next shp
Next objDraw

End Sub

This script generates the following output:

Shape, Type = 1, Path = top:MLIN.TL1,0


Shape, Type = 1, Path = top:MLIN.TL1,0
Shape, Type = 1, Path = top:MLIN.TL1,0
Shape, Type = 1, Path =
Shape, Type = 1, Path =
Shape, Type = 1, Path = top:SUBCKT.S1,0/middle:SUBCKT.S1,0/bottom:MLIN.TL1,0
Shape, Type = 1, Path = top:SUBCKT.S1,0/middle:SUBCKT.S1,0/bottom:MLIN.TL2,0

API offers access two methods for getting the hierarchical path from pCell derived shapes from drawing objects. In the
first method paths are accessible when the shapes come from a drawing object directly and in the second method
hierarchical path are accessible from a layout snap shot:

Dim lay As Layout


Dim snap As Snapshot
Dim objDraw As DrawingObject
Dim shp As Shape

Debug.Clear
Set lay = Project.Schematics("top").Layout
Set snap = lay.CreateSnapshot

For Each shp In snap.Shapes


If (shp.Type ne 6) Then
Debug.Print "Shape, Type = " & shp.Type & ", Path = " & shp.HierarchicalPath
End If
Next shp

Changing EndType for a Path

Because a Drawing object may consist of several shapes that you cannot individually modify, changes are not allowed
to affect the original object. For example, a Path on the Plated Metal line type may consist of three different paths with

API Scripting Guide 1275


Layout

different widths drawn over each other. The system does not allow you to edit the three paths individually, but you can
edit the overall Path object. Many of the same attributes are available at the DrawingObject level, so you can modify
them there and they affect the original object.

The following script changes the attributes at the DrawingObject. The values for the Path and the Path box change when
these attributes change:

' Code Module


Sub Main
Dim sch As Schematic
Dim lay As Layout
Dim dro As DrawingObject
Dim op As Option
Dim prop As Property
Dim par As Parameter
Dim el As Element
Dim sh As Shape
Dim atr As Attribute
Debug.Clear

Set sch = Project.Schematics(1)


Set lay = sch.Layout

For Each dro In lay.DrawingObjects


For Each atr In dro.Attributes
If atr.Name = "PathEndType" Then
Debug.Print dro.TypeBits;vbTab;atr.Value;vbTab;atr.ValueAsString
End If
Next atr
Next dro

lay.Refresh
Debug.Print "TopRight Corner: ("; Project.Schematics(1).Layout.Boundary.Right; ",";Project.Schemat
Debug.Print "BottomLeft Corner: ("; Project.Schematics(1).Layout.Boundary.Left; ",";Project.Schema

For Each dro In lay.DrawingObjects


For Each atr In dro.Attributes
If atr.Name = "PathEndType" Then
Debug.Print dro.TypeBits;vbTab;atr.Value;vbTab;atr.ValueAsString
atr.Value = mwPET_Flush
Debug.Print dro.TypeBits;vbTab;atr.Value;vbTab;atr.ValueAsString
End If

Next atr
Next dro

lay.Refresh

Debug.Print "TopRight Corner: ("; Project.Schematics(1).Layout.Boundary.Right; ",";Project.Schemat


Debug.Print "BottomLeft Corner: ("; Project.Schematics(1).Layout.Boundary.Left; ",";Project.Schema

For Each dro In lay.DrawingObjects


For Each atr In dro.Attributes
If atr.Name = "PathEndType" Then
Debug.Print dro.TypeBits;vbTab;atr.Value;vbTab;atr.ValueAsString
atr.Value = mwPET_ExtendedHalfWidth

1276 NI AWR Design Environment


Layout

Debug.Print dro.TypeBits;vbTab;atr.Value;vbTab;atr.ValueAsString
End If
Next atr
Next dro

lay.Refresh

Debug.Print "TopRight Corner: ("; Project.Schematics(1).Layout.Boundary.Right; ",";Project.Schemat


Debug.Print "BottomLeft Corner: ("; Project.Schematics(1).Layout.Boundary.Left; ",";Project.Schema

End Sub

Accessing PathWriter interface

PathWriter interface added to provide an efficient means for adding large numbers of paths associated with PCB data.
We use a method to create a record object from DrawingObjects collection and then a method for creating the path with
that record object.

The following script is adding multiple paths using the PathWriter and PathRecord interfaces:

' Code Module


Sub Main
Dim lay As Layout
Dim ret As Variant
Dim objDraw As DrawingObject

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If

lay.Activate

PrintDrawObjectsState lay, "*** Before adding paths ***"

AddPaths(lay)

PrintDrawObjectsState lay, "*** After adding paths ***"

End Sub

Sub AddPaths(ByRef lay As Layout)


Dim pathWrite As PathWriter
Dim pathRec As PathRecord
Dim xPos As Double
Dim yPos As Double

Set pathWrite = lay.DrawingObjects.PathWriter


pathWrite.LayerName = "Thick Metal"
pathWrite.EndType = mwPET_Rounded
pathWrite.MiterStyle = mwPMT_Square
pathWrite.Width = 20e-6

API Scripting Guide 1277


Layout

Set pathRec = pathWrite.CreatePathRecord


xPos = 0
yPos = 0
For i = 1 To 5
xPos = xPos + 200e-6
yPos = 0
For j = 0 To 5
yPos = yPos + 200e-6
AddPathPoints pathRec, xPos, yPos
pathWrite.AddPath(pathRec)
pathRec.Clear
Next j
Next i

End Sub

Sub AddPathPoints(ByRef pathRec As PathRecord, xPos As Double, yPos As Double)


Dim x As Double
Dim y As Double
x = xPos
y = yPos

pathRec.PathBegin(x, y)
x = x + 100e-6
pathRec.AddSegment(x, y)
y = y + 100e-6
pathRec.AddSegment(x, y)
x = x + 100e-6
pathRec.AddSegment(x, y)
pathRec.PathEnd

End Sub

Sub PrintDrawObjectsState(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject

Debug.Print title

' Dump the results.


Debug.Print "Layout = " & lay.Name
Debug.Print "DrawingObjects Count = " & lay.DrawingObjects.Count
For Each objDraw In lay.DrawingObjects
PrintDrawingObject objDraw
Debug.Print ""
Next objDraw
Debug.Print ""

End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " & drawingObj.InfoText
Debug.Print "Selected = " & drawingObj.Selected
Debug.Print "Flipped = " & drawingObj.Flipped
Debug.Print "Rotation = " & drawingObj.RotationAngle
Debug.Print "Frozen = " & drawingObj.Frozen
Debug.Print "Base Pos = { x = " & drawingObj.BasePosition.x * 1e6 & ", y = " & drawingObj.BasePos

1278 NI AWR Design Environment


Layout

Debug.Print "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)
PrintSubObjectsState(drawingObj.SubObjects)

End Sub

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Debug.Print "Parameters:"
For Each param In params
Debug.Print param.Name & " = " & param.ValueAsString
Next param

End Sub

See text of PrintXXX subroutines in previuos examples.

Creating the standalone route objects without the associated physical nets

In some cases where we want path objects which support different line types, different widths, or curved bends and one
solution for this has been to allow them to create iNet Route objects which are stand-alone and don't have to be associated
with a physical net. We've supported this in EM, because in general there often isn't a logical schematic to form the
electrical and physical nets there but iNet routes can be useful. For certain cases we've also added support in the normal
layout editor for drawing iNet route objects that can be standalone.

The following script shows an API method for adding standalone route objects to layout via the drawing objects collection.
The code fills out a route record and then adds a route with 5 segments and two vias to the layout:

' Code Module


Sub Main
Dim lay As Layout
Dim physNet As PhysicalNet

Set lay = Project.Schematics("SCH1").Layout

PrintDrawObjectsState lay, "Before Adding Route Object"

AddRouteObject(lay)

PrintDrawObjectsState lay, "After Adding Route Object"

End Sub

Sub AddRouteObject(ByRef lay As Layout)


Dim rtRec As RouteRecord
Dim w As Double
Dim x1 As Double
Dim y1 As Double
Dim x2 As Double

API Scripting Guide 1279


Layout

Dim y2 As Double
Dim lt As Integer

Set rtRec = lay.DrawingObjects.CreateRouteRecord


w = 20e-6
x1 = 0
y1 = 0
x2 = 100e-6
y2 = 0
lt = 0

rtRec.AddSegment(x1, y1, x2, y2, w, lt, mwEST_TruncateEndStyle, 0, mwEST_ExtendedEndStyle, w/2)

x1 = x2
y1 = y2
y2 = y2 + 100e-6

rtRec.AddSegment(x1, y1, x2, y2, w, lt, mwEST_ExtendedEndStyle, w/2, mwEST_ExtendedEndStyle, w/2)

x1 = x2
y1 = y2
x2 = x2 + 100e-6
lt = 2

rtRec.AddSegment(x1, y1, x2, y2, w, lt, mwEST_ExtendedEndStyle, w/2, mwEST_ExtendedEndStyle, w/2)

rtRec.AddVia(x1, y1, w/2, w/2, 0, 0, 0, 2, mwVDT_Layer1ToLayer2ViaDirection)


rtRec.AddVia(x2, y2, w/2, w/2, 0, 0, 0, 2, mwVDT_Layer1ToLayer2ViaDirection)

x1 = x2
y1 = y2
y2 = y2 - 100e-6
lt = 0

rtRec.AddSegment(x1, y1, x2, y2, w, lt, mwEST_ExtendedEndStyle, w/2, mwEST_ExtendedEndStyle, w/2)

x1 = x2
y1 = y2
x2 = x2 + 100e-6

rtRec.AddSegment(x1, y1, x2, y2, w, lt, mwEST_ExtendedEndStyle, w/2, mwEST_TruncateEndStyle, 0)

lay.DrawingObjects.AddRoute(rtRec)

End Sub

Sub RouteFlightLine(ByRef fltLine As FlightLine, ByRef physNet As PhysicalNet)


Dim x1 As Double
Dim y1 As Double
Dim x2 As Double
Dim y2 As Double
Dim xMid As Double
Dim rtRec As RouteRecord
Dim w As Double

x1 = fltLine.Begin.x
y1 = fltLine.Begin.y

1280 NI AWR Design Environment


Layout

x2 = fltLine.End.x
y2 = fltLine.End.y

xMid = (x1 + x2) / 2.0

Set rtRec = physNet.Routes.CreateRouteRecord

w = 20e-6
rtRec.AddSegment(x1, y1, xMid, y1, w, 0, mwEST_TruncateEndStyle, 0, mwEST_ExtendedEndStyle, w/2)
rtRec.AddSegment(xMid, y1, xMid, y2, w, 2, mwEST_ExtendedEndStyle, w/2, mwEST_ExtendedEndStyle, w/
rtRec.AddSegment(xMid, y2, x2, y2, w, 0, mwEST_ExtendedEndStyle, w/2, mwEST_TruncateEndStyle, 0)

physNet.Routes.AddRoute(rtRec)

End Sub

Sub PrintDrawObjectsState(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject

Debug.Print title

' Dump the results of a file for comparison.


Debug.Print "Layout = " & lay.Name
Debug.Print "DrawingObjects Count = " & lay.DrawingObjects.Count
For Each objDraw In lay.DrawingObjects
PrintDrawingObject objDraw
Debug.Print ""
Next objDraw
Debug.Print ""

End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " & drawingObj.InfoText
Debug.Print "Selected = " & drawingObj.Selected
Debug.Print "Flipped = " & drawingObj.Flipped
Debug.Print "Rotation = " & drawingObj.RotationAngle
Debug.Print "Frozen = " & drawingObj.Frozen
Debug.Print "Base Pos = { x = " & drawingObj.BasePosition.x * 1e6 & ", y = " & drawingObj.BasePo
Debug.Print "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)

End Sub

See text of PrintXXX subroutines in previuos examples.

The following is the example of output from the script (partial):

Physical Net Count = 2


Physical Net = ELENET2.EN1

API Scripting Guide 1281


Layout

Route Count = 1
Associated = True
Bend Style = 0
Boundary = Left = -0.00014, Top = 0.000095, Right = -0.000036, Bottom = 0.000016
Continuous = True
Custom Seg Ends = False
Global = False
Length = 0.000222
Miter Amount = 1
Miter Amount Abs = False
NetId = 3
Selected = False
Status = 0
Topology = 0
Via Cell Name = MMICROUTEVIA*

Segment Count = 5
Segments:
Begin Point = { x = -0.00014, y = 0.000026 }
Begin Point = { x = -0.00011, y = 0.000026 }
Begin Extent = 0.00001
End Extent = 0.00001
Begin Style = 0
End Style = 1
Begin Offset Style = 2
End Offset Style = 0
Line Type = 0
Selected = False
Width = 0.00002
Shape Count = 1
Segment Shapes:
Shape Type = 1
Drawing Layer = 12
----------
Begin Point = { x = -0.00011, y = 0.000026 }
Begin Point = { x = -0.00011, y = 0.000085 }
Begin Extent = 0.00001
End Extent = 0.00001
Begin Style = 1
End Style = 1
Begin Offset Style = 0
End Offset Style = 0
Line Type = 0
Selected = False
Width = 0.00002
Shape Count = 1
Segment Shapes:
Shape Type = 1
Drawing Layer = 12
----------

Accessing Outline Points of Poly Line Shapes

This script uses the DrawingObject.Shape.Vertices method to get the list of vertices through the API:

1282 NI AWR Design Environment


Layout

' Code Module


Sub Main
Dim ob As DrawingObject
Dim sh As Shape
Dim vert As Vertex

Debug.Clear
Set ob = Project.Schematics(1).Layout.DrawingObjects(1)
Set sh = ob.Shapes(1)
For Each vert In sh.Vertices
Debug.Print vert.x*1e6;",";vert.y*1e6
Next vert
End Sub

The list obtained this way, shown below:

(0,0)
(10,0)
(10,5)

Drawing Shapes on Layout

To draw an Arc, use the following code:

' Get the schematic and layout for that schematic.


Set schem = Project.Schematics("test_layout")
Set lay = schem.Layout
lay.DrawingObjects.AddArc(1e-6,1e-6,2e-6,145,290,"Mesa")

To draw a Dimension Line, use the following code:

lay.DrawingObjects.AddDimensionLine(1e-6,1e-6,20e-6,1e-6,25e-6,1e-6,2e-6,mwDTL_CenterPar,mwDAL_Out

To draw a Drill Hole, use the following code:

lay.DrawingObjects.AddDrillHole(1e-6,1e-6,"Default")

To draw an Ellipse, use the following code:

lay.DrawingObjects.AddEllipse(1e-6,1e-6,10e-6,6e-6,"Mesa")

To draw a Path, use the following code:

Dim pnts(7) As Double


pnts(0) = 200e-6
pnts(1) = 200e-6
pnts(2) = 350e-6
pnts(3) = 200e-6
pnts(4) = 350e-6

API Scripting Guide 1283


Layout

pnts(5) = 300e-6
pnts(6) = 450e-6
pnts(7) = 250e-6
lay.DrawingObjects.AddPath(pnts,10e-6,mwPET_ExtendedHalfWidth,mwPMT_Square,1e-6,"Mesa",False)

To draw a Polygon, use the following code:

' Add a polygon


Dim pnts(7) As Double
pnts(0) = 200e-6
pnts(1) = 200e-6
pnts(2) = 350e-6
pnts(3) = 200e-6
pnts(4) = 300e-6
pnts(5) = 300e-6
pnts(6) = 200e-6
pnts(7) = 300e-6
lay.DrawingObjects.AddPolygon(pnts,"Mesa")

To draw a Rectangle, use the following code:

lay.DrawingObjects.AddRectangle(1e-6,1e-6,5e-6,5e-6,"Mesa")

To draw a Ruler, use the following code:

lay.DrawingObjects.AddLayoutRuler(0,1e-6,100e-6,1e-6,1e-6,15e-6,mwLRT_AboveRuler,1,3e-5,False,"Ari

To enter Text, use the following code:

lay.DrawingObjects.AddText(1e-6,1e-6,3e-6,"Text",0,False,"",False,False,True,"Mesa")

The following is a more complex example of adding shapes contained artwork cell and overlapped by a region or shape
like in the following picture:

1284 NI AWR Design Environment


Layout

Dim lay As Layout


Dim objDraw As DrawingObject
Dim capBottom As Integer

capBottom = 7

Set lay = Project.Schematics("SCH1").Layout


lay.SelectedObjects.RemoveAll

Debug.Print "Drawing Object Count = " & lay.DrawingObjects.Count

Debug.Print "Selected Count Before Select Overlapped = " & lay.SelectedObjects.Count


For Each objDraw In lay.DrawingObjects
If objDraw.Attributes.Exists("LayerIndex") Then
If objDraw.Attributes("LayerIndex").Value = capBottom Then
lay.SelectedObjects.AddOverlapped(objDraw.Shapes(1),mwAAT_ContainedObjects)
End If
End If
Next objDraw
Debug.Print "Selected Count After Select Overlapped = " & lay.SelectedObjects.Count

The script shows API support for selecting objects in a region defined by a polygon of xy points and by referencing
another shape to define the region.

The following is an example of adding text to Layout:

' Code Module


Sub Main
Dim schName() As String
'begin user dialog box to chose which schematic layout add to
NumSch = Project.Schematics.Count
ReDim schName(NumSch)
For i = 1 To NumSch
schName(i) = Project.Schematics(i).Name
Next i
Begin Dialog UserDialog 400,161,"Select Schematic For Layout " ' %GRID:10,7,1,1
ListBox 40,35,310,63,schName(),.lstSchBox,1
Text 40,21,160,14,"Select Schematic",.Text1
OKButton 150,119,100,28
End Dialog
Dim dlg As UserDialog
Dialog dlg
SchIndex = dlg.lstSchBox
SchIndex = SchIndex + 1
'end dialog box section
horiz = Array("1","2","3","4")
vert = Array("A","B","C","D")
deltax= 1e-3 'in meters
deltay = 5e-4 'in meters
num_x = UBound(horiz)
num_y = UBound(vert)
For i = 0 To num_x
For j = 0 To num_y
Text = Array(horiz(i),vert(j))
text2 = Join(Text)

API Scripting Guide 1285


Layout

Project.Schematics(SchIndex).Layout.DrawingObjects.AddText(i*deltax, j*deltay,1e-4,text2,)
Next j
Next i
End Sub

The following script shows Label Text Alignment in Layout:

' Code Module


Sub Main
Dim s As Schematic
Dim l As Layout
Set s = Project.Schematics.Add("New")
Set l = s.Layout
l.DrawingObjects.AddTextEx(-8e-6,-8e-6,0.4e-6,"Test_CC",True,"Thick Metal Line",mwTAl_CenterCenter
l.DrawingObjects.AddTextEx(-8e-6,-8e-6,0.4e-6,"Test_CL",True,"Thick Metal Line",mwTAl_CenterLeft)
l.DrawingObjects.AddTextEx(-8e-6,-8e-6,0.4e-6,"Test_CR",True,"Thick Metal Line",mwTAl_CenterRight)
l.DrawingObjects.AddTextEx(-8e-6,-8e-6,0.4e-6,"Test_TC",True,"Thick Metal Line",mwTAl_TopCenter)
l.DrawingObjects.AddTextEx(-8e-6,-8e-6,0.4e-6,"Test_TL",True,"Thick Metal Line",mwTAl_TopLeft)
l.DrawingObjects.AddTextEx(-8e-6,-8e-6,0.4e-6,"Test_TR",True,"Thick Metal Line",mwTAl_TopRight)
l.DrawingObjects.AddTextEx(-8e-6,-8e-6,0.4e-6,"Test_BL",True,"Thick Metal Line",mwTAl_BottomLeft)
End Sub

The Alignment option might be the opposite of what you expect - it is the location of the origin relative to where the text
draws. So for the 'BottomLeft' option, the text actually draws to the upper right of the origin. This may seem unusual,
but when you test NI AWR's exported GDS in another viewer, it draws the same way.

To access a name returned for the Layer of the Drawing object, use the following script:

' Code Module


Sub Main
Debug.Clear
Debug.Print Project.Schematics("MIC_LPF").Layout.DrawingObjects(1).Shapes(1).DrawingLayer.Number
Debug.Print Project.Schematics("MIC_LPF").Layout.DrawingObjects(1).Shapes(1).DrawingLayer.Name
End Sub

To change a Shapes drawing layer, previously we had to use the following code:

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject
Dim attr As Attribute
Set lay = Project.Schematics("MySchematic").Layout
For Each objDraw In lay.DrawingObjects
For Each attr In objDraw.Attributes
Debug.Print attr.Name & " = " & attr.Value
Next attr
objDraw.Attributes("LayerIndex").Value = 6
Next objDraw
End Sub

The most complicated part of this code is determining the layer index from the Name:

1286 NI AWR Design Environment


Layout

' Code Module


Option Explicit
Sub Main
Dim index As Integer
Dim lay As Layout

Set lay = Project.Schematics("s").Layout


index = Project.ProcessDefinitions(lay.ProcessDefinition).LayerSetup.DrawingLayers("Mesa").Number
lay.DrawingObjects(1).Attributes("LayerIndex").Value = index
lay.Refresh
End Sub

Now we support getting and setting the drawing layer for shapes via the attributes directly using the layer name. With
this support the same thing can be performed as following:

' Code Module


Option Explicit
Sub Main
Dim lay As Layout
Set lay = Project.Schematics("s").Layout
lay.DrawingObjects(1).Attributes("LayerName").Value = "Mesa"
lay.Refresh
End Sub

This removes the complicated step of looking up the layer index and allows the layer name to be used directly via layer
name attribute.

API has access to the description field of the drawing layers. These provide read/write property on the drawing layer
object in the API so that values can be set and retrieved for each drawing layer object. A string field to the drawing layer
information structure can be used for extended descriptions of the purpose of the layer.

To access Polyline shapes from a Drawing object, use the following code:

' Code Module


Sub Main
Dim ob As DrawingObject
Dim sh As Shape
Dim vert As Vertex

Debug.Clear
Set ob = Project.Schematics(1).Layout.DrawingObjects(1)
Set sh = ob.Shapes(1)
For Each vert In sh.Vertices
Debug.Print vert.x*1e6;",";vert.y*1e6
Next vert
End Sub

To access cell parameters, use the following code:

Dim e As Element
Set e = Project.Schematics(2).Elements(1)

API Scripting Guide 1287


Layout

Dim lp As Layoutparameter
Set lp = e.DrawingObjects(1).parameters(1)
Debug.Print lp.Name

The following example script determines what kind of DrawingObject by type bits:

' Code Module


Sub Main
Debug.Clear

Dim dr As DrawingObject

For Each dr In Project.Schematics(1).Layout.DrawingObjects


Debug.Print dr.InfoText + vbTab + CStr(dr.TypeBits)
Next dr

End Sub

This script generates the following output:

Element: MLIN.TL1, Cell: MLIN, X=0.08468, Y=2.05349, Angle=0, Flipped=false 256


Element: LOAD.Z1, Cell: "myCell", Library: "myLib", X=0, Y=-0.32105, Angle=0, Flipped=false 131072
Element: PORT.P1, Cell: RECT_PIN_PCB*, X=0.29638, Y=1.16435, Angle=0, Flipped=false 256
Element: PORT.P2, Cell: RECT_PIN_PCB*, X=2.32869, Y=1.16435, Angle=0, Flipped=false 256
Cell: "myCell", Library: "myLib", X=3.26849, Y=-0.33697, Angle=0, Flipped=false 131072
Route: NetID=EN1, Status=Complete, Net Number=4, L=2.03231, Segments=1, Vias=0, Guides=0 64
W=0.9, H=0.5 A=0.45 mm^2 [Error] 4
W=1.97606, H=1.04115 A=1.608 mm^2 [Error] 1
W=0.9, H=0.5 A=0.45 mm^2 [Error] 4
W=0.81957 H=0.82462 A=0.675834 mm^2 [Error]

The following types are returned from the type bits:

// Subset of select filters for layout objects.


enum mwLayoutObjectSelectFilters {
mwLSF_None = mwOSF_None,
mwLSF_Graphics = mwOSF_Graphics,
mwLSF_Text = mwOSF_Text,
mwLSF_iNet = mwOSF_iNet,
mwLSF_LayCell = mwOSF_LayCell,
mwLSF_SubCell = mwOSF_SubCell,
mwLSF_CellPort = mwOSF_CellPort,
mwLSF_AreaPin = mwOSF_AreaPin,
mwLSF_LayPort = mwOSF_LayPort,
mwLSF_ArtworkCell = mwOSF_ArtworkCell
};

These are from a larger set defined by the select filters:

// These values from dragObj/select_filter.h


enum mwObjectSelectFilters {
mwOSF_None = 0x0,

1288 NI AWR Design Environment


Layout

mwOSF_Graphics = 0x1,
mwOSF_Equation = 0x2,
mwOSF_Text = 0x4,
mwOSF_CommonElement = 0x8,
mwOSF_Wire = 0x10,
mwOSF_Annotation = 0x20,
mwOSF_iNet = 0x40,
mwOSF_MovableProbe = 0x80,
mwOSF_LayCell = 0x100,
mwOSF_SubCell = 0x200,
mwOSF_ParamFrame = 0x400,
mwOSF_BySize = 0x800,
mwOSF_CellPort = 0x1000,
mwOSF_AreaPin = 0x2000,
mwOSF_LayPort = 0x4000,
mwOSF_ByPositionFixed = 0x8000,
mwOSF_BySize2 = 0x10000,
mwOSF_ArtworkCell = 0x20000,
mwOSF_PinObject = mwOSF_CellPort | mwOSF_LayPort | mwOSF_AreaPin,
mwOSF_InstObject = mwOSF_LayCell | mwOSF_SubCell
};

The following example script defines the base position of the Drawing object:

' Code Module


Sub Main
' Select the object in the layout before running the script!!!
Dim p As Project
Dim s As Schematic
Dim sCol As Schematics
Dim l As Layout
Dim d As DrawingObject
Dim w As Window
Dim wlayout As Window
Dim b As Boolean
Dim vtx As Vertex
Debug.Clear
Set p = MWOffice.Project
' Looking for active window
For Each w In MWOffice.Windows
Debug.Print "window Caption : ";w.Caption
If w.Active=True Then
Set wlayout = w
End If
Next w
'Exit if no active window
If wlayout Is Nothing Then
Exit Sub
End If
'Exit if window is not a layout window
Dim Str As String
Dim s2 As String
Str = wlayout.Caption
Debug.Print "window Layout Caption : ";Str i = InStr(1,Str," ")
Debug.Print i
s2 = Left$(Str,i-1)

API Scripting Guide 1289


Layout

Debug.Print Left$(Str,i-1)
Debug.Print s2
Set sCol = p.Schematics
Set s = sCol.ActiveSchematic
Debug.Print "schematic Name : ;s.Name
Set l = s.Layout
Debug.Print "layout Name : ";l.Name
Dim x As Double
Dim y As Double
For Each d In l.DrawingObjects
If d.Selected Then
Debug.Print d.Flipped
Set vtx = d.BasePosition
x = vtx.x
y = vtx.y
d.Flipped = Not d.Flipped
d.RotationAngle = d.RotationAngle + 180.0
Debug.Print d.BasePosition.x;",";d.BasePosition.y
d.BasePosition.x = x
d.BasePosition.y = y
Debug.Print "drawing object Base Position. x = ";d.BasePosition.x;",";"drawing object Base Posit
End If
Next d
s.Activate
wlayout.Activate
End Sub

NOTE: Drawing objects x, y argument values can depend on what methods you use. For example, if you use Copy and
Paste in the API it should function the same as the Copy and Paste commands from the UI, where the x and y values are
the absolute x and y values where you want to place the Copy of the object. This is consistent with the Paste command,
which also takes x and y values where you want to paste the Shapes. The easiest way to do a relative offset is to get the
base position of the Shape you are copying and offset relative to that base position to get an absolute x and y value. The
values you give for x and y are the new base position for the copied object. The following script is an example of
performing the copy using absolute rather than relative coordinate values. The script moves each of the Shapes relative
to their location.

The script moves all Shapes to x=5um, y=0um. All Shapes have the same base position after the Copy.

' Code Module


Sub Main
Dim i As Integer
Dim objDraw As DrawingObject
For i = 1 To Project.Schematics(1).Layout.SelectedObjects.Count
Set objDraw = Project.Schematics(1).Layout.SelectedObjects(i)
objDraw.Copy(objDraw.BasePosition.x + 5e-6, objDraw.BasePosition.y)
Next i
Project.Schematics(1).Layout.Refresh
End Sub

In the previous script, the SelectedObjects property is used.

The Layout object has a SelectedObjects property that returns a collection of the DrawingObject(s) selected in Layout.
Enumerating this collection allows you to traverse just the objects in the select list of the document. The drawing objects
are contained in an ISelectedDrawingObjects collection that provides methods for Adding Drawing objects to the selected
collection, Removing an object from the selected collection, or Removing all objects from the selected collection.

1290 NI AWR Design Environment


Layout

The following script moves all cells so that they fit the bottom-right of the layout to (0,0):

Sub Main

Debug.Clear

SC = Project.Schematics.Count

For i=1 To SC
SN = Project.Schematics(i).Name
BL = Project.Schematics(i).Layout.Boundary.Left
BB = Project.Schematics(i).Layout.Boundary.Bottom

DC = Project.Schematics(i).Layout.DrawingObjects.Count

For l=1 To DC
Fcheck = Project.Schematics(i).Layout.DrawingObjects(l).Frozen
If Fcheck = True Then
Project.Schematics(i).Layout.DrawingObjects(l).Frozen = False
Project.Schematics(i).Layout.DrawingObjects(l).Move (-BL,-BB)
Project.Schematics(i).Layout.DrawingObjects(l).Frozen = True
Else
Project.Schematics(i).Layout.DrawingObjects(l).Move (-BL,-BB)
End If
Next l

Next i

End Sub

The following script moves all Objects in Layout with a different approach:

Dim lay As Layout


Dim objDraw As DrawingObject
Dim objDraws As SelectedDrawingObjects

Project.Schematics(1).Layout.SelectedObjects.AddAll

Set lay = Project.Schematics(1).Layout

Debug.Print lay.SelectedObjects.Count
lay.InvokeCommand("EditorGroup")

Set objDraws = lay.SelectedObjects

For Each objDraw In objDraws


objDraw.Move(1e-4,1e-4)
lay.Refresh
Next objDraw

We improved the argument support in the two point move command so that in addition to the basic move offset operations
we can make angle and flip moves as well. We added a second set of arguments that can be provided with move of two
point move operations. Rather than just dx and dy, the command can take x1, y1, x2, y2, rotCCW, flip which allows x1

API Scripting Guide 1291


Layout

y1 to be used as a reference point for the move operations and for rotation and flip operations on the objects being
moved.We can now pass angle in degrees rather than radians for rotate selected objects call and ensure the command
member data is updated with the values extracted from the arguments.

The following script moves rectangle with delta arguments:

Set lay = Project.Schematics("SCH1").Layout

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If
lay.Activate

lay.SelectedObjects.AddAll
lay.InvokeCommand("EditMove", Array(200e-6, 200e-6))

To move rectangle with flip:

lay.InvokeCommand("EditMove", Array(0, 0, 200e-6, 0, 0, True))

To move rectangle with full arguments:

lay.InvokeCommand("EditMove", Array(0, 0, 200e-6, 0, 0, False))

To move rectangle with rotate 90 degree:

lay.InvokeCommand("EditMove", Array(0, 0, 200e-6, 0, 90, False))

The following code helps to find the position of the mouse pointer in the schematic layout window, when the script is
run (using a hotkey). After that the script could resize/reshape a polygon, and the mouse position would determine which
vertex to modify since we don't have the ability to select vertices in our environment except when using the shape
stretcher. API provides access to cursor position information associated with a view. The values that we return from the
API are rounded the database grid for layout. We also provide access to the hit info structure held by the view for most
design diagrams and graphs. The diagrams give the X and Y location as well as information regarding the state of the
control and shift keys when the information was recorded.

The following script shows an example API access to cursor position in layout window:

' Code Module


Sub Main
Dim lay As Layout
Dim vw As View
Dim firstVw As View
Dim win As Window
Dim count As Integer

Debug.Clear

1292 NI AWR Design Environment


Layout

Set lay = Project.Schematics("Schematic 1").Layout

For Each vw In lay.Views


If (vw.ViewName = "Layout View") Then
count = count + 1
If (count = 1) Then
Set firstVw = vw
End If
End If

Next vw

' If there are no windows open one.


If (count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
Set firstVw = lay.Views(1)
End If

' Bring window to the front if not already there.


lay.Activate

Debug.Print "Position X = " & vw.Cursor.PositionX * 1e6


Debug.Print "Position Y = " & vw.Cursor.PositionY * 1e6
Debug.Print "Control Dn = " & vw.Cursor.ControlKeyDown
Debug.Print "Shift Down = " & vw.Cursor.ShiftKeyDown

End Sub

The script provides the following output:

Position X = 10.5
Position X = 35.23
Control Dn = False
Shift Down = False

The following script shows an example of adding text with font arguments to artwork cells:

' Code Module


Sub Main
Project.CellLibraries(1).Cells(1).Shapes.AddText(0,40e-6,20e-6,"Test text 1","Mesa",0,"Calibri",Tr
Project.CellLibraries(1).Cells(1).Shapes.AddTextEx(0,0,20e-6,"Test text 2",True,"Mesa",mwTAl_Botto
End Sub

In the previous script, the API supports adding Polygon text directly to GDS cells. This method takes the text to be added
and converts it to Polygons, and then adds the resulting polygons to the GDSII. This is necessary because GDSII does
not directly support Polygon text.

The following script shows an example of rotating text on Layout:

' Code Module


'Must define font size, and how the designator place holder text. Place holder must be consist

API Scripting Guide 1293


Layout

'text angles can only be 0,90,180,and 270 so far, and it doesn't handle flipped text.
Sub Main
Debug.Clear
Dim sx As Schematic
Dim DrawObj As DrawingObject
Dim shp As Shape
Dim attr As Attribute
Dim vtx As Vertex
Dim i As Integer
Dim sch() As String
Dim dlayers() As String
Dim des_name() As String
Dim des_cnt() As Integer
'Define some global variables
'fntsize_mil = 4
fntsize_mm = 0.1
'fntsize_m = fntsize_mil*0.0000254
fntsize_m = fntsize_mm*0.001
dtext = "XXXX"
dtextlen = Len(dtext)
'make a list of all Schematic names
schnum= Project.Schematics.Count
ReDim sch(schnum)
For i = 1 To schnum
sch(i) = Project.Schematics(i).Name
Next i
'chose schematic as reference to layout
Begin Dialog UserDialog 400,300 ' %GRID:10,7,1,1
ListBox 60,42,270,200,sch(),.ListBox1
Text 70,21,240,14,"Select Schematic Layout to Generate
Designators",.Text1
OKButton 150,260,100,28
'CancelButton 225,260,100,28
End Dialog
Dim dlg As UserDialog
Dialog dlg
schIndex = dlg.ListBox1 + 1
'make list of all drawinglayers
lyrnum= Project.LayerSetup.DrawingLayers.Count
ReDim dlayers(lyrnum)
For i = 1 To lyrnum
dlayers(i) = Project.LayerSetup.DrawingLayers(i).Name
Next i
'chose drawing layer for designators
Begin Dialog UserDialog 400,300 ' %GRID:10,7,1,1
ListBox 60,42,270,200,dlayers(),.ListBox1
Text 70,21,240,14,"Select Drawing Layer for Designators",.Text1
OKButton 150,260,100,28
'CancelButton 225,260,100,28
End Dialog
Dim dlg1 As UserDialog
Dialog dlg1
dlayerIndex = dlg1.ListBox1 + 1
deslayer = dlayers(dlayerIndex)
'can get units from layout and multiply vertices by multiplier to give proper units
'umult = Project.Units(mwUT_Length).MultValue
'uname = Project.Units(mwUT_Length).UnitString

1294 NI AWR Design Environment


Layout

ReDim des_name(0)
des_name(0) = ""
ReDim des_cnt(0)
des_cnt(0) = 0
c_index = 0
Set sx = Project.Schematics(sch(schIndex))
Debug.Print "Schematic Name = " & sx.Name
For Each DrawObj In sx.Layout.DrawingObjects
Debug.Print " "
For Each shp In DrawObj.Shapes
If shp.Type = mwST_Text Then
'Debug.Print "Shape Type = Text"
txt= shp.Attributes(2)
If Right(txt,dtextlen) =dtext Then
Debug.Print txt
'here need to figure out what kind it is, if not new, update index, if new, and
'below need to be smart with text
'if have CXXX, first one should be C001, not C1
nw = next_val(des_name,txt,des_cnt,dtext)
'don't have a generic way of doing this now, only 0,90,180,270 degrees
angle = Round((DrawObj.RotationAngle)*180/3.1415927)
Debug.Print "Angle ";angle
'0 angle case
If angle >= -45 Then
If angle < 45 Then
y = shp.Boundary.Bottom
Debug.Print "y origin ";yx = shp.Boundary.Left
Debug.Print "x origin ";x
End If
End If
'90 degree angle case
If angle >= 45 Then
If angle < 135 Then
y = shp.Boundary.Bottom
Debug.Print "y origin ";y
x = shp.Boundary.Right
Debug.Print "x origin ";x
End If
End If
'-90 degree angle case
If angle <= -45 Then
If angle > -135 Then
y = shp.Boundary.Top
Debug.Print "y origin ";y
x = shp.Boundary.Left
Debug.Print "x origin ";x
End If
End If
'-180degree angle case
If angle <= -135 Then
y = shp.Boundary.Top
Debug.Print "y origin ";y
x = shp.Boundary.Right
Debug.Print "x origin ";x
End If
If angle >= 135 Then
y = shp.Boundary.Top

API Scripting Guide 1295


Layout

Debug.Print "y origin ";y


x = shp.Boundary.Right
Debug.Print "x origin ";x
End If
'angle = 0
'can't print text at angle other at 90
sx.Layout.DrawingObjects.AddText(x,y,fntsize_m,nw,angle,0,shp.Attributes(3),Fal
End If
End If
Next shp
Next DrawObj
End Sub
Function next_val(ByRef des_name() As String, nme As String, ByRef des_cnt() As Integer, dtext As S
'first see if it is a new value
dtextlen = Len(dtext)
typ = Left(nme,(Len(nme)-dtextlen))
found = 0
For i = 1 To UBound(des_name)
If typ = des_name(i) Then
found = 1
ind = i
End If
Next i
'if new add entries
If found = 0 Then
ReDim Preserve des_name(UBound(des_name)+1)
des_name(UBound(des_name)) = typ
ReDim Preserve des_cnt(UBound(des_cnt)+1)
des_cnt(UBound(des_cnt)) = 1
cnt = 1
desname = typ
Else 'update count of the entries already there
des_cnt(ind) = des_cnt(ind)+1
cnt = des_cnt(ind)
desname = des_name(ind)
End If
zero=""
For i = 1 To dtextlen-1
If cnt < 10^i Then
zero = Join(Array("0",zero),"")
Else
Exit For
End If
Next i
tnew = Join(Array(desname,zero,cnt),"")
next_val = tnew
End Function

The following code example shows access to read text in text layout objects via text string as an attribute. The script
enumerates all Attributes at the drawing object level and shows the text string as one of the options:

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject

1296 NI AWR Design Environment


Layout

Dim attr As Attribute


Set lay = Project.Schematics("Schematic 1").Layout
Debug.Clear
For Each objDraw In lay.DrawingObjects
For Each attr In objDraw.Attributes
Debug.Print attr.Name & " = " & attr.Value
Next attr
Debug.Print ""
Next objDraw

End Sub

The following code example shows direct access to the shape:

Project.Schematics(1).Layout.DrawingObjects(1).Shapes(1).Attributes("TextString").Value

One more script to access layout text attribute:

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject

Set lay = Project.Schematics("Schematic 1").Layout


For Each objDraw In lay.DrawingObjects
If objDraw.Attributes.Exists("TextString") Then
Debug.Print objDraw.Attributes("TextString").Value
End If
Next objDraw
End Sub

In the following script we use CellEditor to access layout text attribute for the library Cell:

' Code Module


Sub Main
Debug.Clear
Debug.Print Project.Schematics("Test").Layout.DrawingObjects.Count
Dim sch As Schematic
Dim tmpnam As String
Dim Dobj As DrawingObject
Dim attr As Attribute
Dim ced As CellEditor

tmpnam = "Tmp_Annotation_Txt_Read"
If Project.CellLibraries.Exists("tmpnam") Then Project.CellLibraries.Remove(tmpnam)
Set sch = Project.Schematics("Test")
Set ced = sch.Layout.CreateCell(tmpnam,tmpnam).EditCell

For Each Dobj In ced.DrawingObjects


' Debug.Print "Drawing obj info text = " & Dobj.InfoText
If(InStr(Dobj.InfoText,"TEXT") > 0)Then

API Scripting Guide 1297


Layout

For Each attr In Dobj.Attributes


' Debug.Print attr.Name;" = ";attr.Value
If(InStr(attr.Name,"TextString"))Then
Debug.Print "Attribute Value = " & attr.ValueAsString
End If
Next attr
End If
Next Dobj
ced.Windows(1).Activate
ced.SaveCell
ced.Windows(1).Close
Project.CellLibraries.Remove(tmpnam)

End Sub

Note: Sometimes it will be easier to use Snapshot instead of CellEditor to access layout text attribute for the library Cell

The following code example shows flipping an object in Layout:

Dim Schem As Schematic


Dim Lay As Layout
Dim objDraw As DrawingObject
Debug.Clear
Set Schem = Project.Schematics("Schematic 1")
Debug.Print Schem.Name
Set Lay = Schem.Layout
Set objDraw = Lay.DrawingObjects(1)
objDraw.Move(0, 0, 0, True, True)

The flipHorz argument tells the Move command whether the flip is to occur about the horizontal axis or the vertical axis.
For a flip to occur, the argument Flip must be "True". The second argument flipHorz can be "True" or "False" depending
on whether the flip is to occur around the horizontal or vertical axis.

Polygon Writer object in the API.

The Polygon Writer and the associated PolygonRecord object are intended to provide an efficient method for creating
complex polygons and importing large amounts of PCB board data into layout. The Writer allows you to setup the shape
attributes such as layer name, layer mapping using process layers up front and then create a number of objects using
those settings. The Record provides an efficient means for specifying the polygon and cutouts specified in the board
data. The Record can be reused by clearing after each polygon to create multiple polygons.

In the following script the polygon Writer will write a simply polygon, so the Record does not include attributes requiring
a complex polygon. The complex polygon object has additional data structures to support cutouts and arc segments, so
each complex polygon object is larger in memory size than a standard polygon. This feature is intended to save memory
in cases where the polygon doesn't require the features of a complex general polygon:

Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject
Dim polyWrite As PolygonWriter
Dim polyRec As PolygonRecord

Debug.Clear

1298 NI AWR Design Environment


Layout

Set lay = Project.Schematics("SCH1").Layout

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If

lay.Activate
Set polyWrite = lay.DrawingObjects.PolygonWriter
polyWrite.LayerName = "Thick Metal"

Set polyRec = polyWrite.CreatePolygonRecord

' Add Outer Polygon


polyRec.PolygonBegin(0, 0)
polyRec.AddPolySegment(100e-6, 0)
polyRec.AddPolySegment(100e-6, 100e-6)
polyRec.AddPolySegment(0, 100e-6)
polyRec.PolygonEnd

polyWrite.AddPolygon(polyRec)

End Sub

To add a cutout to the plain polygon use InvokeCommand() method as in the following code:

Set objDraw = lay.DrawingObjects(1)


objDraw.Selected = True
lay.InvokeCommand("ShapeAddCircleCutout", Array(30e-6, 30e-6, 40e-6, 30e-6))

The following script provides an example of using the polygon writer to add a complex polygon with cutouts:

Sub Main
Dim lay As Layout
Dim polyWrite As PolygonWriter
Dim polyRec As PolygonRecord

Set lay = Project.Schematics("Schematic 1").Layout


Set polyWrite = lay.DrawingObjects.PolygonWriter
polyWrite.LayerName = "Thick Metal"
lay.DrawingObjects.ActiveNetName = "MyNetName"

Set polyRec = polyWrite.CreatePolygonRecord

' Add Outer Polygon


polyRec.PolygonBegin(0, 0)
polyRec.AddPolySegment(100e-6, 0)
polyRec.AddPolyArcSegment(100e-6, 100e-6, 50e-6, 50e-6, mwDAD_CounterClockwise)
polyRec.AddPolySegment(0, 100e-6)
polyRec.PolygonEnd

' Add Rectangle polygon cutout.


polyRec.PolyCutoutBegin(10e-6, 10e-6)
polyRec.AddPolySegment(30e-6, 10e-6)

API Scripting Guide 1299


Layout

polyRec.AddPolySegment(30e-6, 30e-6)
polyRec.AddPolySegment(10e-6, 30e-6)
polyRec.PolyCutoutEnd

' Add Circular cutout.


polyRec.AddCircleCutout(80e-6, 80e-6, 10e-6)

' Add Ellipse cutout.


polyRec.AddEllipseCutout(10e-6, 90e-6, 30e-6, 20e-6)

' create the complex polygon


polyWrite.AddPolygon(polyRec)

Debug.Print "***"
Debug.Print "* Polygon Writer Net Name = " & lay.DrawingObjects.ActiveNetName
Debug.Print "***"

End Sub

Note, The polygon writer object has a net name property as we mentioned before, which should be passed along as the
net name for any objects created by the polygon writer. When the polygon writer is created the net name is inherited
from the active net name associated with the DrawingObjects collection. If the net name is changed on the writer then
that net name overrides the inherited name for subsequently created objects. In the code above we verify that the polygon
writer passes the net name set on the writer to created objects. We also need to know that the net name is inherited when
the polygon writer is created and if the net name is changed on the polygon writer then the set name on the writer will
override the inherited net name for subsequent objects.

API provides methods in the schematic implementation to highlight all objects in layout that have a given net name. The
highlight can be turned on or off for the group and there is an additional method to Unhighlight all objects. The highlight
is enabled by setting the display mode of the objects to include highlight and invalidating the region where objects exist
that have had their highlight display mode enabled/disabled. Currently highlight consists of drawing red dotted line
around the perimeter of the shapes.

We also need to mention that we added information on cutouts to the info status text produced by the generalized polygon
when the output is in multiline mode. Thies status text supplied for the Info tab on the shape propertied dialog information
about the cutouts in the generalized polygon. For each we provide a description of the type of cutout (Rectangle, Polygon,
Rectangle, Ellipse) and a list of the points. For performance reasons the output is limited to the first 20 cutouts and each
cutout is limited to the first 50 points.

API provides access, to modify, and add sub-objects to a complex polygon object. The API supports a couple of interfaces
for accessing a collection of sub-objects that belong to a drawing object. Those interfaces connect up the
DrawingSubObjects collection as a property of the DrawingObject. Objects can be added or removed and existing objects
can be modified through vertex, edit handle, and attribute collections. Objects that can be added include polygon, rectangle,
circle and ellipse.

API also provides layout.DrawingObjects.ActiveNetName and layout.DrawingObjects.ActiveNetType properties. This


will be set as the net name and type for any objects created through the drawing objects collection methods. This is
similar to how drawing shapes through the UI are placed on the active drawing layer. In addition, the PolygonWriter and
PathWriter objects will inherit the current active net name and type as their default net when they are created by a drawing
objects collection. The ActiveNetName and ActiveNetType appear in the Info tab of the shape properties dialog. If the
net name has a non-zero length then the name is included in the status information produced by objects (Paths, Polygons,
Standalone MultiLayer Paths, and Stanalone cell objects) that can have a net name associated with them. This allows

1300 NI AWR Design Environment


Layout

the user to quickly verify the ActiveNetName for a shape by selecting it and looking at the status information at the
bottom of the AWR DE.

The following subrotine can be used to print out subobjects properties:

Sub PrintSubObjectsState(ByRef subObjs As DrawingSubObjects)


Dim subObj As DrawingSubObject

Debug.Print "Sub Object State: "


Debug.Print "Sub Object Count = " & subObjs.Count
For Each subObj In subObjs
Debug.Print "Type = " & subObj.Type
Debug.Print "Selected = " & subObj.Selected

PrintVertices(subObj.Vertices)
Debug.Print "PolyVertices: "
PrintVertices(subObj.PolyVertices)
PrintBoundary(subObj.Boundary)
PrintAttributes(subObj.Attributes)
PrintEditHandles(subObj.EditHandles)
Next subObj

End Sub
Sub PrintAttributes(ByRef attrs As Attributes)
Dim attr As Attribute
Debug.Print "Attributes:"
For Each attr In attrs
Debug.Print attr.Name & " = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Debug.Print "Boundary:"
Debug.Print "Left = " & bound.Left * 1e6
Debug.Print "Right = " & bound.Right * 1e6
Debug.Print "Top = " & bound.Top * 1e6
Debug.Print "Bottom = " & bound.Bottom * 1e6
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Debug.Print "Vertices:"
For Each vert In verts
Debug.Print "{ x= " & vert.x * 1e6 & ", y= " & vert.y * 1e6 & " }"
Next vert
End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Debug.Print "Edit Handles:"
For Each eh In ehs
Debug.Print "{ x= " & eh.Position.x * 1e6 & ", y= " & eh.Position.y * 1e6 & " }"
Next eh
End Sub

API Scripting Guide 1301


Layout

For accessing and manipulating the edit handles collection associated with sub-objects in a complex polygon object API
provides the individual stretch handles of a drawing sub-object, so the sub-object can be enumerated and moved.

The following code shows API methods for adding cutouts to plain polygon object. Before we showed the code that uses
InvokeCommand() method to add cutouts to the plain polygon. The following code starts with a plain regular polygon
(not on process layers) and then attempts to add a cutout to the object using the SubObjects collection. This requires that
the plain polygon object to be replaced by a complex polygon which can support the new cutout methods and then the
cutout will be added to the new object. This script shows not only the addition of the cutout but also re-connecting the
automation wrapper objects when the target object is replaced. The sub-object state before and after adding the cutout
is dumped out as shown before:

' Code Module


Sub Main
Dim lay As Layout
Dim ret As Variant
Dim objDraw As DrawingObject
Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If

lay.Activate

PrintDrawObjectsState lay, "*** Before adding cutout ***"

Set objDraw = lay.DrawingObjects(1)

objDraw.SubObjects.AddEllipse(10e-6, 10e-6, 60e-6, 40e-6)

PrintDrawObjectsState lay, "*** After adding cutout ***"

End Sub

To add polygon cutout:

Set objDraw = lay.DrawingObjects(1)


Dim xyPoints(15) As Double
Dim x As Double
Dim y As Double

x = 10e-6
y = 10e-6
xyPoints(0) = x
xyPoints(1) = y

y = y + 20e-6
xyPoints(2) = x
xyPoints(3) = y

x = x + 20e-6
xyPoints(4) = x

1302 NI AWR Design Environment


Layout

xyPoints(5) = y

y = y + 20e-6
xyPoints(6) = x
xyPoints(7) = y

x = x + 20e-6
xyPoints(8) = x
xyPoints(9) = y

y = y - 20e-6
xyPoints(10) = x
xyPoints(11) = y

x = x + 20e-6
xyPoints(12) = x
xyPoints(13) = y

y = y - 20e-6
xyPoints(14) = x
xyPoints(15) = y

objDraw.SubObjects.AddPolygon(xyPoints)

PrintDrawObjectsState lay, "*** After adding cutout ***"

To flatten, rotate, flip, mirror and Copy/Paste complex polygon you can use InvokeCommand() methods for shape:

Set objDraw = lay.DrawingObjects(1)


objDraw.Selected = True
lay.InvokeCommand("ShapeFlatten")

To mirror:

lay.InvokeCommand("EditMirror", Array(200e-6, 0, 200e-6, 200e-6))

To access the segments and arc segments associated with sub objects of a complex polygon object API provides a
segments collection for drawing sub objects which mimics the segments collection associated with normal drawing
objects and in particular gives access to the details of an arc segment. The followin routone shows how to use the segments
collection:

Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject

Set lay = Project.Schematics("SCH1").Layout


Set objDraw = lay.DrawingObjects(1)
PrintSegmentState(objDraw.Segments)

End Sub
Sub PrintSegmentState(ByRef segs As DrawingSegments)

API Scripting Guide 1303


Layout

Dim seg As DrawingSegment

Debug.Print"Segment State: "


Debug.Print"Segment Obj Count = " & segs.Count

For Each seg In segs


Debug.Print"Segment Ends = { x1 = " & seg.Begin.x * 1e6 & ", y1= " & seg.Begin.y * 1e6 & ", x2
Debug.Print"Segment Length = " & seg.Length * 1e6
Debug.Print"Segment Angle = " & seg.Angle
Debug.Print"IsArcSegment = " & seg.IsArcSegment
If (seg.IsArcSegment) Then
Dim vtx As Vertex
Set vtx = seg.ArcSegment.Center
Debug.Print"Arc Center = { x = " & vtx.x * 1e6 & ", y = " & vtx.y * 1e6 & " }"
Debug.Print"Arc Dir = " & seg.ArcSegment.Direction
Debug.Print"Arc Length = " & seg.ArcSegment.Length * 1e6
Debug.Print"Arc Vertices: "
For Each vtx In seg.ArcSegment.Points
Debug.Print" Vertex = { x = " & vtx.x * 1e6 & ", y = " & vtx.y * 1e6 & " }"
Next vtx
End If
Debug.Print""
Next seg

End Sub

API Updates for working with generalized polygons.

There have been a number of improvements made to the AWR DE API to support access to the details of generalized
polygons. The API changes support efficient import of PCB board data to create generalized polygons and editing the
details of generalized polygons in the design environment. Normally in the API when we want to access the details of a
polygon object in layout, we start with the Project object, from that we get the specific Schematic of interest and then
access the layout associated with that schematic. The layout contains a collection of drawing objects which represent the
individual objects in the layout. Graphically this looks like the following:

1304 NI AWR Design Environment


Layout

Figure 1. Graphical illustration of accessing a polygon drawing object in a design layout.

In Figure 1 the DrawingObject at the bottom represents the polygon object in the DrawingObjects collection of the
Layout. The DrawingObject provides a number of properties and attributes that provide detailed information about the
layout object. For example, you can find the base position which represents the object location as well as the orientation
of the object indicating the rotation angle and the horizontal and vertical flip state.

In code this looks something like the following:

Sub Main 'Accessing the drawing objects of a schematic layout and printing the base position
Dim lay As Layout
Dim objDraw As DrawingObject

' Access the schematic layout for "Schematic 1"


Set lay = Project.Schematics("Schematic 1").Layout

' Go through the DrawingObjects collection and print base position of each
For Each objDraw In lay.DrawingObjects
Debug.Print "Base Position = " & objDraw.BasePosition.x * 1e6 & ", " & objDraw.BasePosition.y
Next objDraw
End Sub

Listing 1. Accessing the drawing objects of a schematic layout and printing the base position.

We start by dimensioning a Layout object and a DrawingObject. Then we set the Layout object to reference the Layout
associated with the Schematic named "Schematic 1" in the Project. The following For Each loop then goes through each
of the DrawingObjects in the Layout's DrawingObjects collection and for each one accesses the BasePositon property
to print the X and Y coordinates of the BasePosition.

The DrawingObject contains two collections which provide access to the details of a generalized polygon:

API Scripting Guide 1305


Layout

1. The SubObjects collection provides access to the cutout objects on a generalized polygon.
2. The Segments collection provides access to the segments, including arc segments associated with a generalized
polygon.

Graphically this looks like Figure 2:

Figure 2. SubObjects and Segments collection properties for accessing details of a generalized polygon.

For example, we have a generalized polygon with a single cutout, as shown in Figure 3, and we want to access the vertices
of that cutout in the polygon:

Figure 3. Generalized polygon with single cutout.

1306 NI AWR Design Environment


Layout

Then we can display the vertices for this cutout using the SubObjects collection to traverse the sub-objects and printing
the vertices of each sub-object. In this case there will be only one sub-object since we only have one cutout.

The code to display the vertices looks like the following:

Sub DisplayCutoutVertices(ByRef objDraw As DrawingObject)


' Displaying the vertices for the SubObjects of a DrawingObject.
Dim subObj As DrawingSubObject
Dim vtx As Vertex

For Each subObj In objDraw.SubObjects


For Each vtx In subObj.Vertices
Debug.Print "Vertex = " & vtx.x * 1e6 & ", " & vtx.y * 1e6
Next vtx
Next subObj
End Sub

Listing 2. Displaying the vertices for the SubObjects of a DrawingObject.

Note: Here we have written the code as a subroutine which takes a DrawingObject and then traverses the SubObjects
property of that drawing object. For each SubObject it then traverses the Vertices collection to print each Vertex X and
Y value of the Vertex. Running this code we get the following output for the polygon of Figure 3:

Base Position = 0, 250


Vertex = 10, 50
Vertex = 10, 10
Vertex = 50, 10
Vertex = 50, 50

This shows the base position of the polygon object (output from Listing 1) along with the Vertex output obtained by
calling the DisplayCutoutVertices() subroutine from the loop right after the base position is printed and passing a reference
to the drawing object.

The SubObject collections also contain methods for adding, removing, and moving sub objects within the generalized
polygon. If we wanted to add a circle cutout above the rectangle and a square and an ellipse to the right we can do that
as follows:

Sub AddCutoutShapes(ByRef objDraw As DrawingObject)


' Adding additional square, ellipse, and circle cutouts to the general polygon of Figure 3
objDraw.SubObjects.AddRectangle(60e-6, 10e-6, 40e-6, 40e-6)
objDraw.SubObjects.AddEllipse(110e-6, 10e-6, 50e-6, 40e-6)
objDraw.SubObjects.AddCircle(30e-6, 80e-6, 20e-6)
End Sub

Listing 3. Adding additional square, ellipse, and circle cutouts to the general polygon of Figure 3.

Note: this short subroutine adds the cutouts using the SubObjects collection associated with the generalized polygon
DrawingObject. The result of running this subroutine on the polygon of Figure 3 is as follows:

API Scripting Guide 1307


Layout

Figure 4. Result of running the subroutine to add cutouts to the polygon of Figure 3.

Figure 4 shows that a rectangle and ellipse have been added to the right and a circular cutout has been added above the
original rectangle cutout.

The cutouts can also be moved using the SubObjects collection. For example, if we wanted to move each of the cutouts
40um upward we could do that using the following subroutine:

Sub MoveCutoutShapes(ByRef objDraw As DrawingObject)


Dim subObj As DrawingSubObject

' Traversing the SubObjects collection on an DrawingObject and moving each object.
For Each subObj In objDraw.SubObjects
subObj.Move(0, 40e-6)
Next subObj
End Sub

Listing 4. Traversing the SubObjects collection on an DrawingObject and moving each object.

In this routine we traverse each of the SubObjects associated with the given DrawingObject and call the Move() method
on each supplying a dx=0 and a dy=40um. This will move each of the cutouts 40um upward in the y direction. The results
of running this subroutine on the polygon of Figure 4 looks as follows:

1308 NI AWR Design Environment


Layout

Figure 5. Results of shifting each of the cutout shapes 40um upwards in the y direction.

Figure 5 shows the results of the move operation, each of the cutout shapes from Figure 4 have shifted 40um upward.

Cutouts can also be removed from polygon using the SubObjects collection. For example, we wanted to remove the
circle and the ellipse. We can remove all the circles and ellipses using the following subroutine:

Sub RemoveCutoutShapes(ByRef objDraw As DrawingObject)


Dim subObj As DrawingSubObject
Dim index As Integer

' Traversing the SubObjects in reverse order and removing circles and ellipses.
For i = objDraw.SubObjects.Count To 1 Step -1
Set subObj = objDraw.SubObjects(i)
If (subObj.Type = mwDSO_CutoutCircle Or subObj.Type= mwDSO_CutoutEllipse) Then
objDraw.SubObjects.Remove(i)
End If
Next i
End Sub

Listing 5. Traversing the SubObjects in reverse order and removing circles and ellipses.

Removing items is a little tricky because you'll be trying to remove objects from a collection while also traversing the
collection. One technique that is often successful is to traverse the collection from the end to the start and remove them
as we go. This way the objects we are removing will be behind the objects we still have to traverse in the collection so
they won't change the count of the remaining objects. In this subroutine we have used a For loop with an index variable

API Scripting Guide 1309


Layout

which counts from the number of items in the SubObjects collection down to the first index which will be 1. Each time
through we check the type and if it is a circle or ellipse then remove the object. Again since the objects we'll be removing
are behind the objects we still have to traverse they don't affect the count or the index we need for the remove operation.
This way we don't need to do anything fancy with the index when we remove an object. When we run this subroutine
on the polygon from Figure 5 we get the following:

Figure 6. Results of removing the circle and ellipse cutouts using the SubObjects collection Remove method.

Figure 6 shows that the Ellipse on the right end and the circle above the first square have been removed. So the SubObjects
collection provides a flexible way of editing and updating the cutout shapes associated with a generalized polygon.

PCB data is often structured in terms of segments and arc segments in a polygon object. To make accessing and working
with polygon segments easier the DrawingObject has a sub-collection of segments. This can be used to traverse the
segments of the polygon and to convert a segment into an arc segment or revert an arc segment back into a normal
segment. For example, we have a layout with a simple rectangle object.

1310 NI AWR Design Environment


Layout

Figure 7.Simple rectangle shape for traversing polygon segments.

Given the DrawingObject accessed as we show before we can traverse the segments of this polygon as follows:

Sub PrintDrawingObjectSegments(ByRef objDraw As DrawingObject)


Dim seg As DrawingSegment
Dim index As Integer
' Displaying the segments for a rectangle polygon.
index = 1
For Each seg In objDraw.Segments
Debug.Print index & ": P1 (" & seg.Begin.x * 1e6 & ", " & seg.Begin.y * 1e6 & ")";
Debug.Print "P2 (" & seg.End.x * 1e6 & ", " & seg.End.y * 1e6 & ")"
index = index + 1
Next seg
End Sub

Listing 6. Displaying the segments for a rectangle polygon.

When we run this and pass it the DrawingObject representing the square above we get the following output:

1: P1 (0, 100) P2 (0, 0)


2: P1 (0, 0) P2 (100, 0)
3: P1 (100, 0) P2 (100, 100)
4: P1 (100, 100) P2 (0, 100)

API Scripting Guide 1311


Layout

From these values we can see that the square has it's lower left corner at 0,0 and has a width and height of 100um. In the
output we added an index so we can tell which segment pertains to each side of the polygon. Let's suppose we want to
make the right side of the square into an arc segment. Looking at the segments we can see that segment #3 goes from
(100, 0) to (100,100).

So to convert this to a segment we need to pick a center for the arc and a direction. Let's say we want to make a half
circle, so we'll put our center in the middle of the side where we are adding the arc segment or the point (100, 50). This
will be halfway up the right side.

For the direction we can choose counter-clockwise or clockwise. Here it helps to have a little background on the winding
directions for polygons. In the AWR DE normal polygons can be wound in either direction clockwise or counter-clockwise.
But a generalized polygon will always have the outer polygon wound counter-clockwise. So given this a counter-clockwise
arc segment will curve outward and a clockwise arc segment will curve inward.

Figure 8. Viewed as a radial segment from the center to the edge we can see that counter-clockwise will sweep outward
and clockwise will sweep inward.

So if we select counter-clockwise that should add an extra half circle to the right side of the rectangle object. If we choose
clockwise it will cut a semi-circle out of the right side of the rectangle. For the first case let's add the extra half semi-circle
to the rectangle by selecting counter-clockwise.

Sub CreateArcSegment(ByRef objDraw As DrawingObject)


' Converting the right-side segment to a arc-segment with a counter-clockwise direction.

If (objDraw.Segments(3).CanMakeArcSegment) Then
objDraw.Segments(3).MakeArcSegment(100e-6, 50e-6, mwDAD_CounterClockwise)
End If
End Sub

Listing 7. Converting the right-side segment to a arc-segment with a counter-clockwise direction.

This code first verifies that the side can be converted to an arc segment, this verifies that the drawing object can be
converted to a generalized polygon and that in the resulting polygon the side can be made into an arc. Then we request
the segment be made into an arc segment with a center point halfway up the right side and in the counter-clockwise
direction. We get the following result:

1312 NI AWR Design Environment


Layout

Figure 9. The result of running the CreateArcSegment() subroutine on the rectangle drawing object using counter-clockwise
direction.

If we do this again but instead request a clockwise direction using the following code:

Sub CreateArcSegment(ByRef objDraw As DrawingObject)


' Creating the arc-segment but in the clockwise direction.

If (objDraw.Segments(3).CanMakeArcSegment) Then
objDraw.Segments(3).MakeArcSegment(100e-6, 50e-6, mwDAD_Clockwise)
End If
End Sub

Listing 8. Creating the arc-segment but in the clockwise direction.

We get the following result:

API Scripting Guide 1313


Layout

Figure 10. The result of running the CreateArcSegment() subroutine on the rectangle drawing object using clockwise
direction.

Using the MakeArcSegment() method on the Segment object we can convert a normal segment into an arc segment that
curves either outward, or inward.

Each of the segment objects in the segments collection contains a Boolean property for checking if that segment is an
arc-segment. The segments also contain a method for reverting an arc-segment back to a normal segment. Using the
IsArcSegment property and the RevertArcSegment() method we can write a routine to remove all the arc-segments from
a DrawingObject:

Sub RemoveArcSegments(ByRef objDraw As DrawingObject)


Dim seg As DrawingSegment
' Traversing the segments of a drawing object and reverting any arc segments.

For Each seg In objDraw.Segments


If (seg.IsArcSegment) Then
seg.RevertArcSegment
End If
Next seg
End Sub

Listing 9. Traversing the segments of a drawing object and reverting any arc segments.

1314 NI AWR Design Environment


Layout

In the RemoveArcSegments() subroutine we walk through each of the segments associated with the DrawingObject and
ask if each is an arc-segment. If it is, then we ask the segment to revert the arc segment into a normal segment. Running
this subroutine on the rectangle object gives the same result as in Figure 7.

Calling RevertArcSegment on each of the segment objects restores the object to a simple rectangle with straight sides.

Segments are also available from each of the SubObjects within a generalized polygon object. This means that we can
use the same techniques to traverse the segments and convert segments to arc-segments on sub-objects that we used on
the generalized polygon itself. For example, suppose we took the rectangle polygon of Figure 7 and added a single
rectangle cutout in the bottom-left corner as shown in Figure 11.

Figure 11. Rectangle polygon with a single rectangle cutout.

We can traverse the segments of a sub-object similar to how we traversed the vertices but access the Segments collection
on each SubObject rather than the Vertices as follows:

Sub DisplayCutoutSegments(ByRef objDraw As DrawingObject)


' Traversing the segments of a sub-object in a generalized polygon

Dim subObj As DrawingSubObject


Dim seg As DrawingSegment
Dim index As Integer

For Each subObj In objDraw.SubObjects


index = 1
For Each seg In subObj.Segments
Debug.Print index & ": P1 (" & seg.Begin.x * 1e6 & ", " & seg.Begin.y * 1e6 & ")";
Debug.Print " P2 (" & seg.End.x * 1e6 & ", " & seg.End.y * 1e6 & ")"
index = index + 1

API Scripting Guide 1315


Layout

Next seg
Next subObj
End Sub

Listing 10. Traversing the segments of a sub-object in a generalized polygon.

Running the code in Listing 10 we get the following output:

1: P1 (10, 40) P2 (10, 10)


2: P1 (10, 10) P2 (40, 10)
3: P1 (40, 10) P2 (40, 40)
4: P1 (40, 40) P2 (10, 40)

Again, here we added an index beside each segment in the output so we can see which one we might want to convert
into an arc-segment. In this case Segment #3 goes from (40,10) to (40,40) which represents the right side of the rectangle.
Let's see if we can convert that segment into an arc-segment:

Sub ConvertSubObjectArcSegment(ByRef subObj As DrawingSubObject)


' Adding an arc segment on the right side of the rectangle cutout.

If (subObj.Segments(3).CanMakeArcSegment()) Then
subObj.Segments(3).MakeArcSegment(40e-6, 25e-6, mwDAD_Clockwise)
End If
End Sub

Listing 11. Adding an arc segment on the right side of the rectangle cutout.

The code for this is similar to that from Listing 8 with one slight difference. Because cutouts are wound in the opposite
direction of the outer polygon the direction is also different. So for a cutout to get an outward arc we want to use a
clockwise direction. Likewise if we want an inward arc we want to use counter-clockwise. If we pass the drawing
sub-object associated with the rectangle to the subroutine of Listing 11 we get the following result:

1316 NI AWR Design Environment


Layout

Figure 12. Result of converting the rectangle cutout right-side segment to an arc segment.

Similar to the outer polygon the result of converting a sub-object segment to an arc segment allows us to curve the
segment inward or outward depending on the direction we choose. The segments collection for a sub-object also contains
the methods for checking if a segment is an arc segment and reverting an arc segment so we can also remove the
arc-segment attributes from a segment.

Using the DrawingObject's SubObjects collection and the Segments collections associated with the DrawingObject and
the DrawingSubObjects we have complete programmatic access to generalized polygons. The details of the polygon
features can be accessed, added, modified, and removed including sub-objects and arc segments.

Support for Importing PCB Data/PolygonWriter/PathWriter

The AWR DE includes API support custom tailored for efficiently importing (Printed Circuit Board) PCB board data
into layouts. In particular, the API is tailored to make importing data specified in the standard IPC 2581 printed board
and printed board assembly format convenient to import. The API for importing board data provides an object for writing
polygons and one for writing paths. Graphically looking at the object model we have the following structure for these
objects:

API Scripting Guide 1317


Layout

Figure 13. PolygonWriter and PathWriter objects obtained form the DrawingObjects collection.

At the bottom of Figure 13 we see that we can obtain a PolygonWriter and PathWriter from the drawing objects collection.
When we use these objects we will be writing polygons and paths into the DrawingObjects collection for the layout.
There are actually two separate objects involved in using each of the writer objects. There is the Writer object itself
which includes properties such as the DrawingLayer that will be true for a number of paths or polygons. And there is a
record object which holds the details for one object such as the path or polygon vertices.

Figure 14. Path and Polygon Writer objects and their associated Record objects.

So if we are planning on creating polygons we will be using PolygonWriter and the PolygonRecord objects. For example,
to write polygons, the first step would be to obtain a PolygonRecord from the PolygonWriter to contain the details for
each polygon that will be output. Next, we'd set the output layer for the initial set of polygons to be written. Next, we'd
fill out the PolygonRecord with the details of the polygon including segments and cutouts. Then we'd ask the PolygonWriter

1318 NI AWR Design Environment


Layout

to create the polygon passing it the details in the PolygonRecord object. We can then clear the PolygonRecord, fill it out
with the details of the next polygon, and then ask the PolygonWriter to create the next polygon, passing it the
PolygonRecord object with the details. Once we've finished all the polygons on that layer we can set a new layer on the
PolygonWriter object and then use the PolygonRecord to start writing polygons on the next layer, clearing the record
between each one and filling it out with the details of the next polygon and passing that to the PolygonWriter.

Figure 15. Workflow for creating polygons with the PolygonWriter.

Using the PolygonWriter and PolygonRecord Objects

To begin with let's see how the flow outlined in Figure 15 works by creating a couple of simple polygons on the "Thick
Metal" layer:

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject
Dim pw As PolygonWriter

' Access the schematic layout for "Schematic 1"


Set lay = Project.Schematics("Schematic 1").Layout

' Get a polygon writer from the DrawingObjects collection of the layout.
Set pw = lay.DrawingObjects.PolygonWriter

API Scripting Guide 1319


Layout

CreateSimplePolygons(pw)

End Sub

Sub CreateSimplePolygons(ByRef pw As PolygonWriter)


Dim pr As PolygonRecord

' Set the output layer on the polygon writer.


pw.LayerName = "Thick Metal"

' Get a record to provide polygon details to.


Set pr = pw.CreatePolygonRecord

' Add the polygon details to the record.


pr.PolygonBegin(0, 0)
pr.AddPolySegment(100e-6, 0)
pr.AddPolySegment(100e-6, 100e-6)
pr.AddPolySegment(0, 100e-6)
pr.PolygonEnd

' Create the polygon using the polygon writer by supplying the record.
pw.AddPolygon(pr)

' Clear the polygon record so we can reuse it.


pr.Clear

' Add the details for the second polygon


pr.PolygonBegin(200e-6, 0)
pr.AddPolySegment(300e-6, 0)
pr.AddPolySegment(300e-6, 100e-6)
pr.AddPolySegment(200e-6, 100e-6)
pr.PolygonEnd

' Create the polygon using the polgon writer by supplying the record.
pw.AddPolygon(pr)

End Sub

Listing 12. Code to implement each of the steps illustrated in Figure 13 to create a couple of polygons on "Thick Metal"
layer.

The code in Listing 12 is a little longer than most examples but shows each of the steps illustrated in Figure 15 on the
flow for creating polygons using the PolgonWriter and the PolygonRecord objects. Let's start by looking at the Main
Subroutine:

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject
Dim pw As PolygonWriter

' Access the schematic layout for "Schematic 1"


Set lay = Project.Schematics("Schematic 1").Layout

' Get a polygon writer from the DrawingObjects collection of the layout.

1320 NI AWR Design Environment


Layout

Set pw = lay.DrawingObjects.PolygonWriter

CreateSimplePolygons(pw)

End Sub

Listing 13. Setup for the writing process by obtaining a Layout reference and PolygonWriter reference.

We start in the Main subroutine by getting a reference to the layout we are going to write the polygons to, and then
obtaining an PolygonWriter reference from the DrawingObjects collection associated with that layout. This will allow
us to write polygon objects directly into the DrawingObjects collection for the Layout. This corresponds to the top portion
of the flow in Figure 15. Once we have a reference to the polygon writer we call a subroutine to write the actually
polygons:

Sub CreateSimplePolygons(ByRef pw As PolygonWriter)


Dim pr As PolygonRecord

' Get a record to provide polygon details to.


Set pr = pw.CreatePolygonRecord

' Set the output layer on the polygon writer.


pw.LayerName = "Thick Metal"

' Add the polygon details to the record.


pr.PolygonBegin(0, 0)
pr.AddPolySegment(100e-6, 0)
pr.AddPolySegment(100e-6, 100e-6)
pr.AddPolySegment(0, 100e-6)
pr.PolygonEnd

' Create the polygon using the polygon writer by supplying the record.
pw.AddPolygon(pr)

' Clear the polygon record so we can reuse it.


pr.Clear

' Add the details for the second polygon


pr.PolygonBegin(200e-6, 0)
pr.AddPolySegment(300e-6, 0)
pr.AddPolySegment(300e-6, 100e-6)
pr.AddPolySegment(200e-6, 100e-6)
pr.PolygonEnd

' Create the polygon using the polgon writer by supplying the record.
pw.AddPolygon(pr)

End Sub

Listing 14. Writing the actual polygons using the PolygonWriter with a PolygonRecord.

Once inside the CreateSimplePolygons subroutine we first create a PolygonRecord object to describe the polygon details
and then set the initial output layer on the PolygonWriter. Next, the details for the first polygon are provided to the
PolygonRecord using the PolygonBegin(), AddPolySegment(), and PolygonEnd() methods to describe the segments in

API Scripting Guide 1321


Layout

the polygon outline. The PolygonBegin method describes the starting point for the polygon object. Each AddPolySegment()
call then described an end-point for a segment that forms the side of the polygon. It is not necessary to close the polygon
by providing a segment back to the start point, the shape will be closed automatically from the last end point.

Once we have finished adding the polygon details to the polygon record we can add the polygon to the DrawingObjects
collection using the PolygonWriter's AddPolygon() method and supplying the PolygonRecord which contains the details.

We can then begin to describe the next polygon to be added on the same layer. For efficiency we can reused the
PolygonRecord object by clearing the details of the last polygon before we add details of the new polygon. After the
PolygonRecord has been cleared we can begin describing the next polygon to the record object, again using the
PolygonBegin(), AddPolySegment(), and PolygonEnd() methods. Once we have described the polygon details in the
PolygonRecord object, we can add the second polygon using the PolygonWriter's AddPolygon() method and supplying
the updated PolygonRecord which has the details. Note that until we change the layer on the PolygonWriter object all
subsequent polygons will be created on the current layer we have set. We can think of the LayerName property on the
PolygonWriter as the active layer for input.

When adding the polygon we followed a process of providing a start point and then adding segment end points to the
polygon and eventually calling a method to mark the end of the polygon. If we take a look at a sample of IPC 2581 PCB
board data we can see how this aligns with the structure of the data:

<Contour>

<Polygon>

<PolyBegin x="-0.150010" y="-0.150010"/>

<PolyStepSegment x="3.250010" y="-0.150010"/>

<PolyStepSegment x="3.250010" y="3.850010"/>

<PolyStepSegment x="-0.150010" y="3.850010"/>

<PolyStepSegment x="-0.150010" y="-0.150010"/>

</Polygon>

<Cutout>

<PolyBegin x="0.200000" y="-0.100000"/>

<PolyStepSegment x="0.200000" y="3.800000"/>

<PolyStepSegment x="2.900000" y="3.800000"/>

<PolyStepSegment x="2.900000" y="-0.100000"/>

<PolyStepSegment x="0.200000" y="-0.100000"/>

</Cutout>

</Contour>

Listing 15. Sample of IPC 2581 XML describing a polygon contour.

1322 NI AWR Design Environment


Layout

In this data the Contour describes an overall generalized polygon. This sample shows an outer polygon along with a
single cutout in the polygon. Looking at the <Polygon/> section it describes the polygon as a PolyBegin start point
followed by a series of PolyStepSegment points. This aligns with the methods on the PolygonRecord object for specifying
a polygon. The <PolyBegin x="", y="" > corresponds to the PolygonRecord's BeginPolygon(x, y), each of the
<PolyStepSegment x="", y=""> corresponds to a call to the PolygonRecord's AddPolySegment(x, y), and finally the
</Polygon> corresponds to the EndPolygon() call.

The results of running the script from Listing 12 are shown in Figure 16:

Figure 16. The results produced by using the PolygonWriter to create two simple rectangle polygons in layout.

Figure 16 shows the results we obtain in layout from the using the PolygonWriter to create two simple rectangular
polygons. We can also add arc segments when specifying segements to the PolygonWriter object. If we look at a sample
of IPC 2581 XML which includes arc-segments we can see that they are specified like normal segments except with
additional information to specify the center and direction for the arc-segment:

<Contour>

<Polygon>

<PolyBegin x="0.010590" y="0.005640"/>

<PolyStepCurve x="0.010590" y="-0.005640" centerX="-0.000001" centerY="0.0" clockwise

<PolyStepSegment x="0.014960" y="-0.010010"/>

<PolyStepCurve x="0.014960" y="0.010010" centerX="0.000000" centerY="0.0" clockwise="

<PolyStepSegment x="0.010590" y="0.005640"/>

API Scripting Guide 1323


Layout

</Polygon>

</Contour>

Listing 16. Sample IPC 2581 XML Polygon specification with arc-segments.

In the example from Listing 12 we can add arc segments by modifying the calls made on the PolygonRecord to replacing
a couple of the AddPolySegment() calls with AddPolyArcSegment() calls as follows:

Sub CreateSimplePolygons(ByRef pw As PolygonWriter)


Dim pr As PolygonRecord

' Set the output layer on the polygon writer.


pw.LayerName = "Thick Metal"

' Get a record to provide polygon details to.


Set pr = pw.CreatePolygonRecord

' Add the polygon details to the record.


pr.PolygonBegin(0, 0)
pr.AddPolySegment(100e-6, 0)
pr.AddPolyArcSegment(100e-6, 100e-6, 100e-6, 50e-6, mwDAD_CounterClockwise)
pr.AddPolySegment(0, 100e-6)
pr.PolygonEnd

' Create the polygon using the polygon writer by supplying the record.
pw.AddPolygon(pr)

' Clear the polygon record so we can reuse it.


pr.Clear

' Add the details for the second polygon


pr.PolygonBegin(200e-6, 0)
pr.AddPolySegment(300e-6, 0)
pr.AddPolyArcSegment(300e-6, 100e-6, 300e-6, 50e-6,mwDAD_CounterClockwise)
pr.AddPolySegment(200e-6, 100e-6)
pr.PolygonEnd

' Create the polygon using the polgon writer by supplying the record.
pw.AddPolygon(pr)

End Sub

Listing 17. CreateSimplePolygons subroutine modified to create arc-segments on the right side of the polygons.

Like the IPC 2581 XML the changes necessary to create arc segments merely requires changing how we add the segments
to specify additional information about the arc center and the arc direction. We use the PolygonRecord's
AddPolyArcSegment() method to specify the segment and the addition information needed for the arc. The results of
running this subroutine are as follows:

1324 NI AWR Design Environment


Layout

Figure 17. Adding two polygons with arc-segments specified for the right sides.

Figure 17 shows the results when we run the subroutine of Listing 17 which specifies that the right-sides of the polygons
should be arc-segments with the center point half way up the right side of the rectangle.

The IPC 2581 XML sample in Listing 15 also shows how cutouts within a contour are specified very similar to the way
segments for the polygon are specified. The PolygonRecord object also provides methods for specifying the start and
segments of a polygon cutout. Let's try creating an example that parallels Listing 15 and includes a single polygon with
a single cutout. The code for this is as follows:

Sub CreateSimplePolygons(ByRef pw As PolygonWriter)


Dim pr As PolygonRecord

' Set the output layer on the polygon writer.


pw.LayerName = "Thick Metal"

' Get a record to provide polygon details to.


Set pr = pw.CreatePolygonRecord

' Add the polygon details to the record.


pr.PolygonBegin(0, 0)
pr.AddPolySegment(100e-6, 0)
pr.AddPolySegment(100e-6, 100e-6)
pr.AddPolySegment(0, 100e-6)
pr.PolygonEnd

' Add cutout details to the record.


pr.PolyCutoutBegin(10e-6, 10e-6)
pr.AddPolySegment(10e-6, 40e-6)

API Scripting Guide 1325


Layout

pr.AddPolySegment(40e-6, 40e-6)
pr.AddPolySegment(40e-6, 10e-6)
pr.PolyCutoutEnd

' Create the polygon using the polgon writer by supplying the record.
pw.AddPolygon(pr)

End Sub

Listing 18. Subroutine to create a polygon with a single cutout.

Similar to the structure of the IPC 2581 XML in Listing 12 we first use the PolygonRecord to specify the details of the
Polygon object and then we do a similar specification for the cutout. The difference is that we start with PolyCutoutBegin()
and end with PolyCutoutEnd() methods to indicate that this polygon will be a cutout. Once both the polygon and the
cutout have been specified in the PolygonRecord object we provide this to the PolygonWriter and ask it to create a
polygon object with AddPolygon().

The results of running this subroutine are as follows:

Figure 18. Adding a single rectangle polygon with a single rectangle cutout.

Likewise we can add arc-segments into the cutouts just as we did for the outer polygon by changing the segment
specifications from AddPolySegment() calls to AddPolyArcSegment() calls. For example, we can add an arc-segment
to the right side of the cutout as follows:

Sub CreateSimplePolygons(ByRef pw As PolygonWriter)


Dim pr As PolygonRecord

1326 NI AWR Design Environment


Layout

' Set the output layer on the polygon writer.


pw.LayerName = "Thick Metal"

' Get a record to provide polygon details to.


Set pr = pw.CreatePolygonRecord

' Add the polygon details to the record.


pr.PolygonBegin(0, 0)
pr.AddPolySegment(100e-6, 0)
pr.AddPolySegment(100e-6, 100e-6)
pr.AddPolySegment(0, 100e-6)
pr.PolygonEnd

' Add cutout details to the record.


pr.PolyCutoutBegin(10e-6, 10e-6)
pr.AddPolySegment(40e-6, 10e-6)
pr.AddPolyArcSegment(40e-6, 40e-6, 40e-6, 25e-6, mwDAD_CounterClockwise)
pr.AddPolySegment(10e-6, 40e-6)
pr.PolyCutoutEnd

' Create the polygon using the polgon writer by supplying the record.
pw.AddPolygon(pr)

End Sub

Listing 19. Adding a cutout that includes an arc-segment.

Similar to what we did in Listing 17, here we have changed one of the AddPolySegment() calls to be a
AddPolyArcSegment() when creating the arc-segment in the cutout. Running this we get the following output:

API Scripting Guide 1327


Layout

Figure 19. Adding a single polygon with a single cutout that includes an arc segment on the right side.

The polygon record also includes support for directly specifying circular and elliptical cutouts. These can be added to
the polygon specification using the AddCircleCutout() and AddEllipseCutout() methods. For example, the following
script adds a circle and an elllipse cutout to the simple polygon object:

Sub CreateSimplePolygons(ByRef pw As PolygonWriter)


Dim pr As PolygonRecord

' Set the output layer on the polygon writer.


pw.LayerName = "Thick Metal"

' Get a record to provide polygon details to.


Set pr = pw.CreatePolygonRecord

' Add the polygon details to the record.


pr.PolygonBegin(0, 0)
pr.AddPolySegment(100e-6, 0)
pr.AddPolySegment(100e-6, 100e-6)
pr.AddPolySegment(0, 100e-6)
pr.PolygonEnd

pr.AddCircleCutout(25e-6, 25e-6, 15e-6)

pr.AddEllipseCutout(10e-6, 70e-6, 30e-6, 20e-6)

' Create the polygon using the polgon writer by supplying the record.
pw.AddPolygon(pr)

End Sub

Listing 20. Adding a polygon with circle and ellipse cutouts.

Circle and Ellipse cutouts can be added to the PolygonRecord object with a single call each. In Listing 20 we first create
the polygon and then make calls to add a circle and ellipse cutouts. The Circle we specify the center point and a radius
and for the ellipse the upper-left corner and the width and height of a rectangle the ellipse should be inscribed into. The
results of running this subroutine are shown in Figure 20:

1328 NI AWR Design Environment


Layout

Figure 20. Adding a rectangle polygon with a circle and an ellipse cutout.

Using the PolygonWriter and the PolygonRecord we can efficiently specify generalized polygons to be written into the
drawing objects collection of a layout in a manner that aligns with the structure of PCB layout data. In particular the API
is convenient for adding data specified in the IPC 2581 XML format.

Using the PathWriter and PathRecord objects.

The PathWriter and PathRecord objects operate in a similar fashion to the PolygonWriter and PolygonRecord objects.
However, in addition to specifying just the output layer, the PathWriter allows the specification of a number of additional
common attributes of the path objects to be output. For example the path end type, the path width, and the type of bend
to use at the corners can be specified along with the output layer. Once these values are specified they will be inherited
by all paths created by the PathWriter until they are changed.

For example, let's use the PathWriter and PathRecord objects to create a path with rounded ends and rounded corners in
layout. The process will be very similar to what we did with the PolygonWriter. The code to do this is as follows:

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject
Dim pw As PathWriter

' Access the schematic layout for "Schematic 1"


Set lay = Project.Schematics("Schematic 1").Layout

' Get a polygon writer from the DrawingObjects collection of the layout.
Set pw = lay.DrawingObjects.PathWriter

API Scripting Guide 1329


Layout

CreatePath(pw)

End Sub

Sub CreatePath(ByRef pw As PathWriter)


Dim pr As PathRecord

' Get a path record object from the path writer


Set pr = pw.CreatePathRecord

' Specify the common attributes of our path objects.


pw.LayerName = "Thick Metal"
pw.MiterStyle = mwPMT_Rounded
pw.EndType = mwPET_Rounded
pw.Width = 20e-6

' Specify the path details


pr.PathBegin(0, 0)
pr.AddSegment(50e-6, 0)
pr.AddSegment(50e-6, 100e-6)
pr.AddSegment(100e-6, 100e-6)
pr.PathEnd

' Add the path using the path writer supplying the path record.
pw.AddPath(pr)

End Sub

Listing 21. Creating a PathWriter object and using it with a PathRecord object to create a path object in layout.

The process and code contained in Listing 21 is very similar to that of Listing 12 where we added two polygon objects
using the PolygonWriter. In the main() subroutine at the top we get a reference to the layout we want to add the paths
into. Then from the DrawingObjects collection on the layout we get a reference to a PathWriter object. The code then
calls the CreatePath() subroutine and passed the PathWriter reference. Once inside the CreatePath() subroutine we have
the PathWriter create and return a reference to a PathRecord object to use for specifying the details of the paths. Then
we specify the common attributes for the paths that will be added on the PathWriter. These attributes will be set on each
path that is added using the PathWriter until they are changed. In this case we are specifying the "Thick Metal" drawing
layer, Rounded outside corners for curves with the Rounded Miter style, rounded path ends and a path width of 20um.

Once the common attributes have been specified on the PathWriter we can begin to specify the path details using the
PathRecord object. Here we specify the vertices for a 3 segment path. Once the path details are specified using the
PathRecord, this is passed to the PathWriter to create the path in layout. The results of running this program are shown
below:

1330 NI AWR Design Environment


Layout

Figure 21. Resulting path created with PathWriter and PathRecord objects.

Like with the PolygonRecord, we can now clear the PathRecord and begin specifying the next path. Once we complete
that it can be added using the PathWriter and will inherit all the common attributes such as layer, width, end and bend
styles set on the PathWriter object.

At any point we can change the common attributes on the PathWriter and then the subsequent paths we create will inherit
the updated values. For example, we could change the bend style to curved, set the miter amount which in this case
specifies the radius to 30um and specify that the paths should be output on the "Cap Bottom" layer. The remaining details
such as the rounded end style will be retained from the previous settings. The code with these changes looks as follows:

Sub CreatePath(ByRef pw As PathWriter)


Dim pr As PathRecord

' Get a path record object from the path writer


Set pr = pw.CreatePathRecord

' Specify the common attributes of our path objects.


pw.LayerName = "Thick Metal"
pw.MiterStyle = mwPMT_Rounded
pw.EndType = mwPET_Rounded
pw.Width = 20e-6

' Specify the path details


pr.PathBegin(0, 0)
pr.AddSegment(50e-6, 0)
pr.AddSegment(50e-6, 100e-6)
pr.AddSegment(100e-6, 100e-6)
pr.PathEnd

API Scripting Guide 1331


Layout

' Add the path using the path writer supplying the path record.
pw.AddPath(pr)

' Clear the path record so it can be reused.


pr.Clear

' Change some common attributes for next path


pw.LayerName = "Cap Bottom"
pw.MiterStyle = mwPMT_Curved
pw.MiterAmount = 30e-6

' Specify the details


pr.PathBegin(200e-6, 0)
pr.AddSegment(250e-6, 0)
pr.AddSegment(250e-6, 100e-6)
pr.AddSegment(300e-6, 100e-6)
pr.PathEnd

' Add the path using the path writer supplying the record.
pw.AddPath(pr)

End Sub

Listing 22. Adding a second path with different output layer and bend style.

In Listing 22, we've added code at the bottom of the CreatePath() subroutine to clear the PathRecord so we can use it
again. Then we've changed some of the common attributes of the paths to be written by the PathWriter. Finally we specify
a second path using the PathRecord and ask the PathWriter to create the path. The second path will receive the updated
attributes. The result is as follows:

1332 NI AWR Design Environment


Layout

Figure 22. Two paths created using the PathWriter and PathRecord with different attributes.

Figure 22 shows the two resulting paths, the first, on the left, is created as before. The second one on the right has inherited
the updated attributes. It has curved bends and is on the output layer "Cap Bottom".

NetNames and the PolygonWriter and PathWriter objects.

In Layout the DrawingObjects collection has the notion of an active NetName which is the name that will be associated
with all objects created through the DrawingObjects collection. When the PolygonWriter and PathWriter objects are
created they will inherit this name by default. The PolygonWriter and PathWriter objects have a NetName property which
allows the name inherited from the DrawingObjects to be overridden for the objects created by the PolygonWriter and
PathWriter objects. However, for these objects the NetName is passed down to the PathRecord and PolygonRecord
objects. These names can again be overridden by the PathRecord and PolygonRecord objects. For any path or polygon
created by the PathWriter or PolygonWriter the resulting net name will always be that on the PathRecord or PolygonRecord
objects. So changing the value at the PolygonWriter or PathWriter level will result in future PolygonRecord and
PathRecords inheriting the new Writer value but it does not change the net name for any existing PathRecord or PolyRecord
objects that have been created. The result is that to change NetName polygons or paths to a value that is not the default
then you will want to do this at the record level. When a path or polygon is created it always gets the value that is active
at the Record level.

Conclusion.

The Board Layout Improvements provide a set of features which make importing and working with board layout and
more efficient. The support for generalized polygons directly in the layout environment makes it easy to create the types
of complex structures needed for board layout. Generalized polygons allow the layout to support polygons with cutouts
and no cutlines to the cutouts as well as arc-segments within polygons. The layout editor provides commands and methods
for editing and working with the structures contained in generalized polygons. Path objects now support rounded and
chamfered ends as well as rounded and curved bends making it straightforward to create board traces to connect
components. The API has been enhanced to provide access to, and modification of, the structures of a complex polygon

API Scripting Guide 1333


Layout

including different types of cutouts and arc-segments both on the polygon as well as in the cutouts. The API has also be
updated to provide two writer objects for creating paths and polygons with API methods that are tailored to importing
PCB layout data. The new import API objects are specifically targeted for importing data from the IPC 2581 XML format
efficiently. Overall the board layout improves make working with PCB layout data fast and efficient in the AWR DE.

Adding the layout parameters to a layout cell which is not associated with an element.

The following sections include information about API capability to add layout parameters to a cell via the layout parameters
collection. API allows to add parameters of type double, string and integer. API also has implemented read-only method
to the layout parameters collection to allow API users to determine which objects can have parameters added and which
cannot.

The following code shows Layout parameters access:

Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject

Set lay = Project.Schematics("SCH1").Layout


Set objDraw = lay.DrawingObjects(1)
PrintParamState objDraw, "Object Parameter Access"

End Sub

Sub PrintParamState(ByRef objDraw As DrawingObject, title As String)


Dim layParam As LayoutParameter
Dim layParam2 As LayoutParameter

Debug.Print title
For Each layParam In objDraw.Parameters
Debug.Print "Param Name = " & layParam.Name
Debug.Print "Param Type = " & layParam.ParameterType
Debug.Print "Param Unit Type = " & layParam.UnitType
If layParam.ParameterType = mwLPDT_Integer Or layParam.ParameterType = mwLPDT_Real Then
Debug.Print "Param Double Val = " & layParam.ValueAsDouble
Debug.Print "Param Int Val = " & layParam.ValueAsInteger
End If
Debug.Print "Param String Val = " & layParam.ValueAsString

Set layParam2 = objDraw.Parameters(layParam.Name)


If layParam2 Is Nothing Then
Debug.Print "Param " & layParam.Name & " lookup by name failed."
Else
Debug.Print "Param " & layParam.Name & " lookup by name succeeded."
End If

If objDraw.Parameters.Exists(layParam.Name) Then
Debug.Print "Param " & layParam.Name & " exists by name succeeded."
Else
Debug.Print "Param " & layParam.Name & " exists by name failed."
End If

Debug.Print "----"
Next layParam
End Sub

1334 NI AWR Design Environment


Layout

To add a layout parameter use the following code:

Set lay = Project.Schematics("SCH1").Layout


Set objDraw = lay.DrawingObjects(1)

objDraw.Parameters.Add("MyParam", 100e-6, mwUT_Length)

objDraw.Parameters.AddInteger("MyParam", 100)

objDraw.Parameters.AddString("MyParam", "MyString")

To remove layout parameter that had been added using the add methods use the following method:

objDraw.Parameters.Remove("MyParam")

Parameter can be removed by name or numeric index.

Accessing the layout Subcircuit special attributes.

The following code shows how to access layout Subcircuit special attributes:

Dim lay As Layout


Set lay = Project.Schematics("SCH1").Layout

For Each objDraw In lay.DrawingObjects


If (objDraw.TypeBits = 512) Then
For Each attr In objDraw.Attributes
Debug.Print attr.Name & " = " & attr.Value
Next attr
End If
Debug.Print ""
Next objDraw

The output will be:

LineType = 0
UsesProcessLayers = True
LayerMapping = 0
Anchor = False
Frozen = False
CellName =
ElementName = SUBCKT.S1
MasterDocumentName = Sub1

Rotating Subcircuit in layout.

The following code shows how to rotate layout Subcircuit:

Sub Main

API Scripting Guide 1335


Layout

Dim lay As Layout


Dim ret As Variant

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If

lay.Activate

PrintDrawObjectsState lay, "Before Rotate Command"

lay.SelectedObjects.AddAll
lay.InvokeCommand("EditRotate", Array(0.0, 0.0, 90), ret )

PrintDrawObjectsState lay, "After Rotate Command"

End Sub

Sub PrintDrawObjectsState(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject

Debug.Print title

' Dump the results of a file for comparison.


Debug.Print "Layout = " & lay.Name
Debug.Print "DrawingObjects Count = " & lay.DrawingObjects.Count
For Each objDraw In lay.DrawingObjects
PrintDrawingObject objDraw
Debug.Print ""
Next objDraw
Debug.Print ""

End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " & drawingObj.InfoText
Debug.Print "Selected = " & drawingObj.Selected
Debug.Print "Flipped = " & drawingObj.Flipped
Debug.Print "Rotation = " & drawingObj.RotationAngle
Debug.Print "Frozen = " & drawingObj.Frozen
Debug.Print "Base Pos = { x = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePosition
Debug.Print "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)

End Sub

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Debug.Print "Parameters:"

1336 NI AWR Design Environment


Layout

For Each param In params


Debug.Print param.Name & " = " & param.ValueAsString
Next param

End Sub

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Debug.Print "Attributes:"
For Each attr In attrs
Debug.Print attr.Name & " = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Debug.Print "Boundary:"
Debug.Print "Left = " & bound.Left
Debug.Print "Right = " & bound.Right
Debug.Print "Top = " & bound.Top
Debug.Print "Bottom = " & bound.Bottom
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Debug.Print "Vertices:"
For Each vert In verts
Debug.Print "{ x= " & vert.x & ", y= " & vert.y & " }"
Next vert
End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Debug.Print "Edit Handles:"
For Each eh In ehs
Debug.Print "{ x= " & eh.Position.x & ", y= " & eh.Position.y & " }"
Next eh
End Sub

Traversing layout hierarchy using the MasterDocumentName attribute of Subcircuit objects in layout.

The following code shows how to access layout hierarchy using the MasterDocumentName attribute of Subcircuit objects:

' Code Module


Sub Main
Dim lay As Layout
Dim ret As Variant
Dim dl As DrawingLayer
Dim objDraw As DrawingObject

PrintSubCellDocuments(Project.Schematics("SCH1").Layout)

End Sub

Sub PrintSubCellDocuments(ByRef lay As Layout)


Dim objDraw As DrawingObject

API Scripting Guide 1337


Layout

Debug.Print "Layout Name = " & lay.Name


For Each objDraw In lay.DrawingObjects
If (objDraw.Attributes.Exists("MasterDocumentName")) Then
' Print the master document name and then recursively print the sub documents of that.
Debug.Print "Master Document Name = " & objDraw.Attributes("MasterDocumentName").Value
PrintSubCellDocuments(Project.Schematics(objDraw.Attributes("MasterDocumentName").Value
End If
Next objDraw
End Sub

Accessing the layout Rectangle special attributes.

The following code shows how to access layout Rectangle special attributes:

Dim lay As Layout


Set lay = Project.Schematics("SCH1").Layout

For Each objDraw In lay.DrawingObjects


If (objDraw.TypeBits = 1) Then
For Each attr In objDraw.Attributes
Debug.Print attr.Name & " = " & attr.Value
Next attr
End If
Debug.Print ""
Next objDraw

The output will be:

LineType = 0
UsesProcessLayers = True
LayerMapping = 0
LayerIndex = 0
PositionFixed = False
FlipState = False
RotationAngle = 0
Area = 0.00000001
IsEMExtract = False
GroupName = EM_Extract

When accessing the layout Route special attributes the code should be:

For Each objDraw In lay.DrawingObjects


If (objDraw.TypeBits = 64) Then
For Each attr In objDraw.Attributes
Debug.Print attr.Name & " = " & attr.Value
Next attr
End If
Next objDraw

1338 NI AWR Design Environment


Layout

The output will be:

PositionFixed = False
FlipState = False
RotationAngle = 0
NetId = 0
Associated = False

PositionFixed = False
FlipState = False
RotationAngle = 0
NetId = 15
Associated = True

To access the layout Arc attributes the objDraw.TypeBits = 1 and output will be similar to the following:

LineType = -2
UsesProcessLayers = False
LayerMapping = -2
LayerIndex = 2
PositionFixed = False
FlipState = False
RotationAngle = 0
Length = 0.000221863
CenterX = 0.00005
CenterY = 0.00025
Radius = 0.000070711
StartAngle = -135
StopAngle = 45

To access the layout Dimention Line attributes the objDraw.TypeBits = 0 and output will be similar to the following:

FontName = Arial
BoldStyle = True
ItalicStyle = True
FontHeight = 0.000025
PositionFixed = False
FlipState = False
RotationAngle = 0
ArrowLocation = 0
TextLocation = 0
ArrowLength = 0.00002
GapLength = 0.000005
Precision = 1
ShowUnits = True
ShowTolerance = True
LengthTolerance = 0
Length = 0.00092

To access the layout Equation attributes the objDraw.TypeBits = 2 and output will be similar to the following:

API Scripting Guide 1339


Layout

FontName = Arial
BoldStyle = False
ItalicStyle = False
FontHeight = 0.00001

To access the layout pCell attributes the objDraw.TypeBits = 256

To change the layout Artwork Cell attributes Flipstate use the following code:

Sub Main
Dim lay As Layout

Set lay = Project.Schematics("SCH1").Layout


PrintArworkCellBoundaries lay, "Before FlipState Change"
ChangeFlipStateAttribute lay
lay.Refresh
PrintArworkCellBoundaries lay, "After FlipState Change"

End Sub

Sub PrintArworkCellBoundaries(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject

Debug.Print title
For Each objDraw In lay.DrawingObjects
Debug.Print "Boundary = ";
Debug.Print "Left = " & objDraw.Boundary.Left * 1e6;
Debug.Print ", Top = " & objDraw.Boundary.Top * 1e6;
Debug.Print ", Right = " & objDraw.Boundary.Right * 1e6;
Debug.Print ", Bottom = " & objDraw.Boundary.Bottom * 1e6;
If (objDraw.Attributes.Exists("FlipState")) Then
Debug.Print ", FlipState = " & objDraw.Attributes("FlipState").Value
Else
Debug.Print ", No FlipState Attribute"
End If
Next objDraw
End Sub

Sub ChangeFlipStateAttribute(ByRef lay As Layout)


Dim objDraw As DrawingObject

For Each objDraw In lay.DrawingObjects


If (objDraw.Attributes.Exists("FlipState")) Then
objDraw.Attributes("FlipState").Value = Not objDraw.Attributes("FlipState").Value
End If
Next objDraw
End Sub

To change the layout Artwork Cell attributes Magnification use the code below. Magnification attribute for drawing
objects supports scaling through magnification changes. The Attribute can be used to resize Artwork Cell as follows:

' Code Module

1340 NI AWR Design Environment


Layout

Sum Main
Dim lay As Layout

Set lay = Project.Schematics("SCH1").Layout


PrintSubcircuitBoundaries lay, "Before Mag Factor Change"
ChangeMagnficationAttribute lay
lay.Refresh
PrintSubcircuitBoundaries lay, "After Mag Factor Change"
End Sub

Sub PrintSubcircuitBoundaries(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject

Debug.Print title
For Each objDraw In lay.DrawingObjects
Debug.Print "Boundary = ";
Debug.Print "Left = " & objDraw.Boundary.Left * 1e6;
Debug.Print ", Top = " & objDraw.Boundary.Top * 1e6;
Debug.Print ", Right = " & objDraw.Boundary.Right * 1e6;
Debug.Print ", Bottom = " & objDraw.Boundary.Bottom * 1e6;
If (objDraw.Attributes.Exists("Magnification")) Then
Debug.Print ", Magification = " & objDraw.Attributes("Magnification").Value
Else
Debug.Print ", No Magnification Attribute"
End If
Next objDraw
End Sub

Sub ChangeMagnficationAttribute(ByRef lay As Layout)


Dim objDraw As DrawingObject

For Each objDraw In lay.DrawingObjects


If (objDraw.Attributes.Exists("Magnification")) Then
objDraw.Attributes("Magnification").Value = 0.5 * objDraw.Attributes("Magnification").Value
End If
Next objDraw
End Sub

Note in the script to be able to see the results of the attribute changes in existing open views there is a call to refresh the
layout after the changes have been made. To see if a drawing object has a particular attribute you can use
objDraw.Attributes.Exists("Magnification") with an if statement.

Drawing Equations on Layout

The following sections include information about adding equations, removing equations by expression and variable
name, and adding and removing expressions to/from an existing equation.

The following code adds Equations to a Layout:

' Code Module


Sub gen_file(fwrite As String)
Dim lay As Layout
Dim eqn As Equation

Open fwrite For Output As #1

API Scripting Guide 1341


Layout

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

' Check state before


Print #1, "Before Add Equations Count = " & lay.Equations.Count
Print #1, ""

' Add three equations.


lay.Equations.Add2("X=5", 0, 20e-6)
lay.Equations.Add2("Y=6", 0, 10e-6)
lay.Equations.Add2("Z=7", 0, 0)

' Check state after.


Print #1, "After Add Equations Count = " & lay.Equations.Count
Print #1, ""

' Print the state of the resulting equations.


Print #1, "Equation Details:"
For Each eqn In lay.Equations
PrintEqn eqn
Next eqn
Close #1
End Sub

Sub PrintEqn(ByRef eqn As Equation)


Print #1, "Active Index = " & eqn.ActiveIndex
Print #1, "Affects Layout = " & eqn.AffectsLayout
Print #1, "Constrain = " & eqn.Constrain
Print #1, "Data Type = " & eqn.DataType
Print #1, "Description = " & eqn.Description
Print #1, "Distribution = " & eqn.Distribution
Print #1, "Enabled = " & eqn.Enabled
Print #1, "Expression = " & eqn.Expression
Print #1, "Lower Cosntraint = " & eqn.LowerConstraint
Print #1, "Num Sub Expressions = " & eqn.NumSubexpressions
Print #1, "Optimize = " & eqn.Optimize
Print #1, "Optimize Yield = " & eqn.OptimizeYield
Print #1, "Propagation Mode = " & eqn.PropagationMode
Print #1, "Selected = " & eqn.Selected
Print #1, "Stat Variation = " & eqn.StatVariation
Print #1, "Stat Variation 2 = " & eqn.StatVariation2
Print #1, "Step Size = " & eqn.StepSize
Print #1, "Tol In Percent = " & eqn.TolInPercent
Print #1, "Unit Type = " & eqn.UnitType
Print #1, "Upper Constraint = " & eqn.UpperConstraint
Print #1, "Variable Type = " & eqn.VariableType
Print #1, "Exression Count = " & eqn.Expressions.Count
Print #1, ""
End Sub

The following code adds an Equation Expression to a Layout:

Sub gen_file(fwrite As String)


Dim lay As Layout

1342 NI AWR Design Environment


Layout

Dim eqn As Equation


Dim expr As EquationExpression

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

Set eqn = lay.Equations.Add2("X=5", 0, 10e-6)


eqn.AddSubexpression("Y=6")
eqn.AddSubexpression("Z=7")

Print #1, "Expression Count = " & eqn.Expressions.Count

' Print resulting expressions


Print #1, "Resulting expressions:"
For Each expr In eqn.Expressions
PrintExpr expr
Next expr
Close #1
End Sub

Sub PrintExpr(ByRef expr As EquationExpression)


Print #1, "Expression = " & expr.Expression
Print #1, "Affects Layout = " & expr.AffectsLayout
Print #1, "Constraint = " & expr.Constrain
Print #1, "Data Type = " & expr.DataType
Print #1, "Distribution = " & expr.Distribution
Print #1, "Enabled = " & expr.Enabled
Print #1, "Exported = " & expr.Exported
Print #1, "Has Error = " & expr.HasError
Print #1, "Independent = " & expr.Independent
Print #1, "Lower Constraint = " & expr.LowerConstraint
Print #1, "Optimize = " & expr.Optimize
Print #1, "Propagation Mode = " & expr.PropagationMode
Print #1, "Stat Variation = " & expr.StatVariation
Print #1, "Stat Variation 2 = " & expr.StatVariation2
Print #1, "Step Size = " & expr.StepSize
Print #1, "Tol In Percent = " & expr.TolInPercent
Print #1, "Tune = " & expr.Tune
Print #1, "Unit Type = " & expr.UnitType
Print #1, "Upper Constraint = " & expr.UpperConstraint
Print #1, "Use Statistics = " & expr.UseStatistics
Print #1, " HasError = " & expr.HasError
Print #1, "Variable Type = " & expr.VariableType
Print #1, ""
End Sub

The following code adds an Equation referenced to a Layout:

' Code Module


Sub gen_file(fwrite As String)
Dim lay As Layout
Dim eqn As Equation

Open fwrite For Output As #1

API Scripting Guide 1343


Layout

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

' Check state before


Print #1, "Before Add Equations Count = " & lay.Equations.Count
Print #1, ""

' Add three equations each one references the previous.


lay.Equations.Add2("X=5", 0, 20e-6)
lay.Equations.Add2("Y=X", 0, 10e-6)
lay.Equations.Add2("Z=Y", 0, 0)

' Check state after.


Print #1, "After Add Equations Count = " & lay.Equations.Count
Print #1, ""

' Print the state of the resulting equations.


Print #1, "Equation Details:"
For Each eqn In lay.Equations
PrintEqn eqn
Next eqn
Close #1
End Sub

The following code accesses an equation in Layout. The code includes the PrintEqn equation previously described.

Sub gen_file(fwrite As String)


Dim lay As Layout
Dim eqn As Equation

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
For Each eqn In lay.Equations
PrintEqn eqn
Next eqn
Close #1
End Sub

The following code accesses an Equation by Expression in Layout:

Dim lay As Layout


Dim eqn As Equation
Dim eqn2 As Equation

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
For Each eqn In lay.Equations
Set eqn2 = lay.Equations(eqn.Expression)
If eqn2 Is Nothing Then

1344 NI AWR Design Environment


Layout

Print #1, "Could Not Find " & eqn.Expression & " by Expression"
Else
Print #1, "Found " & eqn.Expression & " by Expression"
End If
Next eqn
Close #1

The following code accesses an Equation in Layout by a variable name:

Dim lay As Layout


Dim eqn As Equation
Dim eqn2 As Equation
Dim varName As String

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
For Each eqn In lay.Equations
varName = Left(eqn.Expression, InStr(1, eqn.Expression, "=") - 1)
Set eqn2 = lay.Equations(varName)
If eqn2 Is Nothing Then
Print #1, "Could Not Find " & eqn.Expression & " by Name: " & varName
Else
Print #1, "Found " & eqn.Expression & " by Name: " & varName
End If
Next eqn
Close #1

The following code Prints the Equation Enable State:

' Code Module


Sub gen_file(fwrite As String)
Dim lay As Layout
Dim eqn As Equation

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

' Disable each and print the state of all after each change
For Each eqn In lay.Equations
eqn.Enabled = False
PrintEqnEnabledState(lay)
Next eqn

' Enable each and print the state of all after each change.
For Each eqn In lay.Equations
eqn.Enabled = True
PrintEqnEnabledState(lay)
Next eqn

Close #1

API Scripting Guide 1345


Layout

End Sub

Sub PrintEqnEnabledState(ByRef lay As Layout)


Dim eqn As Equation

Print #1, "Equation Enable State:"


For Each eqn In lay.Equations
Print #1, "Equation = " & eqn.Expression & " Enabled = " & eqn.Enabled
Next eqn
Print #1, ""
End Sub

The following code verifies that the Layout Equation exists by expression:

Dim lay As Layout


Dim eqn As Equation

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
For Each eqn In lay.Equations
If lay.Equations.Exists(eqn.Expression) Then
Print #1, "Found " & eqn.Expression & " by Expression"
Else
Print #1, "Could Not Find " & eqn.Expression & " by Expression"
End If
Next eqn
Close #1

The following code verifies that the Equation Expression exists by variable name:

Dim lay As Layout


Dim eqn As Equation
Dim expr As EquationExpression
Dim expr2 As EquationExpression
Dim varName As String

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
For Each eqn In lay.Equations
For Each expr In eqn.Expressions
varName = Left(expr.Expression, InStr(1, expr.Expression, "=") - 1)
Set expr2 = eqn.Expressions(varName)
If expr2 Is Nothing Then
Print #1, "Could not find expression " & expr.Expression & " by var Name: " & varName
Else
Print #1, "Found expression " & expr.Expression & " by var Name: " & varName
End If
Next expr

1346 NI AWR Design Environment


Layout

Next eqn
Close #1

The following code accesses the Layout Equation Expression:

Sub gen_file(fwrite As String)


Dim lay As Layout
Dim eqn As Equation
Dim expr As EquationExpression

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
For Each eqn In lay.Equations
For Each expr In eqn.Expressions
PrintExpr expr
Next expr
Next eqn
Close #1
End Sub

The following code accesses the Layout Expression by expression. This code includes the PrintExpr expression previously
described.

Dim lay As Layout


Dim eqn As Equation
Dim expr As EquationExpression
Dim expr2 As EquationExpression

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
For Each eqn In lay.Equations
For Each expr In eqn.Expressions
Set expr2 = eqn.Expressions(expr.Expression)
If expr2 Is Nothing Then
Print #1, "Could not find " & expr.Expression & " by Expression"
Else
Print #1, "Found " & expr.Expression & " by Expression"
End If
Next expr
Next eqn
Close #1

The following code accesses the Layout Equation Expression by a variable name:

Dim lay As Layout


Dim eqn As Equation
Dim expr As EquationExpression
Dim expr2 As EquationExpression

API Scripting Guide 1347


Layout

Dim varName As String

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
For Each eqn In lay.Equations
For Each expr In eqn.Expressions
varName = Left(expr.Expression, InStr(1, expr.Expression, "=") - 1)
Set expr2 = eqn.Expressions(varName)
If expr2 Is Nothing Then
Print #1, "Could not find expression " & expr.Expression & " by var Name: " & varName
Else
Print #1, "Found expression " & expr.Expression & " by var Name: " & varName
End If
Next expr
Next eqn
Close #1

The following code enables a Layout Equation Expression:

' Code Module


Sub gen_file(fwrite As String)
Dim lay As Layout
Dim eqn As Equation
Dim eqnExpr As EquationExpression

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
Set eqn = lay.Equations(1)

' Disable each expression and print state of all expressions after each.
For Each eqnExpr In eqn.Expressions
eqnExpr.Enabled = False
PrintEqnExprState(eqn)
Next eqnExpr

' Enable each expression and print state of all expressions after each
For Each eqnExpr In eqn.Expressions
eqnExpr.Enabled = True
PrintEqnExprState(eqn)
Next eqnExpr

Close #1
End Sub

Sub PrintEqnExprState(ByRef eqn As Equation)


Dim eqnExpr As EquationExpression

Print #1, "Equation Expression State:"


For Each eqnExpr In eqn.Expressions

1348 NI AWR Design Environment


Layout

Print #1, "Expression = " & eqnExpr.Expression & " Enabled = " & eqnExpr.Enabled
Next eqnExpr
Print #1, ""
End Sub

The following code includes a Layout Equation Expression existence by Expression:

Dim lay As Layout


Dim eqn As Equation
Dim expr As EquationExpression

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
For Each eqn In lay.Equations
For Each expr In eqn.Expressions
If eqn.Expressions.Exists(expr.Expression) Then
Print #1, "Found " & expr.Expression & " by Expression"
Else
Print #1, "Could not find " & expr.Expression & " by Expression"
End If
Next expr
Next eqn
Close #1

The following code includes a Layout Equation Expression existence by Variable Name:

Dim lay As Layout


Dim eqn As Equation
Dim expr As EquationExpression
Dim varName As String

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
For Each eqn In lay.Equations
For Each expr In eqn.Expressions
varName = Left(expr.Expression, InStr(1, expr.Expression, "=") - 1)
If eqn.Expressions.Exists(varName) Then
Print #1, "Found expression " & expr.Expression & " by varName: " & varName
Else
Print #1, "Could not find " & expr.Expression & " by varName: " & varName
End If
Next expr
Next eqn
Close #1

The following code accesses a Layout Equation Subexpression:

Dim lay As Layout


Dim eqn As Equation

API Scripting Guide 1349


Layout

Dim expr As EquationExpression

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
For Each eqn In lay.Equations
For i = 1 To eqn.NumSubexpressions
Print #1, eqn.Subexpression(i)
Next i
Next eqn
Close #1

The following code removes a Layout Equation by Variable Name:

Dim lay As Layout


Dim eqn As Equation

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

' Check state before


Print #1, "Before Add Equations Count = " & lay.Equations.Count
Print #1, ""

' Print the state of the resulting equations.


Print #1, "Equation Details Before:"
For Each eqn In lay.Equations
PrintEqn eqn
Next eqn

' Add three equations.


lay.Equations.Remove("X")
lay.Equations.Remove("Y")
lay.Equations.Remove("Z")

' Check state after.


Print #1, "After Add Equations Count = " & lay.Equations.Count
Print #1, ""

' Print the state of the resulting equations.


Print #1, "Equation Details After:"
For Each eqn In lay.Equations
PrintEqn eqn
Next eqn
Close #1
End Sub

The following code removes a Layout Equation Expression by Expression:

' Code Module


Sub gen_file(fwrite As String)
Dim lay As Layout

1350 NI AWR Design Environment


Layout

Dim eqn As Equation


Dim expr As EquationExpression

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

Set eqn = lay.Equations(1)

eqn.Expressions.Remove("X=5")

Print #1, "Expression Count = " & eqn.Expressions.Count

' Print resulting expressions


Print #1, "Resulting expressions:"
For Each expr In eqn.Expressions
PrintExpr expr
Next expr
Close #1
End Sub

The following code adds an Equation to a Layout using the Invoke Command:

' Code Module


Sub gen_file(fwrite As String)
Dim lay As Layout
Dim eqn As Equation

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
Print #1, "Before Equation Count = " & lay.Equations.Count

' Use the InsertEquation command to add a command object.


lay.InvokeCommand("InsertEquation", Array("X=5", 0, 0))

' Verify that we have an equation in the collection.


Print #1, "After Equation Count = " & lay.Equations.Count
Print #1, "Equation Details:"
For Each eqn In lay.Equations
PrintEqn eqn
Next eqn

Close #1
End Sub

The following code adds an Equation and Undo/Redo to Layout using Invoke Commands:

Sub gen_file(fwrite As String)


Dim lay As Layout
Dim eqn As Equation

API Scripting Guide 1351


Layout

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
Print #1, "Before Insert Equation Count = " & lay.Equations.Count
Print #1, ""

' Use the InsertEquation command to add a command object.


lay.InvokeCommand("InsertEquation", Array("X=5", 0, 0))

'Verify that we have an Equation In the collection.


Print #1, "After Insert Equation Count = " & lay.Equations.Count
Print #1, "Equation Details:"
For Each eqn In lay.Equations
PrintEqn eqn
Next eqn
Print #1, ""
Set eqn = Nothing

' Perform an undo and check that we removed the equation object.
lay.InvokeCommand("EditUndo")
Print #1, "After Undo Equation Count = " & lay.Equations.Count
Print #1, ""

' Perform a redo and check that we added the equation object back.
lay.InvokeCommand("EditRedo")
Print #1, "After Redo Equation Count = " & lay.Equations.Count
Print #1, "Equation Details:"
For Each eqn In lay.Equations
PrintEqn eqn
Next eqn
Print #1, ""
Set eqn = Nothing

Close #1
End Sub

The following code Copy/Paste an Equation from Schematic to Layout using Invoke Commands method:

Sub Main
Dim lay As Layout
Dim schem As Schematic

Open fwrite For Output As #1

Set schem = Project.Schematics("SCH1")


Set lay = schem.Layout

PrintSchemEquations schem, "Schematic Equations Before Copy/Paste"


PrintLayEquations lay, "Layout Equations Before Copy/Paste"

schem.Equations(1).Selected = True
schem.InvokeCommand("EditCopy")
lay.InvokeCommand("EditPaste", Array(0.0, 0.0))

1352 NI AWR Design Environment


Layout

PrintSchemEquations schem, "Schematic Equations After Copy/Paste"


PrintLayEquations lay, "Layout Equations After Copy/Paste"

End Sub

Sub PrintSchemEquations(ByRef schem As Schematic, title As String)


Dim eqn As Equation

Debug.Print title
Debug.Print "Equation Count = " & schem.Equations.Count
For Each eqn In schem.Equations
Debug.Print eqn.Expression
Next eqn
Debug.Print ""

End Sub

Sub PrintLayEquations(ByRef lay As Layout, title As String)


Dim eqn As Equation

Debug.Print title
Debug.Print "Equation Count = " & lay.Equations.Count
For Each eqn In lay.Equations
Debug.Print eqn.Expression
Next eqn
Debug.Print ""
End Sub

You can also use Cut/Paste an Equation from Schematic to Layout using Invoke Commands method. InvokeCommands
methods Undo/Redo also can be useful.

API command to do Draw > Flatten Cell

A flatten method for the API drawing object allows users to flatten objects in layout similar to what is available from
the Layout's Draw -> Flatten Cell but a little more flexible since this can be used on drawing objects supporting things
like Route Objects and plated dumb shapes.

There are a couple of ways of flattening the selected objects could be handled. First, you can ask each object if it is
selected prior to calling flatten:

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject

Set lay = Project.Schematics("Schematic 1").Layout

For Each objDraw In lay.DrawingObjects


If (objDraw.Selected) Then
objDraw.Flatten
End If

Next objDraw

API Scripting Guide 1353


Layout

End Sub

Second, you can traverse the selected objects in a layout and flatten them. (This is more efficient since you don't have
to go over all the objects in layout):

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject

Set lay = Project.Schematics("Schematic 1").Layout

For Each objDraw In lay.SelectedObjects


objDraw.Flatten
Next objDraw

End Sub

To flatten artwork cell in layout with hierarchy we can use InvokeCommand with zero arguments, indicating that the
command should flatten all levels of hierarchy. It turns out that we allow this command to be invoked with no arguments
as well as a single argument which specifies the flatten level. To flatten all levels of hierarchy use the following code:

Sub Main
Dim lay As Layout
Dim ret As Variant
Dim dl As DrawingLayer
Dim objDraw As DrawingObject

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

Debug.Print "Layout Name = " &amp; lay.Name

PrintDrawingObjects lay, "Before Invoke Flatten Command"

lay.SelectedObjects.AddAll
lay.InvokeCommand("CellFlatten")

PrintDrawingObjects lay, "After Invoke Flatten Command"


End Sub

Sub PrintDrawingObjects(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject

Debug.Print title
Debug.Print "DrawingObjects Count = " &amp; lay.DrawingObjects.Count
For Each objDraw In lay.DrawingObjects
PrintDrawingObject objDraw
Debug.Print ""
Next objDraw
Debug.Print ""
End Sub

1354 NI AWR Design Environment


Layout

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " &amp; drawingObj.InfoText
Debug.Print "Selected = " & drawingObj.Selected
Debug.Print "Flipped = " & drawingObj.Flipped
Debug.Print "Rotation = " & drawingObj.RotationAngle
Debug.Print "Frozen = " & drawingObj.Frozen
Debug.Print "Base Pos = { x = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePosition.
Debug.Print "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)

End Sub

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Debug.Print "Parameters:"
For Each param In params
Debug.Print param.Name & " = " & param.ValueAsString
Next param

End Sub

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Debug.Print "Attributes:"
For Each attr In attrs
Debug.Print attr.Name & " = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Debug.Print "Boundary:"
Debug.Print "Left = " & bound.Left
Debug.Print "Right = " & bound.Right
Debug.Print "Top = " & bound.Top
Debug.Print "Bottom = " & bound.Bottom
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Debug.Print "Vertices:"
For Each vert In verts
Debug.Print "{ x= " & vert.x & ", y= " & vert.y & " }"
Next vert
End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Debug.Print "Edit Handles:"
For Each eh In ehs
Debug.Print "{ x= " & eh.Position.x & ", y= " & eh.Position.y & " }"
Next eh

API Scripting Guide 1355


Layout

End Sub

To flatten certain level in hierarchy use the following code:

lay.SelectedObjects.AddAll
lay.InvokeCommand("CellFlatten", Array(1000))

Snapshot

You cannot directly add Shapes to a Layout, but you can create a "snapshot" and then add Shapes to the snapshot. You
can use the snapshot for export and other operations. The NI AWR SDE does not currently support a Shapes collection
directly off of the Layout because many of the Shapes in Layout are programmatic cells. It is impossible to get the Shapes
of a programmatic cell directly, without first flattening the cell. Once the cell is flattened, you can manipulate the vertices
of the Shapes and see the edits in the Layout. Creating a snapshot flattens these cells into their raw Shapes, after which
you can work with the Shapes. A snapshot acts as a Layout copy that is free of binds to any Schematic.

The following code example works with a snapshot:

Dim lay As Layout


Dim via As Shape
Dim snap As Snapshot
Dim dlName As String
Dim numshapes As Long
Dim numvert As Long
DlName = "Thick Metal"
Set lay = Project.Schematic(2).Layout
Set snap = lay.CreateSnapshot
numshapes = snap.Shapes.Count
numvert = 0
For i = 1 To numshapes
If snap.Shapes(i).DrawingLayer.Name = DlName Then
Set via = snap.Shapes(i)
numvert = snap.Shapes(i).Vertices.Count
For j = 1 To numvert
Debug.Print via.Vertices(j).x;vbTab; via.Vertices(j).y
Next j
End If
Next i

As shown in the code, you can get a collection of Vertices from the Shape. The collection of Vertices represents the
points in the object. You can use the Add method to add a new Vertex to the Vertices collection and so to the Shape
object. The Add method takes an X value and a Y value and returns a reference to the new Vertex object that is created,
so in the Add method the third parameter is the return value. This allows you to add a vertex to an object and then later
move the vertex by changing its X and Y values.

The following example shows this capability:

Dim newVertex As Vertex


' Add a new Vertex to the shape at x = 1.0 and y = 2.0
' Note here the return value is a reference to the newly created vertex object.
Set newVertex = snap.Shapes(1).Vertices.Add(1.0, 2.0)

1356 NI AWR Design Environment


Layout

' Sometime later, move the vertex to x = 3.0 and y = 5.0


newVertex.x = 3.0
newVertex.y = 5.0

The following script is an example of accessing hierarchical Path information for Shapes produced from a Drawing
Object contained in a Layout snap shot.

The script gets information for Shapes produced from PCells contained in levels of hierarchy with a hierarchical Path
from the initial Object, down to the lowest level PCell that produced the Shapes.

' Code Module


Sub Main
Dim lay As Layout
Dim snap As Snapshot
Dim objDraw As DrawingObject
Dim shp As Shape

Debug.Clear
Set lay = Project.Schematics("top").Layout
Set snap = lay.CreateSnapshot

For Each shp In snap.Shapes


If (shp.Type ne 6) Then
Debug.Print "Shape, Type = " & shp.Type & ", Path = " & shp.HierarchicalPath
End If
Next shp
End Sub

This code generates the following output: Shape, Type = 1, Path = top:MLIN.TL1,0 Shape, Type = 1, Path =
top:MLIN.TL1,0 Shape, Type = 1, Path = top:MLIN.TL1,0 Shape, Type = 1, Path = Shape, Type = 1, Path = Shape,
Type = 1, Path = top:SUBCKT.S1,0/middle:SUBCKT.S1,0/bottom:MLIN.TL1,0 Shape, Type = 1, Path =
top:SUBCKT.S1,0/middle:SUBCKT.S1,0/bottom:MLIN.TL2,0

The following scripts are examples of providing some layer based shape modification and boolean operations to API
Layout snapshot object.

In the next code we apply snapshot method for union between layers and output to a single destination layer. This allows
two source layers to be merged and output on a second layer. It also supports union of shapes in a single layer if all layers
are the same.

' Code Module


Sub Main
Dim lay1 As Layout
Dim lay2 As Layout
Dim snap As Snapshot

Set lay1 = Project.Schematics("SCH1").Layout


Set lay2 = Project.Schematics("SCH2").Layout

PrintDrawingObjectState lay1, "Before Shape Union and Copy To Layout"

Set snap = lay1.CreateSnapshot

API Scripting Guide 1357


Layout

snap.UnionLayers("Thick Metal", "Nitride Etch", "Cap Bottom")


snap.CopyToLayout(lay2, 0, 0)

PrintDrawingObjectState lay2, "After Shape Union and Copy to Layout

End Sub

Sub PrintDrawingObjectState(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject

Debug.Print title
For Each objDraw In lay.DrawingObjects
Debug.Print "Boundary = { left = " & objDraw.Boundary.Left * 1e6 & ", Top = " & objDraw.Boundar
PrintDrawObjShapes objDraw
Next objDraw
Debug.Print ""

End Sub

Sub PrintDrawObjShapes(ByRef objDraw As DrawingObject)


Dim objShape As Shape
Dim vtx As Vertex
Dim index As Integer

For Each objShape In objDraw.Shapes


Debug.Print "Drawing Layer = " & objShape.DrawingLayer.Name
Debug.Print "Vertex Count = " & objShape.Vertices.Count
index = 1
For Each vtx In objShape.Vertices
Debug.Print "Vertex[" & index & "]= { x = " & vtx.x * 1e6 & ", y = " & vtx.y * 1e6 & " }"
index = index + 1
Next vtx
Debug.Print ""
Next objShape
Debug.Print ""
End Sub

The following script is an example of providing API Snapshot method for union shapes both by layer and and merge all
to a destination layer.

All shapes should be merge and output on the destination layer.

' Code Module


Sub Main
Dim lay1 As Layout
Dim lay2 As Layout
Dim snap As Snapshot

Set lay1 = Project.Schematics("SCH1").Layout


Set lay2 = Project.Schematics("SCH2").Layout

PrintDrawingObjectState lay1, "Before Shape Union and Copy To Layout"

Set snap = lay1.CreateSnapshot


snap.UnionShapes(mwUST_UnionToDestinationLayer, "Thick Metal")

1358 NI AWR Design Environment


Layout

snap.CopyToLayout(lay2, 0, 0)

PrintDrawingObjectState lay2, "After Shape Union and Copy to Layout


End Sub

The code for PrintDrawingObjectState lay2, "Text" is already shown above.

The following script is an example of providing API a snapshot from the active layout (unless it's the output layout),
then runs Boolean subtract and union to generate the final m1 layer from m1+ and m1-. We can control visibility to turn
on or off for all layers. We had an issue with the layout ellipse object not drawing into the shape buffer surface or shape
flatten surface if the layer was not visible. The ellipse does a check that setting the layer succeeds before drawing. This
is normally a signal that the layer is not visible so there is no need to draw. In some cases, though the layer visibility is
not important for the drawing operation required. For these cases we have a drawing surface mode to draw all objects.
It seems as though the flatten shape surface and shape buffer surface should have this by default, so we added a flag
which is enabled by default to put these surfaces in Draw All Objects mode.

Option Explicit
Sub Run_Snapshot_with_layers_hidden
SetLayerVis(False)
Call RunSnapshot
SetLayerVis(True)
End Sub
Sub Run_Snapshot_with_layers_visible
SetLayerVis(True)
Call RunSnapshot
End Sub

'$Menu=Hidden
Sub RunSnapshot
Dim schIn As Schematic, schOut As Schematic, lay As Layout, s As Snapshot
Dim layA As String, layAm As String, layAp As String, layTmp As String
layA = "m1"
layAm = "m1-"
layAp = "m1+"

Set schIn = GetActiveSchematic()


Set schOut = MakeOutputSchem(schIn)

'SetLayerVis(False)

Set lay = schIn.Layout

Set s = lay.CreateSnapshot

Dim x0 As Double, y0 As Double


x0 = s.Boundary.Left
y0 = s.Boundary.Bottom

'subtract - layer from + layer, and union with nominal layer


s.SubtractLayers(layAp, layAm, layAp)
s.UnionLayers(layAp, layA, layA)
s.CopyLayerToLayout(schOut.Layout, layA, x0, y0, mwPJ_BBoxLowerLeft)
's.CopyLayerToLayout(schOut.Layout, layAm, x0, y0, mwPJ_BBoxLowerLeft)
's.CopyLayerToLayout(schOut.Layout, layAp, x0, y0, mwPJ_BBoxLowerLeft)

API Scripting Guide 1359


Layout

schOut.Layout.Views(1).ViewAll
schIn.Windows(1).Activate
End Sub
Private Function SetLayerVis(isVis As Boolean)
Dim drwLays As DrawingLayers, dl As DrawingLayer
Set drwLays = Project.ProcessDefinitions(1).LayerSetup.DrawingLayers
drwLays.AllVisible=isVis
End Function

Private Function GetActiveSchematic As Schematic


Dim checkedAll As Boolean, s As Schematic, noSchem As Boolean
noSchem = False

Set s = Project.Schematics.ActiveSchematic
If (s Is Nothing) Then
noSchem = True
ElseIf s.Name = "output" Then
noSchem = True
End If
If noSchem Then
MsgBox ("Open a schematic layout (besides 'output') and run the script. The result will appear in
Exit All
End If

Set GetActiveSchematic = s

End Function

Private Function MakeOutputSchem(s As Schematic) As Schematic


Dim newSch As Schematic, newName As String
newName = "output"
If Project.Schematics.Exists(newName) Then
Set newSch = Project.Schematics(newName)
newSch.Layout.SelectedObjects.AddAll
newSch.Layout.InvokeCommand("EditDelete")
Else
Set newSch = Project.Schematics.Add(newName)
End If
While newSch.Windows.Count > 0
newSch.Windows(1).Close
Wend
newSch.NewWindow(mwWT_SchematicLayout)
Set MakeOutputSchem = newSch
End Function

When performing boolean operations in SPP Rules or DRC Rules, shapes on A and B input layers are retained (unless
A/B is the 'target' layer; the behavior then is optional in SPP rules, and we believe that DRC just overwrites.) Non-target
layers are always retained.

In Snapshot api,we added methods UnionLayersEx(), SubtractLayersEx(), IntersectLayersEx(), ExclusiveOrLayersEx()


and hided the non-Ex versions of these methods.

The new methods have optional boolean params 'keepLayer1', 'keepLayer2' (defaulting to true). These allow the user to
retain the original layer shapes after the boolean operation runs.

1360 NI AWR Design Environment


Layout

We added 'mwPJ_SameOrigin' as a new enum value to the enum_mwPlacementJustfication enumeration. This option
adds no additional offset to the shapes (except any x,y specified in the CopyToLayout(), CopyToCellEditor(),
CopyToSnapshot(), CopyLayerToLayout(), CopyLayerToCellEditor(), or CopyLayerToSnapshot() methods. In the above
CopyTo* methods, pulled out a free function GetOffsetForCopy() which takes x,y, justification, and boundary, and
returns (out param) the offset.

In the following code we apply snapshot method for copy all kind of text objects. We need a schematic with some shapes
on layer Default and Copper03. There are Polygons, Rectangles, poly- and non-poly text objects. The code should copy
all shapes on Copper03 and Default 50um to the right, using the Snapshot API. The newly copied shapes should have
all shapes, including the non-poly text objects:

Option Explicit
Sub Main
Dim sch As Schematic, lay As Layout, s As Snapshot
Dim layA As String, layAm As String, layAp As String, layTmp As String, layDef As String
Dim x0 As Double, y0 As Double

layA = "Copper03"
layDef = "Default"

Set lay = Project.Schematics("Uses_2nd_lpf").Layout

Set s = lay.CreateSnapshot

x0 = s.Boundary.Left
y0 = s.Boundary.Bottom

s.CopyLayerToLayout(lay,layA, x0 + 50e-6, y0, mwPJ_BBoxLowerLeft)


s.CopyLayerToLayout(lay,layDef, x0 + 50e-6, y0, mwPJ_BBoxLowerLeft)
End Sub

In the following code we apply snapshot method for copy and resize shapes to layer:

' Code Module


Sub Main
Dim lay1 As Layout
Dim lay2 As Layout
Dim snap As Snapshot

Set lay1 = Project.Schematics("SCH1").Layout


Set lay2 = Project.Schematics("SCH2").Layout

PrintDrawingObjectState lay1, "Before Shape Resize and Copy To Layout"

Set snap = lay1.CreateSnapshot


snap.CopyShapesToLayer("Thick Metal", "Cap Bottom")
snap.CopyShapesToLayer("Nitride Etch", "Cap Bottom")
snap.ResizeLayerShapes(-10e-6, "Cap Bottom")
snap.CopyToLayout(lay2, 0, 0)

PrintDrawingObjectState lay2, "After Shape Resize and Copy to Layout


End Sub

API Scripting Guide 1361


Layout

The code for PrintDrawingObjectState lay2, "Text" is already shown above.

In the following code shows snapshot methods to copy shapes on a specific layer from a snapshot object to a layout, cell
editor or snapshot:

' Code Module


Sub Main
Dim lay1 As Layout
Dim lay2 As Layout
Dim snap As Snapshot
Dim objDraw As DrawingObject

' lay1 is source lay2 is destination.


Set lay1 = Project.Schematics("SCH1").Layout
Set lay2 = Project.Schematics("SCH2").Layout

' Copy to layout with each bbox justification setting.


' Should form something like an X shape in layout.
Set snap = lay1.CreateSnapshot
snap.CopyLayerToLayout(lay2, "Nitride Etch", 0, 0, mwPJ_BBoxCenter)
snap.CopyLayerToLayout(lay2, "Nitride Etch", 100e-6, 100e-6, mwPJ_BBoxLowerLeft)
snap.CopyLayerToLayout(lay2, "Nitride Etch", 100e-6, -100e-6, mwPJ_BBoxUpperLeft)
snap.CopyLayerToLayout(lay2, "Nitride Etch", -100e-6, 100e-6, mwPJ_BBoxLowerRight)
snap.CopyLayerToLayout(lay2, "Nitride Etch", -100e-6, -100e-6, mwPJ_BBoxUpperRight)

' Print the resulting shapes for comparison.


For Each objDraw In lay2.DrawingObjects
PrintDrawingObject objDraw
Next objDraw
End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " & drawingObj.InfoText
Debug.Print "Selected = " & drawingObj.Selected
Debug.Print "Flipped = " & drawingObj.Flipped
Debug.Print "Rotation = " & drawingObj.RotationAngle
Debug.Print "Frozen = " & drawingObj.Frozen
Debug.Print "Base Pos = { x = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePosition.
Debug.Print "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)
PrintVertices(drawingObj.Shapes(1).Vertices)

End Sub

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Debug.Print "Parameters:"
For Each param In params
Debug.Print param.Name & " = " & param.ValueAsString
Next param

1362 NI AWR Design Environment


Layout

End Sub

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Debug.Print "Attributes:"
For Each attr In attrs
Debug.Print attr.Name & " = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Debug.Print "Boundary:"
Debug.Print "Left = " & bound.Left
Debug.Print "Right = " & bound.Right
Debug.Print "Top = " & bound.Top
Debug.Print "Bottom = " & bound.Bottom
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Debug.Print "Vertices:"
For Each vert In verts
Debug.Print "{ x= " & vert.x * 1e6 & ", y= " & vert.y * 1e6 & " }"
Next vert
End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Debug.Print "Edit Handles:"
For Each eh In ehs
Debug.Print "{ x= " & eh.Position.x * 1e6 & ", y= " & eh.Position.y * 1e6 & " }"
Next eh
End Sub

The code for snapshot copy layer to CellEditor:

Dim lay1 As Layout


Dim snap As Snapshot
Dim objDraw As DrawingObject
Dim libCell As Cell
Dim cellEdit As CellEditor

Open fwrite For Output As #1

' lay1 is source cellEdit is destination.


Set lay1 = Project.Schematics("SCH1").Layout
Set libCell = Project.CellLibraries("New_Gdsii_Lib").Cells("New_GDS_Cell")
Set cellEdit = libCell.EditCell

' Copy to layout with each bbox justification setting.


' Should form something like an X shape in layout.
Set snap = lay1.CreateSnapshot
snap.CopyLayerToCellEditor(cellEdit, "Nitride Etch", 0, 0, mwPJ_BBoxCenter)
snap.CopyLayerToCellEditor(cellEdit, "Nitride Etch", 100e-6, 100e-6, mwPJ_BBoxLowerLeft)

API Scripting Guide 1363


Layout

snap.CopyLayerToCellEditor(cellEdit, "Nitride Etch", 100e-6, -100e-6, mwPJ_BBoxUpperLeft)


snap.CopyLayerToCellEditor(cellEdit, "Nitride Etch", -100e-6, 100e-6, mwPJ_BBoxLowerRight)
snap.CopyLayerToCellEditor(cellEdit, "Nitride Etch", -100e-6, -100e-6, mwPJ_BBoxUpperRight)

The code for snapshot copy to CellEditor:

Set snap = lay1.CreateSnapshot

The code for snapshot copy to snapshot:

Set snap = lay1.CreateSnapshot


Set snap2 = cellEdit.CreateSnapshot
snap2.CopyToSnapshot(snap, 0, 0, mwPJ_BBoxLowerRight)
snap.CopyToLayout(lay2, 0, 0, mwPJ_BBoxCenter)
snap.CopyToLayout(lay2, 100e-6, 100e-6, mwPJ_BBoxLowerLeft)
snap.CopyToLayout(lay2, 100e-6, -100e-6, mwPJ_BBoxUpperLeft)
snap.CopyToLayout(lay2, -100e-6, 100e-6, mwPJ_BBoxLowerRight)
snap.CopyToLayout(lay2, -100e-6, -100e-6, mwPJ_BBoxUpperRight)

API has support for resize-copy to the list of Boolean operations supported by the snapshot API object. To make the
snapshot more useful for shape processing we'd implemented a number of Boolean operations that can be performed on
the shapes in a snapshot. We added Resize-Copy method to the list which can be very useful for operations that require
shapes on a layer to be sized relative to the shapes on a different layer. For example, structures like thin film capacitors.

In the following code we show the new resize-copy method of the API snapshot object. The test resizes and copies shapes
from two different layers and moves them to the same destination layer:

Sub Main
Dim lay1 As Layout
Dim lay2 As Layout
Dim snap As Snapshot

Set lay1 = Project.Schematics("SCH1").Layout


Set lay2 = Project.Schematics("SCH2").Layout

PrintDrawingObjectState lay1, "Before Shape Resize and Copy To Layout"

Set snap = lay1.CreateSnapshot


snap.ResizeCopyLayerShapes(-10e-6, "Thick Metal", "Cap Bottom")
snap.ResizeCopyLayerShapes(-10e-6, "Nitride Etch", "Cap Bottom")
snap.CopyToLayout(lay2, 0, 0)

PrintDrawingObjectState lay2, "After Shape Resize and Copy to Layout


End Sub

The code for PrintDrawingObjectState lay1, "Text" is already shown above.

In the next code we apply snapshot method to delete layer shapes:

1364 NI AWR Design Environment


Layout

Sub Main
Dim lay1 As Layout
Dim lay2 As Layout
Dim snap As Snapshot

Set lay1 = Project.Schematics("SCH1").Layout


Set lay2 = Project.Schematics("SCH2").Layout

Set snap = lay1.CreateSnapshot


snap.DeleteLayerShapes("Thick Metal")
snap.DeleteLayerShapes("Nitride Etch")
snap.CopyToLayout(lay2, 0, 0)

PrintDrawingObjectState lay2, "After Delete Layer Shapes


End Sub

The code for PrintDrawingObjectState lay2, "Text" is already shown above.

In the following code we apply snapshot method to move shapes to layer:

Sub Main
Dim lay1 As Layout
Dim lay2 As Layout
Dim snap As Snapshot

Set lay1 = Project.Schematics("SCH1").Layout


Set lay2 = Project.Schematics("SCH2").Layout

PrintDrawingObjectState lay1, "Before Shape Resize and Copy To Layout"

Set snap = lay1.CreateSnapshot


snap.MoveShapesToLayer("Thick Metal", "Cap Bottom")
snap.MoveShapesToLayer("Nitride Etch", "Cap Bottom")
snap.CopyToLayout(lay2, 0, 0)

PrintDrawingObjectState lay2, "After Shape Resize and Copy to Layout

End Sub

The code for PrintDrawingObjectState lay2, "Text" is already shown above.

API snapshot boolean operation methods include intersection, exclusive or and subtraction of shapes on individual layers
and between layers. In the following code we show API snapshot XOR when moving shapes from multiple layers to a
destination layer and performing XOR operations on the resulting shapes:

Set lay1 = Project.Schematics("SCH1").Layout


Set lay2 = Project.Schematics("SCH2").Layout

PrintDrawingObjectState lay1, "Before Shape XOR and Copy To Layout"

Set snap = lay1.CreateSnapshot


snap.ExclusiveOrShapes(mwUST_UnionToDestinationLayer, "Thick Metal")

API Scripting Guide 1365


Layout

snap.CopyToLayout(lay2, 0, 0)

PrintDrawingObjectState lay2, "After Shape XOR and Copy to Layout

In the following code we show API snapshot intersection shapes and moving them to a destination layer:

Set snap = lay1.CreateSnapshot


snap.IntersectShapes(mwUST_UnionToDestinationLayer, "Thick Metal")
snap.CopyToLayout(lay2, 0, 0)

The following script is an example of exporting shapes from a snapshot and then re-importing the resulting library.

The script creates a snapshot from a schematic layout. Then exports this snapshot as a GDSII file, re-imports the resulting
GDSII file and dumps out the resulting shape information from the imported file.

' Code Module


Sub Main
Dim cellLib As CellLibrary
Dim libCell As Cell
Dim cellEd As CellEditor
Dim objDraw As DrawingObject
Dim libPath As String
Dim snap As Snapshot

libPath = Project.Path + "Cell_Lib_SnapShot.gds"


delete_if_exists(libPath)
Set snap = Project.Schematics("SCH1").Layout.CreateSnapshot
Debug.Print "Snap Shot Shape Count = " & snap.Shapes.Count
snap.Export(libPath, 1, "Cell_Lib", "SCH1")
Project.CellLibraries.Import("Cell_Lib", libPath, mwCLT_GDS)
Set libCell = Project.CellLibraries("Cell_Lib").Cells("SCH1")
Set cellEd = libCell.EditCell

For Each objDraw In cellEd.DrawingObjects


PrintDrawingObject objDraw
Next objDraw

End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " & drawingObj.InfoText
Debug.Print "Selected = " & drawingObj.Selected
Debug.Print "Flipped = " & drawingObj.Flipped
Debug.Print "Rotation = " & drawingObj.RotationAngle
Debug.Print "Frozen = " & drawingObj.Frozen
Debug.Print "Base Pos = { x = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePosit
Debug.Print "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)
PrintVertices(drawingObj.Shapes(1).Vertices)

1366 NI AWR Design Environment


Layout

End Sub

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Debug.Print "Parameters:"
For Each param In params
Debug.Print param.Name & " = " & param.ValueAsString
Next param

End Sub

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Debug.Print "Attributes:"
For Each attr In attrs
Debug.Print attr.Name & " = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Debug.Print "Boundary:"
Debug.Print "Left = " & bound.Left
Debug.Print "Right = " & bound.Right
Debug.Print "Top = " & bound.Top
Debug.Print "Bottom = " & bound.Bottom
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Debug.Print "Vertices:"
For Each vert In verts
Debug.Print "{ x= " & vert.x * 1e6 & ", y= " & vert.y * 1e6 & " }"
Next vert
End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Debug.Print "Edit Handles:"
For Each eh In ehs
Debug.Print "{ x= " & eh.Position.x * 1e6 & ", y= " & eh.Position.y * 1e6 & " }"
Next eh
End Sub

The following script is an example of CopyToLayout method that allows placing the shapes from a layout snapshot into
another layout. This allows for options like flattening a layout into a snapshot and then placing it into another layout. It
also allows for editing of the shapes in a snapshot and then placement into a layout. The following code performs multiple
copies with varying justification values and then dumps the details of the resulting layout:

' Code Module


Sub Main
Dim lay1 As Layout
Dim lay2 As Layout
Dim snap As Snapshot

API Scripting Guide 1367


Layout

Dim objDraw As DrawingObject

' lay1 is source lay2 is destination.


Set lay1 = Project.Schematics("SCH1").Layout
Set lay2 = Project.Schematics("SCH2").Layout

' Copy to layout with each bbox justification setting.


' Should form something like an X shape in layout.
Set snap = lay1.CreateSnapshot
snap.CopyToLayout(lay2, 0, 0, mwPJ_BBoxCenter)
snap.CopyToLayout(lay2, 100e-6, 100e-6, mwPJ_BBoxLowerLeft)
snap.CopyToLayout(lay2, 100e-6, -100e-6, mwPJ_BBoxUpperLeft)
snap.CopyToLayout(lay2, -100e-6, 100e-6, mwPJ_BBoxLowerRight)
snap.CopyToLayout(lay2, -100e-6, -100e-6, mwPJ_BBoxUpperRight)

' Print the resulting shapes for comparison.


For Each objDraw In lay2.DrawingObjects
PrintDrawingObject objDraw
Next objDraw
End Sub

The code for PrintDrawingObject objDraw already in the example above.

The following script is an example of new method for copying shapes from a layout snapshot to a cell editor. The script
copies a set of shapes obtained from the layout to the cell editor placing them with various orientations at different
locations and then dumps out the resulting shape details:

' Code Module


Sub Main
Dim lay1 As Layout
Dim snap As Snapshot
Dim objDraw As DrawingObject
Dim libCell As Cell
Dim cellEdit As CellEditor

' lay1 is source cellEdit is destination.


Set lay1 = Project.Schematics("SCH1").Layout
Set libCell = Project.CellLibraries("New_Gdsii_Lib").Cells("New_GDS_Cell")
Set cellEdit = libCell.EditCell

' Copy to layout with each bbox justification setting.


' Should form something like an X shape in layout.
Set snap = lay1.CreateSnapshot
snap.CopyToCellEditor(cellEdit, 0, 0, mwPJ_BBoxCenter)
snap.CopyToCellEditor(cellEdit, 100e-6, 100e-6, mwPJ_BBoxLowerLeft)
snap.CopyToCellEditor(cellEdit, 100e-6, -100e-6, mwPJ_BBoxUpperLeft)
snap.CopyToCellEditor(cellEdit, -100e-6, 100e-6, mwPJ_BBoxLowerRight)
snap.CopyToCellEditor(cellEdit, -100e-6, -100e-6, mwPJ_BBoxUpperRight)

' Print the resulting shapes for comparison.


For Each objDraw In cellEdit.DrawingObjects
PrintDrawingObject objDraw
Next objDraw

1368 NI AWR Design Environment


Layout

End Sub

The code for PrintDrawingObject objDraw already in the example above.

The following code is an example new API snapshot facilities including create snapshot from a cell and copy a snapshot
to another snapshot:

' Code Module


Sub Main
Dim lay1 As Layout
Dim lay2 As Layout
Dim snap As Snapshot
Dim snap2 As Snapshot
Dim objDraw As DrawingObject
Dim cellEdit As CellEditor

' lay1 is source lay2 is destination.


Set lay1 = Project.Schematics("SCH1").Layout
Set lay2 = Project.Schematics("SCH2").Layout
Set cellEdit = Project.CellLibraries("New_Gdsii_Lib").Cells("New_GDS_Cell").EditCell

' Copy to layout with each bbox justification setting.


' Should form something like an X shape in layout.
Set snap = lay1.CreateSnapshot
Set snap2 = cellEdit.CreateSnapshot
snap2.CopyToSnapshot(snap, 0, 0, mwPJ_BBoxLowerRight)
snap.CopyToLayout(lay2, 0, 0, mwPJ_BBoxCenter)
snap.CopyToLayout(lay2, 100e-6, 100e-6, mwPJ_BBoxLowerLeft)
snap.CopyToLayout(lay2, 100e-6, -100e-6, mwPJ_BBoxUpperLeft)
snap.CopyToLayout(lay2, -100e-6, 100e-6, mwPJ_BBoxLowerRight)
snap.CopyToLayout(lay2, -100e-6, -100e-6, mwPJ_BBoxUpperRight)

' Print the resulting shapes for comparison.


For Each objDraw In lay2.DrawingObjects
PrintDrawingObject objDraw
Next objDraw

End Sub

Note: we support API method for copying shapes from one snapshot to another to combine them. We provide one
additional copy method which allows shapes from two snapshots to be combined into one. API has the complete the set
of copy operations for snapshot objects in that we can now go from snapshot to cell, snapshot to layout and snapshot to
snapshot. In addition snapshots can be produced from layout and the cell editors. So the results of shape operations
provided for snapshots can be added to layouts and cells and other snapshots.

SendEmail API command with Layout Export

We recommend using full path such as Project.Path & "Filename.gds" to ensure the file is placed where you want it.

The following code demonstrates this feature:

' Code Module

API Scripting Guide 1369


Layout

Sub Main

Dim fso As FileSystemObject


Dim mail As EMail

Set fso = New FileSystemObject

Project.Schematics(1).Layout.Export("Mystery.gds","MMIC GDSII",True)

Set mail = MWOffice.CreateEMail()


mail.ToRecipients="UserName@ni.com"
mail.Subject="test"
MWOffice.SendEMail(mail)

End Sub

Boundary Object

The Boundary object defines the extents of Shapes within a Layout, Cell, and Drawing object. The Boundary object has
numeric values Right, Left, Top, and Bottom; all the Shapes that comprise the object are located within these extents.

The following code demonstrates this feature:

Set lay = Project.Schematics(5).Layout


Debug.Print "Boundary :"
Debug.Print "Bottom = ";lay.Boundary.Bottom;vbTab;"Left = ";
lay.Boundary.Left;vbTab;"Right = ";lay.Boundary.Right;vbTab;"Top = ";
lay.Boundary.Top

Physical NET Collection of Objects

Access to the Net objects is within the Layout views for Schematics. You can also add new nets by using the
CreateRouteRecord and AddRoute methods on the physical net.

The following code shows how to access the Physical Nets FlightLines collection:

Dim schem As Schematic


Dim lay As Layout
Dim phyNet As PhysicalNet
Dim fltLine As FlightLine
Dim index As Integer
Debug.Clear
For Each schem In Project.Schematics
Debug.Print "Looking for flight lines in: " & schem.Name
Set lay = schem.Layout
For Each phyNet In lay.PhysicalNets
Debug.Print vbTab & "Physical Net has " & phyNet.FlightLines.Count & " flight line(s)"
index = 1
For Each fltLine In phyNet.FlightLines
Debug.Print vbTab &vbTab & "Flight Line [" & index & "] = { ";
Debug.Print "x1 = " & fltLine.Begin.x/Project.Units(mwUT_Length).MultValue & ", ";
Debug.Print "y1 = " & fltLine.Begin.y/Project.Units(mwUT_Length).MultValue & ", ";
Debug.Print "x2 = " & fltLine.End.x/Project.Units(mwUT_Length).MultValue & ", ";
Debug.Print "y2 = " & fltLine.End.y/Project.Units(mwUT_Length).MultValue & " }"

1370 NI AWR Design Environment


Layout

index = index + 1
Next fltLine
Next phyNet
Debug.Print
Next schem

This code generates the following output:

Looking for flight lines in: PortName_Ratline


Physical Net has 1 flight line(s)
Flight Line [1] = { x1 = 4, y1 = -5, x2 = 14, y2 = -5 }
Physical Net has 0 flight line(s)
Physical Net has 1 flight line(s)
Flight Line [1] = { x1 = -59, y1 = -5, x2 = -9, y2 = -5 }
Looking for flight lines in: PortName_iNet
Physical Net has 0 flight line(s)
Physical Net has 0 flight line(s)
Physical Net has 0 flight line(s)
Looking for flight lines in: Port_Ratline
Physical Net has 1 flight line(s)
Flight Line [1] = { x1 = -59, y1 = -5, x2 = -9, y2 = -5 }
Physical Net has 1 flight line(s)
Flight Line [1] = { x1 = 4, y1 = -5, x2 = 14, y2 = -5 }
Physical Net has 0 flight line(s)
Looking for flight lines in: Port_iNet
Physical Net has 0 flight line(s)
Physical Net has 0 flight line(s)
Physical Net has 0 flight line(s)
Looking for flight lines in: Top_Ratline_Bottom_Ratline_Port
Physical Net has 0 flight line(s)
Physical Net has 1 flight line(s)
Flight Line [1] = { x1 = -124, y1 = 5, x2 = -46, y2 = 5 }
Looking for flight lines in: Top_Ratline_Bottom_Ratline_PortName
Physical Net has 0 flight line(s)
Physical Net has 1 flight line(s)
Flight Line [1] = { x1 = -80, y1 = -5, x2 = 0, y2 = -5 }
Looking for flight lines in: Top_Ratline_Bottom_iNet_Port
Physical Net has 1 flight line(s)
Flight Line [1] = { x1 = -139, y1 = 5, x2 = -59, y2 = 5 }
Physical Net has 0 flight line(s)
Looking for flight lines in: Top_Ratline_Bottom_iNet_PortName
Physical Net has 1 flight line(s)
Flight Line [1] = { x1 = -87, y1 = -31, x2 = -7, y2 = -31 }
Physical Net has 0 flight line(s)
Looking for flight lines in: Top_iNET_Bottom_iNET_Port
Physical Net has 0 flight line(s)
Physical Net has 0 flight line(s)
Looking for flight lines in: Top_iNet_Bottom_Ratline_Port
Physical Net has 0 flight line(s)
Physical Net has 0 flight line(s)
Looking for flight lines in: Top_iNet_Bottom_Ratline_PortName
Physical Net has 0 flight line(s)
Physical Net has 0 flight line(s)
Looking for flight lines in: Top_iNet_Bottom_iNet_PortName
Physical Net has 0 flight line(s)

API Scripting Guide 1371


Layout

Physical Net has 0 flight line(s)

Some methods for getting and setting the default route property info through the API. The values can be obtained as in
the following script:

' Code Module


Sub Main

Debug.Print "UseHV = " & Project.RoutePropertyInfo.HorizontalVerticalRouting


Debug.Print "Default Width = " & Project.RoutePropertyInfo.DefaultWidth * 1e6
Debug.Print "Horz Width = " & Project.RoutePropertyInfo.HorizontalWidth * 1e6
Debug.Print "Vert Width = " & Project.RoutePropertyInfo.VerticalWidth * 1e6
Debug.Print "Default Line = " & Project.RoutePropertyInfo.DefaultLineType
Debug.Print "Horiz Line = " & Project.RoutePropertyInfo.HorizontalLineType
Debug.Print "Verti Line = " & Project.RoutePropertyInfo.VerticalLineType

End Sub

And the values can be set as in the following script:

' Code Module


Sub Main
Project.RoutePropertyInfo.HorizontalWidth = 30e-6
Project.RoutePropertyInfo.HorizontalLineType = 2
End Sub

The values can be verified by looking at the iNet properties dialog available from the toolbar when a layout is open.
When the values are set they should update the dialog to refect the new settings if it is open.

The properties for segments of a route can be updated by using the segment properties command. The following script
shows how to change a route segment line type:

' Code Module


Sub Main
Dim lay As Layout
Dim physNet As PhysicalNet
Dim Route As Route

Set lay = Project.Schematics("SCH1").Layout

Debug.Print "Physical Net Count = " & lay.PhysicalNets.Count


' Print initial State
Debug.Print "***Before Route Segment Change***"
For Each physNet In lay.PhysicalNets
PrintPhysicalNetDetails physNet
Next physNet

' Double the width of each segment in each route.


For Each physNet In lay.PhysicalNets
ChangeRouteSegLineTypes physNet
Next physNet

1372 NI AWR Design Environment


Layout

lay.Update
lay.Refresh

' Print Resulting state.


Debug.Print "***After Route Segment Change***"
For Each physNet In lay.PhysicalNets
PrintPhysicalNetDetails physNet
Next physNet

End Sub

Sub PrintPhysicalNetDetails(ByRef physNet As PhysicalNet)


Dim rt As Route

Debug.Print "Physical Net = " & physNet.Name


Debug.Print "Route Count = " & physNet.Routes.Count

For Each rt In physNet.Routes


PrintRouteDetails rt
Next rt

End Sub

Sub PrintRouteDetails(ByRef rt As Route)


Dim seg As RouteSegment
Dim index As Integer

index = 1
For Each seg In rt.Segments
PrintSegmentDetails seg
Next seg

Debug.Print "-----------------------------------------------"

End Sub

Sub PrintSegmentDetails(ByRef seg As RouteSegment)


Debug.Print "Begin Point = { x = " & seg.Begin.x * 1e6 & ", y = " & seg.Begin.y * 1e6 &
Debug.Print "Begin Point = { x = " & seg.End.x * 1e6 & ", y = " & seg.End.y * 1e6 & " }"
Debug.Print "Line Type = " & seg.LineType
Debug.Print "Width = " & seg.Width * 1e6
Debug.Print "Shape Count = " & seg.Shapes.Count
Debug.Print "----------"

End Sub

Sub ChangeRouteSegLineTypes(ByRef physNet As PhysicalNet)


Dim rt As Route
Dim seg As RouteSegment
Dim ThickMetal As Integer

' Line type for thick metal in MMIC process


ThickMetal = 0
For Each rt In physNet.Routes
For Each seg In rt.Segments
If seg.LineType ne ThickMetal Then

API Scripting Guide 1373


Layout

seg.LineType = ThickMetal
End If
Next seg
Next rt
End Sub

The HighlightNet method is part of the physical net object and allows you to enable and disable the highlight state of
the net and to set the highlight color.

Dim sch As Schematic


Dim lay As Layout
Dim phnet As PhysicalNet
Set lay = Project.Schematics(2).Layout
Debug.Print lay.PhysicalNets.Count
Set phnet = lay.PhysicalNets(1)
Debug.Print phnet.HighlightNet(True,237)

The following script demonstrates access flight line counts, and layout PCell counts, the information available from the
LayoutInfo object. Often not having any flightlines can be used as a correctness check for a layout so this information
is useful for layout sign-off, having it available directly from the layout info object prevents having to traverse all the
physical nets in the design to see of any of them have remaining flight lines. Cell counts can be hard to determine since
we lump subcircuits and cells into the same collection container typically. The cells count separates the cells from the
sub-circuits and provides a count of just the cells. The layout info sub object is associated with a layout. This object
provides summary information about a layout object. These script enumerates a number of schematic layouts with
different combinations of shapes, routes, sub-circuits, and cell objects and provides summary output information for
each:

' Code Module


Sub Main
Dim schem As Schematic

For Each schem In Project.Schematics


PrintLayoutInfo schem.Layout
Next schem

End Sub

Sub PrintLayoutInfo(ByRef lay As Layout)


Debug.Print "Layout = " & lay.Name
Debug.Print "Shape Count = " & lay.Info.ShapeCount
Debug.Print "Face Count = " & lay.Info.FaceCount
Debug.Print "Pin Count = " & lay.Info.PinCount
Debug.Print "Flt Line Cnt= " & lay.Info.FlightLineCount
Debug.Print "Cell Count = " & lay.Info.CellCount
Debug.Print ""

End Sub

The following script demonstrates how to set the Select property for all Shapes associated with all physical nets to "True".
After the script runs, all net Shapes are selected in Layout:

1374 NI AWR Design Environment


Layout

' Code Module


Sub Main
Dim lay As Layout
Dim phyNet As PhysicalNet
Dim NetS As NetShape
Debug.Clear
Set lay = Project.Schematics("Schematic 1").Layout
For Each phyNet In lay.PhysicalNets
For Each NetS In phyNet.Shapes
NetS.Selected = True
Next NetS
Next phyNet
End Sub

The following script demonstrates how to set the via mode through the ViaMode property on the physical net object in
the API. The routes on a physical net should update correctly when the via mode is changed. The via mode transitions
can be Full to Minimal, Minimal to Full, Full to Minimal 2 and Minimal 2 to Full:

' Code Module


Sub Main
Dim lay As Layout
Dim phys As PhysicalNet
Dim objDraw As DrawingObject

Set lay = Project.Schematics("SCH1").Layout


Set phys = lay.PhysicalNets(1)
PrintViaState phys, "Full Vias Mode"

phys.ViaMode = mwNVM_MinimalVias
lay.Update
lay.Refresh

PrintViaState phys, "Minimal Vias Mode"

End Sub

Sub PrintViaState(ByRef phys As PhysicalNet, title As String)


Dim rt As Route
Dim rtVia As RouteVia

Debug.Print ""
Debug.Print title
Debug.Print ""
For Each rt In phys.Routes
For Each rtVia In rt.Vias
Debug.Print "Via Center = { x = " & rtVia.Origin.x * 1e6 & ", y = " & rtVia.Origin.y * 1e
Debug.Print "Via Extent = { cx = " & rtVia.Extent.cx * 1e6 & ", cy = " & rtVia.Extent.cy
Debug.Print "Via Offset = { dx = " & rtVia.Offset.dx * 1e6 & ", dy = " & rtVia.Offset.dy
Debug.Print "Via Line Type1 = " & rtVia.LineType1
Debug.Print "Via Line Type2 = " & rtVia.LineType2
Debug.Print "Via Conn Type1 = " & rtVia.ConnectType1
Debug.Print "Via Conn Type2 = " & rtVia.ConnectType2
Debug.Print "Via Direct = " & rtVia.Direction
Debug.Print "Via Enabled = " & rtVia.Enabled
Debug.Print "Via Autosize = " & rtVia.AutoSize

API Scripting Guide 1375


Layout

Debug.Print "Via Selected = " & rtVia.Selected


Debug.Print "Via Type = " & rtVia.TypeIndex
Debug.Print ""
Next rtVia
Next rt
Debug.Print ""

End Sub

The ViaMode can be the following:

mwNVM_MinimalVias
mwNVM_FullVias
mwNVM_Minimal2Vias
mwNVM_ManualVias
mwNVM_SemiAutoVias

The following script demonstrates how to change setting for fixed vs. variable radius curves in an iNet route object.If
route with a radius specification that is large enough that the segments require variable radius to curve the bends. The
script sets variable radius so curves changes to straight segments:

Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject
Dim phyNet As PhysicalNet
Dim rt As Route

Set lay = Project.Schematics("SCH1").Layout


For Each phyNet In lay.PhysicalNets
For Each rt In phyNet.Routes
rt.FixedRadiusCurves = True
Next rt
Next phyNet

Debug.Print ""

For Each objDraw In lay.DrawingObjects


If objDraw.TypeBits = 64 Then
PrintObjectShapes objDraw, "After Curve StyleChange"
End If
Next objDraw
End Sub

Sub PrintObjectShapes(ByRef objDraw As DrawingObject, title As String)


Dim shp As Shape
Dim vtx As Vertex

Debug.Print title
For Each shp In objDraw.Shapes
For Each vtx In shp.Vertices
Debug.Print "Vtx { x = " &amp; vtx.x * 1e6 &amp; ", y = " &amp; vtx.y * 1e6 &amp; " }"
Next vtx
Next shp
Debug.Print ""

1376 NI AWR Design Environment


Layout

End Sub

The PhysicalNet collection of objects includes the Pins and Routes collection of objects.

The PhysicalNet collection of objects has AddRoute() and CreateRouteRecord() methods, and ElectNetName and NetID
properties.

The Route collection of objects has BendStyle, MiterAmount, and NetID properties, and also includes Segments, Guides,
and Objects collections of objects.

Copy/Paste Elements in a Schematic with iNet

You should use EditCopy instead of EditCopyAll, so all selected elements are copied to the Clipboard.

Note that the coordinates to the EditPasteSpecialIncludeRoutes are pasted back into the schematic (rather than the
layout) if the numbers are similar to 10e-6 (which is more for layout) than 1000.

' Code Module


Sub Main
Dim sch As Schematic
Dim ret As Variant
Dim vr(2) As Variant
Set sch = Project.Schematics(1)
sch.InvokeCommand("EditSelectAll")
sch.InvokeCommand("EditCopy")
sch.InvokeCommand("EditPasteSpecialIncludeRoutes",Array(0,1000),ret)

End Sub

Disassociating the Shape from the Net

API provides a method on the physical net for associating objects that will support associating routes and net shapes.
This method takes a generic API drawing object and attempts to associate the object with the physical net. This allows
re-associating disassociated route objects and net shapes as well as changing their association from one physical net to
another. For dumb shapes the call will attempt to create an equivalent net shape which will then be associated with the
physical net. API supports polygons, paths, and ellipses as associated net shapes.

There are two approaches to disassociate a shape from the net.

The first approach uses the InvokeCommand method:

' Code Module


Sub Main
Dim lay As Layout
Dim phys As PhysicalNet

Debug.Clear
Set lay = Project.Schematics("Schematic 1").Layout
Debug.Print lay.Name

Set phys = lay.PhysicalNets(1)

API Scripting Guide 1377


Layout

Debug.Print phys.Shapes.Count

If (phys.Shapes.Count > 0) Then


phys.Shapes(1).Selected = True
lay.InvokeCommand("SchematicDisassocNetShapes")
End If

Debug.Print phys.Shapes.Count
End Sub

The second approach uses a Disassociate method on the Net shape object itself:

' Code Module


Sub Main
Dim lay As Layout
Dim phys As PhysicalNet
Dim physShape As NetShape

Debug.Clear
Set lay = Project.Schematics("Schematic 1").Layout
Debug.Print lay.Name

Set phys = lay.PhysicalNets(1)

For Each physShape In phys.Shapes


physShape.Disassociate
Next physShape
End Sub

Accessing iNet Segment End Types

You can edit the segment end styles and keep the edits when the Route segment end style is set to "Custom". The API
provides a route.CustomSegmentEnds property, so the script that sets the custom end style can set the flag to retain the
end styles. The script includes the following line before setting the custom end styles:

' Add setting to retain segment modifications:


r.CustomSegmentEnds = True

The following script shows an example of working with Route segment end styles.

' Code Module


Option Explicit
Sub Main
Debug.Clear

Dim net As PhysicalNet


Dim s As Schematic
Dim endSegNum As Integer
Dim r As Route
Dim seg As RouteSegment
Dim func As Integer
Dim listArray() As String
Dim e As Integer

1378 NI AWR Design Environment


Layout

Set s = Project.Schematics.ActiveSchematic

If (s Is Nothing) Then
MsgBox("A schematic window must be the active window",vbOkOnly,"Script Error")
End
End If

ReDim listArray(5)

listArray(0) = "Chamfer"
listArray(1) = "Truncate"
listArray(2) = "Extended"
listArray(3) = "Variable"
listArray(4) = "Custom"

Begin Dialog UserDialog 400,203 ' %GRID:10,7,1,1


Text 40,42,260,14,"Select an end type for all iNet segments:",.Text1
DropListBox 50,70,240,14,listArray(),.EndStyle
OKButton 70,133,90,21
CancelButton 200,133,80,21
End Dialog
Dim dlg As UserDialog

func = Dialog(dlg)

'Cancel button
If (func = 0) Then
End
End If

e = dlg.EndStyle
Debug.Print e

For Each net In s.Layout.PhysicalNets


For Each r In net.Routes

' Add setting to retain segment modifications:


r.CustomSegmentEnds = True

For Each seg In r.Segments


If e = 0 Then
seg.BeginStyle = mwEST_ChamferEndStyle
seg.EndStyle = mwEST_ChamferEndStyle
ElseIf e = 1 Then
seg.BeginStyle = mwEST_TruncateEndStyle
seg.EndStyle = mwEST_TruncateEndStyle
ElseIf e = 2 Then
seg.BeginStyle = mwEST_ExtendedEndStyle
seg.EndStyle = mwEST_ExtendedEndStyle
ElseIf e = 3 Then
seg.BeginStyle = mwEST_VariableEndStyle
seg.EndStyle = mwEST_VariableEndStyle
ElseIf e = 4 Then
seg.BeginStyle = mwEST_CustomEndStyle
seg.EndStyle = mwEST_CustomEndStyle

API Scripting Guide 1379


Layout

End If
Next seg
Next r
Next net

s.Layout.Refresh

End Sub

Accessing Path Layout Element End Types

Because a Drawing object may consist of several shapes that you cannot individually modify, changes are not allowed
to affect the original object. For example, a Path on the Plated Metal line type may consist of three different paths with
different widths drawn over each other. The system does not allow you to edit the three paths individually, but you can
edit the overall Path object. Many of the same attributes are available at the DrawingObject level, so you can modify
them there and they affect the original object.

The following script changes the attributes at the DrawingObject level:

' Code Module


Sub Main
Dim sch As Schematic
Dim lay As Layout
Dim dro As DrawingObject
Dim op As Option
Dim prop As Property
Dim par As Parameter
Dim el As Element
Dim sh As Shape
Dim atr As Attribute
Debug.Clear

Set sch = Project.Schematics(1)


Set lay = sch.Layout

For Each dro In lay.DrawingObjects


For Each atr In dro.Attributes
If atr.Name = "PathEndType" Then
Debug.Print dro.TypeBits;vbTab;atr.Value;vbTab;atr.ValueAsString
End If

Next atr
Next dro

lay.Refresh
Debug.Print "TopRight Corner: ("; Project.Schematics(1).Layout.Boundary.Right; ",";Project.Schemat
Debug.Print "BottomLeft Corner: ("; Project.Schematics(1).Layout.Boundary.Left; ",";Project.Schema

For Each dro In lay.DrawingObjects


For Each atr In dro.Attributes
If atr.Name = "PathEndType" Then
Debug.Print dro.TypeBits;vbTab;atr.Value;vbTab;atr.ValueAsString
atr.Value = mwPET_Flush
Debug.Print dro.TypeBits;vbTab;atr.Value;vbTab;atr.ValueAsString

1380 NI AWR Design Environment


Layout

End If

Next atr
Next dro

lay.Refresh

Debug.Print "TopRight Corner: ("; Project.Schematics(1).Layout.Boundary.Right; ",";Project.Schemat


Debug.Print "BottomLeft Corner: ("; Project.Schematics(1).Layout.Boundary.Left; ",";Project.Schema

For Each dro In lay.DrawingObjects


For Each atr In dro.Attributes
If atr.Name = "PathEndType" Then
Debug.Print dro.TypeBits;vbTab;atr.Value;vbTab;atr.ValueAsString
atr.Value = mwPET_ExtendedHalfWidth
Debug.Print dro.TypeBits;vbTab;atr.Value;vbTab;atr.ValueAsString
End If
Next atr
Next dro

lay.Refresh

Debug.Print "TopRight Corner: ("; Project.Schematics(1).Layout.Boundary.Right; ",";Project.Schemat


Debug.Print "BottomLeft Corner: ("; Project.Schematics(1).Layout.Boundary.Left; ",";Project.Schema

End Sub

Four Segments Path Angle Stretch

The following script uses a Drawing Object drag handle to perform a Stretch Edit operation. It reads the angle of angled
segments before and after to determine that the angle is retained (within a range of accuracy to prevent round-off errors).
The script also checks to ensure that the stretch offset was performed correctly by verifying the change in position of the
edit handle.

' Code Module


Sub Main
Dim lay As Layout
Dim ret As Variant
Dim dl As DrawingLayer
Dim objDraw As DrawingObject
Dim eh As EditHandle
Dim ang1 As Double
Dim ang2 As Double
Dim y1 As Double, y2 As Double

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
Set objDraw = lay.DrawingObjects(1)

' Middle of the top handle


Set eh = objDraw.EditHandles(6)

' Get the initial stretch handle y and angle


ang1 = GetMidSectionAngle(objDraw)
y1 = eh.Position.y * 1e6

API Scripting Guide 1381


Layout

' Stretch the shape


eh.Move(0.0, 100e-6)

' Get the resulting strech handle y and angle.


ang2 = GetMidSectionAngle(objDraw)
y2 = eh.Position.y * 1e6

' Check that the mid section angle remained the same (lock-angle)
If (Abs(ang2 - ang1) lt 5) Then
Debug.Print "Left Upward Section Angle Remained The Same"
Else
Debug.Print "Left Upward Section Angle Changed"
End If

' Check that we did succeed in stretching the shape.


If (Abs(y2 - y1) > 90) Then
Debug.Print "Stretch Succeeded"
Else
Debug.Print "Stretch Failed"
End If
End Sub

Function GetMidSectionAngle(ByRef objDraw As DrawingObject)


Dim eh1 As EditHandle
Dim eh2 As EditHandle

Set eh = objDraw.EditHandles(3)
Set eh2 = objDraw.EditHandles(5)

Dim dx As Double
Dim dy As Double

dx = eh2.Position.x - eh.Position.x
dy = eh2.Position.y - eh.Position.y

Dim ang As Double


GetMidSectionAngle = MathUtil.RadiansToDegrees(Atn(dy/dx))

End Function

For a single segment path angle:

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
Set objDraw = lay.DrawingObjects(1)

' Top handle for single segment (2 = mid handle)


Set eh = objDraw.EditHandles(3)

' Get the initial stretch handle y and angle


ang1 = GetSectionAngle(objDraw)
y1 = eh.Position.y * 1e6

' Stretch the shape (stretch up but should retain angle)


eh.Move(0.0, 100e-6)

1382 NI AWR Design Environment


Layout

' Get the resulting strech handle y and angle.


ang2 = GetSectionAngle(objDraw)
y2 = eh.Position.y * 1e6

' Check that the mid section angle remained the same (lock-angle)
If (Abs(ang2 - ang1) lt 5) Then
Debug.Print "Left Upward Section Angle Remained The Same"
Else
Debug.Print "Left Upward Section Angle Changed"
End If

' Check that we did succeed in stretching the shape.


' Note here we are stretching at an angle so only 1/2 offset will go up.
If (Abs(y2 - y1) > 45) Then
Debug.Print "Stretch Succeeded"
Else
Debug.Print "Stretch Failed"
End If

Using Edit Handles to stretch a circle

The following script prints the positions of the edit handles to see which one is the upper right. Then it calls Move on
that edit handle with that index to stretch the shape. Printing them just helps figure out which edit handle is which, these
are the handles that are displayed when you double click the shape. Once you know which handle you want to change
on a shape it should always be the same for that shape type so you can just use the index. The code looks like this:

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject
Dim eh As EditHandle

Debug.Clear
Set lay = Project.Schematics("Schematic 1").Layout
Set objDraw = lay.DrawingObjects(1)

' Print the handle positions so we can tell which is upper left.

For Each eh In objDraw.EditHandles


Debug.Print eh.Position.x * 1e6 & ", " & eh.Position.y * 1e6
Next eh

' Looks like upper right is at -4, 19 which is handle 2


' Move this handle to the right.

objDraw.EditHandles(2).Move(100e-6, 0)

End Sub

Adding and removing route objects from physical nets in layout.

The following script shows an example of adding Route to a physical net in Layout:

API Scripting Guide 1383


Layout

Sub Main
Dim lay As Layout
Dim physNet As PhysicalNet
Set lay = Project.Schematics("SCH1").Layout
' Add the routes
For Each physNet In lay.PhysicalNets
AddPhysicalNetRoutes physNet
Next physNet

lay.Update
lay.Refresh
End Sub

Sub AddPhysicalNetRoutes(ByRef physNet As PhysicalNet)


Dim fltLine As FlightLine

For Each fltLine In physNet.FlightLines


RouteFlightLine fltLine, physNet
Next fltLine
End Sub

Sub RouteFlightLine(ByRef fltLine As FlightLine, ByRef physNet As PhysicalNet)


Dim x1 As Double
Dim y1 As Double
Dim x2 As Double
Dim y2 As Double
Dim xMid As Double
Dim rtRec As RouteRecord
Dim w As Double

x1 = fltLine.Begin.x
y1 = fltLine.Begin.y

x2 = fltLine.End.x
y2 = fltLine.End.y

xMid = (x1 + x2) / 2.0

Set rtRec = physNet.Routes.CreateRouteRecord

w = 20e-6
rtRec.AddSegment(x1, y1, xMid, y1, w, 0, mwEST_TruncateEndStyle, 0, mwEST_ExtendedEndStyle, w/2)
rtRec.AddSegment(xMid, y1, xMid, y2, w, 2, mwEST_ExtendedEndStyle, w/2, mwEST_ExtendedEndStyle, w/
rtRec.AddSegment(xMid, y2, x2, y2, w, 0, mwEST_ExtendedEndStyle, w/2, mwEST_TruncateEndStyle, 0)

' From the API perspective Semi-auto behaves like manual so we need to add vias.
' In manual mode we need to add vias ourselves
rtRec.AddVia(xMid, y1, w/2, w/2, 0, 0, 0, 2, mwVDT_Layer1ToLayer2ViaDirection)
rtRec.AddVia(xMid, y2, w/2, w/2, 0, 0, 0, 2, mwVDT_Layer1ToLayer2ViaDirection)

physNet.Routes.AddRoute(rtRec)

End Sub

1384 NI AWR Design Environment


Layout

To remove route use the following:

physNet.Routes.Remove(1)

Accessing Route Properties

The following script shows an example of working with Route Properties:

' Code Module


Sub Main
Dim lay As Layout
Dim physNet As PhysicalNet
Dim Route As Route

Set lay = Project.Schematics("SCH1").Layout

Debug.Print "Physical Net Count = " & lay.PhysicalNets.Count


For Each physNet In lay.PhysicalNets
PrintPhysicalNetDetails physNet
Next physNet

End Sub

Sub PrintPhysicalNetDetails(ByRef physNet As PhysicalNet)


Dim rt As Route

Debug.Print "Physical Net = " & physNet.Name


Debug.Print "Route Count = " & physNet.Routes.Count

For Each rt In physNet.Routes


PrintRouteDetails rt
Next rt

End Sub

Sub PrintRouteDetails(ByRef rt As Route)


Dim seg As RouteSegment
Dim via As RouteVia
Dim obj As RouteObject

Debug.Print "Associated = " & rt.Associated


Debug.Print "Bend Style = " & rt.BendStyle
Debug.Prin t"Boundary = Left = " & rt.Boundary.Left & ", Top = " & rt.Boundary.Top & "
Debug.Print "Continuous = " & rt.Continuous
Debug.Print "Custom Seg Ends = " & rt.CustomSegmentEnds
Debug.Print "Global = " & rt.Global
Debug.Print "Length = " & rt.Length
Debug.Print "Miter Amount = " & rt.MiterAmount
Debug.Print "Miter Amount Abs = " & rt.MiterAmountAbsolute
Debug.Print "NetId = " & rt.NetID
Debug.Print "Selected = " & rt.Selected
Debug.Print "Status = " & rt.Status
Debug.Print "Topology = " & rt.Topology

API Scripting Guide 1385


Layout

Debug.Print "Via Cell Name = " & rt.ViaCellName


Debug.Print ""

Debug.Print "Segment Count = " & rt.Segments.Count


Debug.Print "Segments: "
For Each seg In rt.Segments
PrintSegmentDetails seg
Next seg

Debug.Print "Via Count = " & rt.Vias.Count


Debug.Print "Vias: "
For Each via In rt.Vias
PrintViaDetails via
Next via

Debug.Print "Object Count = " & rt.Objects.Count


Debug.Print "Objects: "
For Each obj In rt.Objects
PrintObjDetails obj
Next obj

Debug.Print "-----------------------------------------------"

End Sub

Sub PrintSegmentDetails(ByRef seg As RouteSegment)


Debug.Print "Begin Point = { x = " & seg.Begin.x & ", y = " & seg.Begin.y & " }"
Debug.Print "Begin Point = { x = " & seg.End.x & ", y = " & seg.End.y & " }"
Debug.Print "Begin Extent = " & seg.BeginExtent
Debug.Print "End Extent = " & seg.EndExtent
Debug.Print "Begin Style = " & seg.BeginStyle
Debug.Print "End Style = " & seg.EndStyle
Debug.Print "Begin Offset Style = " & seg.BeginOffsetStyle
Debug.Print "End Offset Style = " & seg.EndOffsetStyle
Debug.Print "Line Type = " & seg.LineType
Debug.Print "Selected = " & seg.Selected
Debug.Print "Width = " & seg.Width

Debug.Print "Shape Count = " & seg.Shapes.Count


Debug.Print "Segment Shapes: "
PrintShapesDetails seg.Shapes
Debug.Print "----------"

End Sub

Sub PrintViaDetails(ByRef via As RouteVia)


Debug.Print "AutoSize = " & via.AutoSize
Debug.Print "ConnectType1 = " & via.ConnectType1
Debug.Print "ConnectType2 = " & via.ConnectType2
Debug.Print "Direction = " & via.Direction
Debug.Print "Enabled = " & via.Enabled
Debug.Print "Extent = { cx = " & via.Extent.cx & ", cy = " & via.Extent.cy & " } "
Debug.Print "Via Line Type 1 = " & via.LineType1
Debug.Print "Via Line Type 2 = " & via.LineType2
Debug.Print "Offset = { cx = " & via.Offset.dx & ", cy = " & via.Offset.dy & " } "
Debug.Print "Origin = { x = " & via.Origin.x & ", y = " & via.Origin.y & " } "
Debug.Print "Selected = " & via.Selected

1386 NI AWR Design Environment


Layout

Debug.Print "Type Index = " & via.TypeIndex


Debug.Print "Shapes Count = " & via.Shapes.Count
Debug.Print "Via Shapes:
PrintShapesDetails via.Shapes
Debug.Print "----------"
End Sub

Sub PrintObjDetails(ByRef obj As RouteObject)


Debug.Print "Begin Node = " & obj.BeginNode
Debug.Print "End Node = " & obj.EndNode
Debug.Print "Boundary = Left = " & obj.Boundary.Left & ", Top = " & obj.Boundary.Top &
Debug.Print "Selected = " & obj.Selected
Debug.Print "Type = " & obj.Type

Debug.Print "Shapes Count = " & obj.Shapes.Count


PrintShapesDetails(obj.Shapes)

Debug.Print "Vertices Count = " & obj.Vertices.Count


PrintVertices(obj.Vertices)
Debug.Print "----------"

End Sub

Sub PrintShapesDetails(ByRef shps As Shapes)


Dim shp As Shape

For Each shp In shps


Debug.Print "Shape Type = " & shp.Type
Debug.Print "Drawing Layer = " & shp.DrawingLayer.Number
Next shp
End Sub

Sub PrintVertices(ByRef vts As Vertices)


Dim vtx As Vertex
Dim index As Integer

index = 1
For Each vtx In vts
Debug.Print "Vertex[" & index & "] = { x = " & vtx.x * 1e6 & ", y = " & vtx.y * 1e6 & " }"
index = index + 1
Next vtx
End Sub

Determination of Route Coordinates

The following script shows an example of working with Route coordinates:

' Code Module


Sub Main
Dim lay As Layout
Dim physNet As PhysicalNet
Dim rt As Route

Dim rtObj As RouteObject

API Scripting Guide 1387


Layout

Debug.Clear
Set lay = Project.Schematics("Schematic 1").Layout
For Each physNet In lay.PhysicalNets
For Each rt In physNet.Routes
For Each rtObj In rt.Objects
Debug.Print rtObj.BeginNode & ", ";
Debug.Print rtObj.EndNode
Next rtObj
Next rt
Next physNet
End Sub

This script generates the following output:

1, 3
3, 4
4, 5
5, 6
6, 2

Changing Route Layers on Split Segments

The following script is an example of working with Route segments properties.

This script replicates the steps; it sub-selects the segments, which is the same as right-click selecting them. It invokes
the SegmentProperties command with arguments to change the segments from Metal 3 to Metal 4, and then it invokes
the EditUndo command to undo the changes. The InvokeCommand method is also described. We need to mention very
important information abou using UNDO method. The only API operations that can be undone are those that involve a
command object. So these are operations that involve InvokeCommand() methods. In our system command objects are
able to undo and redo their operations. In order for Undo or Redo to work we need to start with something that was done
by a command. If the operation wasnt done with InvokeCommand() it is unlikely that undo will work.

' Code Module


Sub Main
Dim lay As Layout
Dim phy As PhysicalNet
Dim rt As Route
Dim seg As RouteSegment
Dim ret As Variant

Debug.Clear
Set lay = Project.Schematics("Schematic_1").Layout
Set phy = lay.PhysicalNets(1)

' Second route seems to be the top one.


Set rt = phy.Routes(2)

' Set the segments selected (equivalent to the shift-right-click action)


For Each seg In rt.Segments
seg.Selected = True
Next seg

' Select set the route's state to selected


rt.Selected = True

1388 NI AWR Design Environment


Layout

' Current line type is Metal 3.


For Each seg In rt.Segments
Debug.Print seg.LineType
Next seg

' Change line type to Metal 4.


lay.InvokeCommand("PropertiesRouteSegment", Array(4, 2e-6), ret)
Debug.Print ret

' Now line type should be Metal 4.


For Each seg In rt.Segments
Debug.Print seg.LineType
Next seg

lay.InvokeCommand("EditUndo")

End Sub

Using net route associate and disassociate commands

We can apply for the net route associate and disassociate commands. To do so we can select flightlines associated with
a physical net in the API:

Set lay = Project.Schematics("SCH1").Layout


Set phys = lay.PhysicalNets(1)

Debug.Print, "Physical Net Route Count = " & phys.Routes.Count

lay.SelectedObjects.RemoveAll
For Each objDraw In lay.DrawingObjects
If objDraw.TypeBits = 64 Then
objDraw.Selected = True
End If
Next objDraw
phys.FlightLines.Selected = True

lay.InvokeCommand("SchematicAssocNetRoutes")
Debug.Print "Physical Net Route Count = " & phys.Routes.Count

To disassosiate routes use the following:

Set lay = Project.Schematics("SCH1").Layout


Set phys = lay.PhysicalNets(1)

Debug.Print "Physical Net Route Count = " & phys.Routes.Count

lay.SelectedObjects.RemoveAll
For Each objDraw In lay.DrawingObjects
If objDraw.TypeBits = 64 Then
objDraw.Selected = True
End If
Next objDraw

API Scripting Guide 1389


Layout

lay.InvokeCommand("SchematicDisassocNetShapes")
Debug.Print "Physical Net Route Count = " & phys.Routes.Count

Adding Route via

We support invoking the add route via command via the parametric invoke command API to add vias in manual edit
mode to a route object. The following code adds 4 vias to two different route objects on two different physical nets:

Sub Main
Dim lay As Layout
Dim physNet As PhysicalNet
Dim Route As Route
Dim count As Integer
Dim i As Integer

Set lay = Project.Schematics("SCH1").Layout

Debug.Print "Physical Net Count = " & lay.PhysicalNets.Count

count = 0
If (lay.PhysicalNets.Count > 0) Then
Set physNet = lay.PhysicalNets(1)
SelectNetRoutes(physNet)
lay.InvokeCommand("SchematicManualAddRouteVia", Array(-110e-6, 85e-6))
lay.InvokeCommand("SchematicManualAddRouteVia", Array(-63e-6, 85e-6))
count = count + 2
End If

lay.SelectedObjects.RemoveAll

If (lay.PhysicalNets.Count > 1) Then


Set physNet = lay.PhysicalNets(2)
SelectNetRoutes(physNet)
lay.InvokeCommand("SchematicManualAddRouteVia", Array(91e-6, 84e-6))
lay.InvokeCommand("SchematicManualAddRouteVia", Array(135e-6, 84e-6))
count = count + 2
End If

lay.Update
lay.Refresh

' Print Resulting state.


PrintNetState lay, "***After Add Route Via ***"

End Sub

Sub PrintNetState(ByRef lay As Layout, title As String)


Dim physNet As PhysicalNet

' Print Resulting state.


Debug.Print title
For Each physNet In lay.PhysicalNets
PrintPhysicalNetDetails physNet
Next physNet

1390 NI AWR Design Environment


Layout

Debug.Print ""

End Sub

Sub PrintPhysicalNetDetails(ByRef physNet As PhysicalNet)


Dim rt As Route

Debug.Print "Physical Net = " & physNet.Name


Debug.Print "Route Count = " & physNet.Routes.Count

For Each rt In physNet.Routes


PrintRouteDetails rt
Next rt

End Sub

Sub PrintRouteDetails(ByRef rt As Route)


Dim seg As RouteSegment
Dim via As RouteVia
Dim index As Integer

Debug.Print "Segments: "


For Each seg In rt.Segments
PrintSegmentDetails seg
Next seg
Debug.Print ""

Debug.Print "Vias: "


For Each via In rt.Vias
PrintViaDetails via
Next via
Debug.Print ""

Debug.Print "-----------------------------------------------"

End Sub

Sub PrintSegmentDetails(ByRef seg As RouteSegment)


Debug.Print "Begin Point = { x = " & seg.Begin.x * 1e6 & ", y = " & seg.Begin.y * 1e6 & "
Debug.Print "Begin Point = { x = " & seg.End.x * 1e6 & ", y = " & seg.End.y * 1e6 & " }"
Debug.Print "Line Type = " & seg.LineType
Debug.Print "Width = " & seg.Width * 1e6
Debug.Print "Shape Count = " & seg.Shapes.Count
Debug.Print "----------"

End Sub

Sub PrintViaDetails(ByRef via As RouteVia)


Debug.Print "Origin = { x = " & via.Origin.x * 1e6 & ", y = " & via.Origin.y * 1e6
Debug.Print "Extent = { cx = " & via.Extent.cx * 1e6 & ", cy = " & via.Extent.cy * 1
Debug.Print "Offset = { dx = " & via.Offset.dx * 1e6 & ", dy = " & via.Offset.dy * 1
Debug.Print "LineType 1 = " & via.LineType1
Debug.Print "LineType 2 = " & via.LineType2
Debug.Print "Direction = " & via.Direction
Debug.Print "Enabled = " & via.Enabled
Debug.Print "Type Index = " & via.typeIndex
Debug.Print "----------------"

API Scripting Guide 1391


Layout

End Sub

Sub SelectNetRoutes(ByRef physNet As PhysicalNet)


Dim rt As Route
Dim seg As RouteSegment
Dim ThickMetal As Integer

' Line type for thick metal in MMIC process


ThickMetal = 0
For Each rt In physNet.Routes
rt.Selected = True
Next rt
End Sub

To Delete Route Via use the following:

lay.InvokeCommand("SchematicManualDeleteRouteVia")

To Move Route Via use the following:

lay.InvokeCommand("SchematicManualMoveRouteVia", Array(0, -10e-6))

Changing the AutoSize property of the vias in a route via

The following script is an example of working with Route Via AutoSize property. This property updates the size of the
route vias:

Sub Main
Dim lay As Layout
Dim physNet As PhysicalNet

Set lay = Project.Schematics("SCH1").Layout

For Each physNet In lay.PhysicalNets


ChangeRouteViaToAutoSize physNet
Next physNet

lay.Update
lay.Refresh

End Sub
Sub ChangeRouteViaToAutoSize(ByRef physNet As PhysicalNet)
Dim rt As Route
Dim seg As RouteSegment
Dim via As RouteVia

For Each rt In physNet.Routes


For Each via In rt.Vias
via.AutoSize = True
Next via
Next rt

1392 NI AWR Design Environment


Layout

End Sub

The following code is an example of working with Route Via extent property. This property updates the extent of the
route vias:

For Each rt In physNet.Routes


For Each via In rt.Vias
via.AutoSize = False
via.Extent.cx = via.Extent.cx * 2
via.Extent.cy = via.Extent.cy * 2
Next via
Next rt

The following code is an example of working with Route Via offset property. This property updates the offset of the
route vias:

For Each rt In physNet.Routes


For Each via In rt.Vias
via.AutoSize = False
via.Offset.dx = 10e-6
via.Offset.dy = 10e-6
Next via
Next rt

The following code is an example of added support for invoking the route via properties command via the API. We added
support for KRouteViaPropertiesCommand to allow the dialog to be bypassed if the command was invoked with arguments
and to obtain the needed via values form the arguments. The via update processing is then completed with the argument
values. The following code selects two routes on different physical nets and then updated the attributes of the included
vias. The state of the vias after the changes can be output with the same manner showed above:

Dim lay As Layout


Dim physNet As PhysicalNet
Dim Route As Route

Set lay = Project.Schematics("SCH1").Layout

Debug.Print "Physical Net Count = " & lay.PhysicalNets.Count

For Each physNet In lay.PhysicalNets


SelectNetRoutes physNet
Next physNet

lay.InvokeCommand("PropertiesRouteVia", Array(1, 2, 0, 10e-6, 10e-6, 10e-6, 10e-6, True, False, -1

lay.Update
lay.Refresh

' Print Resulting state.


PrintNetState lay, "***After Route Via Change***"

API Scripting Guide 1393


Layout

Making Route via property Enabl/Disabled

The following code shows how to make route property via enabled/disabled:

Sub Main
Dim lay As Layout
Dim physNet As PhysicalNet
Dim Route As Route

Set lay = Project.Schematics("SCH1").Layout

Debug.Print"Physical Net Count = " & lay.PhysicalNets.Count


' Print initial State
Debug.Print"***Before Route Disable Change***"
Debug.Print""
For Each physNet In lay.PhysicalNets
PrintPhysicalNetDetails physNet
Next physNet

' Double the width of each segment in each route.


For Each physNet In lay.PhysicalNets
ChangeRouteViaToDisable physNet
Next physNet

lay.Update
lay.Refresh

' Print Resulting state.


Debug.Print""
Debug.Print"***After Route Via Disable Change***"
Debug.Print""

For Each physNet In lay.PhysicalNets


PrintPhysicalNetDetails physNet
Next physNet

End Sub

Sub PrintPhysicalNetDetails(ByRef physNet As PhysicalNet)


Dim rt As Route
Dim index As Integer

Debug.Print"Physical Net = " & physNet.Name


Debug.Print"Route Count = " & physNet.Routes.Count

index = 1
For Each rt In physNet.Routes
Debug.Print"Route[" & index & "]"
PrintRouteDetails rt
index = index + 1
Next rt

End Sub

Sub PrintRouteDetails(ByRef rt As Route)


Dim via As RouteVia

1394 NI AWR Design Environment


Layout

Dim index As Integer

index = 1
For Each via In rt.Vias
Debug.Print"Via[" & index & "]"
PrintViaDetails via
index = index + 1
Next via

Debug.Print"-----------------------------------------------"

End Sub

Sub PrintViaDetails(ByRef via As RouteVia)


Debug.Print"Origin = { x = " & via.Origin.x * 1e6 & ", y = " & via.Origin.y * 1e6 & " }"
Debug.Print"Extent = { cx = " & via.Extent.cx * 1e6 & ", cy = " & via.Extent.cy * 1e6 & "
Debug.Print"Offset = { dx = " & via.Offset.dx * 1e6 & ", dy = " & via.Offset.dy * 1e6 & "
Debug.Print"Auto Size = " & via.AutoSize
Debug.Print"ConnectType1 = " & via.ConnectType1
Debug.Print"ConnectType2 = " & via.ConnectType2
Debug.Print"Direction = " & via.Direction
Debug.Print"LineType1 = " & via.LineType1
Debug.Print"LineType2 = " & via.LineType2
Debug.Print"Selected = " & via.Selected
Debug.Print"Shapes Count = " & via.Shapes.Count
Debug.Print""
End Sub

Sub ChangeRouteViaToDisable(ByRef physNet As PhysicalNet)


Dim rt As Route
Dim seg As RouteSegment
Dim via As RouteVia

For Each rt In physNet.Routes


For Each via In rt.Vias
via.Enabled = False
Next via
Next rt
End Sub

Accessing flight lines associated with specific electrical nets

The following code shows how to access to flight lines associated with specific electrical nets, and to verify flight line
update when element is moved to to disconnected position./disabled:

Sub Main
Dim schem As Schematic
Dim lay As Layout
Dim objDraw As DrawingObject
Dim objFace As Face

Set schem = Project.Schematics("SCH1")


Set lay = schem.Layout

API Scripting Guide 1395


Layout

PrintFlightLineState lay, "Flight Line State before Move"

Set objDraw = schem.Elements("TFC.V1").DrawingObjects(1)


objDraw.Move(100e-6, 100e-6)

PrintFlightLineState lay, "Flight Line State after Move"

End Sub

Sub PrintFlightLineState(ByRef lay As Layout, title As String)


Dim physNet As PhysicalNet
Dim fl As FlightLine
Dim index As Integer

Debug.Print title
Debug.Print "FlightLines: "
For Each physNet In lay.PhysicalNets
Debug.Print "Net Name = " & physNet.Name
index = 1
For Each fl In physNet.FlightLines
Debug.Print "FlightLine[" & index & "] = From: x = " & fl.Begin.x * 1e6 & ", y = " & fl.Begin.y
Debug.Print " To: x = " & fl.End.x * 1e6 & ", y = " & fl.End.y * 1e6
index = index + 1
Next fl
Next physNet
Debug.Print ""
End Sub

Using the Layout Method InvokeCommand()

The following code is an example of using the Layout method InvokeCommand() that invokes the name of a specified
command.

Dim lay As Layout


Dim objDraw As DrawingObject
Debug.Clear
Set lay = Project.Schematics("test_layout").Layout
For Each objDraw In lay.DrawingObjects
objDraw.Selected = True
Next objDraw
Dim retVal As Variant
lay.InvokeCommand("ShapeCreateMosaic", Array(2, 2, 300e-6, 300e-6, 1), retVal)
Debug.Print retVal

The following are further examples of using the Layout method InvokeCommand():

'Invoke the EditorAlignLeft On the resulting selected Shapes.


lay.InvokeCommand("EditorAlignLeft")
' Invoke the EditorAlignBottom on the resulting selected shapes.
lay.InvokeCommand("EditorAlignBottom")
' Invoke the EditorCenterHorizontal on the resulting selected shapes.
lay.InvokeCommand("EditorCenterHorizontal")
' Invoke the EditorAlignTop on the resulting selected shapes.

1396 NI AWR Design Environment


Layout

lay.InvokeCommand("EditorAlignTop")

The following is an example of using the Layout method InvokeCommand() for drawing a Circle:

Open fwrite For Output As #1


Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If

lay.Activate

' Invoke the command to create the Circle object.

Set dl = Project.ProcessDefinitions(1).LayerSetup.DrawingLayers("Poly")
Project.ProcessDefinitions(1).LayerSetup.DrawingLayers.ActiveLayer = dl
Debug.Print "Setting Layer = " & dl.Name
Print #1, "Active Layer = " & Project.ProcessDefinitions(1).LayerSetup.DrawingLayers.ActiveLayer.

lay.InvokeCommand("InsertCircle", Array(0, 0, 100e-6, 100e-6), ret)


Debug.Print ret

' Dump the results of a file for comparison.


Debug.Print lay.Name
Debug.Print "DrawingObjects Count = " & lay.DrawingObjects.Count
For Each objDraw In lay.DrawingObjects
PrintDrawingObject objDraw
Debug.Print ""
Next objDraw

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Print #1, "Info Text = " & drawingObj.InfoText
Print #1, "Selected = " & drawingObj.Selected
Print #1, "Flipped = " &drawingObj.Flipped
Print #1, "Rotation = " & drawingObj.RotationAngle
Print #1, "Frozen = " & drawingObj.Frozen
Print #1, "Base Pos = { x = " & drawingObj.BasePosition.x & ", y = "& drawingObj.BasePosition.y &
Print #1, "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Print #1, "Parameters:"
For Each param In params
Print #1, param.Name & " = " & param.ValueAsString
Next param

End Sub

API Scripting Guide 1397


Layout

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Print #1, "Attributes:"
For Each attr In attrs
Print #1, attr.Name &" = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Print #1, "Boundary:"
Print #1, "Left = " & bound.Left
Print #1, "Right = " & bound.Right
Print #1, "Top = " & bound.Top
Print #1, "Bottom = " & bound.Bottom
End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Print #1, "Edit Handles:"
For Each eh In ehs
Print #1, "{ x= " & eh.Position.x & ", y= " & eh.Position.y & " }"
Next eh
End Sub

The following is an example of using the Layout method InvokeCommand() for drawing an Arc:

Dim lay As Layout


Dim ret As Variant
Dim dl As DrawingLayer
Dim objDraw As DrawingObject

Set lay = Project.Schematics("SCH1").Layout

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If

lay.Activate

' Invoke the command to create the rectangle object.


Set dl = Project.ProcessDefinitions(1).LayerSetup.DrawingLayers("Poly")
Project.ProcessDefinitions(1).LayerSetup.DrawingLayers.ActiveLayer = dl
Debug.Print "Setting Layer = " & dl.Name
Debug.Print "Active Layer = " & Project.ProcessDefinitions(1).LayerSetup.DrawingLayers.ActiveLaye
lay.InvokeCommand("InsertArc", Array(0, 0, 100e-6, 100e-6, 0, 100e-6), ret)
Debug.Print ret

The following code is an example of using the Layout method InvokeCommand() for drawing Layout Ruler:

Set dl = Project.ProcessDefinitions(1).LayerSetup.DrawingLayers("Poly")
Project.ProcessDefinitions(1).LayerSetup.DrawingLayers.ActiveLayer = dl
Debug.Print "Setting Layer = " & dl.Name
Debug.Print "Active Layer = " & Project.ProcessDefinitions(1).LayerSetup.DrawingLayers.ActiveLaye
lay.InvokeCommand("InsertRuler", Array(0, 0, 100e-6, 0, False), ret)

1398 NI AWR Design Environment


Layout

Debug.Print ret

The following line of code "Snaps to Fit" Shapes:

lay.InvokeCommand("ShapeCreateSnapToFit")

The system uses different algorithms for "snap to fit" on routes and for PCell objects. In the user interface, the system
recognizes what is selected and determines which algorithm to invoke. In the API, you need to invoke both algorithms
if you select both iNet Shapes and PCell objects. InvokeCommand() objects in the Layout must be selected before this
operation. The following code selects and then "snaps to fit" both iNet and PCell objects in this test case:

Private Sub Project_Open()


Dim sch As Schematic
Dim lay As Layout

Debug.Clear
Set sch=Project.Schematics(1)
Set lay = sch.Layout
sch.Layout.SelectedObjects.AddFromArea(-65e-6,80e-6,300e-6,-100e-6,mwAAT_ContainedObjects)
' Invoke the SnapToFit on the resulting selected shape.

lay.InvokeCommand("SchematicRouteSnapToFit")
sch.Layout.SelectedObjects.AddFromArea(-205e-6,1550e-6,505e-6,-100e-6,mwAAT_ContainedObjects)
lay.InvokeCommand("ShapeSnapToFit")
lay.Refresh

End Sub

The following code shows how to select all objects from the Area of Layout:

Dim schem As Schematic


Dim lay As Layout
' Get the schematic and layout for that schematic.
Set schem = Project.Schematics("test_layout")
'Debug.Print schem.Name
Set lay = schem.Layout
' Select all the objects in the layout.
lay.SelectedObjects.AddFromArea(-3e-6,4e-6,3e-6,-2e-6,mwAAT_ContainedObjects)
lay.SelectedObjects.AddFromArea(7e-6,2e-6,10e-6,8e-6,mwAAT_ContainedObjects)
' Invoke the EditorAlignBottom on the resulting selected shapes.
lay.InvokeCommand("EditorAlignBottom")

The following code shows how to select all objects in the Layout:

Set lay = Project.Schematics("SCH1").Layout


lay.SelectedObjects.AddAll

The following code connects Net Shapes with an existing route:

API Scripting Guide 1399


Layout

Dim lay As Layout


Dim physNet As PhysicalNet

Set lay = Project.Schematics("SCH1").Layout

lay.InvokeCommand("SchematicConnectNetShapes")

For Each physNet In lay.PhysicalNets


Debug.Print physNet.Name & ", Flight Line Count = " & physNet.FlightLines.Count;
Debug.Print ", Net Shape Count = " & physNet.Shapes.Count
Next physNet

The following code associates a dumb polygon shape with a physical net. We had some issues with this since the object
that results is not the same as source object (net shape replaces dumb shape) :

lay.SelectedObjects.RemoveAll
For Each objDraw In lay.DrawingObjects
If objDraw.TypeBits = 1 Then
objDraw.Selected = True
End If
Next objDraw
phys.FlightLines.Selected = True

lay.InvokeCommand("SchematicAssocNetRoutes")

The following example of the code uses AssociateObject() method to associate a dumb polygon shape:

Set lay = Project.Schematics("SCH1").Layout


Set phys = lay.PhysicalNets(1)

lay.SelectedObjects.RemoveAll
For Each objDraw In lay.DrawingObjects
If objDraw.TypeBits = 1 Then
phys.AssociateObject(objDraw)
End If
Next objDraw

The following code associate routes with physical net programmatically without needing to use invoke command. Look
at the picture below that shows the meaning of associating routes with physical net:

1400 NI AWR Design Environment


Layout

Dim lay As Layout


Dim phys As PhysicalNet
Dim objDraw As DrawingObject

Set lay = Project.Schematics("SCH1").Layout


Set phys = lay.PhysicalNets(1)

lay.SelectedObjects.RemoveAll
For Each objDraw In lay.DrawingObjects
If objDraw.TypeBits = 64 Then
phys.AssociateObject(objDraw)
End If
Next objDraw

You can also disassociate shape or route with Disassociate property.

The following code Merge linear end-connected routes using invoke command. This command will be useful with
complex routing connections and makes it possible to associate several routes with the flight lines of a single group of
connections. Look at the picture below that shows the meaning of merging routes. There are two routes in the picture.
After the merge command it will be one route:

Dim lay As Layout


Dim phys As PhysicalNet
Dim rt As Route

API Scripting Guide 1401


Layout

Dim objDraw As DrawingObject

Set lay = Project.Schematics("SCH1").Layout

lay.SelectedObjects.RemoveAll

' Selection order matters so select all routes from one net first.
Set phys = lay.PhysicalNets("ELENET2.EN1")
For Each rt In phys.Routes
rt.Selected = True
Next rt

lay.InvokeCommand("SchematicNetCleanup", Array(True, True))

lay.Update
lay.Refresh

The following code shows via fence operations around route objects, using InvokeCommand() Method. The operations
include adding fencing around the perimeter of a route object, adding them with the perimeters merged and adding them
with the perimeters merged and an offset. Invoking the Via Fill or Via Fence commands via the Invoke Command API
method now requires an additional argument to determine if the results should be grouped:

Dim lay As Layout


Dim ret As Variant
Dim objDraw As DrawingObject
Dim phys As PhysicalNet
Dim rt As Route

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

PrintDrawObjState lay, "***Before Via Fence***"

For Each phys In lay.PhysicalNets


For Each rt In phys.Routes
rt.Selected = True
Next rt
Next phys

lay.InvokeCommand("ShapeViaFence", Array("ViaLib", "ViaCell", 0, 15e-6, 0, 0, 0, 0, 1, 0), ret)

PrintDrawObjState lay, "***After Via Fence***"

End Sub

Sub PrintDrawObjState(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject
Dim objRect As DrawingObject

' Output results for comparison.


Debug.Print title
Debug.Print lay.Name
Debug.Print "DrawingObjects Count = " & lay.DrawingObjects.Count
For Each objDraw In lay.DrawingObjects
PrintDrawingObject objDraw

1402 NI AWR Design Environment


Layout

Debug.Print ""
Next objDraw
Debug.Print ""

End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " & drawingObj.InfoText
Debug.Print "Base Pos = { x = " & drawingObj.BasePosition.x * 1e6 & ", y = " & drawingObj.BasePos
End Sub

The similar operation using InvokeCommand() Method could apply for ViaFill

The following code shows how to Add cells by specifying the settings :

Dim lay As Layout


Dim sch As Schematic
Dim ret As Variant
Set sch = Project.Schematics("sch")
Set lay = sch.Layout
lay.SelectedObjects.AddAll

'Adding cells by specifying the settings


'lay.InvokeCommand("ShapeViaFill", Array("ViaLib", "ViaCell", Type, SpacingX, SpacingY, OffsetX
lay.InvokeCommand("ShapeViaFill", Array("GDS", "Square", 0, 60e-6, 60e-6, 0, 0, 20e-6, 0), ret

'Adding cells by using presets in the LPF


'lay.InvokeCommand("ShapeViaFill", Array("ViaPresetInLPF"),ret)
lay.InvokeCommand("ShapeViaFill",Array("Via1"), ret)

End Sub

We have enabled the API drawing object group collection to access objects inside the group object. Invoking the Via
Fill or Via Fence commands via the Invoke Command API method now requires an additional argument to determine
if the results should be groupped:

Sub Main
' Code Module
Dim lay As Layout
Dim ret As Variant
Dim objDraw As DrawingObject

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

PrintDrawObjState lay, "***Before Via Fill***"

lay.SelectedObjects.AddAll
lay.InvokeCommand("ShapeViaFill", Array("ViaLib", "ViaCell", 0, 15e-6, 15e-6, 0, 0, 5e-6, 0, 1), r

PrintDrawObjState lay, "***After Via Fill***"

lay.InvokeCommand("EditUndo")

API Scripting Guide 1403


Layout

PrintDrawObjState lay, "***After Undo Via Fill***"

lay.InvokeCommand("EditRedo")

PrintDrawObjState lay, "***After Redo Via Fill***"


End Sub

Sub PrintDrawObjState(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject
Dim objRect As DrawingObject

' Output results for comparison.


Debug.Print title
Debug.Print lay.Name
Debug.Print "DrawingObjects Count = " & lay.DrawingObjects.Count
For Each objDraw In lay.DrawingObjects
PrintDrawingObject objDraw
If (objDraw.Group) Then
PrintGroupObjs objDraw
End If
Debug.Print ""
Next objDraw
Debug.Print ""

End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " & drawingObj.InfoText
Debug.Print "Base Pos = { x = " & drawingObj.BasePosition.x * 1e6 & ", y = " & drawingObj.BasePo
End Sub

Sub PrintGroupObjs(ByRef drawingObj As DrawingObject)


Dim grpObj As DrawingObject

Debug.Print "IsGroup = " & drawingObj.Group


If (drawingObj.Group) Then
Debug.Print "Group Obj Count = " & drawingObj.GroupObjects.Count
For Each grpObj In drawingObj.GroupObjects
PrintDrawingObject grpObj
Next grpObj
End If
Debug.Print ""
End Sub

These script invokes the Via Fill command on a number of shape types and requests that the command group the resulting
vias. The details of the results are then dumped out. The script traverses into the grouped objects during the the object
output dump to see the contents of the group objects

The following code shows how to work with many-path crossover insertion. Layout includes a route intersection between
three different routes and the code will attempt to insert two crossovers as an example of handling many path intersection.
The code uses InvokeCommand "SchematicNetCleanup" :

Sub Main

1404 NI AWR Design Environment


Layout

Dim lay As Layout


Dim phys As PhysicalNet
Dim rt As Route

Dim objDraw As DrawingObject

Set lay = Project.Schematics("SCH1").Layout


PrintPhysNetState lay, "Before Net Cleanup"

lay.SelectedObjects.RemoveAll

' Selection order matters so select all routes from one net first.
Set phys = lay.PhysicalNets("ELENET2.EN2")
For Each rt In phys.Routes
rt.Selected = True
Next rt

Set phys = lay.PhysicalNets("ELENET2.EN1")


For Each rt In phys.Routes
rt.Selected = True
Next rt

lay.InvokeCommand("SchematicNetCleanup", Array(True, True, False))

lay.Update
lay.Refresh

PrintPhysNetState lay, "After Net Cleanup"

lay.InvokeCommand("EditUndo")

PrintPhysNetState lay, "After Undo"

End Sub

Sub PrintPhysNetState(ByRef lay As Layout, title As String)


Dim phys As PhysicalNet
Dim rt As Route
Dim index As Integer

Debug.Print "Net State: " & title

For Each phys In lay.PhysicalNets


Debug.Print "Phys Net = " & phys.Name
Debug.Print "Routes: "
index = 1
For Each rt In phys.Routes
Debug.Print "Route [" & index & "]:"
PrintRouteState rt
Debug.Print ""
index = index + 1
Next rt

Next phys

Debug.Print "----------"

API Scripting Guide 1405


Layout

End Sub

Sub PrintRouteState(ByRef rt As Route)


Debug.Print "Route Segment Count = " & rt.Segments.Count
Debug.Print "Route Via Count = " & rt.Vias.Count
End Sub

The Net Cleanup command takes three arguments when invoked by the InvokeCommand method in the API. We have
an option to add routes incrementally so the third argument in InvokeCommand allows specifying this option for the
command.

The following script shows how to insert crossover inrementally.The code inserts two crossovers in the same line selecting
the routes in pairs and invoking the command twice to insert the two crossovers. It depends on the incremental add option
working correctly to not remove the first crossover when inserting the second. We also have Undo and Redo methods
of the incremental add:

Sub Main
Dim lay As Layout
Dim phys As PhysicalNet
Dim rt As Route

Dim objDraw As DrawingObject

Set lay = Project.Schematics("SCH1").Layout


PrintPhysNetState lay, "Before Net Cleanup"

lay.SelectedObjects.RemoveAll

' Selection order matters so select all routes from one net first.
Set phys = lay.PhysicalNets("ELENET2.EN2")
For Each rt In phys.Routes
rt.Selected = True
Next rt

Set phys = lay.PhysicalNets("ELENET2.EN1")


For Each rt In phys.Routes
rt.Selected = True
Next rt

lay.InvokeCommand("SchematicNetCleanup", Array(True, True, False))

lay.Update
lay.Refresh

PrintPhysNetState lay, "After Net Cleanup Initial Net Cleanup"

lay.SelectedObjects.RemoveAll

Set phys = lay.PhysicalNets("ELENET2.EN2")


For Each rt In phys.Routes
rt.Selected = True
Next rt

Set phys = lay.PhysicalNets("ELENET2.EN3")

1406 NI AWR Design Environment


Layout

For Each rt In phys.Routes


rt.Selected = True
Next rt

' Invoke the command to add incrementally.


lay.InvokeCommand("SchematicNetCleanup", Array(True, True, True))

lay.Update
lay.Refresh

PrintPhysNetState lay, "After Net Cleanup Add Incremental"

End Sub

The following script uses the InvokeCommand ("EditPaste", args, res) method for invoking the Copy/ Paste command.

' Code Module


Sub Main
Dim sch As Schematic
Dim lay As Layout
Debug.Clear
Set sch = Project.Schematics(1)
Set lay = sch.Layout
lay.Activate
' Select all the objects in the layout.
' Select all and copy
lay.SelectedObjects.AddAll
lay.InvokeCommand("EditCopy")
' For Paste command Args need to be an array.
Dim var(1) As Variant
Dim res As Variant
var(0) = 700 * 25.4 * 1e-6
var(1) = 700 * 25.4 * 1e-6
lay.InvokeCommand("EditPaste",var, res)
Debug.Print res
'You can also use this instead of InvokeCommand("EditPaste")
s.Layout.Paste(x,y)
'You can also use this instead of InvokeCommand("EditPaste")
lay.SelectedObjects.AddAll
lay.InvokeCommand("ShapeUnion")
End Sub

The following script uses the InvokeCommand( "EditCopyWithReference") that just copies a rectangle object and offsets
it by 200um. The parametric arguments include start point, end point, rotation ccw and flip. The API call will imitate
RButton down clicks for rotation ccw and flip during the dragging stage:

Set lay = Project.Schematics("SCH1").Layout

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If
lay.Activate
PrintDrawObjectsState lay, "Before Copy Command"

API Scripting Guide 1407


Layout

lay.SelectedObjects.AddAll
lay.InvokeCommand("EditCopyWithReference", Array(0, 0, 200e-6, 0, 0, True))
PrintDrawObjectsState lay, "After Copy Command"

lay.InvokeCommand("EditUndo")
PrintDrawObjectsState lay, "After Copy Command Undo"

lay.InvokeCommand("EditRedo")
PrintDrawObjectsState lay, "After Copy Command Redo"

PrintDrawObjectsState() method already described in the previous examples

Copy with reference provides a shortcut for copy/paste in that you can copy something move to a new location and then
place it immediately. But it also places the objects on the clipboard which allows you to move to another location and
then paste again with the standard Paste command or Ctrl + V the resulting objects being moved by the same reference
point as the originals. This can be used to quickly stamp down a number of instance copies of an collection of shapes
and place them precisely by a given reference point.

The following script is the example of copy something move to a new location and then place it immediately:

Set lay = Project.Schematics("SCH1").Layout

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If

lay.Activate

PrintDrawObjectsState lay, "Before Copy Command"

lay.SelectedObjects.AddAll
lay.InvokeCommand("EditCopyWithReference", Array(0, 0, 200e-6, 0, 0, False))

PrintDrawObjectsState lay, "After Copy Command"

lay.InvokeCommand("EditPaste", Array(400e-6, 0))

PrintDrawObjectsState lay, "After First Paste"

lay.InvokeCommand("EditPaste", Array(600e-6, 0))

PrintDrawObjectsState lay, "After Second Paste"

Copy with reference command can also be applied to schematic and system diagram views.

The following script uses the InvokeCommand( "EditCut") that correctly removes objects from the design and places
them on the clipboard so that they can be pasted into a new design:

Set lay = Project.Schematics("SCH1").Layout

Set lay2 = Project.Schematics("SCH2").Layout

1408 NI AWR Design Environment


Layout

lay.SelectedObjects.AddAll
lay.InvokeCommand("EditCut")

lay2.InvokeCommand("EditPaste", Array(0, 0))

You can also use the InvokeCommand("EditDelete") that also removes objects from the layout design.

The following script uses the InvokeCommand ("PasteRelative()" method for both the API Layout object and API
EMStructure object to support pasting relative to the original location. Normal paste uses the upper left base position as
the absolute xy coordinate for placement.

Dim cellLib As CellLibrary


Dim cellEditor1 As CellEditor
Dim cellEditor2 As CellEditor
Dim objDraw As DrawingObject

Set cellLib = Project.CellLibraries("New_Gdsii_Lib")


Set cellEditor1 = cellLib.Cells("CELL1").EditCell
Set cellEditor2 = cellLib.Cells("CELL2").EditCell

cellEditor1.SelectedObjects.AddAll
cellEditor1.CopyToClipboard

If cellEditor2.CanPaste Then
cellEditor2.PasteRelative(25e-6, 25e-6) ' Paste at different location than original
cellEditor2.PasteRelative(50e-6, 50e-6) ' Paste a second time different location
End If

cellEditor2.Update
cellEditor2.Refresh

Debug.Print cellEditor2.Name
Debug.Print "DrawingObjects Count = " & cellEditor2.DrawingObjects.Count
For Each objDraw In cellEditor2.DrawingObjects
PrintDrawingObject objDraw
Debug.Print""
Next objDraw

Close #1
Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)
Debug.Print"Info Text = " & drawingObj.InfoText
Debug.Print"Selected = " & drawingObj.Selected
Debug.Print"Flipped = " & drawingObj.Flipped
Debug.Print"Rotation = " & drawingObj.RotationAngle
Debug.Print"Frozen = " & drawingObj.Frozen
Debug.Print"Base Pos = { x = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePosition.y
Debug.Print"Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)

End Sub

API Scripting Guide 1409


Layout

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Debug.Print"Parameters:"
For Each param In params
Debug.Printparam.Name & " = " & param.ValueAsString
Next param

End Sub

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Debug.Print"Attributes:"
For Each attr In attrs
If (attr.Name ne "Area") Then
Debug.Printattr.Name & " = " & attr.ValueAsString
End If
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Debug.Print"Boundary:"
Debug.Print"Left = " & bound.Left
Debug.Print"Right = " & bound.Right
Debug.Print"Top = " & bound.Top
Debug.Print"Bottom = " & bound.Bottom
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Debug.Print"Vertices:"
For Each vert In verts
Debug.Print"{ x= " & vert.x & ", y= " & vert.y & " }"
Next vert
End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Debug.Print"Edit Handles:"
For Each eh In ehs
Debug.Print"{ x= " & eh.Position.x & ", y= " & eh.Position.y & " }"
Next eh
End Sub

The following script is invoking the export schematic layout command from the API schematic object:

Dim libPath As String


Dim bError As Boolean

On Error GoTo GotError


libPath = Project.Path + "Cell_Lib_Rectangle.gds"
bError = True
Project.Schematics("SCH1").Layout.InvokeCommand("ExportSchematicLayout", Array(libPath, 0, Fals
bError = False

1410 NI AWR Design Environment


Layout

GotError:
If bError Then
Debug.Print "Encountered Error Exporting GDS file."
Else
Debug.Print "No error encountered Exporting GDS file."
End If

' Reset the error handler


On Error GoTo 0

The following script is invoking the export schematic layout command from the API schematic object as DXF file:

Dim libPath As String


Project.Schematics("SCH1").Layout.InvokeCommand("ExportSchematicLayout", Array(libPath, 1, Fals

The following is the command syntax:

Layout.InvokeCommand(String commandName, VariantArgArray args, Variant res)

The arguments are packed in an array of variants. If the command fails, the "res" argument (which is the return value)
should contain a string that provides the syntax details for the arguments to the command. This can help with any necessary
debugging.

NOTE: The 'res' argument is printed in the script.

Debug.Print res

This argument prints any error strings in the following format:

"Error: Invalid Arguments, Usage: EditPaste( VARIANT argArray ), where argArray = Array(double xPo

NOTE: Both 'argArray' and 'res' are optional, although if the command needs the arguments it fails if they are not
provided in a variant array.

The following script uses the InvokeCommand(InsertExtractionPort) method to add Edge Extraction Port. The comand
uses an arguments array.

Sub Main
Dim emp As EMPort
Dim lay As Layout

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

lay.DrawingObjects(1).Selected = True
lay.InvokeCommand("InsertExtractionPort", Array(0.0, 0.0, 0.0, 100e-6))
lay.InvokeCommand("InsertExtractionPort", Array(100e-6, 0.0, 100e-6, 100e-6))

Debug.Print lay.Name

API Scripting Guide 1411


Layout

For Each emp In lay.EMPorts


Print_Port_Attributes(emp)
Debug.Print ""
Next emp
End Sub

Sub Print_Port_Attributes(ByRef emp As EMPort)


Debug.Print "Port Numb = " & emp.Number
Debug.Print "Conductor = " & emp.Conductor
Debug.Print "Deembed = " & emp.Deembed
Debug.Print "Entity ID = " & emp.EntityID
Debug.Print "Flags = " & emp.Flags
Debug.Print "Group Num = " & emp.GroupNumber
Debug.Print "Group Type= " & emp.GroupType
Debug.Print "Layer = " & emp.Layer
Debug.Print "Line Type = " & emp.LineType
Debug.Print "Net id = " & emp.NetID
Debug.Print "Thickness = " & emp.PhysicalThickness
Debug.Print "Reference = " & emp.ReferencePlaneDist
Debug.Print "Thickness2= " & emp.Thickness

Print_ComplexNumber "Excitation: ", emp.Excitation


Print_ComplexNumber "Impdedance: ", emp.Impedance
Print_Termination "Termination:", emp.Termination
Print_Vertices "Vertices: ", emp.Vertices

End Sub

Sub Print_ComplexNumber(Title As String, ByRef ex As ComplexNumber)


Debug.Print Title
Debug.Print " Angle = " & ex.Angle
Debug.Print " Magnitude = " & ex.Magnitude
End Sub

Sub Print_Termination(Title As String, ByRef term As EMPortTermination)


Debug.Print Title
Debug.Print " ExcitationAngle = " & term.ExcitationAngle
Debug.Print " ExcitationSize = " & term.ExcitationSignalSize
Debug.Print " ExcitationPort = " & term.ExcitationPort
Print_ComplexNumber " Excitation Impedance:", term.Impedance
End Sub

Sub Print_Vertices(Title As String, ByRef verts As Vertices)


Dim vtx As Vertex

Debug.Print Title
For Each vtx In verts
Debug.Print "{ x = " & vtx.x & ", y = " & vtx.y & " } "
Next vtx
End Sub

The following script uses InvokeCommand(ShapeStretch) method to work with Layout Polygon. Since both the vertex
definition area and the offset have to be specified for this command invocation to work, this one is a little more complicated
script:

1412 NI AWR Design Environment


Layout

Sub Main
Dim lay As Layout
Dim ret As Variant
Dim dl As DrawingLayer
Dim objDraw As DrawingObject
Dim objRect As DrawingObject
Dim bFound As Boolean

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

' Find the area definition shape.


bFound = False
For Each objDraw In lay.DrawingObjects
If (objDraw.TypeBits = 1) Then
If (objDraw.Shapes(1).Vertices.Count = 4) Then
Set objRect = objDraw
bFound = True
End If
End If
Next objDraw

' Dump the results.


If (bFound) Then
Dim bnd As Boundary

Set bnd = objRect.Boundary


lay.InvokeCommand("EditSelectAll")
objRect.Selected = False
lay.InvokeCommand("ShapeStretch", Array(bnd.Left, bnd.Top, bnd.Right, bnd.Bottom, 300e-6, 0.0), r
Debug.Print ret

' Output results for comparison.


Debug.Print lay.Name
Debug.Print "DrawingObjects Count = " & lay.DrawingObjects.Count
For Each objDraw In lay.DrawingObjects
PrintDrawingObject objDraw
Debug.Print ""
Next objDraw

End If
End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " & drawingObj.InfoText
Debug.Print "Selected = " & drawingObj.Selected
Debug.Print "Flipped = " & drawingObj.Flipped
Debug.Print "Rotation = " & drawingObj.RotationAngle
Debug.Print "Frozen = " & drawingObj.Frozen
Debug.Print "Base Pos = { x = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePosition.
Debug.Print "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)

API Scripting Guide 1413


Layout

End Sub

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Debug.Print "Parameters:"
For Each param In params
Debug.Print param.Name & " = " & param.ValueAsString
Next param

End Sub

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Debug.Print "Attributes:"
For Each attr In attrs
Debug.Print attr.Name & " = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Debug.Print "Boundary:"
Debug.Print "Left = " & bound.Left
Debug.Print "Right = " & bound.Right
Debug.Print "Top = " & bound.Top
Debug.Print "Bottom = " & bound.Bottom
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Debug.Print "Vertices:"
For Each vert In verts
Debug.Print "{ x= " & vert.x & ", y= " & vert.y & " }"
Next vert
End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Debug.Print "Edit Handles:"
For Each eh In ehs
Debug.Print "{ x= " & eh.Position.x & ", y= " & eh.Position.y & " }"
Next eh
End Sub

The following is the basic implementation of stretch command invocation from API using parametric InvokeCommand
api:

' Code Module


Sub Main
Dim lay As Layout
Dim ret As Variant

Debug.Clear
Set lay = Project.Schematics("Schematic 1").Layout

1414 NI AWR Design Environment


Layout

lay.SelectedObjects.AddAll

' Arguments are (x1, y1, dx, dy) where x1 and y1 are xy coordinates of drag handle to stretch.
' dx and dy are how much to move drag handle

lay.InvokeCommand("EditStretch", Array(100e-6, 100e-6, 100e-6, 100e-6), ret)


Debug.Print ret

End Sub

In the following script we added two points to the Path and stretching them:

' Code Module


Sub Main
Dim lay As Layout

Set lay = Project.Schematics("SCH1").Layout

lay.SelectedObjects.AddAll
lay.InvokeCommand("ShapeEditPoints", Array("AddPoint", 25e-6, 0))
lay.InvokeCommand("ShapeEditPoints", Array("AddPoint", 75e-6, 0))

' Arguments for Stretch Area are (left, top, right, bottom, deltaX, deltaY)
lay.InvokeCommand("ShapeEditPoints", Array("StretchArea", 20e-6, 20e-6, 80e-6, -20e-6, 0, 20e-6))
End Sub

To add one point to the path use the following script:

Dim lay As Layout

Set lay = Project.Schematics("SCH1").Layout

lay.SelectedObjects.AddAll
lay.InvokeCommand("ShapeEditPoints", Array("AddPoint", 25e-6, 0))

The following script uses the InvokeCommand(SchematicMakeGdsCell) method for creating GDS Cells. The arguments
array is different here.

' Code Module


Sub Main
Dim sch As Schematic
Dim lay As Layout
Dim ele As Element
Dim pRet As Variant
Dim arg(3) As Variant
Debug.Clear
arg(0) = "CellLib"
arg(1) = "Cell"
arg(2) = True

' Get the schematic and layout for that schematic.

API Scripting Guide 1415


Layout

Set sch = Project.Schematics(1)


'Debug.Print schem.Name

Set lay = sch.Layout


' Select all the objects in the layout.
lay.SelectedObjects.AddFromArea(-2.8e-6,-1.2e-6,102e-6,422e-6,mwAAT_ContainedObjects)

lay.InvokeCommand("SchematicMakeGdsCell",arg,pRet)
Debug.Print pRet

End Sub

The following script uses the InvokeCommand(CellFlatten) method for flatten artwork Cells. There is no arguments
here.The usage statement indicates that the flatten level argument is optional however the logic in the command required
that a flatten level integer be passed into the argument array when invoking the command. If no flatten level is provided
INT_MAX is used as the flatten level.

Set lay = Project.Schematics("SCH1").Layout


lay.SelectedObjects.AddAll
lay.InvokeCommand("CellFlatten")

The following script uses the InvokeCommand("SchematicAssociateCell") method for associating pCells with Elements.
The Arguments array is the Elements name.

' Code Module


Sub Main
Dim lay As Layout
Dim schem As Schematic
Dim objDraw As DrawingObject
Dim eleName As String

Set schem = Project.Schematics("SCH1")


Set lay = schem.Layout

PrintElementCellState schem, "Before Associate:"

For i = 1 To schem.Elements.Count
lay.SelectedObjects.RemoveAll
lay.DrawingObjects(i).Selected = True
eleName = schem.Elements(i).Name
lay.InvokeCommand("SchematicAssociateCell", Array(eleName))
Next i

PrintElementCellState schem, "After Associate:"

End Sub

Sub PrintElementCellState(ByRef schem As Schematic, title As String)


Dim elem As Element

Debug.Print title
For Each elem In schem.Elements
Debug.Print elem.Name & " has cell = " & elem.HasLayoutCell
Next elem

1416 NI AWR Design Environment


Layout

End Sub

The following script uses the InvokeCommand ("EditorSpaceEvenlyVertical", args, res) method for invoking the
Draw/Align Shapes/Space Evenly Down command.

' Code Module


Sub Main
Dim sch As Schematic
Dim lay As Layout
Dim ele As Element
Dim var1 As Variant
Dim var2 As Variant
Dim edgeToEdge As Integer
Dim centerToCenter As Integer

Set sch = Project.Schematics(1)


For Each ele In sch.Elements
ele.Selected = True
Next ele
Set lay = sch.Layout

Debug.Clear

lay.SelectedObjects.AddAll

centerToCenter = 1
' edgeToEdge = 1

lay.InvokeCommand("EditorSpaceEvenlyVertical", Array(10e-6, centerToCenter), var2)


'lay.InvokeCommand("EditorSpaceEvenlyVertical", Array(10e-6, edgeToEdge), var2)

Debug.Print var2

End Sub

In this example, the value 10e-6 is the spacing. You should select the objects you want to space, as shown in the script.
This script also includes a Print command for the return variable "var2". If there is a problem with the values a usage
statement is included in the return variant to help with debugging.

The following script uses the InvokeCommand ("EditMirror",args) method for invoking the Mirror command. The
arguments for this are x1, y1, x2, y2 of the mirror line. To execute the ("EditMirror",args) method we need to select all
drawing objects in layout. Before using the command we need to specify the type of drawing objects we want to apply
the mirror command (no need for Artwork Cell, Path, or MLIN Elenents for EMStructure layout). For example for the
polygon the type will be 65, for the net route it will be 64. To find out the type of drawing object we should use the
following code:

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject

API Scripting Guide 1417


Layout

Set lay = Project.Schematics("SCH1").Layout

For Each objDraw In lay.DrawingObjects


Debug.Print objDraw.TypeBits
Next objDraw

End Sub

After identifying the type of the objects we can use the following script for the Mirror:

' Code Module


Sub Main
Dim lay As Layout
Dim ret As Variant
Dim objDraw As DrawingObject

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If

lay.Activate

PrintDrawObjectsState lay, "Before Mirror Command"

For Each objDraw In lay.DrawingObjects

If objDraw.TypeBits = 64 Then
objDraw.Selected = True
End If
Next objDraw

lay.InvokeCommand("EditMirror", Array(250e-6, -10e-6, 250e-6, 200e-6))

PrintDrawObjectsState lay, "After Mirror Command"

End Sub

Sub PrintDrawObjectsState(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject

Debug.Print title

' Dump the results of a file for comparison.


Debug.Print "Layout = " & lay.Name
Debug.Print "DrawingObjects Count = " & lay.DrawingObjects.Count
For Each objDraw In lay.DrawingObjects
PrintDrawingObject objDraw
Debug.Print ""
Next objDraw
Debug.Print ""

End Sub

1418 NI AWR Design Environment


Layout

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " & drawingObj.InfoText
Debug.Print "Selected = " & drawingObj.Selected
Debug.Print "Flipped = " & drawingObj.Flipped
Debug.Print "Rotation = " & drawingObj.RotationAngle
Debug.Print "Frozen = " & drawingObj.Frozen
Debug.Print "Base Pos = { xamp; = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePosi
Debug.Print "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)

End Sub

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Debug.Print "Parameters:"
For Each param In params
Debug.Print param.Name & " = " & param.ValueAsString
Next param

End Sub

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Debug.Print "Attributes:"
For Each attr In attrs
Debug.Print attr.Name & " = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Debug.Print "Boundary:"
Debug.Print "Left = " & bound.Left
Debug.Print "Right = " & bound.Right
Debug.Print "Top = " & bound.Top
Debug.Print "Bottom = " & bound.Bottom
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Debug.Print "Vertices:"
For Each vert In verts
Debug.Print "{ x= " & vert.x & ", y= " & vert.y & " }"
Next vert
End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Debug.Print "Edit Handles:"
For Each eh In ehs
Debug.Print "{ x= " & eh.Position.x & ", y= " & eh.Position.y & " }"
Next eh

API Scripting Guide 1419


Layout

End Sub

The following scripts show invoking the generic any angle rotation command from the API and specifying a specific
rotation point and angle. The first script shows how to rotate pCell:

lay.SelectedObjects.AddAll
lay.InvokeCommand("EditRotate", Array(0.0, 0.0, 90), ret )

The second script shows how to rotate polygon using drawing objects (we support any arbitrary rotation):

Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If

lay.Activate

PrintDrawObjectsState lay, "Before Rotate 90"

For Each objDraw In lay.DrawingObjects


objDraw.RotationAngle = objDraw.RotationAngle + 90
Next objDraw

lay.Refresh

PrintDrawObjectsState lay, "After Rotate 90"

End Sub

Sub PrintDrawObjectsState(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject

Debug.Print title

' Dump the results of a file


Debug.Print "Layout = " & lay.Name
Debug.Print "DrawingObjects Count = " & lay.DrawingObjects.Count
For Each objDraw In lay.DrawingObjects
PrintDrawingObject objDraw
Debug.Print ""
Next objDraw
Debug.Print ""

End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " & drawingObj.InfoText

1420 NI AWR Design Environment


Layout

Debug.Print "Selected = " & drawingObj.Selected


Debug.Print "Flipped = " & drawingObj.Flipped
Debug.Print "Rotation = " & drawingObj.RotationAngle
Debug.Print "Frozen = " & drawingObj.Frozen
Debug.Print "Base Pos = { x = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePosition.
Debug.Print "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)

End Sub

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Debug.Print "Parameters:"
For Each param In params
Debug.Print param.Name & " = " & param.ValueAsString
Next param

End Sub

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Debug.Print "Attributes:"
For Each attr In attrs
Debug.Print attr.Name & " = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Debug.Print "Boundary:"
Debug.Print "Left = " & bound.Left
Debug.Print "Right = " & bound.Right
Debug.Print "Top = " & bound.Top
Debug.Print "Bottom = " & bound.Bottom
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Debug.Print "Vertices:"
For Each vert In verts
Debug.Print "{ x= " & vert.x & ", y= " & vert.y & " }"
Next vert
End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Debug.Print "Edit Handles:"
For Each eh In ehs
Debug.Print "{ x= " & eh.Position.x & ", y= " & eh.Position.y & " }"
Next eh
End Sub

API Scripting Guide 1421


Layout

The third script shows how to rotate net route using InvokeCommand method:

Sub Main
Dim lay As Layout
Dim ret As Variant
Dim objDraw As DrawingObject

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If

lay.Activate

PrintDrawObjectsState lay, "Before Rotate Command"

For Each objDraw In lay.DrawingObjects


If (objDraw.TypeBits = 64) Then
objDraw.Selected = True
End If
Next objDraw

lay.InvokeCommand("EditRotate", Array(0.0, 0.0, 90), ret )

PrintDrawObjectsState lay, "After Rotate Command"

lay.InvokeCommand("EditUndo")

PrintDrawObjectsState lay, "After Rotate Command Undo"

lay.InvokeCommand("EditRedo")

PrintDrawObjectsState lay, "After Rotate Command Redo"

End Sub

See previous code for the PrintDrawObjectsState(ByRef lay As Layout, title As String) subroutine.

The following script uses the InvokeCommand ("CellFlatten",args, res) method for invoking the Draw/Flatten Cell
command.

Dim lay As Layout


Dim ret As Variant
Dim dl As DrawingLayer
Dim objDraw As DrawingObject

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

lay.SelectedObjects.AddAll
lay.InvokeCommand("CellFlatten", Array(1000))

1422 NI AWR Design Environment


Layout

The following script uses the InvokeCommand ("EditFlip",args) method for invoking the Flip command for pCell,
artwork Cell, mosaic artwork cells:

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If
lay.Activate

lay.SelectedObjects.AddAll
lay.InvokeCommand("EditFlip", Array(250e-6, -10e-6, 250e-6, 200e-6))

The following script uses the InvokeCommand ("ShapeMakePolygon") method. This command converts various higher
level shapes into basic polygon equivalents. It can be used to convert ellipses, circles, and paths into polygons. It can
also be used to fill Arcs and convert closed or nearly closed polylines into filled polygon equivalents. This command
works correctly on a range of objects including net associated objects and retains the association during the conversion.
It is available for Ellipses, Paths, Arcs, Net Ellipses, and Net Paths in NI AWR DE GUI. The menu item for it is on Draw
-> Modify Shapes -> Make Polygon. The command in API looks like:

Dim lay As Layout


Dim objDraw As DrawingObject

Set lay = Project.Schematics("SCH1").Layout

lay.SelectedObjects.RemoveAll
For Each objDraw In lay.DrawingObjects
If (objDraw.TypeBits = 65) Then
objDraw.Selected = True
End If
Next objDraw

lay.InvokeCommand("ShapeMakePolygon") ' Convert to Polygon.

The following script uses the InvokeCommand ("InsertPolygon") method. This command draw a polygon on the certain
layer. The command in API looks like:

' Code Module


Sub Main
Dim schem As Schematic
Dim lay As Layout
Dim ret As Variant
Dim dl As DrawingLayer
Dim objDraw As DrawingObject
dim ret as Variant

' Get the schematic and layout for that schematic.


Set schem = Project.Schematics("test_layout")

Set lay = schem.Layout

API Scripting Guide 1423


Layout

' Drawing polygon on Layer "Poly"

Set dl = Project.ProcessDefinitions(1).LayerSetup.DrawingLayers("Poly")

Poly_on_Layer lay, dl

End Sub
Sub Poly_on_Layer(ByRef lay As Layout, dl As DrawingLayer)

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If

Project.ProcessDefinitions(1).LayerSetup.DrawingLayers.ActiveLayer = dl
Debug.Print "Setting Layer = " & dl.Name
Debug.Print "Active Layer = " & Project.ProcessDefinitions(1).LayerSetup.DrawingLayers.ActiveLaye

lay.InvokeCommand("InsertPolygon", Array(8, 0, 0, 0, 100e-6, 100e-6, 100e-6, 100e-6, 0), ret)

Debug.Print ret

End Sub

Layout Faces Collection of Objects

The collection of Faces objects in Layout is associated with the DrawingObjects collection. The following script explores
all DrawingObjects, collections of Faces, and Faces properties:

' Code Module


Sub Main
Dim sch As Schematic
Dim dra As DrawingObject
Dim fac As Face
Debug.Clear
Set sch = Project.Schematics("Model Lange")
Debug.Print "Layout.DrawingObjects.Count = ";
sch.Layout.DrawingObjects.Count
For Each dra In sch.Layout.DrawingObjects
Debug.Print "dra.Faces.Count = ";dra.Faces.Count
Next dra
Set dra = sch.Layout.DrawingObjects(2)
For Each fac In dra.Faces
Debug.Print "Alignment = ";fac.Alignment;vbTab;"Flipped = ";
fac.Flipped;vbTab;"LayerProperty = ";fac.LayerProperty
Debug.Print "NodeNumber = ";fac.NodeNumber;vbTab;"Offset.dx = ";
fac.Offset.dx;vbTab;"Offset.dy = ";fac.Offset.dy
Debug.Print "LeftEnd.x = ";fac.LeftEnd.x;vbTab;"LeftEnd.y = ";
fac.LeftEnd.y;vbTab;"RightEnd.x = ";fac.RightEnd.x;vbTab;"RightEnd.y = ";fac.RightEnd.y
Debug.Print "OffsetAngle = ";fac.OffsetAngle;vbTab;"PortNumber = ";
fac.PortNumber;vbTab;"SnapToAdjacent = ";fac.SnapToAdjacent
Next fac
End Sub

1424 NI AWR Design Environment


Layout

The following is additional general code showing the API access to each of the properties associated with the Faces of
a Layout drawing object:

' Code Module


Sub Main
Dim lay As Layout

Set lay = Project.Schematics("SCH1").Layout


PrintFaceProperties lay, "Layout Drawing Object Face Properties:"

End Sub

Sub PrintFaceProperties(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject
Dim layFace As Face
Dim vtx As Vertex
Dim index As Integer
Debug.Print title

For Each objDraw In lay.DrawingObjects


For Each layFace In objDraw.Faces
Debug.Print "Element Name = " & layFace.ElementName
Debug.Print "Port Number = " & layFace.PortNumber
Debug.Print "Snap Object = " & layFace.SnapToObject
Debug.Print "Alignment = " & layFace.Alignment
Debug.Print "Area Enabled = " & layFace.AreaEnabled
Debug.Print "Connected = " & layFace.Connected
Debug.Print "ConnectedNetName = " & layFace.ConnectedNetName
Debug.Print "Connect Type = " & layFace.ConnectType
Debug.Print "Drawing Layer = " & layFace.DrawingLayer
Debug.Print "Flipped = " & layFace.Flipped
Debug.Print "Group Number = " & layFace.GroupNumber
Debug.Print "Group Type = " & layFace.GroupType
Debug.Print "Node Number = " & layFace.NodeNumber
Debug.Print "Offset.x = " & layFace.Offset.dx
Debug.Print "Offset.y = " & layFace.Offset.dy
Debug.Print "Offset Angle = " & layFace.OffsetAngle
Debug.Print "Port Number = " & layFace.PortNumber
Debug.Print "Type = " & layFace.Type
Debug.Print "Vertices: "
index = 1
For Each vtx In layFace.Vertices
Debug.Print" vtx[" & index & "] = { x = " & vtx.x & ", y = " & vtx.y & " }
index = index + 1
Next vtx
Debug.Print ""
Next layFace
Next objDraw
Debug.Print ""
End Sub

This script shows how to access Face properties. You can set the properties to a desired value.

The additional properties for Face and Pin objects include connect type, face shape type, group number, group type, and
whether the area portion of a pin is enabled for connection.

API Scripting Guide 1425


Layout

The following code finds the vertices of the Schematic ports using the Faces collection of objects:

Dim schem As Schematic


Dim elem As Element
Dim objName As String
Dim nodeNum As Integer
Dim objDraw As DrawingObject
Dim objFace As Face
' Clear the output debugging window
Debug.Clear
' Process each of the schematics and the elements of each schematic
For Each schem In Project.Schematics
Debug.Print "Schematic: " & schem.Name
'Process the elements of the schematic looking for ports
For Each elem In schem.Elements
objName = Left(elem.Name, 4)
' If this is a port then get the node number and look for the vertices.
If objName = "PORT" Then
Debug.Print elem.Name; " Node Number = "; elem.Nodes.Item(1).NodeNumber
nodeNum = elem.Nodes.Item(1).NodeNumber
For Each objDraw In schem.Layout.DrawingObjects
For Each objFace In objDraw.Faces
If (objFace.NodeNumber = nodeNum) And Left(objDraw.Element.Name,4) <>"PORT" Then
Debug.Print "Vertices[1]: X = "; objFace.RightEnd.x; " Y = "; objFace.RightEnd.y; " for ele
Debug.Print "Vertices[2]: X = "; objFace.LeftEnd.x; " Y = "; objFace.LeftEnd.y; " for ele ";
End If
Next objFace
Next objDraw
End If
Next elem
Next schem

If the GDS cell associated with a model has two cell faces, both assigned to one port, use the following script:

Sub Main
Debug.Clear
Dim e As Element
Dim f As Face

Set e = Project.Schematics(1).Elements(1)
Debug.Print "Num Faces: " & e.DrawingObjects(1).Faces.Count
For Each f In e.DrawingObjects(1).Faces
Debug.Print "PortNum: " & f.PortNumber & " SubPortNum: " & f.SubPortNumber
Next f
End Sub

This code generates the following output:

Num Faces: 2
PortNum: 1 SubPortNum: 1
PortNum: 1 SubPortNum: 2

The NI AWR SDE has many properties for the Face object, including:

1426 NI AWR Design Environment


Layout

AreaEnabled
connectType
DrawingLayer
ElementName
GroupNumber
GroupType
Type

This script sets the SnapToObject and node for a Face.

The SnapToObject is set in a manner similar to that given in the Cell Options dialog box Faces tab Snap to option. In
this dialog box the name of the Element is a combination of the Element type and the Element ID. This is followed by
a ":" colon and the preferred node number. So, for example, a Thin Film capacitor might be specified as "TFC.V1:1",
meaning Thin Film Capacitor, ID="V1" and the preferred node=1. Another example is for the second node of a MLIN
"MLIN.TL2:2", meaning an MLIN element ID=TL2 and preferred node=2.

With this addition, you can automatically set the face offset to make the rat line go away. This is a very difficult task in
the user interface, because you must understand a coordinate transform to do it correctly.

The following code shows how to set SnapToObject using the Faces collection of objects:

' Code Module


Sub Main
Dim lay As Layout

Set lay = Project.Schematics("SCH1").Layout


PrintFaceProperties lay, "Before Setting Snap Object"
SetSnapToObj lay
PrintFaceProperties lay, "After Setting Snap Object"
ClearSnapToObj lay
PrintFaceProperties lay, "After Clearing Snap Object"

End Sub

Sub PrintFaceProperties(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject
Dim layFace As Face
Debug.Print title

For Each objDraw In lay.DrawingObjects


For Each layFace In objDraw.Faces
Debug.Print "Element Name = " & layFace.ElementName
Debug.Print "Port Number = " & layFace.PortNumber
Debug.Print "Snap Object = " & layFace.SnapToObject
Next layFace
Next objDraw
Debug.Print ""
End Sub

Sub SetSnapToObj(ByRef lay As Layout)


Dim objDraw As DrawingObject

API Scripting Guide 1427


Layout

Dim layFace As Face

For Each objDraw In lay.DrawingObjects


For Each layFace In objDraw.Faces
layFace.SnapToObject = ""
If (layFace.ElementName = "TFC.V1" And layFace.PortNumber = 1) Then
layFace.SnapToObject = "MLIN.TL1:2"
End If
Next layFace
Next objDraw
End Sub

Sub ClearSnapToObj(ByRef lay As Layout)


Dim objDraw As DrawingObject
Dim layFace As Face

For Each objDraw In lay.DrawingObjects


For Each layFace In objDraw.Faces
layFace.SnapToObject = ""
Next layFace
Next objDraw
End Sub

Note that the node number index basis is 1 (not zero), to be consistent with the user interface.

The following code shows that changes to the Face Alignment property result in changes to the Face Connection location.
This code sets the Face Alignment to several values:

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject
Dim objFace As Face

Set lay = Project.Schematics("SCH1").Layout


Set objDraw = lay.DrawingObjects(1)
Set objFace = objDraw.Faces(2)

Debug.Print "Element Name = " & objFace.ElementName


Debug.Print "Alignment = " & objFace.Alignment

objFace.Alignment = mwFA_Left

PrintFlightLineState lay, "Alignment = Left"

objFace.Alignment = mwFA_Right

PrintFlightLineState lay, "Alignment = Right"

objFace.Alignment = mwFA_Center

PrintFlightLineState lay, "Alignment = Center"

End Sub

1428 NI AWR Design Environment


Layout

Sub PrintFlightLineState(ByRef lay As Layout, title As String)


Dim physNet As PhysicalNet
Dim fl As FlightLine
Dim index As Integer

Debug.Print title
Debug.Print "FlightLines: "
For Each physNet In lay.PhysicalNets
Debug.Print "Net Name = " & physNet.Name
index = 1
For Each fl In physNet.FlightLines
Debug.Print "FlightLine[" & index & "] = From: x = " & fl.Begin.x & ", y = " & fl.Begin.y;
Debug.Print " To: x = " & fl.End.x & ", y = " & fl.End.y
inde = index + 1
Next fl
Next physNet
Debug.Print ""

End Sub

The following code shows interface for accessing the adjacent objects from a face object. This allows the user to
programmatically determine the objects that can be set as the snap-to object for a given face:

' Code Module


Sub Main
Dim lay As Layout

Set lay = Project.Schematics("SCH1").Layout


PrintFaceProperties lay, "Layout Face Properties"

End Sub

Sub PrintFaceProperties(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject
Dim layFace As Face
Dim objName As ObjectName

Debug.Print title

For Each objDraw In lay.DrawingObjects


For Each layFace In objDraw.Faces
Debug.Print "Element Name = " & layFace.ElementName
Debug.Print "Port Number = " & layFace.PortNumber
Debug.Print "Snap Object = " & layFace.SnapToObject
Debug.Print "Adjacent Objects:"
For Each objName In layFace.AdjacentObjects
Debug.Print " " & objName.Name
Next objName
Next layFace
Next objDraw
Debug.Print ""
End Sub

Sub SetSnapToObj(ByRef lay As Layout)


Dim objDraw As DrawingObject

API Scripting Guide 1429


Layout

Dim layFace As Face

For Each objDraw In lay.DrawingObjects


For Each layFace In objDraw.Faces
layFace.SnapToObject = ""
If (layFace.ElementName = "TFC.V1" And layFace.PortNumber = 1) Then
layFace.SnapToObject = "MLIN.TL1:1"
End If
Next layFace
Next objDraw
End Sub

Sub ClearSnapToObj(ByRef lay As Layout)


Dim objDraw As DrawingObject
Dim layFace As Face

For Each objDraw In lay.DrawingObjects


For Each layFace In objDraw.Faces
layFace.SnapToObject = ""
Next layFace
Next objDraw
End Sub

The following code offsets a face from its base position, prints the flight line state, updates the offset, and then prints the
resulting state of the flight lines to determine if the face offset was performed correctly:

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject
Dim objFace As Face

Set lay = Project.Schematics("SCH1").Layout


Set objDraw = lay.DrawingObjects(1)
Set objFace = objDraw.Faces(2)

Debug.Print "Element Name = " & objFace.ElementName


Debug.Print "Alignment = " & objFace.Alignment

PrintFlightLineState lay, "Before Offset"

objFace.Offset.dy = 10e-6
objFace.Alignment = mwFA_OffsetFix

PrintFlightLineState lay, "After Offset"

objFace.Offset.dy = 0
objFace.Alignment = mwFA_Center

PrintFlightLineState lay, "After Restore"

End Sub

Sub PrintFlightLineState(ByRef lay As Layout, title As String)


Dim physNet As PhysicalNet
Dim fl As FlightLine

1430 NI AWR Design Environment


Layout

Dim index As Integer

Debug.Print title
Debug.Print "FlightLines: "
For Each physNet In lay.PhysicalNets
Debug.Print "Net Name = " & physNet.Name
index = 1
For Each fl In physNet.FlightLines
Debug.Print "FlightLine[" & index & "] = From: x = " & fl.Begin.x & ", y = " & fl.Begin.y;
Debug.Print " To: x = " & fl.End.x & ", y = " & fl.End.y
inde = index + 1
Next fl
Next physNet
Debug.Print ""

End Sub

The following code finds connection points between flight lines and faces. Having the flight line end point we can
compare that with the pins or faces associated with the physical net or drawing to figure out which one is the correct one
by position. The connection point represents an estimate of where the flight line would connect to a face if there is one.
We can use connection point property to the face API object. API gives us an access to a connection point vertex object
accessible from the face object to provide an indication of the default connection point for the face. The connection point
should represent the location where the flight line is likey to connect to the face if the face is not matched to another
face. Note that for nodes with multiple faces there will be a connection point on each face but the flight lines will connect
to the connection points on the closest faces. In the following script we use a dictionary to try to identify which elements
are connected via a flightline. The dictionary can only take a single argument so the script takes the coordinates for the
connection point and computes a cantor pair key and uses that for the dictionary key. In the elements display the number
after the : should be the face index that is connected.You can see it in the bottom of the output:

' Code Module


Sub Main
Dim dict As Object
Dim elem As Element
Dim schem As Schematic
Dim objDraw As DrawingObject
Dim objFace As Face
Dim key As Long
Dim index As Integer

Set dict = CreateObject("Scripting.Dictionary")

' Create a mapping between the face points and the element names
' Dictionary can only handle single value key so compute key from pair of coordinates
Debug.Clear
Set schem = Project.Schematics("s1")
For Each elem In schem.Elements
Debug.Print elem.Name
For Each objDraw In elem.DrawingObjects
index = 1
For Each objFace In objDraw.Faces
If (objFace.Connected) Then

' use 1e7 to allow one decimal place of precision in key.


key = CalcCantorPairing(objFace.ConnectionPoint.x * 1e7, objFace.ConnectionPoint.y * 1e7)

API Scripting Guide 1431


Layout

dict.Add key, elem.Name & ":" & index


Debug.Print "Connect Point = {" & objFace.ConnectionPoint.x * 1e6 & ", " & objFace.ConnectionP
Debug.Print " Key = " & key

End If
index = index + 1
Next objFace
Next objDraw
Next elem

' Traverse flight lines compute matching key and if there is a match in diction ary get element na
Debug.Print
Debug.Print "FlightLines"
Dim physNet As PhysicalNet
Dim fltLine As FlightLine
For Each physNet In schem.Layout.PhysicalNets
For Each fltLine In physNet.FlightLines
Debug.Print "Flight Line = {" & fltLine.Begin.x * 1e6 & ", " & fltLine.Begin.y * 1e6 & "}";
Debug.Print ", {" & fltLine.End.x * 1e6 & ", " & fltLine.End.y * 1e6 & "}"

' use 1e7 here to allow one decimal place of precision in key.
key = CalcCantorPairing(fltLine.Begin.x * 1e7, fltLine.Begin.y * 1e7)
If (dict.Exists(key)) Then
Debug.Print "From: " & dict(key)
End If

' use 1e7 here to allow one decimal place of precision in key.
key = CalcCantorPairing(fltLine.End.x * 1e7, fltLine.End.y * 1e7)
If (dict.Exists(key)) Then
Debug.Print "To: " & dict(key)
End If

Next fltLine
Next physNet
End Sub

' https://en.wikipedia.org/wiki/Pairing_function
Function CalcCantorPairing(k1 As Long, k2 As Long) As Long
CalcCantorPairing = (1/2)*(k1+k2)*(k1 + k2 +1) + k2
End Function

This code generates the following output:

TFCM.TL5
Connect Point = {94, 22} Key = 673600
Connect Point = {72, 44} Key = 673820
Connect Point = {72, 0} Key = 259560
Connect Point = {50, 22} Key = 259780
TFCM.TL6
Connect Point = {4, 22} Key = 34150
Connect Point = {22, 40} Key = 192910
Connect Point = {22, 4} Key = 33970
Connect Point = {40, 22} Key = 192730

FlightLines

1432 NI AWR Design Environment


Layout

Flight Line = {40, 22}, {50, 22}


From: TFCM.TL6:4
To: TFCM.TL5:8

Adding an Extraction Port to a Schematic Layout

The following script adds EM ports to the MLIN element where the faces are located. It does not add them to the dumb
shape.

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject
Dim objFace As Face
Dim emprt As EMPort
Dim ver As Vertex

Debug.Clear

Set lay = Project.Schematics("Schematic 1").Layout


For Each objDraw In lay.DrawingObjects
Debug.Print "Drawing object"
Debug.Print "Ports count = : ";objDraw.EMPorts.Count
For Each objFace In objDraw.Faces
objDraw.EMPorts.Add(mwSPT_EdgePort, objFace.Vertices(1).x, objFace.Vertices(1).y, objFace.Vertic
Next objFace
Next objDraw

For Each objDraw In lay.DrawingObjects


Debug.Print "Drawing object"
Debug.Print "Ports count = : ";objDraw.EMPorts.Count
For Each emprt In objDraw.EMPorts

Debug.Print emprt.Deembed;vbTab;emprt.GroupNumber;vbTab;emprt.GroupType
Debug.Print emprt.Excitation.Angle;vbTab;emprt.Excitation.Imaginary;vbTab;emprt.Excitation.Magni
Debug.Print "Port Number = ";emprt.Number ;vbTab;emprt.Thickness
Debug.Print emprt.Impedance.Angle;vbTab;emprt.Impedance.Imaginary;vbTab;emprt.Impedance.Magnitud
Debug.Print emprt.Termination.ExcitationAngle;vbTab;emprt.Termination.ExcitationPort;vbTab;emprt
Debug.Print emprt.Termination.Impedance.Angle;vbTab;emprt.Termination.Impedance.Imaginary;vbTab;
Debug.Print emprt.Termination.ExcitationPort
Debug.Print emprt.Conductor
Debug.Print emprt.EntityID
Debug.Print emprt.Flags
Debug.Print emprt.Layer
Debug.Print emprt.NetID
Debug.Print emprt.PhysicalThickness
Debug.Print emprt.ReferencePlaneDist
For Each ver In emprt.Vertices
Debug.Print ver.x;vbTab;ver.y
Next ver
Next emprt
Next objDraw
End Sub

API Scripting Guide 1433


Layout

This code generates the following output:

Drawing object
Ports count = : 0
Drawing object
Ports count = : 0
Drawing object
Ports count = : 2
True 0 0
0 0 0 0
Port Number = 2 0
0 0 50 50
0 False 1
0 0 50 50
False

1
0
0
0
0
0
0.0001 0.00004
0.0001 0
0.0001 0.00004
0.0001 0
0.0001 0.00004
True 0 0
0 0 1 1
Port Number = 1 0
0 0 50 50
0 True 1
0 0 50 50
True

0
0
0
0
0
0
0 0
0 0.00004
0 0
0 0.00004
0 0
Drawing object
Ports count = : 0

The following provides access to layout extraction ports, setting the port excitation values for an EM port through the
excitation imaginary values and through the port termination properties, using the API impedance complex value interface.
Script also provides port information.

' Code Module

1434 NI AWR Design Environment


Layout

Sub Main
Dim lay As Layout

Set lay = Project.Schematics("SCH1").Layout


Debug.Print lay.Name

Print_Ports_Status lay, "*** Before Setting Excitation ***"


Update_Port_Excitation lay, 10, 10
Print_Ports_Status lay, "*** After Setting Excitation 10, 10 ***"
Update_Port_Excitation lay, 1, 1
Print_Ports_Status lay, "** After Setting Excitation 1, 1 ***"
End Sub

Sub Update_Port_Excitation(ByRef lay As Layout, real As Double, imag As Double)


Dim objDraw As DrawingObject
Dim emp As EMPort

For Each objDraw In lay.DrawingObjects


For Each emp In objDraw.EMPorts
If (emp.Termination.ExcitationPort) Then
emp.Excitation.Real = real
emp.Excitation.Imaginary = imag
End If
Next emp
Next objDraw

End Sub

Sub Print_Ports_Status(ByRef lay As Layout, Title As String)


Dim objDraw As DrawingObject
Dim emp As EMPort

Debug.Print Title

For Each objDraw In lay.DrawingObjects


For Each emp In objDraw.EMPorts
Print_Port_Attributes(emp)
Debug.Print ""
Next emp
Next objDraw
Debug.Print ""
End Sub

Sub Print_Port_Attributes(ByRef emp As EMPort)


Debug.Print "Conductor = " & emp.Conductor
Debug.Print "Deembed = " & emp.Deembed
Debug.Print "Entity ID = " & emp.EntityID
Debug.Print "Flags = " & emp.Flags
Debug.Print "Group Num = " & emp.GroupNumber
Debug.Print "Group Type= " & emp.GroupType
Debug.Print "Layer = " & emp.Layer
Debug.Print "Line Type = " & emp.LineType
Debug.Print emp.NetID
Debug.Print emp.Number
Debug.Print emp.PhysicalThickness
Debug.Print emp.ReferencePlaneDist
Debug.Print emp.Thickness

API Scripting Guide 1435


Layout

Print_ComplexNumber "Excitation: ", emp.Excitation


Print_ComplexNumber "Impdedance: ", emp.Impedance
Print_Termination "Termination:", emp.Termination
Print_Vertices "Vertices: ", emp.Vertices

End Sub

Sub Print_ComplexNumber(Title As String, ByRef ex As ComplexNumber)


Debug.Print Title
Debug.Print " Angle = " & ex.Angle
Debug.Print " Magnitude = " & ex.Magnitude
Debug.Print " Real = " & ex.Real
Debug.Print " Imaginary = " & ex.Imaginary
End Sub

Sub Print_Termination(Title As String, ByRef term As EMPortTermination)


Debug.Print Title
Debug.Print " ExcitationAngle = " & term.ExcitationAngle
Debug.Print " ExcitationSize = " & term.ExcitationSignalSize
Debug.Print " ExcitationPort = " & term.ExcitationPort
Print_ComplexNumber " Excitation Impedance:", term.Impedance
End Sub

Sub Print_Vertices(Title As String, ByRef verts As Vertices)


Dim vtx As Vertex

Debug.Print Title
For Each vtx In verts
Debug.Print "{ x = " & vtx.x & ", y = " & vtx.y & " } "
Next vtx
End Sub

Setting magnitude and angle through the port termination properties:

Sub Main
Dim lay As Layout

Set lay = Project.Schematics("SCH1").Layout


Debug.Print lay.Name

Print_Ports_Status lay, "*** Before Setting Excitation ***"


Update_Port_Excitation lay, 10, 45
Print_Ports_Status lay, "*** After Setting Excitation 10, 45 ***"
Update_Port_Excitation lay, 1, 30
Print_Ports_Status lay, "** After Setting Excitation 1, 30 ***"
End Sub

Sub Update_Port_Excitation(ByRef lay As Layout, mag As Double, ang As Double)


Dim objDraw As DrawingObject
Dim emp As EMPort

For Each objDraw In lay.DrawingObjects


For Each emp In objDraw.EMPorts
If (emp.Termination.ExcitationPort) Then

1436 NI AWR Design Environment


Layout

emp.Termination.ExcitationAngle = ang
emp.Termination.ExcitationSignalSize = mag
End If
Next emp
Next objDraw

End Sub

Adding Layout Cell objects to layout without associated element objects.

There are two methods for adding cells, AddCell() and AddLayoutCell(). The AddCell() method adds an artwork cell
from a project library.

The following script adds PCell object directly to layout without having to specify an element in the schematic side. For
example, MLIN cell could be created with the following code:

Dim lay As Layout


Set lay = Project.Schematics("Schematic 1").Layout
lay.DrawingObjects.AddLayoutCell("MLIN*", 100e-6, 100e-6)

Accessing layout parameters.

We can access all the parameters of a layout drawing object:

Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject

Set lay = Project.Schematics("SCH1").Layout


Set objDraw = lay.DrawingObjects(1)
PrintParamState objDraw

End Sub

Sub PrintParamState(ByRef objDraw As DrawingObject)


Dim layParam As LayoutParameter
Dim layParam2 As LayoutParameter

For Each layParam In objDraw.Parameters


Debug.Print "Param Name = " & layParam.Name
Debug.Print "Param Type = " & layParam.ParameterType
Debug.Print "Param Unit Type = " & layParam.UnitType
If layParam.ParameterType = mwLPDT_Integer Or layParam.ParameterType = mwLPDT_Real Then
Debug.Print "Param Double Val = " & layParam.ValueAsDouble
Debug.Print "Param Int Val = " & layParam.ValueAsInteger
End If
Debug.Print "Param String Val = " & layParam.ValueAsString
Next layParam

Accessing unit type of layout cell parameters.

We can obtain unit type of layout cell from the parameter objects of a layout drawing object:

API Scripting Guide 1437


Layout

Debug.Print Project.Schematics(1).Layout.DrawingObjects(1).Parameters(1).UnitType

Constants that define different type of units are in the following table:

We can add the parameter objects to a layout drawing object with the following code:

objDraw.Parameters.Add("MyParam", 100e-6, mwUT_Length)


' Adding layout parameter Integer
objDraw.Parameters.AddInteger("MyParam", 100)
' Adding layout parameter String
objDraw.Parameters.AddString("MyParam", "MyString")

Be aware of read-only method for the layout parameters collection that allows API users to determine which objects can
have parameters added or removed and which cannot.

Access to Layout Shape Modification Commands

NOTE:The NI AWR SDE does not log events executed via script, so you cannot rely on Undo/Redo operations after
manual changes to a Layout.

The NI AWR SDE allows some Boolean operations via the InvokeCommand():

lay.InvokeCommand("ShapeCreateMosaic", Array(2, 2, 300e-6, 300e-6, 1), retVal)


Debug.Print retVal

As previously discussed, you need to select InvokeCommand() objects.

To copy an Array:

' Select top shape and array copy center to center r3,c5 dx=40 dy=50
lay.SelectedObjects.AddFromArea(-90e-6,40e-6,-50e-6,75e-6,mwAAT_ContainedObjects)
lay.InvokeCommand "ShapeArrayCopy", Array(5,3,40e-6,50e-6,0)

To use Exclusive Or:

Set lay = schem.Layout

1438 NI AWR Design Environment


Layout

' Select all the objects in the layout.


lay.SelectedObjects.AddAll
' Invoke the ShapeExclusiveOr on the resulting selected shapes.
lay.InvokeCommand("ShapeExclusiveOr")

To use Shape Intersect:

' Invoke the ShapeIntersect on the resulting selected shapes.


lay.InvokeCommand("ShapeIntersect")

To create a Ring:

' Select all shapes and make ring


lay.SelectedObjects.AddAll
lay.InvokeCommand "ShapeMakeRing", 2e-6

To Resize:

' Select top set of shapes and resize bigger


lay.SelectedObjects.AddFromArea(-50e-6,-40e-6,70e-6,20e-6,mwAAT_ContainedObjects)
lay.InvokeCommand("ShapeResize", Array(25e-6))

To Resize Copy:

' Select all shapes and resizecopy


lay.SelectedObjects.AddAll
lay.InvokeCommand ("ShapeResizeCopy", 8e-6)
' Move resized copy away from originals
For Each dobj In lay.SelectedObjects
dobj.Move(0,-70e-6)
Next dobj
lay.Update

To Smooth:

' Select all shapes and smooth


lay.SelectedObjects.AddAll
lay.InvokeCommand "ShapeSmooth"

To Subtract:

lay.SelectedObjects.AddFromArea(-2e-6,-1e-6,4e-6,-7e-6,mwAAT_ContainedObjects)
lay.SelectedObjects.AddFromArea(1e-6,-4e-6,7e-6,-10e-6,mwAAT_ContainedObjects)
' Invoke the ShapeIntersect on the resulting selected shapes.
lay.InvokeCommand("ShapeSubtract")

To Union:

' Invoke the ShapeUnion on the resulting selected shapes.


lay.InvokeCommand("ShapeUnion")

API Scripting Guide 1439


Layout

To Fructure:

lay.SelectedObjects.AddAll
lay.InvokeCommand("ShapeFracture", Array(3)) ' Tesselate the rectangles.

To Notch:

lay.SelectedObjects.AddAll
lay.InvokeCommand("ShapeNotch", Array(100e-6, 150e-6, 200e-6, 50e-6)) ' Notch rectangle.

We support both the Notch-In and Notch-Out behavior of the command similar to the way the UI does. In case the upper
end of the notch region such that it is inside the large open region and the result would be that the command does a
notch-out rather than a notch-in meaning that it will add material to the white region rather than removing it.The following
code provides the coordinates such that the ending point is outside the polygon which for the command indicates that
the action should be a notch-out

To Notch out:

lay.SelectedObjects.AddAll
lay.InvokeCommand("ShapeNotch", Array(100e-6, 50e-6, 200e-6, -50e-6)) ' Notch rectangle.

To Slice through the lines of a Route object:

' Code Module


Sub Main
Dim lay As Layout
Dim ret As Variant
Dim physNet As PhysicalNet
Dim rt As Route

Debug.Clear
Set lay = Project.Schematics("Schematic 1").Layout

' In this case we just have one net so select all.


For Each physNet In lay.PhysicalNets
For Each rt In physNet.Routes
rt.Selected = True
Next rt
Next physNet
' Slice from p1 = {-50um, 0 } to p2 = {50um, 0 }
lay.InvokeCommand("ShapeSlice", Array(-50e-6, 0, 50e-6, 0), ret)
Debug.Print ret
End Sub

You can invoke a command that perform a Segment Properties command on a selected Route or set of Routes:

' Code Module


Sub Main

1440 NI AWR Design Environment


Layout

Dim lay As Layout


Dim phy As PhysicalNet
Dim rt As Route
Dim seg As RouteSegment
Dim ret As Variant

Debug.Clear
Set lay = Project.Schematics("Schematic_1").Layout
Set phy = lay.PhysicalNets(1)

' Second route seems to be the top one.


Set rt = phy.Routes(2)

' Set the segments selected (equivalent to the shift-right-click action)


For Each seg In rt.Segments
seg.Selected = True
Next seg

' Select set the route's state to selected


rt.Selected = True

' Current line type is Metal 3.


For Each seg In rt.Segments
Debug.Print seg.LineType
Next seg

' Change line type to Metal 4.


lay.InvokeCommand("PropertiesRouteSegment", Array(4, 2e-6), ret)
Debug.Print ret

' Now line type should be Metal 4.


For Each seg In rt.Segments
Debug.Print seg.LineType
Next seg

lay.InvokeCommand("EditUndo")
End Sub

To Add a Point to Path:

lay.SelectedObjects.AddAll
lay.InvokeCommand("ShapeEditPoints", Array("AddPoint", 25e-6, 0))

To Delete from a Point to Path:

lay.SelectedObjects.AddAll
lay.InvokeCommand("ShapeEditPoints", Array("DeletePoint", 25e-6, 0))

To Stretch Path Point:

API Scripting Guide 1441


Layout

lay.SelectedObjects.AddAll
lay.InvokeCommand("ShapeEditPoints", Array("AddPoint", 25e-6, 0))
lay.InvokeCommand("ShapeEditPoints", Array("AddPoint", 75e-6, 0))

lay.InvokeCommand("ShapeEditPoints", Array("StretchPoint", 25e-6, 0, 0, 20e-6))

To Stretch Path Area Points:

Set lay = Project.Schematics("SCH1").Layout

lay.SelectedObjects.AddAll
lay.InvokeCommand("ShapeEditPoints", Array("AddPoint", 25e-6, 0))
lay.InvokeCommand("ShapeEditPoints", Array("AddPoint", 75e-6, 0))

' Arguments for Stretch Area are (left, top, right, bottom, deltaX, deltaY)
lay.InvokeCommand("ShapeEditPoints", Array("StretchArea", 20e-6, 20e-6, 80e-6, -20e-6, 0, 20e-6))

This script replicates the steps by sub-selecting the segments (the equivalent of right-clicking them), invoking the
SegmentProperties command with arguments to change the segments from Metal 3 to Metal 4, and then invoking the
EditUndo command to undo the changes. So, the Segment Properties command is able to take arguments. Note that in
the script we also show an access to the route segment line type.

To Slice large polygons (this script tries to invoke ShapeSplit until the smallest shape is < = 8 vertices):

Private Sub Project_Open()


Debug.Clear
Dim sch As Schematic, d As DrawingObject, hasBigShapes As Boolean, s As Shape, i As Long
Set sch = Project.Schematics("shape_small")
Do
hasBigShapes = False
i = 1
While Not hasBigShapes And i < = sch.Layout.DrawingObjects.Count
Set d = sch.Layout.DrawingObjects(i)
For Each s In d.Shapes
If s.Vertices.Count > 8 Then
Debug.Print "Shape " & i & " has " & s.Vertices.Count & " vertices, splitting..."
DoSlice(sch, d)
hasBigShapes = True
End If
Next
i = i + 1
Wend
Loop While hasBigShapes
End Sub
Function DoSlice(sch As Schematic, d As DrawingObject)
Dim l As Double, b As Double, r As Double, t As Double
Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
l = d.Boundary.Left : b = d.Boundary.Bottom
r = d.Boundary.Right : t = d.Boundary.Top
If Abs(r-l) > Abs(t-b) Then
x1 = (r+l)/2 : x2 = x1
y1 = b : y2 = t

1442 NI AWR Design Environment


Layout

Else
y1 = (t+b)/2 : y2 = y1
x1 = l : x2 = r
End If
Dim retval
sch.Layout.SelectedObjects.AddAll
sch.Layout.InvokeCommand("ShapeSlice", Array(x1, y1, x2, y2), retval)
If retval "" Then Debug.Print retval
sch.Layout.SelectedObjects.RemoveAll
End Function

Note that this example modifies the collection over which it is iterating. The Slice operation makes one shape become
two shapes in the Drawing objects collection, but this is also the collection used for the iteration. In this case it works,
but means that underneath the API you are rebuilding the Drawing objects collection for each iteration. For large numbers
of shapes this can be slow. An alternative might be to create an Array and then re-dimension it to the required size and
load it with references to the shapes to be sliced, and then use that as the source for the iteration. Once it is complete,
re-dimension again and reload for the next pass. This process rebuilds the Drawing objects collection only once per pass
instead of after each slice.

To use the Stretch command for moving PCells and artwork cells when fully enclosed:

' Code Module


Sub Main
Dim lay As Layout
Dim ret As Variant
Dim rcLeft, rcTop, rcBottom, rcRight, dx, dy As Double

rcLeft = 50e-6
rcTop = 100e-6
rcRight = 150e-6
rcBottom = -50e-5
dx = 50e-6
dy = 0

Debug.Clear
Set lay = Project.Schematics("Schematic 1").Layout
lay.SelectedObjects.AddAll
lay.InvokeCommand("ShapeStretch", Array(rcLeft, rcTop, rcRight, rcBottom, dx, dy), ret)
Debug.Print ret;

End Sub

The first four arguments are the vertex selection rectangle and the last two arguments are the delta values for the Stretch.
In the example, this stretches one shape that is partially enclosed and moves a PCell object that is fully enclosed. NOTE:
For more complicated cases (such as ruler and dimensions lines), because of the complexity of the MultiStretch command,
appropriate API commands for stretching are not included.

To determine the correct command name to Invoke, use the following script:

' Code Module


Sub Main
Open("c:\commands.txt") For Output As #1
Dim objTable As CommandTable

API Scripting Guide 1443


Layout

Dim cmd As Command


For Each objTable In MWOffice.CommandTables
Debug.Print"Table = " & objTable.Name
For Each cmd In objTable.Commands
Debug.Printcmd.Name
Next cmd
Debug.Print""
Next objTable
End Sub

Do not use InvokeCommand("EditorMakeSameSize/ Height/ Width"); you can use this command in scripts with rectangular
dumb Shapes only.

Working with Shape Modifiers

In the NI AWRDE, from an EM Layout or a Schematic Layout you can access Shape Modifiers and their options via
the API.

There is more than one way to access the shapes associated with a modifier.

The following script accesses the objects through the Modified objects collection on the Modifier, and prints the attributes
for each Drawing object:

' Code Module


Sub gen_file(fwrite As String)
Dim lay As Layout
Dim shapeMod As ShapeModifier
Dim objDraw As DrawingObject

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

' Print the attributes for the modifier graphic object.


Debug.Print lay.Name
Debug.Print "Modifier Count = " & lay.ShapeModifiers.Count
For Each shapeMod In lay.ShapeModifiers
For Each objDraw In shapeMod.ModifyObjects
PrintDrawingObject objDraw
Debug.Print""
Next objDraw
Next shapeMod

End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print"Info Text = " & drawingObj.InfoText
Debug.Print"Selected = " & drawingObj.Selected
Debug.Print"Flipped = " & drawingObj.Flipped
Debug.Print"Rotation = " & drawingObj.RotationAngle
Debug.Print"Frozen = " & drawingObj.Frozen
Debug.Print"Base Pos = { x = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePositio
Debug.Print"Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)

1444 NI AWR Design Environment


Layout

PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)

End Sub

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Debug.Print"Parameters:"
For Each param In params
Debug.Printparam.Name & " = " & param.ValueAsString
Next param

End Sub

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Debug.Print"Attributes:"
For Each attr In attrs
Debug.Printattr.Name & " = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Debug.Print"Boundary:"
Debug.Print"Left = " & bound.Left
Debug.Print"Right = " & bound.Right
Debug.Print"Top = " & bound.Top
Debug.Print"Bottom = " & bound.Bottom
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Debug.Print"Vertices:"
For Each vert In verts
Debug.Print"{ x= " & vert.x & ", y= " & vert.y & " }"
Next vert
End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Debug.Print"Edit Handles:"
For Each eh In ehs
Debug.Print"{ x= " & eh.Position.x & ", y= " & eh.Position.y & " }"
Next eh
End Sub

The following script accesses the Graphic object for the Shape Modifier and prints the attributes of the Graphic object:

' Code Module


Sub gen_file(fwrite As String)
Dim lay As Layout
Dim shapeMod As ShapeModifier

Open fwrite For Output As #1

API Scripting Guide 1445


Layout

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

' Print the attributes for the modifier graphic object.


Print #1, lay.Name
Print #1, "Modifier Count = " & lay.ShapeModifiers.Count
For Each shapeMod In lay.ShapeModifiers
PrintDrawingObject shapeMod.GraphicObject
Print #1, ""
Next shapeMod
Close #1
End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Print #1, "Info Text = " & drawingObj.InfoText
Print #1, "Selected = " & drawingObj.Selected
Print #1, "Flipped = " & drawingObj.Flipped
Print #1, "Rotation = " & drawingObj.RotationAngle
Print #1, "Frozen = " & drawingObj.Frozen
Print #1, "Base Pos = { x = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePosition.y
Print #1, "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)

End Sub

The following is another example of using a Graphic object for a Shape Modifier:

Sub CreateModifier(ByRef lay As Layout)


Dim rec As ModifierDefRecord

Set rec = lay.ShapeModifiers.CreateModifierDefRecord("ARRAYMOD")

rec.ShapeVertices.Add(-100e-6, 50e-6)
rec.ModifyObjects.Add(lay.DrawingObjects(1))
rec.ModifyObjects.Add(lay.DrawingObjects(2))
rec.ParamFramePosX = -50e-6
rec.ParamFramePosY = 150e-6

lay.ShapeModifiers.AddModifier(rec)

End Sub

Sub PrintShapeMod(ByRef shapeMod As ShapeModifier)


Print #1, "Name = " & shapeMod.Name
Print #1, "Enabled = " & shapeMod.Enabled
Print #1, "MessageId = " & shapeMod.MessageId
Print #1, "Selected = " & shapeMod.Selected
Print #1, "Type = " & shapeMod.Type
Print #1, "Modify Cnt= " & shapeMod.ModifyObjects.Count

PrintParameters(shapeMod.Parameters)
PrintAttributes(shapeMod.Attributes)

1446 NI AWR Design Environment


Layout

PrintBoundary(shapeMod.Boundary)
PrintVertices(shapeMod.Vertices)

End Sub

Sub PrintParameters(ByRef params As Parameters)


Dim param As Parameter
Print #1, "Parameters:"
For Each param In params
Print #1, param.Name & " = " & param.ValueAsString
Next param
End Sub

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Print #1, "Attributes:"
For Each attr In attrs
Print #1, attr.Name & " = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Print #1, "Boundary:"
Print #1, "Left = " & bound.Left
Print #1, "Right = " & bound.Right
Print #1, "Top = " & bound.Top
Print #1, "Bottom = " & bound.Bottom
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Print #1, "Vertices:"
For Each vert In verts
Print #1, "{ x= " & vert.x & ", y= " & vert.y & " }"
Next vert
End Sub

NOTE: Some Subroutines in the previous script are shown earlier.

The following script accesses the attributes of the object associated with the Shape Modifier. When you select a modifier,
a cross-highlight is used to show the objects that are associated with the Modifier by marking the objects to draw
themselves as "Marked". This typically includes a dashed green outline around the shapes, although for the Modifiers
additional highlight information is sometimes provided with a cyan line. In both cases the object is marked for display
as "Marked". The Drawing object now includes a property for the DisplayMode that takes an argument to indicate for
which mode you want to check. Many Shape Modifiers are associated with objects they modify, and this relation is
represented by the ModifyObjects collection available from the ShapeModifier. Some modifiers such as the Array
Modifier, however, also generate shapes. A new collection provides access to any shapes generated by the modifier. The
Array Modifier has shapes in the Generated Shapes collection if either the rows or columns value is greater than 1.

The following code shows how to use these to determine if the shapes (modified and generated) associated with a Shape
Modifier are set to draw as "Marked" via the DisplayMode property. The following script shows an example of working
with an Array Modifier and displays if associated and generated shapes are set to draw marked:

' Code Module


Sub Main

API Scripting Guide 1447


Layout

Dim lay As Layout


Dim shpMod As ShapeModifier
Dim objDraw As DrawingObject

Set lay = Project.Schematics("Schematic 1").Layout


Set shpMod = lay.ShapeModifiers(1)

' Start with modifier not selected


shpMod.Selected = False
' (These should Print False for Object Marked)
' Print display mode for modify associated array elements (the originals).
For Each objDraw In shpMod.ModifyObjects
Debug.Print "Display Mode Object Marked = " & objDraw.DisplayMode(mwDMT_ObjectMarked)
Next objDraw

' Print display mode for the generated array elements (The extras (not originals).
For Each objDraw In shpMod.GeneratedObjects
Debug.Print "Display Mode Object Marked = " & objDraw.DisplayMode(mwDMT_ObjectMarked)
Next objDraw

' Now set selected and repeat


shpMod.Selected = True
' (These Should Print True for object marked)
' Print display mode for modify associated array elements (the originals).
For Each objDraw In shpMod.ModifyObjects
Debug.Print "Display Mode Object Marked = " & objDraw.DisplayMode(mwDMT_ObjectMarked)
Next objDraw

' Print display mode for the generated array elements (The extras (not originals).
For Each objDraw In shpMod.GeneratedObjects
Debug.Print "Display Mode Object Marked = " & objDraw.DisplayMode(mwDMT_ObjectMarked)
Next objDraw
End Sub

The following is another example of using the new display mode to show that associated objects are marked when the
Shape Modifier is selected:

' Code Module


Sub gen_file(fwrite As String)
Dim lay As Layout
Dim shapeMod As ShapeModifier
Dim objDraw As DrawingObject

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
Print #1, lay.Name
Print #1, "Modifier Count = " & lay.ShapeModifiers.Count
For Each shapeMod In lay.ShapeModifiers
Print #1, "Objects for ShapeModifierId = " & shapeMod.MessageId
For Each objDraw In shapeMod.GeneratedObjects
PrintDrawingObjectDisplayMode objDraw
Next objDraw
Print #1, ""

1448 NI AWR Design Environment


Layout

Next shapeMod

For Each shapeMod In lay.ShapeModifiers


shapeMod.Selected = True
Print #1, "Objects for ShapeModifierId = " & shapeMod.MessageId
For Each objDraw In shapeMod.GeneratedObjects
PrintDrawingObjectDisplayMode objDraw
Next objDraw
Print #1, ""
shapeMod.Selected = False
Next shapeMod

Close #1
End Sub

Sub PrintDrawingObjectDisplayMode(ByRef drawingObj As DrawingObject)


Print #1, "Display Mode Buddy Selected = " & drawingObj.DisplayMode(mwDMT_BuddySelected)
Print #1, "Display Mode Buddy Unselected = " & drawingObj.DisplayMode(mwDMT_BuddyUnselected)
Print #1, "Display Mode Highlighted = " & drawingObj.DisplayMode(mwDMT_Highlighted)
Print #1, "Display Mode Object Condemned = " & drawingObj.DisplayMode(mwDMT_ObjectCondemned)
Print #1, "Display Mode Object Marked = " & drawingObj.DisplayMode(mwDMT_ObjectMarked)
End Sub

The following code shows how to work with the objects produced by an Array Modifier working on an iNet route object
with vias:

' Code Module


Sub gen_file(fwrite As String)
Dim lay As Layout
Dim shapeMod As ShapeModifier
Dim objDraw As DrawingObject

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout
Print #1, lay.Name
Print #1, "Modifier Count = " & lay.ShapeModifiers.Count
For Each shapeMod In lay.ShapeModifiers
Print #1, "Objects for ShapeModifierId = " & shapeMod.MessageId
For Each objDraw In shapeMod.GeneratedObjects
PrintDrawingObject objDraw
Next objDraw
Print #1, ""
Next shapeMod
Close #1
End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Print #1, "Info Text = " & drawingObj.InfoText
Print #1, "Selected = " & drawingObj.Selected
Print #1, "Flipped = " & drawingObj.Flipped
Print #1, "Rotation = " & drawingObj.RotationAngle
Print #1, "Frozen = " & drawingObj.Frozen
Print #1, "Base Pos = { x = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePosition.y

API Scripting Guide 1449


Layout

Print #1, "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)

End Sub

NOTE: Some Subroutines in the previous script are shown earlier.

The following code shows how to work with Undo and Redo support in the API for the Modifier command:

' Code Module


Sub gen_file(fwrite As String)
Dim lay As Layout
Dim shapeMod As ShapeModifier

Open fwrite For Output As #1

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

' Create the modifier in the layout


CreateModifier lay

' Print numbers of the created modifier.


Print #1, lay.Name
Print #1, "Modifier Count = " & lay.ShapeModifiers.Count

Set shapeMod = Nothing

' Remove the modifier with Undo.


lay.InvokeCommand("EditUndo")

' Drawing Object Count should be one.


Print #1, "Drawing Object Count = " & lay.DrawingObjects.Count

' Modifier should not still exist in the design.


Print #1, "Modifier Count = " &lay.ShapeModifiers.Count

Set shapeMod = Nothing

' Add the modifier back with Redo


lay.InvokeCommand("EditRedo")

' Drawing Object Count should be two.


Print #1, "Drawing Object Count = " & lay.DrawingObjects.Count

' Modifier should now have been returned to the container..


Print #1, "Modifier Count = " & lay.ShapeModifiers.Count

Close #1
End Sub

Sub CreateModifier(ByRef lay As Layout)

1450 NI AWR Design Environment


Layout

Dim x1 As Double
Dim y1 As Double
Dim x2 As Double
Dim y2 As Double
Dim xl As Double
Dim yl As Double
Dim ret As Variant

Set lay = Project.Schematics("SCH1").Layout

x2 = 0.0
y2 = 100.E-6
x1 = 100.E-6
y1 = 100.E-6
xl = 50.E-6
yl = 150.E-6

lay.DrawingObjects(1).Selected = True
lay.InvokeCommand("SchematicEdgeModifier", Array(x1, y1, x2, y2, xl, yl), ret)
End Sub

The following code shows how to create a Width Modifier:

Sub CreateModifier(ByRef lay As Layout)


Dim x1 As Double
Dim y1 As Double
Dim x2 As Double
Dim y2 As Double
Dim xl As Double
Dim yl As Double
Dim ret As Variant

Set lay = Project.Schematics("SCH1").Layout

x1 = 0.0
y1 = 0.0
x2 = 100.E-6
y2 = 0.0
xl = 50.E-6
yl = 50.E-6

lay.DrawingObjects(1).Selected = True
lay.InvokeCommand("SchematicWidthModifier", Array(x1, y1, x2, y2, xl, yl), ret)
End Sub

The following code shows how to create an Edge Modifier:

Sub CreateModifier(ByRef lay As Layout)


Dim rec As ModifierDefRecord
Dim pt1 As Vertex
Dim pt2 As Vertex

Set rec = lay.ShapeModifiers.CreateModifierDefRecord("EDGEMOD")


Set pt1 = lay.DrawingObjects(1).Shapes(1).Vertices(1)

API Scripting Guide 1451


Layout

Set pt2 = lay.DrawingObjects(1).Shapes(1).Vertices(2)

rec.ShapeVertices.Add(pt1.x, pt1.y)
rec.ShapeVertices.Add(pt2.x, pt2.y)
rec.ModifyObjects.Add(lay.DrawingObjects(1))
rec.ParamFramePosX = 50e-6
rec.ParamFramePosY = 50e-6

lay.ShapeModifiers.Add(rec)

End Sub

The next code shows how to change the order Index for Edge Modifier for the example in the following picture:

lay.ShapeModifiers("EDGEMOD.EM12").OrderIndex = 1

The following code shows how to create a Spacing Modifier:

Sub CreateModifier(ByRef lay As Layout)


Dim rec As ModifierDefRecord
Dim objDraw1 As DrawingObject
Dim objDraw2 As DrawingObject
Dim pt1 As Vertex
Dim pt2 As Vertex

Set rec = lay.ShapeModifiers.CreateModifierDefRecord("SPACEMOD")


Set objDraw1 = lay.DrawingObjects(1)
Set objDraw2 = lay.DrawingObjects(2)

If (objDraw1.BasePosition.x > objDraw2.BasePosition.x) Then

1452 NI AWR Design Environment


Layout

Dim temp As DrawingObject

Set temp = objDraw1


Set objDraw1 = objDraw2
Set objDraw2 = temp

End If

Set pt1 = objDraw1.Shapes(1).Vertices(4)


Set pt2 = objDraw2.Shapes(1).Vertices(1)

rec.ShapeVertices.Add(pt1.x, pt1.y)
rec.ShapeVertices.Add(pt2.x, pt2.y)
rec.ModifyObjects.Add(objDraw1)
rec.ModifyObjects.Add(objDraw2)
rec.ParamFramePosX = 150e-6
rec.ParamFramePosY = 150e-6

lay.ShapeModifiers.Add(rec)

End Sub

The following code shows how to create a Circle Radius Modifier:

Sub CreateModifier(ByRef lay As Layout)


Dim x1 As Double
Dim y1 As Double
Dim x2 As Double
Dim y2 As Double
Dim ret As Variant

Set lay = Project.Schematics("SCH1").Layout

x1 = 50.0e-6
y1 = 50.0e-6
x2 = 150.0e-6
y2 = 150.0e-6

lay.DrawingObjects(1).Selected = True
lay.InvokeCommand("SchematicRadiusModifier", Array(x1, y1, x2, y2), ret)
End Sub

The following code shows how to create an Ellipse Size Modifier:

Sub CreateModifier(ByRef lay As Layout)


Dim x1 As Double
Dim y1 As Double
Dim x2 As Double
Dim y2 As Double
Dim ret As Variant

Set lay = Project.Schematics("SCH1").Layout

x1 = 100.0e-6

API Scripting Guide 1453


Layout

y1 = 50.0e-6
x2 = 150.0e-6
y2 = 150.0e-6

lay.DrawingObjects(1).Selected = True
lay.InvokeCommand("SchematicEllipseSizeModifier", Array(x1, y1, x2, y2), ret)
End Sub

The following code shows how to create a Layer Boolean Modifier:

Sub CreateModifier(ByRef lay As Layout)


Dim x1 As Double
Dim y1 As Double
Dim shapeMod As ShapeModifier

x1 = -50e-6
y1 = 50e-6

lay.InvokeCommand("SchematicLayerBooleanModifier", Array(x1, y1))


If (lay.ShapeModifiers.Count > 0) Then

Set shapeMod = lay.ShapeModifiers(1)


If (shapeMod.Parameters.Exists("LIA")) Then
shapeMod.Parameters("LIA").ValueAsDouble = 7 ' Should be Cap Bottom
End If

If (shapeMod.Parameters.Exists("LIB")) Then
shapeMod.Parameters("LIB").ValueAsDouble = 12 ' Should be Top Metal
End If

If (shapeMod.Parameters.Exists("LIR")) Then
shapeMod.Parameters("LIR").ValueAsDouble = 10 ' Should be Nitride Etech
End If
End If

End Sub

The following code shows how to create a Layer Offset Modifier:

Sub CreateModifier(ByRef lay As Layout)


Dim x1 As Double
Dim y1 As Double
Dim shapeMod As ShapeModifier

x1 = -50e-6
y1 = 50e-6

lay.InvokeCommand("SchematicLayerOffsetModifier", Array(x1, y1))


If (lay.ShapeModifiers.Count > 0) Then

Set shapeMod = lay.ShapeModifiers(1)

1454 NI AWR Design Environment


Layout

If (shapeMod.Parameters.Exists("OFX")) Then
shapeMod.Parameters("OFX").ValueAsDouble = 50e-6
End If

If (shapeMod.Parameters.Exists("OFY")) Then
shapeMod.Parameters("OFY").ValueAsDouble = 50e-6
End If

If (shapeMod.Parameters.Exists("LI")) Then
shapeMod.Parameters("LI").ValueAsDouble = 7 ' Should be Cap Bottom
End If
End If

End Sub

The following code shows how to create a Layer Resize Modifier:

Sub CreateModifier(ByRef lay As Layout)


Dim x1 As Double
Dim y1 As Double
Dim shapeMod As ShapeModifier

x1 = -50e-6
y1 = 50e-6

lay.InvokeCommand("SchematicLayerResizeModifier", Array(x1, y1))


If (lay.ShapeModifiers.Count > 0) Then

Set shapeMod = lay.ShapeModifiers(1)


If (shapeMod.Parameters.Exists("OS")) Then
shapeMod.Parameters("OS").ValueAsDouble = 20e-6
End If

If (shapeMod.Parameters.Exists("LI")) Then
shapeMod.Parameters("LI").ValueAsDouble = 7 ' Should be Cap Bottom
End If
End If

End Sub

The following code shows how to create a Stretch Area Modifier:

Sub CreateModifier(ByRef lay As Layout)


Dim x1 As Double
Dim y1 As Double
Dim shapeMod As ShapeModifier

x1 = -150e-6
y1 = 50e-6

lay.InvokeCommand("SchematicStretchAreaModifier", Array(8, -50e-6, -50e-6, -50e-6, 50e-6, 200e-6,

API Scripting Guide 1455


Layout

If (lay.ShapeModifiers.Count > 0) Then

Set shapeMod = lay.ShapeModifiers(1)


If (shapeMod.Parameters.Exists("DX")) Then
shapeMod.Parameters("DX").ValueAsDouble = 20e-6 ' Should be Cap Bottom
End If

If (shapeMod.Parameters.Exists("DY")) Then
shapeMod.Parameters("DY").ValueAsDouble = -20e-6 ' Should be Top Metal
End If
End If

End Sub

Indexing Layer Modifiers and Shape Modifiers by Modifier Name

This code verifies that the collection method Exits and the GetItem methods index into the collections correctly when
presented with the value supplied by the Name property as an index:

' Code Module


Sub Main
Dim lay As Layout
Dim shapeMod As ShapeModifier
Dim shapeMod2 As ShapeModifier
Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

' Print the attributes for the existing modifier.


Debug.Print lay.Name
Debug.Print "Modifier Count = " & lay.ShapeModifiers.Count
For Each shapeMod In lay.ShapeModifiers

' String index into exists


If lay.ShapeModifiers.Exists(shapeMod.Name) Then
Debug.Print "ShapeModifier " & shapeMod.Name & " exists"
Else
PDebug.Print "Error: ShapeModifier " & shapeMod.Name & " should exist but doesn't"
End If

' String index into items.


On Error Resume Next
Set shapeMod2 = lay.ShapeModifiers.Item(shapeMod.Name)
On Error GoTo 0

If shapeMod2 Is Nothing Then


Debug.Print "Error: Unable to use string index on " & shapeMod.Name
Else
Debug.Print "String index to " & shapeMod.Name & " worked correctly"
End If

Next shapeMod
End Sub

1456 NI AWR Design Environment


Layout

Setting the modifier rules via the PreprocessorRules attribute

This code shows how the rules are set and the placed instances should update to reflect the processing being performed
by the new rules:

Sub Main
Dim lay As Layout
Dim lay2 As Layout
Dim shapeMod As ShapeModifier

Set lay = Project.Schematics("SCH1").Layout


Set shapeMod = lay.ShapeModifiers("LAYSPPMOD.SPPM13")
Set lay2 = Project.Schematics("SCH2").Layout

PrintShapeMod shapeMod, "***Before Setting Rules***"


PrintDrawingObjects lay2, "***Before Setting Rules***"
SetSPPRules(shapeMod)
PrintShapeMod shapeMod, "***After Setting Rules***"
PrintDrawingObjects lay2, "***After Setting Rules***"
End Sub

Sub SetSPPRules(ByRef shapeMod As ShapeModifier)


Dim rules As String

rules = "BOOLEAN_OPS ""Temp1"" ""Thick Metal"" OR ""Cap Bottom""" & vbCr &
vbLf & "LDELETE ""Cap Bottom""" & vbCr & vbLf & "Replace ""Thick Metal"" ""Temp1"""

' Set something on the rules attribute to ensure that works


If (shapeMod.Attributes.Exists("PreprocessorRules")) Then
shapeMod.Attributes("PreprocessorRules").Value = rules
End If

End Sub

Sub PrintDrawingObjects(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject
Dim shp As Shape

Debug.Print title
For Each objDraw In lay.DrawingObjects
Debug.Print "Drawing Object Shapes: "
For Each shp In objDraw.Shapes
PrintShape(shp)
Next shp
Debug.Print ""
Next objDraw
Debug.Print ""

End Sub

Sub PrintShape (ByRef shp As Shape)


PrintVertices(shp.Vertices)
PrintBoundary(shp.Boundary)
End Sub

API Scripting Guide 1457


Layout

Sub PrintShapeMod(ByRef shapeMod As ShapeModifier, title As String)


Debug.Print title
Debug.Print "Name = " & shapeMod.Name
Debug.Print "Enabled = " & shapeMod.Enabled
Debug.Print "MessageId = " & shapeMod.MessageId
Debug.Print "Selected = " & shapeMod.Selected
Debug.Print "Type = " & shapeMod.Type
Debug.Print "Modify Cnt= " & shapeMod.ModifyObjects.Count

PrintParameters(shapeMod.Parameters)
PrintAttributes(shapeMod.Attributes)
PrintBoundary(shapeMod.Boundary)
PrintVertices(shapeMod.Vertices)

End Sub

Some of code lines is omitted since they are shon above

The following script shows how to use invoke the command to add a shape preprocessor modifier and set the rules on
it:

Sub Main
Dim lay As Layout
Dim lay2 As Layout
Dim shapeMod As ShapeModifier

Set lay = Project.Schematics("SCH1").Layout


Set lay2 = Project.Schematics("SCH2").Layout

CreateModifier lay

Debug.Print lay.Name

Debug.Print "Schematic 1, Drawing Object Count = " & lay.DrawingObjects.Count


Debug.Print "Schematic 2, Drawing Object Count = " & lay2.DrawingObjects.Count
Debug.Print "Schematic 2, Shape Object Count = " & lay2.CreateSnapshot().Shapes.Count
Debug.Print "Modifier Count = " & lay.ShapeModifiers.Count
For Each shapeMod In lay.ShapeModifiers
PrintShapeMod shapeMod
Debug.Print ""
Next shapeMod

Set shapeMod = Nothing

Debug.Print ""

' Remove modifier with add command undo functionality.


lay.InvokeCommand("EditUndo")

Debug.Print "Schematic 1, Drawing Object Count = " & lay.DrawingObjects.Count


Debug.Print "Schematic 2, Drawing Object Count = " & lay2.DrawingObjects.Count
Debug.Print "Schematic 2, Shape Object Count = " & lay2.CreateSnapshot().Shapes.Count
Debug.Print "Modifier Count = " & lay.ShapeModifiers.Count
For Each shapeMod In lay.ShapeModifiers

1458 NI AWR Design Environment


Layout

PrintShapeMod shapeMod
Debug.Print ""
Next shapeMod

Set shapeMod = Nothing

Debug.Print ""

' Add the modifier back with add command redo functionality.
lay.InvokeCommand("EditRedo")

Debug.Print "Schematic 1, Drawing Object Count = " & lay.DrawingObjects.Count


Debug.Print "Schematic 2, Drawing Object Count = " & lay2.DrawingObjects.Count
Debug.Print "Schematic 2, Shape Object Count = " & lay2.CreateSnapshot().Shapes.Count
Debug.Print "Modifier Count = " & lay.ShapeModifiers.Count
For Each shapeMod In lay.ShapeModifiers
PrintShapeMod shapeMod
Debug.Print ""
Next shapeMod

Set shapeMod = Nothing

Debug.Print ""
End Sub

Sub CreateModifier(ByRef lay As Layout)


Dim x1 As Double
Dim y1 As Double
Dim shapeMod As ShapeModifier

x1 = -50e-6
y1 = 50e-6

lay.InvokeCommand("SchematicShapePreprocessorModifier", Array(x1, y1))


If (lay.ShapeModifiers.Count > 0) Then

Set shapeMod = lay.ShapeModifiers(1)


rules = "BOOLEAN_OPS ""Temp1"" ""Thick Metal"" OR ""Cap Bottom""" & vbCr & vbLf &
"LDELETE ""Cap Bottom""" & vbCr & vbLf & "Replace ""Thick Metal"" ""Temp1"""

' Set something on the rules attribute to ensure that works


If (shapeMod.Attributes.Exists("PreprocessorRules")) Then
shapeMod.Attributes("PreprocessorRules").Value = rules
End If
End If

End Sub
Sub PrintShapeMod(ByRef shapeMod As ShapeModifier)
Debug.Print "Name = " & shapeMod.Name
Debug.Print "Enabled = " & shapeMod.Enabled
Debug.Print "MessageId = " & shapeMod.MessageId
Debug.Print "Selected = " & shapeMod.Selected
Debug.Print "Type = " & shapeMod.Type
Debug.Print "Modify Cnt= " & shapeMod.ModifyObjects.Count

PrintParameters(shapeMod.Parameters)
PrintAttributes(shapeMod.Attributes)

API Scripting Guide 1459


Layout

PrintBoundary(shapeMod.Boundary)
PrintVertices(shapeMod.Vertices)

End Sub

Some of code lines is omitted since they are shon above

In the code we include Undo/Redo and verify that the shapes in placed instances are updated to reflect the state of the
modifier.

Accessing Remove and RemoveAll Methods in Shape Modifiers Collection

The API Remove command works with the Array Modifier. The modifier's generated shapes are cleaned up correctly
with the following code:

' Code Module


Sub Main
Dim lay As Layout
Dim shapeMod As ShapeModifier
Dim modName As String

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

' Print the attributes for the existing modifier.


Debug.Print lay.Name
Debug.Print "Modifier Count = " & lay.ShapeModifiers.Count
PrintShapeMods lay, "Before Remove:"
Debug.Print "Drawing Object Count = " & lay.DrawingObjects.Count & " => Should be 9"

modName = "ARRAYMOD.AM10"

' Remove modifier


If (lay.ShapeModifiers.Exists(modName)) Then
Debug.Print "Remove Shape Modifier " & modName
lay.ShapeModifiers.Remove(modName)
Else
Debug.Print "Unable to find Shape Modifier: " & modName
End If

Debug.Print lay.Name
Debug.Print "Modifier Count = " & lay.ShapeModifiers.Count
PrintShapeMods lay, "After Remove:"
Debug.Print "Drawing Object Count = " & lay.DrawingObjects.Count & " => Should be 2"
End Sub

Accessing Shape Modifiers Library Collection

The following is the Modifier Library access code that takes into account the registration of a new Shape Modifier in
the Library with the Modifier records:

' Code Module


Sub Main

1460 NI AWR Design Environment


Layout

Dim modRec As ShapeModifierRecord

Debug.Clear
' Test global Access.
For Each modRec In ModifierLibrary
PrintShapeModRecord modRec
Next modRec

' Test application Access.


For Each modRec In Application.ModifierLibrary
PrintShapeModRecord modRec
Next modRec

End Sub

Sub PrintShapeModRecord(ByRef modRec As ShapeModifierRecord)


Dim paramDef As ParameterDefinition

Debug.Print "Modifier Record: "


Debug.Print "Name = " & modRec.Name
Debug.Print "Description = " & modRec.Description
Debug.Print "Version = " & modRec.Version
For Each paramDef In modRec.ParameterDefinitions
PrintParamDef paramDef
Next paramDef
End Sub

Sub PrintParamDef(ByRef paramDef As ParameterDefinition)


Debug.Print "Parameter Definition:"
Debug.Print "Name = " & paramDef.Name
Debug.Print "DataType = " & paramDef.DataType
Debug.Print "Default Name = " & paramDef.DefaultName
Debug.Print "Def Flag (default) = " & paramDef.DefinitionFlag(mwPDF_Default)
Debug.Print "Def Flag (secondary) = " & paramDef.DefinitionFlag(mwPDF_Secondary)
Debug.Print "Def Flag (hidden) = " & paramDef.DefinitionFlag(mwPDF_Hide)
Debug.Print "Def Flag (hide empty)= " & paramDef.DefinitionFlag(mwPDF_HideIfEmpty)
Debug.Print "Def Flag (hide units)= " & paramDef.DefinitionFlag(mwPDF_HideUnits)
Debug.Print "Def Flag (read only) = " & paramDef.DefinitionFlag(mwPDF_ReadOnly)
Debug.Print "Description = " & paramDef.Description
Debug.Print "Unit Type = " & paramDef.UnitType
End Sub

Editing Shape Modifiers Collection

The following example code shows you how to change Edge Modifier Path points:

' Code Module


Sub Main
Dim lay As Layout
Dim shapeMod As ShapeModifier
Dim objDraw As DrawingObject
Dim eh As EditHandle

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

API Scripting Guide 1461


Layout

' Print initial state.


PrintLayoutModifiers lay, " *** Before Editing ***"

Set objDraw = lay.DrawingObjects(1)


Set eh = objDraw.EditHandles(6)
eh.Move(0, -130e-6)

lay.Update

PrintLayoutModifiers lay, " *** After Editing ***"

End Sub

' Print the shape modifiers from the design


Sub PrintLayoutModifiers(ByRef lay As Layout, title As String)
Dim shapeMod As ShapeModifier

Debug.Print title
Debug.Print lay.Name & "Shape Modifiers"
Debug.Print "Modifier Count = " & lay.ShapeModifiers.Count
For Each shapeMod In lay.ShapeModifiers
PrintShapeMod shapeMod
Debug.Print ""
Next shapeMod
End Sub

Sub PrintShapeMod(ByRef shapeMod As ShapeModifier)


Debug.Print "Name = " & shapeMod.Name
Debug.Print "Enabled = " & shapeMod.Enabled
Debug.Print "MessageId = " & shapeMod.MessageId
Debug.Print "Selected = " & shapeMod.Selected
Debug.Print "Type = " & shapeMod.Type
Debug.Print "Modify Cnt= " & shapeMod.ModifyObjects.Count

PrintParameters(shapeMod.Parameters)

End Sub

Sub PrintParameters(ByRef params As Parameters)


Dim param As Parameter
Debug.Print "Parameters:"
For Each param In params
Debug.Print param.Name & " = " & param.ValueAsString
Next param
End Sub

Changing Edge Modifier net Polygon points:

This example uses subroutines for printing, as shown in the example code.

' Code Module


Sub Main
Dim lay As Layout
Dim shapeMod As ShapeModifier

1462 NI AWR Design Environment


Layout

Dim objDraw As DrawingObject


Dim eh As EditHandle

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

' Print initial state.


PrintLayoutModifiers lay, " *** Before Editing ***"

For Each objDraw In lay.DrawingObjects


If objDraw.TypeBits = 65 And objDraw.EditHandles.Count > 8 Then
Set eh = objDraw.EditHandles(8)
eh.Move(0, -100e-6)
End If
Next objDraw

lay.Update

PrintLayoutModifiers lay, " *** After Editing ***"

End Sub

Updating Modifiers Parameters

The following example code shows how to update Modifier parameters.

Updating the Edge Modifier Path :

' Code Module


Sub Main
Dim lay As Layout
Dim shapeMod As ShapeModifier

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

'Print the initial state.


PrintLayoutModifiers lay
PrintDrawingObjects lay

' Update the modifier in the layout


Set shapeMod = lay.ShapeModifiers("EDGEMOD.EM9")
UpdateModifier shapeMod

PrintLayoutModifiers lay
PrintDrawingObjects lay

Set shapeMod = lay.ShapeModifiers("EDGEMOD.EM9")


RevertModifier shapeMod

' Print the restsored state.


PrintLayoutModifiers lay
PrintDrawingObjects lay

End Sub

API Scripting Guide 1463


Layout

Sub UpdateModifier(ByRef shapeMod As ShapeModifier)


shapeMod.Parameters("L").ValueAsDouble = 200e-6
End Sub

Sub RevertModifier(ByRef shapeMod As ShapeModifier)


shapeMod.Parameters("L").ValueAsDouble = 100e-6
End Sub

' Print the shape modifiers from the design


Sub PrintLayoutModifiers(ByRef lay As Layout)
Dim shapeMod As ShapeModifier

Debug.Print lay.Name & " Shape Modifiers"


Debug.Print "Modifier Count = " & lay.ShapeModifiers.Count
For Each shapeMod In lay.ShapeModifiers
PrintShapeMod shapeMod
Debug.Print ""
Next shapeMod
End Sub

' Print the drawing objects from the design.


Sub PrintDrawingObjects(ByRef lay As Layout)
Dim objDraw As DrawingObject

Debug.Print lay.Name & " Drawing Objects"


Debug.Print "Drawing Object Count = " & lay.DrawingObjects.Count
For Each objDraw In lay.DrawingObjects
If (objDraw.TypeBits ne mwOSF_LayModifier) Then
PrintDrawingObject objDraw
Debug.Print ""
End If
Next objDraw

End Sub

Sub PrintShapeMod(ByRef shapeMod As ShapeModifier)


Debug.Print "Name = " & shapeMod.Name
Debug.Print "Enabled = " & shapeMod.Enabled
Debug.Print "MessageId = " & shapeMod.MessageId
Debug.Print "Selected = " & shapeMod.Selected
Debug.Print "Type = " & shapeMod.Type
Debug.Print "Modify Cnt= " & shapeMod.ModifyObjects.Count

PrintParameters(shapeMod.Parameters)
PrintAttributes(shapeMod.Attributes)
PrintBoundary(shapeMod.Boundary)
PrintVertices(shapeMod.Vertices)

End Sub

Sub PrintParameters(ByRef params As Parameters)


Dim param As Parameter
Debug.Print "Parameters:"
For Each param In params
Debug.Print param.Name & " = " & param.ValueAsString
Next param

1464 NI AWR Design Environment


Layout

End Sub

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Debug.Print "Attributes:"
For Each attr In attrs
Debug.Print attr.Name & " = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Debug.Print "Boundary:"
Debug.Print "Left = " & bound.Left
Debug.Print "Right = " & bound.Right
Debug.Print "Top = " & bound.Top
Debug.Print "Bottom = " & bound.Bottom
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Debug.Print "Vertices:"
For Each vert In verts
Debug.Print "{ x= " & vert.x & ", y= " & vert.y & " }"
Next vert
End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " & drawingObj.InfoText
Debug.Print "Selected = " & drawingObj.Selected
Debug.Print "Flipped = " & drawingObj.Flipped
Debug.Print "Rotation = " & drawingObj.RotationAngle
Debug.Print "Frozen = " & drawingObj.Frozen
Debug.Print "Base Pos = { x = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePosition.
Debug.Print "Layer Map = " & drawingObj.LayerMapping

PrintDrawObjParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)
End Sub

Sub PrintDrawObjParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Debug.Print "Parameters:"
For Each param In params
Debug.Print param.Name & " = " & param.ValueAsString
Next param

End Sub

Sub PrintDrawObjBoundary(ByRef bound As Boundary)


Debug.Print "Boundary:"
Debug.Print "Left = " & bound.Left
Debug.Print "Right = " & bound.Right
Debug.Print "Top = " & bound.Top
Debug.Print "Bottom = " & bound.Bottom

API Scripting Guide 1465


Layout

End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Debug.Print "Edit Handles:"
For Each eh In ehs
Debug.Print "{ x= " & eh.Position.x & ", y= " & eh.Position.y & " }"
Next eh
End Sub

Updating Ellipse Modifier Ellipse size:

Some of the printing subroutine are shown in previous code.

' Code Module


Sub Main
Dim lay As Layout
Dim shapeMod As ShapeModifier
Dim ModName As String
Debug.Clear

Set lay = Project.Schematics("SCH1").Layout

'Print the initial state.


PrintLayoutModifiers lay
PrintDrawingObjects lay
ModName = "ELLIPSESIZEMOD.ES10"

' Update the modifier in the layout


Set shapeMod = lay.ShapeModifiers(ModName)
UpdateModifier shapeMod

PrintLayoutModifiers lay
PrintDrawingObjects lay

Set shapeMod = lay.ShapeModifiers(ModName)


RevertModifier shapeMod

' Print the restored state.


PrintLayoutModifiers lay
PrintDrawingObjects lay

End Sub

Sub UpdateModifier(ByRef shapeMod As ShapeModifier)


shapeMod.Parameters("W").ValueAsDouble = 200e-6
shapeMod.Parameters("H").ValueAsDouble = 150e-6
End Sub

Sub RevertModifier(ByRef shapeMod As ShapeModifier)


shapeMod.Parameters("W").ValueAsDouble = 100e-6
shapeMod.Parameters("H").ValueAsDouble = 100e-6
End Sub

1466 NI AWR Design Environment


Layout

Highlighting Shape Modifiers

The following example code shows how to highlight Shape Modifiers and print only highlighted Modifier parameters.

Highlighting an Edge Modifier net Polygon:

' Code Module


Sub Main
Dim lay As Layout
Dim shapeMod As ShapeModifier
Dim objDraw As DrawingObject
Dim eh As EditHandle

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

' Print initial state.


PrintLayoutModifiers lay, " *** Before DrawObj Select ***"
For Each objDraw In lay.DrawingObjects
If objDraw.TypeBits = 65 Then
objDraw.Selected = True
End If
Next objDraw
lay.Update

' Print highlight state for modifiers.


PrintLayoutModifiers lay, " *** After DrawObj Select ***"

' Unselect all objects


lay.SelectedObjects.RemoveAll

' Print initial objDraw state


PrintDrawObjs lay, " *** Before Modifier Select ***"

For Each shapeMod In lay.ShapeModifiers


shapeMod.Selected = True
Next shapeMod
lay.Update

' Print obj draw state after modifier select.


PrintDrawObjs lay, " *** After Modifier Select ***"

' Unselect all objects


lay.SelectedObjects.RemoveAll

End Sub

' Print the shape modifiers from the design


Sub PrintLayoutModifiers(ByRef lay As Layout, title As String)
Dim shapeMod As ShapeModifier

Debug.Print title
Debug.Print lay.Name & " Shape Modifiers"
Debug.Print "Modifier Count = " & lay.ShapeModifiers.Count
For Each shapeMod In lay.ShapeModifiers
Debug.Print " Name = " & shapeMod.Name;

API Scripting Guide 1467


Layout

Debug.Print " Marked = " & shapeMod.DisplayMode(mwDMT_ObjectMarked)


Next shapeMod
Debug.Print ""
End Sub

Sub PrintDrawObjs(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject
Dim index As Integer

Debug.Print title
Debug.Print lay.Name & " Drawing Objects"
index = 1
For Each objDraw In lay.DrawingObjects
If objDraw.TypeBits = 65 Then
Debug.Print " DrawObj[" & index & "]: Marked = " & objDraw.DisplayMode(mwDMT_ObjectMarked)
index = index + 1
End If
Next objDraw
Debug.Print ""

End Sub

Flipping and rotating shapes with associated modifiers where the modifiers are included in the selection
when the command is invoked.

While editing the shape alone might be something the user would do when point selecting objects including the modifiers
in the selection would likely happen when doing area select or select all in a design.

The following code shows how to use InvokeCommands Flip and Rotate when user selecting objects including the
modifiers in the selection with area select or select all in a design:

' Code Module


Sub Main
Dim lay As Layout
Dim shapeMod As ShapeModifier
Dim objDraw As DrawingObject
Dim eh As EditHandle
Debug.Clear

Set lay = Project.Schematics("SCH1").Layout

' Print initial state.


PrintLayoutModifiers lay, " *** Before Edit Change ***"

lay.SelectedObjects.AddAll
lay.InvokeCommand("EditRotate", Array(0, 0, 90.0))
lay.Update

PrintLayoutModifiers lay, " *** After Edit Change ***"

End Sub

' Print the shape modifiers from the design


Sub PrintLayoutModifiers(ByRef lay As Layout, title As String)
Dim shapeMod As ShapeModifier

1468 NI AWR Design Environment


Layout

Debug.Print title
Debug.Print lay.Name & " Shape Modifiers"
Debug.Print "Modifier Count = " & lay.ShapeModifiers.Count
For Each shapeMod In lay.ShapeModifiers
PrintShapeMod shapeMod
Debug.Print ""
Next shapeMod
End Sub

Sub PrintShapeMod(ByRef shapeMod As ShapeModifier)


Debug.Print "Name = " & shapeMod.Name
Debug.Print "Enabled = " & shapeMod.Enabled
Debug.Print "MessageId = " & shapeMod.MessageId
Debug.Print "Selected = " & shapeMod.Selected
Debug.Print "Type = " & shapeMod.Type
Debug.Print "Modify Cnt= " & shapeMod.ModifyObjects.Count

PrintParameters(shapeMod.Parameters)
PrintPoints(shapeMod)

End Sub

Sub PrintParameters(ByRef params As Parameters)


Dim param As Parameter
Debug.Print "Parameters:"
For Each param In params
Debug.Print param.Name & " = " & param.ValueAsString
Next param
End Sub

Sub PrintPoints(ByRef shapeMod As ShapeModifier)


Dim vtx As Vertex
Dim index As Integer

index = 1
For Each vtx In shapeMod.Vertices
Debug.Print "Vertex[" & index & "] = { x = " & vtx.x * 1e6 & ", y = " & vtx.y * 1e6 & " }"
index = index + 1
Next vtx
End Sub

To rotate shape with associated modifier use the following code:

lay.SelectedObjects.AddAll
lay.InvokeCommand("EditFlip", Array(550e-6, 0, 550e-6, 500e-6))
lay.Update

Toggling Layout Background and Grid Color

The following script toggles the Layout background color and grid color:

Sub Toggle_Background_Color
Dim o As Option

API Scripting Guide 1469


Layout

Debug.Clear
Set o = Application.Options("LayoutBackColor")
o.Value = 16777215 Xor o.Value
Set o = Application.Options("LayoutGridColor")
o.Value = 16777215 Xor o.Value
Exit Sub
End Sub

The following code shows how to create a Layer Space Modifier:

Sub CreateModifier(ByRef lay As Layout)


Dim x1 As Double
Dim y1 As Double
Dim x2 As Double
Dim y2 As Double
Dim xl As Double
Dim yl As Double
Dim ang As Double

Dim ret As Variant

Set lay = Project.Schematics("SCH1").Layout

ang = 0.0
x1 = 100.E-6
y1 = 100.E-6
x2 = 200.E-6
y2 = 100.E-6
xl = 150.E-6
yl = 150.E-6

lay.DrawingObjects(1).Selected = True
lay.DrawingObjects(2).Selected = True

lay.InvokeCommand("SchematicSpacingModifier", Array(ang, x1, y1, x2, y2, xl, yl), ret)

End Sub

flipHoriz argument in drawingObject.move method

To Flip a Drawing object in the Layout, use the following script:

' Code Module


Sub Main
Dim Schem As Schematic
Dim Lay As Layout
Dim objDraw As DrawingObject
Debug.Clear
Set Schem = Project.Schematics("Schematic 1")
Debug.Print Schem.Name
Set Lay = Schem.Layout
Set objDraw = Lay.DrawingObjects(1)
objDraw.Move(0, 0, 0, True, True)
End Sub

1470 NI AWR Design Environment


Layout

In this script, the flip argument itself determines whether or not the move includes a flip. The second argument of the
Move command, flipHorz, can be "True" or "False" depending on whether you want the flip to occur around the horizontal
or vertical axis.

Navigating All Properties of Selected PCell

To access all properties of a selected PCell, use the following script:

' Code Module


Sub Main
Dim boun As Boundary
Dim ob As Object

Debug.Clear
Set boun = Project.Schematics(1).Layout.SelectedObjects(1).Boundary
ESnum = Project.Schematics(1).Layout.SelectedObjects.Count

PrintBoun(boun)
Set ob = Project.Schematics(1).Layout.SelectedObjects(1)
PrintObAttr(ob)
Debug.Print ob.BasePosition.x;vbTab;ob.BasePosition.y
PrintObFaces(ob)
PrintObOther(ob)

End Sub

' Printing Boundary properties


Sub PrintBoun(ByRef boun As Boundary)
Debug.Print "Boundary Bottom = ";boun.Bottom;vbTab;"Boundary Left = ";boun.Left;vbTab;"Boundary Ri
End Sub

Sub PrintObAttr(ByRef ob As Object)


For Each attr In ob.Attributes
Debug.Print attr.Name
Debug.Print attr.ReadOnly
Debug.Print attr.Type
Debug.Print attr.Value
Debug.Print attr.ValueAsString
Next attr
End Sub

Sub PrintObFaces(ByRef ob As Object)


Dim fc As Face
For Each fc In ob.Faces
Debug.Print fc.Alignment
Debug.Print fc.AreaEnabled
Debug.Print fc.Connected
Debug.Print fc.ConnectedNetName
Debug.Print fc.ConnectType
Debug.Print fc.DrawingLayer
Debug.Print fc.Flipped
Debug.Print fc.GroupNumber
Debug.Print fc.GroupType
Debug.Print fc.LayerProperty
Debug.Print fc.NodeNumber
Debug.Print fc.Offset.dx

API Scripting Guide 1471


Layout

Debug.Print fc.Offset.dy
Debug.Print fc.OffsetAngle
Debug.Print fc.PortNumber
Debug.Print fc.Type
Debug.Print fc.Vertices.Count
Dim vc As Vertex
For Each vc In fc.Vertices
Debug.Print vc.x
Debug.Print vc.y
Next vc
Next fc
End Sub
Sub PrintObOther(ByRef ob As Object)
Debug.Print ob.Flipped
Debug.Print ob.Frozen
Debug.Print ob.InfoText
Debug.Print ob.LayerMapping
Debug.Print ob.ResizeObject
Debug.Print ob.RotationAngle
Debug.Print ob.Selected
Debug.Print ob.TypeBits
End Sub

You need to select the PCell object before running this script.

Copying Layout to a New Window

To Copy Layout to a new Window, use the following script:

' Copying EMStructure to a new Window


Sub Main
Debug.Clear
Dim l As Layout
Dim w As Window
Set w = Project.Schematics(1).Layout.NewWindow(mwLWT_Layout2D)
Debug.Print w.Caption
End Sub

This output contains the new Window Name. The new Window displays in the workspace.

You can use the CopyToClipboard method to place the Layout in memory and then use the Paste method to paste the
Layout to a different Layout space.

Project.Schematics(1).Layout.CopyToClipboard
If Project.Schematics(2).Layout.CanPaste Then
Project.Schematics(2).Layout.Paste(0,0)
End If

You can use the PrintOut method to send the Layout object to the current printer.

Working with a 3D View

To Access a 3D view and Merge shapes, you can use the following script:

1472 NI AWR Design Environment


Layout

' Code Module


Sub Main
Dim lay3D As ThreeDView

Set sch = Project.Schematics("Packaged_Amp")


Set lay = sch.Layout

lay.NewWindow(mwLWT_Layout3D).Activate

Set lay3D = lay.ThreeDViews(1)

lay3D.ShapesMerged = True

End Sub

To Access the 3D view visual flags use the following code. This code sets the flags to two different states and then
verifies that the resulting settings match the requested state.

' Code Module


Sub Main
Dim lay As Layout
Dim view3D As ThreeDView

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

If (lay.ThreeDViews.Count = 0) Then
lay.NewWindow(mwLWT_Layout3D)
End If

Set view3D = lay.ThreeDViews(1)

' Set to simple basic shading first (clear most flags)


flags = mwVV_Shaded
view3D.Visual = flags

Debug.Print "Flags = " & flags & ", Visual = " & view3D.Visual
If (view3D.Visual ne flags) Then
Debug.Print "Flags Not Updated Successfully"
Else
Debug.Print "Flags Updated Successfully"
End If

' Set to more complex set of visual attributes and check updated correctly.
flags = mwVV_Shaded Or mwVV_ShapesMerged Or mwVV_Texturing Or mwVV_AntiAliased
view3D.Visual = flags

Debug.Print "Flags = " & flags & ", Visual = " & view3D.Visual
If (view3D.Visual ne flags) Then
Debug.Print "Flags Not Updated Successfully"
Else
Debug.Print "Flags Updated Successfully"
End If

API Scripting Guide 1473


Layout

End Sub

The following code sets the correct visual attributes on a 3D view through the Visual Flags property. The commands for
these attributes all toggle the state, so you must first determine the state desired from the flags and then determine if you
need a toggle to match the attribute to that state. A couple were attempting to set the state directly, which resulted in the
state toggling on and off with each subsequent attempt. The following shows an example of using the API to set a number
of View/Visual attributes:

' Code Module


Sub Main
Dim lay As Layout
Dim view3d As ThreeDView
Dim flags As Integer
Debug.Clear
Set lay = Project.Schematics("Schematic 1").Layout
' Create a 3D view if one doesn't exist.
If lay.ThreeDViews.Count = 0 Then
lay.NewWindow(mwLWT_Layout3D)
End If
Set view3d = lay.ThreeDViews(1)
' Use logical bitwise or to combine flags for visual display.
flags = mwVV_Shaded Or mwVV_ShapesMerged Or mwVV_Texturing Or mwVV_AntiAliased
view3d.Visual = flags

End Sub

You can also set the flags one by one. NI AWR allows you to turn on/off the visual attributes individually without needing
to merge the flags. This may be easier to use when you want to turn on/off a single property. Flags available for use with
the Visual Flags property are as follows:

enum mwViewVisiual {
mwVV_WireFrame = 0x01,
mwVV_Shaded = 0x02,
mwVV_ShowEdges = 0x04,
mwVV_Texturing = 0x08,
mwVV_AntiAliased = 0x10,
mwVV_ExtrudedOnly = 0x20,
mwVV_ShapesMerged = 0x40,
mwVV_ShapesSelected = 0x80,
mwVV_Stippling = 0x100
};

To Access the 3D view ViewFrom property use the following code. The code sets each possible value and checks the
resulting view angles for comparison.

' Code Module


Sub gen_file(fwrite As String)
Dim lay As Layout
Dim view3D As ThreeDView

1474 NI AWR Design Environment


Layout

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

If (lay.ThreeDViews.Count = 0) Then
lay.NewWindow(mwLWT_Layout3D)
End If

Set view3D = lay.ThreeDViews(1)

view3D.ViewFrom = mwVF_Back
PrintView view3D, "Back: "

view3D.ViewFrom = mwVF_Bottom
PrintView view3D, "Bottom:"

view3D.ViewFrom = mwVF_Front
PrintView view3D, "Front: "

view3D.ViewFrom = mwVF_Left
PrintView view3D, "Left: "

view3D.ViewFrom = mwVF_Ortho
PrintView view3D, "Ortho: "

view3D.ViewFrom = mwVF_Right
PrintView view3D, "Right: "

view3D.ViewFrom = mwVF_Top
PrintView view3D, "Top: "

End Sub

Sub PrintView(ByRef view3D As ThreeDView, title As String)


Debug.Print title & " Phi = " & view3D.Phi & ", Theta = " & view3D.Theta
End Sub

To Access the 3D View property, including ShapesMerged property, use the following code:

Sub Main
Dim lay As Layout
Dim view3D As ThreeDView

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

If (lay.ThreeDViews.Count = 0) Then
lay.NewWindow(mwLWT_Layout3D)
End If

Set view3D = lay.ThreeDViews(1)

' Set to simple basic shading first (clear most flags)


flags = mwVV_WireFrame
view3D.Visual = flags
PrintVisual view3D, "Wireframe: "

API Scripting Guide 1475


Layout

view3D.Shaded = True
PrintVisual view3D, "Shaded: "

view3D.Stippling = True
PrintVisual view3D, "Stippling: "

view3D.Texturing = True
PrintVisual view3D, "Texturing: "

view3D.AntiAliased = True
PrintVisual view3D, "AntiAlias: "

view3D.ShowEdges = True
PrintVisual view3D, "ShowEdges: "

view3D.ShapesMerged = True
PrintVisual view3D, "ShapesMerged:"

view3D.SelectedShapes = True
PrintVisual view3D, "SelectedShps:"

End Sub

Sub PrintVisual(ByRef view3D As ThreeDView, title As String)


Debug.Print title & " Shaded = " & view3D.Shaded;
Debug.Print ", WireFrame = " & view3D.Wireframe;
Debug.Print ", Stippling = " & view3D.Stippling;
Debug.Print ", Texturing = " & view3D.Texturing;
Debug.Print ", AntiAlias = " & view3D.AntiAliased;
Debug.Print ", ShowEdges = " & view3D.ShowEdges;
Debug.Print ", ShpsMerged = " & view3D.ShapesMerged;
Debug.Print ", SelectedShps = " & view3D.SelectedShapes
Debug.Print ""
End Sub

Grid Options

Set the Layout ShowGrid property to "True" if you want the Layout Grid to display.

You can use the SnapToGrid property to enable grid snapping.

Debug.Print "Snapping " & s.Name & "to grid..."


Project.Options("LayoutGridSpacing").Value = Project.Options("LayoutDatabaseUnits").Value
Function SnapAllToGrid(s As Schematic)
MWOffice.Activate
s.Layout.NewWindow(mwLWT_Layout2D)
s.Layout.Activate
SendKeys("^`") 'deselect all
Wait .1
SendKeys("^a") 'select all
Wait .1
SendKeys("+^1") ' Snap to grid
Wait .1
SendKeys("^`") ' deselect all
Wait .1

1476 NI AWR Design Environment


Layout

s.Windows(1).Close
End Function

Layout objects Snap Together

You can use the SnapTogether method to snap together all Layout objects and selected only Layout objects.

The following is an example of code for SnapTogether selected only objects:

Set schem = Project.Schematics("SCH1")


Set lay = Project.Schematics("SCH1").Layout

schem.Elements("MLIN.TL1").DrawingObjects(1).Selected = True
schem.Elements("TFC.V1").DrawingObjects(1).Selected = True

lay.SnapTogether(mwLST_SelectedOnly)

The following is an example of code for SnapTogether all objects:

Set lay = Project.Schematics("SCH1").Layout

lay.SnapTogether(mwLST_AllObjects)

The following is one more example of code for SnapTogether all objects:

Dim schem As Schematic


Dim lay As Layout

' Get the schematic and layout for that schematic.


Set schem = Project.Schematics(1)
'Debug.Print schem.Name

Set lay = schem.Layout

' Select all the objects in the layout.


lay.SelectedObjects.AddAll

' Invoke the SnapTogether on the resulting selected shape.


lay.InvokeCommand("ShapeSnapTogether")

Accessing to group objects

Now we provide access to the sub-drawing objects of a group object. The ability to traverse elements inside a group
object was added to the API. The important part is that sub-elements should be correctly propagated to the parent object.
We can access to the elements of a group, add a drawing object to a group, remove a drawing object from a group, delete
an object out of a group and access the elements of nested groups. We can now make via api shape selection, shape
move, shape rotate, and shape flip in the group.

The following code shows how to add shape to the group:

API Scripting Guide 1477


Layout

' Project Module


Sub Main
Dim lay As Layout
Dim ret As Variant

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

If (lay.Windows.Count = 0) Then
lay.NewWindow(mwLWT_Layout2D)
End If

lay.Activate

PrintDrawObjectsState lay, "Before Add Shape To Group Objects"

AddShapeToGroup lay

PrintDrawObjectsState lay, "After Add Shape To Group Objects"

End Sub

Sub AddShapeToGroup(ByRef lay As Layout)


Dim objDraw As DrawingObject
Dim grpObj As DrawingObject
Dim shpObj As DrawingObject

For Each objDraw In lay.DrawingObjects


If objDraw.Group Then
Set grpObj = objDraw
Else
Set shpObj = objDraw
End If
Next objDraw

If Not grpObj Is Nothing And Not shpObj Is Nothing Then


grpObj.GroupObjects.Add(shpObj)
End If

End Sub

Sub PrintDrawObjectsState(ByRef lay As Layout, title As String)


Dim objDraw As DrawingObject
Dim grpObj As DrawingObject

Debug.Print"*** " & title & " ***"

' Dump the results of a file for comparison.


Debug.Print "Layout = " & lay.Name
Debug.Print "DrawingObjects Count = " & lay.DrawingObjects.Count
For Each objDraw In lay.DrawingObjects
Debug.Print"Is Group = " & objDraw.Group
Debug.Print"Group Obj Count = " & objDraw.GroupObjects.Count
If objDraw.Group Then
For Each grpObj In objDraw.GroupObjects
PrintDrawingObject grpObj

1478 NI AWR Design Environment


Layout

Debug.Print""
Next grpObj
End If
Debug.Print""
Next objDraw
Debug.Print""

End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print"Info Text = " & drawingObj.InfoText
Debug.Print"Selected = " & drawingObj.Selected
Debug.Print"Flipped = " & drawingObj.Flipped
Debug.Print"Rotation = " & drawingObj.RotationAngle
Debug.Print"Frozen = " & drawingObj.Frozen
Debug.Print"Base Pos = { x = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePosition.y
Debug.Print"Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)

End Sub

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Debug.Print"Parameters:"
For Each param In params
Debug.Printparam.Name & " = " & param.ValueAsString
Next param

End Sub

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Debug.Print"Attributes:"
For Each attr In attrs
Debug.Printattr.Name & " = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Debug.Print"Boundary:"
Debug.Print"Left = " & bound.Left
Debug.Print"Right = " & bound.Right
Debug.Print"Top = " & bound.Top
Debug.Print"Bottom = " & bound.Bottom
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Debug.Print"Vertices:"
For Each vert In verts
Debug.Print"{ x= " & vert.x & ", y= " & vert.y & " }"
Next vert

API Scripting Guide 1479


Layout

End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Debug.Print"Edit Handles:"
For Each eh In ehs
Debug.Print"{ x= " & eh.Position.x & ", y= " & eh.Position.y & " }"
Next eh
End Sub

The following fragment of code shows how to access to nested groups:

' Project Module


Sub PrintGroupObjects(ByRef objDraw As DrawingObject, Depth As Integer)
Dim grpObj As DrawingObject

Debug.Print"Is Group = " & objDraw.Group


Debug.Print"Group Obj Count = " & objDraw.GroupObjects.Count
If objDraw.Group Then
Debug.Print""
Debug.Print"*** Group Begin Depth = " & Depth & " ***"
For Each grpObj In objDraw.GroupObjects
PrintDrawingObject grpObj
Debug.Print""

' If it is a group then recurse down into it.


If grpObj.Group Then
PrintGroupObjects grpObj, Depth + 1
End If

Debug.Print""
Next grpObj
Debug.Print"*** Group End Depth = " & Depth & " ***"
Debug.Print""
End If

End Sub

We provide support for the drawing object Flatten method for sub-elements of a group. The Flatten method of a drawing
object is called on elements contained inside a group. When the object is flatten it is removed from the group and the
resulting shapes are added back to the group, so the group object is not lost in the process the sub-object is transformed
in place and replaced by its flattened shapes. If the group sub-object is an element associated PCell, the object is flattened
and the Cell is disassociated before being removed from the group and replaced by the flattened shapes.

Sub FlattenGroupShapes(ByRef lay As Layout)


Dim objDraw As DrawingObject
Dim grpObj As DrawingObject

For Each objDraw In lay.DrawingObjects


If objDraw.Group Then
For Each grpObj In objDraw.GroupObjects
grpObj.Flatten
Next grpObj

1480 NI AWR Design Environment


Layout

End If
Next objDraw

End Sub

The following fragment of code shows how to rotate shapes in groups:

' Project Module


Sub RotateShapeInGroup(ByRef lay As Layout)
Dim objDraw As DrawingObject
Dim grpObj As DrawingObject

For Each objDraw In lay.DrawingObjects


If objDraw.Group Then
Set grpObj = objDraw
End If
Next objDraw

If Not grpObj Is Nothing Then


grpObj.GroupObjects(1).RotationAngle = 90.0
End If

End Sub

The following fragment of code shows how to group shapes:

lay.SelectedObjects.AddAll
lay.InvokeCommand("EditorGroup")

Deleting a Pcell when Grouped with a Dumb Shape

When an element that has a buddy is deleted from a group, and the group (or nested groups) is left with a single object,
you should remove the object from the group and insert it back into the diagram ungrouped. This allows you to later
directly delete the object without needing to ungroup it.

' Project Module


Private Sub Project_Open()
Debug.Clear
Dim par As Parameter
Dim ele As Element
Dim lay As Layout
Dim sh As Shape
Dim drob As DrawingObject

Set sch = Project.Schematics("Schematic_1")

'Seeking for Elements and for Parameters


l = 0
For Each ele In sch.Elements
l=l+1
If ele.Name = "MLIN.TL1" Then

API Scripting Guide 1481


Layout

Debug.Print "Element ";l;": ";ele.Name;vbTab;"Symbol = ";ele.Symbol;vbTab;ele.RotationAngle;vb


ele.Delete
End If
Debug.Print
Next ele
Set lay = sch.Layout
If (sch.Layout.Windows.Count = 0) Then
sch.Layout.NewWindow(mwLWT_Layout2D)
End If

lay.Activate
lay.Refresh
For Each drob In lay.DrawingObjects
If drob.TypeBits = 1 Then
drob.Delete
End If
Next drob

End Sub

This skips the Port related Drawing objects and deletes the remaining shape.

Performing a Design Rule Check

To perform a Design Rule Check of the Layout, use the DesignRuleChecker object:

For Each s In Project.Schematics


'Create a rule set object
Set p = s.Layout.DesignRuleChecker.CreateRuleSet
'Load some rules into the rule set
pth = Project.Path
'rule_file = pth + "drc_rules.txt"
rule_file = pth + "drc_rules_cut.txt"
'p.ImportDefaultRules() 'If rules defined by the LPF
p.Import(rule_file)
'Pass the design rules to the check call
p("Run Cell Base DRC").Enable=False
p("Run Rat Lines Check").Enable=False 'rat line check
p("Run Inets Short Detector").Enable=False
s.Layout.DesignRuleChecker.RunCheck(p)
'once that is complete get errors
Debug.Print s.Name
Debug.Print " errors= " & s.Layout.DesignRuleChecker.Errors.Count
For i = 1 To s.Layout.DesignRuleChecker.Errors.Count
Debug.Print"DRC Code =" & s.Layout.DesignRuleChecker.Errors(i).Code & " DRC Type =" & s.Layout.D
For j = 1 To s.Layout.DesignRuleChecker.Errors(i).Vertices.Count
Debug.Print vbTab & "x= " & s.Layout.DesignRuleChecker.Errors(i).Vertices(1).x/Project.Units(mw
Debug.Print "y= " & s.Layout.DesignRuleChecker.Errors(i).Vertices(1).y/Project.Units(mwUT_Lengt
Next j
Next i
Next s

If you do not want to import the rules, you can manually add them directly to the rule set in the script:

desRules.Add("DesignRule Text here",True)

1482 NI AWR Design Environment


Layout

The following is another example of sweeping and checking for DRC errors:

Option Explicit
Const PI = 3.14159265358979323846
Sub Main
Debug.Clear
Dim s As Schematic, e As Element
Set s = Project.Schematics("lay2")
Dim drc As DesignRuleChecker, dr As DesignRule, drs As DesignRules
Set drc = s.Layout.DesignRuleChecker
Set drs = drc.CreateRuleSet()
drs.Import(Project.Path & "\notch_drc_check.txt")
SweepAndCheckForErrors(s, drc, drs)

End Sub
Private Function SweepAndCheckForErrors(s As Schematic, drc As DesignRuleChecker, drs As DesignRule
Dim e As Element, p As Parameter
Set e = s.Elements("MCURVE.TL1")
Set p = e.Parameters("ANG")
Dim a As Double, totAngs As Long, errAngs As Long, a10ths As Double
For a = 0 To 90 Step 0.15
MWOffice.Status.RemoveAllItems
p.ValueAsDouble = (PI/180)*a
s.Layout.SnapTogether(mwLST_AllObjects)
drc.RunCheck(drs)
Incr(totAngs)
If(drc.Errors.Count > 0) Then
Incr(errAngs)
Debug.Print "Ang = " & a
End If
Next a
Debug.Print totAngs & " angles checked, " & errAngs & " in error, %" & 100*(errAngs/CDbl(totAngs))
End Function
Private Function Incr (ByRef X As Long) As Long
X = X + 1
Incr = X
End Function

The following script shows how to perform a GDSII Compare:

Dim symbName As String

Dim fnm, nm1 As String

fnm = Project.Path + "Full_Enchilada_Analog.sch"


nm1 = "Full_Enchilada_Analog"
Project.Schematics.Import(nm1,fnm)

Project.Schematics("Full_Enchilada_Analog").Layout.NewWindow(mwLWT_Layout2D).Activate
Project.Schematics("Full_Enchilada_Analog").Layout.DesignRuleChecker.CompareLayoutToGDSFile(Projec

Debug.Print Project.Schematics("Full_Enchilada_Analog").Layout.DesignRuleChecker.Errors.Count

End Sub

API Scripting Guide 1483


Layout

API Command lvs.ErrorsWindow.Visible

When a Project which previously had the LVS window open is loaded, the LVS window is open but not owned by any
Schematic, so schematic.Layout.LayoutVsSchematicChecker.ErrorsWindow.Visible is always returned as False. To
avoid this, you should close any windows with an Unknown type at the start of the script.

The following script provides an example of working with LVS:


' Code Module
Function Write_LVS_Errors(ByRef fwrite as String, Optional topsch)
Dim s As Schematic

Open fwrite For Output As #1


'may have to change schematic doing check for here

' If topsch is unspecified or is not a schematic, use Project.Schematics(1).


If IsMissing(topsch)=True Then
Set s = Project.Schematics(1)
else
If Project.Schematics.Exists(topsch) Then
Set s = Project.Schematics(topsch)
Else
Set s = Project.Schematics(1)
End If
End If

Dim lvs As LayoutVsSchematicChecker


Set lvs = s.Layout.LayoutVsSchematicChecker
lvs.RunConnectivityCheck
Print #1, s.Name
Print #1, " errors= " & lvs.Errors.Count
Dim i As Long, shp As DRCErrorShape, vert As Vertex, shpNum As Long
For i = 1 To lvs.Errors.Count
Print #1, "LVS Message =" & lvs.Errors(i).Message & " LVS State =" & lvs.Errors(i).State & " LVS
shpNum = 1
For Each shp In lvs.Errors(i).Shapes
Print #1, "Shape " & shpNum & ":"
For Each vert In shp.Vertices
Print #1, vbTab & "x= " & vert.x/Project.Units(mwUT_Length).MultValue & vbTab;
Print #1, "y= " & vert.y/Project.Units(mwUT_Length).MultValue
Next vert
shpNum = shpNum+1
Next shp
Next i
Close #1

End Function

Accessing Connecttivity Highlighter

You can perform a series of operations with Layout.ConnectivityHighlighter object, including highlight all, highlight
off, highlight shape, highlight probe and highlight selected off methods for determining associated shapes in the
connectivity :

' Code Module

1484 NI AWR Design Environment


Layout

Sub Main
Dim lay As Layout
Set lay = Project.Schematics("Schematic 1").Layout
lay.ConnectivityHighlighter.HighlightOff
' lay.ConnectivityHighlighter.HighlightAll
' lay.ConnectivityHighlighter.HighlightShape(lay.DrawingObjects(2), mwCLR_AliceBlue)
Dim x As Double
Dim y As Double
x = lay.DrawingObjects(1).Shapes(1).Vertices(1).x
y = lay.DrawingObjects(1).Shapes(1).Vertices(1).y
lay.ConnectivityHighlighter.HighlightProbe(x, y, mwCLR_Red)
End Sub

Accessing Connectivity test results in Status Window.

You can perform operations with Layout.Connectivity object. After that to access results in Status Window, when the
messages arent errors from MWO, but from lvs check you can use the following code:

' Project Module


Dim g_b As Boolean

Private Sub Project_AfterSimulate()


Debug.Clear
Dim stg As String
Dim dfile As DataFile

cnt = 0
If g_b = True Then

Dim grp As StatusGroup

For Each grp In MWOffice.Status.Groups


Debug.Print grp.Name
Next grp

Set grp = MWOffice.Status.Groups("Connectivity Tracer - Cap")

For k = 1 To grp.Items.Count
Debug.Print grp.Items(1).Text
If grp.Items(1).Text = "Found shorted elements" Then cnt = 1

Next k

Else
g_b = True
End If

End Sub

Private Sub Project_Open()


Dim s As Schematic
Set s = Project.Schematics(1)

Dim lvs As LayoutVsSchematicChecker


Set lvs = s.Layout.LayoutVsSchematicChecker

API Scripting Guide 1485


Layout

lvs.RunConnectivityCheck

g_b = False
Project.Simulator.Analyze

End Sub

Parts of the Layout Manager


Process Definition

The following code shows how to access the Process Definition:

Dim def As LayoutProcessDefinition


Dim prop As ProcessProperty
Debug.Clear
For Each def In Project.ProcessDefinitions
Debug.Print def.Name
For Each prop In def.Properties
Debug.Print prop.Name & " = " & prop.Value
Next prop
Next def

This code generates the following output:

my_mmic.lpf
First Property = 100
Second Property = 200

You have to set UsePeojectOptions to False to set new ProceccDefinition for Schematic:

' Code Module


Sub Main
Debug.Clear
Debug.Print Project.Schematics(1).ProcessDefinition
Project.Schematics(1).UseProjectOptions=False
Project.Schematics(1).ProcessDefinition= "MIC_english.lpf"
Debug.Print Project.Schematics(1).ProcessDefinition
End Sub

Accessing Process Definition Line Types

To access Process Definition Line types, use the following code:

Dim proc As LayoutProcessDefinition


Dim procName As String
procName = Project.Schematics(1).ProcessDefinition
Set proc = Project.ProcessDefinitions(procName)
Debug.Print proc.LineTypes("Metal1").Number
Debug.Print proc.LineTypes("Metal0").Number

This code generates the following output:

1486 NI AWR Design Environment


Layout

1
2

Accessing Process Definition Via Types

To access Process Definition Via types, use the following code:

Dim layProcDef As LayoutProcessDefinition


Dim viaType As ProcessViaType
Dim index As Integer
Dim ltPair As ProcessViaLineTypePair

Set layProcDef = Project.ProcessDefinitions(1)


Print #1, "Process Definition Name = " & layProcDef.Name
Print #1, "Process Via Types = " & layProcDef.ViaTypes.Count

index = 1
For Each viaType In layProcDef.ViaTypes
Debug.Print "Via Type[" & index & "] = "
Debug.Print "Name = " & viaType.Name
Debug.Print "Number = " & viaType.Number
Debug.Print "Type Index = " & viaType.TypeIndex
Debug.Print "Valid between = " & viaType.ValidBetween(1, 0)
Debug.Print "Valid Line Type Pairs = "
For Each ltPair In viaType.ValidLineTypeEnds
Debug.Print " " & ltPair.First.Name & " and " & ltPair.Second.Name
Next ltPair
Debug.Print "Valid Line Type Ranges = "
For Each ltPair In viaType.ValidLineTypeRanges
Debug.Print " " & ltPair.First.Name & " and " & ltPair.Second.Name
Next ltPair
Debug.Print ""
index = index + 1
Next viaType

Accessing Process Definition Via Fill Entries and Via Fence Entries

API defines interfaces and objects representing process via fill entries and process via fence entries and collections to
provide access to these values in the LPF for a project. For ViaFill and ViaFence entries API provides methods for adding
a new entry, removing an entry, removing all entries and importing a process definition with via fill entries included.

To access Process Definition Via Fill entry, use the following code:

Dim layProcDef As LayoutProcessDefinition


Dim index As Integer
Dim vfe As ProcessViaFillEntry

Set layProcDef = Project.ProcessDefinitions(1)


Debug.Print "Process Definition Name = " & layProcDef.Name
Debug.Print "Via Fill Entry Count = " & layProcDef.ViaFillEntries.Count

' Print each rule and it's state.

API Scripting Guide 1487


Layout

index = 1
For Each vfe In layProcDef.ViaFillEntries
Debug.Print "Via Fill Entry #" & index
PrintViaFillEntry vfe
index = index + 1
Next vfe

End Sub

Sub PrintViaFillEntry(ByRef vfe As ProcessViaFillEntry)


Debug.Print "Name = " & vfe.Name
Debug.Print "Lib Name = " & vfe.libName
Debug.Print "Cell Name = " & vfe.CellName
Debug.Print "Spacing Type = " & vfe.SpacingType
Debug.Print "Spacing X = " & vfe.SpacingX * 1e6
Debug.Print "Spacing Y = " & vfe.SpacingY * 1e6
Debug.Print "Offset X = " & vfe.OffsetX
Debug.Print "Offset Y = " & vfe.OffsetY
Debug.Print , "Stagger Mode = " & vfe.StaggerMode
Debug.Print ""
End Sub

To access ViaFence interface use the following code::

Dim layProcDef As LayoutProcessDefinition


Dim index As Integer
Dim vfe As ProcessViaFenceEntry

Set layProcDef = Project.ProcessDefinitions(1)


Debug.Print "Process Definition Name = " & layProcDef.Name
Debug.Print "Via Fence Entry Count = " & layProcDef.ViaFenceEntries.Count

' Print each rule and it's state.


index = 1
For Each vfe In layProcDef.ViaFenceEntries
Print #1, "Via Fence Entry #" & index
PrintViaFenceEntry vfe
index = index + 1
Next vfe

End Sub

Sub PrintViaFenceEntry(ByRef vfe As ProcessViaFenceEntry)


Debug.Print "Name = " & vfe.Name
Debug.Print "Lib Name = " & vfe.libName
Debug.Print "Cell Name = " & vfe.CellName
Debug.Print "Spacing Type = " & vfe.SpacingType
Debug.Print "Spacing = " & vfe.Spacing * 1e6
Debug.Print "Offset X = " & vfe.OffsetX
Debug.Print "Offset Y = " & vfe.OffsetY
Debug.Print ""
End Sub

1488 NI AWR Design Environment


Layout

Accessing Process Definition Structure

To access Process Definition structure, use the following code:

Dim layProcDef As LayoutProcessDefinition


Dim lt As ProcessTypeInfo
Dim lt2 As ProcessTypeInfo
Dim layInfo As ProcessLayerInfo
Dim index As Integer

Set layProcDef = Project.ProcessDefinitions(1)


Debug.Print "Process Definition Name = " & layProcDef.Name
Debug.Print "Line Type Count = " & layProcDef.LineTypes.Count
Debug.Print ""

' Print each rule and it's state.


index = 1
For Each lt In layProcDef.Structures

Debug.Print "Structure[" & index & "] = " & lt.Name

If layProcDef.Structures.Exists(lt.Name) Then
Debug.Print "Structure " & lt.Name & " Exists in the collection"
Else
Debug.Print "Structure " & lt.Name & " Was not found to exist in the Structures collection"
End If

Set lt2 = layProcDef.Structures(lt.Name)


If lt2 Is Nothing Then
Debug.Print "Structure " & lt.Name & " lookup by name failed"
Else
Debug.Print "Structure " & lt.Name & " lookup by name succeeded"
End If

For Each layInfo In lt.Layers


Debug.Print " Layer = " & layInfo.Name;
Debug.Print ", Offset = " & layInfo.Offset * 1e6;
Debug.Print ", MinWidth = " & layInfo.MinWidth * 1e6;
Debug.Print ", BridgeCount = " & layInfo.Bridges.Count
Next layInfo
Debug.Print ""
index = index + 1
Next lt

Accessing Process Definition Properties

To access Process Definition properties, use the following code:

Dim layProcDef As LayoutProcessDefinition


Dim procProp As ProcessProperty

Set layProcDef = Project.ProcessDefinitions(1)


Debug.Print "Process Definition Name = " & layProcDef.Name

API Scripting Guide 1489


Layout

Debug.Print "Process Properties Count = " & layProcDef.Properties.Count

For Each procProp In layProcDef.Properties


Debug.Print procProp.Name & " = " & procProp.Value
Next procPro

Accessing Process Definition Pads

To access Process Definition Pads, use the following code:

Dim layProcDef As LayoutProcessDefinition


Dim lt As ProcessTypeInfo
Dim lt2 As ProcessTypeInfo
Dim layInfo As ProcessLayerInfo
Dim index As Integer

Set layProcDef = Project.ProcessDefinitions(1)

Debug.Print "Process Definition Name = " & layProcDef.Name


Debug.Print "Pad Type Count = " & layProcDef.Pads.Count
Debug.Print ""

' Print each rule and it's state.


index = 1
For Each lt In layProcDef.Pads

Debug.Print "Pad[" & index & "] = " & lt.Name

If Not lt.Name = "" Then

If layProcDef.Pads.Exists(lt.Name) Then
Debug.Print "Pad " & lt.Name & " Exists in the collection"
Else
Debug.Print "Pad " & lt.Name & " Was not found to exist in the Capacitors collection"
End If

Set lt2 = layProcDef.Pads(lt.Name)


If lt2 Is Nothing Then
Debug.Print "Pad " & lt.Name & " lookup by name failed"
Else
Debug.Print "Pad " & lt.Name & " lookup by name succeeded"
End If

End If

For Each layInfo In lt.Layers


Debug.Print " Layer = " & layInfo.Name;
Debug.Print ", Offset = " & layInfo.Offset * 1e6;
Debug.Print ", MinWidth = " & layInfo.MinWidth * 1e6;
Debug.Print ", BridgeCount = " & layInfo.Bridges.Count
Next layInfo
Debug.Print ""
index = index + 1
Next lt

1490 NI AWR Design Environment


Layout

Accessing Process Definition Connect Rule

To access the Process Definition Connect Rule, use the following code:

Dim layProcDef As LayoutProcessDefinition


Dim connRule As ConnectionRule
Dim index As Integer

Set layProcDef = Project.ProcessDefinitions(1)


Debug.Print "Process Definition Name = " & layProcDef.Name
Debug.Print "Connection Rule Count = " & layProcDef.ConnectionRules.Count

' Print each rule and it's state.


index = 1
For Each connRule In layProcDef.ConnectionRules

Debug.Print "Rule[" & index & "] = " & connRule.Rule;


Debug.Print ", Enabled = " & connRule.Enable
index = index + 1
Next connRule

Accessing Process Definition Crossover Rule

To access the Process Definition Crossover Rule, use the following code:

Sub Main
Dim layProcDef As LayoutProcessDefinition
Dim crossRule As CrossoverRule

Set layProcDef = Project.ProcessDefinitions(1)


PrintCrossRulesState layProcDef, "Before Add Rule Entry"

' Add one entry to each rule (needs to be unique relative to existing entries.
For Each crossRule In layProcDef.CrossoverRules
crossRule.Entries.Add("Plated Metal Line", "Plated Metal Line", 5e-6)
Next crossRule

PrintCrossRulesState layProcDef, "After Add Rule Entry"

End Sub

Sub PrintCrossRulesState(ByRef layProcDef As LayoutProcessDefinition, title As String)


Dim crossRule As CrossoverRule
Dim index As Integer

Debug.Print title

Debug.Print "Process Definition Name = " & layProcDef.Name


Debug.Print "Crossover Rule Count = " & layProcDef.CrossoverRules.Count

' Print each rule and it's state.


index = 1
For Each crossRule In layProcDef.CrossoverRules
Debug.Print "Crossover Rule #" & index

API Scripting Guide 1491


Layout

PrintCrossoverRule crossRule
index = index + 1
Next crossRule

Debug.Print "----------------"
Debug.Print ""

End Sub

Sub PrintCrossoverRule(ByRef crossRule As CrossoverRule)


Dim entry As CrossoverRuleEntry

Debug.Print "Rule Name = " & crossRule.Name


Debug.Print "Flags = " & crossRule.Flags
Debug.Print "Entries: "
For Each entry In crossRule.Entries
Dedug.Print " Name = " & entry.Name
Dedug.Print " ltFrom = " & entry.FromLineTypeName
Dedug.Print " ltTo = " & entry.ToLineTypeName
Dedug.Print " Offset = " & entry.LineOffset * 1e6
Dedug.Print ""
Next entry
Dedug.Print ""
End Sub

The following script adds Crossover Rules:

Sub Main
Dim layProcDef As LayoutProcessDefinition
Dim crossRule As CrossoverRule
Dim index As Integer

Set layProcDef = Project.ProcessDefinitions(1)

Set crossRule = layProcDef.CrossoverRules.CreateNew()


crossRule.Entries.Add("Thick Metal Line", "Thick Metal Line", 5e-6)
crossRule.Entries.Add("Thick Metal Line", "Cap Bottom Line", 5e-6)

Set crossRule = layProcDef.CrossoverRules.CreateNew()


crossRule.Entries.Add("Cap Bottom Line", "Thick Metal Line", 5e-6)
crossRule.Entries.Add("Cap Bottom Line", "Cap Bottom Line", 5e-6)

Set crossRule = layProcDef.CrossoverRules.CreateNew()


crossRule.Entries.Add("Plated Metal Line", "Thick Metal Line", 5e-6)
crossRule.Entries.Add("Plated Metal Line", "Cap Bottom Line", 5e-6)

Set crossRule = layProcDef.CrossoverRules.CreateNew()


crossRule.Entries.Add("Thick Metal Line", "Thick Metal Line", 5e-6)
crossRule.Entries.Add("Plated Metal Line", "Cap Bottom Line", 5e-6)

Set crossRule = layProcDef.CrossoverRules.CreateNew()


crossRule.Entries.Add("Cap Bottom Line", "Cap Bottom Line", 5e-6)
crossRule.Entries.Add("Plated Metal Line", "Thick Metal Line", 5e-6)
Dedug.Print "After Adding Crossover Rules: "
Dedug.Print "Crossover Rule Count = " & layProcDef.CrossoverRules.Count

1492 NI AWR Design Environment


Layout

' Print each rule and it's state.


index = 1
For Each crossRule In layProcDef.CrossoverRules
Dedug.Print "Crossover Rule #" & index
PrintCrossoverRule crossRule
index = index + 1
Next crossRule

End Sub

Sub PrintCrossoverRule(ByRef crossRule As CrossoverRule)


Dim entry As CrossoverRuleEntry

Dedug.Print "Rule Name = " & crossRule.Name


Dedug.Print "Flags = " & crossRule.Flags
Dedug.Print "Entries: "
For Each entry In crossRule.Entries
Dedug.Print " Name = " & entry.Name
Dedug.Print " ltFrom = " & entry.FromLineTypeName
Dedug.Print " ltTo = " & entry.ToLineTypeName
Dedug.Print " Offset = " & entry.LineOffset * 1e6
Dedug.Print ""
Next entry
Dedug.Print ""
End Sub

Accessing Process Definition Capacitor

To access the Process Definition Capacitor, use the following code:

Dim layProcDef As LayoutProcessDefinition


Dim lt As ProcessTypeInfo
Dim lt2 As ProcessTypeInfo
Dim layInfo As ProcessLayerInfo
Dim index As Integer

Set layProcDef = Project.ProcessDefinitions(1)


Debug.Print "Process Definition Name = " & layProcDef.Name
Debug.Print "Capacitor Type Count = " & layProcDef.Capacitors.Count
Debug.Print ""

' Print each rule and it's state.


index = 1
For Each lt In layProcDef.Capacitors

Debug.Print "Capacitor[" & index & "] = " & lt.Name

If Not lt.Name = "" Then

If layProcDef.Capacitors.Exists(lt.Name) Then
Debug.Print "Structure " & lt.Name & " Exists in the collection"
Else
Debug.Print "Structure " & lt.Name & " Was not found to exist in the Capacitors collection"
End If

API Scripting Guide 1493


Layout

Set lt2 = layProcDef.Capacitors(lt.Name)


If lt2 Is Nothing Then
Debug.Print "Capacitor " & lt.Name & " lookup by name failed"
Else
Debug.Print "Capacitor " & lt.Name & " lookup by name succeeded"
End If

End If

For Each layInfo In lt.Layers


Debug.Print " Layer = " & layInfo.Name;
Debug.Print ", Offset = " & layInfo.Offset * 1e6;
Debug.Print ", MinWidth = " & layInfo.MinWidth * 1e6;
Debug.Print ", BridgeCount = " & layInfo.Bridges.Count
Next layInfo
Debug.Print ""
index = index + 1
Next lt

Read/Write Support of Process Definition Properties

To view the Process Definition properties, use the following script:

' Code Module


Sub Main
Dim procDef As LayoutProcessDefinition
Set procDef = Project.ProcessDefinitions("Default")
procDef.LayerSetup.DrawingLayers.Add("MyFirstLayer")
procDef.LayerSetup.DrawingLayers.Add("MySecondLayer")
procDef.Export("c:\users\dupree\MyProcDef.lpf")
End Sub

The exported LPF file displays similar to the following:

"MyFirstLayer" 255 255 0 1 1 1 0 0 0 "" 0 0 0 "Obsolete" 0 0


"MySecondLayer" 255 255 0 1 1 1 0 0 0 "" 0 0 0 "Obsolete" 0 0

These are the layers that were added programmatically. The previous example uses the absolute minimum to add the
layers, and includes optional arguments for line type, fill type and even 3D properties such as z-position.

API allows accessing the default fill patterns and custom fill patterns:

fs = Project.ProcessDefinitions(1).LayerSetup.DrawingLayers("M1").FillStyle
Debug.Print fs

In addition to the LayerSetup, the Process Definition has collections for LineTypes, Structures, Capacitors, Vias, and
Pads. Each of these collections has an Add method that you can use to add values.

1494 NI AWR Design Environment


Layout

Updating dependent process definitions through the API

This will be very useful when we need to add EM Structure Files to PDKs. To do so we need a way to automatically
update the stackup element dependent LPFs during PDK updates.

API methods are equivalent to the UI methods for updating dependent LPFs in a project. The methods provide the ability
to list the dependent LPF by name, update a particular LPF by giving its name and the options to update. The methods
also provide the ability to update all dependent LPFs and provide the update options.

The API provides an object name collection LayoutProcessDefinition.DependentProcessDefinitionNames which provides


a list of the depentent process definition names for a given process definition. It also provides two methods:
UpdateDependentProcessDefinition() and UpdateAllDependentProcessDefinitions(). The first takes the name of the
dependent process definition to be updated. The second will update all dependent process definitions. Both functions
take a set of optional parameters which allow which aspects of the dependent process definition to be updated.

Below are some examples ways to call the new methods for updating the dependent process definitions:

' Code Module


Sub Main
Debug.Clear
Dim layProc As LayoutProcessDefinition
Dim objName As ObjectName
For Each layProc In Project.ProcessDefinitions
Debug.Print "LPF Name (layProc.Name) = " & layProc.Name
Debug.Print "Number of Dependent LPFs (layProc.DependentProcessDefinitionNames.Count) = " & layPr

For Each objName In layProc.DependentProcessDefinitionNames


Debug.Print "Dep LPF Name = " & objName.Name
Next objName

' Update all Dependents


layProc.UpdateAllDependentProcessDefinitions

' Update some aspects of all dependent Procs


layProc.UpdateAllDependentProcessDefinitions True, False, True, False, True

' Update a specific proc by name


Dim procName As String
procName = "+AXIEM_UberShuntCap_StretchXY"

If (layProc.DependentProcessDefinitionNames.Exists(procName)) Then
layProc.UpdateDependentProcessDefinition procName, True, True, True, True, True
End If

Debug.Print "------------------"
Next layProc
End Sub

The example of the output from running the script can look like the following and you can see 3 dependents for the first
LPF:

LPF Name (layProc.Name) = RTN_P80B.lpf


Number of Dependent LPFs (layProc.DependentProcessDefinitionNames.Count) = 3

API Scripting Guide 1495


Layout

Dep LPF Name = +AXIEM_Inductor_StretchY


Dep LPF Name = +AXIEM_SeriesCap_3pTune
Dep LPF Name = +AXIEM_UberShuntCap_StretchXY
------------------
LPF Name (layProc.Name) = +AXIEM_Inductor_StretchY
Number of Dependent LPFs (layProc.DependentProcessDefinitionNames.Count) = 0
------------------
LPF Name (layProc.Name) = +AXIEM_SeriesCap_3pTune
Number of Dependent LPFs (layProc.DependentProcessDefinitionNames.Count) = 0
------------------
LPF Name (layProc.Name) = +AXIEM_UberShuntCap_StretchXY
Number of Dependent LPFs (layProc.DependentProcessDefinitionNames.Count) = 0
------------------
LPF Name (layProc.Name) = QORVO_QGAN15_ES.lpf
Number of Dependent LPFs (layProc.DependentProcessDefinitionNames.Count) = 0
------------------
LPF Name (layProc.Name) = GCS_DHBT3.lpf
Number of Dependent LPFs (layProc.DependentProcessDefinitionNames.Count) = 0

Accessing Process Definition Default font

To view the Process Definition default Font information, use the following script:

' Code Module


Sub Main
Dim layProcDef As LayoutProcessDefinition
Dim fontInf As FontInfo

Set layProcDef = Project.ProcessDefinitions(1)


Debug.Print "Process Definition Name = " & layProcDef.Name
Debug.Print "Default Font Info: "

Set fontInf = layProcDef.DefaultFont

Print #1, "Font Name = " & fontInf.Name


Print #1, "Font Height = " & fontInf.Height
Print #1, "Font Bold = " & fontInf.Bold
Print #1, "Font Italic = " & fontInf.Italic

End Sub

Adding EM Layer Mapping to Process Definition

When a new Project is created a default Process Definition is added to the Layout as a place holder. To add an EM Layer
Mapping to Process Definition use the following script:

Sub Main
Dim layProcDef As LayoutProcessDefinition
Dim laySetup As LayerSetup

Set layProcDef = Project.ProcessDefinitions(1)


Set laySetup = layProcDef.LayerSetup
Debug.Print "Process Definition Name = " & layProcDef.Name

1496 NI AWR Design Environment


Layout

Debug.Print "***** Before Add EM Layer Mapping *****"


PrintEMLayerMapping(laySetup)

laySetup.EMLayerMappings.Add("MyMapping")

Debug.Print "***** After Add EM Layer Mapping *****"


PrintEMLayerMapping(laySetup)

End Sub

Sub PrintEMLayerMapping(ByRef laySetup As LayerSetup)


Dim layMap As EMLayerMapping
Dim layMap2 As EMLayerMapping
Dim index As Integer

Debug.Print "Layer Mappings Count = " & laySetup.EMLayerMappings.Count


Debug.Print ""

index = 1
For Each layMap In laySetup.EMLayerMappings

Debug.Print "Layer Mapping[" & index & "] = "


Debug.Print "Mapping Name = " & layMap.Name
PrintLayMapEntries layMap.Entries

If laySetup.EMLayerMappings.Exists(layMap.Name) Then
Debug.Print "Layer Mapping " & layMap.Name & " Exists in lookup by name"
Else
Debug.Print "Layer Mapping " & layMap.Name & " Does Not Exist in lookup by name"
End If

Set layMap2 = laySetup.EMLayerMappings(layMap.Name)


If layMap2 Is Nothing Then
Debug.Print "Layer Mapping " & layMap.Name & " Lookup by name failed"
Else
Debug.Print "Layer Mapping " & layMap.Name & " Lookup by name succeeded"
End If

Debug.Print ""
index = index + 1
Next layMap

End Sub

Sub PrintLayMapEntries(ByRef entries As EMLayerMapEntries)


Dim entry As EMLayerMapEntry

For Each entry In entries


Debug.Print entry.DrawingLayer & " -> " & entry.EMLayer
Debug.Print "Is Via = " & entry.IsVia
Debug.Print "Material = " & entry.Material
Next entry

End Sub

API Scripting Guide 1497


Layout

To add a File Export Mapping use the following code:

laySetup.LayerExportMappings.Add("MyMapping", mwLEF_GDSII_Hierarchical)

Using copy methods to the File Export Mappings collection and the EM Layer Mappings collections.

The add methods use to copy a default configuration when invoked but we need explicit copy methods to allow the user
to specify the target that the new file mapping or EM layer mapping should be copied from. The following statements
show copy methods added the layer export file mappings and the em layer mappings collections in the layer setup portion
of the process definition:

laySetup.LayerExportMappings.Copy("MMIC GDSII", "MyMapping")

The statement will copy the existing "MMIC GDSII" mapping to a new mapping with name "MyMapping".

laySetup.EMLayerMappings.Copy("Default", "MyMapping")

The statement will copy the exiting EM layer mapping "Default" to a new mapping with the name "MyMapping".

Importing/Exporting an LPF File

When a new Project is created a default Process Definition is added to the Layout as a place holder. When you import
the new Process Definition it overwrites the place holder and becomes the default LPF file. To import a LPF file named
mmic.lpf, use the following script:

' Code Module


Sub Main
Dim procDef As LayoutProcessDefinition
Debug.Clear
Set procDef = Project.ProcessDefinitions.Import("C:\mmic.lpf", True)
Debug.Print procDef.Name
' Import second lpf (overwrite = false to add and not overwrite default
Set procDef = Project.ProcessDefinitions.Import("C:\mic_metric.lpf", False)
End Sub

The first Import statement imports the mmic.lpf file and replaces the default LPF file in the Project. The second argument
in the last statement, OverwriteDefault, is set to "False" so it does not replace mmic.lpf but is merged into the Project
with it.

After importing the LPF file, the process layers are defined, as well as a number of processing parameters such as the
default length units.

To export an LPF file, use the following script:

' Code Module


Sub Main
If Project.LayerSetup.ExportLPF(Project.Path & "MIC_english_1.lpf") Then
Debug.Print "lpf exported"
Else
Debug.Print "lpf hasn't been exported!"
End If
End Sub

1498 NI AWR Design Environment


Layout

To set the process library on an imported gds library to other than the default use the following script

Script imports a GDS library which associates the library with the default library and then uses the process library property
to associate the library with the second process definition in the project. The properties of the resulting imported cell
library are then being output to verify that the cell library is not associated with default but is associated with the second
process definition.

' Code Module


Sub Main
Dim cellLib As CellLibrary
Dim libPath As String

libPath = Project.Path + "ccadc.gds"

PrintCellLibraries "Before Import CellLibrary"

Set cellLib = Project.CellLibraries.Import("ccadc.gds", libPath, mwCLT_GDSII)


cellLib.ProcessDefinition = "mmic.lpf"

PrintCellLibraries "After Import CellLibrary"

End Sub

Sub PrintCellLibraries(title As String)


Dim cellLib As CellLibrary
Dim cellLib2 As CellLibrary

Debug.Print title
Debug.Print "CellLibrary Count = " & Project.CellLibraries.Count

For Each cellLib In Project.CellLibraries


Debug.Print "Name = " & cellLib.Name
Debug.Print " DatabaseUnitsPerMeter = " & cellLib.DatabaseUnitsPerMeter
Debug.Print " DatabaseUnitsPerUserUnit = " & cellLib.DatabaseUnitsPerUserUnit
Debug.Print " ExcludeFromExport = " & cellLib.ExcludeFromExport
Debug.Print " Modified = " & cellLib.Modified
Debug.Print " OverrideDatabaseUnit = " & cellLib.OverrideDatabaseUnit
Debug.Print " OverrideDatabaseUnitSize = " & cellLib.OverrideDatabaseUnitSize
Debug.Print " Process Definition = " & cellLib.ProcessDefinition
If (Project.CellLibraries.Exists(cellLib.Name)) Then
Debug.Print "CellLibrary " & cellLib.Name & " exists in collection"
Else
Debug.Print "CellLibrary " & cellLib.Name & " not found to exist in collection"
End If

Set cellLib2 = Project.CellLibraries(cellLib.Name)


If (cellLib2 Is Nothing) Then
Debug.Print "CellLibrary " & cellLib.Name & " lookup by name failed."
Else
Debug.Print "CellLibrary " & cellLib.Name & " lookup by name succeeded."
End If

Debug.Print "---"
Next cellLib
Debug.Print ""
End Sub

API Scripting Guide 1499


Layout

Layout Connectivity Checker: Providing Connectivity Rules to LPF File

When you need to run the Connectivity Checker you must add connectivity rules to the LPF file in the Project. To add
rules to the LPF file, run the scripting code as shown in the following example:

' Code Module


Sub Main
Dim lpf As LayoutProcessDefinition

Set lpf = Project.ProcessDefinitions(1)

lpf.ConnectionRules.RemoveAll()
lpf.ConnectionRules.Add("External_Connect ""Metal 2"" External")
lpf.ConnectionRules.Add("Connect Connect ""Gate Metal"" To ""Metal 1""")
lpf.ConnectionRules.Add("Connect ""Source Drain Metal"" To ""Metal 1""")
lpf.ConnectionRules.Add("Connect ""Ground Via"" To ""Metal 1""")
lpf.ConnectionRules.Add("Connect ""Metal 1"" To ""Metal 2"" By ""Dielectric Via""")
lpf.ConnectionRules.Add("Connect ""Tantalum"" To ""Metal 1""")
lpf.ConnectionRules.Add("Connect ""Mesa"" To ""Metal 1""")
lpf.ConnectionRules.Add("Connect_All ""Ground Via""")

End Sub

The following script prints the connectivity rules:

' Code Module


Sub Main
Dim lpf As LayoutProcessDefinition

Set lpf = Project.ProcessDefinitions(1)

For i = 1 To lpf.ConnectionRules.Count
Debug.Print lpf.ConnectionRules(i).Rule
Next i
End Sub

This script generates the following output:

External_Connect "Metal 2" One


Connect "Gate Metal" To "Metal 1"
Connect "Source Drain Metal" To "Metal 1"
Connect "Ground Via" To "Metal 1"
Connect "Metal 1" To "Metal 2" By "Dielectric Via"
Connect "Tantalum" To "Metal 1"
Connect "Mesa" To "Metal 1"

You can use the following script to clean up Connectivity errors in the Project:

' Code Module


Sub Main
Dim lpf As LayoutProcessDefinition
For Each lpf In Project.ProcessDefinitions

1500 NI AWR Design Environment


Layout

Debug.Print lpf.Name
If Left(lpf.Name,1) = "+" Then
lpf.ConnectionRules.RemoveAll()
End If
Next lpf
End Sub

Layer Setup Interface

The NI AWR SDE exposes a LayerSetup object from the Project level. This object includes the following collections:

DrawingLayers
DrillTools
LayerMappings
LayerExportMappings
EMLayerMappings

These collections allow modification of the items available in the Layer Setup dialog box of the NI AWR SDE.

The LayerSetup object allows you to access all attributes associated with the DrawingLayers collection:

' Code Module


Sub Main
Dim layProcDef As LayoutProcessDefinition
Dim laySetup As LayerSetup
Dim drwLayer As DrawingLayer
Dim drwLayer2 As DrawingLayer
Dim index As Integer

Set layProcDef = Project.ProcessDefinitions(1)


Set laySetup = layProcDef.LayerSetup
Debug.Print "Process Definition Name = " & layProcDef.Name
Debug.Print "Drawing Layers Count = " & laySetup.DrawingLayers.Count
Debug.Print ""

index = 1
For Each drwLayer In laySetup.DrawingLayers

Debug.Print "Drawing Layer[" & index & "] = "


PrintLayerAttributes(drwLayer)
If laySetup.DrawingLayers.Exists(drwLayer.Name) Then
Debug.Print "Drawing Layer " & drwLayer.Name & " Exists Drawing Layers"
Else
Debug.Print "Drawing Layer " & drwLayer.Name & " Not Found in Exists String Lookup"
End If

Set drwLayer2 = laySetup.DrawingLayers(drwLayer.Name)


If drwLayer2 Is Nothing Then
Debug.Print "Drawing Layer " & drwLayer.Name & " lookup by name failed"
Else
Debug.Print "Drawing Layer " & drwLayer.Name & " lookup by name succeeded"
End If

Debug.Print ""

API Scripting Guide 1501


Layout

index = index + 1
Next drwLayer
End Sub

Sub PrintLayerAttributes(ByRef drwLayer As DrawingLayer)


Debug.Print "Name = " & drwLayer.Name
Debug.Print "Number = " & drwLayer.Number
Debug.Print "Blend = " & drwLayer.Blend
Debug.Print "Cloak = " & drwLayer.Cloak
Debug.Print "FillColor = " & drwLayer.FillColor
Debug.Print "Filled = " & drwLayer.Filled
Debug.Print "FillStyle = " & drwLayer.FillStyle
Debug.Print "Flags = " & drwLayer.Flags
Debug.Print "Frozen = " & drwLayer.Frozen
Debug.Print "LineColor = " & drwLayer.LineColor
Debug.Print "LineStyle = " & drwLayer.LineStyle
Debug.Print "Opaque = " & drwLayer.Opaque
Debug.Print "TextureFile = " & drwLayer.TextureFile
Debug.Print "TextureScale = " & drwLayer.TextureScale
Debug.Print "Thickness = " & drwLayer.Thickness
Debug.Print "Visible = " & drwLayer.Visible
Debug.Print "ZPosition = " & drwLayer.ZPosition
End Sub

The LayerSetup object allows you to access all methods and properties associated with the DrawingLayers collection.
You can set the color for the Layer object, line color, and line style; and also specify the 3D view object.

This simple script outputs the DrawingLayers Names and properties:

' Code Module


Sub Main
Dim drawls As DrawingLayers
Dim drawlay As DrawingLayer
Debug.Clear
Debug.Print Project.LayerSetup.DrawingLayers.Count
For Each drawlay In Project.DrawingLayers
Debug.Print "drawlay.Name = ";drawlay.Name
Debug.Print "Blend = ";drawlay.Blend;vbTab;"FillColor = ";drawlay.FillColor;vbTab;"FillStyle = ";
Debug.Print "LineColor = ";drawlay.LineColor;vbTab;"LineStyle = ";drawlay.LineStyle;vbTab;"Textur
Debug.Print "TextureScale = ";drawlay.TextureScale;vbTab;"Thickness = ";drawlay.Thickness;vbTab;"
If drawlay.Filled Then
Debug.Print drawlay.Name;" is Filled"
End If
If drawlay.Frozen Then
Debug.Print drawlay.Name;" is Frozen"
End If
If drawlay.Opaque Then
Debug.Print drawlay.Name;" is Opaque"
End If
If drawlay.Visible Then
Debug.Print drawlay.Name;" is Visible"
End If
Debug.Print
Next drawlay
End Sub

1502 NI AWR Design Environment


Layout

This script generates the following output:

21
drawlay.Name = Error
Blend = 0.1 FillColor = 4210943 FillStyle = 21
LineColor = 1000 LineStyle = 0 TextureFile =
TextureScale = 1.3 Thickness = 0.000035 ZPosition = -2.147483648
Error is Filled
Error is Frozen
Error is Opaque
Error is Visible
drawlay.Name = Mesa
Blend = 0 FillColor = 32768 FillStyle = 8
LineColor = 128 LineStyle = 0 TextureFile =
TextureScale = 1 Thickness = 0.0000004 ZPosition = 0
Mesa is Filled
Mesa is Opaque
Mesa is Visible
drawlay.Name = Source Drain
Blend = 0 FillColor = 8421376 FillStyle = 9
LineColor = 8388736 LineStyle = 0 TextureFile =
TextureScale = 0 Thickness = 0.000001 ZPosition = 0.000000001
Source Drain is Filled
Source Drain is Opaque
Source Drain is Visible
drawlay.Name = Source Draintext
Blend = 0 FillColor = 32896 FillStyle = 2
LineColor = 8388608 LineStyle = 0 TextureFile =
TextureScale = 0 Thickness = 0.000002 ZPosition = 0.000001001
Source Draintext is Filled
Source Draintext is Opaque
Source Draintext is Visible
drawlay.Name = Gatepad
Blend = 0 FillColor = 8388608 FillStyle = 9
LineColor = 8388736 LineStyle = 0 TextureFile = 2e6
TextureScale = 0 Thickness = 0.000001 ZPosition = 0.000003001
Gatepad is Filled
Gatepad is Opaque
Gatepad is Visible
drawlay.Name = Gate
Blend = 0 FillColor = 128 FillStyle = 9
LineColor = 8388736 LineStyle = 0 TextureFile = 2e6
TextureScale = 0 Thickness = 0.000002 ZPosition = 0.000004001
Gate is Filled
Gate is Opaque
Gate is Visible
drawlay.Name = Cap Bottom
Blend = 0 FillColor = 32768 FillStyle = 8
LineColor = 8421376 LineStyle = 0 TextureFile = 0
TextureScale = 0 Thickness = 0.000001 ZPosition = 0.000001
Cap Bottom is Filled
Cap Bottom is Opaque
Cap Bottom is Visible
drawlay.Name = Tantalum
Blend = 0 FillColor = 4227327 FillStyle = 9
LineColor = 8388736 LineStyle = 0 TextureFile = 0

API Scripting Guide 1503


Layout

TextureScale = 0 Thickness = 0.000002 ZPosition = 0.000003


Tantalum is Filled
Tantalum is Opaque
Tantalum is Visible
drawlay.Name = Poly
Blend = 0 FillColor = 65535 FillStyle = 10
LineColor = 128 LineStyle = 0 TextureFile = 0
TextureScale = 0 Thickness = 0.000002 ZPosition = 0.000003
Poly is Filled
Poly is Opaque
Poly is Visible
drawlay.Name = Nitride Etch
Blend = 0 FillColor = 16711935 FillStyle = 3
LineColor = 16711935 LineStyle = 0 TextureFile =
TextureScale = 0 Thickness = 0.000004 ZPosition = 0.000002
Nitride Etch is Filled
Nitride Etch is Opaque
Nitride Etch is Visible
drawlay.Name = Air Bridge
Blend = 0 FillColor = 65535 FillStyle = 10
LineColor = 32896 LineStyle = 0 TextureFile =
TextureScale = 0 Thickness = 0.000005 ZPosition = 0.000002
Air Bridge is Filled
Air Bridge is Opaque
Air Bridge is Visible
drawlay.Name = Thick Metal
Blend = 0.5 FillColor = 8421376 FillStyle = 2
LineColor = 8388608 LineStyle = 0 TextureFile =
TextureScale = 0 Thickness = 0.000004 ZPosition = 0.000005
Thick Metal is Filled
Thick Metal is Opaque
Thick Metal is Visible
drawlay.Name = Via
Blend = 0 FillColor = 33023 FillStyle = 8
LineColor = 128 LineStyle = 0 TextureFile =
TextureScale = 0 Thickness = 0.000004 ZPosition = 0.000008
Via is Filled
Via is Opaque
Via is Visible

As shown in the previous example, the LPF file can have many layers. The NI AWR SDE contains special methods for
the DrawingLayers collection to work only with one layer and make all other layers Not Visible, Filled, or Frozen, as
shown in the following script:

'Code Module
Sub Main
Dim layers As DrawingLayers
Debug.Clear
Set layers = Project.LayerSetup.DrawingLayers
LayerStatus(layers)
layers.AllFilled = False
LayerStatus(layers)
End Sub
Sub LayerStatus(ByRef layers As DrawingLayers)
Debug.Print "Layer Count = " & layers.Count
Debug.Print "All Visible = " & layers.AllVisible

1504 NI AWR Design Environment


Layout

Debug.Print "All Filled = " & layers.AllFilled


Debug.Print "All Frozen = " & layers.AllFrozen
End Sub

This script generates the following output:

Layer Count = 24
All Visible = True
All Filled = True
All Frozen = False
Layer Count = 24
All Visible = True
All Filled = False
All Frozen = False

providing DrawingLayers.All methods for Visible, Frozen, and Filled

' Code Module


Sub Main
Dim layers As DrawingLayers

Debug.Clear
Set layers = Project.LayerSetup.DrawingLayers
LayerStatus(layers)
layers.AllFilled = False
LayerStatus(layers)

End Sub

Sub LayerStatus(ByRef layers As DrawingLayers)


Debug.Print "Layer Count = " & layers.Count
Debug.Print "All Visible = " & layers.AllVisible
Debug.Print "All Filled = " & layers.AllFilled
Debug.Print "All Frozen = " & layers.AllFrozen
End Sub

The LayerSetup object allows you to access a DrillTool collection. You can add a new DrillTool to a collection and
output all DrillTool properties. You can also remove a DrillTool from the collection.

The following script provides a good example of creating a Drill Hole File. After you select a Drawing Layer and Units
for the Drill Hole File and a Schematic for the Layout, this script creates a set of tools, assigns coordinates for centers,
and creates an output Drill Hole File. Note that the script creates a Snapshot from the beginning.

'Code Module
Dim layerName () As String
Dim layern As String
Dim Dlayer As DrawingLayer
Dim Dl As DrawingLayer
Dim Via As Shape
Dim Snap As Snapshot
Dim lay As Layout
Dim layoutList() As String
Sub Main

API Scripting Guide 1505


Layout

Debug.Clear
numlayer = Project.LayerSetup.DrawingLayers.Count
ReDim layerName(numlayer)
j=1
For Each Dlayer In Project.LayerSetup.DrawingLayers
layerName(j) = (Dlayer.Name)
Debug.Print Dlayer.Name
j=j+1
Next Dlayer
'get the drawing layer for drill file
Begin Dialog UserDialog 400,200,"Select Drawing Layer for Drill Hole file" ' %GRID:10,7,1,1
ListBox 40,35,310,100,layerName(),.lstdataBox,1
Text 40,21,160,14,"Select Drawing Layer",.Text1
OKButton 150,160,100,28
End Dialog
Dim dlg1 As UserDialog
Dialog dlg1
Dlayerindexi = dlg1.lstdataBox
Dlayerindexi = Dlayerindexi + 1
Dlayeri = layerName(Dlayerindexi)
Debug.Print Dlayeri
numschematics = Project.Schematics.Count
ReDim layoutList(numschematics)
i=1
For Each s In Project.Schematics
layoutList( i ) = s.Name
i = i+ 1
Next s
'get the layout for the drill file
Begin Dialog UserDialog 400,203, "Select Schematic for layout" ' %GRID:10,7,1,1
ListBox 50,35,300,91,layoutList(),.ListBox1,1 'Select Circuit Schematic
OKButton 80,154,90,21
CancelButton 230,154,90,21
End Dialog
Dim dlg As UserDialog
Dialog dlg
layoutIndex = dlg.ListBox1+1
Set lay = Project.Schematics( layoutIndex ).Layout
Set Snap = lay.CreateSnapshot
Debug.Print "Create Snapshot for layout Name: ";lay.Name
Dim UnitName(2) As String
UnitName(1)="Millimeters"
UnitName(2)="Inches"
'Select the units of the drill file
Begin Dialog UserDialog 400,200,"Select Units for Drill Hole file" ' %GRID:10,7,1,1
ListBox 40,35,310,100,UnitName(),.lstdataBox,1
Text 40,21,160,14,"Select Units",.Text1
OKButton 150,160,100,28
End Dialog
Dim dlg2 As UserDialog
Dialog dlg2
Unitindexi = dlg2.lstdataBox
Unitindexi = Unitindexi + 1
Unitnamei = UnitName(Unitindexi)
Debug.Print "You choose unit: ";Unitnamei
'determine number of shapes on the layer and initialize arrays
numshapes=Snap.Shapes.Count

1506 NI AWR Design Environment


Layout

Debug.Print "Snap.Shapes.Count: ";Snap.Shapes.Count


ReDim dia (numshapes) As Double
ReDim tools (numshapes) As Double
ReDim centersx (numshapes) As Long
ReDim centersy (numshapes) As Double
ReDim toolscoor (numshapes) As String
Dim numshapesL As Long
numshapesL=0
'determine min and max x,y coordinates to find centers of vias
For i = 1 To numshapes
If Snap.Shapes(i).DrawingLayer.Name = Dlayeri Then
Set Via = Snap.Shapes(i)
numshapesL=numshapesL+1
Numvert=Via.Vertices.Count
For j = 1 To Numvert
vx = Via.Vertices(j).x
vy = Via.Vertices(j).y
If j = 1 Then
xmin=vx
ymin=vy
xmax=vx
ymax=vy
End If
If vx < xmin Then
xmin=vx
End If
If vx > xmax Then
xmax=vx
End If
If vy < ymin Then
ymin=vy
End If
If vy > ymax Then
ymax=vy
End If
Next j
Debug.Print "min vertex xmin = ";xmin;" ymin = ";ymin
Debug.Print "max vertex xmax = ";xmax;" ymax = ";ymax
End If
If unitnamei="Millimeters" Then
centersx(numshapesL)= Round((xmax + xmin)/2*1e6) 'rounding used for 3.3 format for 'mm
centersy(numshapesL)= Round((ymax + ymin)/2*1e6)
Else
centersx(numshapesL)= Round((xmax + xmin)/2*1e4*(1/.0254)) 'rounding used for 2.4 format for inc
centersy(numshapesL)= Round((ymax + ymin)/2*1e4*(1/.0254))
End If
dia(numshapesL)= Round(xmax-xmin,8)
'find diameters by the min max x of bounding box
Next i
'Create the tool set by comparing shape dia to the current set of tools, Comparing an array vs. a
numb_tool=0
For k = 1 To numshapesL
If unitnamei="Millimeters" Then
diaunit = dia(k)*1e3
Else
diaunit = dia(k)*(1/.0254)
End If

API Scripting Guide 1507


Layout

If k=1 Then
tools(1)=diaunit
numb_tool=numb_tool+1
Else
found=False
For j = 1 To numb_tool
If diaunit = tools(j) Then
found=True
End If
Next j
If found=False Then
numb_tool=numb_tool+1
tools(numb_tool)=diaunit
End If
End If
Debug.Print "centers ";k;" x = ";centersx(k);" y = ";centersy(k)
Debug.Print "diameters ";k;" diameter = ";dia(k)
Next k
'Assign tools to centers
For x = 1 To numshapesL
For y = 1 To numb_tool
If unitnamei="Millimeters" Then
If dia(x)*1e3=tools(y) Then
toolscoor(x)=y
End If
Else
If dia(x)*(1/.0254)=tools(y) Then
toolscoor(x)=y
End If
End If
Next y
Next x
'user can enter filename and directory
fn$ = GetFilePath("Drill file","txt",,"Save Drill file As:",2)
If fn$="" Then Exit Sub 'Cancel was pressed
Open fn$ For Output As #1
'output results to file
Print #1,"M48"
If unitnamei="Millimeters" Then
Print #1,"M71,LZ" 'M71 is metric in mm
Else
Print #1,"M72,LZ" 'M72 is English in inches
End If
For i = 1 To numb_tool
Print #1,"T";Format(i,"00");"C";Format(tools(i),"0.####")
Debug.Print "T";Format(i,"00");"C";Format(tools(i),"0.####")
Next i
Print #1,"%"
For i = 1 To numb_tool
first_shape = True
For j=1 To numshapesL
If toolscoor(j)=i Then
If first_shape Then
first_shape = False
Print #1,"T";Format(i,"00")
Debug.Print "T";Format(i,"00")
End If

1508 NI AWR Design Environment


Layout

Print #1,"X";Format(centersx(j),"000000");"Y";Format(centersy(j),"000000")
Debug.Print "X";Format(centersx(j),"000000");"Y";Format(centersy(j),"000000")
End If
Next j
Next i
Print #1,"T00"
Print #1,"M30"
Close #1
End Sub

This script generates the following Drill Hole File:

M48
M71,LZ
T01C0.64
T02C1.
T03C3.
%
T01
X-006310Y-033145
X-010000Y-038015
X011110Y-033915
X011150Y-028565
T02
X-026900Y-021800
X-025000Y-021800
X-023000Y-021800
X-026900Y-023700
X-025000Y-023700
X-023000Y-023700
X-026900Y-025800
X-025000Y-025800
X-023000Y-025800
T03
X-020200Y-022800
X-021400Y-042200
X000500Y-042800
X001400Y-023200
X017000Y-042800
X015700Y-023600
T00
M30

The LayerSetup object also provides an Export DrawingLayer capability. You only need to set the WriteLayer property
to "True" for the DrawingLayer object you want to export. The following code demonstrates this ability:

Dim mapentry As LayerExportEntry


'To create a new Gerber export mapping table.
Project.LayerSetup.LayerExportMappings.Add("script gerber",mwLEF_Gerber)
For Each mapEntry In Project.LayerSetup.LayerExportMappings("script gerber").Entries
mapEntry.WriteLayer = True
Next mapEntry
l.Export("Layers.ger","script gerber")

API Scripting Guide 1509


Layout

Layer Mapping

To map a model layer to the proper drawing layer, use the following code:

Project.LayerSetup.LayerMappings.Add(_Name).Entries.Add(_ModelLayer, _DrawingLayer)

This code adds a new object to a LayerMappings collection. After you add this object, the ModelLayer gets mapped to
the corresponding DrawingLayer.

To modify layer mapping, use the following code:

Project.ProcessDefinitions(1).LayerSetup.LayerMappings(1).Entries(1).DrawingLayer = "Copper"

You can see that the first layer is mapped to "Copper" in the Project.

To access Process Definition Layer Setup Layer Mappings use the following code:

' Code Module


Sub Main
Dim layProcDef As LayoutProcessDefinition
Dim laySetup As LayerSetup
Dim layMap As LayerMapping
Dim layMap2 As LayerMapping
Dim index As Integer

Set layProcDef = Project.ProcessDefinitions(1)


Set laySetup = layProcDef.LayerSetup
Debug.Print "Process Definition Name = " & layProcDef.Name
Debug.Print "Layer Mappings Count = " & laySetup.LayerMappings.Count
Debug.Print ""

index = 1
For Each layMap In laySetup.LayerMappings

Debug.Print "Layer Mapping[" & index & "] = "


Debug.Print "Mapping Name = " & layMap.Name
PrintLayMapEntries layMap.Entries

If laySetup.LayerMappings.Exists(layMap.Name) Then
Debug.Print "Layer Mapping " & layMap.Name & " Exists in lookup by name"
Else
Debug.Print "Layer Mapping " & layMap.Name & " Does Not Exist in lookup by name"
End If

Set layMap2 = laySetup.LayerMappings(layMap.Name)


If layMap2 Is Nothing Then
Debug.Print "Layer Mapping " & layMap.Name & " Lookup by name failed"
Else
Debug.Print "Layer Mapping " & layMap.Name & " Lookup by name succeeded"
End If

Debug.Print ""
index = index + 1
Next layMap

1510 NI AWR Design Environment


Layout

End Sub

Sub PrintLayMapEntries(ByRef entries As LayerMapEntries)


Dim entry As LayerMapEntry

For Each entry In entries


Debug.Print entry.ModelLayer & " -> " & entry.DrawingLayer
Next entry

End Sub

To access Process Definition Layer Setup File Export Mappings use the following code:

' Code Module


Sub Main

Dim layProcDef As LayoutProcessDefinition


Dim laySetup As LayerSetup
Dim layMap As EMLayerMapping
Dim layMap2 As EMLayerMapping
Dim index As Integer

Set layProcDef = Project.ProcessDefinitions(1)


Set laySetup = layProcDef.LayerSetup
Debug.Print "Process Definition Name = " & layProcDef.Name
Debug.Print "Layer Mappings Count = " & laySetup.EMLayerMappings.Count
Debug.Print ""

index = 1
For Each layMap In laySetup.EMLayerMappings

Debug.Print "Layer Mapping[" & index & "] = "


Debug.Print "Mapping Name = " & layMap.Name
PrintLayMapEntries layMap.Entries

If laySetup.EMLayerMappings.Exists(layMap.Name) Then
Debug.Print "Layer Mapping " & layMap.Name & " Exists in lookup by name"
Else
Debug.Print "Layer Mapping " & layMap.Name & " Does Not Exist in lookup by name"
End If

Set layMap2 = laySetup.EMLayerMappings(layMap.Name)


If layMap2 Is Nothing Then
Debug.Print "Layer Mapping " & layMap.Name & " Lookup by name failed"
Else
Debug.Print "Layer Mapping " & layMap.Name & " Lookup by name succeeded"
End If

Debug.Print ""
index = index + 1
Next layMap

End Sub

Sub PrintLayMapEntries(ByRef entries As EMLayerMapEntries)

API Scripting Guide 1511


Layout

Dim entry As EMLayerMapEntry

For Each entry In entries


Debug.Print entry.DrawingLayer & " -> " & entry.EMLayer
Debug.Print "Is Via = " & entry.IsVia
Debug.Print "Material = " & entry.Material
Next entry

End Sub

To add Process Definition Layer Setup File Export Mappings use the following code:

' Code Module


Sub Main
Dim layProcDef As LayoutProcessDefinition
Dim laySetup As LayerSetup
Dim layMap As LayerExportMapping
Dim layMap2 As LayerExportMapping
Dim index As Integer

Set layProcDef = Project.ProcessDefinitions(1)


Set laySetup = layProcDef.LayerSetup
Debug.Print "Process Definition Name = " & layProcDef.Name
Debug.Print " ***** Before Add LayerExport Mapping *****"
PrintExportMappings(laySetup)

Debug.Print ""
Debug.Print ""

laySetup.LayerExportMappings.Add("MyMapping", mwLEF_GDSII_Hierarchical)
Debug.Print " ***** After Add LayerExport Mapping *****"
PrintExportMappings(laySetup)

End Sub

Sub PrintExportMappings(ByRef laySetup As LayerSetup)


Dim layMap As LayerExportMapping
Dim layMap2 As LayerExportMapping
Dim index As Integer

Debug.Print "Layer Mappings Count = " & laySetup.LayerExportMappings.Count


Debug.Print ""

index = 1
For Each layMap In laySetup.LayerExportMappings

Debug.Print "Layer Mapping[" & index & "] = "


Debug.Print "Mapping Name = " & layMap.Name
PrintLayMapEntries layMap.Entries

If laySetup.LayerExportMappings.Exists(layMap.Name) Then
Debug.Print "Layer Mapping " & layMap.Name & " Exists in lookup by name"
Else
Debug.Print "Layer Mapping " & layMap.Name & " Does Not Exist in lookup by name"
End If

1512 NI AWR Design Environment


Layout

Set layMap2 = laySetup.LayerExportMappings(layMap.Name)


If layMap2 Is Nothing Then
Debug.Print "Layer Mapping " & layMap.Name & " Lookup by name failed"
Else
Debug.Print "Layer Mapping " & layMap.Name & " Lookup by name succeeded"
End If

Debug.Print ""
index = index + 1
Next layMap
End Sub

When Exporting DXF hierarchical the main problem is that the exportMap parameter (the 2nd parameter) to the
Layout.Export() command is the name of a LayerExportMapping object, which we can get from
Project.ProcessDefinitions().LayerSetup.LayerExportMappings. Heres some of the info you can get from there:

Dim layerExportMaps As LayerExportMappings


Set layerExportMaps = Project.ProcessDefinitions(1).LayerSetup.LayerExportMappings

Debug.Print layerExportMaps.Count
Debug.Print layerExportMaps.Item(1).Name
Debug.Print layerExportMaps.Item(1).Type = mwLEF_GDSII_Hierarchical

We can search the LayerExportMappings for a map of type mwLEF_DXF, and then use the .Name of that mapping
when calling Layout.Export():

Project.Schematics(1).Layout.Export("layoutfile.gds", layerExportMaps(1).Name, True)

To access Process Definition Layer Setup EM Layer Mappings use the following code:

Dim layProcDef As LayoutProcessDefinition


Dim laySetup As LayerSetup
Dim layMap As EMLayerMapping
Dim layMap2 As EMLayerMapping
Dim index As Integer

Set layProcDef = Project.ProcessDefinitions(1)


Set laySetup = layProcDef.LayerSetup
Debug.Print "Process Definition Name = " & layProcDef.Name
Debug.Print "Layer Mappings Count = " & laySetup.EMLayerMappings.Count
Debug.Print ""

index = 1
For Each layMap In laySetup.EMLayerMappings

Debug.Print "Layer Mapping[" & index & "] = "


Debug.Print "Mapping Name = " & layMap.Name
PrintLayMapEntries layMap.Entries

If laySetup.EMLayerMappings.Exists(layMap.Name) Then
Debug.Print "Layer Mapping " & layMap.Name & " Exists in lookup by name"

API Scripting Guide 1513


Layout

Else
Debug.Print "Layer Mapping " & layMap.Name & " Does Not Exist in lookup by name"
End If

Set layMap2 = laySetup.EMLayerMappings(layMap.Name)


If layMap2 Is Nothing Then
Debug.Print "Layer Mapping " & layMap.Name & " Lookup by name failed"
Else
Debug.Print "Layer Mapping " & layMap.Name & " Lookup by name succeeded"
End If

Debug.Print ""
index = index + 1
Next layMap

End Sub

To copy Process Definition Layer Setup EM Layer Mappings use the following code:

Dim layProcDef As LayoutProcessDefinition


Dim laySetup As LayerSetup

Set layProcDef = Project.ProcessDefinitions(1)


Set laySetup = layProcDef.LayerSetup
Debug.Print "Process Definition Name = " & layProcDef.Name

laySetup.EMLayerMappings.Copy("Default", "MyMapping")

Sub PrintLayMapEntries (ByRef entries As EMLayerMapEntries) shown in the previous code.

The following is another example of accessing Process Definition Layer Setup Drill Tools:

Dim layProcDef As LayoutProcessDefinition


Dim laySetup As LayerSetup
Dim tool As DrillTool
Dim tool2 As DrillTool
Dim index As Integer

Set layProcDef = Project.ProcessDefinitions(1)


Set laySetup = layProcDef.LayerSetup
Debug.Print "Process Definition Name = " & layProcDef.Name
Debug.Print "Drill Tool Count = " & laySetup.DrillTools.Count
Debug.Print ""

index = 1
For Each tool In laySetup.DrillTools
Debug.Print "DrillTool[" & index & "] = "
Debug.Print "Name = " & tool.Name
Debug.Print "Number = " & tool.Number
Debug.Print "Radius = " & tool.Radius
Debug.Print ""
index = index + 1

1514 NI AWR Design Environment


Layout

Next tool
End Sub

Layout Options Collection

The NI AWR SDE exposes the Options collection for the Layout Object. The Options collection provides access to a
particular Layout. To apply the Options collection, use the following script:

Sub Main
Dim lay As Layout
Dim opt As Option
Set lay = Project.Schematics(2).Layout
For Each opt In lay.Options
Debug.Print "Name = ";opt.Name;vbTab;"Description = ";opt.Description
Debug.Print "DataType = ";opt.DataType;vbTab;"DefaultValue = ";
opt.DefaultValue;vbTab;"Value = ";opt.Value
Debug.Print
Next opt
End Sub

This script generates the following output:

Name = LayoutGridSpacing Description = Returns/sets the grid spacing for layouts in the projec
DataType = 3 DefaultValue = 25400 Value = 25400
Name = LayoutDatabaseUnits Description = Returns/sets the database units for layouts in the
project.
DataType = 3 DefaultValue = 2540 Value = 2540
Name = LayoutAngleSnapDiv Description = Returns/sets the number of snap divisions per quadrant
layouts in the project.
DataType = 3 DefaultValue = 2 Value = 2
Name = ExportUnionShapes Description = Returns/sets if Layout Shapes should be united on
export.
DataType = 11 DefaultValue = True Value = True

You can configure settings for a particular Layout. To change the default options, set the Use Project options property
to "False".

The following script demonstrates how to set Options/Layout Options/Export/LPF/Artwork Instance export options:

' Code Module


Sub Main
Project.Options("InstanceExportOptions").Value = mwIEO_NoChangesToCellNames
Project.Options("InstanceExportOptions").Value = mwIEO_AppendNumberToDuplicates
Project.Options("InstanceExportOptions").Value = mwIEO_AppendLibNameToDuplicates
Project.Options("InstanceExportOptions").Value = mwIEO_AppendLibNameToAll
Debug.Print Project.Options("InstanceExportOptions").Value
End Sub

The following API Project level options are the same as the options on the Layout Options dialog box iNet tab. (Choose
Options > Layout Options to view this dialog box.)

LayInetMinViaSize
LayInetViaSizeOpts

API Scripting Guide 1515


Layout

LayInetPinRouteOpts
LayInetRouteOpts
LayInetViaInsideRoute
LayInetOverrideForShortSeg
LayInetDefRouteBendStyle
LayInetDefRouteBendAmount
LayRouteViaMode

To set these options, use the following script:

' Code Module


Sub Main
Project.Options("LayInetViaSizeOpts").Value = mwVSO_ViaCoversPinRouteIntersection
Project.Options("LayInetViaSizeOpts").Value = mwVSO_ViaConversEntirePin
Project.Options("LayInetViaSizeOpts").Value = mwVSO_ViaMinimalSize
End Sub

This script changes the Automatic Via Sizing options and corresponds to the radio button options in the Layout Options
dialog box. The options for the iNet tab are the following:

LayInetMinViaSize = True
LayInetViaSizeOpts = 2
LayInetDefRouteBendStyle = 0
LayInetDefRouteBendAmount = 1

Layout mode Options

The NI AWR SDE exposes the Layout Mode Options collection. The Mode Options collection provides access to a
particular Layout Mode Property. For example, to access to the layout mode property for drawing origin markers use
the following script:

' Code Module


Sub Main
Dim opts As Options
Dim activeName As String

Debug.Clear
Debug.Print "Active Name = " & MWOffice.LayoutModes.GetActive().Name
Set opts = MWOffice.LayoutModes.GetActive().Options
Debug.Print "Draw Origin Markers = " & opts("DrawOriginMarkers").Value

opts("DrawOriginMarkers").Value = Not opts("DrawOriginMarkers").Value

Debug.Print "Draw Origin Markers = " & opts("DrawOriginMarkers").Value

End Sub

This script toggles the option on and off each time it is run

Cell Libraries Collection

The NI AWR SDE exposes the CellLibrary collection to enable work with cell libraries. You can create or import Cell
Libraries in GDSII or DXF formats. You can create new cells and draw different Shapes on different Drawing Layers.
The following script demonstrates this ability:

1516 NI AWR Design Environment


Layout

'Code Module
Sub Main
Dim cel As Cell
Dim cels As Cells
Dim sh As Shape
Dim cl As CellLibrary
Dim vr As Vertex
Dim arpath(9) As Double
Debug.Clear
arpath(0) = 0.000006
arpath(1) = 0.000034
arpath(2) = 0.000015
arpath(3) = 0.000034
arpath(4) = 0.000015
arpath(5) = 0.000027
arpath(6) = 0.000022
arpath(7) = 0.000027
arpath(8) = 0.000006
arpath(9) = 0.000034
For Each cel In Project.CellLibraries.Item(1).Cells
Debug.Print cel.Name;cel.Shapes.Item(1).Attributes.Count
Next cel
Set cl = Project.CellLibraries.Add("New Library",mwCLT_GDSII)
For Each cl In Project.CellLibraries
Debug.Print cl.Name
Next cl
Set cl = Project.CellLibraries(1)
Debug.Print cl.Name
Set cel = cl.Cells.Add("New Cell")
Debug.Print cel.Name
Set sh = cel.Shapes.AddRectangle(0, 0, 10e-6, 10e-6, "Cap Bottom")
Set sh = cel.Shapes.AddPolygon(arpath(),"Cap Bottom")
Set sh = cel.Shapes.AddPath(arpath(),10e-6,"Cap Bottom")
Set sh = cel.Shapes.AddEllipse(2*10e-5,10e-5,0.5*10e-5,0.8*10e-5,"Cap Bottom")
Set sh = cel.Shapes.AddPort(0.000006,0.000015,0.000015,0.000015,1)
Set sh = cel.Shapes.AddText(0.000018,0.00001,10e-6,"New Cell","Cap Bottom")
Set sh = cel.Shapes.AddDrillHole(0.5*10e-6,0.5*10e-6,"Drill 1")
Set sh = cel.Shapes.AddArc(0, 0, 100e-6, 180.0, 90.0, "Source Drain")
Debug.Print "Shapes.Count = ";cel.Shapes.Count
For Each sh In cel.Shapes
Debug.Print sh.Type;vbTab;sh.DrawingLayer.Name
Next sh
End Sub

This script creates a "New Library" subnode under the Cell Libraries node and a Cell "New Cell" subnode under the "New
Library" subnode. The Cell "New Cell" contains all permitted types of Shapes in the NI AWR SDE.

You can create a cell in one line of code as shown in the following example:

Project.CellLibraries.Add("TempLibrary",mwCLT_GDSII).Cells.Add("TestCell").Shaps
.AddRectangle(0, 0, 10e-6, 10e-6, "Cap Bottom")

You can create a cell from a hierarchical layout, which includes just the selected objects as shown in the following
example:

API Scripting Guide 1517


Layout

Sub Main
Dim lay As Layout
Dim ret As Variant
Dim dl As DrawingLayer
Dim objDraw As DrawingObject

Debug.Clear
Set lay = Project.Schematics("SCH1").Layout

Debug.Print "Layout Name = " & lay.Name

' Create cell and flatten objects, select only one of the two.
lay.SelectedObjects.RemoveAll
lay.DrawingObjects(1).Selected = True
lay.CreateCell("New_Gdsii_Lib", "NewCell", mwOIT_SelectedObjects, True)

Dim libCell As Cell


Set libCell = Project.CellLibraries("New_Gdsii_Lib").Cells("NewCell")
Dim libCellEdit As CellEditor
Set libCellEdit = libCell.EditCell

PrintDrawingObjects libCellEdit, "After Invoke Flatten Command"

End Sub

Sub PrintDrawingObjects(ByRef lay As CellEditor, title As String)


Dim objDraw As DrawingObject

Debug.Print title
Debug.Print "DrawingObjects Count = " & lay.DrawingObjects.Count
For Each objDraw In lay.DrawingObjects
PrintDrawingObject objDraw
Debug.Print ""
Next objDraw
Debug.Print ""
End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " & drawingObj.InfoText
Debug.Print "Selected = " & drawingObj.Selected
Debug.Print "Flipped = " & drawingObj.Flipped
Debug.Print "Rotation = " & drawingObj.RotationAngle
Debug.Print "Frozen = " & drawingObj.Frozen
Debug.Print "Base Pos = { x = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePosition
Debug.Print "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)

End Sub

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter

1518 NI AWR Design Environment


Layout

Debug.Print "Parameters:"
For Each param In params
Debug.Print param.Name & " = " & param.ValueAsString
Next param

End Sub

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Debug.Print "Attributes:"
For Each attr In attrs
Debug.Print attr.Name & " = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Debug.Print "Boundary:"
Debug.Print "Left = " & bound.Left
Debug.Print "Right = " & bound.Right
Debug.Print "Top = " & bound.Top
Debug.Print "Bottom = " & bound.Bottom
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Debug.Print "Vertices:"
For Each vert In verts
Debug.Print "{ x= " & vert.x & ", y= " & vert.y & " }"
Next vert
End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Debug.Print "Edit Handles:"
For Each eh In ehs
Debug.Print "{ x= " & eh.Position.x & ", y= " & eh.Position.y & " }"
Next eh
End Sub

You can create a cell from a hierarchical layout, which includes all objects if you use the following:

lay.CreateCell("New_Gdsii_Lib", "NewCell", mwOIT_AllObjects, True)

To iterate through the collection of Libraries and Cells and access cell information, use the following code:

Dim c As Cell
Dim l As CellLibrary
Dim info As CellInfo
For Each l In Project.CellLibraries
For Each c In l.Cells
Debug.Print c.Name
Set info = c.Info
Debug.Print "Info Face Count = " & info.FaceCount

API Scripting Guide 1519


Layout

Debug.Print "Info Pin Count = " & info.PinCount


Debug.Print "Info Refer Count = " & info.ReferenceCount
Debug.Print "Info Shape Count = " & info.ShapeCount
Next c
Next l

With access to the Cell you get access to the Shapes collection. You can also access the Shapes.Vertices collections and
you can add Vertex to the collection.

Set newVertex = cel.Shapes(1).Vertices.Add(0.00056,0.00046)


For Each ver In cel.Shapes.Item(1).Vertices
Debug.Print ver.x;VbTab;ver.y
Next ver

Note that the Layout Cell you created returns "True" for the Modified property.

You should check this property before trying to Add Shapes to the Cell. If this property returns to "False" you cannot
Add Shapes to the Cell.

If Add Shape to the Cell fails, check the x and y properties for reasonable values. This may help you determine the cause
of the failure.

A CellInstances collection of the Cell object allows you to access the Cell Instances (sub cells) of a cell. From the Cell
Instance object you can determine the master Cell and master Library names, which allow you to then get the master of
that Cell and traverse it for Cell Instances. The collection also allows you to add a Cell Instance (create a new Instance
in the cell) to the Cell Instances collection.

Naming Conflicts for Artwork Cells and Libraries

When you add a new artwork cell or library an error message displays if you try to name it with an existing cell or library
name.

Accessing Get/Set Shape and Cell LineType Settings

You get and set Shape and Cell LineType settings through the DrawingObject.Attributes collection because Drawing
objects can be a range of objects including artwork cells, subcircuit Layouts, or dumb Shapes.

You can index the LineType attribute by name, and you can use Attributes.Exists("LineType") to verify whether an
object has the attribute before trying to get or set it.

To display all attributes for all of the drawing objects in a Layout, use the following code:

' Get and output the attributes for all the drawing objects in the layout of each Schematic.
Sub Main
Dim schem As Schematic
Dim lay As Layout
Dim objDraw As DrawingObject
Dim attr As Attribute
Dim index As Integer
Dim attrIndex As Integer
Debug.Clear
Set schem = Project.Schematics("Schematic 1")
Set lay = schem.Layout
index = 1

1520 NI AWR Design Environment


Layout

Debug.Print "Schematic = " & schem.Name


For Each objDraw In lay.DrawingObjects
Debug.Print "Drawing Object[" & index & "], Attribute count = " & objDraw.Attributes.Count
attrIndex = 1
For Each attr In objDraw.Attributes
Debug.Print "Attr[" & attrIndex & "] = " & attr.Name & " = " & attr.ValueAsString
attrIndex = attrIndex + 1
Next attr
index = index + 1
Next objDraw
End Sub
The output from running the script:
Schematic = Schematic 1
Drawing Object[1], Attribute count = 3
Attr[1] = LineType = 1
Attr[2] = UsesProcessLayers = -1
Attr[3] = LayerMapping = 0

The following script tests for the existence of and sets the line type attribute on a Drawing object, and then checks the
new value:

' Demonstrates setting the line type attribute for drawing objects in a layout.
Sub Main
Dim schem As Schematic
Dim lay As Layout
Dim objDraw As DrawingObject
Debug.Clear
Set schem = Project.Schematics("Schematic 1")
Debug.Print "Schematic = " & schem.Name
Set lay = schem.Layout
For Each objDraw In lay.DrawingObjects
If (objDraw.Attributes.Exists("LineType")) Then
Debug.Print "Old Line Type = " & objDraw.Attributes("LineType").ValueAsString
' Set the line type to new value here.
objDraw.Attributes("LineType").Value = 1
Debug.Print "New Line Type = " & objDraw.Attributes("LineType").ValueAsString
End If
Next objDraw
End Sub

This script generates the following output:

Schematic = Schematic 1
Old Line Type = 0
New Line Type = 1

Accessing the Model Layer when adding Cell Ports

A special AddFaceEx method for the Shapes collection allows you to specify the Layer name when adding Faces through
the collection.

The AddFaceEx method includes an optional argument for the Model layer. With this method you can add a cell port as
in the following code:

API Scripting Guide 1521


Layout

' Code Module


Sub Main
Dim libCell As Cell

Set libCell = Project.CellLibraries("Lib").Cells("Cell")


libCell.Shapes.AddFaceEx(0, 0, 0, 100e-6, 1, 0, "4_0")

End Sub

Accessing model layer to drawing layer mapping when adding cell Path

API allows layer name to be specified by model layer, drawing layer or model layer to drawing layer mapping strings.
This can be applied for adding arc, pin, ellipse, path, polygon, rectangle and text objects. With drawing layer mapping
method you can add a path as in the following code:

Dim libCell As Cell


Dim cellEd As CellEditor
Dim objDraw As DrawingObject
Dim pts(7) As Double

Set libCell = Project.CellLibraries("Cell_Lib").Cells("Cell")

pts(0) = 0
pts(1) = 0

pts(2) = 100e-6
pts(3) = 0

pts(4) = 100e-6
pts(5) = 100e-6

pts(6) = 200e-6
pts(7) = 100e-6

libCell.Shapes.AddPath(pts, 20e-6, "5_0->Source Drain", mwPET_ExtendedHalfWidth, mwPMT_Square)

How to change Model layer for Cell

The following code shows how how to change Model layer for Cell:

Option Explicit
Sub Main
Debug.Clear
Dim c As Cell, ce As CellEditor
Dim i As Long, layCount As Long, dwgLays As LayerMapEntries

Set dwgLays = Project.ProcessDefinitions(1).LayerSetup.LayerMappings(1).Entries


layCount = dwgLays.Count

Debug.Print layCount
For i = 1 To layCount

1522 NI AWR Design Environment


Layout

Debug.Print i-1 & vbTab & dwgLays(i).DrawingLayer


Next i

Debug.Print
Set c = Project.CellLibraries(1).Cells(1)
Set ce = c.EditCell

Dim d As DrawingObject
Set d = ce.DrawingObjects(1)
d.Attributes("LayerIndex") = 25
Debug.Print "new layer = " & d.Shapes(1).DrawingLayer.Name
ce.SaveCell
ce.Windows(1).Close

End Sub

Working with the Cell Editor

To use the CellEditor to Add a Drawing object to a Selection, use the following script:

' Code Module


Sub Main
Dim libCell As Cell
Dim editor As CellEditor
Dim objDraw As DrawingObject
Dim index As Integer
Debug.Clear
Set libCell = Project.CellLibraries("TDMSDEMOLIB.DB").Cells("CCADC")
Set editor = libCell.EditCell
Debug.Print "Cell = " & libCell.Name
' Try adding all the drawing objects that are currently not selected to the selection.
index = 1
For Each objDraw In editor.DrawingObjects
If (Not objDraw.Selected) Then
editor.SelectedObjects.Add(objDraw)
Debug.Print "Added Object " & index
index = index + 1
End If
Next objDraw
End Sub

To use the Cell Editor to Copy to the Clipboard, use the following script:

' Code Module


Sub Main
Dim libCell As Cell
Dim editor As CellEditor
Debug.Clear
Set libCell = Project.CellLibraries("TDMSDEMOLIB.DB").Cells("CCADC")
Set editor = libCell.EditCell
Debug.Print "Cell = " & libCell.Name
Debug.Print "Try Copy to Clipboard...";
editor.CopyToClipboard

API Scripting Guide 1523


Layout

Debug.Print "Done"
End Sub

To use the Cell Editor to Create a Rectangle, use the following script:

' Code Module


Sub Main
Dim libCell As Cell
Dim editor As CellEditor
Debug.Clear
Set libCell = Project.CellLibraries("TDMSDEMOLIB.DB").Cells("CCADC")
Set editor = libCell.EditCell
Debug.Print "Cell = " & libCell.Name
' Create a new rectangle and refresh the view afterward so we can see it.
editor.DrawingObjects.AddRectangle(0, 0, 200e-6, 200e-6, "Source Drain")
editor.Refresh
End Sub

With the Editor object you can open an Artwork Cell for editing and then perform editing commands similar to those in
a Schematic Layout. The following method saves Cell edits and prevents a Cell edit query from displaying when saving
the project. The code should run without dialog boxes:

' Code Module


Sub Main
Dim cellLib As CellLibrary
Dim libCell As Cell
Dim editCell As CellEditor
Set cellLib = Project.CellLibraries("TDMSDEMOLIB.DB")
Set libCell = cellLib.Cells("AND2")
Set editCell = libCell.EditCell
editCell.DrawingObjects.AddRectangle(0, 0, 100e-6, 100e-6)
editCell.SaveCell
Project.Save
End Sub

To use the Cell Editor for Design Rule Checking, use the following script:

' Code Module


Sub Main
Dim libCell As Cell
Dim editor As CellEditor
Dim checker As DesignRuleChecker
Dim ruleSet As DesignRules
Debug.Clear
Set libCell = Project.CellLibraries("TDMSDEMOLIB.DB").Cells("CCADC")
Set editor = libCell.EditCell
Debug.Print "Cell = " & libCell.Name
Set checker = editor.DesignRuleChecker
Set ruleSet = checker.CreateRuleSet
ruleSet.ImportDefaultRules
checker.RunCheck(ruleSet)
Debug.Print "Errors = " & checker.Errors.Count
End Sub

1524 NI AWR Design Environment


Layout

To use the Cell Editor to Export, use the following script:

Sub Main
Dim libCell As Cell
Dim editor As CellEditor
Debug.Clear
Set libCell = Project.CellLibraries("TDMSDEMOLIB.DB").Cells("CCADC")
Set editor = libCell.EditCell
Debug.Print "Cell = " & libCell.Name
Debug.Print "Exporting editor content...";
editor.Export("c:\my_cell.gds", 1)
Debug.Print "Done"
End Sub

To use the Cell Editor to create a new Window, use the following script:

' Code Module


Sub Main
Dim libCell As Cell
Dim editor As CellEditor
Debug.Clear
Set libCell = Project.CellLibraries("TDMSDEMOLIB.DB").Cells("CCADC")
Set editor = libCell.EditCell
Debug.Print "Cell = " & libCell.Name
editor.NewWindow
End Sub

To use the Cell Editor to Refresh, use the following script:

' Code Module


Sub Main
Dim libCell As Cell
Dim editor As CellEditor
Debug.Clear
Set libCell = Project.CellLibraries("TDMSDEMOLIB.DB").Cells("CCADC")
Set editor = libCell.EditCell
Debug.Print "Cell = " & libCell.Name
' Call refresh a number of times so we can see it.
For i = 0 To 10
' turns out that because of buffering this is not visible
editor.Refresh
Debug.Print "Refresh " & i
Next i
End Sub

To use the Cell Editor to Print Out, use the following script:

' Code Module


Sub Main
Dim libCell As Cell
Dim editor As CellEditor
Debug.Clear
Set libCell = Project.CellLibraries("TDMSDEMOLIB.DB").Cells("CCADC")

API Scripting Guide 1525


Layout

Set editor = libCell.EditCell


Debug.Print "Cell = " & libCell.Name
Debug.Print "Printing cell out...";
editor.PrintOut
Debug.Print "...Done"
End Sub

To use the Cell Editor to Update, use the following script:

' Code Module


Sub Main
Dim libCell As Cell
Dim editor As CellEditor
Debug.Clear
Set libCell = Project.CellLibraries("TDMSDEMOLIB.DB").Cells("CCADC")
Set editor = libCell.EditCell
Debug.Print "Cell = " & libCell.Name
' Again because of buffering this is not too visible.
For i = 0 To 10
editor.Update
Debug.Print "Update " & i
Next i
End Sub

To use the Cell Editor to Create a new Cell by editing a Cell, use the following script:

' Code Module


Sub Main
Dim libCell, newCell As Cell
Dim editor, newEditor As CellEditor
Debug.Clear
Set libCell = Project.CellLibraries("TDMSDEMOLIB.DB").Cells("CCADC")
Set editor = libCell.EditCell
Debug.Print "Cell = " & libCell.Name
' Test the create cell
Set newCell = editor.CreateCell("New_Gdsii_Lib", "New_Cell")
Set newEditor = newCell.EditCell
Debug.Print newEditor.Name
End Sub

To use the Cell Editor to Edit a Cell, use the following script:

' Code Module


Sub Main
Dim libCell As Cell
Dim editor As CellEditor
Debug.Clear
Set libCell = Project.CellLibraries("TDMSDEMOLIB.DB").Cells("CCADC")
Set editor = libCell.EditCell
Debug.Print "Drawing Objects = " & editor.DrawingObjects.Count
libCell.Windows(1).Close
End Sub

1526 NI AWR Design Environment


Layout

To use the Cell Editor to Save Cell edits and prevent a query regarding the edits from displaying when saving the Project,
use the following script:

' Code Module


Sub Main
Dim cellLib As CellLibrary
Dim libCell As Cell
Dim editCell As CellEditor
Set cellLib = Project.CellLibraries("TDMSDEMOLIB.DB")
Set libCell = cellLib.Cells("AND2")
Set editCell = libCell.EditCell
editCell.DrawingObjects.AddRectangle(0, 0, 100e-6, 100e-6)
editCell.SaveCell
Project.Save
End Sub

The following script performs filtering on the shape type (path), copy and paste into a DXF design using CellEditor:

' Code Module


Sub Main
Dim lay As Layout
Dim objDraw As DrawingObject
Dim s As String
Dim libCell As Cell
Dim cellEd As CellEditor
Dim sh As Shape

Debug.Clear

Set lay = Project.Schematics(1).Layout

For Each objDraw In lay.DrawingObjects


'if object is not a path, remove from selection
s = objDraw.InfoText
If InStr(s,"Path") ne 0 Then
lay.SelectedObjects.Add(objDraw)
End If
Next objDraw

lay.InvokeCommand("EditCopy")

'copy selected paths to the dxf cell


Set libCell = Project.CellLibraries("Test_dxf").Cells("copy_path")
Set cellEd = libCell.EditCell

cellEd.Paste(0,0)
cellEd.SaveCell
libCell.Windows(1).Close

Set libCell = Project.CellLibraries("Test_dxf").Cells("copy_path")


Set cellEd = libCell.EditCell

For Each objDraw In cellEd.DrawingObjects


Debug.Print objDraw.InfoText

API Scripting Guide 1527


Layout

For Each sh In objDraw.Shapes


Debug.Print "Shape Boundary: "
Debug.Print vbTab & "Top = " & sh.Boundary.Top/25.4e-6
Debug.Print vbTab & "Bottom = " & sh.Boundary.Bottom/25.4e-6
Debug.Print vbTab & "Left = " & sh.Boundary.Left/25.4e-6
Debug.Print vbTab & "Right = " & sh.Boundary.Right/25.4e-6
Next sh
Next objDraw
End Sub

To Loop through drawing cell objects during EditCell use the following script:

' Code Module


Option Explicit
Sub Main
Dim objDraw As DrawingObject
Dim libCell As Cell
Dim ed As CellEditor

Debug.Clear

If Not Project.CellLibraries.Exists("TEST_LIB") = True Then


Project.CellLibraries.Add("TEST_LIB",mwCLT_GDSII)
Project.CellLibraries("TEST_LIB").Cells.Add("TEST")
End If

Set libCell = Project.CellLibraries("TEST_LIB").Cells("TEST")


Set ed = libCell.EditCell

ed.DrawingObjects.AddText(0, 0, 30*1e-6, "TEST", 0,False,"",False,False,True,"")


ed.DrawingObjects.AddText(40*1e-6, 40*1e-6, 30*1e-6, "QUIZ", 0,False,"",False,False,True,"")

For Each objDraw In ed.DrawingObjects


Debug.Print objDraw.InfoText
Next objDraw

ed.SaveCell

Debug.Print ed.DrawingObjects(1).InfoText

End Sub

To use the Cell Editor to Count, use the following script:

' Code Module


Sub Main
Dim cellLib As CellLibrary
Dim libCell As Cell
Dim cellEdit As CellEditor
Debug.Clear
For Each cellLib In Project.CellLibraries
Debug.Print "Library = " & cellLib.Name
For Each libCell In cellLib.Cells

1528 NI AWR Design Environment


Layout

Debug.Print "Cell = " & libCell.Name


Debug.Print "Editor Count = " & libCell.Editors.Count
For Each cellEdit In libCell.Editors
Debug.Print "Drawing Objects = " & cellEdit.DrawingObjects.Count
Next cellEdit
Next libCell
Next cellLib
End Sub

To use the Cell Editor to access Editor properties, use the following script:

' Code Module


Sub Main
Dim cellLib As CellLibrary
Dim libCell As Cell
Dim cellEdit As CellEditor
Debug.Clear
For Each cellLib In Project.CellLibraries
Debug.Print "Library = " & cellLib.Name
For Each libCell In cellLib.Cells
Debug.Print "Cell = " & libCell.Name
Debug.Print "Editor Count = " & libCell.Editors.Count
For Each cellEdit In libCell.Editors
Debug.Print "Drawing Objects = " & cellEdit.DrawingObjects.Count
Next cellEdit
Next libCell
Next cellLib
End Sub

To use the Cell Editor to access Base, use the following script:

' Code Module


Sub Main
Dim libCell As Cell
Dim editor As CellEditor
Debug.Clear
Set libCell = Project.CellLibraries("TDMSDEMOLIB.DB").Cells("CCADC")
Set editor = libCell.EditCell
Debug.Print "Cell = " & libCell.Name
End Sub

You can use Invoke command to draw a cell port object in a layout cell editor window, as shown in the following example:

Sub Main
Dim lay As Layout
Dim ret As Variant
Dim objDraw As DrawingObject
Dim libCell As Cell
Dim ed As CellEditor

Set libCell = Project.CellLibraries("Lib").Cells("Cell")


Set ed = libCell.EditCell
ed.InvokeCommand("InsertCellPort", Array(0, 0, 0, 100e-6), ret)
Debug.Print ret

API Scripting Guide 1529


Layout

ed.SaveCell

' Print the results .


Debug.Print libCell.Name
Debug.Print "DrawingObjects Count = " & ed.DrawingObjects.Count
For Each objDraw In ed.DrawingObjects
PrintDrawingObject objDraw
Debug.Print ""
Next objDraw

End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " & drawingObj.InfoText
Debug.Print "Selected = " & drawingObj.Selected
Debug.Print "Flipped = " & drawingObj.Flipped
Debug.Print "Rotation = " & drawingObj.RotationAngle
Debug.Print "Frozen = " & drawingObj.Frozen
Debug.Print "Base Pos = { x = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePosition.
Debug.Print "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)

End Sub

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Debug.Print "Parameters:"
For Each param In params
Debug.Print param.Name & " = " & param.ValueAsString
Next param

End Sub

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Debug.Print "Attributes:"
For Each attr In attrs
Debug.Print attr.Name & " = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Debug.Print "Boundary:"
Debug.Print "Left = " & bound.Left
Debug.Print "Right = " & bound.Right
Debug.Print "Top = " & bound.Top
Debug.Print "Bottom = " & bound.Bottom
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Debug.Print "Vertices:"

1530 NI AWR Design Environment


Layout

For Each vert In verts


Debug.Print "{ x= " & vert.x & ", y= " & vert.y & " }"
Next vert
End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Debug.Print "Edit Handles:"
For Each eh In ehs
Debug.Print "{ x= " & eh.Position.x & ", y= " & eh.Position.y & " }"
Next eh
End Sub

Cell Libraries Overview


Typically a Project has Cell Libraries, Cells, Instances, and Shapes. A Library contains Cells. A Cell can contain Instances
and Shapes. An Instance is a reference to another Cell. The Cell that an Instance references is called the master Cell for
that Instance, and it can be in the same Library as the Instance or in another Library.

Determining CellLibraries Content

To determine the contents of a Cell Library you need a script that searches through the Libraries, and for each Library
goes through the Cells, and for each Cell goes through the Instances and Shapes for that Cell. For Instances, you need
to print the name of the master Cell and the Library in which that master Cell resides. (An Instance points backward to
indicate what Cell to draw in the current Cell.) Instances allow you to re-use a Cell by placing several Instances of that
cell in another Cell. The first Cell becomes a building block that is re-used in the second Cell through Instances. The
following script uses indenting to show the structure. Cell Libraries are at the top; in them are a collection of Cells, and
inside the Cells are Instances and Shapes. The Instances refer back to other Cells in the same or different Library, so to
determine which Cell the Instance refers to you need to know both the master Cell and master Library name. This script
prints the master Cell name and the master Library name as the From Library:

' Code Module


Sub Main
Dim cellLib As CellLibrary
Dim libCell As Cell
Dim inst As CellInstance
Dim shp As Shape

Debug.Clear

' For each library


For Each cellLib In Project.CellLibraries
Debug.Print "Cell Library: " & cellLib.Name

' For Each cell in the library


For Each libCell In cellLib.Cells
Debug.Print " Cell: " & libCell.Name

' For Each Instance in the cell print the master cell name and library
Debug.Print " Instances: "
For Each inst In libCell.Instances
Debug.Print " Inst Master Cell: " & inst.MasterCell & ", From Library: " & inst.MasterLibr
Next inst

API Scripting Guide 1531


Layout

' For Each Shape in the cell print the drawing layer for that shape
Debug.Print " Shapes: "
For Each shp In libCell.Shapes
Debug.Print " Drawing Layer: " & shp.DrawingLayer.Name
Next shp

Debug.Print
Next libCell

Debug.Print
Next cellLib

End Sub

This script generates the following output:

Cell Library: Old


Cell: sub1
Instances:
Shapes:
Drawing Layer: NiCr
Drawing Layer: Copper

Cell: sub2
Instances:
Shapes:
Drawing Layer: NiCr
Drawing Layer: Copper

Cell: Top
Instances:
Inst Master Cell: sub2, From Library: Old
Inst Master Cell: sub1, From Library: Old
Shapes:
Drawing Layer: NiCr
Drawing Layer: Copper
Drawing Layer: NiCr
Drawing Layer: Copper

Cell Library: New


Cell: New_GDS_Cell
Instances:
Shapes:

Cell: Top
Instances:
Inst Master Cell: sub2, From Library: New
Inst Master Cell: sub1, From Library: New
Shapes:
Drawing Layer: NiCr
Drawing Layer: Copper
Drawing Layer: NiCr
Drawing Layer: Copper

Cell: sub2

1532 NI AWR Design Environment


Layout

Instances:
Shapes:
Drawing Layer: NiCr
Drawing Layer: Copper

Cell: sub1
Instances:
Shapes:
Drawing Layer: NiCr
Drawing Layer: Copper

Notice that sub1 and sub2 do not have any Instances, just Shapes. For the sub1 and sub2 Instances in the "Top" cell there
is both a master Cell name and Library printed.

Adding Cell Instance to the CellLibrary

The following code adds Cell Instancies to the source Cell Library:

' Code Module


Sub Main
Dim libCell As Cell
Dim cellEd As CellEditor
Dim objDraw As DrawingObject

Set libCell = Project.CellLibraries("New_Gdsii_Lib").Cells("New_GDS_Cell")

libCell.Instances.Add("TDMSDEMOLIB.DB", "AND2", 0, 0)
libCell.Instances.Add("TDMSDEMOLIB.DB", "BJT2CMOS", -100e-6, 0)
libCell.Instances.Add("TDMSDEMOLIB.DB", "CMOS2BJT", 100e-6, 0)

PrintCellInfo(libCell)
PrintCellInstanceInfo(libCell)

End Sub

Sub PrintCellInfo(ByRef libCell As Cell)


Dim info As CellInfo

' Print cell values.


Debug.Print "Name = " & libCell.Name

' Print Info values.


Set info = libCell.Info
Debug.Print "Info Face Count = " & info.FaceCount
Debug.Print "Info Pin Count = " & info.PinCount
Debug.Print "Info Refer Count = " & info.ReferenceCount
Debug.Print "Info Shape Count = " & info.ShapeCount
End Sub

Sub PrintCellInstanceInfo(ByRef libCell As Cell)


Dim cellInst As CellInstance

For Each cellInst In libCell.Instances

' Avoid numerous redundant placements

API Scripting Guide 1533


Layout

If InStr(cellInst.Name, "I1_I2") = 0 Then


PrintInstanceInfo(cellInst)
End If

Next cellInst
End Sub

Sub PrintInstanceInfo(ByRef cellInst As CellInstance)


Debug.Print "Instance Name = " & cellInst.Name
Debug.Print "Base Position = x = " & cellInst.BasePosition.x * 1e6 & ", y = " & cellInst.BasePo
Debug.Print "Boundary = left = " & cellInst.Boundary.Left * 1e6 & ", top = " & cellInst.Bou
Debug.Print "Flipped = " & cellInst.Flipped
Debug.Print "Master Cell = " & cellInst.MasterCell
Debug.Print "Master Library = " & cellInst.MasterLibrary
Debug.Print "Rotation Angle = " & cellInst.RotationAngle
Debug.Print ""
End Sub

Creating a Cell Library with hierarchy programmatically

The following code creates a library and cells and using the instances methods to add references to other cells within the
library. A library hierarchy is created with the library structure:

' Code Module


Sub Main
Dim cellLib As CellLibrary
Dim libCell As Cell
Dim cellEd As CellEditor
Dim objDraw As DrawingObject

Set cellLib = Project.CellLibraries.Add("MyCellLib", mwCLT_GDSII)


Set libCell = cellLib.Cells.Add("sub1")
libCell.Shapes.AddRectangle(0, 0, 200e-6, 100e-6, "Mesa")
libCell.Shapes.AddRectangle(10e-6,10e-6, 180e-6, 80e-6, "Gate")
Set libCell = cellLib.Cells.Add("sub2")
libCell.Instances.Add("MyCellLib", "sub1", 0, 0)

PrintCellInfo(libCell)
PrintCellInstanceInfo(libCell)

Debug.Print "*************"

Set libCell = cellLib.Cells.Add("top")


libCell.Instances.Add("MyCellLib", "sub2", 0, 0)

PrintCellInfo(libCell)
PrintCellInstanceInfo(libCell)
End Sub
Sub PrintCellInfo(ByRef libCell As Cell)
Dim info As CellInfo

' Print cell values.


Debug.Print "Name = " & libCell.Name

' Print Info values.

1534 NI AWR Design Environment


Layout

Set info = libCell.Info


Debug.Print "Info Face Count = " & info.FaceCount
Debug.Print "Info Pin Count = " & info.PinCount
Debug.Print "Info Refer Count = " & info.ReferenceCount
Debug.Print "Info Shape Count = " & info.ShapeCount
End Sub

Sub PrintCellInstanceInfo(ByRef libCell As Cell)


Dim cellInst As CellInstance

For Each cellInst In libCell.Instances

' Avoid numerous redundant placements


If InStr(cellInst.Name, "I1_I2") = 0 Then
PrintInstanceInfo(cellInst)
End If

Next cellInst
End Sub

Sub PrintInstanceInfo(ByRef cellInst As CellInstance)


Debug.Print "Instance Name = " & cellInst.Name
Debug.Print "Base Position = x = " & cellInst.BasePosition.x * 1e6 & ", y = " & cellInst.BasePo
Debug.Print "Boundary = left = " & cellInst.Boundary.Left * 1e6 & ", top = " & cellInst.Bou
Debug.Print "Flipped = " & cellInst.Flipped
Debug.Print "Master Cell = " & cellInst.MasterCell
Debug.Print "Master Library = " & cellInst.MasterLibrary
Debug.Print "Rotation Angle = " & cellInst.RotationAngle
Debug.Print ""
End Sub

Instance access in cell with instances placed from a different library.

This is typically the way many designs are created with one library as a reference and one as the actual design. The
following code prints the instance reference names and they should correctly reflect both the library name and cell name
since the cells are from a different library:

' Code Module


Sub Main
Dim libCell As Cell
Dim cellEd As CellEditor
Dim objDraw As DrawingObject

Set libCell = Project.CellLibraries("New_Gdsii_Lib").Cells("New_GDS_Cell")

PrintCellInfo(libCell)
PrintCellInstanceInfo(libCell)

End Sub

Sub PrintCellInfo(ByRef libCell As Cell)


Dim info As CellInfo

' Print cell values.


Debug.Print "Name = " & libCell.Name

API Scripting Guide 1535


Layout

' Print Info values.


Set info = libCell.Info
Debug.Print "Info Face Count = " & info.FaceCount
Debug.Print "Info Pin Count = " & info.PinCount
Debug.Print "Info Refer Count = " & info.ReferenceCount
Debug.Print "Info Shape Count = " & info.ShapeCount
End Sub

Sub PrintCellInstanceInfo(ByRef libCell As Cell)


Dim cellInst As CellInstance

For Each cellInst In libCell.Instances

' Avoid numerous redundant placements


If InStr(cellInst.Name, "I1_I2") = 0 Then
PrintInstanceInfo(cellInst)
End If

Next cellInst
End Sub

Sub PrintInstanceInfo(ByRef cellInst As CellInstance)


Debug.Print "Instance Name = " & cellInst.Name
Debug.Print "Base Position = x = " & cellInst.BasePosition.x * 1e6 & ", y = " & cellInst.BaseP
Debug.Print "Boundary = left = " & cellInst.Boundary.Left * 1e6 & ", top = " & cellInst.Bo
Debug.Print "Flipped = " & cellInst.Flipped
Debug.Print "Master Cell = " & cellInst.MasterCell
Debug.Print "Master Library = " & cellInst.MasterLibrary
Debug.Print "Rotation Angle = " & cellInst.RotationAngle
Debug.Print ""
End Sub

Copying Cell Libraries

The NI AWR SDE supports three options when copying a Cell:

1. No change (the Cell is copied without hierarchy) - this option depends on lookup to locate any Instances.
2. Flatten (all Instances in the Cell are flattened) - all Shapes are self-contained in the Cell. Flatten = "False" copies the
cell without hierarchy. Flatten = "True" flattens all the Instances to flat Shapes and copies the result.
3. (Cells.Copy2) - copies the hierarchy (the argument copyChildren) and should allow you to perform the copy with
hierarchy.

The following code performs all three methods:

Project.CellLibraries(1).Cells.Copy("Lib1","cellA") ' Copy to lib1 cellA


Project.CellLibraries(1).Cells.Copy("Lib1","top1",,True) 'Copy top1 to lib1 flatten

' Code Module


Sub Main
Dim cellLib As CellLibrary

Set cellLib = Project.CellLibraries("Lib1")

1536 NI AWR Design Environment


Layout

cellLib.Cells.Copy2("Lib2", "top2", "top2", False, True)


End Sub

Note that if in the Project the top3 Cell has an Instance that is a reference to cellA from Lib1 of the same Project, Lib3
does not have it's own cellA; it refers to cellA of Lib1. Since Lib3 does not have a Cell named cellA, you will not see it
if you print Cell names from the Lib3 Library. Choose Options > Environment Options to display the Environment Options
dialog box, then click the Layout tab and clear the Show top level library cells only option to display the Cell libraries flat
in the Project Browser. You can see that Lib1 and Lib2 have a cellA Cell in the Library but Lib3 does not. The following
command copies Lib3 top3 to Lib1 and correctly retains the reference to cellA from Lib1:

Project.CellLibraries("Lib1").Cells.Copy2("Lib3", "top3", "top3_copy", False, True)

The following command copies Lib3 top3 to Lib2 and creates a new Cell cellA_copy so it is not referencing cellA from
Lib2:

Project.CellLibraries("Lib2").Cells.Copy2("Lib3", "top3", "top3_copy", False, True)

By default, only the top level Cells (not the Cells in the Library) display. If you clear the Show top level library cells only
option then you can see a flat listing of all the Cells in each Library. So, Lib3 really only has one Cell (top3) and does
not contain a cellA. The Copy2 command, however, is functioning correctly in terms of copying the top3 Cell with
hierarchy.

Merging Cell Libraries

The CellLibrary has a method in the API named Merge which allows you to perform merges between libraries. A Merge
command associated with a Cell Library allows you to Merge other libraries with that Library. This command is the
equivalent of right-clicking a Library in the Layout Manager and choosing Merge Cell Libraries. The following script
merges Lib2 into Lib1 and sets Print to "True":

' Code Module


Sub Main
Dim cellLib As CellLibrary

Set cellLib = Project.CellLibraries("Lib1")


Debug.Print cellLib.Merge("Lib2")

End Sub

Importing and Exporting Cell Libraries

The following code imports the "First.gds" CellLibrary into the Project and creates a "First" subnode under the Cell
Libraries node in the Layout Manager.

Project.CellLibraries.Import("First","First.gds",mwCLT_GDSII)

API Scripting Guide 1537


Layout

Note that CellLibrary must be in the Project directory or you must include the path to the code. Also, when directly
importing DXF files to CellLibraries, be aware that some DXF files have units defined in the files and some do not. To
define the unit scale when importing a DXF file, use the following code:

Project.CellLibraries.Import2(Name,FileName,mwCLT_DXF, scale)

If the units are defined in the file, this scale has no affect.

The following is an example of the actual code:

Dim cl As CellLibrary
Dim dxfcell As Cell
Dim meter_per_inch As Double
pth = Project.Path
fn = pth+"filtronic_dxf.dxf"
meter_per_inch = 0.0254
Set cl = Project.CellLibraries.Import2("filtronic",fn,mwCLT_DXF, 1e-3)
'below adds to a schematic layout,
'Project.Schematics(1).Layout.DrawingObjects.AddCell("test","test",0,0)

If the units are defined in the file you can use the following function:

Project.CellLibraries.Import(Name,FileName,mwCLT_DXF)

The following script opens a Cell in the Cell Editor and then uses the Cell Editor Export method to perform the export.
"DXF" is the name of a file mapping in the Project. This is the name of the default DXF file mapping created when the
Project was created. You can create another file mapping if you want to change how the exported layers are mapped. In
the Layout Manager, select the Layer Setup node, then right-click and choose Edit Drawing Layers. In the Drawing Layers
Options dialog box, select the File Export Mappings node (GDSII, Gerber, and DXF) and choose, for example New GDSII
Export Mapping to create a custom mapping. To export the Project you must turn on (click the Check All button) all layers
in the export map.

The Export method determines what type of export to perform based on the type of file mapping you give it. For example,
if it is a GDSII file mapping it exports GDSII, or if it is a DXF file mapping it exports DXF.

' Code Module


Sub Main
Dim cellLib As CellLibrary
Dim libCell As Cell
Dim cellEd As CellEditor
Debug.Clear
Set cellLib = Project.CellLibraries("New_DXF_Lib")
Debug.Print cellLib.Name
' Get the cell of interest from the cell library
Set libCell = cellLib.Cells("new_trf")
Debug.Print libCell.Name
' Get an editor on the cell.
If (libCell.Editors.Count) Then
Set cellEd = libCell.Editors(1)
Else
Set cellEd = libCell.EditCell
End If

1538 NI AWR Design Environment


Layout

' Note: Here "DXF" is the name of a DXF type file mapping in the layer setup
' The name can be the name of any DXF type file mapping in the layer setup.
cellEd.Export("new_trf_flat.dxf", "DXF", True)
cellEd.Export("new_trf_hier.dxf", "DXF", False)
' Import the libraries back into the library browser
Project.CellLibraries.Import2("new_trf_flat", "new_trf_flat.dxf", mwCLT_DXF)
Project.CellLibraries.Import2("new_trf_hier", "new_trf_hier.dxf", mwCLT_DXF)
End Sub

Next script shows text exporting and importing in DXF format. The script exports a design with poly text and view text
and then re-import the exported file.

' Code Module


Sub Main
Dim cellLib As CellLibrary
Dim libCell As Cell
Dim cellEd As CellEditor
Dim objDraw As DrawingObject
Dim libPath As String

libPath = Project.Path + "Cell_Lib_View_Text.dxf"

delete_if_exists(libPath)

Set cellLib = Project.CellLibraries.Add("Cell_Lib", mwCLT_DXF)


Set libCell = cellLib.Cells.Add("Cell")

libCell.Shapes.AddText(100e-6, 100e-6, 30e-6, "Text", "Source Drain", 0, "", False, False, False)
cellLib.SaveAs(libPath)
Project.CellLibraries.Remove(cellLib.Name)
Project.CellLibraries.Import("Cell_Lib", libPath, mwCLT_DXF)

Set libCell = Project.CellLibraries("Cell_Lib").Cells("Cell")


Set cellEd = libCell.EditCell

For Each objDraw In cellEd.DrawingObjects


PrintDrawingObject objDraw
Next objDraw

End Sub

Sub PrintDrawingObject(ByRef drawingObj As DrawingObject)


Debug.Print "Info Text = " &amp; drawingObj.InfoText
Debug.Print "Selected = " &amp; drawingObj.Selected
Debug.Print "Flipped = " &amp; drawingObj.Flipped
Debug.Print "Rotation = " & drawingObj.RotationAngle
Debug.Print "Frozen = " & drawingObj.Frozen
Debug.Print "Base Pos = { x = " & drawingObj.BasePosition.x & ", y = " & drawingObj.BasePosition.
Debug.Print "Layer Map = " & drawingObj.LayerMapping

PrintParameters(drawingObj.Parameters)
PrintAttributes(drawingObj.Attributes)
PrintBoundary(drawingObj.Boundary)
PrintEditHandles(drawingObj.EditHandles)
PrintVertices(drawingObj.Shapes(1).Vertices)

API Scripting Guide 1539


Layout

End Sub

Sub PrintParameters(ByRef params As LayoutParameters)

Dim param As LayoutParameter


Debug.Print "Parameters:"
For Each param In params
Debug.Print param.Name & " = " & param.ValueAsString
Next param

End Sub

Sub PrintAttributes(ByRef attrs As Attributes)


Dim attr As Attribute
Debug.Print "Attributes:"
For Each attr In attrs
Debug.Print attr.Name & " = " & attr.ValueAsString
Next attr
End Sub

Sub PrintBoundary(ByRef bound As Boundary)


Debug.Print "Boundary:"
Debug.Print "Left = " & bound.Left
Debug.Print "Right = " & bound.Right
Debug.Print "Top = " & bound.Top
Debug.Print "Bottom = " & bound.Bottom
End Sub

Sub PrintVertices(ByRef verts As Vertices)


Dim vert As Vertex
Debug.Print "Vertices:"
For Each vert In verts
Debug.Print "{ x= " & vert.x & ", y= " & vert.y & " }"
Next vert
End Sub

Sub PrintEditHandles(ByRef ehs As EditHandles)


Dim eh As EditHandle
Debug.Print "Edit Handles:"
For Each eh In ehs
Debug.Print "{ x= " & eh.Position.x & ", y= " & eh.Position.y & " }"
Next eh
End Sub

The part of the output looks like:

Info Text = Polygon: Perimeter=89.64 um, A=119.646 um^2, [Source Drain]


Selected = False
Flipped = False
Rotation = 0
Frozen = False
Base Pos = { x = 0.00010063, y = 0.00013 }
Layer Map =
Parameters:
Attributes:
LineType = 0

1540 NI AWR Design Environment


Layout

UsesProcessLayers = 0
LayerMapping = 0
LayerIndex = 3
PositionFixed = 0
FlipState = 0
RotationAngle = 0
Area = 0.000000000119646
IsEMExtract = 0
GroupName =
LayerName = Source Drain
Boundary:
Left = 0.00010063
Right = 0.00011593
Top = 0.00013
Bottom = 0.00010048
Edit Handles:
{ x= 0.00010954, y= 0.00010048 }
{ x= 0.00010954, y= 0.0001135 }
{ x= 0.00010954, y= 0.00012652 }
{ x= 0.000112735, y= 0.00012652 }
{ x= 0.00011593, y= 0.00012652 }
{ x= 0.00011593, y= 0.00012826 }
{ x= 0.00011593, y= 0.00013 }
{ x= 0.00010828, y= 0.00013 }
{ x= 0.00010063, y= 0.00013 }
{ x= 0.00010063, y= 0.00012826 }
{ x= 0.00010063, y= 0.00012652 }
{ x= 0.00010381, y= 0.00012652 }
{ x= 0.00010699, y= 0.00012652 }
{ x= 0.00010699, y= 0.0001135 }
{ x= 0.00010699, y= 0.00010048 }
{ x= 0.000108265, y= 0.00010048 }
Vertices:
{ x= 0.00010954, y= 0.00010048 }
{ x= 0.00010954, y= 0.00012652 }
{ x= 0.00011593, y= 0.00012652 }
{ x= 0.00011593, y= 0.00013 }
{ x= 0.00010063, y= 0.00013 }
{ x= 0.00010063, y= 0.00012652 }
{ x= 0.00010699, y= 0.00012652 }
{ x= 0.00010699, y= 0.00010048 }

Use an Export method as in the following code to the Cell object in the API so that a single cell can be exported directly
in a manner similar to right clicking on the cell in the UI and selecting "Export Layout Cell" from the context menu:

' Code Module


Sub Main
Dim libCell As Cell

Debug.Clear
Set libCell = Project.CellLibraries("TDMSDEMOLIB.DB").Cells("AND2")
Debug.Print libCell.Name

libCell.Export("D:\Documents\AWR Projects\Test Projects\Scripting\CellExportTest.gds",mwCEF_GDSII,


End Sub

API Scripting Guide 1541


Layout

This will export the cell in GDSII format flat. The cell could be exported in DXF format with mwCEF_DXF.

To Import GDSII Library use the following code:

Dim cellLib As CellLibrary


libPath = Project.Path + "Cell_Lib_Path.gds"
Project.CellLibraries.Import("Cell_Lib", libPath, mwCLT_GDSII)

Output Cell Libraries Properties

To output Cell Libraries features, use the following code:

Dim cl As CellLibrary
Debug.Clear
For Each cl In Project.CellLibraries
Debug.Print "Library name = "; cl.Name;vbTab;"ExcludeFromExport = ";cl.ExcludeFromExport
Debug.Print "Filename = ";cl.Filename;vbTab;"Modified = ";cl.Modified;vbTab;"SearchPriority = "
;cl.SearchPriority
Debug.Print "ReadNewest = ";cl.ReadNewest;vbTab;"ReplaceAllCells = ";cl.ReplaceAllCells;vbTab;"T
;vbTab;cl.Type
Debug.Print
Next cl

This code generates output similar to the following example:

Library name = New_Gdsii_Lib ExcludeFromExport = True


Filename = C:\My6scripts\CellLibraies\cell_library.gds Modified = False SearchPriority = 1
ReadNewest = True ReplaceAllCells = True Type = 0
Library name = New_DXF_Lib ExcludeFromExport = False
Filename = C:\My6scripts\CellLibraies\New_DXF_Lib.dxf Modified = False SearchPriority = 2
ReadNewest = False ReplaceAllCells = False Type = 1
Library name = New Library ExcludeFromExport = False
Filename = Modified = False SearchPriority = 3
ReadNewest = False ReplaceAllCells = False Type = 0

To output or set the name of the Process Definition to use with a specified Cell Library, use the following code:

Dim cl As CellLibrary
Set cl = Project.CellLibraries(1)
Debug.Print cl.ProcessDefinition

This code generates output similar to the following example:

Default

The Process Definition to be used with the Cell Library is named "Default".

1542 NI AWR Design Environment


Layout

Saving Cell Libraries

To Save a Cell Library under the new file name, use the following code:

Dim cl As CellLibrary
Set cl = Project.CellLibraries.Item(1)
Debug.Print cl.Name
cl.SaveAs(cl.Name &".gds")

The Cell Library is created in the same directory as the Project.

Adding Cells from CellLibrary to Schematic/Layout

To add all cells from the library, use the following code:

Dim l As CellLibrary
Set l = Project.CellLibraries("PSCTESTLAY1.DB")
Dim c As Cell
Dim s As Schematic
Set s = Project.Schematics("NMOS_RF_Cds_cells")
For Each c In l.Cells
s.Layout.DrawingObjects.AddCell(l.Name, c.Name, 0, 0)
Next c

Updating layout view after creating artwork cell and placing it in schematic layout

After adding all cells from the library, use the following code to update the layout view:

' Code Module


Sub Main

Dim l As CellLibrary
Dim c As Cell

Set l = Project.CellLibraries.Add("Lib", mwCLT_GDSII)


Set c = l.Cells.Add("Cell")
c.Shapes.AddRectangle(0.0, 0.0, 100e-6, 100e-6, "Nitride Etch")
c.UpdateViews

Project.Schematics(1).Layout.DrawingObjects.AddCell("Lib", "Cell", 0.0, 0.0)


c.UpdateViews

End Sub

Layout.Refresh command also works, but we need to be sure that layout window is open, so, we need to use the following
code:

If (sch.Layout.Windows.Count = 0) Then
sch.Layout.NewWindow(mwLWT_Layout2D)
End If
sch.Layout.Refresh

API Scripting Guide 1543


Layout

Exporting and Importing artwork cell

The following fragment of code exports the layout as a GDS file, then re-imports the exported result as a cell library and
then opens a cell editor on the library schematic cell to allow the objects of the cell to be enumerated:

Dim cellLib As CellLibrary


Dim libCell As Cell
Dim cellEd As CellEditor
Dim objDraw As DrawingObject
Dim libPath As String

libPath = Project.Path + "Cell_Lib_Artwork_Cell.gds"


delete_if_exists(libPath)

Project.Schematics("SCH1").Layout.Export(libPath, 1)
Project.CellLibraries.Import("Cell_Lib", libPath, mwCLT_GDS)
Set libCell = Project.CellLibraries("Cell_Lib").Cells("SCH1")
Set cellEd = libCell.EditCell

The following fragment of code exporting layout shapes to dxf and then re-importing them as cell libraries:

Dim cellLib As CellLibrary


Dim libCell As Cell
Dim cellEd As CellEditor
Dim objDraw As DrawingObject
Dim libPath As String

libPath = Project.Path + "Cell_Lib_Artwork_Cell.gds"


delete_if_exists(libPath)

Project.Schematics("SCH1").Layout.Export(libPath, 1)
Project.CellLibraries.Import("Cell_Lib", libPath, mwCLT_GDS)
Set libCell = Project.CellLibraries("Cell_Lib").Cells("SCH1")
Set cellEd = libCell.EditCell

Navigating Layout
Negative Layers

The NI AWR SDE Layout supports the concept of negative layers. The following layer types are supported:

Positive Layers
Negative Layers
Normal Layers

To find all types of Layers via the NI AWR SDE, use the following code.

Dim drawlayer() As String


Dim dl As DrawingLayer
Dim normlayer As String
Dim poslayer As String

1544 NI AWR Design Environment


Variables and Equations

Dim neglayer As String


Dim nrmlayers() As String
Dim i As Integer
i=1
ReDim drawlayer(Project.LayerSetup.DrawingLayers.Count)
i=1
For Each dl In Project.LayerSetup.DrawingLayers
drawlayer(i) = dl.Name
i = i+1
Next dl
' Extract negative, positive, and normal layers
ReDim nrmlayers(0)
nrmlayers(0) = "none"
For i=1 To UBound(drawlayer)
negfound=0
posfound=0
If Right(drawlayer(i),1) <> "+" Then
If Right(drawlayer(i),1) <> "-" Then
poslayer = Join(Array(drawlayer(i),"+"),"")
neglayer = Join(Array(drawlayer(i),"-"),"")
For j = 1 To UBound(drawlayer)
If poslayer = drawlayer(j) Then
posfound = 1
End If
If neglayer = drawlayer(j) Then
negfound = 1
End If
Next j
If posfound = 1 Then
If negfound = 1 Then
If nrmlayers(0) = "none" Then
nrmlayers(0) = drawlayer(i)
ElseIf nrmlayers(0) <> "none" Then
num = UBound(nrmlayers)+1
ReDim Preserve nrmlayers(num)
nrmlayers(num) = drawlayer(i)
End If
End If
End If
End If
End If
Next i

Variables and Equations


The NI AWR SDE allows you to define variables and equations for a number of purposes. You can create variables and
equations using the following collections of objects:

The GlobalEquations collection creates equations in the Global Definition window (Global Definitions node in the
Project Browser).
The OutputEquation collection creates equations in the OutputEquation window (Output Equations node in the Project
Browser).
The Schematics collection allows you to create equations inside the Schematic window.

API Scripting Guide 1545


Variables and Equations

The SystemDiagram collection allows you to create equations inside the SystemDiagram window.

Using Variables and Equations in Schematics and SystemDiagrams


Defining Global Equations Via the GlobalEquations Collection of Objects

The GlobalEquations collection of objects allows you to define global variables and equations for use anywhere within
the Project.

To iterate through a collection of GlobalEquations objects, use the following script:

Sub Main 'Check_geqn_count


Debug.Clear
Dim eqn As Equation
Dim valstr(7) As String
i=0
For Each eqn In Project.GlobalEquations
Debug.Print eqn.Expression
valstr(i) = eqn.Expression
Debug.Print "valstr("&i&") = ";valstr(i)
i = i + 1
Next eqn
Dim iCount As Double
iCount = Project.GlobalEquations.Count
Debug.Print "iCount = ";iCount
'Checking REMOVE method
For i=1 To iCount
Project.GlobalEquations.Remove(1)
Next i
For Each eqn In Project.GlobalEquations
Debug.Print eqn.Expression
Next eqn
'Restore GlobalEquations
For i=0 To (iCount-1)
Project.GlobalEquations.Add(valstr(i),0,i*150)
Next i
For Each eqn In Project.GlobalEquations
Debug.Print eqn.Expression
Next eqn
iCount = Project.GlobalEquations.Count
Debug.Print "iCount = ";iCount
Project.GlobalEquations.Add("pi=3.1415926",0,450)
Debug.Print "Count = ";Project.GlobalEquations.Count
End Sub

This script generates the following output:

mils_per_meter=39370
valstr(0) = mils_per_meter=39370
l=460/mils_per_meter
valstr(1) = l=460/mils_per_meter
C_light=2.997925e+8
valstr(2) = C_light=2.997925e+8
pi=3.1415926
valstr(3) = pi=3.1415926

1546 NI AWR Design Environment


Variables and Equations

iCount = 4
mils_per_meter=39370
l=460/mils_per_meter
C_light=2.997925e+8
pi=3.1415926
iCount = 4
iCount = 5

To access the Global Equation Expression by variable name, use the following script:

Dim globalDoc As GlobalDefinitionDocument


Dim eqn As Equation
Dim expr As EquationExpression
Dim varName As String

Debug.Clear
Set globalDoc = Project.GlobalDefinitionDocuments("Global Definitions")
For Each eqn In globalDoc.Equations
For Each expr In eqn.Expressions
varName = Left(expr.Expression, InStr(1, expr.Expression, "=") - 1)
If eqn.Expressions.Exists(varName) Then
Debug.Print "Found expression " & expr.Expression & " by varName: " & varName
Else
Debug.Print "Could not find " & expr.Expression & " by varName: " & varName
End If
Next expr
Next eqn

To add a Global Equation with InsertEquation command on a GlobalDocument , use the following script:

Dim globalDoc As GlobalDefinitionDocument


Set globalDoc = Project.GlobalDefinitionDocuments("Global Definitions")

' Use the InsertEquation command to add a command object.


globalDoc.InvokeCommand("InsertEquation", Array("X=5", 0, 0))

The following script deletes all Global Def equations, then adds a new equation "2 + 3:", and then runs
ge.InvokeCommand("SimulateUpdateEquations", args, retval). You can run Project.Simulator.Analyze and it will update,
but to update without simulating use the following InvokeCommand():

Debug.Clear
Dim ge As GlobalDefinitionDocument
Dim args, retval
Set ge = Project.GlobalDefinitionDocuments(1)

If ge.Windows.Count = 0 Then
ge.NewWindow()
End If

Dim i As Long
For i = ge.Equations.Count To 1 Step -1

API Scripting Guide 1547


Variables and Equations

ge.Equations.Remove(i)
Next i

ge.Equations.Add2("2 + 3:", 0, 0)

ge.InvokeCommand("SimulateUpdateEquations", args, retval)

Debug.Print retval

We converted the Update equations command from a view UI macro which called into the document to a command
object which calls into the document. The advantage of command is that it doesn't require access to a view object in
order to be invoked so the API can invoke the command as well. This allows the API to use a command such as:

ge.InvokeCommand("SimulateUpdateEquations", args, retval)

Where ge can be a Schematic, System Diagram, Global Definitions etc. We also added an Update() api method to the
Equations collection which can also be used to update the equations in a more direct API call. With this the equations
can be updated using a call such as:

ge.Equations.Update

Where again ge can be a Schematic, System Diagram, Global Definitions Document etc.

You can apply the Selected property to an Equation object. This allows you to set equations to selected or unselected as
well as determine which equation objects are selected.

To set relations between Element parameters and the GlobalEquation.expression, use the following script:

Sub Main
Debug.Clear
Dim eqn As Equation
For Each eqn In Project.GlobalEquations
Debug.Print eqn.Expression
Next eqn
Dim schem As Schematic
Dim ele As Element
Set schem = Project.Schematics.Add("Master")
Set eqn = schem.Equations.Add("X=99",0,100)
eqn.Tune = True
Set ele = schem.Elements.Add("Res",0,0,0)
Dim p As parameter
Set p = ele.parameters("R")
p.ValueAsString = "X"
Set ele = schem.Elements.Add("PORT",0,0,0)
Set ele = schem.Elements.Add("PORT",1000,0,180)
End Sub

Setting GlobalEquations Variables for Optimization

To set GlobalEquations values for optimization, use the following code:

1548 NI AWR Design Environment


Variables and Equations

Dim ucon As Double


Dim lcon As Double
ucon =600
lcon=200
'Printing Expression
Debug.Print "Project.GlobalEquations(3)= ";vbTab;Project.GlobalEquations(3)
' Setting Optimization properties
Project.GlobalEquations(3).Tune=True
Project.GlobalEquations(3).Optimize=True
Project.GlobalEquations(3).Constrain=True
Project.GlobalEquations(3).UpperConstraint=ucon
Project.GlobalEquations(3).LowerConstraint=lcon
Debug.Print Project.GlobalEquations(3).UpperConstraint
Debug.Print Project.GlobalEquations(3).LowerConstraint
Project.GlobalEquations(3).UseStatistics=True
Project.GlobalEquations(3).Distribution=mwSD_NormalDist
Project.GlobalEquations(3).Distribution=mwSD_UniformDist
Project.GlobalEquations(3).OptimizeYield=True
Project.GlobalEquations(3).TolInPercent=True
Project.GlobalEquations(3).y=300
Project.GlobalEquations(3).x=30
Project.GlobalEquations(3).StatVariation=0.000000002

Accessing Elements in GlobalDefinitions

To list Elements in the global definitions, use the following code:

Dim elem As Element


Debug.Clear
For Each elem In Project.GlobalDataElements
Debug.Print elem.Name
Next elem

To Add an Element (in this case an MSUB), use the following code:

Project.GlobalDataElements.Add("MSUB", 0, 0)

To Remove an Element, use the following code:

Project.GlobalDataElements.Remove("MSUB.SUB1")

To Remove all Elements, use the following code:

Project.GlobalDataElements.RemoveAll

Working with Multiple GlobalDefinitionsDocuments

To list Elements in the Multiple Global Definitions, use the following script:

' Code Module


Sub Main

API Scripting Guide 1549


Variables and Equations

Dim glo As GlobalDefinitionDocument


Dim eq As Equation

Debug.Clear

For Each glo In Project.GlobalDefinitionDocuments


Debug.Print "Global Name:";glo.Name

For Each eq In glo.Equations


Debug.Print "Expression:";eq.Expression
Debug.Print "Description:";eq.Description
Debug.Print "Constrain:";eq.Constrain;vbTab;eq.LowerConstraint
Next eq
Next glo
End Sub

This script generate the following output:

Global Name:Global Definitions


Expression:a=0.2
Description:
Constrain:False 0
Global Name:Global Definitions1
Expression:b=a+0.3
Description:
Constrain:False 0
Expression:b:
Description:
Constrain:False 0
Expression:c=0.7
Description:
Constrain:False 0
Global Name:Global Definitions2
Expression:b=a+0.4
Description:
Constrain:False 0
Expression:b:
Description:
Constrain:False 0
Expression:c=0.9
Description:
Constrain:False 0

Having access to multiple Global Definition Documents enables adding and removing documents programmatically
from this collection.

' Code Module


Sub Main
Dim doc As GlobalDefinitionDocument
Dim doc2 As GlobalDefinitionDocument
Dim docName As String

docName = "MyGlobalDefDoc"

1550 NI AWR Design Environment


Variables and Equations

Set doc = Project.GlobalDefinitionDocuments.Add(docName)


If doc.Name = docName Then
Debug.Print "Returned doc with correct Name: " & doc.Name
Else
Debug.Print "Returned do with incorrect Name: " & doc.Name
End If

If Project.GlobalDefinitionDocuments.Exists(docName) Then
Debug.Print "Document " & docName & " found to exist in the collection"
Else
Debug.Print "Document " & docName & " not-found to exist in the collection"
End If

Set doc2 = Project.GlobalDefinitionDocuments(docName)


If doc2 Is Nothing Then
Debug.Print "Document " & docName & " lookup by name failed."
Else
Debug.Print "Document " & docName & " lookup by name succeeded."
End If
End Sub

To add an Element to each Global Definitions Document, use the following code:

' Code Module


Sub Main
Dim doc As GlobalDefinitionDocument

For Each doc In Project.GlobalDefinitionDocuments


AddElementToDoc doc
Next doc

End Sub

Sub AddElementToDoc(ByRef doc As GlobalDefinitionDocument)


Dim elem As Element
Dim elem2 As Element

Debug.Print "Processing Document: " & doc.Name

Debug.Print "Element Count before Add = " & doc.DataElements.Count

' Add a substrate element.


Set elem = doc.DataElements.Add("MSUB", 0, 0)

Debug.Print "Element Count after Add = " &doc.DataElements.Count

If elem Is Nothing Then


Debug.Print "Add failed to return valid element reference"
Else
Debug.Print "Add returned a valid element reference"
End If

If doc.DataElements.Exists(elem.Name) Then
Debug.Print "Element named " & elem.Name & " exists in the data elements collection."
Else

API Scripting Guide 1551


Variables and Equations

Debug.Print "Element named " & elem.Name & " not-found in the data elements collection."
End If

Set elem2 = doc.DataElements(elem.Name)


If elem2 Is Nothing Then
Debug.Print "Element named " & elem.Name & " lookup by name failed in data elements collection."
Else
Debug.Print "Element named " & elem.Name & " lookup by name succeeded in data elements collection
End If

End Sub

To remove a specific Global Definitions Document, use the following command:

Project.GlobalDefinitionDocuments.Remove(docName)

Defining Local Equations within Schematics or SystemDiagrams

To define a Variable or Equation for a particular Schematic or SystemDiagram, use the following code.

Dim s As Schematic 'Dim s As SystemDiagram


Dim e As Equation
Set s = Project.Schematics("Filter") 'Set s = Project.SystemDiagram(1)
s.Equations.Add("ca=0.03988",0,-1000)
Set e = s.Equations.Add("la=25.41",0,-1100)
e.Tune = True

After running this code, two equations display in the "Filter" Schematic. The two arguments after the text string in the
Add method are the X and Y position that determine where the equation is placed. Note that the X-axis is oriented
left-to-right and the Y-axis is oriented top-to-bottom.

You can delete equations using the Remove method.

You can also set equations for optimization using Constrain, Distribution, LowerConstraint, UpperConstraint, Optimize,
OptimizeYield, StatVariation, TolInPercent, and UseStatistics properties.

Dim s As Schematic
Dim e As Equation
Set s = Project.Schematics("Diode Mixer")
Set e = s.Equation("GroundReturn") 'the Equation object
Set e.X = -1000
Set e.Y = -4000
e.Tune = True 'Make tunable
e.Optimize = True
e.Constrain = True 'To constrain
eLower.Constraint = 0.5
e.UpperConstraint = 3.0

The Expression property of the equation returns the entire expression, not just a value of the expression. For the previous
example the returned expression is:

1552 NI AWR Design Environment


Variables and Equations

"GroundReturn" = 1.25

You can use this property to set or get the equation. You should use the update method on the equation and expression
objects. Those methods cause schematic equations to be evaluated and display their results. You can use DisplayText
property for equations and expressions which allows access to the evaluation results text of an equation and equation
expression:

Sub Main
Dim schem As Schematic

Debug.Clear
Set schem = Project.Schematics("SCH1")
PrintSchemEqnExprs schem, "*** Before Update Equations ***"

schem.Equations.Update

PrintSchemEqnExprs schem, "*** After Update Equations ***"


End Sub

Sub PrintSchemEqnExprs(ByRef schem As Schematic, title As String)


Dim eqn As Equation
Dim expr As EquationExpression

Debug.Print title
For Each eqn In schem.Equations
For Each expr In eqn.Expressions
PrintExpr expr
Next expr
Next eqn
Debug.Print ""
End Sub

Sub PrintExpr(ByRef expr As EquationExpression)


Debug.Print "Expression = " & expr.Expression
Debug.Print "Display Text = " & expr.DisplayText
Debug.Print "Affects Layout = " & expr.AffectsLayout
Debug.Print "Constraint = " & expr.Constrain
Debug.Print "Data Type = " & expr.DataType
Debug.Print "Distribution = " & expr.Distribution
Debug.Print "Enabled = " & expr.Enabled
Debug.Print "Exported = " & expr.Exported
Debug.Print "Has Error = " & expr.HasError
Debug.Print "Independent = " & expr.Independent
Debug.Print "Lower Constraint = " & expr.LowerConstraint
Debug.Print "Optimize = " & expr.Optimize
Debug.Print "Propagation Mode = " & expr.PropagationMode
Debug.Print "Stat Variation = " & expr.StatVariation
Debug.Print "Stat Variation 2 = " & expr.StatVariation2
Debug.Print "Step Size = " & expr.StepSize
Debug.Print "Tol In Percent = " & expr.TolInPercent
Debug.Print "Tune = " & expr.Tune
Debug.Print "Unit Type = " & expr.UnitType
Debug.Print "Upper Constraint = " & expr.UpperConstraint
Debug.Print "Use Statistics = " & expr.UseStatistics
Debug.Print "Variable Type = " & expr.VariableType

API Scripting Guide 1553


Variables and Equations

Debug.Print ""
End Sub

API also has "SimulateUpdateEquations" InvokeCommand() method to update and simulate the equation.

To disable the equation in the Schematic or SystemDiagram, set the Enable property to "False".

To access either the left side (name) of the equal sign or the right side (value) of the equal sign, use the following functions:

Function GetEqName(e As String) As String


GetEqName = Trim(Left(e, InStr(e,"=")-1))
End Function
Function GetEqVal(e As String) As Double
GetEqVal = Val(Right(e, Len(e) - InStr(e,"=")))
End Function

The NI AWRDE handles the entire equation as a string through the "Expression" method (for example,
Equation.Expression), as shown in the following code:

Dim x as String ' Equation name


Dim y as Double ' Equation value
x = GetEqName(project.Equations("EquationName").Expression)
y = GetEqVal(project.Equations("EquationName").Expression)

Manipulating Groups of Equations

Since the program handles the entire group of equations as a string through the "Expression" method, each equation in
the group is separated from the next equation by a carriage return and line feed characters.

To read all equations in the group, use the following code:

Dim x as String
x = Project.Schematics(1).Equations(1).Expression

To set the group of equations, use the following code:

project.Schematics(1).Equations(1).Expression = "x=11"+vbCRLF+"y=21"+vbCRLF+"z=31",

or:

project.Schematics(1).Equations(1).Expression = "x=11"+chr(13)+chr(10)+"y=21"
+chr(13)+chr(10)+"z=31"

The following code works only for groups:

vbCRLF = chr(13) + chr(10)

To get the number of groups of equations, use the following code:

1554 NI AWR Design Environment


Variables and Equations

Debug.Print Project.Schematics(1).Equations.Count

To loop through groups of equations, use the following code:

For Each eqn In Project.Schematics(1).Equations


Next eqn

There are equation properties for individual equations within the group. To change an equation property you must first
specify which equation you want to work on, and then change the desired property. (In the following code, the second
equation in the group is disabled). To specify which equation in the group to access, use the ActiveIndex property on
the Equation object:

project.Schematics(1).Equations(1).ActiveIndex=2
project.Schematics(1).Equations(1).Enabled=False

When you access the Enabled or Tune properties, they function in the group on the equation that ActiveIndex selects.
By default, ActiveIndex is set to "one".

If equations are organized as separate equations (without grouping them), they are treated as the usual collection of
equations.

Using Output Equations

Output Equations assigns the result of a Measurement to a variable, which you can use in other equations just like other
variables.

Note that in OutputEquations the values must be specified in MKS units; conversion to the Project units does not work.
You must provide explicit units conversions in OutputEquations.

The following example creates OutputEquations:

Sub Main
Debug.Clear
Dim eqn As Equation
Dim valstr(11) As String
Dim freq As Frequency
Dim gs As Graphs
Dim g As Graph
Dim schem_Name As String
Dim m As Measurement
Dim mm As Measurement
Dim valze() As Double
Dim valzo() As Double
'Define the Name of the Schematic
schem_Name = Project.Schematics(1).Name
Debug.Print schem_Name
valstr(0) ="y11="&schem_Name &":Y(1,1)"
Debug.Print valstr(0)
valstr(1) ="y12="&schem_Name &":Y(2,1)"
valstr(2) ="y13="&schem_Name &":Y(3,1)"
valstr(3) ="y14="&schem_Name &":Y(4,1)"
valstr(4) = "a=0.5*(y11+y12)"

API Scripting Guide 1555


Variables and Equations

valstr(5) = "b=0.5*(y11-y12)"
valstr(6) = "c=-0.5*(y13+y14)"
valstr(7) = "d=-0.5*(y13-y14)"
valstr(8) = "ye=2*sqrt(a*a-c*c)"
valstr(9) = "yo=2*sqrt(b*b-d*d)"
valstr(10) = "ze=1/ye"
valstr(11) = "zo=1/yo"
' Adding Equations
For i = 0 To 11
Set eqn = Project.OutputEquations.Add(valstr(i),0,i*100)
Debug.Print Project.OutputEquations.Item(i+1)
Next i
Set gs = Project.Graphs
Set g = gs.Add("Ze and Zo",mwGT_Rectangular)
g.Measurements.Add("ze","Re(Eqn)")
g.Measurements.Add("zo","Re(Eqn)")
Project.Simulator.Analize
Set m = Project.Graphs("Ze and Zo").Measurements("ze:Re(Eqn)")
Set mm = Project.Graphs("Ze and Zo").Measurements("zo:Re(Eqn)")
cPoints = m.XPointCount
ReDim Preserve valze(cPoints)
ReDim Preserve valzo(cPoints)
'Debug.Print cPoints
For i=1 To cPoints
valze(i) = m.YValue(i,1)
valzo(i) = mm.YValue(i,1)
'Debug.Print i;";m.XValue(i)/1.e9;vbTab;m.YValue(i,1);vbTab;mm.YValue(i,1);
vbTab;valze(i);vbTab;valzo(i)
Next i
End Sub

You need to create Graphs and Measurements before using the results of the Measurements. The Measurement results
are assigned to arrays valze(cPoints) and valzo(cPoints). The length of these arrays depends on the amount of points in
the Measurements.

This script generates the following output:

Model Lange
y11=Schematic 1:Y(1,1)
y11 = Schematic 1:Y(1,1)
y12 = Schematic 1:Y(2,1)
y13 = Schematic 1:Y(3,1)
y14 = Schematic 1:Y(4,1)
a=0.5*(y11+y12)
b=0.5*(y11-y12)
c=-0.5*(y13+y14)
d=-0.5*(y13-y14)
ye=2*sqrt(a*a-c*c)
yo=2*sqrt(b*b-d*d)
ze=1/ye
zo=1/yo
1: 1 107.234917897098 24.5190017043023 107.234917897098 24.5190017043023
2: 6 106.105364024421 21.1282783219225 106.105364024421 21.1282783219225
3: 11 106.215060982942 20.7597001994286 106.215060982942 20.7597001994286
4: 16 106.690595211431 20.5790745667766 106.690595211431 20.5790745667766

1556 NI AWR Design Environment


Variables and Equations

5: 21 107.579870937395 20.4536523596659 107.579870937395 20.4536523596659


6: 26 109.104367568555 20.3565120928252 109.104367568555 20.3565120928252
7: 31 111.834905110759 20.2915326115504
111.83490511075 20.2915326115504
8: 36 117.518738680552 20.3003944802393 117.518738680552 20.3003944802393
9: 41 134.652818916737 20.5573692641565 134.652818916737 20.5573692641565
10: 46 111.700095301258 22.110491015337 111.700095301258 22.110491015337
11: 50 7.04220000903733 28.0238758789628 7.04220000903733 28.0238758789628

The following example creates OutputEquations using InvokeCommand method():

Dim outEqnDoc As OutputEquationDocument


Dim eqn As Equation

Set outEqnDoc = Project.OutputEquationDocuments("Output Equations")

outEqnDoc.InvokeCommand("InsertEquation", Array("X=5", 0, 0))

You can set the same properties on the OutputEquations as you can on Global Equations and Equations:

Sub Main
Dim e As equation
Set e = Project.OutputEquations.Add("x=20",100,100)
eConstrain = True
e.LowerConstraint = 10
e.UpperConstraint = 30
e.Distribution = mwSD_NormalDist
Debug.Print e.x
End Sub

Using Multiple Output Equations Documents

Output Equations can have multiple pages.

The following code adds a New Page to Output Equations:

' Project Module


Private Sub Project_BeforeSimulate(Cancel As Boolean)
Dim e As OutputEquationDocument

Set e = Project.OutputEquationDocuments.Add("added_in_api")
e.Equations.Add("EQ1 = :PlotVs(""cap:DB(|S(1,1)|)"",""cap:R_PRL(1)"")",-2600,-900)
e.Equations.Add("xa=EQ1+a",-2600,-700)
e.Equations.Add("EQ2 = cap:|ZIN(1)|", -2600,300)
e.Equations.Add("ya = EQ2 + a*100",-2600,500)
e.Equations.Add("deq1 = awr_double(xa)",-2600,900)
End Sub

The following code adds Output Equations referenced each other:

API Scripting Guide 1557


Variables and Equations

outputEq.Equations.Add2("X=5", 0, 0)
outputEq.Equations.Add2("Y=X", 0, 100)
outputEq.Equations.Add2("Z=Y", 0, 200)

You can also use Subexpressions as in the following code to add Output Equations referenced each other:

Dim outputEq As OutputEquationDocument


Dim eqn As Equation
Dim expr As EquationExpression

Debug.Clear
Set outputEq = Project.OutputEquationDocuments("Output Equations")

Set eqn = outputEq.Equations.Add2("X=5", 0, 0)


eqn.AddSubexpression("Y=6")
eqn.AddSubexpression("Z=7")

Debug.Print "Expression Count = " & eqn.Expressions.Count

The following code renames an OutputEquations Document:

' Project Module


Private Sub Project_BeforeSimulate(Cancel As Boolean)
Dim e As OutputEquationDocument
Project.OutputEquationDocuments("added_in_api2").Name="added_in_api"
End Sub

The following code adds and removes an OutputEquations Document:

Project.OutputEquationDocuments.Add("test")
Project.OutputEquationDocuments.Remove("test")

The following example shows how to access OutputEquations Document by Name:

Dim doc As OutputEquationDocument


Dim doc2 As OutputEquationDocument

For Each doc In Project.OutputEquationDocuments


Debug.Print "Processing Document: " & doc.Name

If (Project.OutputEquationDocuments.Exists(doc.Name)) Then
Debug.Print "Document " & doc.Name & " exists in the output equations documents collection"
Else
Debug.Print "Document " & doc.Name & " was not found to exist in the output equations doucments
End If

Set doc2 = Project.OutputEquationDocuments(doc.Name)


If doc2 Is Nothing Then
Debug.Print "Document " & doc.Name & " lookup by name failed."

1558 NI AWR Design Environment


Variables and Equations

Else
Debug.Print "Document " & doc.Name & " lookup by name succeeded."
End If

Debug.Print ""
Next doc

The following example shows how to access OutputEquations Document by Variable Name:

Set outputEq = Project.OutputEquationDocuments("Output Equations")


For Each eqn In outputEq.Equations
varName = Left(eqn.Expression, InStr(1, eqn.Expression, "=") - 1)
Set eqn2 = outputEq.Equations(varName)
If eqn2 Is Nothing Then
Debug.Print "Could Not Find " & eqn.Expression & " by Name: " & varName
Else
Debug.Print "Found " & eqn.Expression & " by Name: " & varName
End If
Next eqn

The following example shows how to access OutputEquations Document by Expression:

Dim outputEq As OutputEquationDocument


Dim eqn As Equation
Dim eqn2 As Equation

Debug.Clear
Set outputEq = Project.OutputEquationDocuments("Output Equations")
For Each eqn In outputEq.Equations
Set eqn2 = outputEq.Equations(eqn.Expression)
If eqn2 Is Nothing Then
Debug.Print "Could Not Find " & eqn.Expression & " by Expression"
Else
Debug.Print "Found " & eqn.Expression & " by Expression"
End If
Next eqn

Output Equations includes an Options collection because you need to choose which globals to use for each Output
Equation document.

The following script shows how to access Multiple OutputEquations options and equations:

' Code Module


Sub Main
Dim ope As OutputEquationDocument
Dim glo As GlobalDefinitionDocument
Dim opt As Option
Dim eq As Equation

Debug.Clear

API Scripting Guide 1559


Variables and Equations

For Each ope In Project.OutputEquationDocuments


Debug.Print "Equation Name:";ope.Name

For Each opt In ope.Options

Debug.Print "Option Name = :";opt.Name;vbTab;opt.Description;vbTab;opt.Value;vbTab;opt.DefaultVa


Next opt
For Each eq In ope.Equations
Debug.Print "Expression:";eq.Expression
Debug.Print "Description:";eq.Description
Debug.Print "Constrain:";eq.Constrain;vbTab;eq.LowerConstraint
Next eq
Next ope
End Sub

This script generates the following output:

Equation Name:Output Equations


Option Name = :Equations.Options.Global Definitions Specify the global definition document to use a
Expression:EQ1 = :PlotVs("cap:DB(|S(1,1)|)","cap:R_PRL(1)")
Description:
Constrain:False 0
Expression:xa=EQ1+a
Description:
Constrain:False 0
Expression:xa:
Description:
Constrain:False 0
Expression:xb=EQ1+b
Description:
Constrain:False 0

Equation Name:xnew_equations
Option Name = :Equations.Options.Global Definitions Specify the global definition document to use a
Expression:EQ1 = :PlotVs("cap:DB(|S(1,1)|)","cap:R_PRL(1)")
Description:
Constrain:False 0
Expression:xa=EQ1+a
Description:
Constrain:False 0
Expression:xa:
Description:
Constrain:False 0
Expression:xb=EQ1+b
Description:
Constrain:False 0
Expression:xb:
Description:
Constrain:False 0

Equation Name:ynew_equations
Option Name = :Equations.Options.Global Definitions Specify the global definition document to use a
Expression:EQ1 = :PlotVs("cap:DB(|S(1,1)|)","cap:R_PRL(1)")
Description:
Constrain:False 0
Expression:xa=EQ1+a

1560 NI AWR Design Environment


Variables and Equations

Description:
Constrain:False 0
Expression:xa:
Description:
Constrain:False 0

The following code provides an example of accessing all Properties of the Output Equation document:

Sub Main
Dim outputEq As OutputEquationDocument
Dim eqn As Equation

Debug.Clear
Set outputEq = Project.OutputEquationDocuments("Output Equations")
For Each eqn In outputEq.Equations
PrintEqn eqn
Next eqn

End Sub

Sub PrintEqn(ByRef eqn As Equation)


Debug.Print "Active Index = " & eqn.ActiveIndex
Debug.Print "Affects Layout = " & eqn.AffectsLayout
Debug.Print "Constrain = " & eqn.Constrain
Debug.Print "Data Type = " & eqn.DataType
Debug.Print "Description = " & eqn.Description
Debug.Print "Distribution = " & eqn.Distribution
Debug.Print "Enabled = " & eqn.Enabled
Debug.Print "Expression = " & eqn.Expression
Debug.Print "Lower Cosntraint = " & eqn.LowerConstraint
Debug.Print "Num Sub Expressions = " & eqn.NumSubexpressions
Debug.Print "Optimize = " & eqn.Optimize
Debug.Print "Optimize Yield = " & eqn.OptimizeYield
Debug.Print "Propagation Mode = " & eqn.PropagationMode
Debug.Print "Selected = " & eqn.Selected
Debug.Print "Stat Variation = " & eqn.StatVariation
Debug.Print "Stat Variation 2 = " & eqn.StatVariation2
Debug.Print "Step Size = " & eqn.StepSize
Debug.Print "Tol In Percent = " & eqn.TolInPercent
Debug.Print "Unit Type = " & eqn.UnitType
Debug.Print "Upper Constraint = " & eqn.UpperConstraint
Debug.Print "Variable Type = " & eqn.VariableType
Debug.Print "Exression Count = " & eqn.Expressions.Count
Debug.Print ""
End Sub

The following code provides an example of creating a new Window or activating an existing Window on the Output
Equation document.

' Code Module


Sub Main
Dim outEqnDoc As OutputEquationDocument
Set outEqnDoc = Project.OutputEquationDocuments("Output Equations1")

API Scripting Guide 1561


Variables and Equations

' If we don't have a window on the document create one.


If outEqnDoc.Windows.Count = 0 Then
outEqnDoc.NewWindow
End If
' Bring window to front. (This needs a window to work.)
outEqnDoc.Activate
End Sub

There are standard Document methods and properties accessible, such as modified, read-only, and printing support.

Accessing and adding embedded designs in output equation documents.

The embedded designs collection provides API access to embedded design views in Output Equations documents.

The following example shows embedded disign access in OutputEquations:

Sub Main
Dim outeqn As OutputEquationDocument

Set outeqn = Project.OutputEquationDocuments("Output Equations")


PrintEmbeddedDesigns outeqn
End Sub

Sub PrintEmbeddedDesigns(ByRef outeqn As OutputEquationDocument)


Dim emb As EmbeddedDesign

For Each emb In outeqn.EmbeddedDesigns


PrintEmbeddedDetails emb
Next emb

End Sub

Sub PrintEmbeddedDetails(ByRef emb As EmbeddedDesign)


Debug.Print "Design Name = " & emb.DesignName
Debug.Print "Extension = " & emb.Extension
Debug.Print "X Pos = " & emb.x
Debug.Print "Y Pos = " & emb.y
Debug.Print "Width = " & emb.Width
Debug.Print "Height = " & emb.Height
Debug.Print ""
End Sub

To add embedded design to OutputEquationDocument use the following code:

' To add embedded EM Structure


Dim outeqn As OutputEquationDocument
Dim y As Double
Dim h As Double
Dim w As Double

y = 0
h = 1000
w = 2000

1562 NI AWR Design Environment


Variables and Equations

Set outeqn = Project.OutputEquationDocuments("Output Equations")

outeqn.EmbeddedDesigns.Add("EMS1", mwEDT_EMLayout, 0, y, w, h)
' To add embedded Graph
outeqn.EmbeddedDesigns.Add("Graph 1", mwEDT_Graph, 0, y, w, h)
'To add embedded layout
outeqn.EmbeddedDesigns.Add("SCH1", mwEDT_SchematicLayout, 0, y, w, h)
' To add embedded Shematic
outeqn.EmbeddedDesigns.Add("SCH2",mwEDT_Schematic, 0, 0, 2000, 1000)

To move embedded design in Output Equations use the following code:

If (outeqn.EmbeddedDesigns.Count > 0) Then


' Move the base position of the embedded layout design
Set emb = outeqn.EmbeddedDesigns(1)
emb.x = 500
emb.y = 500
End If

To remove embedded design "Graph 1" from Output Equations use the following code:

Dim index As Integer


index = 0
Set outeqn = Project.OutputEquationDocuments("Output Equations")

For i = 1 To outeqn.EmbeddedDesigns.Count
If (outeqn.EmbeddedDesigns(i).DesignName = "Graph 1") Then
index = i
End If
Next i

Dim bRes As Boolean


If (index ne 0) Then
bRes = outeqn.EmbeddedDesigns.Remove(index)
Debug.Print "Remove Returned: " & bRes
End If

To remove All embedded design in Output Equations use the following code:

Dim bRet As Boolean


bRet = outeqn.EmbeddedDesigns.RemoveAll
Debug.Print "Remove All Returned: " & bRet

To resize layout embedded design in Output Equations use the following code:

Dim emb As EmbeddedDesign

Set outeqn = Project.OutputEquationDocuments("Output Equations")

API Scripting Guide 1563


Variables and Equations

If (outeqn.EmbeddedDesigns.Count > 0) Then


' Resize the embedded design to make it larger.
Set emb = outeqn.EmbeddedDesigns(1)
emb.Width = emb.Width + 1000
emb.Height = emb.Height + 1000
End If

Using the Scripted Equation Function


Scripted functions allow you to extend the functions you can reference in equations, by referencing functions located in
a script. These scripts are describe in detail in Using Scripted Equation Functions. The following is an example. For
more information on adding equation functions, referencing a function in an equation, local and global scoping, and
using the NI AWR SDE for debugging and equations syntax, see Built-in Functions .

In the following example, the OutputEquations window contains equations:

z = Example1( 123,"abc", 5.5 )


z :
z = Example2( 1,2 )
z :
z = Example3( 2 + j*3 )
z :
r = Example4( 2.5 , 5 )
r :

The following is the "Equation" code:

' Code Module


Option Explicit
Function Example1(Z As Integer, x As String, Y As Double) As Double
Debug.Print "Example1"
Debug.Print x
Debug.Print Y
Example1=Y
End Function
Function Example2(I As Integer, j As Integer) As Integer
Debug.Print "Example2"
Debug.Print I
Debug.Print j
Example2=I+j
End Function
Function Example3(Y As Complex)
Debug.Print "Example3"
Debug.Print Y.Real
Debug.Print Y.Imaginary
Example3=Y
End Function
Function Example4(x As Double, Y As Integer) As Double
Debug.Print "Example4"
Debug.Print x
Debug.Print Y

1564 NI AWR Design Environment


Variables and Equations

Example4=x
End Function

When you simulate, the Output Equations window displays the following:

z = Example1( 123,"abc", 5.5 )


z : 5.5
z = Example2( 1,2 )
z : 3
z = Example3( 2 + j*3 )
z : (2, 3)
r = Example4( 2.5 , 5 )
r : 2.5

The following output displays in the Immediate window:

Example4
2.5
5
Example3
2
3
Example2
1
2
Example1
abc
5.5

Be careful when you work with Complex equations. The following example does not work:

Function Example (Y As Complex) As Complex


Example=Y
End Function

There is a bug in the scripting engine that prevents a return value from being returned correctly when you specify
'Complex' as the return type. The solution is to omit 'As Complex' in the function declaration so a complex data type is
returned correctly. (See Function Example3 in the previous example).

Note that arithmetic operations over complex data are not implemented, and Complex math operations must be done by
handling the Real and Imaginary components separately, as follows:

Sub ComplexAdd(X As Complex, Y As Complex) As Complex


ComplexAdd.Real = X.Real + Y.Real
ComplexAdd.Imaginary = X.Imaginary + Y.Imaginary
End Sub

The following script demonstrates another way to handle complex data:

Sub Main
Debug.Clear
Dim m As Measurement

API Scripting Guide 1565


Sweeper Object

Dim mm As Double
Set m = Project.Graphs(Graph 1".Measurements("k:Eqn")
CPoints = m.XpointCount
For i = 1 To cPoints
Debug.Printi;":";m.Xvalue(i)/1e9;vbTab;m.Yvalue(i,2)
Mm = Abs(m.Yvalue(i,2))
Next I
End Sub

Sweeper Object
The Swept Variable Wizard in the NI AWR SDE allows you to create measurements that are plotted not versus frequency,
but versus Element parameters or equations.

The Sweeper object sweeps parameters or equations that are added to the Sweeper object.

Dim sw As Sweeper
Dim e As Equation
Dim p As parameter
Set sw = MWOffice.Project.Sweeper
Set p = Project.Schematics(2).Elements(1).parameters(3)
Set e = Project.Schematics(2).Equations(3)
sw.AddVariable "swv", e ' adding equation
sw.AddVariable "swv", p 'adding parameter

Note that "swv" is the name used to refer to a particular parameter.

The following script gets an Instance of the Sweeper object from the Project. It gets a reference to the global equation
from the Project.GlobalEquations collection and adds the variable to the Sweeper named "MyLength", then loops through
double values from 1000 to 10,000, incremented by 100, and sweeps the variable by setting, as follows:

Sweeper.Value("MyLength") = <value>.
' Code Module
Sub Main
Dim Swp As Sweeper
Dim myLenVar As Equation
Dim i As Double
Set Swp = Project.Sweeper
Set myLenVar = Project.GlobalEquations("myLength")
Swp.AddVariable("MyLength", myLenVar)
i = 1000
While i < 10000
i = i + 1000
Swp.Value("MyLength") = i
Swp.Update(True, True)
Wend
End Sub

It is implied that the global equation is included in the Project,

MyLength = 1000

and that a Schematic with three transmission lines is tested, as shown in the following figure.

1566 NI AWR Design Environment


Sweeper Object

The length of the middle line depends on the global variable "myLength". If you simulate the Project, bring the Graph
forward, and run the script, you should see how the graph changes as the sweeper changes the variable value. Also, if
you view the Global Definitions window you can see the value in the equation changing.

API Scripting Guide 1567


Sweeper Object

The following example shows an alternative way of using the Sweeper object:

Sub Main
Debug.Clear
Dim sch As Schematic
Dim e As Element
Dim p As parameter
Set sch = Project.Schematics("Schematic 1")
Set e = sch.Elements(7)
Set p =e.parameters(3)
Debug.Print "Sweeping ";sch.Name;"->";e.Name;"->";p.Name
orgValue = p.ValueAsDouble
count = 2
startVal = 0
stopVal = 180
stepVal = (stopVal-startVal)/(count)
Project.Simulator.Analyze
With Project.Sweeper
.AddVariable("Par",p)
For i=0 To count
'Use the name to refer to a particular parameter

1568 NI AWR Design Environment


Working with System Diagrams

.Value("Par") = startVal + i*stepVal


Debug.Print i;": ";p.Name;" = ";.Value("Par")
'The first parameter tells if to update the parameter value on the 'schematic or not.
'The second parameter tells if to update the 'graphs or not
.Update(False,True)
Next i
.Value("Par") = orgValue
.Update(True,True)
End With
End Sub

Working with System Diagrams


The core object in the NI AWR SDE is the Project. From the Project object you can access the SystemDiagrams collection
of objects. The following code example finds each SystemDiagram in a Project (iterates through the whole collection of
SystemDiagram objects) and prints its name in the Immediate window:

Dim s As SystemDiagrams
For Each s In Project.SystemDiagrams
Debug.Print s.Name
Next s

You can access a specific SystemDiagram by name or by index, like each Element in a collection of objects:

Dim s As SystemDiagrams
Set s = Project. SystemDiagrams ("System Diagram 1")

or

Set s = Project. SystemDiagram (1)

This code assigns the SystemDiagram named "System Diagram 1" to the variable "s" ("s" is a reference to the
SystemDiagram named "System Diagram 1").

After you get a reference to a specific SystemDiagram object, you can perform actions such as the following on a
SystemDiagram:

Set Options for the SystemDiagram


CopyToClipboard
Export and Import SystemDiagram
Work with SystemDiagram Elements collection
Work with SystemDiagram Equations collection
PrintOut a particular SystemDiagram
Place SystemDiagram in a new Window
Work with the collection of SystemDiagram Wires objects

API Scripting Guide 1569


Working with System Diagrams

Specifying SystemDiagram Options


You can configure SystemDiagrams options for a particular SystemDiagram via the SystemDiagram object, or you can
use the default options set for all SystemDiagrams within a Project.

Configuring Local SystemDiagram Options

You can configure the SystemDiagrams options that control all specific settings for a particular SystemDiagram. You
can explore the whole collection of SystemDiagrams options and set a particular option to new value:

' Code Module


Sub Main
Dim sys As SystemDiagram
Dim opt As Option
Dim i As Long
Debug.Clear
i = 0
For Each sys In Project.SystemDiagrams
For Each opt In sys.Options
i = i+1
Debug.Print "i = ";i;vbTab;opt.Name &"="& opt.Value
Next opt
Next sys
End

This script example generates the following output:

i = 1 SampleRate=8
i = 2 DataBlockSize=1000
i = 3 StopTime=80
i = 4 TimeFrame=0.000000001
i = 5 OutputBufferSize=10000
i = 6 DefaultImpedance=-80
i = 7 SamplesPerMeasurement=2000
i = 8 DisplayFrequenciesAsReal=True
i = 9 DisplayFrequenciesUsingCarrrier=True
i = 10 DisplayTimeInTimeUnits=True
i = 11 NormalizeToTimeUnits=True
i = 12 WaveFormsStartFromZero=True
i = 13 AlignWaveFormsToData=True

The Sampling frequency and Symbol time values are accessible through the Options property on both the SystemDiagrams
and SystemDiagram objects. The Sampling frequency is calculated as:

DataRate = 1/TimeFrame

SamplePerSymbol * DataRate = 8 GHz

Likewise, the Symbol time is defined:

SymbolTime = 1/TimeFrame = 1ns

SamplesPerSymbol = SampleRate = 8

1570 NI AWR Design Environment


Working with System Diagrams

The value of SystemDiagram.UseProjectOptions (True/False) determines whether the value comes from the local system
diagram or the collection level options.

You can make modifications the same way you do for the Schematic collection of objects. The key to changing options
at the individual SystemDiagram level is to make sure the UseProjectDefaults property is set to "False". The following
is an example that sets options at the SystemDiagram level:

Set sys = Project.SystemDiagrams(1)


sys.UseProjectOptions = False
sys.Options("DataBlockSize").Value = 1000000

Creating or Importing a SystemDiagram


Creating a SystemDiagram

To create a SystemDiagram you need to use the Add method, which takes one argument, the name of the SystemDiagram
to add. The following code creates a new SystemDiagram named "System Diagram 1" and makes a reference to it:

Set sys = Project.SystemDiagrams.Add("System Diagram 1")

If a SystemDiagram named "System Diagram 1" already exists, a new SystemDiagram named "System Diagram11" is
created.

To delete an existing SystemDiagram by name, enter:

Project.Schematics.Remove("System Diagram 1")

Importing a SystemDiagram

To import an existing SystemDiagram to the Project, use the following code:

Project.SystemDiagrams.Import("import_SDiagr",Project.Path + "SysDiagr.sys")

This fragment of code finds the file (an imported SystemDiagram file has a *.sys extension) and adds the SystemDiagram
to the Project Browser under the name "import_SDiagr". Note that this method as well as the LinkTo method accepts a
Name under which to create the Project Browser node and File Path to the imported or linked file.

To link to the file that contains the SystemDiagram, use the following code:

Set sys = Project.SystemDiagrams.LinkTo("Link_To",Project.Path + "SysDiagr.sys")

This code adds a SystemDiagram object link to the collection from a file (a linked SystemDiagram file has a *.sys
extension) and returns a reference to the created object.

The Import method embeds the document into the Project, while the LinkTo method retains a reference and displays the
reference in the Project Browser node name.

You can also perform a Copy to Clipboard operation in the script by using the following CopyToClipboard method:

Project. SystemDiagrams ("System Diagram 1").CopyToClipboard

API Scripting Guide 1571


Working with System Diagrams

After completion of the script, the "System Diagram 1" system diagram is stored in the Clipboard.

Exporting a SystemDiagram

To export a SystemDiagram from the Project, use the following code:

Dim sys As SystemDiagram


Set sys = Project. SystemDiagrams ("SysDiagr")
sys.Export("C:\My6scripts\SystemDiagram\SysDiagr.sys",mwSYF_MWOSystemFile)

This code finds the SystemDiagram ("SysDiagr") and writes a SysDiagr.sys file to the directory ("C:\
My6scripts\SystemDiagram").

To create hard copies of a SystemDiagram, use the following code:

Project. SystemDiagrams ("System Diagram 1").PrintOut

Working with SystemDiagram Elements


Looking Through Elements

The NI AWR SDE allows you to browse through a comprehensive database of hierarchical groups of electrical models
used in SystemDiagrams, and print out all information about the model, such as Name, Description, Category, Symbol
name, Company name, and model Level. You can browse through the Elements manually with the Element Browser
(the System Blocks node) or programmatically via the NI AWR SDE.

The following script looks through all SystemDiagrams models.

' Code Module


Sub Main
On Error Resume Next 'Checking Model
Debug.Clear
Dim m As Model
Dim sys As SystemDiagram
Set sys = Project.SystemDiagrams("Test")
If sys Is Nothing Then
Set sys = Project.SystemDiagrams.Add("Test")
End If
For Each m In MWOffice.SystemModels
sys.Elements.Add(m.Name,0,0)
sys.Elements.Remove(1)
Debug.Print m.Name;vbTab;"Cat-ry = ";m.Category(1);vbTab;"Levels = ";
m.Levels;vbTab;"Module = ";m.Module;vbTab;"Symbol = ";
m.Symbol;vbTab;"Version = ";m.Version
Debug.Print "Company = ";m.Company;vbTab;"Description = ";
m.Description;vbTab;"HelpContext = ";m.HelpContext;vbTab;
"HelpFile =";m.HelpFile
Next m
Debug.Print MWOffice.SystemModels.Count
End Sub

The following is the portion of output generated by this script:

1572 NI AWR Design Environment


Working with System Diagrams

SMPLHLD Cat-ry = Signal Processing Levels = 2 Module = unknown


Symbol = SAMPLER@sys_block.syf Version = 1
Company = AWR Description = Sample and Hold HelpContext = 7353 HelpFile =
FDMUX Cat-ry = Sources Levels = 3 Module = unknown Symbol = FDMUX@SYS_BLOCK.SYF
Version = 1
Company = AWR Description = Maps input modulation to multicarrier output HelpContext = 0
HelpFile =
RN Cat-ry = Sources Levels = 3 Module = unknown Symbol = NOISE_1@sys_block.syf Version = 1
Company = AWR Description = Noisy resistor (matched to load) HelpContext = 0 HelpFile =
VN Cat-ry = Sources Levels = 3 Module = unknown Symbol = NOISE_1@sys_block.syf Version = 1
Company = AWR Description = Noise voltage HelpContext = 0 HelpFile =

You can also iterate through the SystemDiagram Elements Collection in the same way you iterate through the Schematic
Collection of objects.

Dim ele As Element


Dim sys As SystemDiagram
Debug.Clear
Set sys = Project.SystemDiagrams("System Diagram 1")
'Seeking for Elements
l = 0
For Each ele In sys.Elements
l=l+1
Debug.Print "Element ";l;": ";ele.Name;vbTab;"Symbol = ";ele.Symbol;
vbTab;ele.RotationAngle;vbTab;"x = ";ele.x;vbTab;"y = ";ele.y
Next ele

Working with the Elements Collection

You can perform the same operations with Elements programmatically that you can manually:

Adding Elements to a SystemDiagram at a determined position


Rotating and flipping Elements
Editing Element parameter values
Using variables and equations for parameter values
Making an Element Enabled and Selected
Working with the Nodes collection

Adding Elements to A SystemDiagram

When you have access to a SystemDiagram you can iterate through Elements and parameters collections as usual:

Sub Main
Dim ele As Element
Dim par As parameter
Dim s As SystemDiagram
Debug.Clear
Set s = Project.SystemDiagrams ("System Diagram 1")
'Seeking for Elements and for parameters
l = 0
For Each ele In s.Elements

API Scripting Guide 1573


Working with System Diagrams

l=l+1
Debug.Print "Element ";l;": ";ele.Name;vbTab;"Symbol = ";ele.Symbol;
vbTab;ele.RotationAngle;vbTab;"x = ";ele.x;vbTab;"y = ";ele.y
If ele.parameters.Count > 0 Then
k = 0
For Each par In s.Elements(l).parameters
k = k + 1
Debug.Print k;" : ";par.Name;vbTab;par.ValueAsString
Next par
End If
Debug.Print
Next ele
End Sub

The following is the portion of output generated by this script:

Element 1: BER.3 Symbol = BER_1@SYS_BLOCK.SYF 0 x = 3600 y = 500


1 : ID 3
2 : SWPVAR ES_N0
3 : SWPTYP ES_NO
4 : OUTFL ""
5 : OFLFMT 0
6 : EXISTS 1
7 : MNERR 10
8 : TBLKSZ 100
9 : MXTRL 1e5
10 : IGNR 0
11 : DLY
12 : NERRACT 0
13 : DETACT 0
14 : ERRFLR
Element 2: QAM_SRC.A1 Symbol = MODSIG_2@sys_block.syf 0 x = 1300 y = 500
1 : ID A1
2 : MOD 4
3 : OUTLVL ES_N0
4 : OLVLTYP 0
5 : RATE 1/_TFRAME
6 : CTRFRQ
7 : PLSTYP 0
8 : ALPHA 0.35
9 : PLSLN
10 : STRTTYP 0
11 : DTYP 0
12 : SMPSYM _SMPRATE
13 : BLKSZ _BLKSZ

To create a new SystemDiagram by adding all Elements, use the following script:

' Code Module


Sub Main
Dim sys As SystemDiagram
Dim syss As SystemDiagrams
Debug.Clear
Set syss = Project.SystemDiagrams
syss.Add("System Diagram 1")

1574 NI AWR Design Environment


Working with System Diagrams

Set sys = syss(1)


sys.Elements.Add("OQPSK_SRC",0,0)
sys.Elements.Add("TP",500,0,270)
sys.Wires.Add(0,0,500,0)
Set p = sys.Elements(1).parameters("OLVLTYP")
p.ValueAsDouble = 1
p.ValueAsString = "1"
Set p = sys.Elements(1).parameters("PLSTYP")
p.ValueAsDouble = 5
p.ValueAsString = "5"
sys.Elements(1).parameters("RATE").ValueAsDouble = 1e9
sys.Elements(1).parameters("SMPSYM").ValueAsString = "_SMPRATE"
End Sub

This script creates a new SystemDiagram named "System Diagram 1" and places two Elements on it.

Note that the Add method contains the x and y coordinates of the Element. In this example, Elements connect via a wire.
To connect Elements via wire you need to use the Wires collection of objects. In this script the following code makes a
connection:

sys.Wires.Add(0,0,500,0)

When setting a parameter using ValueAsDouble, the value must be in MKS units. In the following code the line sets the
value of the RATE parameter to 1Hz:

sys.Elements(1).parameters("RATE").ValueAsDouble=1

The correct form is either:

sys.Elements(1).parameters("RATE").ValueAsDouble=1e9 'for GHz

or

sys.Elements(1).parameters("RATE").ValueAsString="1e9"

API Scripting Guide 1575


Working with System Diagrams

You can Rotate and Flip Elements in SystemDiagrams the same way you do in a Schematic. You can also Enable and
Select an Element using Selected and Enabled properties.

Adding an Element to a System Diagram from the Library

To add a library Element, use the following script:

' Code Module


Sub Main
Dim ele As Element
Dim sysdiag As SystemDiagram
Set sysdiag = Project.SystemDiagrams(1)
pth = "BP:\System Blocks\Libraries\test\System Diagrams\AWGN1sys"
Set ele = sysdiag.Elements.AddLibraryElement(pth, 0, 0)
End Sub

Adding Different Kinds of Data to the Elements Collection

To add a Data File to the Element collection, use the following code:

1576 NI AWR Design Environment


Working with System Diagrams

Dim sys As SystemDiagram


Set sys = Project.SystemDiagrams("System Diagram 1")
sys.Elements.AddDataFile("C:\MyScripts\Test_Data\SGA-3586.s2p",True,True)

A new Element is added to the SystemDiagram "System Diagram 1" and a subnode named "SGA-3586" displays in the
Project Browser under the System Diagram 1 node.

To add a Subcircuit to the SystemDiagram Elements collection, use the following code:

Dim sysch As SystemDiagram


Set sysch = Project.SystemDiagrams.Add("SystemSubcircuit")
sysch.Elements.AddSubcircuit("Ideal filter",0,1000)

After running the code, a "SystemSubcircuit" subnode with a subnode named "Ideal filter" displays in the Project Browser.

To add a Model File to the SystemDiagram, use the following code:

Dim sys As SystemDiagram


Dim ele As Element
Dim mdlPath, xPath As String
Set sys = Project.SystemDiagrams(1)
Debug.Print sys.Name
mdlPath = "C:\mwo_1877\Library\Models\Nonlinear\GettingStarted\GBJT\BLT11_chip.mdl"
sys.Elements.AddModelFile(mdlPath, 0, 0)

After running the code, a Model displays in the SystemDiagram.

Adding Equations to SystemDiagrams


The Equations collection is described in Using Scripted Equation Functions. Like the Schematics collection of Objects,
you can refer to a variable in an Element parameter by specifying the variable name as its new value. After making this
reference you need to define the variable by creating equations for the SystemDiagram.

To create an equation for the SystemDiagram, use the following script:

' Code Module


Sub Main
Dim sys As SystemDiagram
Dim ss As SystemDiagrams
Dim i As Long
Debug.Clear
Set sys = Project.SystemDiagrams(2)
Debug.Print sys.Name
sys.Equations.Add("Eb_NO = sweep(stepped(0,9,1))",1000,-1000)
End Sub

After running the code, a new equation ("Eb_NO = sweep(stepped(0,9,1))" displays in the SystemDiagram(2). Note that
the Add method accepts the x and y coordinates of the equation.

Also note that if you assign an equation to an Element parameter, the units are set to MKS units on the system diagram.
The model receives the value from the equation in MKS units.

API Scripting Guide 1577


Working with System Diagrams

Working with the Nodes Collection


The following script is similar to the script example presented when working with the Nodes collection for Schematic
objects:

' Code Module


Sub Main
Dim objNode As Node
Dim objElem As Element
Dim objSys As SystemDiagram
Dim index As Integer
Debug.Clear
' Get a reference to our schematic
For Each objSys In Project.SystemDiagrams
Debug.Print "Processing SystemDiagram " & objSys.Name
' Setup the connectivity so the node numbers are established.
objSys.SetupConnectivity
' For Each element
For Each objElem In objSys.Elements
Debug.Print "Processing Nodes for " & objElem.Name
' Output the node information for this element.
index = 1
For Each objNode In objElem.Nodes
Debug.Print "Node Index = " & index
Debug.Print "Node Number = " & objNode.NodeNumber
Debug.Print "Port Number = " & objNode.PortNumber
Debug.Print "Node x = " & objNode.x
Debug.Print "Node y = " & objNode.y
index = index + 1
Debug.Print
Next objNode
Debug.Print
Next objElem
Next objSys
End Sub

This script generates the following output:

Processing SystemDiagram System Diagram 1


Processing Nodes for BER.3
Node Index = 1
Node Number = 5
Port Number = 0
Node x = 3600
Node y = 500
Processing Nodes for QAM_SRC.A1
Node Index = 1
Node Number = 1
Port Number = 0
Node x = 1300
Node y = 500
Node Index = 2
Node Number = 3
Port Number = 0
Node x = 1000

1578 NI AWR Design Environment


Working with System Diagrams

Node y = 900
Processing Nodes for AWGN.A2
Node Index = 1
Node Number = 1
Port Number = 0
Node x = 1600
Node y = 500
Node Index = 2
Node Number = 6
Port Number = 0
Node x = 2600
Node y = 500

Printing out the user attributes for all the system diagrams in the project
The following script writes the user attributes for all the system diagrams in the project:

Code Module
' This script prints the user attributes for all the system diagrams in the project
Sub Main
Dim ele As Element
Dim sys As SystemDiagram
Dim prop As Property
project_path=Project.Path
fn$=Project.Path & Replace(Project.Name,".emp","") & "_user_att.csv"

Debug.Print "System Diagram,Element Name,Id,Vd,Cost,Weight"


For Each sys In Project.SystemDiagrams
For Each ele In sys.Elements
id=" "
vd=" "
cost=" "
weight=" "
user_flag=0
For Each prop In ele.Properties
If InStr(prop.Name,"User") Then
user_flag=1
Select Case Replace(prop.Name,"User:","")
Case "Id"
id=prop.Value
ase "Vd"
vd=prop.Value
Case "Cost"
cost=prop.Value
Case "Weight"
weight=prop.Value
End Select
End If
Next prop
If user_flag=1 Then
Debug.Print sys.Name & "," & ele.Name & "," & id & "," & vd & "," & cost & "," &
End If
Next ele
Next sys
End Sub

API Scripting Guide 1579


Working with System Diagrams

Copying a SystemDiagram to a New Window


To Copy a SystemDiagram to new Window, use the following script:

' Copying SystemDiagram to a new Window


Sub Main
Debug.Clear
Set sys = Project.SystemDiagrams(2)
Debug.Print sys.Name
Dim w As Window
Set w = Project.SystemDiagrams(2).NewWindow(mwWT_SystemDiagram)
Debug.Print w.Caption
End Sub

This script generates the following output:

System Diagram 11
System Diagram 11:1

System Diagram sweepVariables collection


System Diagram sweepVariables collection reports about all sweep variables in the system diagram. To see this, use the
following script:

' Code Module


Sub Main
Debug.Clear
Dim s As SystemDiagram
Dim sv As SweepVariable

Set s = Project.SystemDiagrams("a")

Debug.Print s.SweepVariables.Count
For Each sv In s.SweepVariables
Debug.Print sv.Name & vbTab & sv.Values.Count
Next
End Sub

System Simulation via Script


To run and stop the system simulator, use the following script:

' Code Module


Sub Main
Debug.Clear
Dim i As Integer
Dim j As Integer
Dim pointCount As Double
Dim stopTime As Double
Dim curTime As Double
curTime = 0
stopTime = 3e-5

1580 NI AWR Design Environment


Working with System Diagrams

MWOffice.Activate
SendKeys("^0") ' Start the system simulator
While curTime < stopTime
Wait 5 'Check the time every 5 seconds
SendKeys("^9") ' Need to set "ctrl-9" as the pause/unpause System
'Sim hotkey
' The simulator needs to be paused for these next 'two commands,
' otherwise things could change in between the 'if' and the next 'command.
If Project.Graphs("SimTime").Measurements(1).XPointCount Then
curTime = Project.Graphs("SimTime").Measurements(1).XValue(1)
Debug.Print curTime
End If
SendKeys("^9") 'unpause the simulator
Wend
SendKeys("^0") 'Stop the system simulator
End Sub

NOTE: You can add hotkeys via the API, although the API is not designed for use by an external customization editor
so the settings are not remembered from one session to the next.

At times, you may run the system simulator, need to make changes in the system diagram, and then need to run the
system simulator again. The following script shows how to do this using events, and how to avoid a system simulation
loop:

' Project Module


Public need_sim

Private Sub Project_Open()


Debug.Clear

need_sim = True

Project.Simulator.Start

End Sub

Private Sub Project_AfterSystemSimulate()


Debug.Print need_sim
If need_sim = True Then
edit_element
need_sim=False
Project.Simulator.Start
End If
End Sub

Private Sub edit_element

Dim ele As Element


Dim par As Parameter
Dim sys As SystemDiagram

For Each sys In Project.SystemDiagrams


'Seeking for Elements and for Parameters
l = 0
For Each ele In sys.Elements

API Scripting Guide 1581


Working with System Diagrams

l=l+1
If ele.Parameters.Count > 0 Then
If ele.Name = "AMP_EQN.A2" Then

Debug.Print "Element ";l;": ";ele.Name;vbTab;"Symbol = ";ele.Symbol;vbTab;ele.RotationAng


k = 0
For Each par In sys.Elements(l).Parameters
k = k + 1
If par.Name = "VISAT" Then
Debug.Print par.ValueAsDouble
par.ValueAsDouble = 1.5
Debug.Print "After setting ";par.ValueAsDouble
Debug.Print k;" : ";par.Name;vbTab;par.ValueAsString
End If
If par.Name = "VSATSTART" Then
Debug.Print par.ValueAsDouble
par.ValueAsDouble = 1.5
Debug.Print "After setting ";par.ValueAsDouble
Debug.Print k;" : ";par.Name;vbTab;par.ValueAsString
End If
Next par
End If
End If
Debug.Print
Next ele
sys.Changed = True
Next sys
End Sub

We added a start-up state for the system simulator API. Because the systems simulator is started by posting a message
similarly to the way the UI starts it and the start method returns right after the message is posted it is possible for additional
API calls to be processed before the simulator moves into the running stage. This can result in getting a status of
mwSSS_Stopped prior to the simulator moving into the mwSSS_running stage. This is particularly true since to avoid
during startup the system simulator pumps waiting messages to preventing hanging any UI update events this can also
allow processing of API calls. We added an additional state mwSSS_Starting which will be set immediately in the
request to start the simulator. Once the simulator has transitioned to running the get simulator state will report running,
it will move the state into mwSSS_Running, then at some point in the future when the system simulator is stopped the
Simulator.State() call will return mwSSS_Stopped. This way the states will go immediately into starting and then
transition to running once the simulator is up and running.

With this approach the user can distinguish between three states (starting), (running) and (stopped). Often what is desired
especially with a cycle simulator such as the system simulator is to know when it is actually running. In this case the
transition from (starting) to (running) should provide the desired point. added an additional state mwSSS_Starting which
I place the Simulator.State() return value into immediately before returning. So when you do Simulator.Start() the only
two following values you should get are mwSSS_Starting or mwSSS_Running depending on how fast the simulator
starts. You should always get at least mwSSS_Starting, but if the simulator starts quickly the next call to get the state
may indicate that it is running.

So the program that wanted to do something while the simulator was running:

' Code Module


Sub Main

1582 NI AWR Design Environment


Working with System Diagrams

Project.Simulator.Start

While (Project.Simulator.State = mwSSS_Starting Or Project.Simulator.State = mwSSS_Running)


Wait(1)
Wend

MsgBox("Done!")

End Sub

Or another possible one would be something like::

' Code Module


Sub Main
Project.Simulator.Start

While (Project.Simulator.State = mwSSS_Starting)


Wait(1)
Wend

While(Project.Simulator.State = mwSSS_Running)
' Do stuff while running.
Wend

MsgBox("Done!")

End Sub

VSS Simulation Timing via Script


To count VSS simulation time, use the following script:

Dim t1 As Double
Dim t2 As Double

Private Sub Project_AfterSystemSimulate()


Dim t As Double
Dim fn As String

t2 = Timer
t = awr_timer(t1,t2)
fn = AWR_get_perf_file
Open fn For Append As #1
tks = Split(Project.Name,".")
Print #1, Chr(34) & tks(0) & "@sim_time" & Chr(34) & vbTab & t
Close #1
End Sub

Function awr_timer(tstart As Double, tstop As Double) As Double


tt = tstop-tstart
If tt lt 0 Then 'means had rollover at midnight.
tt = tt + 86400

API Scripting Guide 1583


Libraries Collection of Objects

End If
awr_timer = tt
End Function
Function AWR_get_perf_file() As String
Dim objFileSystem As Scripting.FileSystemObject
Set objFileSystem = New Scripting.FileSystemObject

bd = MWOffice.BuildNumber ' need to be able to get minor number, need that in the API.
'folder location
pth = MWOffice.Directories(2).ValueAsString & "\testresults\"
'pth = "C:\AWR_PerfLogs\"
'check to make sure path exists, more for testing than running code.
If objFileSystem.FolderExists(pth) = False Then
objFileSystem.CreateFolder(pth)
End If

fn = pth & "DesEnv_B" & MWOffice.BuildNumber & "_R" & MWOffice.BuildRevision & ".per"
If objFileSystem.FileExists(fn) = False Then
Open fn For Output As #1
Debug.Print """Name""" & vbTab &"""Time(s)$T"""
Close #1
End If
AWR_get_perf_file = fn
End Function

Libraries Collection of Objects


The NI AWR SDE provides access to the Libraries collection of objects. The following script iterates through the whole
collection of Libraries objects and through all Modules in the Libraries:

' Code Module


Sub Main
Dim mylib As Library
Debug.Clear

Set mylib=MWOffice.Libraries(1)

process_library mylib

End Sub
Sub process_library(mylib As Library)

Dim sublib As Library


Dim ele As LibraryElement
Debug.Print mylib.Name
For Each ele In mylib.LibraryElements
Debug.Print vbTab & ele.Name & " " & ele.BrowserPath
Next ele
For Each sublib In mylib.Libraries
process_library sublib
Next sublib

End Sub

1584 NI AWR Design Environment


Libraries Collection of Objects

The NI AWR SDE provides access to the Name and Browser path for the LibraryElement, and also to the Element
description and default Symbol name of the LibraryElement via collection of the attributes for the properties of
LibraryElement objects. The attributes collection can be used for the different library Element types (model, xml,
subcircuit, datafile) with attributes appropriate for the Element type.

The following script adds process library to the project: (The library .ini file should be at the same directory as the project)

' Code Module


Sub Main
Project.ProcessLibraries.AddLibrary("FSL_MRF7P20040H_Level2_Rev1",Project.Path+"FSL_MRF7P20040H_Le
End Sub

The following script also adds a new process library to the project from the example_pdks:

' Code Module


Sub Main
pth = Application.Directories(1).ValueAsString
pth = pth & "\Library\example_pdks\genbic35\Generic_GenBic35.ini"
Debug.Print pth
Project.ProcessLibraries.AddLibrary("cat", pth)
Debug.Print Project.ProcessLibraries(1).IniFilePath

Project.Schematics(1).Elements.AddLibraryElement("BP:\Circuit Elements\Libraries\*Generic Ge

End Sub

Note that in the previous example we use Application collection of objects to find out the path to the Directories collection
of objects. The Application collection of objects can also be used to get access to Files, Measurements, Models, and
System Models Collections of objects.

The following script adds a Library Element to the Global Definitions Document to demonstrate adding Elements by
Library browser path. This code adds a library Element to two separate Global Definition Documents and then checks
to see that they display correctly in the Data Elements collections for these Documents.

' Code Module


Sub Main
Dim doc As GlobalDefinitionDocument

For Each doc In Project.GlobalDefinitionDocuments


AddElementToDoc doc
Next doc

End Sub

Sub AddElementToDoc(ByRef doc As GlobalDefinitionDocument)


Dim elem As Element
Dim elem2 As Element
Dim schem As Schematic

Debug.Print "Processing Document: " & doc.Name

Debug.Print "Element Count before Add = " & doc.DataElements.Count

API Scripting Guide 1585


Libraries Collection of Objects

Set linelib = MWOffice.Application.Libraries("Circuit Elements").Libraries("Substrates")


Set libele = linelib.LibraryElements("MSUB")
Set elem = doc.DataElements.AddLibraryElement(libele.BrowserPath, 0, 0)

Debug.Print "Element Count after Add = " &doc.DataElements.Count

If elem Is Nothing Then


Debug.Print "Add failed to return valid element reference"
Else
Debug.Print "Add returned a valid element reference"
End If

If doc.DataElements.Exists(elem.Name) Then
Debug.Print "Element named " & elem.Name & " exists in the data elements collection."
Else
Debug.Print "Element named " & elem.Name & " not-found in the data elements collection."
End If

Set elem2 = doc.DataElements(elem.Name)


If elem2 Is Nothing Then
Debug.Print "Element named " & elem.Name & " lookup by name failed in data elements collection."
Else
Debug.Print "Element named " & elem.Name & " lookup by name succeeded in data elements collection
End If

End Sub

The following script shows AddLibraryElement method for placing elements based upon MDIF and GMDIF files to
schematic:

Project.Schematics(1).Elements.AddLibraryElement("BP:\Circuit Elements\Libraries\Test\WPP1530_PHEM

Project.Schematics(1).Elements.AddLibraryElement("BP:\Circuit Elements\Libraries\Test\WPP1530_PHEM

The following script creates a schematic that contains an XML schematic, exports the schematic and import back to the
project:

' Code Module


Sub Main
Dim schem_name As String
Dim schem As Schematic
Dim bp As String
Debug.Clear

bp = MWOffice.Libraries("Circuit Elements").Libraries("Libraries").Libraries("*Generic GenBic35").

schem_name = "Foundry_Lib_Cells"
Set schem = Project.Schematics.Add(schem_name)

schem.Elements.AddLibraryElement(bp, 0, 0)

schem.Export("\C:\User_Test\schem.sch")

1586 NI AWR Design Environment


Libraries Collection of Objects

Project.Schematics.Import("schem" , "C:\User_Test\schem.sch")

End Sub

The following script gets the browser path from the XML library element and add a library element to a schematic:

' Code Module


Option Explicit
Sub Main
Debug.Clear
Dim libs As Libraries
Dim bp As String
Dim pdkName As String

pdkName = "*AWR Module"

'Find the MWO Library


If(MWOffice.Libraries.Exists("Circuit Elements")) Then
Set libs = MWOffice.Libraries("Circuit Elements").Libraries("Libraries").Libraries(pdkName).Libr
Else
Set libs = MWOffice.Libraries("Libraries").Libraries(pdkName).Libraries
End If

'Get the browser path from the library element


bp = libs("Resistors").LibraryElements("10 Ohm").BrowserPath
Debug.Print "Browser Path ";vbTab; bp

'To add a library element to a schematic, you need a browser path


Project.Schematics("Res").Elements.AddLibraryElement(bp,0,0)
End Sub

The following script shows access to the installed process libraries. This allows the user to get a list of the libraries that
can be used with the API NewWithLibrary() call which creates a new project with an associated PDK library (the same
list under File > New With Library...):

' Code Module


Option Explicit
Sub Main
Dim procInfo As ProcessLibraryInfo

Debug.Clear
Debug.Print "Library Count = " & MWOffice.AvailableProcessLibraries.Count

For Each procInfo In MWOffice.AvailableProcessLibraries


Debug.Print procInfo.Name & ", " & procInfo.Version & ", " & procInfo.Description
Next procInfo
End Sub

Depending of what libraries are included the output can look as follows:

Library Count = 25

API Scripting Guide 1587


SwitchLists Collection of Objects

Generic_GenBic35, ~Unversioned, Generic BiCMOS 0.35u Process GenBic35


AWR_MESFET, ~Unversioned, AWR MESFET Example PDK
AWR_Module, ~Unversioned, Module Rogers 4003
AWR_PCB, ~Unversioned, 7 Layer PCB process
AWR_RFBoard_2layer_FR4, ~Unversioned, Simple RF Board Rogers FR4
AWR_RFBoard_2layer_RO4003, ~Unversioned, Simple RF Board Rogers 4003
AWR_RFBoard_2layer_RO4350, ~Unversioned, Simple RF Board Rogers 4350
OMMIC_D025PHS, 1.0.1.6, OMMIC D025PHS Design Kit
AWR Example PCB Process, 1.0.0, AWR Example PCB Process
TQOR_TQPED, 1.1.22.2, TriQuint Oregon TQPED Process
Jazz_sbc18h3, 2.0.2.21, Jazz sbc18h3 Process
Jazz_sbc18h3, 3.0.2.21, Jazz sbc18h3 Process
Jazz_SiGe120_SBC18HA, 0.1.26.1, Jazz SiGe120 SBC18HA Process
TQOR_TQHBT3, 1.1.13.23, TriQuint Oregon TQHBT3 Process
AWR_Test, 1.0.0, iNet Via Test PDK
TQTX_3MI25XKu, 7.2.26.3, TriQuint Texas 3MI25 XKu Process
TQTX_3MI25XKui, 7.2.26.3, TriQuint Texas 3MI25 XKu Process
TSMC_SG035, 0.2.32, TSMC SG035 Process (Beta)
Archive, 1.0.0, Archive PDK from Project Archive Script
EPCOS_TDK6L_LAM, 0.0.1.8, EPCOS TDK6L_LAM Design Kit
EPCOS_TDK6L_LAM, 0.0.1.9, EPCOS TDK6L_LAM Design Kit
TQ_BAW, 4.1.0, Triquint BAW Design Kit
WLANPA APLAC library, 1.0, Aplac native netlist
HRL_GaN_T4, 1.0.0.2, HRL Laboratories GaN T4 Design Kit
HRL_GaN_T4, 1.0.1.1, HRL Laboratories GaN T4 Design Kit

The following script shows access to ProcessLibraries API info:

' Code Module


Sub Main
Dim procLib As ProcessLibrary

Debug.Clear
For Each procLib In Project.ProcessLibraries
Debug.Print procLib.Name
Debug.Print procLib.IniFilePath
Debug.Print procLib.Version
Next procLib
End Sub

SwitchLists Collection of Objects


The NI AWR SDE provides API access to switch lists. Note that multiple view lists for a given named configuration is
not supported. The 'SwitchList' object has a name and a view list property. The view list property is a string array, use
it like this:

Dim newNames(3) As String


newNames(0) = "Red"
newNames(1) = "Blue"
newNames(2) = "Green"
Dim sl As SwitchList
Set sl = Project.SwitchLists.Add("NewList")

1588 NI AWR Design Environment


Scripting the NI AWR SDE Externally

sl.ViewNames = newNames

We can also remove SwitchList from the collection.

Scripting the NI AWR SDE Externally


Assigning an Object Reference using the CreateObject Function
You can use the CreateObject function in a Set statement to create a new object, and assign object reference to the object
variable. You must pass the object programmatic identifier as an argument to the function, and the object you want to
access must be externally creatable.

You can create scripts inside the NI AWR SDE as well as scripts in other programming languages, and run them outside
of the NI AWR SDE.

The following code example starts the NI AWR SDE (if it is not already running) and establishes the variable objMWO
to refer to an object of the Application class.

' Make a list of the models inside AWR SDE.


' Call Main Subroutine.
Main
' Main Subroutine, Create AWR SDE object and list models.
Sub Main
Dim objMWO
Dim Mdl
Dim Text
' Create an instance of MWOffice and set it visible
Set objMWO = WScript.CreateObject("MWOApp.MWOffice")
objMWO.Visible = True
Text = "Models:" & vbLF
' Compile a list of the models.
For Each Mdl In objMWO.Models
Text = Text & Mdl.Name & ", "
Next
' Display the models.
MsgBox Text
' Release the AWR SDE MWOffice object instance.
Set objMWO = Nothing
End Sub

The following script shows how to automate the consecutive simulation of more than one Project. This script may run
externally in a Visual Basic IDE.

Sub Main
Dim objMWO
Dim Mdl
Dim Text
Set objMWO = MWOffice.Application
objMWO.Visible = True
' Make a list of all project in TT directory - file_Names(num_files)
For i = 0 To num_files - 1
ObjMWO.Open (num_files(i))
For Each s In ObjMWO. Project.Schematics

API Scripting Guide 1589


Scripting the NI AWR SDE Externally

Debug. Print "Schematic ";s.Name


For Each e In s.Elements
Debug.Print "Element ";e.Name
Next e
Next s
ObjMWO. Close
Next i
Set ObjMWO. Visible = False
Set ObjMWO = Nothing
End Sub

Multiselect option for GetFilePath


You can use the Microsoft Office to display a multiselect file open dialog.

The following code is using Excel to display a multiselect file open dialog. We can use it for example to plot a lot of
files into MWOffice simultaneously:

' Code Module


Sub Main()
Dim excel As Object
excel = CreateObject("Excel.Application")

Dim fd As FileDialog
fd = excel.FileDialog(msoFileDialogFilePicker)
fd.AllowMultiSelect = True
fd.Show()

Debug.Print fd.SelectedItems(1)
Debug.Print fd.SelectedItems(2)
Debug.Print fd.SelectedItems(3)

End Sub

To use the code do not forget to reference to the Microsoft Office Object Library.

Creating Another Application


To create an Excel object inside the NI AWR SDE, use the following code:

' Script creates a bill-of-materials for each schematic in the project and exports the results to
' Requires Microsoft Excel be installed on the machine.
Sub Main
Dim schem As Schematic
Dim elem As Element
Dim excel As Object
Dim workBook As Object
Dim sheet As Object
Dim partNum As Object
' Create an instance of Excel
Set excel = CreateObject("Excel.Application")
excel.Visible = True
excel.Interactive = True
Set workBook = excel.Workbooks.Add()

1590 NI AWR Design Environment


Scripting the NI AWR SDE Externally

' Loop through all the schematics


For Each schem In Project.Schematics
' Add a new sheet for this schematic
Set sheet = workBook.Sheets.Add()
sheet.Name = schem.Name
sheet.Range("A1").FormulaR1C1 = "Part Number"
sheet.Range("B1").FormulaR1C1 = "Count"
sheet.Range("A1:B1").Font.Bold = True
' Loop over all the elements and sum the counts.
row = 2
For Each elem In schem.Elements
If (elem.PartNumber <> "") Then
Set partNum = sheet.Range("A2:A" + row).Find(elem.PartNumber)
If partNum Is Nothing Then
sheet.Range("A" + row).FormulaR1C1 = elem.PartNumber
sheet.Range("B" + row).FormulaR1C1 = 1
row = row + 1
Else
partRow = partNum.Row
sheet.Range("B" + partRow).FormulaR1C1 = sheet.Range("B" + partRow).FormulaR1C1 + 1
End If
End If
Next elem
' Fit the columns to the data we've entered.
sheet.Range("A1:B1").EntireColumn.AutoFit
Next schem
End Sub

Closing the Current Project and Opening Another Project


To close the current Project and open another Project, use the following script:

' Code Module


Sub Main
Debug.Clear
Dim ap As Application
Set ap = MWOffice.Application
Debug.Print ap.Caption;vbTab;"ControlBars.Count = ";ap.ControlBars.Count;vbTab;
"Libraries.Count = ";ap.Libraries.Count
' Some code to do
ap.Dispose
ap.Open("C:\My405Scripts\MWObject\"+"OddEven_Windows.emp")
' Some code to do
End Sub

Notice that you need to use an absolute path before calling Open.

To repeatedly open the NI AWRDE, execute commands, and then close the program, use the Quit method which posts
a CM_EXIT command message to the Application object:

MWOffice.Application.Quit

If the Project state is set as Saved, you can use Close to exit without saving a dirty Project. To run without the Save
Changes dialog box displaying, use the following script:

API Scripting Guide 1591


Scripting the NI AWR SDE Externally

' Code Module


Sub Main
' Add a schematic so the project becomes dirty.
Project.Schematics.Add("MySchematic")
' Now try to close without saving.
Project.Saved = True
Project.Close(False)
End Sub

Running Microwave Office from an Excel Macro


The following is an Excel macro that runs a script in a Project TestScript.emp:

Sub RunMWOScript()
Dim objMWO As MWOffice.Application

Set objMWO = New MWOffice.Application


objMWO.Open ("C:\Users\dupree\Documents\Scripts\TestScript.emp")
objMWO.Project.ProjectScripts("Module1").Routines("Main").Run

End Sub

Do not forget to add a reference from Excel to the AWR Design Environment Current Version ( for example v11.0) in
the References menu in Excel. After running this Macro in Excel the MWOffice script will be executed.

VB Express Program Loop through AWR Projects


This code opens every .emp file located in the Path specified by the Path variable. You may need to add object references
to the NI AWRDE and the Microsoft Scripting Runtime.

Module Module1
Dim objFileSystem As Scripting.FileSystemObject
Dim mwoffice2 As MWOffice.Application
Dim pathr As String

Sub Main()
'need to add a way for specific projects to be skipped meaning it is okay to have saved dat
objFileSystem = New Scripting.FileSystemObject
'start Microwave Office
mwoffice2 = CreateObject("AWR.MWOffice.10.0")
'mwoffice2 = CreateObject("AWR.MWOffice.9.0")

System.Threading.Thread.Sleep(5000) 'wait a few seconds

mwoffice2.TestMode = True
'MsgBox("make sure test mode is turned on in Microwave Office")
pathr = "C:\Subversion\buildtests\trunk\buildtests\Examples\60 Examples\Linear"
process(pathr)
End Sub
Sub process(ByVal nm As String)
Dim subFile As Scripting.File
Dim newFolder As Scripting.Folder
newFolder = objFileSystem.GetFolder(nm)

1592 NI AWR Design Environment


Scripting the NI AWR SDE Externally

For Each subFile In newFolder.Files


If InStr(subFile.Name, ".emp") Then
mwoffice2.Open(subFile.Path)
' Check_EM()
mwoffice2.Project.Close(False)
End If
Next subFile
End Sub

End Module

Creating a New Project


To create a New Project, use the following script:

Sub CreateAndSaveANewProject
MWOffice.New
Project.Name = "SomeName" ' Warn if bad name
' To do: Add some things to the project
Project.Save
End Sub

This script should reside under the Global node.

When creating a new Project, use MWOffice.New() instead of MWOffice.New(" "). Including a space in the file name
makes it invalid, and you cannot save the file.

Sub CreateAndSaveANewProject
Project.New
Project.Name = "SomeName" ' Warn if bad name
' Todo: Add some things to the project
Project.Save
End Sub

Working with NI AWR SDE MWOffice Object Properties


When working with the NI AWR SDE MWOffice object itself, you need to know that the methods and properties are
added to the global namespace for the application. You should be able to access the properties and methods directly
without qualifying them with the "MWOffice." prefix. This functions correctly unless there is a collision with a VBA
reserved word. For example, if you refer to the Count property, your referral is associated with the MWOffice.Windows
collection. To access the Count property, use the following code:

Debug.Print "Count=";MWOffice.Windows.Count
Debug.Print "Count=";Windows.Count
However if user writes the following
Debug.Print "Count=";Count

This code creates a new automatic variable named 'Count' which has no type and no value, so nothing is printed. Note
that variables do not need to be declared before they are used in Basic; new variables are automatically created as you
use them. You can avoid this problem by using the "Option Explicit" declaration at the top of the Basic file, which
requires all variables to be explicitly declared.

API Scripting Guide 1593


Working with the Windows Collection of Objects

The following is an example using the MWOffice.Left property, where in one place in the code "Left" there is a reference
to the MWOffice.Left property. Since Left is a keyword for a function in Basic, just referring to "Left" causes an interpreter
syntax error.

Debug.Print "Left=";Left ' Syntax Error, trying to call the Left() basic
'function without parentheses?
Debug.Print "Left=";MWOffice.Left ' Returns the left side of the window.

Setting the Size of the NI AWR SDE Window

To resize the NI AWR SDE Window, use the following code:

MWOffice.Width = 300
MWOffice.Height = 200

Working with the Windows Collection of Objects


Creating a Reference to a Window
To declare and set a reference to a Window, use the following code:

Dim hWn As Window


Set hWn = Windows(2).Previous

Remember to add 'Set' to the left-hand side of statement.

The Windows collection is a property of the NI AWR SDE MWOffice object, and all MWOffice object properties and
methods are included in the global namespace, so

Windows(2).Close

is the same as

MWOffice.Windows(2).Close

Note that the Windows collection, like most collections, has a default property called Item, which allows you to access
a specific window via index, so the expression

Windows(2).Close

is really equivalent to the full expression

MWOffice.Windows.Item(2).Close

The NI AWR SDE supports tiling the Windows collection in MWOffice using a tile method with an argument for direction
(vertical or horizontal):

1594 NI AWR Design Environment


Working with the Job Scheduler queues Collection of Objects

MWOffice.Windows.Tile(mwWTD_Horizontal)
MWOffice.Windows.Tile(mwWTD_Vertical)

Using the Window Collection Properties


To loop through the open Windows in the Project, use the following script:

Option Explicit
Sub Main
Dim wins As Windows
Dim win As Window
Dim hWn As Window
Dim hWnd As Long
Dim opt As Option
Debug.Clear
For Each win In Windows
Debug.Print win.Caption
Next win
Debug.Print "The window handle of the NI AWRDE main window = ";MWOffice.hWnd
End Sub

This script generates the following output:

Constellation
BER Table
BER
EM Lange
System Diagram 1
Schematic 1
The window handle of the NI AWR SDE main window = 2359432

To loop through the open Windows in the Project and print the Window type, use the following code:

MWOffice.Activate
Dim w As Window
For Each w In MWOffice.Windows
Debug.Print w.Caption; w.Type
Next w

Working with the Job Scheduler queues Collection of Objects


Accessing information about job scheduling queues
Code similar to the following can be used to access information about job scheduling queues:

' Code Module


Sub Main
Dim jq As JobQueue
Dim je As JobEntry
Dim attr As Attribute

API Scripting Guide 1595


Working with the Job Scheduler queues Collection of Objects

Debug.Clear
For Each jq In MWOffice.JobControlMonitor.Queues
Debug.Print "Name = " & jq.Name & " Local = " & jq.Local
Debug.Print "Entry Count = " & jq.Entries.Count
For Each je In jq.Entries
Debug.Print "Job #" & je.Id & ", Name = " & je.Name
Debug.Print " Status = " & je.Status
Debug.Print " Description = " & je.Description
Debug.Print " Project = " & je.Project
Debug.Print " Owner = " & je.Owner
Debug.Print " Start = " & je.StartTime
Debug.Print " HasStarted = " & je.HasStarted
Debug.Print " IsRunning = " & je.IsRunning
Debug.Print " HasEnded = " & je.HasEnded
Debug.Print " ExitCode = " & je.ExitCode
For Each attr In je.Details
Debug.Print " " & attr.Name & " = " & attr.Value
Next attr
Debug.Print ""
Next je
Debug.Print ""
Next jq
End Sub

API is providing access to job scheduler resources, for queues and job entries. It is also providing access to available job
queues defined in the settings and state of job entries in the job queues, (i.e. pending, running, completed). API allows
users to determine things like if simulation processes are still running or have been completed. JobQueue objects in the
JobMonitor can read the details for the ipc connection libraries and interfaces. Job queue details can indicate if the queue
is local or remote.

API provides some additional properties for JobEntry objects to check the state of the task. For example, HasStarted,
IsRunning, and HasEnded. There is also access to the Exit Code if the task has ended. Details attribute collection provides
a collection of name /value pairs of the detailed attributes available for each job entry.

API supports basic job control methods on JobEntry objects. These include pause, resume, and cancel. These methods
are from basic level of job management similar to what is available from the Job Monitor window.

The following example of code going through JobControlMonitor Queues collection of objects and counts
JobControlMonitor Queues with different methods of access:

Dim nQue1 As Integer


Dim nQue2 As Integer
Dim queue As JobQueue
Dim queue2 As JobQueue

nQue1 = MWOffice.JobControlMonitor.Queues.Count

nQue2 = 0
For Each queue In MWOffice.JobControlMonitor.Queues
nQue2 = nQue2 + 1
Next queue

' Check application queue access.


If nQue1 ne nQue2 Then

1596 NI AWR Design Environment


Working with Folders and Files Collection of Objects

Debug.Print "Application Queue Count Does not Match"


Else
Debug.Print "Application Queue Count Matches."
End If

' Check global queue access.


nQue2 = 0
For Each queue In JobControlMonitor.Queues
nQue2 = nQue2 + 1
Next queue

If nQue1 ne nQue2 Then


Debug.Print "Global Queue Count Does not Match"
Else
Debug.Print "Global Queue Count Matches."
End If

' Check for string index access.


nQue2 = 0
For Each queue In JobControlMonitor.Queues
Set queue2 = JobControlMonitor.Queues(queue.Name)
If (queue2 Is Nothing) Then
Debug.Print "Unable to access queue: " & queue.Name & " by string index"
Else
nQue2 = nQue2 + 1
End If
Next queue

If (nQue1 = nQue2) Then


Debug.Print "All queues string index accessible."
End If

' Check for exists string index.


nQue2 = 0
For Each queue In JobControlMonitor.Queues
If (Not JobControlMonitor.Queues.Exists(queue.Name)) Then
Debug.Print "Exist test failed for queue: " & queue.Name
Else
nQue2 = nQue2 + 1
End If
Next queue

If (nQue1 = nQue2) Then


Debug.Print "All queues string index accessible for exists function."
End If

Working with Folders and Files Collection of Objects


Accessing Folder information
Code similar to the following can be used to access information about Folder object of the File System structure :

' Code Module


Sub Main

API Scripting Guide 1597


Working with Folders and Files Collection of Objects

PrintFolderInfoDetails FileUtil.GetFolderInfo(Project.Path + "Dir1")

End Sub

Sub PrintFolderInfoDetails(ByRef fo As FolderInfo)


Dim fi As FileInfo
Dim sf As FolderInfo

Debug.Print " *** Folder Info *** "


Debug.Print "Folder Name = " & fo.Name
Debug.Print "Folder Exists = " & fo.FolderExists
Debug.Print "File Count = " & fo.Files.Count
Debug.Print "Folder Count = " & fo.Folders.Count

Debug.Print "Sub File Details:"


For Each fi In fo.Files
PrintFileInfoDetails(fi)
Next fi

If fo.Folders.Count > 0 Then


Debug.Print "Sub Folder Details:"
For Each sf In fo.Folders
PrintFolderInfoDetails sf
Next sf
End If

End Sub

Sub PrintFileInfoDetails(ByRef fi As FileInfo)


Debug.Print " File Name = " & fi.Name
Debug.Print " File Extension = " & fi.Extension
Debug.Print " File Exists = " & fi.FileExists
Debug.Print " Is Directory = " & fi.IsDirectory
Debug.Print " Is ReadOnly = " & fi.ReadOnly
Debug.Print ""

End Sub

Code similar to the following can be used to make a project not read-only:

' Code Module


Sub Main
Dim prjpth As String
Dim info As FileInfo

'Make project not Read-only, and save


prjpth = Project.Path & Project.Name
Set info = FileUtil.GetFileInfo(prjpth)
If (info.ReadOnly) Then
SetAttr(prjpth, 0) ' Clear attributes
End If

Project.Save

1598 NI AWR Design Environment


Working with Folders and Files Collection of Objects

End Sub

Deleting all Files in Folder


Code similar to the following can be used to access information about Folder object of the File System structure. Need
to have a reference to Microsoft Scripting Runtime Library:

' Code Module


Sub Main
Debug.Clear
Dim FO, currFolder As Object
Dim fi As File

Set FO = CreateObject( "Scripting.FileSystemObject")

Set currFolder = FO.GetFolder(Project.Path + "TEMP\ProjectName\")

If FO Is Nothing Then
MsgBox( "BrowseForFolder failed to get a folder",vbOkOnly, "Error Window")
Else
For Each fi In currFolder.Files
fi.Delete
Next fi
End If
End Sub

Using API file attribute classes to access file attributes for objects in the file utility
interfaces.
The following code can be used to access information of the File System structure attributes:

' Code Module


Sub Main

Dim bRet As Boolean


Dim fi As FileInfo

PrintFileInfoDetails(Project.Path + "File1.txt")
PrintFileInfoDetails(Project.Path + "File2.txt")
PrintFileInfoDetails(Project.Path + "File3.txt")
PrintFileInfoDetails(Project.Path + "Dir1")

End Sub

Sub PrintFileInfoDetails(filepath As String)


Dim fi As FileInfo
Dim fa As FileAttribute

Set fi = FileUtil.GetFileInfo(filepath)
Debug.Print "File Name = " & fi.Name
Debug.Print "File Extension = " & fi.Extension
Debug.Print "File Exists = " & fi.FileExists

API Scripting Guide 1599


Working with Folders and Files Collection of Objects

Debug.Print "Is Directory = " & fi.IsDirectory


Debug.Print "Is ReadOnly = " & fi.ReadOnly
Debug.Print "Attributes:"
For Each fa In fi.Attributes
If (fa.Name ne "NotIndexed") Then
Debug.Print " " & fa.Name & " = " & fa.Value
End If
Next fa
Debug.Print ""
End Sub

Using API methods to explore the browse for folder dialog.


In the following code we don't invoke the dialog, the code can be used to call each of the methods to get values:

' Code Module


Sub Main
Dim bffd As BrowseForFolderDialog

Set bffd = FileUtil.CreateBrowseForFolderDialog


bffd.Title = "Select Folder"
bffd.DirectoryPath = "C:\MyDirectory\MyFile.txt"
bffd.UseNewUI = True
bffd.EditBox = True
bffd.OnlyFileSystemDirs = True
bffd.ValidateEntry = True

PrintBrowseForFolderdetails bffd

End Sub

Sub PrintBrowseForFolderdetails(ByRef bffd As BrowseForFolderDialog)


Debug.Print "Browse For Folder Dialog Details"
Debug.Print "Title = " & bffd.Title
Debug.Print "Directory Path = " & bffd.DirectoryPath
Debug.Print "Browse For Comp = " & bffd.BrowseForComputer
Debug.Print "Browse For Printer = " & bffd.BrowseForPrinter
Debug.Print "Edit Box = " & bffd.EditBox
Debug.Print "Include Files = " & bffd.IncludeFiles
Debug.Print "Include URLs = " & bffd.IncludeURLs
Debug.Print "No New Folder Button = " & bffd.NoNewFolderButton
Debug.Print "Only File Sys Dirs = " & bffd.OnlyFileSystemDirs
Debug.Print "Status Text = " & bffd.StatusText
Debug.Print "Usage Hint = " & bffd.UsageHint
Debug.Print "Use New UI = " & bffd.UseNewUI
Debug.Print "Validate Entry = " & bffd.ValidateEntry
Debug.Print ""
End Sub

Using API methods to explore the browse for file path dialog.
In the following code we don't invoke the dialog, the code can be used to call each of the methods to get values:

1600 NI AWR Design Environment


Working with Folders and Files Collection of Objects

' Code Module


Sub Main
Dim fpd As FilePathDialog

Set fpd = FileUtil.CreateOpenFileDialog


fpd.Title = "Select File"
fpd.Filename = "C:\MyDirectory\MyFile.txt"
fpd.DefaultExtension = ".txt"
fpd.FileMustExist = True
fpd.AllowMultiSelect = True
fpd.Filters.Add("All Files", "*.*")
fpd.Filters.Add("Text Files", "*.txt")
fpd.Filters.Add("MWO Files", "*.emp")
fpd.FilterIndex = 2

PrintFilePathDialogDetails fpd

End Sub

Sub PrintFilePathDialogDetails(ByRef fpd As FilePathDialog)


Dim fe As FileFilterEntry
Dim fp As FilePathEntry

Debug.Print "File Path Details:"


Debug.Print "Title = " & fpd.Title
Debug.Print "Filename = " & fpd.Filename
Debug.Print "Allow Multi Select = " & fpd.AllowMultiSelect
Debug.Print "Default Extension = " & fpd.DefaultExtension
Debug.Print "Don't Add To Recent = " & fpd.DontAddToRecent
Debug.Print "Explorer Style = " & fpd.ExplorerStyle
Debug.Print "Extension is Different= " & fpd.ExtensionIsDifferent
Debug.Print "Extension offset = " & fpd.ExtensionOffset
Debug.Print "File Create Prompt = " & fpd.FileCreatePrompt
Debug.Print "File Must Exist = " & fpd.FileMustExist
Debug.Print "File Offset = " & fpd.FileOffset
Debug.Print "Filter Index = " & fpd.FilterIndex
Debug.Print "Hide Readonly = " & fpd.HideReadOnly
Debug.Print "Initial Directory = " & fpd.InitialDirectory
Debug.Print "No Change Directory = " & fpd.NoChangeDirectory
Debug.Print "No Places Bar = " & fpd.NoPlacesBar
Debug.Print "No Test File Create = " & fpd.NoTestFileCreate
Debug.Print "No Validate = " & fpd.NoValidate
Debug.Print "Overwrite Prompt = " & fpd.OverwritePrompt
Debug.Print "Path Must Exist = " & fpd.PathMustExist
Debug.Print "Read Only = " & fpd.ReadOnly

Debug.Print "Filter Entries: "


Debug.Print "Fitler Entry Count = " & fpd.Filters.Count
For Each fe In fpd.Filters
Debug.Print "Desc = " & fe.Name & ", Filter = " & fe.Filter
Next fe

Debug.Print "File Path Entries: "


Debug.Print "File Path Entry Count = " & fpd.FilePaths.Count
For Each fp In fpd.FilePaths
Debug.Print "File Path = " & fp.FullPath

API Scripting Guide 1601


Working with Folders and Files Collection of Objects

Next fp

End Sub

Using API Zip file Archive reader.


Creating a new Archive.

The following code creates a new archive, then opens the resulting archive and enumerates and outputing the contents:

' Code Module


Sub Main
Dim ar As ZipArchiveWriter
Dim zItem As ZipArchiveItem
Dim zItems As ZipArchiveItems

Dim arcPath As String


Dim bRet As Boolean
Dim fi As FileInfo

arcName = Project.Path + Left(Project.Name, Len(Project.Name)-4) + ".zip"

delete_if_exists(arcName)

Set ar = FileUtil.NewZipArchive(arcName)
If ar.IsValid Then
Debug.Print "Archive is Valid."
bRet = ar.AddFile(Project.Path + "File1.txt")
Debug.Print "Add File1.txt returned: " & bRet

bRet = ar.AddFile(Project.Path + "File2.txt")


Debug.Print "Add File2.txt returned: " & bRet

bRet = ar.AddFile(Project.Path + "File3.txt")


Debug.Print "Add File3.txt returned: " & bRet

bRet = ar.AddDirectory(Project.Path + "Dir1")


Debug.Print "Add Dir1 returned: " & bRet

ar.Close

Else
Debug.Print "Unable to create valid archive with name: " & arcName
End If

Set fi = FileUtil.GetFileInfo(arcName)
If fi.FileExists Then
Debug.Print "Successfully created archive output file."
Else
Debug.Print "Failed to create archive output file."
End If

Set zItems = FileUtil.OpenZipArchive(arcName)

If (zItems.Valid) Then

1602 NI AWR Design Environment


Working with Folders and Files Collection of Objects

Debug.Print "Successfully Opened archive input file."


Debug.Print "Archive Items:"
For Each zItem In zItems
Debug.Print "Name = " & zItem.Name
Debug.Print "Extension = " & zItem.Extension
Debug.Print "Comp Size = " & zItem.CompressedSize
Debug.Print "UnComp Size = " & zItem.UncompressedSize
Next zItem
Else
Debug.Print "Failed to open created archive file."
End If

End Sub

Accessing Zip reader attributes.

The following code is accessing the File attributes inside the zip Archive:

' Code Module


Sub Main

Dim ar As ZipArchiveWriter
Dim zItem As ZipArchiveItem
Dim zItems As ZipArchiveItems

Dim arcPath As String


Dim bRet As Boolean
Dim fi As FileInfo
Dim fa As FileAttribute

arcName = Project.Path + Left(Project.Name, Len(Project.Name)-4) + ".zip"

delete_if_exists(arcName)

Set ar = FileUtil.NewZipArchive(arcName)
If ar.IsValid Then
Debug.Print "Archive is Valid."
bRet = ar.AddFile(Project.Path + "File1.txt")
Debug.Print "Add File1.txt returned: " & bRet

bRet = ar.AddFile(Project.Path + "File2.txt")


Debug.Print "Add File2.txt returned: " & bRet

bRet = ar.AddFile(Project.Path + "File3.txt")


Debug.Print "Add File3.txt returned: " & bRet

bRet = ar.AddDirectory(Project.Path + "Dir1")


Debug.Print "Add Dir1 returned: " & bRet

ar.Close

Else
Debug.Print "Unable to create valid archive with name: " & arcName
End If

API Scripting Guide 1603


Working with Folders and Files Collection of Objects

Set fi = FileUtil.GetFileInfo(arcName)
If fi.FileExists Then
Debug.Print "Successfully created archive output file."
Else
Debug.Print "Failed to create archive output file."
End If

Set zItems = FileUtil.OpenZipArchive(arcName)

If (zItems.Valid) Then
Debug.Print "Successfully Opened archive input file."
Debug.Print "Archive Items:"
For Each zItem In zItems
Debug.Print "Name = " & zItem.Name
Debug.Print "Extension = " & zItem.Extension
Debug.Print "Comp Size = " & zItem.CompressedSize
Debug.Print "UnComp Size = " & zItem.UncompressedSize

Debug.Print "Attributes:"
For Each fa In zItem.Attributes
Debug.Print " " & fa.Name & " = " & fa.Value
Next fa
Next zItem
Else
Debug.Print "Failed to open created archive file."
End If
End Sub

This script adds the files File1.txt, File2.txt, File3.txt and Directory Dir1 to the zip archive. When a directory is added
to a zip archive all files and directories below the directory will also be added. That is, adding a directory recursively
adds the files and directories below it.

Adding contents with Zip writer.

The following code is for individual zip file operations that confirms the contents of the resulting zip file. The code
incorporates both the zip file reader and writer to create archives using the writer commands and then opens and reads
the contents to verify correct construction for each type of zip file:

' Code Module


Sub Main
Dim ar As ZipArchiveWriter
Dim zItem As ZipArchiveItem
Dim zItems As ZipArchiveItems

Dim arcPath As String


Dim bRet As Boolean
Dim fi As FileInfo

arcName = Project.Path + Left(Project.Name, Len(Project.Name)-4) + ".zip"

delete_if_exists(arcName)

Set ar = FileUtil.NewZipArchive(arcName)
If ar.IsValid Then

1604 NI AWR Design Environment


Working with Folders and Files Collection of Objects

Debug.Print "Archive is Valid."

bRet = ar.AddContents(Project.Path + "Dir1")


Debug.Print "Add Contents Dir1 returned: " & bRet

ar.Close

Else
Debug.Print "Unable to create valid archive with name: " & arcName
End If

Set fi = FileUtil.GetFileInfo(arcName)
If fi.FileExists Then
Debug.Print "Successfully created archive output file."
Else
Debug.Print "Failed to create archive output file."
End If

Set zItems = FileUtil.OpenZipArchive(arcName)

If (zItems.Valid) Then
Debug.Print "Successfully Opened archive input file."
Debug.Print "Archive Items:"
For Each zItem In zItems
Debug.Print "Name = " & zItem.Name
Debug.Print "Extension = " & zItem.Extension
Debug.Print "Comp Size = " & zItem.CompressedSize
Debug.Print "UnComp Size = " & zItem.UncompressedSize
Next zItem
Else
Debug.Print "Failed to open created archive file."
End If
End Sub

Adding directory with Zip writer.

The following code is adding a directory with Zip writer:

' Code Module


Sub Main
Dim ar As ZipArchiveWriter
Dim zItem As ZipArchiveItem
Dim zItems As ZipArchiveItems

Dim arcPath As String


Dim bRet As Boolean
Dim fi As FileInfo

arcName = Project.Path + Left(Project.Name, Len(Project.Name)-4) + ".zip"

delete_if_exists(arcName)

Set ar = FileUtil.NewZipArchive(arcName)
If ar.IsValid Then
Debug.Print "Archive is Valid."

API Scripting Guide 1605


Working with Folders and Files Collection of Objects

' Add directory and its contents.


bRet = ar.AddDirectory(Project.Path + "Dir1")
Debug.Print "Add Dir1 returned: " & bRet

ar.Close

Else
Debug.Print "Unable to create valid archive with name: " & arcName
End If

Set fi = FileUtil.GetFileInfo(arcName)
If fi.FileExists Then
Debug.Print "Successfully created archive output file."
Else
Debug.Print "Failed to create archive output file."
End If

Set zItems = FileUtil.OpenZipArchive(arcName)

If (zItems.Valid) Then
Debug.Print "Successfully Opened archive input file."
Debug.Print "Archive Items:"
For Each zItem In zItems
Debug.Print "Name = " & zItem.Name
Debug.Print "Extension = " & zItem.Extension
Debug.Print "Comp Size = " & zItem.CompressedSize
Debug.Print "UnComp Size = " & zItem.UncompressedSize
Next zItem
Else
Debug.Print "Failed to open created archive file."
End If
End Sub

Adding File with Zip writer.

The following code is adding a File with Zip writer:

' Code Module


Sub Main
Dim ar As ZipArchiveWriter
Dim zItem As ZipArchiveItem
Dim zItems As ZipArchiveItems

Dim arcPath As String


Dim bRet As Boolean
Dim fi As FileInfo
arcName = Project.Path + Left(Project.Name, Len(Project.Name)-4) + ".zip"

delete_if_exists(arcName)

Set ar = FileUtil.NewZipArchive(arcName)
If ar.IsValid Then
Debug.Print "Archive is Valid."
bRet = ar.AddFile(Project.Path + "File1.txt")

1606 NI AWR Design Environment


Working with Folders and Files Collection of Objects

Debug.Print "Add File1.txt returned: " & bRet

bRet = ar.AddFile(Project.Path + "File2.txt")


Debug.Print "Add File2.txt returned: " & bRet

bRet = ar.AddFile(Project.Path + "File3.txt")


Debug.Print "Add File3.txt returned: " & bRet

ar.Close

Else
Debug.Print "Unable to create valid archive with name: " & arcName
End If

Set fi = FileUtil.GetFileInfo(arcName)
If fi.FileExists Then
Debug.Print "Successfully created archive output file."
Else
Debug.Print "Failed to create archive output file."
End If

Set zItems = FileUtil.OpenZipArchive(arcName)

If (zItems.Valid) Then
Debug.Print "Successfully Opened archive input file."
Debug.Print "Archive Items:"
For Each zItem In zItems
Debug.Print "Name = " & zItem.Name
Debug.Print "Extension = " & zItem.Extension
Debug.Print "Comp Size = " & zItem.CompressedSize
Debug.Print "UnComp Size = " & zItem.UncompressedSize
Next zItem
Else
Debug.Print "Failed to open created archive file."
End If
End Sub

Creating Archive Output File.

The following code is creating an Archive Output File:

' Code Module


Sub Main
Dim ar As ZipArchiveWriter
Dim arcPath As String
Dim bRet As Boolean
Dim fi As FileInfo

arcName = Project.Path + Left(Project.Name, Len(Project.Name)-4) + ".zip"

delete_if_exists(arcName)

Set ar = FileUtil.NewZipArchive(arcName)
If ar.IsValid Then
Debug.Print "Archive is Valid."

API Scripting Guide 1607


Working with Design Notes Collection of Objects

bRet = ar.AddFile(Project.Path + "File1.txt")


Debug.Print "Add File1.txt returned: " & bRet

bRet = ar.AddFile(Project.Path + "File2.txt")


Debug.Print "Add File2.txt returned: " & bRet

bRet = ar.AddFile(Project.Path + "File3.txt")


Debug.Print "Add File3.txt returned: " & bRet

bRet = ar.AddDirectory(Project.Path + "Dir1")


Debug.Print "Add Dir1 returned: " & bRet

ar.Close

Else
Debug.Print "Unable to create valid archive with name: " & arcName
End If

Set fi = FileUtil.GetFileInfo(arcName)
If fi.FileExists Then
Debug.Print "Successfully created archive output file."
Else
Debug.Print "Failed to create archive output file."
End If
End Sub

Working with Design Notes Collection of Objects


Accessing Design Notes information
The AWR NI SDE allows a number of methods of working with DesignNotes Collection of objects. You can access to
the design notes and their contents, import an external TRF file, export a design note and then import the result, and open
and access a window associated with a design note object.

Code similar to the following can be used to access Design Notes information:

' Code Module


Sub Main
Dim dn As DesignNote

For Each dn In Project.DesignNotes

PrintDesignNoteDetails dn

Next dn

End Sub

Sub PrintDesignNoteDetails(ByRef dn As DesignNote)


Dim dn2 As DesignNote

Debug.Print "Design Note Details:"


Debug.Print "Name = " & dn.Name
Debug.Print "Content = " & dn.Content

1608 NI AWR Design Environment


Working with Design Notes Collection of Objects

Debug.Print "Modified = " & dn.Modified


Debug.Print "ReadOnly = " & dn.ReadOnly

If Project.DesignNotes.Exists(dn.Name) Then
Debug.Print "Design Note exists by name succeeded"
Else
Debug.Print "Design Note exists by name failed"
End If

Set dn2 = Project.DesignNotes(dn.Name)

If dn2 Is Nothing Then


Debug.Print "Design Note lookup by name failed"
Else
Debug.Print "Design Note lookup by name succeeded"
End If
End Sub

Exporting/ Importing Design Notes information


Code similar to the following can be used to Export / Import Design Notes information:

' Code Module


Sub Main
Dim dn As DesignNote
Dim fname As String

fname = Project.Path + "ExportRTF.rtf"

delete_if_exists(fname)

Project.DesignNotes(1).Export(fname)

If FileUtil.GetFileInfo(fname).FileExists Then
Debug.Print "Design Note Export Succeeded"
Else
Debug.Print "Design Note Export Failed
End If

Project.DesignNotes(1).Import(fname)

For Each dn In Project.DesignNotes


PrintDesignNoteDetails dn
Next dn

End Sub

Code for PrintDesignNoteDetails(ByRef dn As DesignNote) is similar to the code example above

Accessing Design Notes window


Code similar to the following can be used to access Design Notes Window:

API Scripting Guide 1609


Working with Design Notes Collection of Objects

' Code Module


Sub Main
Dim dn As DesignNote
Dim win As Window
Dim win2 As Window

Set dn = Project.DesignNotes(1)
Set win = dn.NewWindow

Debug.Print "Windows count = " & dn.Windows.Count


Debug.Print "Window Caption = " & win.Caption

If dn.Windows.Exists(win.Caption) Then
Debug.Print "Window exists by name succeeded"
Else
Debug.Print "Window exists by name failed"
End If

Set win2 = dn.Windows(win.Caption)


If win2 Is Nothing Then
Debug.Print "Window lookup by name failed"
Else
Debug.Print "Window lookup by name succeeded"
End If

win.Close

End Sub

The following is the API method on window object to center a window relative to its parent window. This can be used
to center a MDI child window relative to the MDI client area of the AWR DE. For example the following code could be
used to open a Design Note window. Ensure it is the active (front) window and then center that window in the MDI client
area of the AWR DE:

Dim win As Window

Set win = Project.DesignNotes(1).NewWindow


win.Activate
win.Center

Accessing path property to the ScriptModule object in the API.


It can be used to access the path for the file of a script module (assuming it was loaded from a file). The following example
lists the name followed by the path for each script module in the global scripts collection. With this property the path to
the script module file can be accessed in the following way:

' Code Module


Sub Main
Dim sm As ScriptModule

For Each sm In MWOffice.GlobalScripts

1610 NI AWR Design Environment


Working with Wizards via the API

Debug.Print sm.Name &amp;amp;amp;amp; ", " &amp;amp;amp;amp; sm.Path


Next sm
End Sub

This script prints the script module name followed by the path for each script module in the global scripts collection.

Working with Wizards via the API


Working with Wizards via the API
The NI AWR SDE API allows you to access the Wizards collection. You can create and run Wizards, and see Wizard
names, and Wizard type libraries using the Description property.

OpenAccess Import/Export Wizard

This tool allows importing and exporting individual schematics and project symbols from/to ADS and Virtuoso OpenAccess
databases. See OpenAccess Import/Export Wizard for more information.

The NI AWRDE API has support for the OpenAccess Import/Export Wizard. In a script, prepare to use the wizard with
the following code:

Dim wiz As MWOffice.OAWiz

Set wiz = Project.WizardDocs.CreateNew("OpenAccess Import/Export", False)

Methods available on the wiz object:

Method Return Value Description


GetOption(OptionName) Value Get the value of option
OptionName. (See list
of options below.)
PutOption(OptionName, none Set the value of option
Value) OptionName to Value.
(See list of options
below.)
Import(OADirectory) none Import an OpenAccess
object using the current
options.
Import2(OALibDefsFile) none Import an OpenAccess
object using the current
options. Specify full
path to library
definitions file.
Export(OADirectory) none Export an OpenAccess
object using the current
options.
Export2(OALibDefsFile) none Export an OpenAccess
object using the current

API Scripting Guide 1611


Working with Wizards via the API

Method Return Value Description


options. Specify full
path to library
definitions file.
OaLibCount() Count Get the number of
libraries referenced by
the OpenAccess library
definitions file.
OaLibName(Index) Name Get the name of a
library referenced by
the OpenAccess library
definitions file by
index. Parameter Index
is one-based.
OaLibNameList() Name Array Get list of names of
libraries referenced by
the OpenAccess library
definitions file.
OaLibCellCount() Count Get the number of cells
in an OpenAccess
library that have the
specified view
(schematic or symbol).
OaLibCellName(Index) Name Get the name of the cell
with the specified view
by index from an
OpenAccess library.
Parameter Index is
one-based.
OaLibCellNameList() OaLibCellNameList() Get list of names of the
cells with the specified
view from an
OpenAccess library.

Settings that can be configured or queried using the PutOption and GetOption methods:

Option Name Default Value Description


AwrDocName Name of AWRDE
document to create on
import or export from.
AwrDocType 0 Determines the OA cell
view: 0 -> Symbol, 1
-> Schematic.
DataFileDir The directory name to
insert at the beginning
of the DataFile
parameter string of any

1612 NI AWR Design Environment


Working with Wizards via the API

Option Name Default Value Description


NPORT_F elements on
export.
EvalExprs True The "Export evaluated
expressions" option.
Hierarchy True The "Descend into
hierarchy" option.
OACellName Name of OpenAccess
cell.
OADatabaseType 0 Dialect of OpenAccess
database: 0 -> ADS,
1-> Virtuoso.
OADirectory Location of lib.defs or
cds.lib file that defines
the OA library.
OALibDefsFile Full path to library
definitions file.
(Specify this or
OADirectory before
accessing lib or cell
names/counts.)
OALibraryName Name of OpenAccess
library.

API Scripting Guide 1613


Working with Wizards via the API

1614 NI AWR Design Environment


AWR Design Environment Component API
Introduction
Because AWR Design Environment Is designed As an Object-oriented Application, its underlying Object Model can be
exposed via an Application Programming Interface (API).

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 Or
Java Script) 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 And Wizards appear As groups In the AWR Design
Environment design environment's Project View.

Objects List
Object Name Description
Annotation A MWOffice Annotation object.
Annotations A collection of MWOffice Annotation objects.
Application The MWOffice application object.
Argument An MWOffice Argument object.
Arguments A collection of MWOffice Argument objects.
Attribute An MWOffice Attribute object.
Attributes A collection of MWOffice Attribute objects.
AutoSearchMarker An MWOffice AutoSearchMarker Object.
Axes A collection of MWOffice Axis objects.
Axis An MWOffice Axis object.
Boundary An MWOffice Boundary object.
BoundaryModel An MWOffice BoundaryModel object.
BrowseForFolderDialog An MWOffice BrowseForFolderDialog object.
BundleBit An MWOffice BundleBit object.
BundleBits A collection of MWOffuce BunldeBit objects.
BundleBus An MWOffice BundleBus object.
BundleBuses A collection of MWOffice BundleBus objects.
BundleInfo An MWOffice BundleInfo object.
BundleInfos A collection of MWOffice BundleInfo objects.
BusNetName An MWOffice BusNetName object.
BusNetNames A collection of MWOffice BusNetName objects.
CSelectFilters A collection of MWOffice SelectFilter objects.
Cell An MWOffice Cell object.
CellEditor An MWOffice CellEditor object.

API Scripting Guide 21


Objects List

Object Name Description


CellEditors A collection of MWOffice CellEditor objects.
CellInfo A MWOffice CellInfo object.
CellInstance An MWOffice CellInstance object.
CellInstances A collection of MWOffice CellInstance objects.
CellLibraries A collection of MWOffice Cell Library objects.
CellLibrary An MWOffice Cell Library object.
CellMapping An MWOffice CellMapping object.
CellMappings A collection of MWOffice CellMapping objects.
Cells A collection of MWOffice Cell objects.
Command An MWOffice Command object.
CommandTable An MWOffice CommandTable object.
CommandTables A collection of MWOffice CommandTable objects.
Commands A collection of MWOffice Command objects.
ComplexNumber A MWOffice ComplexNumber object.
ComplexNumbers A collection of MWOffice ComplexNumber objects.
ComponentTest A MWOffice ComponentTest object.
ComponentTests A collection of ComponentTest objects.
ConnectionRule A MWOffice ConnectionRule object.
ConnectionRules A collection of MWOffice ConnectionRule objects.
ConnectivityHighlighter An MWOffice ConnectivityHighlighter object.
ControlBar An MWOffice ControlBar object.
ControlBarItem An MWOffice ControlBarItem object.
ControlBarItems A collection of MWOffice ControlBarItem objects.
ControlBars A collection of MWOffice ControlBar objects.
CrossoverRule A MWOffice CrossoverRule object.
CrossoverRuleEntries A collection of MWOffice CrossoverRuleEntry objects.
CrossoverRuleEntry A MWOffice CrossoverRuleEntry object.
CrossoverRules A collection of MWOffice CrossoverRule objects.
CursorInfo A MWOffice CursorInfo object.
DRCErrorShape An MWOffice DRCErrorShape object, for use with DRC/LVS error types that
have multiple shapes (like mwDRT_MultiPolygon)
DRCErrorShapes A collection of MWOffice DRCErrorShape objects.
DRCErrorsWindow An MWOffice DRCErrorsWindow object.
DataFile An MWOffice Datafile object.
DataFiles A collection of MWOffice Datafile objects.
DataSet An MWOffice DataSet object.
DataSetFolder An MWOffice DataSetFolder object.

22 NI AWR Design Environment


Objects List

Object Name Description


DataSetFolders A collection of MWOffice DataSetFolder objects.
DataSetProperties A collection of MWOffice DataSetProperty objects.
DataSetProperty An MWOffice DataSetProperty object.
DataSets A collection of MWOffice DataSet objects.
DesignNote An MWOffice DesignNote object.
DesignNotes A collection of MWOffice DesignNote objects.
DesignRule An MWOffice DesignRule object.
DesignRuleChecker An MWOffice DesignRuleChecker object.
DesignRuleError An MWOffice DesignRuleError object.
DesignRuleErrors A collection of MWOffice DesignRuleError objects.
DesignRules A collection of MWOffice DesignRule objects.
DisplayPrecision A MWOffice DisplayPrecision object.
DrawingArcSegment An MWOffice DrawingArcSegment object.
DrawingArcSegments A collection of DrawingArcSegment objects.
DrawingLayer An MWOffice Drawing Layer object.
DrawingLayers A collection of MWOffice Drawing Layer objects.
DrawingObject An MWOffice DrawingObject.
DrawingObjects A collection of MWOffice DrawingObjects.
DrawingSegment An MWOffice DrawingSegment object.
DrawingSegments A collection of MWOffice DrawingSegment objects.
DrawingShape An MWOffice DrawingShape object.
DrawingShapes A collection of MWOffice DrawingShape objects.
DrawingSubObject An MWOffice DrawingSubObject object.
DrawingSubObjects A collection of MWOffice DrawingSubObject objects.
DrillTool An MWOffice DrillTool object.
DrillTools A collection of MWOffice DrillTool objects.
EM3DStructure A MWOffice EM3DStructure object.
EM3DStructures A collection of EM3DStructure objects.
EMInitializationRecord A MWOffice EMInitializationRecord object.
EMLayerMapEntries A collection of MWOffice EMLayerMapEntry objects.
EMLayerMapEntry An MWOffice EMLayerMapEntry object.
EMLayerMapping An MWOffice EMLayerMapping object.
EMLayerMappings A collection of MWOffice EMLayerMapping objects.
EMPort A MWOffice EMPort object.
EMPortTermination A MWOffice EMPortTermination object.
EMPortTerminations A collection of MWOffice EMPortTermination objects.
EMPorts A collection of MWOffice EMPort objects.

API Scripting Guide 23


Objects List

Object Name Description


EMStructure An MWOffice EMStructure object.
EMStructureInfo An MWOffice EMStructure Info object.
EMStructures A collection of MWOffice EMStructure objects.
EMail A MWOffice EMail object.
EditHandle An MWOffice EditHandle object.
EditHandles A collection of MWOffice EditHandle objects.
ElectricalNets A collection of MWOffice Element objects consisting of only the schematic
electrical nets
Element An MWOffice Element object.
Elements A collection of MWOffice Element objects.
EmbeddedDesign A MWOffice EmbeddedDesign object.
EmbeddedDesigns A collection of MWOffice EmbeddedDesign objects.
Enclosure An MWOffice Enclosure object.
Equation An MWOffice Equation object.
EquationExpression A MWOffice EquationExpression object.
EquationExpressions A Collection of EquationExpression objects.
Equations A collection of MWOffice Equation objects.
Extent An MWOffice Extent object.
Extents A collection of MWOffice Extent objects.
ExternalEditor A MWOffice ExternalEditor object.
Face An MWOffice Face object.
Faces A collection of MWOffice Face objects.
FileAttribute An MWOffice FileAttribute object.
FileAttributes A collection of FileAttribute objects.
FileFilterEntries A Collection of MWOffice FileFilterEntry objects.
FileFilterEntry A MWOffice FileFitlerEntry object.
FileInfo A MWOffice FileInfo object.
FileInfos A collection of MWOffice FileInfo objects.
FilePathDialog A MWOffice FilePathDialog object.
FilePathEntries A collection of MWOffice FilePathEntry objects.
FilePathEntry A MWOffice FilePathEntry object.
FileUtil An MWOffice FileUtil object.
FlightLine An MWOffice FlightLine object.
FlightLines A collection of MWOffice FlightLine objects.
FolderInfo A MWOffice FolderInfo object.
FolderInfos A collection of MWOffice FolderInfo objects.
FontInfo An MWOffice FontInfo object.

24 NI AWR Design Environment


Objects List

Object Name Description


FontInfos A collection of MWOffice FontInfo objects.
Frequencies A collection of MWOffice Frequency objects.
Frequency An MWOffice Frequency object.
GlobalDefinitionDocument A MWOffice GlobalDefinitionDocument object.
GlobalDefinitionDocuments A collection of GlobalDefinitionDocument objects.
Goal An MWOffice Goal object.
Graph An MWOffice Graph object.
Graphs A collection of MWOffice Graph objects.
GroupDrawingObjects A collection of MWOffice GroupDrawingObject objects.
Hotkey An MWOffice Hotkey object.
HotkeyTable An MWOffice HotkeyTable object.
HotkeyTables A collection of MWOffice HotkeyTable objects.
Hotkeys A collection of MWOffice Hotkey objects.
JobEntries A collection of JobEntry objects.
JobEntry A MWOffice JobEntry object.
JobMonitor A MWOffice JobMonitor object.
JobQueue A MWOffice JobQueue object.
JobQueues A collection of JobQueue objects.
JobSchedulerQuery A MWOffice JobSchedulerQuery object.
LVSError An MWOffice LVSError object.
LVSErrors A collection of MWOffice LVSError objects.
LVSErrorsWindow An MWOffice DRCErrorsWindow object.
LVSNetHighlight An MWOffice NetlistHighlight object.
LVSNetHighlights A collection of MWOffice NetlistHighlight objects.
LVSSchemHighlight An MWOffice SchematicHighlight object.
LVSSchemHighlights A collection of MWOffice SchematicHighlights objects.
LayerExportEntries A collection of MWOffice LayerExportEntry objects.
LayerExportEntry An MWOffice LayerExportEntry object.
LayerExportMapping An MWOffice LayerExportMapping object.
LayerExportMappings A collection of MWOffice LayerExportMapping objects.
LayerMapEntries A collection of MWOffice LayerMapEntry objects.
LayerMapEntry An MWOffice LayerMapEntry object.
LayerMapping An MWOffice LayerMapping object.
LayerMappings A collection of MWOffice LayerMapping objects.
LayerSetup An MWOffice LayerSetup object.
Layout An MWOffice Layout object.
LayoutCell An MWOffice LayoutCell object.

API Scripting Guide 25


Objects List

Object Name Description


LayoutCells A collection of MWOffice LayoutCell objects.
LayoutInfo A MWOffice LayoutInfo object.
LayoutModeSet An MWOffice LayoutModeSet object.
LayoutModeSets A collection of MWOffice LayoutModeSet objects.
LayoutParameter An MWOffice LayoutParameter object.
LayoutParameterFrame An MWOffice LayoutParameterFrame object.
LayoutParameters A collection of MWOffice LayoutParameters objects.
LayoutProcessDefinition An MWOffice LayoutProcessDefinition object.
LayoutProcessDefinitions A collection of MWOffice LayoutProcessDefinition objects.
LayoutVsSchematicChecker An MWOffice LayoutVsSchematicChecker object.
Legend An MWOffice Legend object.
Libraries A collection of MWOffice Library objects.
Library An MWOffice Library object.
LibraryElement An MWOffice LibraryElement object.
LibraryElements A collection of MWOffice LibraryElement objects.
LineMarker An MWOffice LineMarker object.
LineMarkers A collection of MWOffice LineMarker objects.
Marker An MWOffice Marker object.
MarkerDisplay An MWOffice MarkerDisplay Object.
MarkerOptions An MWOffice MarkerOptions Object.
Markers A collection of MWOffice Marker objects.
MaterialLayer An MWOffice Material Layer object.
MaterialLayers A collection of MWOffice Material Layer objects.
MathUtil An MWOffice MathUtil object.
Measurement An MWOffice Measurement object.
MeasurementInfo An MWOffice MeasurementInfo object contains information about measurement
types available in the application.
MeasurementInfos A collection of MWOffice MeasurementInfo objects.
Measurements A collection of MWOffice Measurement objects.
Menu An MWOffice Menu object.
MenuBar An MWOffice MenuBar object.
MenuBars A collection of MWOffice MenuBar objects.
MenuItem An MWOffice MenuItem object.
MenuItems A collection of MWOffice MenuItem objects.
Menus A collection of MWOffice Menu objects.
Model An MWOffice Model object.
Models A collection of MWOffice Model objects.

26 NI AWR Design Environment


Objects List

Object Name Description


ModifierDefDrawingObjects A collection of DrawingObject objects.
ModifierDefRecord A MWOffice ModifierDefRecord object.
ModifierDefRecords A collection of ModifierDefRecord objects.
NamedConnectors A collection of MWOffice Element objects consisting of only the schematic
named connectors
NetShape An MWOffice NetShape object.
NetShapes A collection of MWOffice NetShape objects.
Netlist An MWOffice Netlist object.
Netlists A collection of MWOffice Netlist objects.
Node An MWOffice Node object.
Nodes A collection of MWOffice Node objects.
ObjectName An MWOffice ObjectName Object.
ObjectNames A collection of MOffice ObjectName objects.
Offset An MWOffice Offset object.
OffsetMarker An MWOffice OffsetMarker Object.
Offsets A collection of MWOffice Offset objects.
OptGoals A collection of MWOffice Goal objects.
Optimizer An MWOffice Optimizer object.
Option An MWOffice Option object.
Options A collection of MWOffice Option objects.
OutputEquationDocument A MWOffice OutputEquationDocument object.
OutputEquationDocuments A collection of OutputEquationDocument objects.
OutputFile An MWOffice OutputFile object.
OutputFiles A collection of MWOffice OutputFile objects.
PageSetup A MWOffice PageSetup object.
Parameter An MWOffice Parameter object.
ParameterDefaultValue A MWOffice ParameterDefaultValue object.
ParameterDefaultValues A MWOffice ParameterDefaultValue object.
ParameterDefinition An MWOffice ParameterDefinition object.
ParameterDefinitions A collection of MWOffice ParameterDefinition objects.
ParameterFrame An MWOffice ParameterFrame object.
Parameters A collection of MWOffice Parameter objects.
PathRecord An MWOffice PathRecord object.
PathWriter An MWOffice PathWriter object.
PhysicalNet An MWOffice PhysicalNet object.
PhysicalNets A collection of MWOffice PhysicalNet objects.
Pin An MWOffice Pin Object.

API Scripting Guide 27


Objects List

Object Name Description


Pins A collection of MWOffice Pin objects.
Point An MWOffice Point object.
Points A collection of MWOffice Point objects.
PolygonRecord An MWOffice PolygonRecord object.
PolygonWriter An MWOffice PolygonWriter object.
Ports A collection of MWOffice Element objects consisting of only the schematic or
system diagram ports
ProcessBridgeInfo An MWOffice ProcessBridgeInfo object.
ProcessBridgeInfos A collection of MWOffice ProcessBridgeInfo objects.
ProcessLayerInfo An MWOffice ProcessLayerInfo object.
ProcessLayerInfos A collection of MWOffice ProcessLayerInfo objects.
ProcessLibraries A collection of MWOffice ProcessLibrary objects.
ProcessLibrary An MWOffice ProcessLibrary object.
ProcessLibraryInfo An MWOffice ProcessLibraryInfo object.
ProcessLibraryInfos A collection of MWOffice ProcessLibraryInfo objects.
ProcessProperties A collection of MWOffice ProcessProperties objects.
ProcessProperty An MWOffice ProcessProperty object.
ProcessTypeInfo An MWOffice ProcessTypeInfo object.
ProcessTypeInfos A collection of MWOffice ProcessTypeInfo objects.
ProcessViaFenceEntries A collection of MWOffice ProcessViaFenceEntry objects.
ProcessViaFenceEntry A MWOffice ProcessViaFenceEntry object.
ProcessViaFillEntries A collection of MWOffice ProcessViaFillEntry objects.
ProcessViaFillEntry A MWOffice ProcessViaFillEntry object.
ProcessViaLineType An MWOffice ProcessViaLineType object.
ProcessViaLineTypePair An MWOffice ProcessViaLineTypePair object.
ProcessViaLineTypePairs A collection of MWOffice ProcessViaLineTypePair objects.
ProcessViaType An MWOffice ProcessViaType object.
ProcessViaTypes A collection of MWOffice ProcessViaType objects.
Project An MWOffice Project object.
ProjectFile A MWOffice ProjectFile object.
ProjectFiles A collection of MWOffice ProjectFile objects.
ProjectItem A MWOffice ProjectItem object.
ProjectItems A collection of MWOffice ProjectItem objects.
ProjectTreeView A MWOffice project TreeView object.
Properties A collection of MWOffice Property objects.
Property An MWOffice Property object.
RegressionResult A MWOffice RegressionResult object.

28 NI AWR Design Environment


Objects List

Object Name Description


RegressionTester A MWOffice RegressionTester object.
Route An MWOffice Route object.
RouteGuide An MWOffice RouteGuide object.
RouteGuides A collection of MWOffice RouteGuide objects.
RouteObject An MWOffice RouteObject object.
RouteObjects A collection MWOffice RouteObject objects.
RoutePropertyInfo A MWOffice RoutePropertyInfo object.
RouteRecord An MWOffice RouteRecord object.
RouteSegment An MWOffice RouteSegment object.
RouteSegments A collection of MWOffice RouteSegment objects.
RouteVia An MWOffice RouteVia object.
RouteVias A collection MWOffice RouteVia objects.
Routes A collection of MWOffice Route objects.
Schematic An MWOffice Schematic object.
Schematics A collection of MWOffice Schematic objects.
ScriptModule A MWOffice ScriptModule object.
ScriptModules A collection of ScriptModule objects.
ScriptRoutine A MWOffice ScriptRoutine object.
ScriptRoutines A collection of ScriptRoutine objects.
SelectFilter An MWOffice SelectFilter object.
SelectFilterItem An MWOffice SelectFilterItem object.
SelectFilterItems A collection of MWOffice SelectFilterItem objects.
SelectedDrawingObjects A collection of MWOffice SelectedDrawingObject objects.
SelectedElements A collection of MWOffice SelectedElement objects.
SelectedWires A collection of MWOffice SelectedWire objects.
Shape An MWOffice Shape object.
ShapeArcSegment An MWOffice ShapeArcSegment object.
ShapeArcSegments A collection of MWOffice ShapeArcSegment objects.
ShapeModifier A MWOffice ShapeModifier object.
ShapeModifierRecord A MWOffice ShapeModifierRecord object.
ShapeModifierRecords A collection of MWOffice ShapeModfierRecordObjects.
ShapeModifiers A collection of MWOffice ShapeModifier objects.
ShapeSegment An MWOffice ShapeSegment object.
ShapeSegments A collection of MWOffice ShapeSegment objects.
ShapeSubObject An MWOffice ShapeSubObject object.
ShapeSubObjects A collection of MWOffice ShapeSubObject objects.
Shapes A collection of MWOffice Shape objects.

API Scripting Guide 29


Objects List

Object Name Description


SimulationFilter An MWOffice SimulationFilter object.
SimulationFilters A collection of MWOffice SimulationFilter objects.
SimulationResult An MWOffice SimulationResult object.
SimulationResults A collection of MWOffice SimulationResult objects.
Simulator An MWOffice Simulator object.
Size An MWOffice Size object.
Sizes A collection of MWOffice Size objects.
Snapshot An MWOffice Snapshot object.
StackupUtil An MWOffice StackupUtil object.
Status A collection of MWOffice StatusGroup objects.
StatusGroup A MWOffice StatusGroup object.
StatusGroups A collection of MWOffice StatusGroup objects.
StatusItem A MWOffice StatusItem object.
StatusItems A collection of MWOffice StatusItem objects.
StatusWindow The MWOffice StatusWindow object.
Subcircuits A collection of MWOffice Element objects consisting of only the schematic
subcircuits
Subsystems A collection of MWOffice Element objects consisting of only the system diagram
subsystems.
SweepLabel A SweepLabel object contains information about the swept variable values for
a particular measurement trace.
SweepLabels A collection of MWOffice SweepLabel objects.
SweepValue A MWOffice SweepVariable object.
SweepValues A collection of MWOffice SweepValue objects.
SweepVariable A MWOffice SweepVariable object.
SweepVariables A collection of MWOffice SweepVariable objects.
Sweeper An MWOffice Sweeper object.
SwitchList An MWOffice SwitchList object.
SwitchLists A collection of MWOffice SwitchList objects.
Symbol An MWOffice Symbol object.
SymbolNode An MWOffice SymbolNode object.
SymbolNodes A collection of MWOffice SymbolNode objects.
SymbolRecord An MWOffice SymbolRecord object.
SymbolShape An MWOffice SymbolShape object.
SymbolShapes A collection of MWOffice SymbolShape objects.
Symbols A collection of MWOffice Symbol objects.
Synthesizer An MWOffice Synthesis object.

210 NI AWR Design Environment


Objects List

Object Name Description


SystemDiagram An MWOffice SystemDiagram object.
SystemDiagrams A collection of MWOffice SystemDiagram objects.
ThreeDView A MWOffice 3DView object.
ThreeDViews A collection of MWOffice 3D View objects.
Trace An MWOffice Trace object.
Traces A collection of MWOffice Trace objects.
TreeNode A MWOffice TreeNode object.
TreeNodes A collection of MWOffice TreeNode objects.
TuneVariable A MWOffice TuneVariable object.
TuneVariables A collection of MWOffice TuneVariable objects.
Tuner A MWOffice Tuner object.
Unit An MWOffice Unit object.
Units A collection of MWOffice Unit objects.
UserFolder A MWOffice Folder object.
UserFolders A collection of MWOffice Folder objects.
Vertex An MWOffice Vertex object.
Vertex3D An MWOffice Vertex3D object.
Vertices A collection of MWOffice Vertex objects.
View A MWOffice View object.
Views A collection of MWOffice View objects.
Window An MWOffice Window object.
Windows A collection of MWOffice Window objects.
WireNet An MWOffice WireNet object.
WireSegment An MWOffice WireSegment object.
Wires A collection of MWOffice WireSegment objects.
Wizard A MWOffice Wizard definition object.
WizardDoc A MWOffice WizardDoc instance object.
WizardDocs A collection of MWOffice WizardDoc objects.
Wizards A collection of MWOffice Wizard objects.
YieldGoals A collection of MWOffice Goal objects.
ZipArchiveItem An MWOffice ZipArchiveItem object.
ZipArchiveItems A collection of MWOffice ZipArchiveItem objects.
ZipArchiveWriter An MWOffice ZipArchiveWriter object.

API Scripting Guide 211


Enumerations List

Enumerations List
Enumeration Name Description
mwAlignToolFlags Constants that define the types of alignment tools.
mwApplicationAttributeType Constants that define different types of application attribute types
mwApplicationDirectoryType Constants that define different types of application directories.
mwApplicationFileType Constants that define different types of application files.
mwArcAttributes Constants that define different types of Arc attributes.
mwAreaAddType Constants that define different constraints for adding objects in an area
mwArrayCellAttributes Constants that define attributes of an array cell object.
mwBooleanCornerStyles Constanst that define the different types of corner styles that can be used when
resizing shapes with acute angles
mwBooleanEngineVersions Constanst that define the different types of boolean engines that can be used for
shape processing in layout.
mwBoundaryModelType Constants that define different types of boundary models.
mwCellExportFormat Constants that define different types of cell export formats.
mwCellLibraryType Constants that define the different cell library types.
mwCellStretcherAttributes Constants that define different attribute types for cell stretcher shapes
mwColor Constants that define different types of standard colors.
mwComponentTestResultType Constants that define the different types of component test result types.
mwDashStyle Constants that define the dash styles of a line.
mwDataFileType Constants that define different types of data files.
mwDataSetFlags Constants that define flag types associated with data sets.
mwDefRouteConnModelTypes Constants that define different types of route-to-route connection models.
mwDefaultFaceAlignType Constants that define different types of default face alignments.
mwDesignRuleErrorFileFormat Constants that define different types of DRC error file formats.
mwDesignRuleState Constants that define different types of design rule states
mwDesignRuleType Constants that define different types of design rule types
mwDesignViewType Constants that defined different views on a design
mwDiagramLockLevel Constants that define different types of lock levels for schematic and system
diagrams
mwDimensionArrowLocation Constants that define different types of arrow locations for dimension line objects.
mwDimensionTextLocation Constants that define different types of text locations for dimension line objects.
mwDisplayModeType Constants that define the different types of drawing object display modes.
mwDockBorder Constants that define the locations that a window can be docked to.
mwDockState Constants that define the different dockable states of a window.
mwDrawingArcDirection Constants that define different arc segment directions.
mwDrawingShapeType Constants that define different types of drawing shape objects.
mwDrawingSubObjectType Constants that define differnet types of drawing sub-objects.

212 NI AWR Design Environment


Enumerations List

Enumeration Name Description


mwDrawingTextAttributes Constants that define different types of drawing text attributes.
mwEECmdShow Constants that define the different types of external editor show states.
mwEMGroupType Constants that define the different types of EM port group types.
mwEMInitType Constants that define the different types of EMStructure initialization types.
mwEMInputDataXMLType Constants that define the different types of XML Input Data formats.
mwEMMeshDensity Constants that define the mesh density levels available for EM simulation.
mwEMPortFlags Constants that define flags which can be used in the EM port flags field.
mwEMPortType Constants that define the different types of EM ports.
mwEMShapePortType Constants that define the different types of EM shape port types.
mwEMSolverToleranceLevel Constants that define the tolerance level for the matrix solver.
mwEMSolverType Constants that define the matrix solution types available in the EM simulator.
mwElementType Constants that define different types of elements.
mwEllipseAttributes Constants that define different types of Ellipse attributes.
mwEmExtractAtrributes Constants that define different types of layout EM extraction attributes.
mwEmSimulator Constants that define the different types of electromagnetic simulators.
mwEmbeddedDocType Values that define different embedded document types.
mwEquationDataType Constants that define different types of data for equations
mwEquationVariableType Constants that define different types of equation variables
mwErrorType Constants that define different types of errors.
mwExclusiveOrShapesType Constants that define the different types of shape exclusive or types.
mwExternalEditorType Constants that define the different types of external editors for EM3DStructure
objects.
mwFaceAlignment Constants that define different types of face alignments.
mwFaceGroupType Constants that define different types of face groups
mwFaceInsetOptions Constants that define different options for inserting layout cell faces.
mwFaceMultiLayerProperty Constants that define different types of face multi-layer drawing properties.
mwFaceShapeType Constants that define different types of face shapes, segment for faces and area
for pins
mwFeatureTypeFlags Constants that define the project features.
mwFillStyle Constants that define different fill style types.
mwGraphColorIndex Constants that define indexes for the graph color values for graph color options.
mwGraphLegendStyleIndex Constants that define index values pf legend styles for the legend text entries.
mwGraphLineStyleIndex Constants that define indexes for the graph line style values for graph line style
options.
mwGraphLineWeightIndex Consants that define index for the graph line weight values for graph line weight
options.
mwGraphMarkerFormat Constants that define different output formats for graph cursors and markers.
mwGraphMarkerType Constants that define different output data types for graph cursors and markers.

API Scripting Guide 213


Enumerations List

Enumeration Name Description


mwGraphType Constants that define different types of graphs.
mwGraphYieldDisplayStyle Constants that define different modes for displaying traces for yield data.
mwGraphYieldRangeStyle Constants that define different modes for dispalying range values for yield data.
mwHatchStyle Constants that define different types of Hatch fill styles.
mwINetModelingLevel Constants that define different iNet modeling accuracy levels
mwInstanceExportOptions Constants that define different options for exporting instances from layout.
mwInterpolationCoords Constants that define different interpolation coordinate system types.
mwInterpolationMethod Constants that define different methods for value interpolation.
mwIntersectShapesType Constants that define the different types of shape intersection types.
mwJobStatusType Constants that define the different types of job status states for JobProcess objects.
mwLVSHighlightLoc Constants that define where an LVS SchematicHighlight item should be
highlighted.
mwLayout3DPlacementAttributes Constants that define different types of layout 3D placement attributes.
mwLayoutArcAttributes Constants that define different types of layout arc attributes.
mwLayoutCellAttributes Constants that define different types of Layout Cell attributes.
mwLayoutCellExportOptions Constants that define different types of layout cell export options
mwLayoutCellShapeAttributes Constants that define the different types of LayoutCellShape attributes.
mwLayoutCellStretcherAttributes Constants that define different types of layout cell stretcher attributes.
mwLayoutConnectionLineTypes Constants that define different types of layout connection line drawing.
mwLayoutDimensionLineAttributes Constants that define different types of layout dimension line attributes.
mwLayoutDragLayoutObjectAttributes Constants that define different types of layout drag object attributes.
mwLayoutDrillHoleAttributes Constants that define different types of layout drill hole attributes.
mwLayoutEllipseAttributes Constants that define different types of layout ellipse attributes.
mwLayoutExportFormat Constants that define different types of layout export formats.
mwLayoutFaceAttributes Constants that define different types of layout face attributes.
mwLayoutFontAttributes Constants that define different types of layout font attributes.
mwLayoutGroupAttributes Constants that define the different types of Layout Group attributes.
mwLayoutLayerAttributes Constants that define the different types of LayoutLayer attributes.
mwLayoutMagnificationAttributes Constants that define different types of layout magnification attributes.
mwLayoutNetShapeAttributes Constants that define different types of LayoutNetShape attributes.
mwLayoutObjectSelectFilters Constants that define bits for specific object types for restricting selection in
layout
mwLayoutOrientationAttributes Constants that define different types of layout orientation attributes.
mwLayoutParamDataType Constants that define the data types of a LayoutParameter.
mwLayoutPathAttributes Constants that define different types of layout path attributes.
mwLayoutPinAttributes Constants that define different types of Layout Pin attributes.
mwLayoutPolyAttributes Constants that define different types of layout polygon attributes.

214 NI AWR Design Environment


Enumerations List

Enumeration Name Description


mwLayoutPolylineAttributes Constants that define different types of layout polyline attributes.
mwLayoutRouteGravity Constants that define different levels of layout route inference snap gravity.
mwLayoutRoutePathAttributes Constants that define different types of Layout Route attributes.
mwLayoutRulerAttributes Constants that define different types of layout ruler attributes.
mwLayoutRulerTickLocation Constants that define different types of layout ruler tick mark locations.
mwLayoutSelectMode Constants that define different types of layout selection modes.
mwLayoutShapeAttributes Constants that define different types of Layout Shape attributes.
mwLayoutSnapMode Constants that define different types of layout snap modes.
mwLayoutSnapType Constants that define different types of layout snap types.
mwLayoutSubcircuitAttributes Constanst that define the different types of LayoutSubcircuit attributes.
mwLayoutTextAttributes Constants that define different types of layout text attributes.
mwLayoutViewDetails Constants that define different levels of layout viewing details.
mwLayoutWindowType Constants that define the different layout window styles.
mwLibraryElementType Constants that define the different types of library elements.
mwLineMarkerTrackType Constants that define different types of LineMarker track types.
mwLineMarkerType Constants that define different types of LineMarker objects.
mwLineStyle Constants that define different line style types.
mwLinearSolveType Constants that define the solution types available in the linear circuit simulator.
mwMarkerAutoSearchMode Constants that define different auto-search marker modes.
mwMarkerOffsetMode Constants that define different offset marker modes.
mwMarkerSearchDirection Constants that define different search directions for markers.
mwMarkerSearchMode Constants that define different search modes for markers.
mwMarkerSearchVariable Constants that define different search variable types for markers.
mwMarkerSymbolType Constants that define different types of marker symbols.
mwMarkerType Constants that define different types of graph markers.
mwMeasDataType Constants that define different measurement data types.
mwModelCompatibilityVersion Constants that define different model compatibility version levels
mwModelExtractType Constants that define different model options for an element.
mwModelParseType Constants that define different types of model parse types.
mwModelPriorityType Constants that define different types of priorities for Model objects.
mwModelPropertyFlags Constants that define different bits for model flag types.
mwNetViaMode Constants that define different types of via modes.
mwNetViaSizeOpts Constants that define different types of iNet route to pin via size options.
mwNetlistType Constants that define different types of netlists.
mwNodeDataType Constants that define different types of node data types.
mwNodeFlags Constants that define different types of node flags.
mwNodeType Constants that define different types of element nodes.

API Scripting Guide 215


Enumerations List

Enumeration Name Description


mwNonLinearSolveType Constants that define the solution types available in the non-linear circuit
simulator.
mwObjectIncludeType Constants that define the types of objects to be included in an operation.
mwObjectSelectFilters Constants that define bits for specific object types for restricting selection
mwOptGoalType Constants that define different types of optimization goals.
mwOptimizerSetting Constants that define the different optimizer settings.
mwPageSetupDetailLevel Constants that define the diffeent levels of output detail.
mwPageSetupOrientation Constants that define the different types of page orientations.
mwParamDefDataType Constants that define the data types of a ParameterDefinition.
mwParameterDefinitionFlagType Constants that define different types of parameter default flags for parameter
definitions.
mwParameterStyle Constants that define different types of parameter styles.
mwParameterStyleSetting Constants that define different types of parameter style settings.
mwPathAttributes Constants that define attributes of a shape path object.
mwPathEndType Constants that define different types of path ends.
mwPathEndTypeOptions Constants that define different options for path end types.
mwPathMiterType Constants that define different types of path miters.
mwPathMiterTypeOptions Constants that define different options for path miter types.
mwPlacementJustfication Constants that define the different types of placement justification styles.
mwPlot3DGridAttributes Constants that define the different types of attributes for a 3D Plot type Graph.
mwPlotAxis Constants that define different axes for plotting.
mwPolarGridAttributes Constants that define the different types of attributes for a Polar Chart type
Graph.
mwPolygonAttributes Constants that define different types of Polygon attributes.
mwPolylineAttributes Constants that defined different types of Polyline attributes.
mwPortFaceConnectTypes Constants that define different types of face connection options.
mwPrecisionMode Constants that define the different types of precision display modes.
mwPrecisionStyle Constants that define the different types of precision display styles.
mwPrintPaperSize Constants that define the different sizes of paper for printing.
mwPrintPaperSource Constants that define the different sources of paper for printing
mwProjectItemType Constants that define the different types of project items.
mwProjectTemplateType Constants that define different types of project template type values.
mwProjectToolFlags Constants that define the types of project tools.
mwProjectVersionType Constants that define different types of project version values.
mwPropertyDataType Constants that define different data types of property objects.
mwRectGridAttributes Constants that define the different types of attributes for a Rectangular Chart
type Graph.
mwRectangleAttributes Constants that define different types of Rectangle attributes.

216 NI AWR Design Environment


Enumerations List

Enumeration Name Description


mwRouteBendStyleType Constants that define different types of bend styles for route objects.
mwRouteConnModel Constants that define different types of route-to-route connection models for a
physical net.
mwRouteObjectType Constants that define different types of route object types
mwRouteObstructionLevel Constants that define different routing obstruction avoidance levels
mwRouteSegmentEndOffsetType Constants that define different route segment end offset style types.
mwRouteSegmentEndStyleType Constants that define different route segment end style types
mwRouteStatusType Constants that define different route status types
mwRouteTopologyType Constants that define different route topologies
mwRouteViaDirectionType Constants that define different route via direction types
mwScaleType Constants that define the type of scale of an Axis object.
mwSchematicExportFormat Constants that define different types of schematic export formats.
mwSchematicFontAttributes Constants that define different types of schematic font attributes.
mwSchematicNetlistExportFormat Constants that define different types of schematic netlist export formats.
mwShapeArcDirection Constants that define different arc segment directions.
mwShapeModifierPriority Constants that define the different types of modifier priority levels.
mwShapeModifierType Constants that define the different types of shape modifiers.
mwShapeNetType Constants that define different types of networks for layout shape objects.
mwShapePreprocessorAttributes Constants that define the different types of Preprocessor attributes.
mwShapeSubObjectType Constants that define different types fo shape sub-objects.
mwShapeToolFlags Constants that define the types of shape tools.
mwShapeType Constants that define different types of shapes.
mwShowFileFlags Constants that define flags for the options when displaying a file using the file
util ShowFile.
mwShowFileType Constants that define the different types of files that can be displayed by the file
utility ShowFile.
mwSimStateFlags Constants that define flags for the different types of simulation dirty states.
mwSmithGridAttributes Constants that define the different types of attributes for a Smith Chart type
Graph.
mwSpiceExtractionModelLevel Constants that define different spice model extraction levels
mwStatisticalDist Constants that define different types of statistical distributions.
mwStatusItemCategory Constants that define the category of a status item.
mwSubcktGroundType Constants that define different types of sub-circuit grounding.
mwSymbolPathAttributes Constants that define different types of symbol path attributes.
mwSymbolSelectMode Constants that define different types of symbol select modes.
mwSymbolShapeType Constants that define different types of symbol shapes.
mwSymbolTextAttributes Constants that define different types of symbol text attributes.

API Scripting Guide 217


Count

Enumeration Name Description


mwSymbolType Constants that define different types of symbol categories like project or system
symbols
mwSysNoiseModeling Constants that define different modes of system noise modeling.
mwSystemExportFormat Constants that define different types of system export formats.
mwSystemSimulatorState Constants that define different types of simulator run states
mwTabularGridAttributes Constants that define the different types of attributes for a Tabular Grid type
Graph.
mwTextAlignment Constants that define different types of Text alignment.
mwThickness Constants that define the thickness of a line or trace.
mwTraceSteppedColorStyle Constants that define different stepped color styles for a graph trace object.
mwTraceStyle Constants that define different styles for a graph trace object.
mwTraceSymbols Constants that define the different symbols for traces objects.
mwUnionShapesType Constanst that define the different types of shape union types.
mwUnitMultType Constants that define different types of multipliers.
mwUnitType Constants that define different types of units.
mwVarPropMode Constants that define different types of variable passing down hierarchy
mwViaAlignType Constants that define the different types of via alignments for via fill entries.
mwViaFillStaggerMode Constants that define the different types of via stagger mode for via fill entries.
mwViaSpacingType Constants that define the different types of via spacings for via fill entries and
via fence entries.
mwViewAutoRotate Constants that define the different modes for auto rotation within a 3D view.
mwViewFrom Constants that define the different predefined view from perspectives in a 3D
view
mwViewVisiual Constants that define the different predefined visual modes in a 3D view.
mwWindowState Constants that define the different window states.
mwWindowTileDirection Cosntants that define the different window tile directions.
mwWindowType Constants that define the different window types.
mwYieldGoalType Constants that define different types of yield goals.

Count
This page is for the common property Count and all the objects that use this property.

Object Help Description


Annotations Returns the number of objects in the collection.
Arguments Returns the number of objects in the collection.
Attributes Returns the number of objects in the collection.
Axes Returns the number of objects in the collection.
BundleBits Returns the number of objects in the collection.

218 NI AWR Design Environment


Count

Object Help Description


BundleBuses Returns the number of objects in the collection.
BundleInfos Returns the number of objects in the collection.
BusNetNames Returns the number of objects in the collection.
CSelectFilters Returns the number of objects in the collection.
CellEditors Returns the number of objects in the collection.
CellInstances Returns the number of objects in the collection.
CellLibraries Returns the number of objects in the collection.
CellMappings Returns the number of objects in the collection.
Cells Returns the number of objects in the collection.
CommandTables Returns the number of objects in the collection.
Commands Returns the number of objects in the collection.
ComplexNumbers Returns the number of objects in the collection.
ComponentTests Returns the number of objects in the collection.
ConnectionRules Returns the number of objects in the collection.
ControlBarItems Returns the number of objects in the collection.
ControlBars Returns the number of objects in the collection.
CrossoverRuleEntries Returns the number of objects in the collection.
CrossoverRules Returns the number of objects in the collection.
DRCErrorShapes Returns the number of objects in the collection.
DataFiles Returns the number of objects in the collection.
DataSetFolders Returns the number of objects in the collection.
DataSetProperties Returns the number of objects in the collection.
DataSets Returns the number of objects in the collection.
DesignNotes Returns the number of objects in the collection.
DesignRuleErrors Returns the number of objects in the collection.
DesignRules Returns the number of objects in the collection.
DrawingArcSegments Returns the number of objects in the collection.
DrawingLayers Returns the number of objects in the collection.
DrawingObjects Returns the number of objects in the collection.
DrawingSegments Returns the number of objects in the collection.
DrawingShapes Returns the number of objects in the collection.
DrawingSubObjects Returns the number of objects in the collection.
DrillTools Returns the number of objects in the collection.
EM3DStructures Returns the number of objects in the collection.
EMLayerMapEntries Returns the number of objects in the collection.
EMLayerMappings Returns the number of objects in the collection.
EMPortTerminations Returns the number of objects in the collection.

API Scripting Guide 219


Count

Object Help Description


EMPorts Returns the number of objects in the collection.
EMStructures Returns the number of objects in the collection.
EditHandles Returns the number of objects in the collection.
ElectricalNets Returns the number of objects in the collection.
Elements Returns the number of objects in the collection.
EmbeddedDesigns Returns the number of objects in the collection.
EquationExpressions Returns the number of objects in the collection.
Equations Returns the number of objects in the collection.
Extents Returns the number of objects in the collection.
Faces Returns the number of objects in the collection.
FileAttributes Returns the number of objects in the collection.
FileFilterEntries Returns the number of objects in the collection.
FileInfos Returns the number of objects in the collection.
FilePathEntries Returns the number of objects in the collection.
FlightLines Returns the number of objects in the collection.
FolderInfos Returns the number of objects in the collection.
FontInfos Returns the number of objects in the collection.
Frequencies Returns the number of objects in the collection.
GlobalDefinitionDocuments Returns the number of objects in the collection.
Graphs Returns the number of objects in the collection.
GroupDrawingObjects Returns the number of objects in the collection.
HotkeyTables Returns the number of objects in the collection.
Hotkeys Returns the number of objects in the collection.
JobEntries Returns the number of objects in the collection.
JobQueues Returns the number of objects in the collection.
LVSErrors Returns the number of objects in the collection.
LVSNetHighlights Returns the number of objects in the collection.
LVSSchemHighlights Returns the number of objects in the collection.
LayerExportEntries Returns the number of objects in the collection.
LayerExportMappings Returns the number of objects in the collection.
LayerMapEntries Returns the number of objects in the collection.
LayerMappings Returns the number of objects in the collection.
LayoutCells Returns the number of objects in the collection.
LayoutModeSets Returns the number of objects in the collection.
LayoutParameters Returns the number of objects in the collection.
LayoutProcessDefinitions Returns the number of objects in the collection.
Libraries Returns the number of objects in the collection.

220 NI AWR Design Environment


Count

Object Help Description


Library Returns the number of objects in the collection.
LibraryElements Returns the number of objects in the collection.
LineMarkers Returns the number of objects in the collection.
Markers Returns the number of objects in the collection.
MaterialLayers Returns the number of objects in the collection.
MeasurementInfos Returns the number of objects in the collection.
Measurements Returns the number of objects in the collection.
MenuBars Returns the number of objects in the collection.
MenuItems Returns the number of objects in the collection.
Menus Returns the number of objects in the collection.
Models Returns the number of objects in the collection.
ModifierDefDrawingObjects Returns the number of objects in the collection.
ModifierDefRecords Returns the number of objects in the collection.
NamedConnectors Returns the number of objects in the collection.
NetShapes Returns the number of objects in the collection.
Netlists Returns the number of objects in the collection.
Nodes Returns the number of objects in the collection.
ObjectNames Returns the number of objects in the collection.
Offsets Returns the number of objects in the collection.
OptGoals Returns the number of objects in the collection.
Options Returns the number of objects in the collection.
OutputEquationDocuments Returns the number of objects in the collection.
OutputFiles Returns the number of objects in the collection.
ParameterDefaultValues Returns the number of objects in the collection.
ParameterDefinitions Returns the number of objects in the collection.
Parameters Returns the number of objects in the collection.
PhysicalNets Returns the number of objects in the collection.
Pins Returns the number of objects in the collection.
Points Returns the number of objects in the collection.
Ports Returns the number of objects in the collection.
ProcessBridgeInfos Returns the number of objects in the collection.
ProcessLayerInfos Returns the number of objects in the collection.
ProcessLibraries Returns the number of objects in the collection.
ProcessLibraryInfos Returns the number of objects in the collection.
ProcessProperties Returns the number of objects in the collection.
ProcessTypeInfos Returns the number of objects in the collection.
ProcessViaFenceEntries Returns the number of objects in the collection.

API Scripting Guide 221


Count

Object Help Description


ProcessViaFillEntries Returns the number of objects in the collection.
ProcessViaLineTypePairs Returns the number of objects in the collection.
ProcessViaTypes Returns the number of objects in the collection.
ProjectFiles Returns the number of objects in the collection.
ProjectItems Returns the number of objects in the collection.
Properties Returns the number of objects in the collection.
RouteGuides Returns the number of objects in the collection.
RouteObjects Returns the number of objects in the collection.
RouteSegments Returns the number of objects in the collection.
RouteVias Returns the number of objects in the collection.
Routes Returns the number of objects in the collection.
Schematics Returns the number of objects in the collection.
ScriptModules Returns the number of objects in the collection.
ScriptRoutines Returns the number of objects in the collection.
SelectFilterItems Returns the number of objects in the collection.
SelectedDrawingObjects Returns the number of objects in the collection.
SelectedElements Returns the number of objects in the collection.
SelectedWires Returns the number of objects in the collection.
ShapeArcSegments Returns the number of objects in the collection.
ShapeModifierRecords Returns the number of objects in the collection.
ShapeModifiers Returns the number of objects in the collection.
ShapeSegments Returns the number of objects in the collection.
ShapeSubObjects Returns the number of objects in the collection.
Shapes Returns the number of objects in the collection.
SimulationFilters Returns the number of objects in the collection.
SimulationResults Returns the number of objects in the collection.
Sizes Returns the number of objects in the collection.
StatusGroups Returns the number of objects in the collection.
StatusItems Returns the number of objects in the collection.
Subcircuits Returns the number of objects in the collection.
Subsystems Returns the number of objects in the collection.
SweepLabels Returns the number of objects in the collection.
SweepValues Returns the number of objects in the collection.
SweepVariables Returns the number of objects in the collection.
SwitchLists Returns the number of objects in the collection.
SymbolNodes Returns the number of objects in the collection.
SymbolShapes Returns the number of objects in the collection.

222 NI AWR Design Environment


Add

Object Help Description


Symbols Returns the number of objects in the collection.
SystemDiagrams Returns the number of objects in the collection.
ThreeDViews Returns the number of objects in the collection.
Traces Returns the number of objects in the collection.
TreeNodes Returns the number of objects in the collection.
TuneVariables Returns the number of objects in the collection.
Units Returns the number of objects in the collection.
UserFolders Returns the number of objects in the collection.
Vertices Returns the number of objects in the collection.
Views Returns the number of objects in the collection.
Windows Returns the number of objects in the collection.
Wires Returns the number of objects in the collection.
WizardDocs Returns the number of objects in the collection.
Wizards Returns the number of objects in the collection.
YieldGoals Returns the number of objects in the collection.
ZipArchiveItems Returns the number of objects in the collection.

Add
This page is for the common method Add and all the objects that use this method.

Object Method Help Description


Annotations Add Adds an object to the collection and returns a reference to
the created object.
Axes Add Adds an object to the collection and returns a reference to
the created object.
CellInstances Add Adds an object to the collection and returns a reference to
the created object.
CellLibraries Add Adds an object to the collection and returns a reference to
the created object.
Cells Add Adds an object to the collection and returns a reference to
the created object.
CommandTables Add Adds an object to the collection and returns a reference to
the created object.
Commands Add Adds an object to the collection and returns a reference to
the created object.
ComplexNumbers Add Adds an object to the collection and returns a reference to
the created object.
ConnectionRules Add Adds an object to the collection and returns a reference to
the created object.

API Scripting Guide 223


Add

Object Method Help Description


ControlBarItems Add Adds an object to the collection and returns a reference to
the created object.
ControlBars Add Adds an object to the collection and returns a reference to
the created object.
CrossoverRuleEntries Add Adds an object to the collection and returns a reference to
the created object.
CrossoverRules CreateNew Adds an object to the collection and returns a reference to
the created object.
DataFiles Add Adds an object to the collection and returns a reference to
the created object.
DataFiles AddNew Adds an object to the collection and returns a reference to
the created object.
DataSetFolders AddGraphDataSet Adds an object to the collection and returns a reference to
the created object.
DesignRuleErrors Add Adds an object to the collection and returns a reference to
the created object.
DesignRules Add Adds an object to the collection and returns a reference to
the created object.
DesignRules AddGroup Adds an object to the collection and returns a reference to
the created object.
DrawingObjects AddRoute Adds a Route object to the DrawingObjects collection.
DrillTools Add Adds an object to the collection and returns a reference to
the created object.
EM3DStructures Add Adds an object to the collection and returns a reference to
the created object.
EM3DStructures AddLinked Adds an object to the collection and returns a reference to
the created object.
EMLayerMappings Add Adds an object to the collection and returns a reference to
the created object.
EMPorts Add Adds an object to the collection and returns a reference to
the created object.
EMStructures Add Adds an object to the collection and returns a reference to
the created object.
EMStructures AddEx Adds an object to the collection and returns a reference to
the created object.
EMStructures AddInit Adds an object to the collection and returns a reference to
the created object.
Elements AddLibraryElement Adds a LibraryElement specified by browser path to the
collection and returns a reference to the created object.
Elements AddXMLComponent Adds a XML component specified by an XPath to the
collection and returns a reference to the created object.

224 NI AWR Design Environment


Add

Object Method Help Description


Elements Add Adds an object to the collection and returns a reference to
the created object.
Elements AddDataFile Adds an object to the collection and returns a reference to
the created object.
Elements AddModelFile Adds an object to the collection and returns a reference to
the created object.
Elements AddSubcircuit Adds an object to the collection and returns a reference to
the created object.
EmbeddedDesigns Add Adds an object to the collection and returns a reference to
the created object.
EquationExpressions Add Adds an object to the collection and returns a reference to
the created object.
Equations Add Adds an object to the collection and returns a reference to
the created object.
Equations Add2 Adds an object to the collection and returns a reference to
the created object.
FileFilterEntries Add Adds an object to the collection and returns a reference to
the created object.
FileInfos Add Adds an object to the collection and returns a reference to
the created object.
FilePathEntries Add Adds an object to the collection and returns a reference to
the created object.
Frequencies Add Adds an object to the collection and returns a reference to
the created object.
GlobalDefinitionDocuments Add Adds an object to the collection and returns a reference to
the created object.
Graphs Add Adds an object to the collection and returns a reference to
the created object.
GroupDrawingObjects Add Adds an object to the collection and returns a reference to
the created object.
Hotkeys Add Adds an object to the collection and returns a reference to
the created object.
LVSErrors Add Adds an object to the collection and returns a reference to
the created object.
LVSNetHighlights Add Adds an object to the collection and returns a reference to
the created object.
LVSSchemHighlights Add Adds an object to the collection and returns a reference to
the created object.
LayerExportMappings Add Adds an object to the collection and returns a reference to
the created object.
LayerMapEntries Add Adds an object to the collection and returns a reference to
the created object.

API Scripting Guide 225


Add

Object Method Help Description


LayerMappings Add Adds an object to the collection and returns a reference to
the created object.
LayoutModeSets Add Adds an object to the collection and returns a reference to
the created object.
LayoutParameters Add Adds an object to the collection and returns a reference to
the created object.
LayoutParameters AddInteger Adds an object to the collection and returns a reference to
the created object.
LayoutParameters AddString Adds an object to the collection and returns a reference to
the created object.
LayoutProcessDefinitions Add Adds an object to the collection and returns a reference to
the created object.
LineMarkers Add Adds an object to the collection and returns a reference to
the created object.
Markers Add Adds an object to the collection and returns a reference to
the created object.
Markers AddEx Adds an object to the collection and returns a reference to
the created object.
MaterialLayers Add Adds an object to the collection and returns a reference to
the created object.
Measurements Add Adds an object to the collection and returns a reference to
the created object.
MenuItems Add Adds an object to the collection and returns a reference to
the created object.
Menus Add Adds an object to the collection and returns a reference to
the created object.
ModifierDefDrawingObjects Add Adds an object to the collection and returns a reference to
the created object.
Netlists Add Adds an object to the collection and returns a reference to
the created object.
Netlists AddEx Adds an object to the collection and returns a reference to
the created object.
OptGoals Add Adds an object to the collection and returns a reference to
the created object.
OutputEquationDocuments Add Adds an object to the collection and returns a reference to
the created object.
OutputFiles Add Adds an object to the collection and returns a reference to
the created object.
ProcessBridgeInfos Add Adds an object to the collection and returns a reference to
the created object.
ProcessLayerInfos Add Adds an object to the collection and returns a reference to
the created object.

226 NI AWR Design Environment


Add

Object Method Help Description


ProcessLibraries Add Adds a ProcessLibrary entry to the MOWOffice
ProcessLibraries collection.
ProcessLibraries AddLibrary Adds a ProcessLibrary entry to the MOWOffice
ProcessLibraries collection.
ProcessProperties Add Adds an object to the collection and returns a reference to
the created object.
ProcessTypeInfos Add Adds an object to the collection and returns a reference to
the created object.
ProcessViaFenceEntries Add Adds an object to the collection and returns a reference to
the created object.
ProcessViaFillEntries Add Adds an object to the collection and returns a reference to
the created object.
ProcessViaLineTypePairs Add Adds an object to the collection and returns a reference to
the created object.
ProcessViaTypes Add Adds an object to the collection and returns a reference to
the created object.
ProjectItems Add Adds an object to the collection and returns a reference to
the created object.
Properties Add Adds an object to the collection and returns a reference to
the created object.
RouteVias Add Adds an object to the collection and returns a reference to
the created object.
Routes AddVias Add the vias in the route record to the existing route objects.
Allows adding vias after routes have been created.
Routes AddRoute Adds the route described by the route record to the
PhysicalNet object.
Schematics Add Adds an object to the collection and returns a reference to
the created object.
SelectedDrawingObjects Add Adds an object to the collection and returns a reference to
the created object.
SelectedDrawingObjects AddAll Adds an object to the collection and returns a reference to
the created object.
SelectedDrawingObjects AddFromArea Adds an object to the collection and returns a reference to
the created object.
SelectedDrawingObjects AddFromRegion Adds an object to the collection and returns a reference to
the created object.
SelectedDrawingObjects AddOverlapped Adds an object to the collection and returns a reference to
the created object.
SelectedElements Add Adds an object to the collection and returns a reference to
the created object.
SelectedWires Add Adds an object to the collection and returns a reference to
the created object.

API Scripting Guide 227


Remove

Object Method Help Description


SelectedWires AddAll Adds an object to the collection and returns a reference to
the created object.
SimulationFilters Add Adds an object to the collection and returns a reference to
the created object.
StatusGroups Add Adds an object to the collection and returns a reference to
the created object.
StatusItems Add Adds an object to the collection and returns a reference to
the created object.
Subcircuits Add Adds an object to the collection and returns a reference to
the created object.
Subsystems Add Adds an object to the collection and returns a reference to
the created object.
SwitchLists Add Adds an object to the collection and returns a reference to
the created object.
SystemDiagrams Add Adds an object to the collection and returns a reference to
the created object.
UserFolders Add Adds an object to the collection and returns a reference to
the created object.
Vertices Add Adds an object to the collection and returns a reference to
the created object.
Windows Add Adds an object to the collection and returns a reference to
the created object.
Wires Add Adds an object to the collection and returns a reference to
the created object.
Wires AddBusNet Adds an object to the collection and returns a reference to
the created object.
YieldGoals Add Adds an object to the collection and returns a reference to
the created object.

Remove
This page is for the common method Remove and all the objects that use this method.

Object Method Help Description


Annotations Remove Removes a specific member from a collection.
Axes Remove Removes a specific member from a collection.
CellInstances Remove Removes a specific member from a collection.
CellLibraries Remove Removes a specific member from a collection.
Cells Remove Removes a specific member from a collection.
ComplexNumbers Remove Removes a specific member from a collection.
ConnectionRules Remove Removes a specific member from a collection.
ControlBars Remove Removes a specific member from a collection.

228 NI AWR Design Environment


Remove

Object Method Help Description


CrossoverRuleEntries Remove Removes a specific member from a collection.
CrossoverRules Remove Removes a specific member from a collection.
DRCErrorShapes Remove Removes a specific member from a collection.
DataFiles Remove Removes a specific member from a collection.
DataSetFolders Remove Removes a specific member from a collection.
DataSets Remove Removes a specific member from a collection.
DesignRuleErrors Remove Removes a specific member from a collection.
DesignRules Remove Removes a specific member from a collection.
DrawingShapes Remove Removes a specific member from a collection.
DrawingSubObjects Remove Removes a specific member from a collection.
DrillTools Remove Removes a specific member from a collection.
EM3DStructures Remove Removes a specific member from a collection.
EMLayerMappings Remove Removes a specific member from a collection.
EMPorts Remove Removes a specific member from a collection.
EMStructures Remove Removes a specific member from a collection.
Elements Remove Removes a specific member from a collection.
EmbeddedDesigns Remove Removes a specific member from a collection.
EquationExpressions Remove Removes a specific member from a collection.
Equations Remove Removes a specific member from a collection.
FileFilterEntries Remove Removes a specific member from a collection.
FileInfos Remove Removes a specific member from a collection.
FilePathEntries Remove Removes a specific member from a collection.
Frequencies Remove Removes a specific member from a collection.
GlobalDefinitionDocuments Remove Removes a specific member from a collection.
Graphs Remove Removes a specific member from a collection.
GroupDrawingObjects Remove Removes a specific member from a collection.
LVSErrors Remove Removes a specific member from a collection.
LVSNetHighlights Remove Removes a specific member from a collection.
LVSSchemHighlights Remove Removes a specific member from a collection.
LayerExportMappings Remove Removes a specific member from a collection.
LayerMapEntries Remove Removes a specific member from a collection.
LayerMappings Remove Removes a specific member from a collection.
LayoutModeSets Remove Removes a specific member from a collection.
LayoutParameters Remove Removes a specific member from a collection.
LayoutProcessDefinitions Remove Removes a specific member from a collection.
LineMarkers Remove Removes a specific member from a collection.
Markers Remove Removes a specific member from a collection.

API Scripting Guide 229


Remove

Object Method Help Description


MaterialLayers Remove Removes a specific member from a collection.
Measurements Remove Removes a specific member from a collection.
ModifierDefDrawingObjects Remove Removes a specific member from a collection.
Netlists Remove Removes a specific member from a collection.
OptGoals Remove Removes a specific member from a collection.
OutputEquationDocuments Remove Removes a specific member from a collection.
OutputFiles Remove Removes a specific member from a collection.
ProcessBridgeInfos Remove Removes a specific member from a collection.
ProcessLayerInfos Remove Removes a specific member from a collection.
ProcessLibraries Remove Removes a ProcessLibrary entry from the MWOffice
ProcessLibraries collection.
ProcessLibraries RemoveLibrary Removes a ProcessLibrary entry from the MWOffice
ProcessLibraries collection.
ProcessProperties Remove Removes a specific member from a collection.
ProcessTypeInfos Remove Removes a specific member from a collection.
ProcessViaFenceEntries Remove Removes a specific member from a collection.
ProcessViaFillEntries Remove Removes a specific member from a collection.
ProcessViaLineTypePairs Remove Removes a specific member from a collection.
ProcessViaTypes Remove Removes a specific member from a collection.
ProjectItems Remove Removes a specific member from a collection.
Properties Remove Removes a specific member from a collection.
RouteVias Remove Removes a specific member from a collection.
Routes Remove Removes a specific member from a collection.
Schematics Remove Removes a specific member from a collection.
SelectedDrawingObjects Remove Removes a specific member from a collection.
SelectedElements Remove Removes a specific member from a collection.
SelectedWires Remove Removes a specific member from a collection.
SimulationFilters Remove Removes a specific member from a collection.
Subcircuits Remove Removes a specific member from a collection.
Subsystems Remove Removes a specific member from a collection.
SwitchLists Remove Removes a specific member from a collection.
Symbols Remove Removes a specific member from a collection.
SystemDiagrams Remove Removes a specific member from a collection.
UserFolders Remove Removes a specific member from a collection.
Vertices Remove Removes a specific member from a collection.
Wires Remove Removes a specific member from a collection.
WizardDoc Remove Removes a specific member from a collection.

230 NI AWR Design Environment


Clear

Object Method Help Description


WizardDocs Remove Removes a specific member from a collection.
YieldGoals Remove Removes a specific member from a collection.

Clear
This page is for the common method Clear and all the objects that use this method.

Object Method Help Description


Annotations RemoveAll Removes all objects in a collection.
Commands Clear Removes all objects in a collection.
ComplexNumbers RemoveAll Removes all objects in a collection.
ConnectionRules RemoveAll Removes all objects in a collection.
ControlBarItems Clear Removes all objects in a collection.
CrossoverRuleEntries RemoveAll Removes all objects in a collection.
CrossoverRules RemoveAll Removes all objects in a collection.
DRCErrorShapes RemoveAll Removes all objects in a collection.
DataSetFolders RemoveAll Removes all objects in a collection.
DataSets RemoveAll Removes all objects in a collection.
DesignRuleErrors RemoveAll Removes all objects in a collection.
DesignRules RemoveAll Removes all objects in a collection.
DrawingShapes RemoveAll Removes all objects in a collection.
DrawingSubObjects RemoveAll Removes all objects in a collection.
EMPorts RemoveAll Removes all objects in a collection.
Elements RemoveAll Removes all objects in a collection.
EmbeddedDesigns RemoveAll Removes all objects in a collection.
FileFilterEntries RemoveAll Removes all objects in a collection.
FileInfos RemoveAll Removes all objects in a collection.
FilePathEntries RemoveAll Removes all objects in a collection.
Frequencies Clear Removes all objects in a collection.
Hotkeys Clear Removes all objects in a collection.
LVSErrors RemoveAll Removes all objects in a collection.
LVSNetHighlights RemoveAll Removes all objects in a collection.
LVSSchemHighlights RemoveAll Removes all objects in a collection.
LayerExportMappings Clear Removes all objects in a collection.
LayerMappings Clear Removes all objects in a collection.
LayoutModeSets RemoveAll Removes all objects in a collection.
LineMarkers RemoveAll Removes all objects in a collection.
Markers RemoveAll Removes all objects in a collection.

API Scripting Guide 231


Name

Object Method Help Description


Measurements RemoveAll Removes all objects in a collection.
Menus Clear Removes all objects in a collection.
ModifierDefDrawingObjects RemoveAll Removes all objects in a collection.
OptGoals RemoveAll Removes all objects in a collection.
OutputFiles RemoveAll Removes all objects in a collection.
ProcessBridgeInfos RemoveAll Removes all objects in a collection.
ProcessLayerInfos RemoveAll Removes all objects in a collection.
ProcessProperties RemoveAll Removes all objects in a collection.
ProcessTypeInfos RemoveAll Removes all objects in a collection.
ProcessViaFenceEntries RemoveAll Removes all objects in a collection.
ProcessViaFillEntries RemoveAll Removes all objects in a collection.
ProcessViaLineTypePairs RemoveAll Removes all objects in a collection.
ProcessViaTypes RemoveAll Removes all objects in a collection.
ProjectItems RemoveAll Removes all objects in a collection.
RouteVias RemoveAll Removes all objects in a collection.
Routes RemoveAll Removes all objects in a collection.
SelectedDrawingObjects RemoveAll Removes all objects in a collection.
SelectedElements RemoveAll Removes all objects in a collection.
SelectedWires RemoveAll Removes all objects in a collection.
SimulationFilters RemoveAll Removes all objects in a collection.
SwitchLists RemoveAll Removes all objects in a collection.
UserFolder RemoveAll Removes all objects in a collection.
UserFolders RemoveAll Removes all objects in a collection.
Vertices RemoveAll Removes all objects in a collection.
Wires RemoveAll Removes all objects in a collection.
YieldGoals RemoveAll Removes all objects in a collection.

Name
This page is for the common property Name and all the objects that use this property.

Object Help Description


Annotation Returns/sets the name of the MWOffice Annotation object.
Application Returns/Sets the name used in code to identify an object.
Attribute Returns the name used in code to identify an object.
BundleBit Returns/Sets the name used in code to identify an object.
BundleBus Returns/Sets the name used in code to identify an object.
BundleInfo Returns/Sets the name used in code to identify an object.

232 NI AWR Design Environment


Name

Object Help Description


BusNetName Returns/Sets the name used in code to identify an object.
Cell Returns/Sets the name used in code to identify an object.
CellEditor Returns the name used in code to identify an object.
CellInstance Returns/Sets the name used in code to identify an object.
CellLibrary Returns/Sets the name used in code to identify an object.
Command Returns the name used in code to identify an object.
CommandTable Returns the name used in code to identify an object.
ComponentTest Returns the name used in code to identify an object.
ControlBar Returns the name used in code to identify an object.
CrossoverRule Returns the name used in code to identify an object.
CrossoverRuleEntry Returns the name used in code to identify an object.
DataFile Returns/Sets the name used in code to identify an object.
DataSet Returns/Sets the name used in code to identify an object.
DataSetFolder Returns/Sets the name used in code to identify an object.
DataSetProperty Returns the name used in code to identify an object.
DesignNote Returns the file name of the project
DrawingLayer Returns/Sets the name used in code to identify an object.
DrillTool Returns/Sets the name used in code to identify an object.
EM3DStructure Returns/Sets the name used in code to identify an object.
EMLayerMapping Returns/Sets the name used in code to identify an object.
EMStructure Returns/Sets the name used in code to identify an object.
Element Returns/Sets the name used in code to identify an object.
Equations Returns/Sets the name used in code to identify an object.
ExternalEditor Returns/Sets the name used in code to identify an object.
FileAttribute Returns/Sets the name used in code to identify an object.
FileFilterEntry Returns/Sets the name used in code to identify an object.
FileInfo Returns/Sets the name used in code to identify an object.
FolderInfo Returns/Sets the name used in code to identify an object.
FontInfo Returns/Sets the name used in code to identify an object.
GlobalDefinitionDocument Returns/Sets the name used in code to identify an object.
Goal Returns the name used in code to identify an object.
Graph Returns/Sets the name used in code to identify an object.
HotkeyTable Returns the name used in code to identify an object.
JobEntry Returns/Sets the name used in code to identify an object.
JobQueue Returns/Sets the name used in code to identify an object.
LayerExportMapping Returns/Sets the name used in code to identify an object.
LayerMapping Returns/Sets the name used in code to identify an object.

API Scripting Guide 233


Name

Object Help Description


Layout Returns the name used in code to identify an object.
LayoutCell Returns the name used in code to identify an object.
LayoutModeSet Returns the name used in code to identify an object.
LayoutParameter Returns the name used in code to identify an object.
LayoutProcessDefinition Returns/Sets the name used in code to identify an object.
Library Returns the name used in code to identify an object.
LineMarker Returns/Sets the name used in code to identify an object.
Marker Returns/Sets the name used in code to identify an object.
Measurement Returns/Sets the name used in code to identify an object.
MeasurementInfo Returns the name used in code to identify an object.
MenuBar Returns the name used in code to identify an object.
Model Returns the name used in code to identify an object.
ModifierDefRecord Returns/Sets the name used in code to identify an object.
Netlist Returns/Sets the name used in code to identify an object.
Option Returns/Sets the name used in code to identify an object.
OutputEquationDocument Returns/Sets the name used in code to identify an object.
OutputFile Returns/Sets the name used in code to identify an object.
Parameter Returns the name used in code to identify an object.
ParameterDefaultValue Returns/Sets the name used in code to identify an object.
ParameterDefinition Returns the name used in code to identify an object.
PhysicalNet Returns/Sets the name used in code to identify an object.
ProcessBridgeInfo Returns/Sets the name used in code to identify an object.
ProcessLayerInfo Returns/Sets the name used in code to identify an object.
ProcessLibrary Returns/Sets the name used in code to identify an object.
ProcessLibraryInfo Returns/Sets the name used in code to identify an object.
ProcessProperty Returns/Sets the name used in code to identify an object.
ProcessTypeInfo Returns/Sets the name used in code to identify an object.
ProcessViaFenceEntry Returns/Sets the name used in code to identify an object.
ProcessViaFillEntry Returns/Sets the name used in code to identify an object.
ProcessViaLineType Returns/Sets the name used in code to identify an object.
ProcessViaType Returns/Sets the name used in code to identify an object.
Project Returns the file name of the project
ProjectFile Returns the name of the ProjectFile.
ProjectItem Returns/Sets the name used in code to identify an object.
Property Returns the name used in code to identify an object.
Schematic Returns/Sets the name used in code to identify an object.
ScriptModule Returns/Sets the name used in code to identify an object.

234 NI AWR Design Environment


Value

Object Help Description


ScriptRoutine Returns/Sets the name used in code to identify an object.
SelectFilter Returns/Sets the name used in code to identify an object.
SelectFilterItem Returns/Sets the name used in code to identify an object.
ShapeModifier Returns/Sets the name used in code to identify an object.
ShapeModifierRecord Returns/Sets the name used in code to identify an object.
SimulationFilter Returns/Sets the name used in code to identify an object.
SimulationResult Returns/Sets the name used in code to identify an object.
StatusGroup Returns/Sets the name used in code to identify an object.
SweepLabel Returns/Sets the name used in code to identify an object.
SweepVariable Returns/Sets the name used in code to identify an object.
SwitchList Returns/Sets the name used in code to identify an object.
Symbol Returns/Sets the name used in code to identify an object.
SystemDiagram Returns/Sets the name used in code to identify an object.
ThreeDView Returns/Sets the name used in code to identify an object.
TreeNode Returns the name of the MWOffice TreeNode object.
TuneVariable Returns the file name of the project
UserFolder Returns/Sets the name used in code to identify an object.
View Returns/Sets the name used in code to identify an object.
Wizard Returns the name of the MWOffice Wizard object.
WizardDoc Returns the name of and instance of a MWOffice Wizard object.
ZipArchiveItem Returns/Sets the name used in code to identify an object.

Value
This page is for the common property Value and all the objects that use this property.

Object Help Description


Attribute Returns/sets the value of the Attribute object.
DataSetProperty Returns the value for this DataSetPropety object.
Option Returns/Set the value of a Option object.
Property Returns the value of a Property object.

Activate
This page is for the common method Activate and all the objects that use this method.

Object Method Help Description


Cell Activate Activates the objects.
CellEditor Activate Activates the objects.

API Scripting Guide 235


NewWindow

Object Method Help Description


DataFile Activate Activates the objects.
DesignNote Activate Activates the objects.
EMStructure Activate Activates the objects.
GlobalDefinitionDocument Activate Activates the objects.
Graph Activate Activates the objects.
Layout Activate Activates the objects.
LayoutModeSets SetActive Activates the objects.
Netlist Activate Activates the objects.
OutputEquationDocument Activate Activates the objects.
Schematic Activate Activates the objects.
SystemDiagram Activate Activates the objects.

NewWindow
This page is for the common method NewWindow and all the objects that use this method.

Object Method Help Description


Cell NewWindow Displays the object in new window.
CellEditor NewWindow Displays the object in new window.
DataFile NewWindow Displays the object in new window.
DesignNote NewWindow Displays the object in new window.
EMStructure NewWindow Displays the object in new window.
GlobalDefinitionDocument NewWindow Displays the object in new window.
Graph NewWindow Displays the object in new window.
Layout NewWindow Displays the object in new window.
Netlist NewWindow Displays the object in new window.
Optimizer NewWindow Displays the object in new window.
OutputEquationDocument NewWindow Displays the object in new window.
Project NewGlobalEquationsWindow Displays the object in new window.
Project NewOutputEquationsWindow Displays the object in new window.
Schematic NewWindow Displays the object in new window.
SystemDiagram NewWindow Displays the object in new window.

Print
This page is for the common method Print and all the objects that use this method.

Object Method Help Description


CellEditor PrintOut Sends the object to the current printer.

236 NI AWR Design Environment


Caption

Object Method Help Description


DataFile PrintOut Sends the object to the current printer.
DesignNote PrintOut Sends the object to the current printer.
EMStructure PrintOut Sends the object to the current printer.
GlobalDefinitionDocument PrintOut Sends the object to the current printer.
Graph PrintOut Sends the object to the current printer.
Layout PrintOut Sends the object to the current printer.
Netlist PrintOut Sends the object to the current printer.
OutputEquationDocument PrintOut Sends the object to the current printer.
Schematic PrintOut Sends the object to the current printer.
SystemDiagram PrintOut Sends the object to the current printer.

Caption
This page is for the common property Caption and all the objects that use this property.

Object Help Description


Application Returns/Sets the caption of an object.
Command Returns/Sets the caption of an object.
ControlBar Returns/Sets the caption of an object.
ControlBarItem Returns/Sets the caption of an object.
Menu Returns/Sets the caption of an object.
MenuItem Returns/Sets the caption of an object.
Window Returns/Sets the caption of an object.

Delete
This page is for the common method Delete and all the objects that use this method.

Object Method Help Description


BusNetName Delete Removes the object.
CellInstance Delete Removes the object.
Command Delete Removes the object.
ControlBarItem Delete Removes the object.
DrawingObject Delete Removes the object.
DrawingShape Delete Removes the object.
Element Delete Removes the object.
Hotkey Delete Removes the object.
Menu Delete Removes the object.
MenuItem Delete Removes the object.

API Scripting Guide 237


Exists

Object Method Help Description


WireSegment Delete Removes the object.

Exists
This page is for the common property Exists and all the objects that use this property.

Object Help Description


Annotations Returns whether an item matching the specified criteria exists in the collection.
Arguments Returns whether an item matching the specified criteria exists in the collection.
Attributes Returns whether an item matching the specified criteria exists in the collection.
Axes Returns whether an item matching the specified criteria exists in the collection.
BundleBits Returns whether an item matching the specified criteria exists in the collection.
BundleBuses Returns whether an item matching the specified criteria exists in the collection.
BundleInfos Returns whether an item matching the specified criteria exists in the collection.
BusNetNames Returns whether an item matching the specified criteria exists in the collection.
CSelectFilters Returns whether an item matching the specified criteria exists in the collection.
CellEditors Returns whether an item matching the specified criteria exists in the collection.
CellInstances Returns whether an item matching the specified criteria exists in the collection.
CellLibraries Returns whether an item matching the specified criteria exists in the collection.
CellMappings Returns whether an item matching the specified criteria exists in the collection.
Cells Returns whether an item matching the specified criteria exists in the collection.
CommandTables Returns whether an item matching the specified criteria exists in the collection.
Commands Returns whether an item matching the specified criteria exists in the collection.
ComplexNumbers Returns whether an item matching the specified criteria exists in the collection.
ComponentTests Returns whether an item matching the specified criteria exists in the collection.
ControlBarItems Returns whether an item matching the specified criteria exists in the collection.
ControlBars Returns whether an item matching the specified criteria exists in the collection.
CrossoverRuleEntries Returns whether an item matching the specified criteria exists in the collection.
CrossoverRules Returns whether an item matching the specified criteria exists in the collection.
DRCErrorShapes Returns whether an item matching the specified criteria exists in the collection.
DataFiles Returns whether an item matching the specified criteria exists in the collection.
DataSetFolders Returns whether an item matching the specified criteria exists in the collection.
DataSetProperties Returns whether an item matching the specified criteria exists in the collection.
DataSets Returns whether an item matching the specified criteria exists in the collection.
DesignNotes Returns whether an item matching the specified criteria exists in the collection.
DesignRuleErrors Returns whether an item matching the specified criteria exists in the collection.
DesignRules Returns whether an item matching the specified criteria exists in the collection.
DrawingArcSegments Returns whether an item matching the specified criteria exists in the collection.

238 NI AWR Design Environment


Exists

Object Help Description


DrawingLayers Returns whether an item matching the specified criteria exists in the collection.
DrawingObjects Returns whether an item matching the specified criteria exists in the collection.
DrawingSegments Returns whether an item matching the specified criteria exists in the collection.
DrawingShapes Returns whether an item matching the specified criteria exists in the collection.
DrawingSubObjects Returns whether an item matching the specified criteria exists in the collection.
DrillTools Returns whether an item matching the specified criteria exists in the collection.
EM3DStructures Returns whether an item matching the specified criteria exists in the collection.
EMLayerMapEntries Returns whether an item matching the specified criteria exists in the collection.
EMLayerMappings Returns whether an item matching the specified criteria exists in the collection.
EMPortTerminations Returns whether an item matching the specified criteria exists in the collection.
EMPorts Returns whether an item matching the specified criteria exists in the collection.
EMStructures Returns whether an item matching the specified criteria exists in the collection.
EditHandles Returns whether an item matching the specified criteria exists in the collection.
ElectricalNets Returns whether an item matching the specified criteria exists in the collection.
Elements Returns whether an item matching the specified criteria exists in the collection.
EmbeddedDesigns Returns whether an item matching the specified criteria exists in the collection.
EquationExpressions Returns whether an item matching the specified criteria exists in the collection.
Equations Returns whether an item matching the specified criteria exists in the collection.
Extents Returns whether an item matching the specified criteria exists in the collection.
Faces Returns whether an item matching the specified criteria exists in the collection.
FileAttributes Returns whether an item matching the specified criteria exists in the collection.
FileFilterEntries Returns whether an item matching the specified criteria exists in the collection.
FileInfos Returns whether an item matching the specified criteria exists in the collection.
FilePathEntries Returns whether an item matching the specified criteria exists in the collection.
FlightLines Returns whether an item matching the specified criteria exists in the collection.
FolderInfos Returns whether an item matching the specified criteria exists in the collection.
FontInfos Returns whether an item matching the specified criteria exists in the collection.
GlobalDefinitionDocuments Returns whether an item matching the specified criteria exists in the collection.
Graphs Returns whether an item matching the specified criteria exists in the collection.
GroupDrawingObjects Returns whether an item matching the specified criteria exists in the collection.
HotkeyTables Returns whether an item matching the specified criteria exists in the collection.
Hotkeys Returns whether an item matching the specified criteria exists in the collection.
JobEntries Returns whether an item matching the specified criteria exists in the collection.
JobQueues Returns whether an item matching the specified criteria exists in the collection.
LVSErrors Returns whether an item matching the specified criteria exists in the collection.
LVSNetHighlights Returns whether an item matching the specified criteria exists in the collection.
LVSSchemHighlights Returns whether an item matching the specified criteria exists in the collection.

API Scripting Guide 239


Exists

Object Help Description


LayerExportEntries Returns whether an item matching the specified criteria exists in the collection.
LayerExportMappings Returns whether an item matching the specified criteria exists in the collection.
LayerMapEntries Returns whether an item matching the specified criteria exists in the collection.
LayerMappings Returns whether an item matching the specified criteria exists in the collection.
LayoutCells Returns whether an item matching the specified criteria exists in the collection.
LayoutModeSets Returns whether an item matching the specified criteria exists in the collection.
LayoutParameters Returns whether an item matching the specified criteria exists in the collection.
LayoutProcessDefinitions Returns whether an item matching the specified criteria exists in the collection.
Libraries Returns whether an item matching the specified criteria exists in the collection.
LibraryElements Returns whether an item matching the specified criteria exists in the collection.
LineMarkers Returns whether an item matching the specified criteria exists in the collection.
Markers Returns whether an item matching the specified criteria exists in the collection.
MaterialLayers Returns whether an item matching the specified criteria exists in the collection.
MeasurementInfos Returns whether an item matching the specified criteria exists in the collection.
Measurements Returns whether an item matching the specified criteria exists in the collection.
MenuBars Returns whether an item matching the specified criteria exists in the collection.
MenuItems Returns whether an item matching the specified criteria exists in the collection.
Menus Returns whether an item matching the specified criteria exists in the collection.
Models Returns whether an item matching the specified criteria exists in the collection.
ModifierDefDrawingObjects Returns whether an item matching the specified criteria exists in the collection.
ModifierDefRecords Returns whether an item matching the specified criteria exists in the collection.
NamedConnectors Returns whether an item matching the specified criteria exists in the collection.
NetShapes Returns whether an item matching the specified criteria exists in the collection.
Netlists Returns whether an item matching the specified criteria exists in the collection.
Nodes Returns whether an item matching the specified criteria exists in the collection.
ObjectNames Returns whether an item matching the specified criteria exists in the collection.
Offsets Returns whether an item matching the specified criteria exists in the collection.
OptGoals Returns whether an item matching the specified criteria exists in the collection.
Options Returns whether an item matching the specified criteria exists in the collection.
OutputEquationDocuments Returns whether an item matching the specified criteria exists in the collection.
OutputFiles Returns whether an item matching the specified criteria exists in the collection.
ParameterDefaultValues Returns whether an item matching the specified criteria exists in the collection.
ParameterDefinitions Returns whether an item matching the specified criteria exists in the collection.
Parameters Returns whether an item matching the specified criteria exists in the collection.
PhysicalNets Returns whether an item matching the specified criteria exists in the collection.
Pins Returns whether an item matching the specified criteria exists in the collection.
Points Returns whether an item matching the specified criteria exists in the collection.

240 NI AWR Design Environment


Exists

Object Help Description


Ports Returns whether an item matching the specified criteria exists in the collection.
ProcessBridgeInfos Returns whether an item matching the specified criteria exists in the collection.
ProcessLayerInfos Returns whether an item matching the specified criteria exists in the collection.
ProcessLibraries Returns whether an item matching the specified criteria exists in the collection.
ProcessLibraryInfos Returns whether an item matching the specified criteria exists in the collection.
ProcessProperties Returns whether an item matching the specified criteria exists in the collection.
ProcessTypeInfos Returns whether an item matching the specified criteria exists in the collection.
ProcessViaFenceEntries Returns whether an item matching the specified criteria exists in the collection.
ProcessViaFillEntries Returns whether an item matching the specified criteria exists in the collection.
ProcessViaLineTypePairs Returns whether an item matching the specified criteria exists in the collection.
ProcessViaLineTypePairs Returns whether an item matching the specified criteria exists in the collection.
ProcessViaTypes Returns whether an item matching the specified criteria exists in the collection.
ProjectFiles Returns whether an item matching the specified criteria exists in the collection.
ProjectItems Returns whether an item matching the specified criteria exists in the collection.
RouteGuides Returns whether an item matching the specified criteria exists in the collection.
RouteObjects Returns whether an item matching the specified criteria exists in the collection.
RouteSegments Returns whether an item matching the specified criteria exists in the collection.
RouteVias Returns whether an item matching the specified criteria exists in the collection.
Routes Returns whether an item matching the specified criteria exists in the collection.
Schematics Returns whether an item matching the specified criteria exists in the collection.
ScriptModules Returns whether an item matching the specified criteria exists in the collection.
ScriptRoutines Returns whether an item matching the specified criteria exists in the collection.
SelectFilterItems Returns whether an item matching the specified criteria exists in the collection.
SelectedElements Returns whether an item matching the specified criteria exists in the collection.
ShapeArcSegments Returns whether an item matching the specified criteria exists in the collection.
ShapeModifierRecords Returns whether an item matching the specified criteria exists in the collection.
ShapeModifiers Returns whether an item matching the specified criteria exists in the collection.
ShapeSegments Returns whether an item matching the specified criteria exists in the collection.
ShapeSubObjects Returns whether an item matching the specified criteria exists in the collection.
Shapes Returns whether an item matching the specified criteria exists in the collection.
SimulationFilters Returns whether an item matching the specified criteria exists in the collection.
SimulationResults Returns whether an item matching the specified criteria exists in the collection.
Sizes Returns whether an item matching the specified criteria exists in the collection.
StatusGroups Returns whether an item matching the specified criteria exists in the collection.
StatusItems Returns whether an item matching the specified criteria exists in the collection.
Subcircuits Returns whether an item matching the specified criteria exists in the collection.
Subsystems Returns whether an item matching the specified criteria exists in the collection.

API Scripting Guide 241


Copy

Object Help Description


SweepLabels Returns whether an item matching the specified criteria exists in the collection.
SweepValues Returns whether an item matching the specified criteria exists in the collection.
SweepVariables Returns whether an item matching the specified criteria exists in the collection.
SwitchLists Returns whether an item matching the specified criteria exists in the collection.
SymbolNodes Returns whether an item matching the specified criteria exists in the collection.
SymbolShapes Returns whether an item matching the specified criteria exists in the collection.
Symbols Returns whether an item matching the specified criteria exists in the collection.
SystemDiagrams Returns whether an item matching the specified criteria exists in the collection.
ThreeDViews Returns whether an item matching the specified criteria exists in the collection.
Traces Returns whether an item matching the specified criteria exists in the collection.
TreeNodes Returns whether an item matching the specified criteria exists in the collection.
TuneVariables Returns whether an item matching the specified criteria exists in the collection.
Units Returns whether an item matching the specified criteria exists in the collection.
UserFolders Returns whether an item matching the specified criteria exists in the collection.
Vertices Returns whether an item matching the specified criteria exists in the collection.
Views Returns whether an item matching the specified criteria exists in the collection.
Windows Returns whether an item matching the specified criteria exists in the collection.
Wires Returns whether an item matching the specified criteria exists in the collection.
WizardDocs Returns whether an item matching the specified criteria exists in the collection.
Wizards Returns whether an item matching the specified criteria exists in the collection.
YieldGoals Returns whether an item matching the specified criteria exists in the collection.
ZipArchiveItems Returns whether an item matching the specified criteria exists in the collection.

Copy
This page is for the common method Copy and all the objects that use this method.

Object Method Help Description


Cells Copy Copies an object from another object collection into this
object collection.
Cells Copy2 Copies an object from another object collection into this
object collection.
EMLayerMappings Copy Copies the object to the system clipboard.
GlobalDefinitionDocument CopyToClipboard Copies the object to the system clipboard.
LayerExportMappings Copy Copies the object to the system clipboard.
OutputEquationDocument CopyToClipboard Copies the object to the system clipboard.

Ccopy
This page is for the common method Ccopy and all the objects that use this method.

242 NI AWR Design Environment


Update

Object Method Help Description


DataFiles Copy Copies an object from another object collection into this
object collection.
EMStructures Copy Copies an object from another object collection into this
object collection.
Graphs Copy Copies an object from another object collection into this
object collection.
Schematics Copy Copies an object from another object collection into this
object collection.
SystemDiagrams Copy Copies an object from another object collection into this
object collection.

Update
This page is for the common method Update and all the objects that use this method.

Object Method Help Description


ConnectionRules UpdateConnectivity Updates the connectivity to show changes in the rules.
Equations Update Called to perform final updates to a collection object.

Import
This page is for the common method Import and all the objects that use this method.

Object Method Help Description


Application Import Adds a Netlist object to the collection from a file and returns
a reference to the created object.
CellLibraries Import2 Adds a CellLibrary object to the collection from a file and
returns a reference to the created object.
CellLibraries Import Adds a Netlist object to the collection from a file and returns
a reference to the created object.
DataFiles Import Adds a Netlist object to the collection from a file and returns
a reference to the created object.
DataSetFolders Import Adds a Netlist object to the collection from a file and returns
a reference to the created object.
DesignNote Import Imports a Rich Text File into the DesignNote object.
DesignRules Import Adds a Netlist object to the collection from a file and returns
a reference to the created object.
DesignRules ImportDefaultRules Adds a Netlist object to the collection from a file and returns
a reference to the created object.
EM3DStructures Import Adds a Netlist object to the collection from a file and returns
a reference to the created object.
EMStructures Import Adds a Netlist object to the collection from a file and returns
a reference to the created object.

API Scripting Guide 243


LinkTo

Object Method Help Description


LayoutProcessDefinitions Import Adds a Netlist object to the collection from a file and returns
a reference to the created object.
Netlists Import Adds a Netlist object to the collection from a file and returns
a reference to the created object.
Schematics Import Adds a Netlist object to the collection from a file and returns
a reference to the created object.
ScriptModules Import Adds a Netlist object to the collection from a file and returns
a reference to the created object.
Symbols Import Adds a Netlist object to the collection from a file and returns
a reference to the created object.
SystemDiagrams Import Adds a Netlist object to the collection from a file and returns
a reference to the created object.

LinkTo
This page is for the common method LinkTo and all the objects that use this method.

Object Method Help Description


CellLibraries LinkTo Adds a CellLibrary object to the collection linked the library
file and returns a reference to the created object.
DataFiles LinkTo Adds a DataFile object link to the collection from a file and
returns a reference to the created object.
EM3DStructures LinkTo Adds an Electromagnetic structure referencing an external
file and returns a reference to the created object.
EMStructures LinkTo Adds an Electromagnetic structure referencing an external
file and returns a reference to the created object.
Netlists LinkTo Adds a Netlist object link to the collection from a file and
returns a reference to the created object.
Schematics LinkTo Adds a Schematic object link to the collection from a file
and returns a reference to the created object.
SystemDiagrams LinkTo Adds a SystemDiagram object link to the collection from a
file and returns a reference to the created object.

Coptions
This page is for the common property Coptions and all the objects that use this property.

Object Help Description


Application Returns a reference to a collection of Option objects.
DataFile Returns a reference to a collection of Option objects.
DataFiles Returns a reference to a collection of Option objects.
DataSetFolders Returns a reference to a collection of Option objects.
EMStructure Returns a reference to a collection of Option objects.

244 NI AWR Design Environment


Application

Object Help Description


EMStructures Returns a reference to a collection of Option objects.
Element Returns a reference to a collection of Option objects.
Layout Returns a reference to a collection of Option objects.
LayoutModeSet Returns a reference to a collection of Option objects.
Markers Returns a reference to an MWOffice MarkerOptions object.
Project Returns a reference to a collection of Option objects.
Schematic Returns a reference to a collection of Option objects.
Schematics Returns a reference to a collection of Option objects.
SystemDiagram Returns a reference to a collection of Option objects.
SystemDiagrams Returns a reference to a collection of Option objects.

Application
The MWOffice application object.

Properties

Name Data Type Description


Active Boolean Activates the Window associated with the object.
AppName String Returns/Sets the name used in code to identify an object.
Arguments Arguments Returns a reference to a MWOffice Arguments collection.
Attributes Attributes Returns a reference to a collection of Attribute objects.
AvailableProcessLibraries ProcessLibraryInfos Returns a reference to a MWOffice FoundryLibrariess
collection.
BuildNumber Integer Returns the build number of MWOffice.
BuildRevision Long Returns the build revsion for the MWOffice Application.
CanSendEMail Boolean Returns a value that indicates if the MWOffice Application
can send email.
Caption String Returns/Sets the caption of an object.
CellMappings CellMappings Returns a reference to a collection of MWOffice
CellMapping objects.
CommandTables CommandTables Returns a reference to a collection of CommandTable
objects.
ControlBars ControlBars Returns a reference to a collection of ControlBar objects.
Directories Attributes Returns a reference to a collection of Attribute objects.
ExeName String Returns the name of the MWOffice application executable
file.
FileUtil FileUtil Returns a reference to a MWOffice FileUtil object.
Files Attributes Returns a reference to a collection of Attribute objects.
GlobalProject Project

API Scripting Guide 245


Application

Name Data Type Description


GlobalScripts ScriptModules Returns a reference to a collection of ScriptModule objects.
Height Long Returns/sets the height of a Window object.
HotkeyTables HotkeyTables Returns a reference to a collection of HotkeyTable objects.
InstanceCLSID String Returns the CLSID of the current MWOffice Application
instance
JobControlMonitor JobMonitor Returns a reference to a JobMonitor object.
LayoutCells LayoutCells Returns a reference to a collection of LayoutCell objects.
LayoutModes LayoutModeSets Returns a reference to a MWOffice LayoutModeSets
collection.
Left Long Returns/sets the left edge of a Window object.
Libraries Libraries Returns a reference to a MWOffice Libraries collection.
MathUtil MathUtil Returns a reference to a MWOffice MathUtil object.
MeasurementInfos MeasurementInfos Returns a reference to a collection of MeasurementInfo
objects.
Models Models Returns a reference to a collection of Model objects
representing the available circuit elements.
ModifierLibrary ShapeModifierRecords Returns a reference to a collection of ShapeModifier objects.
Options Options Returns a reference to a collection of Option objects.
PageSetup PageSetup Returns a reference to a PageSetup object.
Path String Returns the path of the MWOffice application.
Project Project Returns a reference to the Project object.
ProjectOpen Boolean Returns a value that indicates if the MWOffice Application
currently has a project open.
RecentProjects ProjectFiles Returns a reference to a MWOffice ProjectFiles collection.
ScaleHeight Long Returns the height of a Window object's interior.
ScaleWidth Long Returns the width of a Window object's interior.
Setting Variant Returns/Sets a persisted setting of the MWOffice
application.
StackupUtil StackupUtil Returns a reference to a MWOffice MathUtil object.
Status Status Returns a reference to a MWOffice Status object.
SystemModels Models Returns a reference to a collection of Model objects
representing the available system blocks.
Top Long Returns/sets the top edge of a Window object.
UserSetting Variant Returns/Sets a persisted user setting of the MWOffice
application.
Version Float Returns the version number of MWOffice.
VersionString String Returns the version string for the MWOffice Application.
Visible Boolean Returns/sets a value which specifies if the object is visible.
Width Long Returns/sets the width of a Window object.

246 NI AWR Design Environment


Application

Name Data Type Description


WindowState mwWindowState Returns the screen state of a Window object.
Windows Windows Returns a reference to a collection of Window objects.
hWnd Long Returns the window handle of the MWOffice main window.

Methods
Activate

Description: Activates the Window associated with the object.

Returns: Void

Syntax: Sub Activate()

CreateEMail

Description: Returns a reference to a MWOffice EMail object.

Returns: EMail

Syntax: Function CreateEMail() As EMail

Dispose

Description: Releases object references being held by MWOffice.

Returns: Void

Syntax: Sub Dispose()

InvokeCommand

Description: Invoke a application level menu command by name. Any required input will need to be supplied in the
arguments.

Returns: Void

Syntax: Sub InvokeCommand(CommandName As String, [Arguments], [pRet])

New

Description: Creates a new Project.

Returns: Boolean

Syntax: Function New([Name As String]) As Boolean

NewWithProcessLibrary

Description: Creates a new Project with a Process Library.

Returns: Void

API Scripting Guide 247


Application

Syntax: Sub NewWithProcessLibrary(ProcessLibrary As String)

Open

Description: Opens an existing Project.

Returns: Boolean

Syntax: Function Open(Filename As String) As Boolean

Quit

Description: Quits the MWOffice Application.

Returns: Void

Syntax: Sub Quit()

SendEMail

Description: Sends the provided email object.

Returns: Boolean

Syntax: Function SendEMail(ppEmail As EMail) As Boolean

StartCommand

Description: Start a application level menu command by name. Any required input will need to be supplied by the user
interactively.

Returns: Void

Syntax: Sub StartCommand(CommandName As String, [pRet])

Events
NewProject

Description: Occurs when a new Project is created.

Returns: HRESULT

Syntax: Event NewProject(Project As Project)

OpenProject

Description: Occurs when an existing Project is opened.

Returns: HRESULT

Syntax: Event OpenProject(Project As Project)

248 NI AWR Design Environment


Application

ProjectAfterClose

Description: Occurs after a Project has closed.

Returns: HRESULT

Syntax: Event ProjectAfterClose(ProjectName As String)

ProjectAfterSave

Description: Occurs after a Project has been saved.

Returns: HRESULT

Syntax: Event ProjectAfterSave(Project As Project)

ProjectBeforeClose

Description: Occurs when a Project is about to close.

Returns: HRESULT

Syntax: Event ProjectBeforeClose(Project As Project, Cancel As Boolean)

ProjectBeforeSave

Description: Occurs when a Project is about to be saved.

Returns: HRESULT

Syntax: Event ProjectBeforeSave(Project As Project, Cancel As Boolean)

ProjectOpen

Description: Occurs when an existing Project is opened.

Returns: HRESULT

Syntax: Event ProjectOpen(Project As Project)

Options

Number Name Description


1 ShowTopLevelOnly Returns/sets if project should display only top level
schematic nodes.
2 OptionNodesInProject Returns/sets if options nodes should be displayed in project
tree.
3 CollapseProjectTreeOnOpen Returns/sets if project tree should be collapsed on open.
4 EvironmentOptionsInProject Returns/sets if the environment options should be displayed
in project tree.
5 SaveRevisions Returns/sets if revisions are to be saved.

API Scripting Guide 249


Application

Number Name Description


6 AutoSaveProject Returns/sets the interval in minutes between automatic
project saves.
7 AutoSaveInterval Returns/sets the interval in minutes between automatic
project saves.
8 RevisionCount Returns/sets the number of revisions to save.
9 SaveBeforeSimulating Returns/sets if the project should be saved prior to
simulation.
10 ShowSplashScreen Returns/sets if the splash screen should be displayed on
startup.
11 RunScriptingEnv Returns/sets if the scripting environment should be run on
startup.
12 DrawDisabledGoals Returns/sets if disabled optimization and yield goals draw
on graphs.
13 EqnEditAutoComplete Returns/sets if equation editing displays an auto-completion
list.
14 DiagramTextColor Returns/sets the text color for schematics and system
diagrams.
15 DiagramWireColor Returns/sets the wire color for schematics and system
diagrams.
16 DiagramNodeColor Returns/sets the node color for schematics and system
diagrams.
17 DiagramDisabledColor Returns/sets the disabled element color for schematics and
system diagrams.
18 SchematicBackColor Returns/sets the background color for schematic diagrams.
19 SchematicGridColor Returns/sets the grid color for schematic diagrams.
20 ElementNormalColor Returns/sets the normal element color for schematic
diagrams.
21 ElementLayoutColor Returns/sets the element with a layout color in schematic
diagrams.
22 SchematicSourceColor Returns/sets the source element color in schematic diagrams.
23 SchematicMeterColor Returns/sets the meter element color in schematic diagrams.
24 SystemBackColor Returns/sets the background color for system diagrams.
25 SystemGridColor Returns/sets the grid color for system diagrams.
26 SystemElementNormalColor Returns/sets the normal element color for system diagrams.
27 SystemSourceColor Returns/sets the source element color for system diagrams.
28 LayoutBackColor Returns/sets the background color for layouts.
29 LayoutGridColor Returns/sets the grid color for layouts.
30 PlainTextColor Returns/sets the color of text objects in any view.
31 SchemShapeColor Returns/sets the color of non-layout shapes.

250 NI AWR Design Environment


Application

Number Name Description


32 TuneParamColor Returns/sets the color of equations and parameters marked
for tuning.
33 TuneOptParamColor Returns/sets the color of equations and parameters marked
for tuning and optimizing.
34 OptParamColor Returns/sets the color of equations and parameters marked
for optimizing.
35 ReadOnlyParamColor Returns/sets the color of parameters that are read-only.
36 GraphBackColor Returns/sets the background color for all graphs.
37 NetRoutedColor Returns/sets the color of schematic nodes/wires that
represented routed nets.
38 OutputEqnColor Returns/sets the color of measurement equations in the
output equation window.
39 HideSymbolElementNodes Returns/sets the visibility of the schematic element nodes.
40 SymbolLinesBack Returns/sets if the element symbols are drawn black or in
color.
41 BoldElementNamesBold Returns/sets if element names are draw in bold.
42 BoldParameterNames Returns/sets if the element parameters are drawn in bold.
43 SymbolLineThickness Returns/sets line width for drawing element symbols.
44 DependentParametersInBaseUnits Returns/sets if schematic dependent parameters should be
in base units.
45 SchemElementFontSize Sets the size for element parameter text in schematic designs.
46 SchemEquationFontSize Sets the size for equation text in schematic designs.
47 SchemElementFontName Sets the font name for the element parameter text in
schematic designs.
48 SchemEquationFontName Sets the font name for equation text in schematic designs.
49 LayoutSnapTogetherMode Returns/sets the snap-together mode.
50 LayoutNoRotateOnSnap Returns/sets if rotation should be allowed during snapping
in layouts.
51 LayoutScalePrintouts Returns/sets if layout printouts should be scaled
52 LayoutPrintScaleFactor Returns/sets the layout printout scale factor
53 LayoutPrintMaxLayervisible Returns/sets if the printout should include max layer visible
54 LayoutDefaultFaceAlign Returns/sets the default face alignment set for newly created
cells.
55 LayoutEnablePinAreaDef Returns/sets if the pin area should be enabled by default on
newly placed cells.
56 LayoutProjectTopLevelCellsOnly Returns/sets if the layout project should display only
top-level cells.
57 ShowDerivedLPF Returns/sets if the layout project should display EM
document's LPF.

API Scripting Guide 251


Project

Number Name Description


58 LayoutSnapToAdjacentDef Returns/sets if the face should be set to snap to adjacent
faces by default.
59 SysDependentParametersInBaseUnits Returns/sets if system diagram dependent parameters should
be in base units
60 EnableElementAlignmentGuides Returns/sets if alignment guides enabled for moving and
placement elements in schematic and system designs.

Project
An MWOffice Project object.

Properties

Name Data Type Description


Annotations Annotations Returns a reference to a MWOffice Annotations collection.
AppVersion Long Returns the application version used to create the project.
Application Application The MWOffice application object.
BuildNumber Long Returns the build number of the version used to create the
project.
CellLibraries CellLibraries Returns a reference to a collection of Cell Library objects.
DataFiles DataFiles Returns a reference to a collection of Datafile objects.
DataSetFolders DataSetFolders Returns a reference to a collection of DataSetFolder objects.
DesignNotes DesignNotes Returns a reference to a DesignNotes collection.
EM3DStructures EM3DStructures Returns a reference to a collection of EM3DStructures.
EMStructures EMStructures Returns a reference to a collection of Electromagnetic
Structure objects.
ErrorState mwErrorType Returns the error state of a Project object.
Filename String Returns the name of the current project file including the
filename extension or 'Untitled Project' if the project has
not been saved
Frequencies Frequencies Returns a reference to a collection of Frequency objects.
FullName String Returns the file specification of the project including the
path.
GlobalDefinitionDocuments GlobalDefinitionDocuments Returns a reference to a collection of
GlobalDefinitionDocument objects.
GlobalEquationsWindows Windows Returns a reference to a collection of Window objects.
Graphs Graphs Returns a reference to a collection of Graph objects.
HasEventScripts Boolean Returns a value indicating if the project contains event
scripts.
LockUpdates Boolean Returns/sets a value that indicates if updates should be
locked or disabled.

252 NI AWR Design Environment


Project

Name Data Type Description


Name String Returns the file name of the project not including the file's
path specification.
Netlists Netlists Returns a reference to a collection of Netlist objects.
OptGoals OptGoals Returns a reference to a collection of Goal objects.
Optimizer Optimizer Returns a reference to the Optimizer object.
Options Options Returns a reference to a collection of Option objects.
OutputEquationDocuments OutputEquationDocuments Returns a reference to a collection of
OutputEquationDocument objects.
OutputEquationsWindows Windows Returns a reference to a collection of Window objects.
OutputFiles OutputFiles Returns a reference to a MWOffice OutputFiles collection.
Parent Application The MWOffice application object.
Path String Returns the path specification for the project not including
the file name or file name extension.
ProcessDefinitions LayoutProcessDefinitions Returns a reference to a MWOffice LayoutProcessDefinition
object.
ProcessLibraries ProcessLibraries Returns a reference to a MWOffice FoundryLibrariess
collection.
ProjectScripts ScriptModules Returns a reference to a collection of ScriptModule objects.
ProjectSymbols Symbols Returns a reference to a collection of Symbol objects.
Properties Properties Returns a reference to a collection of Property objects.
ReadOnly Boolean Returns True if the project file is read only otherwise False.
RoutePropertyInfo RoutePropertyInfo Returns a reference to a RoutePropertyInfo object.
Saved Boolean Returns False if the project has changed otherwise True.
Schematics Schematics Returns a reference to a collection of Schematic objects.
SelectFilters CSelectFilters Returns a reference to a collection of MWOffice SelectFilter
objects.
SimulationFilters SimulationFilters Returns a reference to a collection of MWOffice
SimulationFilter objects.
SimulationResults SimulationResults Returns a reference to a collection of MWOffice
SimulationResult objects.
Simulator Simulator Returns a reference to a Simulator object.
Sweeper Sweeper Returns a reference to a Sweeper object.
SwitchLists SwitchLists Returns a reference to a collection of MWOffice SwitchList
objects.
Symbols Symbols Returns a reference to a collection of Symbol objects.
Synthesizer Synthesizer Returns a reference to a Synthesis object.
SystemDiagrams SystemDiagrams Returns a reference to a collection of SystemDiagram
objects.

API Scripting Guide 253


Project

Name Data Type Description


TreeView ProjectTreeView Returns a reference to the MWOffice project TreeView
object.
Tuner Tuner Returns a reference to a MWOffice Tuner object.
Units Units Returns a reference to a collection of Unit objects.
UserFolders UserFolder Returns a reference to a MWOffice Folders collection.
WizardDocs WizardDocs Returns a reference to a MWOffice WizardDocs collection.
Wizards Wizards Returns a reference to a MWOffice Wizards collection.
YieldAnalyzer Optimizer Returns a reference to the Optimizer object.
YieldGoals YieldGoals Returns a reference to a collection of Goal objects.

Methods
Close

Description: Closes the project and all windows associated with the project.

Returns: Void

Syntax: Sub Close([SaveChanges As Boolean], [Filename As String])

Import

Description: Merges one project into another.

Returns: Void

Syntax: Sub Import(Filename As String, [SuppressWarings As Boolean = 0])

ImportTestbench

Description: Merges one project into another.

Returns: Void

Syntax: Sub ImportTestbench(Filename As String, [SuppressWarings As Boolean = 0])

NewGlobalEquationsWindow

Description: Displays the object in new window.

Returns: Window

Syntax: Function NewGlobalEquationsWindow() As Window

NewOutputEquationsWindow

Description: Displays the object in new window.

Returns: Window

254 NI AWR Design Environment


Project

Syntax: Function NewOutputEquationsWindow() As Window

Save

Description: Saves changes to the project file specified in the project's FullName property.

Returns: Boolean

Syntax: Function Save() As Boolean

SaveAs

Description: Saves the project to a file.

Returns: Void

Syntax: Sub SaveAs(Filename As String)

SaveAsTemplate

Description: Saves the project to a file as a template.

Returns: Void

Syntax: Sub SaveAsTemplate(Filename As String, Type As mwProjectTemplateType)

SaveAsVersion

Description: Saves the project to a file as a specified version.

Returns: Void

Syntax: Sub SaveAsVersion(Filename As String, Type As mwProjectVersionType, [VersionNumber As Double = 0])

Events
AfterSave

Description: Occurs after a Project has been saved.

Returns: HRESULT

Syntax: Event AfterSave()

AfterSimulate

Description: Occurs after a circuit simulation has completed.

Returns: HRESULT

Syntax: Event AfterSimulate()

AfterSystemSimulate

Description: Occurs after a system simulation has completed.

API Scripting Guide 255


Project

Returns: HRESULT

Syntax: Event AfterSystemSimulate()

BeforeClose

Description: Occurs when a Project is about to close.

Returns: HRESULT

Syntax: Event BeforeClose(Cancel As Boolean)

BeforeSave

Description: Occurs when a Project is about to be saved.

Returns: HRESULT

Syntax: Event BeforeSave(Cancel As Boolean)

BeforeSimulate

Description: Occurs when a circuit simulation is about to start.

Returns: HRESULT

Syntax: Event BeforeSimulate(Cancel As Boolean)

BeforeSystemSimulate

Description: Occurs when a system simulation is about to start.

Returns: HRESULT

Syntax: Event BeforeSystemSimulate(Cancel As Boolean)

CellLibraryAfterRemove

Description: Occurs after a CellLibrary has been removed from a Project.

Returns: HRESULT

Syntax: Event CellLibraryAfterRemove(CellLibraryName As String)

CellLibraryAfterRename

Description: Occurs after a CellLibrary has is renamed.

Returns: HRESULT

Syntax: Event CellLibraryAfterRename(CellLibrary As CellLibrary, OldName As String)

CellLibraryBeforeRemove

Description: Occurs when a CellLibrary is about to be removed from a Project.

256 NI AWR Design Environment


Project

Returns: HRESULT

Syntax: Event CellLibraryBeforeRemove(CellLibrary As CellLibrary, Cancel As Boolean)

CellLibraryBeforeRename

Description: Occurs when a CellLibrary is about to be renamed.

Returns: HRESULT

Syntax: Event CellLibraryBeforeRename(CellLibrary As CellLibrary, NewName As String, Cancel As Boolean)

DataFileAfterRemove

Description: Occurs after a DataFile has been removed from a Project.

Returns: HRESULT

Syntax: Event DataFileAfterRemove(DataFileName As String)

DataFileAfterRename

Description: Occurs after a DataFile has is renamed.

Returns: HRESULT

Syntax: Event DataFileAfterRename(DataFile As DataFile, OldName As String)

DataFileBeforeRemove

Description: Occurs when a DataFile is about to be removed from a Project.

Returns: HRESULT

Syntax: Event DataFileBeforeRemove(DataFile As DataFile, Cancel As Boolean)

DataFileBeforeRename

Description: Occurs when a DataFile is about to be renamed.

Returns: HRESULT

Syntax: Event DataFileBeforeRename(DataFile As DataFile, NewName As String, Cancel As Boolean)

EMStructureAfterRemove

Description: Occurs after a EMStructure has been removed from a Project.

Returns: HRESULT

Syntax: Event EMStructureAfterRemove(EMStructureName As String)

EMStructureAfterRename

Description: Occurs after a EMStructure has is renamed.

API Scripting Guide 257


Project

Returns: HRESULT

Syntax: Event EMStructureAfterRename(EMStructure As EMStructure, OldName As String)

EMStructureBeforeRemove

Description: Occurs when a EMStructure is about to be removed from a Project.

Returns: HRESULT

Syntax: Event EMStructureBeforeRemove(EMStructure As EMStructure, Cancel As Boolean)

EMStructureBeforeRename

Description: Occurs when a EMStructure is about to be renamed.

Returns: HRESULT

Syntax: Event EMStructureBeforeRename(EMStructure As EMStructure, NewName As String, Cancel As Boolean)

GraphAfterRemove

Description: Occurs after a Graph has been removed from a Project.

Returns: HRESULT

Syntax: Event GraphAfterRemove(GraphName As String)

GraphAfterRename

Description: Occurs after a Graph has is renamed.

Returns: HRESULT

Syntax: Event GraphAfterRename(Graph As Graph, OldName As String)

GraphBeforeRemove

Description: Occurs when a Graph is about to be removed from a Project.

Returns: HRESULT

Syntax: Event GraphBeforeRemove(Graph As Graph, Cancel As Boolean)

GraphBeforeRename

Description: Occurs when a Graph is about to be renamed.

Returns: HRESULT

Syntax: Event GraphBeforeRename(Graph As Graph, NewName As String, Cancel As Boolean)

GraphNewMeasurement

Description: Occurs when an Measurement is added to a Graph.

258 NI AWR Design Environment


Project

Returns: HRESULT

Syntax: Event GraphNewMeasurement(Graph As Graph, Measurement As Measurement)

NetlistAfterRemove

Description: Occurs after a Netlist has been removed from a Project.

Returns: HRESULT

Syntax: Event NetlistAfterRemove(NetlistName As String)

NetlistAfterRename

Description: Occurs after a Netlist has is renamed.

Returns: HRESULT

Syntax: Event NetlistAfterRename(Netlist As Netlist, OldName As String)

NetlistBeforeRemove

Description: Occurs when a Netlist is about to be removed from a Project.

Returns: HRESULT

Syntax: Event NetlistBeforeRemove(Netlist As Netlist, Cancel As Boolean)

NetlistBeforeRename

Description: Occurs when a Netlist is about to be renamed.

Returns: HRESULT

Syntax: Event NetlistBeforeRename(Netlist As Netlist, NewName As String, Cancel As Boolean)

New

Description: Occurs when a new Project is created.

Returns: HRESULT

Syntax: Event New()

NewCellLibrary

Description: Occurs when a CellLibrary is added to a Project.

Returns: HRESULT

Syntax: Event NewCellLibrary(CellLibrary As CellLibrary)

NewDataFile

Description: Occurs when a DataFile is added to a Project.

API Scripting Guide 259


Project

Returns: HRESULT

Syntax: Event NewDataFile(DataFile As DataFile)

NewEMStructure

Description: Occurs when a EMStructure is added to a Project.

Returns: HRESULT

Syntax: Event NewEMStructure(EMStructure As EMStructure)

NewGraph

Description: Occurs when a Graph is added to a Project.

Returns: HRESULT

Syntax: Event NewGraph(Graph As Graph)

NewNetlist

Description: Occurs when a Netlist is added to a Project.

Returns: HRESULT

Syntax: Event NewNetlist(Netlist As Netlist)

NewOptGoal

Description: Occurs when a OptGoal is added to a Project.

Returns: HRESULT

Syntax: Event NewOptGoal(OptGoal As Goal)

NewOutputFile

Description: Occurs when a OutputFile is added to a Project.

Returns: HRESULT

Syntax: Event NewOutputFile(OutputFile As OutputFile)

NewProcessDefinition

Description: Occurs when a LayoutProcessDefinition is added to a Project.

Returns: HRESULT

Syntax: Event NewProcessDefinition(ProcessDefinition As LayoutProcessDefinition)

NewSchematic

Description: Occurs when a Schematic is added to a Project.

260 NI AWR Design Environment


Project

Returns: HRESULT

Syntax: Event NewSchematic(Schematic As Schematic)

NewSystemDiagram

Description: Occurs when a SystemDiagram is added to a Project.

Returns: HRESULT

Syntax: Event NewSystemDiagram(SystemDiagram As SystemDiagram)

NewYieldGoal

Description: Occurs when a YeildGoal is added to a Project.

Returns: HRESULT

Syntax: Event NewYieldGoal(YieldGoal As Goal)

Open

Description: Occurs when an existing Project is opened.

Returns: HRESULT

Syntax: Event Open()

OptGoalAfterChange

Description: Occurs after a OptGoal has is changed.

Returns: HRESULT

Syntax: Event OptGoalAfterChange(OptGoal As Goal, OldGoal As String)

OptGoalAfterRemove

Description: Occurs after a OptGoal has been removed from a Project.

Returns: HRESULT

Syntax: Event OptGoalAfterRemove(OptGoal As String)

OptGoalAfterToggleEnable

Description: Occurs after a OptGoal has is toggle enabled.

Returns: HRESULT

Syntax: Event OptGoalAfterToggleEnable(OptGoal As Goal)

OptGoalBeforeChange

Description: Occurs when a OptGoal is about to be changed.

API Scripting Guide 261


Project

Returns: HRESULT

Syntax: Event OptGoalBeforeChange(OptGoal As Goal, NewGoal As String, Cancel As Boolean)

OptGoalBeforeRemove

Description: Occurs when a OptGoal is about to be removed from a Project.

Returns: HRESULT

Syntax: Event OptGoalBeforeRemove(OptGoal As Goal, Cancel As Boolean)

OptGoalBeforeToggleEnable

Description: Occurs when a OptGoal is about to be toggle enabled.

Returns: HRESULT

Syntax: Event OptGoalBeforeToggleEnable(OptGoal As Goal, Cancel As Boolean)

OptimizerIteration

Description: Occurs at each iteration of an Optimization.

Returns: HRESULT

Syntax: Event OptimizerIteration(Optimizer As Optimizer)

OptimizerStarted

Description: Occurs when an Optimization has been started.

Returns: HRESULT

Syntax: Event OptimizerStarted(Optimizer As Optimizer)

OptimizerStopped

Description: Occurs when an Optimization has stopped.

Returns: HRESULT

Syntax: Event OptimizerStopped(Optimizer As Optimizer)

OutputFileAfterRemove

Description: Occurs after a OutputFile has been removed from a Project.

Returns: HRESULT

Syntax: Event OutputFileAfterRemove(OutputFileName As String)

OutputFileAfterRename

Description: Occurs after a OutputFile has is renamed.

262 NI AWR Design Environment


Project

Returns: HRESULT

Syntax: Event OutputFileAfterRename(OutputFile As OutputFile, OldName As String)

OutputFileBeforeRemove

Description: Occurs when a OutputFile is about to be removed from a Project.

Returns: HRESULT

Syntax: Event OutputFileBeforeRemove(OutputFile As OutputFile, Cancel As Boolean)

OutputFileBeforeRename

Description: Occurs when a OutputFile is about to be renamed.

Returns: HRESULT

Syntax: Event OutputFileBeforeRename(OutputFile As OutputFile, NewName As String, Cancel As Boolean)

ProcessDefinitionAfterChange

Description: Occurs after a LayoutProcessDefinition has is changed.

Returns: HRESULT

Syntax: Event ProcessDefinitionAfterChange(ProcessDefinition As LayoutProcessDefinition)

ProcessDefinitionAfterRemove

Description: Occurs after a LayoutProcessDefinition has been removed from a Project.

Returns: HRESULT

Syntax: Event ProcessDefinitionAfterRemove(ProcessDefinitionName As String)

ProcessDefinitionBeforeChange

Description: Occurs when a LayoutProcessDefinition is about to be changed.

Returns: HRESULT

Syntax: Event ProcessDefinitionBeforeChange(ProcessDefinition As LayoutProcessDefinition, Cancel As Boolean)

ProcessDefinitionBeforeRemove

Description: Occurs when a LayoutProcessDefinition is about to be removed from a Project.

Returns: HRESULT

Syntax: Event ProcessDefinitionBeforeRemove(ProcessDefinition As LayoutProcessDefinition, Cancel As Boolean)

SchematicAfterRemove

Description: Occurs after a Schematic has been removed from a Project.

API Scripting Guide 263


Project

Returns: HRESULT

Syntax: Event SchematicAfterRemove(SchematicName As String)

SchematicAfterRename

Description: Occurs after a Schematic has is renamed.

Returns: HRESULT

Syntax: Event SchematicAfterRename(Schematic As Schematic, OldName As String)

SchematicBeforeRemove

Description: Occurs when a Schematic is about to be removed from a Project.

Returns: HRESULT

Syntax: Event SchematicBeforeRemove(Schematic As Schematic, Cancel As Boolean)

SchematicBeforeRename

Description: Occurs when a Schematic is about to be renamed.

Returns: HRESULT

Syntax: Event SchematicBeforeRename(Schematic As Schematic, NewName As String, Cancel As Boolean)

SchematicElementAfterRemove

Description: Occurs after an Element has been removed from a Schematic.

Returns: HRESULT

Syntax: Event SchematicElementAfterRemove(Schematic As Schematic, ElementId As String)

SchematicElementBeforeRemove

Description: Occurs when an Element is about to be removed from a Schematic.

Returns: HRESULT

Syntax: Event SchematicElementBeforeRemove(Schematic As Schematic, Element As Element, Cancel As Boolean)

SchematicNewElement

Description: Occurs when an Element is added to a Schematic.

Returns: HRESULT

Syntax: Event SchematicNewElement(Schematic As Schematic, Element As Element)

SystemDiagramAfterRemove

Description: Occurs after a SystemDiagram has been removed from a Project.

264 NI AWR Design Environment


Project

Returns: HRESULT

Syntax: Event SystemDiagramAfterRemove(SystemDiagramName As String)

SystemDiagramAfterRename

Description: Occurs after a SystemDiagram has is renamed.

Returns: HRESULT

Syntax: Event SystemDiagramAfterRename(SystemDiagram As SystemDiagram, OldName As String)

SystemDiagramBeforeRemove

Description: Occurs when a SystemDiagram is about to be removed from a Project.

Returns: HRESULT

Syntax: Event SystemDiagramBeforeRemove(SystemDiagram As SystemDiagram, Cancel As Boolean)

SystemDiagramBeforeRename

Description: Occurs when a SystemDiagram is about to be renamed.

Returns: HRESULT

Syntax: Event SystemDiagramBeforeRename(SystemDiagram As SystemDiagram, NewName As String, Cancel As


Boolean)

SystemDiagramElementAfterRemove

Description: Occurs after an Element has been removed from a System Diagram.

Returns: HRESULT

Syntax: Event SystemDiagramElementAfterRemove(SystemDiagram As SystemDiagram, ElementId As String)

SystemDiagramElementBeforeRemove

Description: Occurs when an Element is about to be removed from a System Diagram.

Returns: HRESULT

Syntax: Event SystemDiagramElementBeforeRemove(SystemDiagram As SystemDiagram, Element As Element, Cancel


As Boolean)

SystemDiagramNewElement

Description: Occurs when an Element is added to a System Diagram.

Returns: HRESULT

Syntax: Event SystemDiagramNewElement(SystemDiagram As SystemDiagram, Element As Element)

API Scripting Guide 265


Project

YieldAnalysisIteration

Description: Occurs at each iteration of an Yield Analysis.

Returns: HRESULT

Syntax: Event YieldAnalysisIteration(YieldAnalyzer As Optimizer)

YieldAnalysisStarted

Description: Occurs when an Yield Analysis has been started.

Returns: HRESULT

Syntax: Event YieldAnalysisStarted(YieldAnalyzer As Optimizer)

YieldAnalysisStopped

Description: Occurs when an Yield Analysis has stopped.

Returns: HRESULT

Syntax: Event YieldAnalysisStopped(YieldAnalyzer As Optimizer)

YieldGoalAfterChange

Description: Occurs after a YeildGoal has is changed.

Returns: HRESULT

Syntax: Event YieldGoalAfterChange(YieldGoal As Goal, OldGoal As String)

YieldGoalAfterRemove

Description: Occurs after a YeildGoal has been removed from a Project.

Returns: HRESULT

Syntax: Event YieldGoalAfterRemove(YieldGoal As String)

YieldGoalAfterToggleEnable

Description: Occurs after a YeildGoal has is toggle enabled.

Returns: HRESULT

Syntax: Event YieldGoalAfterToggleEnable(YieldGoal As Goal)

YieldGoalBeforeChange

Description: Occurs when a YeildGoal is about to be changed.

Returns: HRESULT

Syntax: Event YieldGoalBeforeChange(YieldGoal As Goal, NewGoal As String, Cancel As Boolean)

266 NI AWR Design Environment


Project

YieldGoalBeforeRemove

Description: Occurs when a YeildGoal is about to be removed from a Project.

Returns: HRESULT

Syntax: Event YieldGoalBeforeRemove(YieldGoal As Goal, Cancel As Boolean)

YieldGoalBeforeToggleEnable

Description: Occurs when a YeildGoal is about to be toggle enabled.

Returns: HRESULT

Syntax: Event YieldGoalBeforeToggleEnable(YieldGoal As Goal, Cancel As Boolean)

Options

Number Name Description


1 HideParameters Returns/sets if parameters should be hidden on diagrams.
2 HideParameterUnits Returns/sets if parameters units should be hidden on
diagrams.
3 HideParameterIfEmpty Returns/sets if empty parameters should be hidden on
diagrams.
4 HideParameterVarName Returns/sets if variable names should be hidden on diagrams
5 LeftJustifyParameters Returns/sets if parameters should be left justified on
diagrams.
6 BoldParameterFont Returns/sets if parameters names should use a bold font on
diagrams.
7 HideElementNames Returns/sets if element names should be hidden on system
diagrams.
8 BoldElementFont Returns/sets if element names should use a bold font on
diagrams.
9 LeftJustifyElementName Returns/sets if element names should be left justified.
10 HideSecondaryParameters Returns/sets if secondary parameters should be hidden.
11 SymbolLineThickness Returns/sets if the thickness for drawing symbol lines.
12 BlackAndWhite Returns/sets if elements should be drawn in black and white
13 DependentParametersInBaseUnits Returns/sets if schematic dependent parameters should be
in base units.
14 SignificantParameterDigits Returns/sets the number of significant digits displayed in
element parameters.
15 ParameterZeroThreshold Returns/sets the zero threshold number for element
parameters.
16 SchematicCleanUpWires Returns/sets if the schematic should automatically cleanup
dangling wires.

API Scripting Guide 267


Project

Number Name Description


17 ParametersMultiColumn Returns/sets if element parameters use multiple columns to
display.
18 NumberInterpolationPoints Returns/sets the number of points used for interpolation.
19 InterpolationWindowSize Returns/sets the window size used for interpolation.
20 InterpolationSplineOrder Returns/sets the spline order used for interpolation.
21 InterpolationMethod Returns/sets the method used for interpolation.
22 InterpolationCoordinates Returns/sets the interpolation coordinate system type.
23 EnableInterpolation Returns/sets if parameter interpolation is enabled in EM
documents
24 ConsiderPassiveForNoise Returns/sets if passive elements should be considered in
noise calculations.
25 LayoutGridSpacing Returns/sets the grid spacing for layouts in the project.
26 LayoutDatabaseUnits Returns/sets the database units for layouts in the project.
27 LayoutAngleSnapDiv Returns/sets the number of snap divisions per quadrant for
layouts in the project.
28 LayoutSnapTogetherMode Returns/sets the snap-together mode.
29 LayoutNoRotateOnSnap Returns/sets if rotation should be allowed during snapping
in layouts.
30 FaceInsetOptions Returns/sets the automatic options for face insets on layouts.
31 LayoutPointsPerCircle Returns/Sets the number of points used per circle in layout
32 LayoutConnectionLineType Returns/Sets the type of lines drawn between connected
objects in layout, values come from
mwLayoutConnectionLineTypes enumeration
33 LayDefaultClosestFace Layout default connections to closest face.
34 LayFixedCellOrigin Layout keep cell origin fixed rather than using fixed face
for placement
35 LayFixedSubCktOrigin Layout keep subcircuit origin fixed rather than using fixed
face for placement
36 LayCellOriginOnGrid Layout always keep cell origins on grid
37 LayLockSubCktHierUpdate Layout cache hierarchical update notifications during
subcircuit editing
38 LayExcludePcell Layout allows pcell origins to float
39 InstanceExportOptions Returns/sets the options for exporting instances from layout.
40 ExportMergeShapes Returns/sets if layout shapes on +/- layers should be merged
on export.
41 ExportSubcircuitsAsInstances Returns/sets if subcircuits should be exported as instances.
42 LayoutCellExportOptions Returns/sets the options for exporting layout cells from
layout.
43 LayCellLimitNameLen Layout limit cell names to comply with GDSII library
specifications.

268 NI AWR Design Environment


Project

Number Name Description


44 LayExportCellFaces Returns/sets the options for exporting cell faces from layout.
45 LayCellRemoveIllegalChars Layout remove illegal characters from cell names on
import/export to comply with GDSII library specifications.
46 LayExportWriteParamMap When exporting write layout cell parameter map.
47 LayExportPromptForLPF Prompt to load newer LPF files.
48 LayExportUseParentLPFForEM Use parent LPF for EM subcircuits.
49 LimitVerticesPerPolygon Returns/sets maximum number of vertices per polygon on
GDSII export
50 ExportUnionShapes Returns/sets if layout shapes should be union-ed on export.
51 PathWidth Returns/sets the default path width, value is in integer
nanometers.
52 PathMiterOffset Returns/sets the default miter offset, value is in integer
nanometers.
53 PathEndType Returns/sets the default path end style.
54 PathMiterType Returns/sets the default path miter style.
55 DrawPathAsPolygon Returns/sets if path is being drawn as polygon
56 LayPathDefProcessLineType Layout Path default line type when using process layers.
57 LayPathDefaultUseProcessLayers Paths by default use process layers.
58 LayInetMinViaSize Layout inets enforce minimum via size.
59 LayInetViaSizeOpts Layout inet via size options.
60 LayInetDefRouteBendStyle Layout inet default route bend style.
61 LayInetDefRouteBendAmount Layout inet default route bend amount.
62 LayRouteViaMode Layout via insertion mode for Inet routes
63 LayRouteBendAmountRel Determines if the bend amount value is relative to the route
width or absolute.
64 LayDefRouteConnectionModel Specifies the default connection model to be used for
route-to-route connections on physical nets.
65 LayRouteCurveFixedRadius Determines if curved route bends should used a fixed or
variable radius type.
66 RouteMinSpacing Returns/Sets the minimum spacing used when routing iNets
in layout
67 RoutePathWidth Returns/Sets the path width used when routing iNets in
layout
68 RouteLevel Returns/Sets the obstruction avoidance level used when
routing iNets, values come from mwRouteObstructionLevel
enumeration
69 LayoutRouteLineType Returns/sets the default line type index used for routing
commands.
70 RulerFontFace Returns/sets the default ruler font face.
71 RulerFontHeight Returns/sets the default ruler font height.

API Scripting Guide 269


Project

Number Name Description


72 RulerTickHeight Returns/sets the default ruler tick height.
73 RulerDisplayPrecision Returns/sets the default ruler display precision.
74 RulerShowUnits Returns/sets if units should be displayed for rulers by
default.
75 RulerSpacing Returns/sets the default ruler spacing.
76 RulerTickLocation Returns/sets the default ruler tick location, value is either
positive or negative.
77 RulerDefaultGap Returns/sets the default ruler gap.
78 LayoutRulerShowLabels Returns/sets if measurement labels should be displayed on
the ruler major tick marks.
79 LayoutRulerShowMinorTicks Returns/sets if minor tick marks should be displayed on the
ruler.
80 DimensionLineArrowSize Returns/sets the default dimension line arrow size, value is
in integer nanometers.
81 DimensionLineTextFont Returns/sets the default dimension line font face.
82 DimensionLineFontHeight Returns/sets the default dimension line font height.
83 DimensionLineSidesOffset Returns/sets the default dimension line side offset.
84 DimensionLineDisplayPrecision Returns/sets the default dimension line display precision.
85 DimensionLineShowUnits Returns/sets if the dimension line units should be displayed.
86 DimensionLineShowTolerance Returns/sets if the dimension line tolerance should be
displayed.
87 DimensionLineToleranceLength Returns/sets the default dimension line tolerance display
length.
88 DimensionLineTextLocation Returns/sets the default dimension line text location.
89 DimensionLineArrowLocation Returns/sets the default dimension line arrow location.
90 LayoutTextFont Returns/sets the default font for layout text objects.
91 LayoutTextHeight Returns/sets the default height for layout text object.
92 LayoutTextBold Returns/sets if layout text should be bold by default.
93 LayoutTextItalic Returns/sets if layout text should be italic by default.
94 LayoutTextDrawAsPolygons Returns/sets if layout text should be draw as polygons by
default.
95 CellStretcherArrowHeight Returns/sets the default cell stretcher arrow height, value is
in integer nanometers
96 CellStretcherDefaultMultiplier Returns/sets the default cell stretcher multiplier ratio.
97 CellStretcherDefaultOffset Returns/sets the default cell stretcher offset.
98 CellStretcherUpperLimit Returns/sets the default cell stretcher upper limit, value is
in integer nanometers.
99 CellStretcherLowerLimit Returns/sets the default cell stretcher lower limit, value is
in integer nanometers.

270 NI AWR Design Environment


ProjectFile

Number Name Description


100 CellStretcherIsBounded Returns/sets if the cell stretcher is bounded by default.
101 CellStretcherDefaultParameter Returns/sets the default parameter name used by the cell
stretcher.
102 SysDependentParametersInBaseUnits Returns/sets if system diagram dependent parameters should
be in base units
103 DefBooleanVersion Returns/sets the defalt boolean engine version to be used
for processing shapes in layout.
104 DefBooleanCornerStyle Returns/sets the default corner style to be used when resizing
shapes with acute angles in layout.

ProjectFile
A MWOffice ProjectFile object.

Properties

Name Data Type Description


AccessDate String Returns the date of the last access for this ProjectFile.
Name String Returns the name of the ProjectFile.
Path String Returns the full path to the ProjectFile.
UseCount Long Returns a count of the number of accesses for this
ProjectFile.

ProjectFiles
A collection of MWOffice ProjectFile objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ProjectFile Returns a specific item of a Collection object either by
position or by key.

ControlBar
An MWOffice ControlBar object.

Properties

Name Data Type Description


Align mwDockBorder Returns/sets the border a ControlBar object is docked to.

API Scripting Guide 271


ControlBars

Name Data Type Description


Caption String Returns/Sets the caption of an object.
ControlBarItems ControlBarItems Returns a reference to a ControlBarItem objects.
DockState mwDockState Returns/sets the DockState state of a ControlBar object.
FloatingCols Long Returns/sets the number of columns the ControlBar has
when it is Floating.
FloatingRows Long Returns/sets the number of rows the ControlBar has when
it is Floating.
InitiallyVisible Boolean Returns/sets whether the ControlBar is initially Visible.
Name String Returns the name used in code to identify an object.
Visible Boolean Returns/sets the visible state of a ControlBar object.

Methods
Dock

Description: Docks a ControlBar object.

Returns: Void

Syntax: Sub Dock()

Float

Description: Floats a ControlBar object.

Returns: Void

Syntax: Sub Float()

LoadSettings

Description: Sets the ControlBar properties to those previously saved.

Returns: Void

Syntax: Sub LoadSettings()

SaveSettings

Description: Saves the current ControlBar properties.

Returns: Void

Syntax: Sub SaveSettings()

ControlBars
A collection of MWOffice ControlBar objects.

272 NI AWR Design Environment


DataFile

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Item ControlBar Returns a specific item of a Collection object either by
position or by key.

Methods
None

DataFile
An MWOffice Datafile object.

Click to see examples

Properties

Name Data Type Description


DataAsText String Returns/sets the text value of a Datafile object.
Embedded Boolean Returns a value which specifies if the Datafile object is
embedded.
FilePath String Returns the Datafile file path.
Modified Boolean Returns/sets if the data file status is modified.
Name String Returns/Sets the name used in code to identify an object.
Options Options Returns a reference to a collection of Option objects.
PortCount Long Returns a count of the ports for this MWOffice Datafile
object.
ReadOnly Boolean Returns/sets if the data file is read-only.
SimulationDirty Boolean Returns if the current simulation state is dirty for the object.
SimulationState Long Returns the current simulation state for the object.
Type mwDataFileType Returns the type of the MWOffice Datafile object.
UseProjectOptions Boolean Returns/sets a value which specifies if the global project
options should be used.
Windows Windows Returns a reference to a collection of Window objects.

Methods
Activate

Description: Activates the objects.

Returns: Void

Syntax: Sub Activate()

API Scripting Guide 273


DataFiles

Export

Description: Exports a design document file from MWOffice.

Returns: Boolean

Syntax: Function Export(FilePath As String) As Boolean

NewWindow

Description: Displays the object in new window.

Returns: Window

Syntax: Function NewWindow() As Window

PrintOut

Description: Sends the object to the current printer.

Returns: Void

Syntax: Sub PrintOut()

DataFiles
A collection of MWOffice Datafile objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DataFile Returns a specific item of a Collection object either by
position or by key.
Options Options Returns a reference to a collection of Option objects.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: DataFile

Syntax: Function Add(Name As String, Filename As String, Embedded As Boolean, Type As mwDataFileType) As
DataFile

AddNew

Description: Adds an object to the collection and returns a reference to the created object.

274 NI AWR Design Environment


DataSetProperty

Returns: DataFile

Syntax: Function AddNew(Name As String, Type As mwDataFileType) As DataFile

Copy

Description: Copies an object from another object collection into this object collection.

Returns: DataFile

Syntax: Function Copy(Index, [NewName As String = ""]) As DataFile

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Import

Description: Adds a Netlist object to the collection from a file and returns a reference to the created object.

Returns: DataFile

Syntax: Function Import(Name As String, Filename As String, Type As mwDataFileType) As DataFile

LinkTo

Description: Adds a DataFile object link to the collection from a file and returns a reference to the created object.

Returns: DataFile

Syntax: Function LinkTo(Name As String, Filename As String, Type As mwDataFileType) As DataFile

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

DataSetProperty
An MWOffice DataSetProperty object.

Properties

Name Data Type Description


Description String Returns a description of this DataSetProperty object.
Name String Returns the name used in code to identify an object.

API Scripting Guide 275


DataSetProperties

Name Data Type Description


Type Long Returns the type of this DataSetProperty object.
Value Variant Returns the value for this DataSetPropety object.
ValueAsString String Returns the value of this DataSetProperty object converted
to a string.

DataSetProperties
A collection of MWOffice DataSetProperty objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DataSetProperty Returns a specific item of a Collection object either by
position or by key.

DataSet
An MWOffice DataSet object.

Properties

Name Data Type Description


AutoDelete Boolean Returns/sets the auto-delete state of the data set object.
Current Boolean Returns true if the data set is current.
DocumentName String Returns the name of the document associated with the data
set object.
Filename String Returns the file name of the data set object.
Flags Boolean Returns the state of flags associated with the data set.
LogInfo String Returns a string that contains details of the simulate lot for
the data set.
Name String Returns/Sets the name used in code to identify an object.
Pinned Boolean Returns/sets the pinned state of the data set object.
Properties DataSetProperties Returns a reference to a collection of MWOffice
DataSetProperty objects.
SimInfo String Returns a string that contains details of the simulation info
for the data set.
SimulatorName String Returns the simulator used by the data set object.
SubDataSets DataSets Returns a reference to a collection of DataSet objects.
TreeNode TreeNode Returns a reference to a MWOffice TreeNode object.

276 NI AWR Design Environment


DataSets

Name Data Type Description


UserName String Returns the user assigned name of the data set object.

Methods
UpdateClock

Description: Updates the clock if the data set current.

Returns: Void

Syntax: Sub UpdateClock()

UpdateResults

Description: Updates the results of the data set.

Returns: Void

Syntax: Sub UpdateResults([vbEnableMeasurements As Boolean = -1], [vbAddMissingMeasurements As Boolean =


-1])

DataSets
A collection of MWOffice DataSet objects.

Click to see examples

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DataSet Returns a specific item of a Collection object either by
position or by key.

Methods
Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

API Scripting Guide 277


DataSetFolder

Syntax: Function RemoveAll() As Boolean

DataSetFolder
An MWOffice DataSetFolder object.

Properties

Name Data Type Description


DataSets DataSets Returns a reference to a collection of DataSet objects.
Name String Returns/Sets the name used in code to identify an object.
TreeNode TreeNode Returns a reference to a MWOffice TreeNode object.

DataSetFolders
A collection of MWOffice DataSetFolder objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DataSetFolder Returns a specific item of a Collection object either by
position or by key.
Options Options Returns a reference to a collection of Option objects.
UpdateDependents Boolean Returns the whether updating the dependent data sets is
enabled.

Methods
AddGraphDataSet

Description: Adds an object to the collection and returns a reference to the created object.

Returns: DataSet

Syntax: Function AddGraphDataSet(Name As String) As DataSet

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

278 NI AWR Design Environment


OutputFile

Import

Description: Adds a Netlist object to the collection from a file and returns a reference to the created object.

Returns: DataSet

Syntax: Function Import(Filename As String) As DataSet

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

OutputFile
An MWOffice OutputFile object.

Properties

Name Data Type Description


Enabled Boolean Returns/sets a value which specifies if the object is enabled.
Name String Returns/Sets the name used in code to identify an object.

OutputFiles
A collection of MWOffice OutputFile objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item OutputFile Returns a specific item of a Collection object either by
position or by key.

API Scripting Guide 279


Frequency

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: OutputFile

Syntax: Function Add(SourceDoc As String, Measurement As String) As OutputFile

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub RemoveAll()

Frequency
An MWOffice Frequency object.

Properties

Name Data Type Description


Value Double Returns/sets the value of a Frequency object.

Frequencies
A collection of MWOffice Frequency objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.

280 NI AWR Design Environment


Element

Name Data Type Description


Item Frequency Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Frequency

Syntax: Function Add(Value As Double) As Frequency

AddMultiple

Description: Adds multiple Frequency objects to the collection.

Returns: Void

Syntax: Sub AddMultiple(Values As SafeArray)

Clear

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function Clear() As Boolean

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index As Long) As Boolean

Element
An MWOffice Element object.

Click to see examples

Properties

Name Data Type Description


CellName String Returns/sets the layout cell name associated with an element.
DisplayMode Boolean Returns/Sets various Element display mode settings.
DrawingObjects DrawingObjects Returns a reference to a collection of DrawingObjects.

API Scripting Guide 281


Element

Name Data Type Description


Enabled Boolean Returns/sets a value which specifies if the Element object
is enabled.
Flipped Boolean Returns a value which specifies if the Element object is
flipped.
Frozen Boolean Returns/sets a value that indicates if the Element object is
frozen.
HasLayoutCell Boolean Returns if the Element has an associated layout cell.
Height Long Returns the height of a Symbol object.
Left Long Returns the left edge of a Symbol object.
LockParameterizedLayout Boolean Returns/sets a value that indicates if the Element's
parameterized layout update is locked.
MultiplicityFactor Long Returns the multiplicity factor for the Element object.
Name String Returns/Sets the name used in code to identify an object.
NameVisible Boolean Returns/sets a value which specifies if the Element name is
visible.
Nodes Nodes Returns a reference to a collection of Node objects.
Options Options Returns a reference to a collection of Option objects.
ParameterFrame ParameterFrame Returns a reference to a ParameterFrame object.
Parameters Parameters Returns a reference to a collection of Parameter objects.
PartHelpPath String Returns/sets the part help path property of the Element
object.
PartNumber String Returns/sets the part number of an Element object.
Properties Properties Returns a reference to a collection of Property objects.
RotationAngle Long Returns the rotational angle of an Element object.
Selected Boolean Returns/sets a value which specifies if the object is selected.
Symbol String Returns the symbol name of an Element object.
SymbolColor Long Returns the color used to render the Element symbol.
Top Long Returns the top edge of a Symbol object.
Type mwElementType Returns the type of this Element (Circuit or System).
UniqueID Long Returns the numerical unique identifier for this element.
UseDefaultModelOptions Boolean Returns/sets a value which specifies if the default inherited
options should be used.
VectorInstanceCount Long Returns the vector instance count for the Element object.
VectorInstanceName String Returns/sets the vector instance property name for an
element.
Width Long Returns the width of a Symbol object.
x Long Returns the X value of a Element object.
y Long Returns the Y value of a Element object.

282 NI AWR Design Environment


Elements

Methods
Delete

Description: Removes the object.

Returns: Boolean

Syntax: Function Delete() As Boolean

Move

Description: Moves DrawingShape object by the given values relative to the current location.

Returns: Boolean

Syntax: Function Move(dx As Long, dy As Long, [CCWRotatation As Double = 0], [Flip As Boolean = 0], [HorizontalAxis
As Boolean = 0], [OriginX As Double = 0], [OriginY As Double = 0]) As Boolean

Options

Number Name Description


1 SpiceModelLevel Returns/Sets the spice model extraction level, valid values
are 0 to 15 and are dependent on the element type
2 ExtractModelType Returns/Sets the model type option for an element, values
come from mwModelExtractType enumeration.

Elements
A collection of MWOffice Element objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Element Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Element

Syntax: Function Add(Name As String, x As Long, y As Long, [RotationAngle As Long = 0], [Flipped As Boolean =
0], [Symbol As String = ""]) As Element

API Scripting Guide 283


Elements

AddDataFile

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Element

Syntax: Function AddDataFile(Path As String, x As Long, y As Long, [Embedded As Boolean = -1], [RotationAngle
As Long = 0], [Flipped As Boolean = 0], [Symbol As String = ""]) As Element

AddLibraryElement

Description: Adds a LibraryElement specified by browser path to the collection and returns a reference to the created
object.

Returns: Element

Syntax: Function AddLibraryElement(BrowserPath As String, x As Long, y As Long, [RotationAngle As Long = 0],


[Flipped As Boolean = 0], [Symbol As String = ""]) As Element

AddModelFile

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Element

Syntax: Function AddModelFile(Path As String, x As Long, y As Long, [DefaultName As String = ""], [Type As
mwModelParseType = 0], [RotationAngle As Long = 0], [Flipped As Boolean = 0], [Symbol As String = ""]) As Element

AddSubcircuit

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Element

Syntax: Function AddSubcircuit(SubcircuitName As String, x As Long, y As Long, [RotationAngle As Long = 0],


[Flipped As Boolean = 0], [Symbol As String = ""], [GndType As mwSubcktGroundType = 0]) As Element

AddXMLComponent

Description: Adds a XML component specified by an XPath to the collection and returns a reference to the created
object.

Returns: Element

Syntax: Function AddXMLComponent(XPath As String, x As Long, y As Long, [RotationAngle As Long = 0], [Flipped
As Boolean = 0], [Symbol As String = ""]) As Element

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

284 NI AWR Design Environment


SelectedElements

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

SelectedElements
A collection of MWOffice SelectedElement objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Element Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Boolean

Syntax: Function Add(Element As Element) As Boolean

AddAll

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Boolean

Syntax: Function AddAll() As Boolean

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

API Scripting Guide 285


EquationExpression

Syntax: Function RemoveAll() As Boolean

EquationExpression
A MWOffice EquationExpression object.

Properties

Name Data Type Description


AffectsLayout Boolean Returns/sets if the value affects layout. Valid only for
EquationExpression that are exported parmeters.
Constrain Boolean Returns/sets a value which specifies if the object is
constrained by the upper and lower limit.
DataType mwEquationDataType Returns/sets a value which specifies the data type of an
EquationExpression object.
Description String Returns/sets a string for the description field of the
EquationExpression object.
DisplayText String Returns the display text of the EquationExpression object.
Distribution mwStatisticalDist Returns/sets a value which specifies the distribution type
of the object.
Enabled Boolean Returns/sets a value which specifies if the object is enabled.
Exported Boolean Returns/sets if the EquationExpression object is exported.
Expression String Returns/sets the expression of an Equation object.
HasError Boolean Returns if the EquationExpression object has an expression
error.
Independent Boolean Returns if the EquationExpression object is independent or
depends on other variables.
LowerConstraint Double Returns/sets the lower constraint of the object.
Optimize Boolean Returns/sets a value which specifies if the object is
optimized.
OptimizeYield Boolean Returns/sets a value which specifies if the object's yield is
optimized.
PropagationMode mwVarPropMode Returns/sets a value which specifies the propagation mode
of the object. Used for inherited parameters.
StatVariation Double Returns/sets the statistical variation parameter of the object.
StatVariation2 Double Returns/sets the second statistical variation parameter of the
object.
StepSize Double Returns/sets the step size used for tuning and discrete
optimization of the object.
Tag String Returns/sets the tag value of the object.
TolInPercent Boolean Returns/sets a value which specifies if the object's total is
in percent.
Tune Boolean Returns/sets a value which specifies if the object is tuned.

286 NI AWR Design Environment


EquationExpressions

Name Data Type Description


UnitType mwUnitType Returns/sets a value which specifies the unit type of an
EquationExpression object.
UpperConstraint Double Returns/sets the upper constraint of the object.
UseStatistics Boolean Returns/sets a value which specifies if the object uses
statistics.
ValueAsComplex ComplexNumber Returns a reference to a ComplexNumber object.
ValueAsDouble Double Returns the value interpreted as a numeric double value.
ValueAsDoubleVector SafeArray Returns the value of the object as a vector of doubles.
ValueAsString String Returns the value interpreted as a string value.
VariableType mwEquationVariableType Returns/sets a value which specifies variable type of the
EquationExpression object.

EquationExpressions
A Collection of EquationExpression objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item EquationExpression Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: EquationExpression

Syntax: Function Add(Expression As String) As EquationExpression

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

Equation
An MWOffice Equation object.

API Scripting Guide 287


Equation

Click to see examples

Properties

Name Data Type Description


ActiveIndex Long Returns/sets a value for the active index of the equation
object. The active index is which line of a multi-line
equation that is used for most property read/writes.
AffectsLayout Boolean Returns/sets if the value affects layout. Valid only for
equations that are exported parmeters.
Boundary Boundary Returns a reference to a Boundary object.
Constrain Boolean Returns/sets a value which specifies if the object is
constrained by the upper and lower limit.
DataType mwEquationDataType Returns/sets a value which specifies the data type of an
equation object.
Description String Returns/sets a string for the description field of the equation
object.
DisplayText String Returns the display text for the object.
Distribution mwStatisticalDist Returns/sets a value which specifies the distribution type
of the object.
Enabled Boolean Returns/sets a value which specifies if the object is enabled.
Expression String Returns/sets the expression of an Equation object.
Expressions EquationExpressions Returns a reference to a EquationExpression object.
LowerConstraint Double Returns/sets the lower constraint of the object.
NumSubexpressions Long Returns a count of the number of subexpressions in the
equation object.
Optimize Boolean Returns/sets a value which specifies if the object is
optimized.
OptimizeYield Boolean Returns/sets a value which specifies if the object's yield is
optimized.
PropagationMode mwVarPropMode Returns/sets a value which specifies the propagation mode
of the object. Used for inherited parameters.
Selected Boolean Returns/sets if the Equation object is seleted.
StatVariation Double Returns/sets the statistical variation parameter of the object.
StatVariation2 Double Returns/sets the second statistical variation parameter of the
object.
StepSize Double Returns/sets the step size used for tuning and discrete
optimization of the object.
Subexpression String Returns/sets the indexed subexpression value in the equation
object.
Tag String Returns/sets the tag value of the object.
TolInPercent Boolean Returns/sets a value which specifies if the object's total is
in percent.

288 NI AWR Design Environment


Equations

Name Data Type Description


Tune Boolean Returns/sets a value which specifies if the object is tuned.
UnitType mwUnitType Returns/sets a value which specifies the unit type of an
equation object.
UpperConstraint Double Returns/sets the upper constraint of the object.
UseStatistics Boolean Returns/sets a value which specifies if the object uses
statistics.
VariableType mwEquationVariableType Returns/sets a value which specifies variable type of the
equation object.
x Long Returns/sets the X value of a Equation object.
y Long Returns/sets the Y value of a Equation object.

Methods
None

Equations
A collection of MWOffice Equation objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Equation Returns a specific item of a Collection object either by
position or by key.
Name String Returns/Sets the name used in code to identify an object.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Equation

Syntax: Function Add(Expression As String, x As Long, y As Long) As Equation

Add2

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Equation

Syntax: Function Add2(Expression As String, x As Double, y As Double) As Equation

API Scripting Guide 289


GlobalDefinitionDocument

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

Update

Description: Called to perform final updates to a collection object.

Returns: Boolean

Syntax: Function Update() As Boolean

GlobalDefinitionDocument
A MWOffice GlobalDefinitionDocument object.

Properties

Name Data Type Description


CanPaste Boolean Returns a value that determines the clipboard contents can
be pasted to the object.
DataElements Elements Returns a reference to a collection of Element objects.
EmbeddedDesigns EmbeddedDesigns Returns a reference to a collection of EmbeddedDesign
objects.
Equations Equations Returns a reference to a collection of Equation objects.
Modified Boolean Returns/sets if the GlobalDefinitionDocument file status is
modified.
Name String Returns/Sets the name used in code to identify an object.
ReadOnly Boolean Returns/sets if the GlobalDefinitionDocument is read-only.
SelectedElements SelectedElements Returns a reference to a collection of MWOffice
SelectedElement objects.
Windows Windows Returns a reference to a collection of Window objects.

Methods
Activate

Description: Activates the objects.

Returns: Void

Syntax: Sub Activate()

CopyToClipboard

Description: Copies the object to the system clipboard.

290 NI AWR Design Environment


GlobalDefinitionDocuments

Returns: Boolean

Syntax: Function CopyToClipboard() As Boolean

InvokeCommand

Description: Invoke a menu command by specifying the name for the command. Any required input will need to be
supplied as arguments.

Returns: Void

Syntax: Sub InvokeCommand(CommandName As String, [Arguments], [pRet])

NewWindow

Description: Displays the object in new window.

Returns: Window

Syntax: Function NewWindow() As Window

Paste

Description: Pastes the system clipboard to the object.

Returns: Boolean

Syntax: Function Paste(x As Long, y As Long, [CCWRotation As Long = 0], [Flipped As Boolean = 0]) As Boolean

PrintOut

Description: Sends the object to the current printer.

Returns: Boolean

Syntax: Function PrintOut() As Boolean

StartCommand

Description: Start a menu command by specifying the name for the command. Any rquired input will need to be supplied
by the user interactively.

Returns: Void

Syntax: Sub StartCommand(CommandName As String, [pRet])

GlobalDefinitionDocuments
A collection of GlobalDefinitionDocument objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.

API Scripting Guide 291


OutputEquationDocument

Name Data Type Description


Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item GlobalDefinitionDocument Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: GlobalDefinitionDocument

Syntax: Function Add(Name As String, [parentName As String = ""]) As GlobalDefinitionDocument

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

OutputEquationDocument
A MWOffice OutputEquationDocument object.

Properties

Name Data Type Description


CanPaste Boolean Returns a value that determines the clipboard contents can
be pasted to the object.
EmbeddedDesigns EmbeddedDesigns Returns a reference to a collection of EmbeddedDesign
objects.
Equations Equations Returns a reference to a collection of Equation objects.
Modified Boolean Returns/sets if the OutputEquationDocument file status is
modified.
Name String Returns/Sets the name used in code to identify an object.
Options Options Returns a reference to a collection of Option objects.
ReadOnly Boolean Returns/sets if the OutputEquationDocument is read-only.

292 NI AWR Design Environment


OutputEquationDocument

Name Data Type Description


Windows Windows Returns a reference to a collection of Window objects.

Methods
Activate

Description: Activates the objects.

Returns: Void

Syntax: Sub Activate()

CopyToClipboard

Description: Copies the object to the system clipboard.

Returns: Boolean

Syntax: Function CopyToClipboard() As Boolean

InvokeCommand

Description: Invoke a menu command by specifying the name for the command. Any required input will need to be
supplied as arguments.

Returns: Void

Syntax: Sub InvokeCommand(CommandName As String, [Arguments], [pRet])

NewWindow

Description: Displays the object in new window.

Returns: Window

Syntax: Function NewWindow() As Window

Paste

Description: Pastes the system clipboard to the object.

Returns: Boolean

Syntax: Function Paste(x As Long, y As Long, [CCWRotation As Long = 0], [Flipped As Boolean = 0]) As Boolean

PrintOut

Description: Sends the object to the current printer.

Returns: Boolean

Syntax: Function PrintOut() As Boolean

API Scripting Guide 293


OutputEquationDocuments

StartCommand

Description: Start a menu command by specifying the name for the command. Any rquired input will need to be supplied
by the user interactively.

Returns: Void

Syntax: Sub StartCommand(CommandName As String, [pRet])

OutputEquationDocuments
A collection of OutputEquationDocument objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item OutputEquationDocument Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: OutputEquationDocument

Syntax: Function Add(Name As String) As OutputEquationDocument

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

Goal
An MWOffice Goal object.

294 NI AWR Design Environment


DisplayPrecision

Properties

Name Data Type Description


CircuitName String Returns the circuit name of a Goal object.
Cost Double Returns the cost of a Goal object.
Enable Boolean Returns/sets a value which specifies if the Goal object is
enabled.
L Long Returns/sets the L property of a Goal object.
Measurement Measurement Returns a reference to MWOffice Measurement object.
MeasurementName String Returns the measurement name of a Goal object.
Name String Returns the name used in code to identify an object.
Tag String Returns/sets the tag value of the object.
Type mwOptGoalType Returns the type ($lt; > =) of the goal.
Weight Double Returns/sets the weight of a Goal object.
xStart Double Returns/sets the X start of a Goal object.
xStop Double Returns/sets the X stop of a Goal object.
yStart Double Returns/sets the Y start of a Goal object.
yStop Double Returns/sets the Y stop of the object.

DisplayPrecision
A MWOffice DisplayPrecision object.

Properties

Name Data Type Description


Digits Long Returns/Sets the number of display digits for the
DisplayPrecision object.
Style mwPrecisionStyle Returns/Sets the display style for the DisplayPrecision
object.
mode mwPrecisionMode Returns/Sets the display mode for the DisplayPrecision
object.

Graph
An MWOffice Graph object.

Click to see examples

Properties

Name Data Type Description


Attributes Attributes Returns a reference to a collection of Attribute objects.
Axes Axes Returns a reference to a collection of Axis objects.

API Scripting Guide 295


Graph

Name Data Type Description


BorderColor Long Returns/sets the color of the graph border.
BorderVisible Boolean Returns/sets whether the graph border is displayed.
BorderWeight mwThickness Returns/sets the thickness of the graph border.
DataPrecision DisplayPrecision Returns a reference to a MWOffice DisplayPrecision object.
DrawingShapes DrawingShapes Returns a reference to a collection of DrawingShape objects.
EmbeddedDesigns EmbeddedDesigns Returns a reference to a collection of EmbeddedDesign
objects.
Height Long Returns/sets the height of the graph.
Left Long Returns/sets the position of the left edge of the graph
Legend Legend Returns a reference to a Legend object.
LineMarkers LineMarkers Returns a reference tp a collection of LineMarker objects.
Markers Markers Returns a reference to a collection of Marker objects.
Measurements Measurements Returns a reference to a collection of Measurement objects.
Name String Returns/Sets the name used in code to identify an object.
SweepPrecision DisplayPrecision Returns a reference to a MWOffice DisplayPrecision object.
TickMarksVisible Boolean Returns/sets whether the tick marks are displayed on the
graph.
Title String Returns/sets the text used for the graph title.
TitleColor Long Returns/sets the color used for the graph title.
TitleFont Object Returns/sets the font used for the graph title.
TitleVisible Boolean Returns/sets whether the graph title is displayed.
Top Long Returns/sets the position of the top edge of the graph
Traces Traces Returns a reference to a collection of Trace objects.
Type mwGraphType Returns a value which specifies the graph type of a Graph
object.
Width Long Returns/sets the width of the graph.
Windows Windows Returns a reference to a collection of Window objects.

Methods
Activate

Description: Activates the objects.

Returns: Void

Syntax: Sub Activate()

ClearFrozenTraces

Description: Clears any previously frozen traces on the graph.

296 NI AWR Design Environment


Graph

Returns: Void

Syntax: Sub ClearFrozenTraces()

CopyToClipboard

Description: Copies the object to the system clipboard.

Returns: Void

Syntax: Sub CopyToClipboard()

CopyViewToClipboard

Description: Copies the object to the system clipboard.

Returns: Boolean

Syntax: Function CopyViewToClipboard() As Boolean

ExportTraceData

Description: Export trace data from this Graph object.

Returns: Boolean

Syntax: Function ExportTraceData(Filename As String) As Boolean

FreezeTraces

Description: Freezes the traces on the graph.

Returns: Void

Syntax: Sub FreezeTraces()

GridToLogicalCoordinateX

Description: Converts a coordinate value from grid to logical coordinates along the X axis.

Returns: Long

Syntax: Function GridToLogicalCoordinateX(GridX As Double) As Long

GridToLogicalCoordinateY

Description: Converts a coordinate value from grid to logical coordinates along the Y axis.

Returns: Long

Syntax: Function GridToLogicalCoordinateY(GridY As Double, [yAxisIndex = 1], [OnLeft As Boolean = -1]) As Long

LogicalToGridCoordinateX

Description: Converts a coordinate value from logical to grid coordinates along the X axis.

API Scripting Guide 297


Graphs

Returns: Double

Syntax: Function LogicalToGridCoordinateX(LogicalX As Long) As Double

LogicalToGridCoordinateY

Description: Converts a coordinate value from logical to grid coordinates along the Y axis.

Returns: Double

Syntax: Function LogicalToGridCoordinateY(LogicalY As Long, [yAxisIndex = 1], [OnLeft As Boolean = -1]) As


Double

NewWindow

Description: Displays the object in new window.

Returns: Window

Syntax: Function NewWindow() As Window

PrintOut

Description: Sends the object to the current printer.

Returns: Void

Syntax: Sub PrintOut()

SimulateMeasurements

Description: Simulate measurements for this Graph object.

Returns: Boolean

Syntax: Function SimulateMeasurements() As Boolean

Graphs
A collection of MWOffice Graph objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Graph Returns a specific item of a Collection object either by
position or by key.
Options Options Returns a reference to a collection of Option objects.

298 NI AWR Design Environment


Axis

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Graph

Syntax: Function Add(Name As String, Type As mwGraphType) As Graph

Copy

Description: Copies an object from another object collection into this object collection.

Returns: Graph

Syntax: Function Copy(Index, [NewName As String = ""]) As Graph

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

Axis
An MWOffice Axis object.

Properties

Name Data Type Description


AutoScale Boolean Returns/sets whether the axis minimum and maximum
values are automatically calculated.
GridlineLabelsColor Long Returns/sets the color of the axis grid line label.
GridlineLabelsFont Object Returns/sets the font of the axis grid line label.
GridlineLabelsVisible Boolean Returns/sets whether the axis grid line labels are displayed.
LabelColor Long Returns/sets the color of the axis label.
LabelFont Object Returns/sets the font of the axis label.
LabelText String Returns/sets the text of the axis label.
LabelUnitsVisible Boolean Returns/sets whether the axis label units are displayed.

API Scripting Guide 299


Axes

Name Data Type Description


LabelVisible Boolean Returns/sets whether the axis labels are displayed.
MajorGridlinesAutoStep Boolean Returns/sets whether the grid line step size is automatically
calculated.
MajorGridlinesColor Long Returns/sets the color of the axis major grid lines.
MajorGridlinesDashStyle mwDashStyle Returns/sets the dash style of the axis major grid lines.
MajorGridlinesStep Double Returns/sets the step size of the axis major grid lines.
MajorGridlinesVisible Boolean Returns/sets whether the major axis grid lines are displayed.
MajorGridlinesWeight mwThickness Returns/sets the thickness of the axis major grid lines.
MaximumScale Double Returns/sets the maximum value of the axis scale.
MinimumScale Double Returns/sets the minimum value of the axis scale.
MinorGridlinesAutoStep Boolean Returns/sets whether the grid line step size is automatically
calculated.
MinorGridlinesColor Long Returns/sets the color of the axis minor grid lines.
MinorGridlinesDashStyle mwDashStyle Returns/sets the dash style of the axis minor grid lines.
MinorGridlinesStep Double Returns/sets the step size of the axis major grid lines.
MinorGridlinesVisible Boolean Returns/sets whether the minor axis grid lines are displayed.
MinorGridlinesWeight mwThickness Returns/sets the thickness of the axis minor gridlines.
Name String Returns the name of the axis object.
ScaleType mwScaleType Returns/sets the scale type of the axis.

Axes
A collection of MWOffice Axis objects.

Click to see examples

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Axis Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Axes

2100 NI AWR Design Environment


Trace

Syntax: Function Add() As Axes

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

Trace
An MWOffice Trace object.

Properties

Name Data Type Description


AxisIndex Long Returns/Sets the index of the plot axis associated with this
Trace object.
Color Long Returns/sets the color of the trace.
CompatibleStyle Boolean Returns if the given Trace style is compatible with the
Graph.
DashStyle mwDashStyle Returns/sets the dash style of the trace.
DefaultStyle mwTraceStyle Returns the default Trace style for the Graph.
FrequencyArrows Boolean Returns/sets whether frequency arrows should be displayed
on the text.
LegendText String Returns/sets the legend text displayed for the measurement
name.
LegendText2 String Returns/sets the legend text displayed for the data source
name.
MeasurementName String Returns the name of the measurement associated with this
Trace object.
Name String Returns the name of a trace object.
PlotAxis mwPlotAxis Returns/sets the axis on which to plot the Trace.
SteppedColorStyle mwTraceSteppedColorStyle Returns/sets the stepped color style of the Trace.
Style mwTraceStyle Returns/sets the style of the Trace.
Symbol mwTraceSymbols Returns/sets the symbol used by the trace.
SymbolInterval Long Returns/sets the spacing of the symbols displayed on the
trace.
SymbolSize Long Returns/sets the size of the symbol displayed on the trace.
SymbolVisible Boolean Returns/sets whether the symbol is displayed on the trace.
TextVisible Boolean Returns/sets whether the trace text is displayed.
UseDefaultLegendText Boolean Returns/sets whether to use the default legend text for the
measurement name.

API Scripting Guide 2101


Traces

Name Data Type Description


UseDefaultLegendText2 Boolean Returns/sets whether to use the default legend text for the
data source name.
Visible Boolean Returns/sets whether the trace is displayed on the graph.
Weight mwThickness Returns/sets the thickness of the trace.

Traces
A collection of MWOffice Trace objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Trace Returns a specific item of a Collection object either by
position or by key.

Legend
An MWOffice Legend object.

Properties

Name Data Type Description


BorderShadow Boolean Returns/sets whether the legend border is displayed with a
shadow.
BorderVisible Boolean Returns/sets whether the legend border is displayed.
Color Long Returns/sets the color used by the legend.
Font Object Returns/sets the font used by the legend.
Height Long Returns/sets the height of a Legend object.
Left Long Returns/sets the left edge of a Legend object.
Text2Visible Boolean Returns/sets whether the additional legend text is displayed.
TextVisible Boolean Returns/sets whether the legend text is displayed.
Top Long Returns/sets the top edge of a Legend object.
Visible Boolean Returns/sets whether the legend is displayed.
Width Long Returns/sets the width of a Legend object.

MarkerOptions
An MWOffice MarkerOptions Object.

2102 NI AWR Design Environment


MarkerDisplay

Properties

Name Data Type Description


Color Long Returns/sets color used by the marker.
ConnectorVisible Boolean Returns/sets whether the marker connector is displayed.
ConnectorWeight mwThickness Returns/sets the thickness of the marker connector.
DataMarkersInLegend Boolean Returns/sets if the data markers should be in the legend.
DisplayFormat mwGraphMarkerFormat Returns/sets the marker format.
DisplayType mwGraphMarkerType Returns/sets the marker display type.
EnableParameterMarkers Boolean Returns/sets if the parameter markers should be enabled.
FrequencyVisible Boolean Returns/sets whether the frequency of the marker is
displayed.
MarkerSymbol mwMarkerSymbolType Returns/sets the symbol type for the marker.
NamesInLabels Boolean Returns/sets whether the marker names should be displayed
in the labels.
Normalized Boolean Returns/sets if marker values are normalized to reference
impedance
ParameterMarkersInLegend Boolean Returns/sets if the parameter markers should be in the
legend.
RefImpedance Double Returns/sets the reference impedance
RefMarkerAllTraces Boolean Returns/sets if reference markers affect markers on all traces.
SymbolSize Long Returns/sets the size of the marker symbol.
SymbolVisible Boolean Returns/sets whether the marker symbol is displayed.
TiedToLabel Boolean Returns/sets whether the MarkerDisplay is tied to the label.
Transparent Boolean Returns/sets whether the MarkerDisplay background is
transparent.

MarkerDisplay
An MWOffice MarkerDisplay Object.

Properties

Name Data Type Description


Height Long Returns/sets the height of a Marker object.
Left Long Returns/sets the left edge of a Marker object.
Top Long Returns/sets the top edge of a Marker object.
Width Long Returns/sets the width of a Marker object.

AutoSearchMarker
An MWOffice AutoSearchMarker Object.

API Scripting Guide 2103


OffsetMarker

Properties

Name Data Type Description


ApertureHeight Double Returns/sets the height of the aperture for a Peak/Valley
AutoSearchMarker object.
ApertureWidth Double Returns/sets the width of the aperture for a Peak/Valley
AutoSearchMarker object.
YValue Double Returns/sets the Y value for which an AutoSearchMarker
object in Value mode will search.
mode mwMarkerAutoSearchMode Returns/sets the auto-search mode of an AutoSearchMarker
object.
xIndex Int Returns/sets the X index for which an AutoSearchMarker
object in XIndex mode will search.

OffsetMarker
An MWOffice OffsetMarker Object.

Properties

Name Data Type Description


Distance Double Returns/sets the offset distance for an OffsetMarker object.
ReferenceMarker String Returns/sets the name of the marker referenced by an
OffsetMarker object.
mode mwMarkerOffsetMode Returns/sets the offset mode of an OffsetMarker object.

Marker
An MWOffice Marker object.

Properties

Name Data Type Description


AutoSearch AutoSearchMarker Returns a reference to an MWOffice AutoSearchMarker
object.
DataItem Long Returns/Sets the data item index for the Marker object.
DataItemMax Long Returns the maximum allowable data index for the marker
object.
DataValue Double Returns the data value associated with this Marker object.
DataValueText String Returns a text string with the numeric values from the
marker label.
Display MarkerDisplay Returns a reference to an MWOffice MarkerDisplay object.
Measurement String Returns the measurement name associated with this Marker
object.

2104 NI AWR Design Environment


Marker

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
NumDataValueDim Long Returns the number of data value dimensions available from
the data value property.
Offset OffsetMarker Returns a reference to an MWOffice OffsetMarker object.
ReferenceMarker Boolean Returns if the marker is a reference marker object.
SweepValue Double Returns/Sets the sweep value associated with this Marker
object.
TraceIndex Long Returns/Sets the trace index of the Marker object.
TraceIndexMax Long Returns the maximum value for the trace index of the
Marker object.
Type mwMarkerType Returns the type of Marker object.

Methods
Delete

Description: Removes the object.

Returns: Boolean

Syntax: Function Delete() As Boolean

MoveToMaximum

Description: Move the marker to display the maximum trace value.

Returns: Boolean

Syntax: Function MoveToMaximum() As Boolean

MoveToMinimum

Description: Move the marker to display the minimum trace value.

Returns: Boolean

Syntax: Function MoveToMinimum() As Boolean

Search

Description: Perform a marker search for a specified trace value.

Returns: Boolean

Syntax: Function Search(Value As Double, [mode As mwMarkerSearchMode = 0], [dir As mwMarkerSearchDirection


= 0], [var As mwMarkerSearchVariable = 1]) As Boolean

API Scripting Guide 2105


Markers

Markers
A collection of MWOffice Marker objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Marker Returns a specific item of a Collection object either by
position or by key.
Options MarkerOptions Returns a reference to an MWOffice MarkerOptions object.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Marker

Syntax: Function Add(MeasurementIndex, DataIndex, SweepPoint As Double) As Marker

AddEx

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Marker

Syntax: Function AddEx(MeasurementIndex, DataIndex, SweepPoint As Double, TraceIndex As Long) As Marker

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub RemoveAll()

LineMarker
An MWOffice LineMarker object.

2106 NI AWR Design Environment


LineMarkers

Properties

Name Data Type Description


Axis Long Returns/sets the Y-Axis id for this LineMarker object.
Name String Returns/Sets the name used in code to identify an object.
Number Long Returns/sets the number associated with this LineMarker
object.
Track mwLineMarkerTrackType Returns the track mode for this LineMarker object.
Type mwLineMarkerType Returns the type of the LineMarker object.
UnitType mwUnitType Returns the unit type for this LineMarker object.
Value Double Returns/sets the value of the LineMarker object.
Visible Boolean Returns if this line marker is visible in the current Graph
grid area.

LineMarkers
A collection of MWOffice LineMarker objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item LineMarker Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: LineMarker

Syntax: Function Add(Type As mwLineMarkerType, Value As Double, AxisIndex) As LineMarker

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

API Scripting Guide 2107


Measurement

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

Measurement
An MWOffice Measurement object.

Click to see examples

Properties

Name Data Type Description


AxisIndex Long Returns/sets the index of the plot axis for this measurement.
AxisPointLabel String Returns/sets a axis point label for this measurement.
AxisPointLabelCount Long Returns a count of the axis point labels for this measurement.
DataPointLabel String Returns/sets the label for a data point of a Measurement
object.
DataType mwMeasDataType Returns/sets the data type of a Measurement object.
Enabled Boolean Returns/sets a value which specifies if the Measurement
object is enabled.
Name String Returns/Sets the name used in code to identify an object.
OnLeftAxis Boolean Returns/sets a value indicating if the measurement is plotted
against the left axis.
PlotDimension Long Returns the plot dimension of a Measurement object.
Source String Returns the source of a Measurement object.
SweepLabels SweepLabels Returns a reference to a collection of MeasurementInfo
objects.
TraceCount Long Returns the number of traces for this measurement.
TraceValues SafeArray Returns the x/y values associated with a trace
Type String Returns the parameter of a Measurement object.
UnitType mwUnitType Returns/sets the unit type of a Measurement object.
XPointCount Long Returns the number of X points of a Measurement object.
XValue Double Returns/sets the X value of a Measurement object.
XValues SafeArray Returns/sets the X values of a Measurement object.
YDataDim Long Returns the number of Y dimensions of a Measurement
object.
YPointCount Long Returns the number of Y points of a Measurement object.
YValue Double Returns/sets the Y value of a Measurement object.
YValues SafeArray Returns/sets the Y values of a Measurement object.
ZDataDim Long Returns the number of Z dimensions of a Measurement
object.
ZValue Double Returns/sets the Z value of a Measurement object.

2108 NI AWR Design Environment


Measurements

Name Data Type Description


ZValues SafeArray Returns/sets the Z values of a Measurement object.

Methods
ResizeFor2D

Description: Resizes a Measurement object for two dimensions.

Returns: Void

Syntax: Sub ResizeFor2D(xCount As Long, DataDimension As Long)

ResizeFor2DEx

Description: Resizes a Measurement object for two dimensions and allows specification of the trace count.

Returns: Void

Syntax: Sub ResizeFor2DEx(xCount As Long, DataDimension As Long, TraceCount As Long, SeparateXAxis As


Boolean)

ResizeFor3D

Description: Resizes a Measurement object for three dimensions.

Returns: Void

Syntax: Sub ResizeFor3D(xCount As Long, yCount As Long, DataDimension As Long)

SimulateMeasurement

Description: Perform simulations required for this measurement.

Returns: Boolean

Syntax: Function SimulateMeasurement() As Boolean

Update

Description: Updates a Measurement object.

Returns: Void

Syntax: Sub Update()

Measurements
A collection of MWOffice Measurement objects.

API Scripting Guide 2109


Netlist

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Measurement Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Measurement

Syntax: Function Add(SourceDoc As String, Measurement As String) As Measurement

Remove

Description: Removes a specific member from a collection.

Returns: Void

Syntax: Sub Remove(MeasName As String)

RemoveAll

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub RemoveAll()

Netlist
An MWOffice Netlist object.

Click to see examples

Properties

Name Data Type Description


Embedded Boolean Returns a value which specifies if the Netlist object is
embedded.
Filename String Returns the file name of a linked Netlist object.
Name String Returns/Sets the name used in code to identify an object.
Properties Properties Returns a reference to a collection of Property objects.
SimulationDirty Boolean Returns if the current simulation state is dirty for the object.

2110 NI AWR Design Environment


Netlists

Name Data Type Description


SimulationState Long Returns the current simulation state for the object.
Text String Returns/sets the text value of a Netlist object.
Type mwNetlistType Returns the type of a Netlist object.
Windows Windows Returns a reference to a collection of Window objects.

Methods
Activate

Description: Activates the objects.

Returns: Void

Syntax: Sub Activate()

Export

Description: Exports a design document file from MWOffice.

Returns: Boolean

Syntax: Function Export(FilePath As String) As Boolean

NewWindow

Description: Displays the object in new window.

Returns: Window

Syntax: Function NewWindow() As Window

Parse

Description: Parse the netlist.

Returns: Void

Syntax: Sub Parse()

PrintOut

Description: Sends the object to the current printer.

Returns: Void

Syntax: Sub PrintOut()

Netlists
A collection of MWOffice Netlist objects.

API Scripting Guide 2111


Netlists

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Netlist Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Netlist

Syntax: Function Add(Name As String) As Netlist

AddEx

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Netlist

Syntax: Function AddEx(Name As String, Type As mwNetlistType, [Value = 0]) As Netlist

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Import

Description: Adds a Netlist object to the collection from a file and returns a reference to the created object.

Returns: Netlist

Syntax: Function Import(Name As String, Filename As String, Embedded As Boolean, Type As mwNetlistType) As
Netlist

LinkTo

Description: Adds a Netlist object link to the collection from a file and returns a reference to the created object.

Returns: Netlist

Syntax: Function LinkTo(Name As String, Filename As String, Type As mwNetlistType) As Netlist

2112 NI AWR Design Environment


Node

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

Node
An MWOffice Node object.

Click to see examples

Properties

Name Data Type Description


Connected Boolean Returns if the node is connected to other elements in the
design.
DataType mwNodeDataType Returns a value describing the data type of the node.
NodeFlags Boolean Returns the flags associated with this node.
NodeNumber Long Returns the node number for this node.
PortNumber Long Returns the port number for this node.
Type mwNodeType Returns a value describing the type of the node.
x Long Returns the X value of a Node object.
y Long Returns the Y value of a Node object.

Nodes
A collection of MWOffice Node objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Node Returns a specific item of a Collection object either by
position or by key.

OptGoals
A collection of MWOffice Goal objects.

Click to see examples

API Scripting Guide 2113


Parameter

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Goal Returns a specific item of a Collection object either by
position or by key.
TotalCost Double Returns the total cost of a collection of Goal object.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Goal

Syntax: Function Add(CircuitName As String, MeasName As String, GoalType As mwOptGoalType, Weight As Double,
L As Long, xStart As Double, xStop As Double, xUnit As mwUnitType, yStart As Double, yStop As Double, yUnit As
mwUnitType) As Goal

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

Parameter
An MWOffice Parameter object.

Click to see examples

Properties

Name Data Type Description


Constrain Boolean Returns/sets a value which specifies if the object is
constrained by the upper and lower limit.
Description String Returns the description of the object.

2114 NI AWR Design Environment


Parameters

Name Data Type Description


Distribution mwStatisticalDist Returns/sets a value which specifies the distribution type
of the object.
HasError Boolean Returns a value which specifies if the Parameter object has
an error.
Independent Boolean Returns a value which specifies if the Parameter object is
independent.
LowerConstraint Double Returns/sets the lower constraint of the object.
Name String Returns the name used in code to identify an object.
Optimize Boolean Returns/sets a value which specifies if the object is
optimized.
OptimizeYield Boolean Returns/sets a value which specifies if the object's yield is
optimized.
ParameterDefinition ParameterDefinition Returns a reference to a MWOffice ParameterDefinition
object.
ReadOnly Boolean Returns a value which specifies if the Parameter object is
read-only.
StatVariation Double Returns/sets the statistical variation parameter of the object.
StatVariation2 Double Returns/sets the second statistical variation parameter of the
object.
StepSize Double Returns/sets the step size used for tuning and discrete
optimization of the object.
Style mwParameterStyleSetting Returns/sets a value which specifies the style of a parameter
object. Styles should be set to mwParamStyleSetting enum
values
Tag String Returns/sets the tag value of the object.
TolInPercent Boolean Returns/sets a value which specifies if the object's total is
in percent.
Tune Boolean Returns/sets a value which specifies if the object is tuned.
UnitType mwUnitType Returns a value which specifies the unit type of a Parameter
object.
UpperConstraint Double Returns/sets the upper constraint of the object.
UseStatistics Boolean Returns/sets a value which specifies if the object uses
statistics.
ValueAsComplex ComplexNumber Returns a reference to a ComplexNumber object.
ValueAsDouble Double Returns/sets the value of a Parameter object.
ValueAsDoubleVector SafeArray Returns/sets the value of a Parameter object as an array of
doubles.
ValueAsString String Returns/sets the text value of a Parameter object.

Parameters
A collection of MWOffice Parameter objects.

API Scripting Guide 2115


ParameterDefinition

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Parameter Returns a specific item of a Collection object either by
position or by key.

ParameterDefinition
An MWOffice ParameterDefinition object.

Properties

Name Data Type Description


DataType mwParamDefDataType Returns a value which specifies the data type of the
ParameterDefinition.
DefaultName Variant Returns the default value of the ParameterDefinition.
DefinitionFlag Boolean Returns a value which indicates if a specific definition flag
is set or cleared.
Description String Returns the description of the object.
EnumeratedTypes SafeArray Returns an array of enumerated types for the
ParameterDefinition.
Name String Returns the name used in code to identify an object.
UnitType mwUnitType Returns a value which specifies the data unit type of the
ParameterDefinition.

ParameterDefinitions
A collection of MWOffice ParameterDefinition objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ParameterDefinition Returns a specific item of a Collection object either by
position or by key.

ParameterFrame
An MWOffice ParameterFrame object.

2116 NI AWR Design Environment


LayoutParameterFrame

Properties

Name Data Type Description


DisplayMode Boolean Returns/Sets various ParameterFrame display mode settings.
Height Long Returns the height of a ParameterFrame object.
Left Long Return the left edge position of the ParameterFrame object.
Selected Boolean Returns/sets if the ParameterFrame object is seleted.
Top Long Returns the top edge position of the ParameterFrame object.
Width Long Returns the width of a ParameterFrame object.
x Long Returns/sets the x position of a ParameterFrame object.
y Long Returns/sets the y position of a ParameterFrame object.

Methods
None

LayoutParameterFrame
An MWOffice LayoutParameterFrame object.

Properties

Name Data Type Description


DisplayMode Boolean Returns/Sets various ParameterFrame display mode settings.
Height Double Returns the height of a LayoutParameterFrame object.
Left Double Return the left edge position of the LayoutParameterFrame
object.
Selected Boolean Returns/sets if the ParameterFrame object is seleted.
Top Double Returns the top edge position of the LayoutParameterFrame
object.
Width Double Returns the width of a LayoutParameterFrame object.
x Double Returns/sets the x position of a LayoutParameterFrame
object.
y Double Returns/sets the y position of a LayoutParameterFrame
object.

Methods
None

ProcessLibrary
An MWOffice ProcessLibrary object.

API Scripting Guide 2117


ProcessLibraries

Properties

Name Data Type Description


IniFilePath String Returns the file path to the initialization file for this
ProcessLibrary object.
Name String Returns/Sets the name used in code to identify an object.
Version String Returns a string containing the version information for the
MWOffice ProcessLibrary object.

ProcessLibraries
A collection of MWOffice ProcessLibrary objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ProcessLibrary Returns a specific item of a Collection object either by
position or by key.

Methods
AddLibrary

Description: Adds a ProcessLibrary entry to the MOWOffice ProcessLibraries collection.

Returns: Boolean

Syntax: Function AddLibrary(Name As String, IniFilePath As String) As Boolean

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

RemoveLibrary

Description: Removes a ProcessLibrary entry from the MWOffice ProcessLibraries collection.

Returns: Boolean

Syntax: Function RemoveLibrary(Index) As Boolean

2118 NI AWR Design Environment


ProcessLibraryInfo

ProcessLibraryInfo
An MWOffice ProcessLibraryInfo object.

Properties

Name Data Type Description


Description String Returns a description of the MWOffice ProcessLibraryInfo
object.
Name String Returns/Sets the name used in code to identify an object.
Version String Returns the version of the MWOffice ProcessLibraryInfo
object.

ProcessLibraryInfos
A collection of MWOffice ProcessLibraryInfo objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ProcessLibraryInfo Returns a specific item of a Collection object either by
position or by key.

Property
An MWOffice Property object.

Properties

Name Data Type Description


Attributes Long Returns a value which specifies the attributes of a Property
object.
DefaultValue Variant Returns a value which specifies the default value of the
object.
Name String Returns the name used in code to identify an object.
Type mwPropertyDataType Returns a value which specifies the data unit type of the
object.
Value Variant Returns the value of a Property object.

Properties
A collection of MWOffice Property objects.

API Scripting Guide 2119


Schematic

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Item Property Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Property

Syntax: Function Add(Name As String, Value, [Attributes As Long = 0]) As Property

Exists

Description: Returns whether an item matching the specified criteria exists in the collection.

Returns: Boolean

Syntax: Function Exists(Name As String) As Boolean

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Void

Syntax: Sub Remove(Name As String)

Schematic
An MWOffice Schematic object.

Click to see examples

Properties

Name Data Type Description


Boundary Boundary Returns a reference to a Boundary object.

2120 NI AWR Design Environment


Schematic

Name Data Type Description


CanPaste Boolean Returns a value that determines the clipboard contents can
be pasted to the object.
Changed Boolean Returns/Sets a value that indicates if the object has changed
and needs to be saved or resimulated.
DrawingShapes DrawingShapes Returns a reference to a collection of DrawingShape objects.
ElectricalNets ElectricalNets Returns a reference to a MWOffice ElectNet collection
consisting of only the schematic electrical network elements
Elements Elements Returns a reference to a collection of Element objects.
Embedded Boolean Returns if the schematic document is embedded in the
project or linked externally
EmbeddedDesigns EmbeddedDesigns Returns a reference to a collection of EmbeddedDesign
objects.
Equations Equations Returns a reference to a collection of Equation objects.
FilePath String Returns the Schematic document file path.
Frequencies Frequencies Returns a reference to a collection of Frequency objects.
GridVisible Boolean Returns/sets a value that specifies if the snap grid is visible
for the Schematic.
Layout Layout Returns a reference to a Layout object.
LockLevel mwDiagramLockLevel Returns a value that specifies the lock level of the schematic
diagram
LockUpdates Boolean property LockUpdates
Name String Returns/Sets the name used in code to identify an object.
NamedConnectors NamedConnectors Returns a reference to a MWOffice NamedConnector
collection consisting of only the schematic named connector
elements
Options Options Returns a reference to a collection of Option objects.
Orthogonal Boolean Returns/sets a value that specifies if drawing should be only
orthogonal in the schematic.
Ports Ports Returns a reference to a MWOffice Port collection consisting
of only the schematic port elements
ProcessDefinition String Returns/sets the name of the layout process definition
associated with this schematic.
Properties Properties Returns a reference to a collection of Property objects.
SelectedElements SelectedElements Returns a reference to a collection of MWOffice
SelectedElement objects.
SelectedWires SelectedWires Returns a reference to a collection of MWOffice
SelectedWire objects.
SimulationDirty Boolean Returns if the current simulation state is dirty for the
Schematic object.
SimulationState Long Returns the current simulation state for the Schematic object.

API Scripting Guide 2121


Schematic

Name Data Type Description


SnapToGrid Boolean Returns/sets a value that specifies if grid snap is enabled for
the Schematic
Subcircuits Subcircuits Returns a reference to a MWOffice Subcircuit collection
consisting of only the schematic subcircuit elements
SweepVariables SweepVariables Returns a reference to a MWOffice SweepVariables
collection.
UseProjectFrequencies Boolean Returns/sets a value which specifies if the global project
frequencies should be used for analysis.
UseProjectOptions Boolean Returns/sets a value which specifies if the global project
options should be used.
Views Views Returns a reference to a MWOffive Views collection.
Windows Windows Returns a reference to a collection of Window objects.
Wires Wires Returns a reference to a collection of WireSegment objects.
XGridSpacing Long Returns/sets a value that specifies the grid spacing along
the X coordinate direction.
YGridSpacing Long Returns/sets a value that specifies the grid spacing along
the Y coordinate direction.

Methods
Activate

Description: Activates the objects.

Returns: Void

Syntax: Sub Activate()

AddExtraction

Description: Add an exraction document associated with this schematic object. Values specified in extract block in the
schematic

Returns: Boolean

Syntax: Function AddExtraction() As Boolean

CopyToClipboard

Description: Copies the object to the system clipboard.

Returns: Void

Syntax: Sub CopyToClipboard()

CopyViewToClipboard

Description: Copies the object to the system clipboard.

2122 NI AWR Design Environment


Schematic

Returns: Boolean

Syntax: Function CopyViewToClipboard() As Boolean

Export

Description: Exports a design document file from MWOffice.

Returns: Void

Syntax: Sub Export(FilePath As String, [format As mwSchematicExportFormat = 0])

ExportNetlist

Description: Exports a netlist document file from MWOffice.

Returns: Void

Syntax: Sub ExportNetlist(FilePath As String, [format As mwSchematicNetlistExportFormat = 0])

InvokeCommand

Description: Invoke a menu command by specifying the name for the command. Arguments need to be supplied for
any input.

Returns: Void

Syntax: Sub InvokeCommand(CommandName As String, [Arguments], [pRet])

LockDiagram

Description: Changes the lock level of the schematic diagram to the given lock level

Returns: Boolean

Syntax: Function LockDiagram(NewLevel As mwDiagramLockLevel, [Password As String = ""]) As Boolean

NewWindow

Description: Displays the object in new window.

Returns: Window

Syntax: Function NewWindow([WindowType As mwWindowType = 9]) As Window

Paste

Description: Pastes the system clipboard to the object.

Returns: Boolean

Syntax: Function Paste(x As Long, y As Long, [CCWRotation As Long = 0], [Flipped As Boolean = 0]) As Boolean

API Scripting Guide 2123


Schematic

PrintOut

Description: Sends the object to the current printer.

Returns: Void

Syntax: Sub PrintOut()

PrintView

Description: Sends the object to the current printer.

Returns: Boolean

Syntax: Function PrintView() As Boolean

SetupConnectivity

Description: method SetupConnectivity

Returns: Void

Syntax: Sub SetupConnectivity()

StartCommand

Description: Start a menu command by specifying the name for the command, user wll need to complete interactive
input.

Returns: Void

Syntax: Sub StartCommand(CommandName As String, [pRet])

UpdateConnectivity

Description: Sends notifications that the connectivity of this schematic document has changed and referring documents
need to update.

Returns: Void

Syntax: Sub UpdateConnectivity()

Events
AfterRename

Description: Occurs after a Schematic has is renamed.

Returns: HRESULT

Syntax: Event AfterRename(OldName As String)

BeforeRemove

Description: Occurs when a Schematic is about to be removed from a Project.

2124 NI AWR Design Environment


Schematic

Returns: HRESULT

Syntax: Event BeforeRemove(Cancel As Boolean)

BeforeRename

Description: Occurs when a Schematic is about to be renamed.

Returns: HRESULT

Syntax: Event BeforeRename(NewName As String, Cancel As Boolean)

Options

Number Name Description


1 HideParameters Returns/sets if parameters should be hidden on diagrams.
2 HideParameterUnits Returns/sets if parameters units should be hidden on
diagrams.
3 HideParameterIfEmpty Returns/sets if empty parameters should be hidden on
diagrams.
4 HideParameterVarName Returns/sets if variable names should be hidden on diagrams
5 LeftJustifyParameters Returns/sets if parameters should be left justified on
diagrams.
6 BoldParameterFont Returns/sets if parameters names should use a bold font on
diagrams.
7 HideElementNames Returns/sets if element names should be hidden on system
diagrams.
8 BoldElementFont Returns/sets if element names should use a bold font on
diagrams.
9 LeftJustifyElementName Returns/sets if element names should be left justified.
10 HideSecondaryParameters Returns/sets if secondary parameters should be hidden.
11 SymbolLineThickness Returns/sets if the thickness for drawing symbol lines.
12 BlackAndWhite Returns/sets if elements should be drawn in black and white
13 DependentParametersInBaseUnits Returns/sets if schematic dependent parameters should be
in base units.
14 SignificantParameterDigits Returns/sets the number of significant digits displayed in
element parameters.
15 ParameterZeroThreshold Returns/sets the zero threshold number for element
parameters.
16 SchemLocalLPFName Returns/sets the name of the LPF file associated with this
schematic
17 SchemLocalLPFZOffset Returns/sets the z-offset associated with the local LPF
18 SchemLocalLPFFlippedZ Returns/sets if the z-offset is flipped
19 SysDependentParametersInBaseUnits Returns/sets if system diagram dependent parameters should
be in base units

API Scripting Guide 2125


Schematic

Number Name Description


20 SchematicSymbolName Returns sets the default symbol name used when the
document is placed as a subcircuit.
21 Spectre.PreText User supplied text that will be inserted at the beginning of
the netlist
22 Spectre.PostText User supplied text that will be inserted at the end of the
netlist
23 AWR_JobSchedulerMaxProcs Maximum number of logical processors (as seen by OS) to
allocate for the job (0 = Use all available, -1 = Use all but
one, etc.)
24 AWR_JobSchedulerMinProcs Minimum number of logical processors (as seen by OS) to
allocate for the job (0 = Use all available, -1 = Use all but
one, etc.)
25 AWR_JobSchedulerThreadsPerProc The number of computational threads created for each
allocated logical processor (Recommended settings:
Axiem=1-2, Analyst=1)
26 AWR_JobSchedulerJobOSPriority The Operating System priority to assign to the job process
once it's running. (Default=Normal, or the value set in the
user.ini file, if any)
27 AWR_JobSchedulerJobRemotePreference Preference for how to dispatch the job if remote job servers
are available
28 AWR_JobSchedulerJobPerfPreference The preferred processor performance of the server to be
assigned to the job, if the job is executed remotely.
29 AWR_JobSchedulerJobMemCapPreference The preferred memory capacity of the server to be assigned
to the job, if the job is executed remotely.
30 AWR_JobSchedulerJobRunAsMWOJob ALL simulations for this document will be done in a separate
MWO simulation process
31 AWR_UseResultsForPartialSwp Allow a swept parameter simulation to use the results when
some of the sweep points failed to simulate
32 SpecGlobalEquations Specify the global definition document to use as the global
equations for this document
33 APLAC_ACMatrixSolver Matrix solver used in AC analysis.
34 APLAC_ADDDCPATH Add resistive DC paths to ground for all floating nodes.
35 APLAC_PWL_ACC Defines the trade-off between accuracy and speed in the DC
convergence strategy #5.
36 APLAC_PWL_GRID Density of the controlling-voltage grids in the DC
convergence strategy #5.
37 APLAC_TAUDC Time constant for ideal capacitors and inductors in DC
analysis. Specifying TAUDC=0 excludes this property.
38 APLAC_CONV_STRATEGY Specifies the 1st convergence strategy to be used in DC
analysis.
39 APLAC_DCMatrixSolver Matrix solver used in DC analysis.
40 APLAC_DC_SPARSE_LEVEL Sparse matrix re-ordering strategy used in DC analysis.

2126 NI AWR Design Environment


Schematic

Number Name Description


41 APLAC_ThermalFeedback Enable the thermal feedback in all electrothermal
components.
42 APLAC_ETMAXTEMP Maximum allowed temperature rise during the
electrothermal simulation.
43 APLAC_ETSCALE Scaling coefficient for the voltage levels of the
electrothermal nodes.
44 APLAC_ENV_STOP_TIME Stop time used for envelope analysis
45 APLAC_ENV_TIME_STEP Envelope analysis time step.
46 APLAC_ERR Relative accuracy of the voltages and currents in the circuit.
47 APLAC_ABS_ERR Absolute accuracy of the voltages and currents in the circuit.
48 APLAC_U Largest accepted change in any node voltage or branch
current between consecutive iterations.
49 APLAC_ITER Maximum number of iterations.
50 APLAC_RMIN Minimum resistance level.
51 APLAC_RMAX Maximum resistance level.
52 APLAC_GMRES_ERR Absolute accuracy for terminating GMRES iterations.
53 APLAC_GMRES_ITER Maximum number of restarts in the GMRES iteration.
54 APLAC_GMRES_M Maximum number of full GMRES iterations.
55 APLAC_INIT_SOURCE_STEP Initial damping factor in source stepping.
56 APLAC_ZEROPIVOT Zero level for a pivot element in solving the circuit matrix.
57 APLAC_NONMONOTONESTEPS Maximum number of non-monotone steps.
58 APLAC_SOURCE_STEP_CYCLES Maximum number of cycles in source stepping.
59 APLAC_ForceDC Force a DC analysis at every sweep point. Applies to Linear,
AC, and HB simulators.
60 APLAC_RESETDC Don't use previous sweep point as a starting guess for DC.
61 APLAC_RESETHB Don't use previous sweep point as a starting guess for HB.
62 APLAC_LOADDCGUESS Use saved results as the initial guess for DC.
63 APLAC_SAVEDCGUESS Save results for use as a starting guess for DC.
64 APLAC_LOADHBGUESS Use saved results as the initial guess for HB.
65 APLAC_SAVEHBGUESS Save results for use as a starting guess for HB.
66 APLAC_ShowNonconverged Include non-converged sweep points in the measurement
results.
67 APLAC_HBMODE Use nodal or piecewise harmonic-balance algorithm. Auto
select chooses optimal algorithm based on circuit topology.
68 APLAC_INEXACT_NEWTON Method for computing the accuracy of GMRES iteration.
69 APLAC_INEXACT_NEWTON_ERR Multiplier used in computing the accuracy of GMRES
iteration if INEXACT_NEWTON=2.
70 APLAC_LSSS_SAMPLES Number of sampling points used in the
large-signal/small-signal analysis.

API Scripting Guide 2127


Schematic

Number Name Description


71 APLAC_HBMatrixSolver Matrix solver used in HB analysis.
72 APLAC_HBNoiseMatrixSolver Matrix solver used in nonlinear noise analysis.
73 APLAC_HB_LINEARIZE Improves performance when many devices are not strongly
driven.
74 APLAC_TaHBMode Use transient assisted HB algorithm.
75 APLAC_TaHBMinPeriods Minimum number of periods used in transient assisted HB.
76 APLAC_TaHBMaxPeriods Maximum number of periods used in transient assisted HB.
77 APLAC_TaHBErrorTol Relative error tolerance for detecting transient steady state.
78 APLAC_TaHBFirstPointOnly Use transient assisted HB in the first sweep point, use as a
convergence aid in other sweep points.
79 APLAC_NTHREADS Number of threads used.
80 APLAC_FNOM Nominal frequency used in the computation of
frequency-dependent functions in DC and transient analyses.
81 APLAC_INDSCALE Scaling factor for inductors.
82 APLAC_RESMODE Use a gyrator and a conductance to implement small
resistors.
83 APLAC_RESMODEVALUE Threshold R0 for RESMODE.
84 APLAC_RESWARNING Give warning when zero resistors are shorted or small
resistors are implemented using a gyrator.
85 APLAC_REMOVEZERORES Replace resistors that have a zero initial value with a short
circuit.
86 APLAC_LIMITEDR Enable limiting of resistors with temperature coefficients.
87 APLAC_UseMarchingWF Use marching waveforms to update measurements while
simulating.
88 APLAC_FreeText Add any text to the end of the APLAC Prepare statement.
89 APLAC_storeActiveMeas Write data into the dataset only if there are active
measurements that use it.
90 APLAC_SIMTYPE Simulation type used in the element extraction. Time domain
uses approximations for linear frequency-dependent
elements that work in all analysis modes, but may require
a significant amount of CPU time to create. Frequency
domain uses Y parameters for linear elements.
91 APLAC_StabEnvelopePoints Number of impedance points used in computing the Stability
Envelope.
92 APLAC_PrintDCOPS Print DC operating point information of all components.
93 APLAC_PrintPUBLICS Print public values of all components.
94 APLAC_PrintSUMMARY Print the total number of components, analyses, etc.
95 APLAC_PrintAPLACVERSION Print APLAC version information.
96 APLAC_TransientPreset Transient analysis preset.
97 APLAC_TransientErrRef Transient analysis error reference.

2128 NI AWR Design Environment


Schematic

Number Name Description


98 APLAC_IntegrationMethod Numerical integration method used in the transient analysis.
99 APLAC_TimeStep Use fixed or variable time step.
100 APLAC_TRANMODE Time-step control is based on sweep grid (Mode 0) or source
events (Modes 1 and 2). Auto select uses Mode 0 for
autonomous circuits (e.g., oscillators) and Mode 1 otherwise.
101 APLAC_TRANNORMREDUCTION Use norm-reduction in transient analysis.
102 APLAC_TRUNCERRMODE Local truncation error computation mode. Auto select uses
Voltage for circuits having sinusoidal excitations and Charge
otherwise.
103 APLAC_TRTOL Local truncation error parameter.
104 APLAC_TransientMatrixSolver Matrix solver used in the transient analysis.
105 APLAC_HBAssistedTransient Use HB analysis as a starting point for transient analysis.
The circuit will be in a steady state corresponding to the HB
solution at the transient analysis start time.
106 NumberTone1Harmonics Number of harmonics used for tone 1 for harmonic balance
107 NumberTone2Harmonics Number of harmonics used for tone 2 for harmonic balance
108 NumberTone3Harmonics Number of harmonics used for tone 3 for harmonic balance
109 OversamplingRate Tone 1 over sample factor used for sampling the nonlinear
time domain waveforms, increasing can reduce aliasing
errors
110 OversamplingRate2 Tone 2 over sample factor used for sampling the nonlinear
time domain waveforms, increasing can reduce aliasing
errors
111 OversamplingRate3 Tone 3 over sample factor used for sampling the nonlinear
time domain waveforms, increasing can reduce aliasing
errors
112 MaximumHarmonicIterations Sets the maximum number of iterations allowed before
source stepping is started
113 RelativeConvergenceError Relative current error tolerance used to determine
convergence
114 AbsoluteConvergenceError Absolute current error tolerance used to determine
convergence
115 LimitHarmonicOrder Limit the order of the harmonics for harmonic balance
116 MaximumHarmonicOrder Maximum order used to limit the intermod products
117 AWRHB_LIMITINTERMODONLY Apply the order limit to intermod products only
118 AWRHB_LINEARIZE_MODE Used improve performance when many devices are not
strongly driven
119 AWRHB_LINEARIZE_TOL Relative tolerance used to determine when to linearize
120 AWRHB_SOLVE_TYPE Formulation used for HB solver
121 AWRHB_CONVERGE_FAIL_ACT Specify what should happen when the HB solver fails to
converge

API Scripting Guide 2129


Schematic

Number Name Description


122 AWRHB_SUB_SIZE Specify the size of the Krlylov subspace used within the
HB solver
123 AWRHB_SOLVER_SETTER Formulation used for HB solver
124 AWRHB_CONFIG Paste in the solver options used to configure the solver
125 AWRHB_CONFIG_LEARN Configuration file for automated training
126 AWRHB_USE_CONFIG_WIZ The options in this group are used to automatically configure
other options on this option page
127 AWRHB_CONFIG_TO_TRY This option is used to automatically populate the solver
configuration
128 AWRHB_WIZ_SOURCE_STEP Always do source stepping using the source stepping values
defined in this group
129 AWRHB_WIZ_SS_RED Amount of source step reduction used at the beginning of
the iterations
130 AWRHB_WIZ_SS_STEP Size of steps used for source stepping at the beginning of
the iterations
131 AWRHB_WIZ_TOL_OPT Use to specify a looser convergence tolerance for the earlier
steps in the source stepping
132 AWRHB_ADD_SHUNT Automatically add a minimum conductance across all
nonlinear elements
133 AWRHB_SHUNT_VAL Minimum conductance value that is added across each
nonlinear element
134 AWRHB_LIMIT_V_STEP Limit the size of the voltage step that can be taken during
the solution process
135 AWRHB_LIMIT_V_SIZE Maximum size of the voltage change if step limiting is
enabled
136 AWRHB_SRC_RES Internal series resistance of sources
137 AWRHB_DO_NOT_USE_PREVIOUS_DC Don't use previous sweep point for starting guess for DC
analysis
138 AWRHB_DO_NOT_USE_PREVIOUS_HB Don't use previous sweep point for starting guess for
harmonic balance
139 AWRHB_MODEL_INIT_GUESS For models that support an initial guess value, use the value
for the DC and HB initial guess
140 AWRHB_SAVE_RESULTS Save results in the project for use as a starting guess for
harmonic balance
141 AWRHB_USE_SAVE_RESULTS Use saved results as a starting guess for harmonic balance
142 AWRHB_COMP_NLD_IV Compute and save the nonlinear element voltages and
currents (for measurements)
143 AWRHB_COMP_LIN_IV Compute and save the linear element voltages and currents
(for measurements)
144 AWRHB_COMP_OP_PNT Compute and save the device operating point info (for
measurements)

2130 NI AWR Design Environment


Schematic

Number Name Description


145 AWRHB_COMP_OP_TD Compute and save the time domain device operating point
info (for measurements)
146 AWRHB_COMP_QCG Compute and save the nonlinear charge, capacitance and
conductance for the controlled sources within the nonlinear
elements
147 AWRHB_MAX_TIME_PNTS Limits the number of time points that can be displayed for
harmonic balance results
148 AWRHB_DIAGNOSE Run internal solver diagnostics
149 AWRHB_PROFILE Automatically profile the algorithm performance
150 AWRHB_HIDDEN_BRANCHES Compute and save the nonlinear element voltages and
currents for hidden branches within a nonlinear element
151 AWRTRAN_USE_HB_SETTINGS Use the harmonic balance settings to determine the stop
time for transient analysis
152 AWRTRAN_PERIODS Define the stop time as a multiple of the period defined by
the harmonic balance settings
153 AWRTRAN_START_TIME Start time used to define the beginning of data collection
for transient analysis
154 AWRTRAN_STOP_TIME Stop time used for transient analysis
155 AWRTRAN_STEP Step time used for transient analysis results
156 AWRTRAN_TIME_OFFSET Offsets the time value used to display the time domain
waveform. Set this equal to 'Start time' to make the wave
form display as starting from T = 0
157 AWRTRAN_SAVE_CURRENTS Specify the types of currents that are saved in the results of
the transient simulation
158 AWRTRAN_SAVE_VOLTAGES_EX Specify the types of voltages that are saved in the results of
the transient simulation
159 AWRTRAN_SHOW_LAST2PERIODS Only show the last two periods of the results (can use for
easier comparison with harmonic balance)
160 AWRTRAN_USE_DELAY_FOR_ANGLE Helps transient simulations to reach steady state faster. If
selected, the sine wave sources whose value at zero time is
not zero will stay constant at zero value until their value
becomes zero again.
161 AWRTRAN_TX_MIN_LINE_LEN Transmission lines with a length less than this factor of
lambda will get approximated as a lumped model
162 AWRTRAN_TX_MAX_FREQ Maximum frequency to use for table generation
163 AWRTRAN_TX_NUMB_FREQ Number of frequency points used for table generation
164 AWRTRAN_TX_LOG_GRID By default a linear frequency grid will be used, this option
allows for a logarithmic grid
165 LinearSolveType Specify the type of matrix solver to use for solving the linear
circuit simulation
166 UseIncrementalSolve Use a fast hierarchical incremental solver (faster with tuning
and optimization)

API Scripting Guide 2131


Schematic

Number Name Description


167 AWRLIN_SOLVE_FLAT Solve the linear circuit with hierarchy flattened (global
problem is solved in a single matrix)
168 AWRLIN_SOLVE_NOISE Compute the noise solution for the circuit
169 AWRLIN_MIN_SERIES_RES_EXP The value X entered will define the minimum source series
resistance as 1eX
170 AWRLIN_MIN_NODE_COND_EXP The value X entered will define the minimum node
conductance as 1eX
171 AWRLIN_ADD_COND_TO_ALL Always add the minimum node conductance defined above
to all nodes to prevent singularities
172 AWRLIN_ADD_COND_TO_SING Only add the minimum node conductance if a singularity
is detected (slower than always adding a conductance when
there is a singularity)
173 Spice.Options Option statement that is added to the HSPICE netlist. This
option will automatically update when any option below
that defines an HSPICE option is changed. You can also
type or paste in HSPICE options directly into this field, and
the corresponding options below will be automatically
updated.
174 Spice.ABSH Absolute accuracy of the currents in the circuit. A value of
zero will use the internal HSPICE default
175 Spice.ABSV Absolute accuracy of the voltages in the circuit. A value of
zero will use the internal HSPICE default
176 Spice.CHGTOL Absolute accuracy of the charges in the circuit. A value of
zero will use the internal HSPICE default
177 Spice.RELH Relative accuracy of the currents in the circuit. This option
is only used if the value of the 'Absolute current error'
control option is greater than zero
178 Spice.RELV Relative accuracy of the voltages in the circuit. A value of
zero will use the internal HSPICE default
179 Spice.RELQ Relative accuracy of the charges in the circuit. A value of
zero will use the internal HSPICE default. Only used with
LVLTIM = 2
180 Spice.ABSMOS Absolute accuracy of the currents in the MOSFETs.
181 Spice.ABSVDC Minimum voltage for DC and Transient analysis
182 Spice.RELMOS Relative accuracy of the currents in the MOSFETs.
183 Spice.RELVDC Relative voltage error tolerance from iteration to iteration
184 Spice.TRTOL Local truncation error for timestep algorithm
185 Spice.CPTIME Maximum CPU time for simulation (seconds)
186 Spice.DELMAX Maximum value for delta of internal timestep (default value
depends on circuit)
187 Spice.DI Maximum current change between iterations, through
voltage sources and inductors, if ABSH > 0

2132 NI AWR Design Environment


Schematic

Number Name Description


188 Spice.ITL1 Maximum DC iteration limit
189 Spice.ITL2 Maximum DC transfer curve iteration limit
190 Spice.ITL4 Maximum number of iterations per time point. Smaller step
is used if this is exceeded
191 Spice.MAXAMP Maximum current through voltage sources and inductors
(0=infinite)
192 Spice.RESMIN Min resistance for all resistors, including parasitic and
inductive
193 Spice.ACCURATE Sets several options to improve accuracy and time domain
resolution
194 Spice.CONVERGE Chooses convergence algorithm, tries each in turn by default
195 Spice.CSHUNT Capacitance added from each node to ground
196 Spice.DCSTEP Adds an extra conductance parallel to capacitors present in
the netlist. For example, if DCSTEP=0.1, a conductance of
0.1x10e-12 Sm is added in parallel to the 1 pF capacitor
197 Spice.FAST Sets several options to improve speed at cost of time domain
resolution
198 Spice.GMIN Minimum conductance in transient analysis
199 Spice.GMINDC Parallel conductance for PN junctions and between
MOSFET nodes for DC convergence
200 Spice.GSHUNT Conductance added between each node and ground
201 Spice.KCLTEST Activates Kirchoff's Current Law & sets options for accuracy
at cost of speed
202 Spice.METHOD Allows you to choose trapezoidal (TRAP, default), or the
Gear method when integrating the system of ordinary
differential equations. The Gear method is utilized if
parasitic numerical oscillations develop
203 Spice.ACCT Include accounting and runtime statistics
204 Spice.BRIEF Exclude input circuit information
205 Spice.CAPTAB Print a table of single-plate node capacitance for some
devices at each operating point
206 Spice.DIAGNOSTIC Log occurrence of negative model conductances
207 Spice.LIST Include element summary listing of input circuit
208 Spice.NODE Include node cross reference table
209 Spice.NOMOD Exclude model parameters
210 Spice.NOPAGE Exclude page ejects for title headings
211 Spice.NOWARN Suppress warning messages
212 Spice.OPTS Include settings for all control options
213 Spice.VFLOOR Lower limit for printed voltages; smaller voltages are printed
as 0

API Scripting Guide 2133


Schematics

Number Name Description


214 Spice.WARNLIMIT Limit number of times certain warnings appear in output
listing
215 Spice.CO Number of characters per line in the .lis file
216 Spice.INGOLD Numerical format(1=Engineering, 2=G format, 3=Sci.
notation)
217 Spice.LENNAM Maximum length of names in operating point analysis report
218 Spice.NUMDGT Number of significant digits for output variable values
219 Spice.PATHNUM Hierarchical path numbers for subcircuits, instead of names
220 Spice.Preamble Text to add at the beginning of the netlist
221 Spice.Postamble Text to add at the end of the netlist
222 Spice.SaveResults With this option checked the Hspice related files will be
saved in a subdirectory of the project location
223 Spice.LoadPreviousBias Use bias data from previous simulation as initial guess
224 Spice.UseExistingResultsFile With this option checked the existing results file is used
without running the simulation
225 Spice.UseExistingNetListFile Use existing netlist file (not recommended)
226 AWRMOD_SPICE_LEVEL Use to control how distributed models are mapped to time
domain equivalent models
227 AWRMOD_MODEL_VERS Use to specify that an older version of a model should be
used

Schematics
A collection of MWOffice Schematic objects.

Properties

Name Data Type Description


ActiveSchematic Schematic Returns the active schematic of a Project object.
Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Schematic Returns a specific item of a Collection object either by
position or by key.
Options Options Returns a reference to a collection of Option objects.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Schematic

2134 NI AWR Design Environment


Schematics

Syntax: Function Add(Name As String) As Schematic

Copy

Description: Copies an object from another object collection into this object collection.

Returns: Schematic

Syntax: Function Copy(Index, [NewName As String = ""]) As Schematic

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Import

Description: Adds a Netlist object to the collection from a file and returns a reference to the created object.

Returns: Schematic

Syntax: Function Import(Name As String, Filename As String) As Schematic

LinkTo

Description: Adds a Schematic object link to the collection from a file and returns a reference to the created object.

Returns: Schematic

Syntax: Function LinkTo(Name As String, Filename As String) As Schematic

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

Options

Number Name Description


1 Spectre.PreText User supplied text that will be inserted at the beginning of
the netlist
2 Spectre.PostText User supplied text that will be inserted at the end of the
netlist
3 AWR_JobSchedulerMaxProcs Maximum number of logical processors (as seen by OS) to
allocate for the job (0 = Use all available, -1 = Use all but
one, etc.)

API Scripting Guide 2135


Schematics

Number Name Description


4 AWR_JobSchedulerMinProcs Minimum number of logical processors (as seen by OS) to
allocate for the job (0 = Use all available, -1 = Use all but
one, etc.)
5 AWR_JobSchedulerThreadsPerProc The number of computational threads created for each
allocated logical processor (Recommended settings:
Axiem=1-2, Analyst=1)
6 AWR_JobSchedulerJobOSPriority The Operating System priority to assign to the job process
once it's running. (Default=Normal, or the value set in the
user.ini file, if any)
7 AWR_JobSchedulerJobRemotePreference Preference for how to dispatch the job if remote job servers
are available
8 AWR_JobSchedulerJobPerfPreference The preferred processor performance of the server to be
assigned to the job, if the job is executed remotely.
9 AWR_JobSchedulerJobMemCapPreference The preferred memory capacity of the server to be assigned
to the job, if the job is executed remotely.
10 AWR_JobSchedulerJobRunAsMWOJob ALL simulations for this document will be done in a separate
MWO simulation process
11 AWR_UseResultsForPartialSwp Allow a swept parameter simulation to use the results when
some of the sweep points failed to simulate
12 APLAC_ACMatrixSolver Matrix solver used in AC analysis.
13 APLAC_ADDDCPATH Add resistive DC paths to ground for all floating nodes.
14 APLAC_PWL_ACC Defines the trade-off between accuracy and speed in the DC
convergence strategy #5.
15 APLAC_PWL_GRID Density of the controlling-voltage grids in the DC
convergence strategy #5.
16 APLAC_TAUDC Time constant for ideal capacitors and inductors in DC
analysis. Specifying TAUDC=0 excludes this property.
17 APLAC_CONV_STRATEGY Specifies the 1st convergence strategy to be used in DC
analysis.
18 APLAC_DCMatrixSolver Matrix solver used in DC analysis.
19 APLAC_DC_SPARSE_LEVEL Sparse matrix re-ordering strategy used in DC analysis.
20 APLAC_ThermalFeedback Enable the thermal feedback in all electrothermal
components.
21 APLAC_ETMAXTEMP Maximum allowed temperature rise during the
electrothermal simulation.
22 APLAC_ETSCALE Scaling coefficient for the voltage levels of the
electrothermal nodes.
23 APLAC_ENV_STOP_TIME Stop time used for envelope analysis
24 APLAC_ENV_TIME_STEP Envelope analysis time step.
25 APLAC_ERR Relative accuracy of the voltages and currents in the circuit.
26 APLAC_ABS_ERR Absolute accuracy of the voltages and currents in the circuit.

2136 NI AWR Design Environment


Schematics

Number Name Description


27 APLAC_U Largest accepted change in any node voltage or branch
current between consecutive iterations.
28 APLAC_ITER Maximum number of iterations.
29 APLAC_RMIN Minimum resistance level.
30 APLAC_RMAX Maximum resistance level.
31 APLAC_GMRES_ERR Absolute accuracy for terminating GMRES iterations.
32 APLAC_GMRES_ITER Maximum number of restarts in the GMRES iteration.
33 APLAC_GMRES_M Maximum number of full GMRES iterations.
34 APLAC_INIT_SOURCE_STEP Initial damping factor in source stepping.
35 APLAC_ZEROPIVOT Zero level for a pivot element in solving the circuit matrix.
36 APLAC_NONMONOTONESTEPS Maximum number of non-monotone steps.
37 APLAC_SOURCE_STEP_CYCLES Maximum number of cycles in source stepping.
38 APLAC_ForceDC Force a DC analysis at every sweep point. Applies to Linear,
AC, and HB simulators.
39 APLAC_RESETDC Don't use previous sweep point as a starting guess for DC.
40 APLAC_RESETHB Don't use previous sweep point as a starting guess for HB.
41 APLAC_LOADDCGUESS Use saved results as the initial guess for DC.
42 APLAC_SAVEDCGUESS Save results for use as a starting guess for DC.
43 APLAC_LOADHBGUESS Use saved results as the initial guess for HB.
44 APLAC_SAVEHBGUESS Save results for use as a starting guess for HB.
45 APLAC_ShowNonconverged Include non-converged sweep points in the measurement
results.
46 APLAC_HBMODE Use nodal or piecewise harmonic-balance algorithm. Auto
select chooses optimal algorithm based on circuit topology.
47 APLAC_INEXACT_NEWTON Method for computing the accuracy of GMRES iteration.
48 APLAC_INEXACT_NEWTON_ERR Multiplier used in computing the accuracy of GMRES
iteration if INEXACT_NEWTON=2.
49 APLAC_LSSS_SAMPLES Number of sampling points used in the
large-signal/small-signal analysis.
50 APLAC_HBMatrixSolver Matrix solver used in HB analysis.
51 APLAC_HBNoiseMatrixSolver Matrix solver used in nonlinear noise analysis.
52 APLAC_HB_LINEARIZE Improves performance when many devices are not strongly
driven.
53 APLAC_TaHBMode Use transient assisted HB algorithm.
54 APLAC_TaHBMinPeriods Minimum number of periods used in transient assisted HB.
55 APLAC_TaHBMaxPeriods Maximum number of periods used in transient assisted HB.
56 APLAC_TaHBErrorTol Relative error tolerance for detecting transient steady state.
57 APLAC_TaHBFirstPointOnly Use transient assisted HB in the first sweep point, use as a
convergence aid in other sweep points.

API Scripting Guide 2137


Schematics

Number Name Description


58 APLAC_NTHREADS Number of threads used.
59 APLAC_FNOM Nominal frequency used in the computation of
frequency-dependent functions in DC and transient analyses.
60 APLAC_INDSCALE Scaling factor for inductors.
61 APLAC_RESMODE Use a gyrator and a conductance to implement small
resistors.
62 APLAC_RESMODEVALUE Threshold R0 for RESMODE.
63 APLAC_RESWARNING Give warning when zero resistors are shorted or small
resistors are implemented using a gyrator.
64 APLAC_REMOVEZERORES Replace resistors that have a zero initial value with a short
circuit.
65 APLAC_LIMITEDR Enable limiting of resistors with temperature coefficients.
66 APLAC_UseMarchingWF Use marching waveforms to update measurements while
simulating.
67 APLAC_FreeText Add any text to the end of the APLAC Prepare statement.
68 APLAC_storeActiveMeas Write data into the dataset only if there are active
measurements that use it.
69 APLAC_SIMTYPE Simulation type used in the element extraction. Time domain
uses approximations for linear frequency-dependent
elements that work in all analysis modes, but may require
a significant amount of CPU time to create. Frequency
domain uses Y parameters for linear elements.
70 APLAC_StabEnvelopePoints Number of impedance points used in computing the Stability
Envelope.
71 APLAC_PrintDCOPS Print DC operating point information of all components.
72 APLAC_PrintPUBLICS Print public values of all components.
73 APLAC_PrintSUMMARY Print the total number of components, analyses, etc.
74 APLAC_PrintAPLACVERSION Print APLAC version information.
75 APLAC_TransientPreset Transient analysis preset.
76 APLAC_TransientErrRef Transient analysis error reference.
77 APLAC_IntegrationMethod Numerical integration method used in the transient analysis.
78 APLAC_TimeStep Use fixed or variable time step.
79 APLAC_TRANMODE Time-step control is based on sweep grid (Mode 0) or source
events (Modes 1 and 2). Auto select uses Mode 0 for
autonomous circuits (e.g., oscillators) and Mode 1 otherwise.
80 APLAC_TRANNORMREDUCTION Use norm-reduction in transient analysis.
81 APLAC_TRUNCERRMODE Local truncation error computation mode. Auto select uses
Voltage for circuits having sinusoidal excitations and Charge
otherwise.
82 APLAC_TRTOL Local truncation error parameter.
83 APLAC_TransientMatrixSolver Matrix solver used in the transient analysis.

2138 NI AWR Design Environment


Schematics

Number Name Description


84 APLAC_HBAssistedTransient Use HB analysis as a starting point for transient analysis.
The circuit will be in a steady state corresponding to the HB
solution at the transient analysis start time.
85 NumberTone1Harmonics Number of harmonics used for tone 1 for harmonic balance
86 NumberTone2Harmonics Number of harmonics used for tone 2 for harmonic balance
87 NumberTone3Harmonics Number of harmonics used for tone 3 for harmonic balance
88 OversamplingRate Tone 1 over sample factor used for sampling the nonlinear
time domain waveforms, increasing can reduce aliasing
errors
89 OversamplingRate2 Tone 2 over sample factor used for sampling the nonlinear
time domain waveforms, increasing can reduce aliasing
errors
90 OversamplingRate3 Tone 3 over sample factor used for sampling the nonlinear
time domain waveforms, increasing can reduce aliasing
errors
91 MaximumHarmonicIterations Sets the maximum number of iterations allowed before
source stepping is started
92 RelativeConvergenceError Relative current error tolerance used to determine
convergence
93 AbsoluteConvergenceError Absolute current error tolerance used to determine
convergence
94 LimitHarmonicOrder Limit the order of the harmonics for harmonic balance
95 MaximumHarmonicOrder Maximum order used to limit the intermod products
96 AWRHB_LIMITINTERMODONLY Apply the order limit to intermod products only
97 AWRHB_LINEARIZE_MODE Used improve performance when many devices are not
strongly driven
98 AWRHB_LINEARIZE_TOL Relative tolerance used to determine when to linearize
99 AWRHB_SOLVE_TYPE Formulation used for HB solver
100 AWRHB_CONVERGE_FAIL_ACT Specify what should happen when the HB solver fails to
converge
101 AWRHB_SUB_SIZE Specify the size of the Krlylov subspace used within the
HB solver
102 AWRHB_SOLVER_SETTER Formulation used for HB solver
103 AWRHB_CONFIG Paste in the solver options used to configure the solver
104 AWRHB_CONFIG_LEARN Configuration file for automated training
105 AWRHB_USE_CONFIG_WIZ The options in this group are used to automatically configure
other options on this option page
106 AWRHB_CONFIG_TO_TRY This option is used to automatically populate the solver
configuration
107 AWRHB_WIZ_SOURCE_STEP Always do source stepping using the source stepping values
defined in this group

API Scripting Guide 2139


Schematics

Number Name Description


108 AWRHB_WIZ_SS_RED Amount of source step reduction used at the beginning of
the iterations
109 AWRHB_WIZ_SS_STEP Size of steps used for source stepping at the beginning of
the iterations
110 AWRHB_WIZ_TOL_OPT Use to specify a looser convergence tolerance for the earlier
steps in the source stepping
111 AWRHB_ADD_SHUNT Automatically add a minimum conductance across all
nonlinear elements
112 AWRHB_SHUNT_VAL Minimum conductance value that is added across each
nonlinear element
113 AWRHB_LIMIT_V_STEP Limit the size of the voltage step that can be taken during
the solution process
114 AWRHB_LIMIT_V_SIZE Maximum size of the voltage change if step limiting is
enabled
115 AWRHB_SRC_RES Internal series resistance of sources
116 AWRHB_DO_NOT_USE_PREVIOUS_DC Don't use previous sweep point for starting guess for DC
analysis
117 AWRHB_DO_NOT_USE_PREVIOUS_HB Don't use previous sweep point for starting guess for
harmonic balance
118 AWRHB_MODEL_INIT_GUESS For models that support an initial guess value, use the value
for the DC and HB initial guess
119 AWRHB_SAVE_RESULTS Save results in the project for use as a starting guess for
harmonic balance
120 AWRHB_USE_SAVE_RESULTS Use saved results as a starting guess for harmonic balance
121 AWRHB_COMP_NLD_IV Compute and save the nonlinear element voltages and
currents (for measurements)
122 AWRHB_COMP_LIN_IV Compute and save the linear element voltages and currents
(for measurements)
123 AWRHB_COMP_OP_PNT Compute and save the device operating point info (for
measurements)
124 AWRHB_COMP_OP_TD Compute and save the time domain device operating point
info (for measurements)
125 AWRHB_COMP_QCG Compute and save the nonlinear charge, capacitance and
conductance for the controlled sources within the nonlinear
elements
126 AWRHB_MAX_TIME_PNTS Limits the number of time points that can be displayed for
harmonic balance results
127 AWRHB_DIAGNOSE Run internal solver diagnostics
128 AWRHB_PROFILE Automatically profile the algorithm performance
129 AWRHB_HIDDEN_BRANCHES Compute and save the nonlinear element voltages and
currents for hidden branches within a nonlinear element

2140 NI AWR Design Environment


Schematics

Number Name Description


130 AWRTRAN_USE_HB_SETTINGS Use the harmonic balance settings to determine the stop
time for transient analysis
131 AWRTRAN_PERIODS Define the stop time as a multiple of the period defined by
the harmonic balance settings
132 AWRTRAN_START_TIME Start time used to define the beginning of data collection
for transient analysis
133 AWRTRAN_STOP_TIME Stop time used for transient analysis
134 AWRTRAN_STEP Step time used for transient analysis results
135 AWRTRAN_TIME_OFFSET Offsets the time value used to display the time domain
waveform. Set this equal to 'Start time' to make the wave
form display as starting from T = 0
136 AWRTRAN_SAVE_CURRENTS Specify the types of currents that are saved in the results of
the transient simulation
137 AWRTRAN_SAVE_VOLTAGES_EX Specify the types of voltages that are saved in the results of
the transient simulation
138 AWRTRAN_SHOW_LAST2PERIODS Only show the last two periods of the results (can use for
easier comparison with harmonic balance)
139 AWRTRAN_USE_DELAY_FOR_ANGLE Helps transient simulations to reach steady state faster. If
selected, the sine wave sources whose value at zero time is
not zero will stay constant at zero value until their value
becomes zero again.
140 AWRTRAN_TX_MIN_LINE_LEN Transmission lines with a length less than this factor of
lambda will get approximated as a lumped model
141 AWRTRAN_TX_MAX_FREQ Maximum frequency to use for table generation
142 AWRTRAN_TX_NUMB_FREQ Number of frequency points used for table generation
143 AWRTRAN_TX_LOG_GRID By default a linear frequency grid will be used, this option
allows for a logarithmic grid
144 LinearSolveType Specify the type of matrix solver to use for solving the linear
circuit simulation
145 UseIncrementalSolve Use a fast hierarchical incremental solver (faster with tuning
and optimization)
146 AWRLIN_SOLVE_FLAT Solve the linear circuit with hierarchy flattened (global
problem is solved in a single matrix)
147 AWRLIN_SOLVE_NOISE Compute the noise solution for the circuit
148 AWRLIN_MIN_SERIES_RES_EXP The value X entered will define the minimum source series
resistance as 1eX
149 AWRLIN_MIN_NODE_COND_EXP The value X entered will define the minimum node
conductance as 1eX
150 AWRLIN_ADD_COND_TO_ALL Always add the minimum node conductance defined above
to all nodes to prevent singularities

API Scripting Guide 2141


Schematics

Number Name Description


151 AWRLIN_ADD_COND_TO_SING Only add the minimum node conductance if a singularity
is detected (slower than always adding a conductance when
there is a singularity)
152 Spice.Options Option statement that is added to the HSPICE netlist. This
option will automatically update when any option below
that defines an HSPICE option is changed. You can also
type or paste in HSPICE options directly into this field, and
the corresponding options below will be automatically
updated.
153 Spice.ABSH Absolute accuracy of the currents in the circuit. A value of
zero will use the internal HSPICE default
154 Spice.ABSV Absolute accuracy of the voltages in the circuit. A value of
zero will use the internal HSPICE default
155 Spice.CHGTOL Absolute accuracy of the charges in the circuit. A value of
zero will use the internal HSPICE default
156 Spice.RELH Relative accuracy of the currents in the circuit. This option
is only used if the value of the 'Absolute current error'
control option is greater than zero
157 Spice.RELV Relative accuracy of the voltages in the circuit. A value of
zero will use the internal HSPICE default
158 Spice.RELQ Relative accuracy of the charges in the circuit. A value of
zero will use the internal HSPICE default. Only used with
LVLTIM = 2
159 Spice.ABSMOS Absolute accuracy of the currents in the MOSFETs.
160 Spice.ABSVDC Minimum voltage for DC and Transient analysis
161 Spice.RELMOS Relative accuracy of the currents in the MOSFETs.
162 Spice.RELVDC Relative voltage error tolerance from iteration to iteration
163 Spice.TRTOL Local truncation error for timestep algorithm
164 Spice.CPTIME Maximum CPU time for simulation (seconds)
165 Spice.DELMAX Maximum value for delta of internal timestep (default value
depends on circuit)
166 Spice.DI Maximum current change between iterations, through
voltage sources and inductors, if ABSH > 0
167 Spice.ITL1 Maximum DC iteration limit
168 Spice.ITL2 Maximum DC transfer curve iteration limit
169 Spice.ITL4 Maximum number of iterations per time point. Smaller step
is used if this is exceeded
170 Spice.MAXAMP Maximum current through voltage sources and inductors
(0=infinite)
171 Spice.RESMIN Min resistance for all resistors, including parasitic and
inductive

2142 NI AWR Design Environment


Schematics

Number Name Description


172 Spice.ACCURATE Sets several options to improve accuracy and time domain
resolution
173 Spice.CONVERGE Chooses convergence algorithm, tries each in turn by default
174 Spice.CSHUNT Capacitance added from each node to ground
175 Spice.DCSTEP Adds an extra conductance parallel to capacitors present in
the netlist. For example, if DCSTEP=0.1, a conductance of
0.1x10e-12 Sm is added in parallel to the 1 pF capacitor
176 Spice.FAST Sets several options to improve speed at cost of time domain
resolution
177 Spice.GMIN Minimum conductance in transient analysis
178 Spice.GMINDC Parallel conductance for PN junctions and between
MOSFET nodes for DC convergence
179 Spice.GSHUNT Conductance added between each node and ground
180 Spice.KCLTEST Activates Kirchoff's Current Law & sets options for accuracy
at cost of speed
181 Spice.METHOD Allows you to choose trapezoidal (TRAP, default), or the
Gear method when integrating the system of ordinary
differential equations. The Gear method is utilized if
parasitic numerical oscillations develop
182 Spice.ACCT Include accounting and runtime statistics
183 Spice.BRIEF Exclude input circuit information
184 Spice.CAPTAB Print a table of single-plate node capacitance for some
devices at each operating point
185 Spice.DIAGNOSTIC Log occurrence of negative model conductances
186 Spice.LIST Include element summary listing of input circuit
187 Spice.NODE Include node cross reference table
188 Spice.NOMOD Exclude model parameters
189 Spice.NOPAGE Exclude page ejects for title headings
190 Spice.NOWARN Suppress warning messages
191 Spice.OPTS Include settings for all control options
192 Spice.VFLOOR Lower limit for printed voltages; smaller voltages are printed
as 0
193 Spice.WARNLIMIT Limit number of times certain warnings appear in output
listing
194 Spice.CO Number of characters per line in the .lis file
195 Spice.INGOLD Numerical format(1=Engineering, 2=G format, 3=Sci.
notation)
196 Spice.LENNAM Maximum length of names in operating point analysis report
197 Spice.NUMDGT Number of significant digits for output variable values
198 Spice.PATHNUM Hierarchical path numbers for subcircuits, instead of names

API Scripting Guide 2143


Subcircuits

Number Name Description


199 Spice.Preamble Text to add at the beginning of the netlist
200 Spice.Postamble Text to add at the end of the netlist
201 Spice.SaveResults With this option checked the Hspice related files will be
saved in a subdirectory of the project location
202 Spice.LoadPreviousBias Use bias data from previous simulation as initial guess
203 Spice.UseExistingResultsFile With this option checked the existing results file is used
without running the simulation
204 Spice.UseExistingNetListFile Use existing netlist file (not recommended)
205 AWRMOD_SPICE_LEVEL Use to control how distributed models are mapped to time
domain equivalent models
206 AWRMOD_MODEL_VERS Use to specify that an older version of a model should be
used

Subcircuits
A collection of MWOffice Element objects consisting of only the schematic subcircuits

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Element Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Element

Syntax: Function Add(SubcircuitName As String, x As Long, y As Long, [RotationAngle As Long = 0], [Flipped As
Boolean = 0], [Symbol As String = ""], [GndType As mwSubcktGroundType = 0]) As Element

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

2144 NI AWR Design Environment


Subsystems

Subsystems
A collection of MWOffice Element objects consisting of only the system diagram subsystems.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Element Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: HRESULT

Syntax: Function Add(SubSystemName As String, x As Long, y As Long, [RotationAngle As Long = 0], [Flipped As
Boolean = 0], [Symbol As String = ""], [GndType As mwSubcktGroundType = 0]) As Element

Remove

Description: Removes a specific member from a collection.

Returns: HRESULT

Syntax: Function Remove(Index) As Boolean

Ports
A collection of MWOffice Element objects consisting of only the schematic or system diagram ports

Click to see examples

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Element Returns a specific item of a Collection object either by
position or by key.

ElectricalNets
A collection of MWOffice Element objects consisting of only the schematic electrical nets

API Scripting Guide 2145


NamedConnectors

Click to see examples

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Element Returns a specific item of a Collection object either by
position or by key.

NamedConnectors
A collection of MWOffice Element objects consisting of only the schematic named connectors

Click to see examples

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Element Returns a specific item of a Collection object either by
position or by key.

SymbolNode
An MWOffice SymbolNode object.

Properties

Name Data Type Description


LabelOffset Size Returns the label offset relative to the SymbolNode position.
LabelText String Returns/sets the label text associated with the SymbolNode.
LabelVisible Boolean Returns a value that specifies if the symbol node label is
visible
x Long Returns the X value of a SymbolNode object position.
y Long Returns the Y value of a SymbolNode object position.

SymbolNodes
A collection of MWOffice SymbolNode objects.

2146 NI AWR Design Environment


SymbolShape

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item SymbolNode Returns a specific item of a Collection object either by
position or by key.

SymbolShape
An MWOffice SymbolShape object.

Properties

Name Data Type Description


Attributes Attributes Returns a reference to a collection of Attribute objects.
Boundary Boundary Returns a reference to a Boundary object.
Points Points Returns a reference to a collection of Point objects.
Type mwSymbolShapeType Returns a value that specifies the type of the SymbolShape
object.

SymbolShapes
A collection of MWOffice SymbolShape objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item SymbolShape Returns a specific item of a Collection object either by
position or by key.

SymbolRecord
An MWOffice SymbolRecord object.

Properties

Name Data Type Description


FirstNodePlacementOrigin Boolean Returns/Sets if the symbol should be created such that the
first node is offset to the origin and all shapes are created
relative to that for placement.
NodeLabelFontHeight Long Returns/Sets the height of the node label font.

API Scripting Guide 2147


SymbolRecord

Name Data Type Description


Nodes SymbolNodes Returns a reference to a collection of SymbolNodes objects.
SelectMode mwSymbolSelectMode Returns/Sets a value indicating the selection mode for this
Symbol object.
Shapes SymbolShapes Returns a reference to a collection of SymbolShape objects.

Methods
AddArc

Description: Adds a symbol arc shape to the SymbolRecord object.

Returns: SymbolShape

Syntax: Function AddArc(Left As Long, Top As Long, Right As Long, Bottom As Long, xStart As Long, yStart As
Long, xEnd As Long, yEnd As Long) As SymbolShape

AddEllipse

Description: Adds an symbol ellipse shape to the SymbolRecord object.

Returns: SymbolShape

Syntax: Function AddEllipse(Left As Long, Top As Long, Right As Long, Bottom As Long) As SymbolShape

AddLine

Description: Adds a line shape to the to the SymbolRecord object.

Returns: SymbolShape

Syntax: Function AddLine(x1 As Long, y1 As Long, x2 As Long, y2 As Long) As SymbolShape

AddMetaText

Description: Adds an embedded text string shape to the SymbolRecord object.

Returns: SymbolShape

Syntax: Function AddMetaText(Left As Long, Top As Long, Right As Long, Bottom As Long, Text As String) As
SymbolShape

AddNode

Description: Adds a symbol connection node to the SymbolRecord object.

Returns: SymbolNode

Syntax: Function AddNode(x As Long, y As Long, TextDx As Long, TextDy As Long, TextVisible As Boolean) As
SymbolNode

2148 NI AWR Design Environment


Symbol

AddNode2

Description: Adds a symbol connection node with label text to the SymbolRecord object.

Returns: SymbolNode

Syntax: Function AddNode2(x As Long, y As Long, Text As String, TextDx As Long, TextDy As Long, TextVisible
As Boolean) As SymbolNode

AddPolygon

Description: Adds a symbol polygon shape to the SymbolRecord object.

Returns: SymbolShape

Syntax: Function AddPolygon(XYPoints As SafeArray) As SymbolShape

AddPolyline

Description: Adds a polyline shape to the SymbolRecord object.

Returns: SymbolShape

Syntax: Function AddPolyline(XYPoints As SafeArray) As SymbolShape

AddText

Description: Adds a text string shape to the SymbolRecord object.

Returns: SymbolShape

Syntax: Function AddText(Left As Long, Top As Long, Right As Long, Bottom As Long, Text As String) As
SymbolShape

AddText2

Description: Adds a text string shape to the SymbolRecord object.

Returns: SymbolShape

Syntax: Function AddText2(Left As Long, Top As Long, Height As Long, CCWRotation As Long, Text As String) As
SymbolShape

Symbol
An MWOffice Symbol object.

Click to see examples

Properties

Name Data Type Description


Boundary Boundary Returns a reference to a Boundary object.

API Scripting Guide 2149


Symbols

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
Nodes SymbolNodes Returns a reference to a collection of SymbolNodes objects.
ProjectSymbol Boolean Returns if the symbol is a project or system symbol
RecordCount Long Returns the number of records of a Symbol object.
RecordData Variant Returns/sets the record data of a Symbol object.
Referenced Boolean Returns if a symbol is referenced by a schematic element.
SelectMode mwSymbolSelectMode Returns/Sets a value indicating the selection mode for this
Symbol object.
Shapes SymbolShapes Returns a reference to a collection of SymbolShape objects.
SymbolType mwSymbolType Returns the type of the symbol like project or system type.

Methods
None

Symbols
A collection of MWOffice Symbol objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Symbol Returns a specific item of a Collection object either by
position or by key.

Methods
CreateSymbol

Description: Returns a reference to a Symbol object.

Returns: Symbol

Syntax: Function CreateSymbol(Name As String, SymbolRecord As SymbolRecord) As Symbol

CreateSymbolRecord

Description: Returns a reference to a SymbolRecord object.

Returns: SymbolRecord

Syntax: Function CreateSymbolRecord() As SymbolRecord

2150 NI AWR Design Environment


Symbols

Export

Description: Exports a design document file from MWOffice.

Returns: Boolean

Syntax: Function Export(SymbolFilePath As String) As Boolean

GetDefaultSymbol

Description: Returns a reference to a Symbol object.

Returns: Symbol

Syntax: Function GetDefaultSymbol(NumberNodes As Long) As Symbol

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Import

Description: Adds a Netlist object to the collection from a file and returns a reference to the created object.

Returns: Boolean

Syntax: Function Import(SymbolFilePath As String) As Boolean

ImportSystemFile

Description: Imports a symbol file into the system symbols collection. These symbols are not saved with the project.

Returns: Boolean

Syntax: Function ImportSystemFile(SymbolFilePath As String) As Boolean

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

SaveToFile

Description: Saves the project symbols to a symbol file.

Returns: Void

Syntax: Sub SaveToFile(Filename As String)

API Scripting Guide 2151


Unit

Unit
An MWOffice Unit object.

Properties

Name Data Type Description


BaseUnitString String Returns the units string for the base of this unit type.
Description String Returns the full description for a unit type.
MultType mwUnitMultType Returns/sets a value which specifies the multiplier type of
a Unit object.
MultValue Double Returns the multiplier of a Unit object.
Type mwUnitType Returns a value which specifies the unit type of a Unit
object.
UnitString String Returns the units string identifier.

Units
A collection of MWOffice Unit objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Unit Returns a specific item of a Collection object either by
position or by key.

SweepValue
A MWOffice SweepVariable object.

Properties

Name Data Type Description


ValueAsDouble Double Returns a numeric value for the MWOffice SweepValue
object.
ValueAsString String Returns a string value for the MWOffice SweepValue object.

SweepValues
A collection of MWOffice SweepValue objects.

2152 NI AWR Design Environment


SweepVariable

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item SweepValue Returns a specific item of a Collection object either by
position or by key.

SweepVariable
A MWOffice SweepVariable object.

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
Type mwUnitType Defines the unit type of the Sweep varible object.
Values SweepValues Returns a reference to a MWOFfice SweepValues collection.

SweepVariables
A collection of MWOffice SweepVariable objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item SweepVariable Returns a specific item of a Collection object either by
position or by key.

Window
An MWOffice Window object.

Properties

Name Data Type Description


Active Boolean Returns the active state of a Window object.
Caption String Returns/Sets the caption of an object.
Floating Boolean Returns/sets the floating state of the Window object.
Height Long Returns/sets the height of a Window object.
Left Long Returns/sets the left edge of a Window object.

API Scripting Guide 2153


Windows

Name Data Type Description


Next Window Returns a reference to a Window object.
Previous Window Returns a reference to a Window object.
Top Long Returns/sets the top edge of a Window object.
Type mwWindowType Returns the content type of a Window object.
Width Long Returns/sets the width of a Window object.
WindowState mwWindowState Returns the screen state of a Window object.

Methods
Activate

Description: Activates the Window associated with the object.

Returns: Void

Syntax: Sub Activate()

Center

Description: Centers the window in the MDI child region of the main frame window if applicable.

Returns: Boolean

Syntax: Function Center() As Boolean

Close

Description: Closes the Window associated with the object.

Returns: Void

Syntax: Sub Close()

ViewAll

Description: Updates the window to display all objects.

Returns: Void

Syntax: Sub ViewAll()

Windows
A collection of MWOffice Window objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.

2154 NI AWR Design Environment


WireNet

Name Data Type Description


Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Window Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Window

Syntax: Function Add(hWnd As Long) As Window

Cascade

Description: Cascades all top-level windows.

Returns: Void

Syntax: Sub Cascade()

Tile

Description: Tiles all top-level windows in a horizontal or vertical orientation.

Returns: Void

Syntax: Sub Tile(dir As mwWindowTileDirection)

WireNet
An MWOffice WireNet object.

Click to see examples

Properties

Name Data Type Description


ElectNetName String Returns a reference to an Element object.
NetHighlight Boolean Returns if the wire net is currently highlighted.
NetHighlightColor Long Returns the highlight color for the net.
Wires Wires Returns a reference to a collection of WireSegment objects.

Methods
None

API Scripting Guide 2155


WireSegment

WireSegment
An MWOffice WireSegment object.

Properties

Name Data Type Description


BusNetName BusNetName Returns a reference to a MWOffice BusNetName object.
HasBusNetName Boolean Returns a value indicating if the WireSegment object has a
BusNetName object associated with it.
Nodes Nodes Returns a reference to a collection of Node objects.
NumConnected1 Long Returns a count of the number of connections to the end of
the WireSegment object.
NumConnected2 Long Returns a count of the number of connections to the end of
the WireSegment object.
ParentNet WireNet Returns a reference to a MWOffice WireNet object.
Selected Boolean Returns/sets a value which specifies if the object is selected.
x1 Long Returns the X coordinate of the starting point of a
WireSegment object.
x2 Long Returns the X coordinate of the ending point of a
WireSegment object.
y1 Long Returns the Y coordinate of the starting point of a
WireSegment object.
y2 Long Returns the Y coordinate of the ending point of a
WireSegment object.

Methods
AddBusNetName

Description: Adds a BusNetName object to the WiresegmentObject and returns a reference to the newly added
BusNetName object.

Returns: BusNetName

Syntax: Function AddBusNetName(Name As String, x As Long, y As Long, [Priority As Long = 0], [Flags As Long =
0]) As BusNetName

Delete

Description: Removes the object.

Returns: Boolean

Syntax: Function Delete() As Boolean

2156 NI AWR Design Environment


Wires

RemoveBusNetName

Description: Removes a BusNetName object from the WireSegment object.

Returns: Boolean

Syntax: Function RemoveBusNetName() As Boolean

Wires
A collection of MWOffice WireSegment objects.

Click to see examples

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item WireSegment Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: WireSegment

Syntax: Function Add(x1 As Long, y1 As Long, x2 As Long, y2 As Long) As WireSegment

AddBusNet

Description: Adds an object to the collection and returns a reference to the created object.

Returns: WireSegment

Syntax: Function AddBusNet(x1 As Long, y1 As Long, x2 As Long, y2 As Long, NetName As String, xName As Long,
yName As Long, [Priority As Long = 0], [Flags As Long = 0]) As WireSegment

Cleanup

Description: Performs a cleanup operation on the collection object.

Returns: Boolean

Syntax: Function Cleanup() As Boolean

Remove

Description: Removes a specific member from a collection.

API Scripting Guide 2157


SelectedWires

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

SelectedWires
A collection of MWOffice SelectedWire objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Item WireSegment Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Boolean

Syntax: Function Add(WireSegment As WireSegment) As Boolean

AddAll

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Boolean

Syntax: Function AddAll() As Boolean

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

2158 NI AWR Design Environment


YieldGoals

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

YieldGoals
A collection of MWOffice Goal objects.

Click to see examples

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Goal Returns a specific item of a Collection object either by
position or by key.
TotalCost Double Returns the total cost of a collection of Goal object.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Goal

Syntax: Function Add(CircuitName As String, MeasName As String, GoalType As mwYieldGoalType, xStart As


Double, xStop As Double, xUnit As mwUnitType, yStart As Double, yStop As Double, yUnit As mwUnitType) As Goal

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

Option
An MWOffice Option object.

API Scripting Guide 2159


Options

Properties

Name Data Type Description


DataType Long Returns the data type of the Option object.
DefaultValue Variant Returns the default value of the Option object.
Description String Returns a description of the Option object.
Id Long Returns the ID of the Option object.
Name String Returns/Sets the name used in code to identify an object.
Value Variant Returns/Set the value of a Option object.

Options
A collection of MWOffice Option objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Option Returns a specific item of a Collection object either by
position or by key.

SystemDiagram
An MWOffice SystemDiagram object.

Click to see examples

Properties

Name Data Type Description


Boundary Boundary Returns a reference to a Boundary object.
CanPaste Boolean Returns a value that determines the clipboard contents can
be pasted to the object.
Changed Boolean Returns/Sets a value that indicates if the object has changed
and needs to be saved or resimulated.
DrawingShapes DrawingShapes Returns a reference to a collection of DrawingShape objects.
Elements Elements Returns a reference to a collection of Element objects.
Embedded Boolean Returns if the SystemDiagram is embedded or linked
externally.
EmbeddedDesigns EmbeddedDesigns Returns a reference to a collection of EmbeddedDesign
objects.
Equations Equations Returns a reference to a collection of Equation objects.

2160 NI AWR Design Environment


SystemDiagram

Name Data Type Description


FilePath String Returns the file path for this SystemDiagram object.
GridVisible Boolean Returns/sets a value that specifies if the snap grid is visible
for the SystemDiagram.
LockLevel mwDiagramLockLevel Returns a value that specifies the lock level of the schematic
diagram
LockUpdates Boolean property LockUpdates
Name String Returns/Sets the name used in code to identify an object.
Options Options Returns a reference to a collection of Option objects.
Orthogonal Boolean Returns/sets a value that specifies if drawing should be only
orthogonal for the SystemDiagram.
Ports Ports Returns a reference to a MWOffice Element collection
consisting of only the system diagram port elements
Properties Properties Returns a reference to a collection of Property objects.
RFBFrequencyOffsets Frequencies A collection of the MWOffice frequency objects for the RF
Budget Analysis frequency offsets.
SelectedElements SelectedElements Returns a reference to a collection of MWOffice
SelectedElement objects.
SelectedWires SelectedWires Returns a reference to a collection of MWOffice
SelectedWire objects.
SimulationDirty Boolean Returns if the current simulation state is dirty for the
SystemDiagram object.
SimulationState Long Returns the current simulation state for the SystemDiagram
object.
SnapToGrid Boolean Returns/sets a value that specifies if grid snap is enabled
for the SystemDiagram.
Subsystems Subsystems Returns a reference to a MWOffice Element collection
consisting of only the system diagram subsystem elements
SweepVariables SweepVariables Returns a reference to a MWOffice SweepVariables
collection.
UseProjectOptions Boolean Returns/sets a value which specifies if the global project
options should be used.
UseProjectRFBFrequencyOffsets Boolean Returns/sets a value which specifies if the global RFB
frequency offsets should be used for analysis.
Views Views Returns a reference to a MWOffive Views collection.
Windows Windows Returns a reference to a collection of Window objects.
Wires Wires Returns a reference to a collection of WireSegment objects.
XGridSpacing Long Returns/sets a value that specifies the grid spacing along
the X coordinate direction.
YGridSpacing Long Returns/sets a value that specifies the grid spacing along
the Y coordinate direction.

API Scripting Guide 2161


SystemDiagram

Methods
Activate

Description: Activates the objects.

Returns: Void

Syntax: Sub Activate()

CopyToClipboard

Description: Copies the object to the system clipboard.

Returns: Void

Syntax: Sub CopyToClipboard()

CopyViewToClipboard

Description: Copies the object to the system clipboard.

Returns: Boolean

Syntax: Function CopyViewToClipboard() As Boolean

Export

Description: Exports a design document file from MWOffice.

Returns: Void

Syntax: Sub Export(FilePath As String, [format As mwSystemExportFormat = 0])

InvokeCommand

Description: Invoke a menu command by specifying the name for the command. Arguments must be supplied for any
required input.

Returns: Void

Syntax: Sub InvokeCommand(CommandName As String, [Arguments], [pRet])

LockDiagram

Description: Changes the lock level of the system diagram to the given lock level

Returns: Boolean

Syntax: Function LockDiagram(NewLevel As mwDiagramLockLevel, [Password As String = ""]) As Boolean

NewWindow

Description: Displays the object in new window.

2162 NI AWR Design Environment


SystemDiagram

Returns: Window

Syntax: Function NewWindow([WindowType As mwWindowType = 12]) As Window

Paste

Description: Pastes the system clipboard to the object.

Returns: Boolean

Syntax: Function Paste(x As Long, y As Long, [CCWRotation As Long = 0], [Flipped As Boolean = 0]) As Boolean

PrintOut

Description: Sends the object to the current printer.

Returns: Void

Syntax: Sub PrintOut()

PrintView

Description: Sends the object to the current printer.

Returns: Boolean

Syntax: Function PrintView() As Boolean

SetupConnectivity

Description: method SetupConnectivity

Returns: Void

Syntax: Sub SetupConnectivity()

StartCommand

Description: Start a menu command by specifying the name for the command. The user will need to complete any
required input.

Returns: Void

Syntax: Sub StartCommand(CommandName As String, [pRet])

Options

Number Name Description


1 SampleRate Returns/sets the system data sample rate.
2 DataBlockSize Returns/sets the system sample block size.
3 StopTime Returns/sets the system stop time.
4 TimeFrame Returns/sets the system time frame

API Scripting Guide 2163


SystemDiagram

Number Name Description


5 OutputBufferSize Returns/sets the maximum system output buffer size.
6 DefaultImpedance Returns/sets the system default impedance level.
7 SysIncludeRFMismatch Model impedance mismatch effects, RF blocks only.
8 SysAmbientTemp Ambient system temperature.
9 SysAnnotationSigDigits Maximum significant digits for annotations.
10 SysRFNoiseMode Default RF block noise modeling.
11 SysMultithreadRFB Enables multithreading support in RF Budget Analysis
simulations
12 SysExtrapolateCoSimFreqs Extrapolate Y matrices for frequencies outside co-simulation
project frequencies
13 SysMultithreadRFI Enables multithreading support in RF Inspector simulations
14 SysMultithreadTDBlock Enables block level multithreading support in VSS Time
Domain simulations
15 SysMultithreadTDTopLevel Enables system diagram level multithreading support in
VSS Time Domain simulations
16 SamplesPerMeasurement Returns/sets the maximum number of samples in a
measurement.
17 NormalizeToTimeUnits Returns/sets if the waveform display should be normalized
to time frames.
18 WaveFormsStartFromZero Returns/sets if the waveforms should be displayed from
time equals zero.
19 AlignWaveFormsToData Returns/sets if the waveforms should be aligned so it looks
like there is no time delay.
20 SchematicSymbolName Returns sets the default symbol name used when the
document is placed as a subcircuit.
21 SpecGlobalEquations Specify the global definition document to use as the global
equations for this document
22 VSS_SamplingFreq Default time domain sampling frequency or overall
bandwidth (frequency span) to simulate over (_SMPFRQ).
For TD frequency graphs the default x-axis has this
frequency span, centered about the center frequency: from
fc-_SMPFRQ/2 to fc+_SMPFRQ/2
23 VSS_OversamplingRate Default oversampling rate or samples per symbol, this
should be at least 2, preferrably larger (_SMPSYM)
24 VSS_BlockSize Default number of symbols to generate during each source
block visit (_BLKSZ)
25 VSS_UseSimStopTime Enable use of Simulation Stop Time
26 VSS_SimStopTime If enabled, stop the simulation after this simulation time has
been reached
27 VSS_MaxNodeDataAccumulation Threshold for output node buffer backlog

2164 NI AWR Design Environment


SystemDiagram

Number Name Description


28 VSS_MismatchModeling Impedance mismatch modeling between RF blocks is most
accurate in RFB/RFI simulations, less so in TD simulations.
29 VSS_Impedance Default characteristic impedance (_Z0)
30 VSS_AmbientTemperature Ambient system temperature for noise (_TAMB)
31 VSS_AnnotationSigDigits Maximum significant digits for annotations (1 to 16)
32 VSS_RF_NoiseModeling Specifies noise modeling when an RF block's NOISE
parameter is 'Auto'
33 VSS_DirectUpConversionGainType Specifies how a mixer's conversion gain parameter is
interpreted when upconverting from baseband
34 VSS_CosimS11UseRFB Specifies whether amplifier co-simulations use S11 from
the co-simulation for RF Budget Analysis simulations
35 VSS_CosimS11UseRFI Specifies whether amplifier co-simulations use S11 from
the co-simulation for RF Inspector simulations
36 VSS_CosimS11UseTD Specifies whether amplifier co-simulations use S11 from
the co-simulation for Time Domain simulations
37 VSS_NonlinearSaturationModel Specifies how upgrades to the nonlinear amplifier and mixer
saturation models are to be applied
38 VSS_RFB_UseMultiCore Specifies if multi-core processing is used for RF Budget
Analysis simulations
39 VSS_RFI_UseMultiCore Specifies if multi-core processing is used for RF Inspectors
simulations
40 VSS_TD_Block_UseMultiCore Specifies if multi-core processing is used at the block
processing level for Time Domain simulations
41 VSS_ExtrapolateCoSimFreqs Extrapolate cosimulation frequencies outside the circuit's
document frequency range
42 VSS_TD_TopLevel_UseMultiCore Specifies if multi-core processing is used at the top system
diagram level for Time Domain simulations
43 VSS_MaxMeasBufferSize Maximum number of samples for measurement buffers
44 VSS_NormalizeWaveformsToSymbols Display waveform x-axis in symbols
45 VSS_WaveformsXAxisFrom0 Display waveform x-axis from x=0
46 VSS_AlignToDataStart Display signals aligned to start of data
47 RFI_UseHarmonicBand Determines if the Harmonic Band setting is used.
48 RFI_HarmonicBand The default maximum harmonic band relative to the center
frequency at which nonlinear RF blocks will generate IM
and harmonic products.
49 RFI_UseFreqAboveFc Determines if the Frequency Above Fc setting is used.
50 RFI_FreqAboveFc By default nonlinear RF blocks will only generate frequency
components whose frequencies are <= the center frequency
plus this amount.
51 RFI_UseFreqBelowFc Determines if the Frequency Below Fc setting is used.

API Scripting Guide 2165


SystemDiagram

Number Name Description


52 RFI_FreqBelowFc By default nonlinear RF blocks will only generate frequency
components whose frequencies are >= the center frequency
minus this amount.
53 RFI_UseMaxFreq Determines if the Maximum Frequency setting is used.
54 RFI_MaxFreq By default nonlinear RF blocks will only generate frequency
components whose frequencies are <= this frequency.
55 RFI_UseMinFreq Determines if the Minimum Frequency setting is used.
56 RFI_MinFreq By default nonlinear RF blocks will only generate frequency
components whose frequencies are >= this frequency.
57 RFI_UseDBBelowNoise Determines if the dB Below Noise setting is used for
nonlinear blocks.
58 RFI_UseDBBelowNoiseForLinearBlocks Determines if the dB Below Noise setting is used for linear
blocks.
59 RFI_DBBelowNoise RF blocks will only generate frequency components whose
PSD in dBm/Hz is >= the ambient noise (_TAMB) in
dBm/Hz less this amount.
60 RFI_UseMinDBm_Hz Determines if the Minimum dBm/Hz setting is used.
61 RFI_MinDBm_Hz RF blocks will only generate frequency components whose
PSD in dBm/Hz is >= this amount.
62 RFI_UseMinDBV_sqrtHz Determines if the Minimum dBV/sqrt(Hz) setting is used.
63 RFI_MinDBV_sqrtHz RF blocks will only generate frequency components whose
VSD in dBV/sqrt(Hz) is >= this amount.
64 RFI_UseMaxHarmonic Determines if the Maximum Harmonic Generated setting
is used.
65 RFI_MaxHarmonic Maximum harmonic order of input components generated
by RF nonlinear blocks.
66 RFI_UseMaxComponents Determines if the Maximum Components Generated setting
is used.
67 RFI_MaxComponents Maximum number of frequency components output by a
RF nonlinear block. The components output are the ones
with the highest power level.
68 RFI_UseMaxContributionsTracked Determines if the Maximum Contributions Tracked setting
is used.
69 RFI_MaxContributionsTracked Maximum number of contributions to each frequency
component generated to be tracked. This limits the amount
of information per component the simulator must track.
Lower power contributions are discarded first.
70 RFI_AmpsSuppressDC If checked, RF nonlinear amplifiers will by default not
generate DC on their output.
71 RFI_MixersSuppressDC If checked, RF nonlinear mixers will by default not generate
DC on their output.

2166 NI AWR Design Environment


SystemDiagrams

Number Name Description


72 RFA_MaxIterations Maximum number of nonlinear solution iterations per, if
present, feedback control loop per sweep
73 RFA_MinChangeInDB The nonlinear iterative solution will be considered
converged if the maximum change in all voltage magnitudes
in dB is <= this amount.
74 RFA_MaxControlLoopIterations Maximum number of feedback control loop solution
iterations per sweep
75 VSS_RBW_NFFT_Use Determines whether the RBW or NFFT setting is used by
default in spectrum based measurements. If 'Auto' the
measurements will by default determine the settings from
the signal characteristics.
76 VSS_RBW The default resolution bandwidth used by spectrum based
measurements, only used if Use RBW/NFFT is set to 'RBW'.
77 VSS_NFFT The default number of FFT bins used by spectrum based
measurements, only used if Use RBW/NFFT is set to
'NFFT'.
78 VSS_VBW_NAVG_Use Determines whether the VBW or NAVG setting is used by
default in spectrum based measurements. If 'Auto' the
measurements will by default determine the settings from
the signal characteristics.
79 VSS_VBW The default video bandwidth approximation used by
spectrum based measurements, only used if Use
VBW/NAVG is set to 'VBW'.
80 VSS_NAVG The default number of averages used by spectrum based
measurements, only used if Use VBW/NAVG is set to
'NAVG'.

SystemDiagrams
A collection of MWOffice SystemDiagram objects.

Properties

Name Data Type Description


ActiveSystemDiagram SystemDiagram Returns the active system diagram of a Project object.
Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item SystemDiagram Returns a specific item of a Collection object either by
position or by key.
Options Options Returns a reference to a collection of Option objects.
RFBFrequencyOffsets Frequencies A collection of the MWOffice frequency objects for the RF
Budget Analysis frequency offsets.

API Scripting Guide 2167


SystemDiagrams

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: SystemDiagram

Syntax: Function Add(Name As String) As SystemDiagram

Copy

Description: Copies an object from another object collection into this object collection.

Returns: SystemDiagram

Syntax: Function Copy(Index, [NewName As String = ""]) As SystemDiagram

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Import

Description: Adds a Netlist object to the collection from a file and returns a reference to the created object.

Returns: SystemDiagram

Syntax: Function Import(Name As String, Filename As String) As SystemDiagram

LinkTo

Description: Adds a SystemDiagram object link to the collection from a file and returns a reference to the created object.

Returns: SystemDiagram

Syntax: Function LinkTo(Name As String, Filename As String) As SystemDiagram

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

Options

Number Name Description


1 SampleRate Returns/sets the system data sample rate.

2168 NI AWR Design Environment


SystemDiagrams

Number Name Description


2 DataBlockSize Returns/sets the system sample block size.
3 StopTime Returns/sets the system stop time.
4 TimeFrame Returns/sets the system time frame
5 OutputBufferSize Returns/sets the maximum system output buffer size.
6 DefaultImpedance Returns/sets the system default impedance level.
7 SysIncludeRFMismatch Model impedance mismatch effects, RF blocks only.
8 SysAmbientTemp Ambient system temperature.
9 SysAnnotationSigDigits Maximum significant digits for annotations.
10 SysRFNoiseMode Default RF block noise modeling.
11 SysMultithreadRFB Enables multithreading support in RF Budget Analysis
simulations
12 SysExtrapolateCoSimFreqs Extrapolate Y matrices for frequencies outside co-simulation
project frequencies
13 SysMultithreadRFI Enables multithreading support in RF Inspector simulations
14 SysMultithreadTDBlock Enables block level multithreading support in VSS Time
Domain simulations
15 SysMultithreadTDTopLevel Enables system diagram level multithreading support in
VSS Time Domain simulations
16 SamplesPerMeasurement Returns/sets the maximum number of samples in a
measurement.
17 NormalizeToTimeUnits Returns/sets if the waveform display should be normalized
to time frames.
18 WaveFormsStartFromZero Returns/sets if the waveforms should be displayed from
time equals zero.
19 AlignWaveFormsToData Returns/sets if the waveforms should be aligned so it looks
like there is no time delay.
20 VSS_SamplingFreq Default time domain sampling frequency or overall
bandwidth (frequency span) to simulate over (_SMPFRQ).
For TD frequency graphs the default x-axis has this
frequency span, centered about the center frequency: from
fc-_SMPFRQ/2 to fc+_SMPFRQ/2
21 VSS_OversamplingRate Default oversampling rate or samples per symbol, this
should be at least 2, preferrably larger (_SMPSYM)
22 VSS_BlockSize Default number of symbols to generate during each source
block visit (_BLKSZ)
23 VSS_UseSimStopTime Enable use of Simulation Stop Time
24 VSS_SimStopTime If enabled, stop the simulation after this simulation time has
been reached
25 VSS_MaxNodeDataAccumulation Threshold for output node buffer backlog
26 VSS_MismatchModeling Impedance mismatch modeling between RF blocks is most
accurate in RFB/RFI simulations, less so in TD simulations.

API Scripting Guide 2169


SystemDiagrams

Number Name Description


27 VSS_Impedance Default characteristic impedance (_Z0)
28 VSS_AmbientTemperature Ambient system temperature for noise (_TAMB)
29 VSS_AnnotationSigDigits Maximum significant digits for annotations (1 to 16)
30 VSS_RF_NoiseModeling Specifies noise modeling when an RF block's NOISE
parameter is 'Auto'
31 VSS_DirectUpConversionGainType Specifies how a mixer's conversion gain parameter is
interpreted when upconverting from baseband
32 VSS_CosimS11UseRFB Specifies whether amplifier co-simulations use S11 from
the co-simulation for RF Budget Analysis simulations
33 VSS_CosimS11UseRFI Specifies whether amplifier co-simulations use S11 from
the co-simulation for RF Inspector simulations
34 VSS_CosimS11UseTD Specifies whether amplifier co-simulations use S11 from
the co-simulation for Time Domain simulations
35 VSS_NonlinearSaturationModel Specifies how upgrades to the nonlinear amplifier and mixer
saturation models are to be applied
36 VSS_RFB_UseMultiCore Specifies if multi-core processing is used for RF Budget
Analysis simulations
37 VSS_RFI_UseMultiCore Specifies if multi-core processing is used for RF Inspectors
simulations
38 VSS_TD_Block_UseMultiCore Specifies if multi-core processing is used at the block
processing level for Time Domain simulations
39 VSS_ExtrapolateCoSimFreqs Extrapolate cosimulation frequencies outside the circuit's
document frequency range
40 VSS_TD_TopLevel_UseMultiCore Specifies if multi-core processing is used at the top system
diagram level for Time Domain simulations
41 VSS_MaxMeasBufferSize Maximum number of samples for measurement buffers
42 VSS_NormalizeWaveformsToSymbols Display waveform x-axis in symbols
43 VSS_WaveformsXAxisFrom0 Display waveform x-axis from x=0
44 VSS_AlignToDataStart Display signals aligned to start of data
45 RFI_UseHarmonicBand Determines if the Harmonic Band setting is used.
46 RFI_HarmonicBand The default maximum harmonic band relative to the center
frequency at which nonlinear RF blocks will generate IM
and harmonic products.
47 RFI_UseFreqAboveFc Determines if the Frequency Above Fc setting is used.
48 RFI_FreqAboveFc By default nonlinear RF blocks will only generate frequency
components whose frequencies are <= the center frequency
plus this amount.
49 RFI_UseFreqBelowFc Determines if the Frequency Below Fc setting is used.
50 RFI_FreqBelowFc By default nonlinear RF blocks will only generate frequency
components whose frequencies are >= the center frequency
minus this amount.

2170 NI AWR Design Environment


SystemDiagrams

Number Name Description


51 RFI_UseMaxFreq Determines if the Maximum Frequency setting is used.
52 RFI_MaxFreq By default nonlinear RF blocks will only generate frequency
components whose frequencies are <= this frequency.
53 RFI_UseMinFreq Determines if the Minimum Frequency setting is used.
54 RFI_MinFreq By default nonlinear RF blocks will only generate frequency
components whose frequencies are >= this frequency.
55 RFI_UseDBBelowNoise Determines if the dB Below Noise setting is used for
nonlinear blocks.
56 RFI_UseDBBelowNoiseForLinearBlocks Determines if the dB Below Noise setting is used for linear
blocks.
57 RFI_DBBelowNoise RF blocks will only generate frequency components whose
PSD in dBm/Hz is >= the ambient noise (_TAMB) in
dBm/Hz less this amount.
58 RFI_UseMinDBm_Hz Determines if the Minimum dBm/Hz setting is used.
59 RFI_MinDBm_Hz RF blocks will only generate frequency components whose
PSD in dBm/Hz is >= this amount.
60 RFI_UseMinDBV_sqrtHz Determines if the Minimum dBV/sqrt(Hz) setting is used.
61 RFI_MinDBV_sqrtHz RF blocks will only generate frequency components whose
VSD in dBV/sqrt(Hz) is >= this amount.
62 RFI_UseMaxHarmonic Determines if the Maximum Harmonic Generated setting
is used.
63 RFI_MaxHarmonic Maximum harmonic order of input components generated
by RF nonlinear blocks.
64 RFI_UseMaxComponents Determines if the Maximum Components Generated setting
is used.
65 RFI_MaxComponents Maximum number of frequency components output by a
RF nonlinear block. The components output are the ones
with the highest power level.
66 RFI_UseMaxContributionsTracked Determines if the Maximum Contributions Tracked setting
is used.
67 RFI_MaxContributionsTracked Maximum number of contributions to each frequency
component generated to be tracked. This limits the amount
of information per component the simulator must track.
Lower power contributions are discarded first.
68 RFI_AmpsSuppressDC If checked, RF nonlinear amplifiers will by default not
generate DC on their output.
69 RFI_MixersSuppressDC If checked, RF nonlinear mixers will by default not generate
DC on their output.
70 RFA_MaxIterations Maximum number of nonlinear solution iterations per, if
present, feedback control loop per sweep

API Scripting Guide 2171


DesignNote

Number Name Description


71 RFA_MinChangeInDB The nonlinear iterative solution will be considered
converged if the maximum change in all voltage magnitudes
in dB is <= this amount.
72 RFA_MaxControlLoopIterations Maximum number of feedback control loop solution
iterations per sweep
73 VSS_RBW_NFFT_Use Determines whether the RBW or NFFT setting is used by
default in spectrum based measurements. If 'Auto' the
measurements will by default determine the settings from
the signal characteristics.
74 VSS_RBW The default resolution bandwidth used by spectrum based
measurements, only used if Use RBW/NFFT is set to 'RBW'.
75 VSS_NFFT The default number of FFT bins used by spectrum based
measurements, only used if Use RBW/NFFT is set to
'NFFT'.
76 VSS_VBW_NAVG_Use Determines whether the VBW or NAVG setting is used by
default in spectrum based measurements. If 'Auto' the
measurements will by default determine the settings from
the signal characteristics.
77 VSS_VBW The default video bandwidth approximation used by
spectrum based measurements, only used if Use
VBW/NAVG is set to 'VBW'.
78 VSS_NAVG The default number of averages used by spectrum based
measurements, only used if Use VBW/NAVG is set to
'NAVG'.

DesignNote
An MWOffice DesignNote object.

Properties

Name Data Type Description


CanPaste Boolean Returns a value which indicates if the current clipboard
contents can be pasted into the DesignNote view.
Content String Returns the content of a DesignNote in Rich Text format.
Modified Boolean Returns/Sets a value which determines if the Design Note
Object has been modified.
Name String Returns the file name of the project not including the file's
path specification.
ReadOnly Boolean Returns a value which determines if the Design Note object
is read-only.
Windows Windows Returns a reference to a collection of Window objects.

2172 NI AWR Design Environment


DesignNote

Methods
Activate

Description: Activates the objects.

Returns: Void

Syntax: Sub Activate()

CopyToClipboard

Description: Copies the object to the system clipboard.

Returns: Void

Syntax: Sub CopyToClipboard()

Export

Description: Exports the DesignNote to a Rich Text file.

Returns: Void

Syntax: Sub Export(Path As String)

Import

Description: Imports a Rich Text File into the DesignNote object.

Returns: Void

Syntax: Sub Import(Path As String)

NewWindow

Description: Displays the object in new window.

Returns: Window

Syntax: Function NewWindow() As Window

Paste

Description: Pastes the current contents of the clipboard into the design note view.

Returns: Boolean

Syntax: Function Paste() As Boolean

PrintOut

Description: Sends the object to the current printer.

Returns: Void

API Scripting Guide 2173


DesignNotes

Syntax: Sub PrintOut()

DesignNotes
A collection of MWOffice DesignNote objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DesignNote Returns a specific item of a Collection object either by
position or by key.

Simulator
An MWOffice Simulator object.

Properties

Name Data Type Description


State mwSystemSimulatorState Returns a value indicating the current system simulator state

Methods
Analyze

Description: Invokes a circuit simulator analysis.

Returns: Void

Syntax: Sub Analyze()

AnalyzeOpenGraphs

Description: Simulates the open graphs.

Returns: Void

Syntax: Sub AnalyzeOpenGraphs()

Continue

Description: Steps a paused system simulation

Returns: Void

Syntax: Sub Continue()

2174 NI AWR Design Environment


Attribute

Pause

Description: Pauses the system simulator during an analysis.

Returns: Void

Syntax: Sub Pause()

RunStop

Description: Runs the system simulators if they are stopped, stops the system simulators if they are running

Returns: Void

Syntax: Sub RunStop()

Start

Description: Starts the system simulator to perform an analysis.

Returns: Void

Syntax: Sub Start()

Stop

Description: Stops the system simulator during an analysis.

Returns: Void

Syntax: Sub Stop()

Attribute
An MWOffice Attribute object.

Properties

Name Data Type Description


Name String Returns the name used in code to identify an object.
ReadOnly Boolean Returns a value which specifies if the Attribute is read-only.
Type Long Returns a value which specifies the type of an Attribute
object.
Value Variant Returns/sets the value of the Attribute object.
ValueAsString String Returns the attribute value as a string.

Attributes
A collection of MWOffice Attribute objects.

API Scripting Guide 2175


BoundaryModel

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Attribute Returns a specific item of a Collection object either by
position or by key.

BoundaryModel
An MWOffice BoundaryModel object.

Properties

Name Data Type Description


Type mwBoundaryModelType Returns a value which specifies the type of a
BoundaryModel object.

Boundary
An MWOffice Boundary object.

Click to see examples

Properties

Name Data Type Description


Bottom Double Returns the boundary bottom edge for an object.
Left Double Returns the boundary left edge for an object.
Right Double Returns the boundary right edge for an object.
Top Double Returns the boundary top edge for an object.

LayoutParameter
An MWOffice LayoutParameter object.

Properties

Name Data Type Description


Name String Returns the name used in code to identify an object.
ParameterType mwLayoutParamDataType Returns the variable type of a LayoutParameter object as
an mwLayoutParamDataType enum value.
UnitType mwUnitType Returns a value which specifies the unit type of a Parameter
object.

2176 NI AWR Design Environment


LayoutParameters

Name Data Type Description


ValueAsDouble Double Returns/sets the value of a LayoutParameter object as a
double.
ValueAsIntVector SafeArray Returns/sets the value of an IntVector type LayoutParameter
object.
ValueAsInteger Int Returns/sets the value of a LayoutParameter object as an
integer.
ValueAsRealVector SafeArray Returns/sets the value of a RealVector type LayoutParameter
object.
ValueAsString String Returns/sets the value of a LayoutParameter object as a
string.

LayoutParameters
A collection of MWOffice LayoutParameters objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item LayoutParameter Returns a specific item of a Collection object either by
position or by key.
ReadOnly Boolean Object or collection is readonly and cannot be changed.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: LayoutParameter

Syntax: Function Add(Name As String, Value As Double, [UnitType As mwUnitType = 17]) As LayoutParameter

AddInteger

Description: Adds an object to the collection and returns a reference to the created object.

Returns: LayoutParameter

Syntax: Function AddInteger(Name As String, Value As Long) As LayoutParameter

AddString

Description: Adds an object to the collection and returns a reference to the created object.

Returns: LayoutParameter

API Scripting Guide 2177


ObjectName

Syntax: Function AddString(Name As String, Value As String) As LayoutParameter

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

ObjectName
An MWOffice ObjectName Object.

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.

ObjectNames
A collection of MOffice ObjectName objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ObjectName Returns a specific item of a Collection object either by
position or by key.

ComplexNumber
A MWOffice ComplexNumber object.

Properties

Name Data Type Description


Angle Double Returns the angle of the complex number in degrees.
Imaginary Double Returns/sets the imaginary part of the Complex number.

2178 NI AWR Design Environment


ComplexNumbers

Name Data Type Description


Magnitude Double Returns the magnitude of the complex number.
Real Double Returns/sets the real part of the ComplexNumber.

ComplexNumbers
A collection of MWOffice ComplexNumber objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ComplexNumber Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: ComplexNumber

Syntax: Function Add(realPart As Double, imagPart As Double) As ComplexNumber

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

Offset
An MWOffice Offset object.

API Scripting Guide 2179


Offsets

Properties

Name Data Type Description


dx Double Returns/sets the DX value of a Offset object.
dy Double Returns/sets the DY value of a Offset object.

Offsets
A collection of MWOffice Offset objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Offset Returns a specific item of a Collection object either by
position or by key.

Point
An MWOffice Point object.

Properties

Name Data Type Description


x Long Returns/sets the X value of a Point object.
y Long Returns/sets the Y value of a Point object.

Points
A collection of MWOffice Point objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Point Returns a specific item of a Collection object either by
position or by key.

Size
An MWOffice Size object.

2180 NI AWR Design Environment


Sizes

Properties

Name Data Type Description


cx Long Returns/sets the X size value of the Size object.
cy Long Returns/sets the Y size value of the Size object.

Sizes
A collection of MWOffice Size objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Size Returns a specific item of a Collection object either by
position or by key.

Vertex
An MWOffice Vertex object.

Properties

Name Data Type Description


x Double Returns/sets the X value of a Vertex object.
y Double Returns/sets the Y value of a Vertex object.

Vertices
A collection of MWOffice Vertex objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Vertex Returns a specific item of a Collection object either by
position or by key.
XYPoints SafeArray Returns/sets the the points of a vertices collection as an
array of x y point pairs.

API Scripting Guide 2181


Vertex3D

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Vertex

Syntax: Function Add(x As Double, y As Double) As Vertex

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

Vertex3D
An MWOffice Vertex3D object.

Properties

Name Data Type Description


x Double Returns/sets the X value of a Vertex3D object.
y Double Returns/sets the Y value of a Vertex3D object.
z Double Returns/sets the Z value of a Vertex3D object.

CellInstance
An MWOffice CellInstance object.

Properties

Name Data Type Description


BasePosition Vertex Returns a reference to a Vertex object.
Bound Boolean Returns if the instance is bound to a master library cell.
Boundary Boundary Returns a reference to a Boundary object.
Flipped Boolean Returns/sets if the CellInstance object is flipped.

2182 NI AWR Design Environment


CellInstances

Name Data Type Description


MasterCell String Returns the name of the master cell associated with the
CellInstance object.
MasterLibrary String Returns the name of the master cell library associated with
the CellInstance object.
Name String Returns/Sets the name used in code to identify an object.
RotationAngle Double Returns/sets the angle in degrees of the CellInstance object.

Methods
None

CellInstances
A collection of MWOffice CellInstance objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item CellInstance Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: CellInstance

Syntax: Function Add(LibraryName As String, CellName As String, x As Double, y As Double, [CCWRotation As


Double = 0], [Flipped As Boolean = 0]) As CellInstance

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

Cell
An MWOffice Cell object.

API Scripting Guide 2183


Cell

Properties

Name Data Type Description


Boundary Boundary Returns a reference to a Boundary object.
Editors CellEditors Returns a reference to a CellEditors collection.
Info CellInfo Returns a reference to a MWOffice CellInfo object.
Instances CellInstances Returns a reference to a MWOffice CellInstances collection.
Name String Returns/Sets the name used in code to identify an object.
Shapes Shapes Returns a reference to a collection of Shape objects.
Windows Windows Returns a reference to a collection of Window objects.

Methods
Activate

Description: Activates the objects.

Returns: Void

Syntax: Sub Activate()

EditCell

Description: Returns a reference to a CellEditor object.

Returns: CellEditor

Syntax: Function EditCell() As CellEditor

Export

Description: Exports a design document file from MWOffice.

Returns: Boolean

Syntax: Function Export(Filename As String, format As mwCellExportFormat, [bFlat As Boolean = 0]) As Boolean

NewWindow

Description: Displays the object in new window.

Returns: Window

Syntax: Function NewWindow() As Window

UpdateViews

Description: Updates active views associated with the given cell object to display the latest shape edits.

Returns: Boolean

2184 NI AWR Design Environment


Cells

Syntax: Function UpdateViews() As Boolean

Cells
A collection of MWOffice Cell objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Cell Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Cell

Syntax: Function Add(CellName As String) As Cell

Copy

Description: Copies an object from another object collection into this object collection.

Returns: Cell

Syntax: Function Copy(FromLibrary As String, FromCell As String, [NewCellName As String = ""], [FlattenCell As
Boolean = 0]) As Cell

Copy2

Description: Copies an object from another object collection into this object collection.

Returns: Cell

Syntax: Function Copy2(FromLibrary As String, FromCell As String, [NewCellName As String = ""], [FlattenCell As
Boolean = 0], [CopyChildren As Boolean = 0]) As Cell

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

API Scripting Guide 2185


CellLibrary

CellLibrary
An MWOffice Cell Library object.

Click to see examples

Properties

Name Data Type Description


Cells Cells Returns a reference to a collection of Cell objects.
DatabaseUnitsPerMeter Double Returns the number of database units per meter.
DatabaseUnitsPerUserUnit Double Returns the number of user units per meter.
ExcludeFromExport Boolean Returns/sets a value which specifies if the Library is
excluded from export.
Filename String Returns the filename of a Cell Library object.
Locked Boolean Returns/sets a value which specifies if the Library is locked.
Modified Boolean Returns a value which specifies if the Library has been
modified.
Name String Returns/Sets the name used in code to identify an object.
OverrideDatabaseUnit Boolean Returns/sets whether the override unit size should be used
instead of the internal library unit size.
OverrideDatabaseUnitSize Double Returns/sets the unit size to be used when override database
unit size is enabled.
ProcessDefinition String Returns/sets the name of the process definition to be used
with this cell library.
ReadNewest Boolean Returns/sets a value which specifies if the Library should
read newest cells.
ReplaceAllCells Boolean Returns/sets a value which specifies if the Library should
replace all cells including modified cells.
SearchPriority Long Returns/sets the search priority of the CellLibrary object.
Values range from 1 to the number of libraries in the project.
Type mwCellLibraryType Returns the cell format for a CellLibrary object.
UserUnitsPerMeter Double Returns the number of user units per meter.

Methods
Merge

Description: Merges the named library with this library to form a single library

Returns: Boolean

Syntax: Function Merge(libName As String, [mergeFlags As Long = 0]) As Boolean

2186 NI AWR Design Environment


CellLibraries

SaveAs

Description: Saves the Cell Library under a new filename.

Returns: Void

Syntax: Sub SaveAs(Filename As String)

CellLibraries
A collection of MWOffice Cell Library objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item CellLibrary Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: CellLibrary

Syntax: Function Add(CellLibraryName As String, Type As mwCellLibraryType) As CellLibrary

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Import

Description: Adds a Netlist object to the collection from a file and returns a reference to the created object.

Returns: CellLibrary

Syntax: Function Import(Name As String, Filename As String, Type As mwCellLibraryType) As CellLibrary

Import2

Description: Adds a CellLibrary object to the collection from a file and returns a reference to the created object.

Returns: CellLibrary

API Scripting Guide 2187


EMLayerMapEntry

Syntax: Function Import2(Name As String, Filename As String, Type As mwCellLibraryType, [DefaultScaleFactor As


Double = 0]) As CellLibrary

LinkTo

Description: Adds a CellLibrary object to the collection linked the library file and returns a reference to the created
object.

Returns: CellLibrary

Syntax: Function LinkTo(Name As String, Filename As String, Type As mwCellLibraryType) As CellLibrary

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

EMLayerMapEntry
An MWOffice EMLayerMapEntry object.

Properties

Name Data Type Description


DrawingLayer String Returns the drawing layer for the EMLayerMapping object.
EMLayer Long Returns/Sets the EM layer index or the EMLayerMapping
object.
IsVia Boolean Returns/Sets a value which determines whether the layer
type is a via layer.
Material String Returns/Sets the material for the layer for the
EMLayerMapping object.
ViaExtent Long Returns/Sets the via extent value for the EMLayerMapEntry
object.

EMLayerMapEntries
A collection of MWOffice EMLayerMapEntry objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item EMLayerMapEntry Returns a specific item of a Collection object either by
position or by key.

2188 NI AWR Design Environment


EMLayerMapping

EMLayerMapping
An MWOffice EMLayerMapping object.

Properties

Name Data Type Description


Active Boolean Returns a value which determines if the mapping is the
active mapping.
Entries EMLayerMapEntries Returns a reference to a EMLayerMapEntries collection.
Name String Returns/Sets the name used in code to identify an object.

EMLayerMappings
A collection of MWOffice EMLayerMapping objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item EMLayerMapping Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: EMLayerMapping

Syntax: Function Add(Name As String) As EMLayerMapping

Copy

Description: Copies the object to the system clipboard.

Returns: EMLayerMapping

Syntax: Function Copy(Index, [NewName As String = ""]) As EMLayerMapping

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

API Scripting Guide 2189


LayerMapEntry

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Key) As Boolean

SetActive

Description: Sets the mapping identified by index active to be the active EM mapping.

Returns: Void

Syntax: Sub SetActive(Index)

LayerMapEntry
An MWOffice LayerMapEntry object.

Properties

Name Data Type Description


DrawingLayer String Returns the drawing layer name for the entry object.
ModelLayer String Returns the model layer name for the entry object.

LayerMapEntries
A collection of MWOffice LayerMapEntry objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item LayerMapEntry Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: LayerMapEntry

Syntax: Function Add(ModelLayer As String, DrawingLayer As String) As LayerMapEntry

2190 NI AWR Design Environment


LayerMapping

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

LayerMapping
An MWOffice LayerMapping object.

Click to see examples

Properties

Name Data Type Description


Entries LayerMapEntries Returns a reference to a LayerMapEntries collection.
Name String Returns/Sets the name used in code to identify an object.

LayerMappings
A collection of MWOffice LayerMapping objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item LayerMapping Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: LayerMapping

Syntax: Function Add(Name As String) As LayerMapping

API Scripting Guide 2191


LayerExportEntry

Clear

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function Clear() As Boolean

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

LayerExportEntry
An MWOffice LayerExportEntry object.

Properties

Name Data Type Description


DrawingLayer String Returns/Sets the drawing layer for the LayerExportEntry
object.
ExportLayer String Returns/Sets the export layer for the LayerExportEntry
object.
WriteLayer Boolean Returns/Sets a value which specifies if the layer should be
output when exporting.

LayerExportEntries
A collection of MWOffice LayerExportEntry objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item LayerExportEntry Returns a specific item of a Collection object either by
position or by key.

2192 NI AWR Design Environment


LayerExportMapping

LayerExportMapping
An MWOffice LayerExportMapping object.

Properties

Name Data Type Description


Entries LayerExportEntries Returns a reference to a LayerMapEntries collection.
Name String Returns/Sets the name used in code to identify an object.
Type mwLayoutExportFormat Returns/Sets a value which determines the type of the layer
export mapping.

LayerExportMappings
A collection of MWOffice LayerExportMapping objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item LayerExportMapping Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: LayerExportMapping

Syntax: Function Add(Name As String, Type As mwLayoutExportFormat) As LayerExportMapping

Clear

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function Clear() As Boolean

Copy

Description: Copies the object to the system clipboard.

Returns: LayerExportMapping

Syntax: Function Copy(Index, [NewName As String = ""]) As LayerExportMapping

API Scripting Guide 2193


DrawingLayer

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

DrawingLayer
An MWOffice Drawing Layer object.

Properties

Name Data Type Description


Blend Double Returns/sets the 3D layer blend level for a DrawingLayer
object.
Blend2D Double Returns/sets the 2D layer blend level for a DrawingLayer
object.
Cloak Boolean Returns/sets a value indicating if the drawing layer is
cloaked.
Description String Returns/sets a value associated with the layer intended to
provide an extended description of the layer purpose
FillColor Long Returns/sets the value of a color for the Layer object.
FillStyle mwFillStyle Returns/sets a value which specifies the fill style of a
Drawing Layer object.
Filled Boolean Returns/sets a value which specifies if the Drawing Layer
is filled.
Flags Int Returns a value which specifies the flags of the Drawing
Layer.
Frozen Boolean Returns a value which specifies if the Drawing Layer object
is frozen.
HatchName String Returns/sets a value associated with the layer to provide a
name for the hatch style.
LineColor Long Returns/sets the value of a color for the Layer object.
LineStyle mwLineStyle Returns/sets a value which specifies the line style of a
Drawing Layer object.
Name String Returns/Sets the name used in code to identify an object.
Number Int Returns/sets the number of the drawing layer object.

2194 NI AWR Design Environment


DrawingLayers

Name Data Type Description


Opaque Boolean Returns/sets a value which specifies if the layer is opaque
in 3D view.
Opaque2D Boolean Returns/sets a value which specifies if the layer is opaque
in 2D view.
SystemLayer Boolean Returns a value which specifies if the Drawing Layer is a
system layer. System layers cannot be removed.
TextureFile String Returns/sets the name of the file for the texture of a
DrawingLayer object.
TextureScale Double Returns/sets the 3D layer texture scale for a DrawingLayer
object.
Thickness Double Returns/sets the 3D layer thickness for a DrawingLayer
object.
Visible Boolean Returns/sets a value which specifies if the Drawing Layer
is visible.
ZPosition Double Returns/sets the 3D layer Z-Position for a DrawingLayer
object.

DrawingLayers
A collection of MWOffice Drawing Layer objects.

Properties

Name Data Type Description


ActiveLayer DrawingLayer Returns the active drawing layer object.
AllFilled Boolean Returns/sets a value indicating if all layers are filled.
AllFrozen Boolean Returns/sets a value indicating if all layers are frozen.
AllVisible Boolean Returns/sets a value indicating if all layers are visible.
Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DrawingLayer Returns a specific item of a Collection object either by
position or by key.

Methods
Add2

Description: Adds an object to the collection and returns a reference to the created object.

Returns: DrawingLayer

Syntax: Function Add2(Name As String, [LineColor As Long = 255], [LineStyle As mwLineStyle = 0], [Filled As
Boolean = -1], [FillColor As Long = 255], [FillStyle As mwFillStyle = 1], [Thickness As Double = 0], [ZPosition As

API Scripting Guide 2195


LayerSetup

Double = 0], [Opaque2D As Boolean = -1], [Opaque3D As Boolean = -1], [Blend2D As Double = 0], [Blend3D As
Double = 0]) As DrawingLayer

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Name As String) As Boolean

RemoveAll

Description: Removes all non-system drawing layers

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

LayerSetup
An MWOffice LayerSetup object.

Properties

Name Data Type Description


DrawingLayers DrawingLayers Returns a reference to a collection of Drawing Layer objects.
DrillTools DrillTools Returns a reference to a collection of DrillTool objects.
EMLayerMappings EMLayerMappings Returns a reference to a EMLayerMappings collection.
LayerExportMappings LayerExportMappings Returns a reference to a LayerExportMappings collection.
LayerMappings LayerMappings Returns a reference to a LayerMappings collection.

Methods
None

DrillTool
An MWOffice DrillTool object.

2196 NI AWR Design Environment


DrillTools

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
Number Int Returns/sets the number of a DrillTool object.
Radius Double Returns/sets the radius of a DrillTool object.

DrillTools
A collection of MWOffice DrillTool objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DrillTool Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: DrillTool

Syntax: Function Add(Name As String, [Number As Int = 1], [Radius As Double = 9.99999974737875E-05]) As
DrillTool

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

ModifierDefDrawingObjects
A collection of DrawingObject objects.

API Scripting Guide 2197


ModifierDefRecord

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DrawingObject Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Boolean

Syntax: Function Add(pObj As DrawingObject) As Boolean

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

ModifierDefRecord
A MWOffice ModifierDefRecord object.

Properties

Name Data Type Description


Attributes Attributes Returns a reference to a collection of Attribute objects.
ModifyObjects ModifierDefDrawingObjects Returns a reference to a ModifierDefDrawingObjects
collection.
Name String Returns/Sets the name used in code to identify an object.
ParamFramePosX Double Returns/sets the x coordinate for the placement of the
parameter frame when the modifier is created.

2198 NI AWR Design Environment


ModifierDefRecords

Name Data Type Description


ParamFramePosY Double Returns/sets the y coordinate for the placement of the
parameter frame when the modifier is created.
ShapeVertices Vertices Returns a reference to a collection of Vertex objects.

ModifierDefRecords
A collection of ModifierDefRecord objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ModifierDefRecord Returns a specific item of a Collection object either by
position or by key.

ShapeModifierRecord
A MWOffice ShapeModifierRecord object.

Properties

Name Data Type Description


Description String Returns a description of the ShapeModifier created by this
ShapeModifierRecord object.
Name String Returns/Sets the name used in code to identify an object.
ParameterDefinitions ParameterDefinitions Returns a reference to a collection of ParameterDefinition
objects.
Version Long Returns the version of the ShapeModifier created by this
ShapeModifierRecord object.

ShapeModifierRecords
A collection of MWOffice ShapeModfierRecordObjects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ShapeModifierRecord Returns a specific item of a Collection object either by
position or by key.

API Scripting Guide 2199


ShapeModifier

ShapeModifier
A MWOffice ShapeModifier object.

Properties

Name Data Type Description


Attributes Attributes Returns a reference to a collection of Attribute objects.
Boundary Boundary Returns a reference to a Boundary object.
DisplayMode Boolean Returns/Sets various ShapeModifier display mode settings.
Enabled Boolean Returns/sets if the ShapeModifer object is enabled.
GeneratedObjects DrawingObjects Returns a reference to a collection of DrawingObjects.
GraphicObject DrawingObject Returns a reference to a DrawingObject.
HasError Boolean Returns if the ShapeModifier object is in an error state.
MessageId Long Returns the message id for this ShapeModifier object.
ModifyObjects DrawingObjects Returns a reference to a collection of DrawingObjects.
Name String Returns/Sets the name used in code to identify an object.
OrderIndex Long Returns/sets the order index for this ShapeModifier object.
ParameterFrame LayoutParameterFrame Returns a reference to a ParameterFrame object.
Parameters Parameters Returns a reference to a collection of Parameter objects.
Priority mwShapeModifierPriority Returns the priority level for this ShapeModifier object.
Record ShapeModifierRecord Returns a reference to a ShapeModifierRecord object.
Selected Boolean Returns/sets if the ShapeModifier object is selected.
Type mwShapeModifierType Returns the type of the ShapeModifier object.
Vertices Vertices Returns a reference to a collection of Vertex objects.

ShapeModifiers
A collection of MWOffice ShapeModifier objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ShapeModifier Returns a specific item of a Collection object either by
position or by key.

2200 NI AWR Design Environment


DesignRule

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: ShapeModifier

Syntax: Function Add(pDef As ModifierDefRecord) As ShapeModifier

CreateModifierDefRecord

Description: Creates and returns a shape modifier record for creating a specific type of shape modifier.

Returns: ModifierDefRecord

Syntax: Function CreateModifierDefRecord(Type As String) As ModifierDefRecord

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

DesignRule
An MWOffice DesignRule object.

Properties

Name Data Type Description


Enable Boolean Returns a value that determines if the design rule is
evaluated during a design rule check
GroupRules DesignRules Returns a reference to a collection of GroupRules objects.
IsGroup Boolean Returns a value that determines if the design rule represents
a group of rules.
Rule String Returns the design rule string.

DesignRules
A collection of MWOffice DesignRule objects.

API Scripting Guide 2201


DesignRules

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DesignRule Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: DesignRule

Syntax: Function Add(Rule As String, [Enable As Boolean = -1]) As DesignRule

AddGroup

Description: Adds an object to the collection and returns a reference to the created object.

Returns: DesignRule

Syntax: Function AddGroup(GroupName As String, [Enable As Boolean = -1]) As DesignRule

Export

Description: Exports a design document file from MWOffice.

Returns: Boolean

Syntax: Function Export(FilePath As String, [Flags As Long = 0]) As Boolean

Import

Description: Adds a Netlist object to the collection from a file and returns a reference to the created object.

Returns: Boolean

Syntax: Function Import(FilePath As String) As Boolean

ImportDefaultRules

Description: Adds a Netlist object to the collection from a file and returns a reference to the created object.

Returns: Boolean

Syntax: Function ImportDefaultRules() As Boolean

2202 NI AWR Design Environment


DesignRuleError

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub RemoveAll()

DesignRuleError
An MWOffice DesignRuleError object.

Properties

Name Data Type Description


Boundary Boundary Returns a reference to a Boundary object.
Code Long Returns the raw value of a design rule error code defined
by the object.
Color Int Returns/sets the color used to highlight the DesignRuleError
shapes in the layout.
Message String Returns the message string associated with the
DesignRuleError object.
Shapes DRCErrorShapes Returns a reference to a collection of Vertex objects.
State mwDesignRuleState Returns/sets a value which specifies the DesignRuleError
state
Type mwDesignRuleType Returns a value that specifies the type of the
DesignRuleErorr object.

DesignRuleErrors
A collection of MWOffice DesignRuleError objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DesignRuleError Returns a specific item of a Collection object either by
position or by key.

API Scripting Guide 2203


LVSError

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: DesignRuleError

Syntax: Function Add(ErrorCategory As String, ErrorMessage As String, ErrorType As mwDesignRuleType, ErrorState


As mwDesignRuleState, XYPoints As SafeArray) As DesignRuleError

Load

Description: Reads in the specified DRC error file and adds the errors to the DesignRuleErrors collection (does not clear
errors first.)

Returns: Void

Syntax: Sub Load(ErrorFile As String, fileFormat As mwDesignRuleErrorFileFormat)

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

Save

Description: Saves the errors in the DesignRuleErrors collection to the specified file name in AWR DRC error format.

Returns: Void

Syntax: Sub Save(ErrorFile As String)

LVSError
An MWOffice LVSError object.

Properties

Name Data Type Description


Boundary Boundary Returns a reference to a Boundary object.

2204 NI AWR Design Environment


LVSErrors

Name Data Type Description


Color Int Returns/sets the color used to highlight the LVSError shapes
in the layout and schematic.
Message String Returns the message string associated with the LVSError
object.
NetlistHighlights LVSNetHighlights Returns a reference to a collection of NetlistHighlights.
SchematicHighlights LVSSchemHighlights Returns a reference to a collection of SchematicHighlights.
Shapes DRCErrorShapes Returns a reference to a collection of Vertex objects.
State mwDesignRuleState Returns/sets a value which specifies the LVSError state

LVSErrors
A collection of MWOffice LVSError objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item LVSError Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: LVSError

Syntax: Function Add(ErrorCategory As String, ErrorMessage As String, ErrorState As mwDesignRuleState) As


LVSError

Load

Description: Reads in the specified LVS error file and adds the errors to the LVSErrors collection (does not clear errors
first.)

Returns: Void

Syntax: Sub Load(ErrorFile As String)

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

API Scripting Guide 2205


LVSSchemHighlight

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

Save

Description: Saves the errors in the LVSErrors collection to the specified file name in AWR error format.

Returns: Void

Syntax: Sub Save(ErrorFile As String)

LVSSchemHighlight
An MWOffice SchematicHighlight object.

Properties

Name Data Type Description


HighlightLocation mwLVSHighlightLoc Returns/Sets the HighlightLoc value associated with the
MWOffice SchematicHighlight object.
ItemID String Returns/Sets the ItemID string associated with the
MWOffice SchematicHighlight object.

LVSSchemHighlights
A collection of MWOffice SchematicHighlights objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item LVSSchemHighlight Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: LVSSchemHighlight

2206 NI AWR Design Environment


LVSNetHighlight

Syntax: Function Add(ItemID As String, HighlightLocation As mwLVSHighlightLoc) As LVSSchemHighlight

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

LVSNetHighlight
An MWOffice NetlistHighlight object.

Properties

Name Data Type Description


HighlightString String Returns/Sets a string to highlight for an MWOffice
NetlistHighlight object.
NetlistDisplayName String Returns/Sets a display name for the netlist associated with
the MWOffice NetlistHighlight object.
NetlistPath String Returns/Sets the full file path string associated with the
MWOffice NetlistHighlight object.

LVSNetHighlights
A collection of MWOffice NetlistHighlight objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item LVSNetHighlight Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

API Scripting Guide 2207


DesignRuleChecker

Returns: LVSNetHighlight

Syntax: Function Add(NetlistPath As String, NetlistDisplayName As String, HighlightString As String) As


LVSNetHighlight

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

DesignRuleChecker
An MWOffice DesignRuleChecker object.

Click to see examples

Properties

Name Data Type Description


DesignName String Returns/sets a string containing the name of the layout
checked in the last DRC run.
Errors DesignRuleErrors Returns a reference to a collection of DesignRuleError
objects.
ErrorsWindow DRCErrorsWindow Returns a reference to the DRCErrorsWindow object.
LastRunDateTime String Returns/sets a string containing the date and time of the last
DRC run.
RuleDeckName String Returns/sets a string containing the name of the rule deck
used for the last DRC run.

Methods
CompareLayoutToGDSFile

Description: Compares the layout associated with this design rule checkout with a specified GDSII file.

Returns: Boolean

Syntax: Function CompareLayoutToGDSFile(pGdsFileName As String, pCompareFlattened As Boolean) As Boolean

2208 NI AWR Design Environment


LayoutVsSchematicChecker

CreateRuleSet

Description: Creates a collection of rules for a design rule check run.

Returns: DesignRules

Syntax: Function CreateRuleSet() As DesignRules

RunCheck

Description: Runs a design rule check on the layout associated with the design rule checker

Returns: Boolean

Syntax: Function RunCheck(Rules As DesignRules) As Boolean

LayoutVsSchematicChecker
An MWOffice LayoutVsSchematicChecker object.

Properties

Name Data Type Description


DesignName String Returns/sets a string containing the name of the
layout/schematic checked in the last LVS run.
Errors LVSErrors Returns a reference to a collection of LVSError objects.
ErrorsWindow LVSErrorsWindow Returns a reference to the LVSErrorsWindow object.
LastRunDateTime String Returns/sets a string containing the date and time of the last
LVS run.
RuleDeckName String Returns/sets a string containing the name of the rule deck
used for the last LVS run.
SimConfigName String Returns/sets a string containing the name of the simulation
configuration used for the last LVS run.

Methods
None

DRCErrorsWindow
An MWOffice DRCErrorsWindow object.

Properties

Name Data Type Description


Visible Boolean Returns/sets a value which specifies the visibility of a
DRCErrorsWindow object.

API Scripting Guide 2209


LVSErrorsWindow

LVSErrorsWindow
An MWOffice DRCErrorsWindow object.

Properties

Name Data Type Description


Visible Boolean Returns/sets a value which specifies the visibility of a
LVSErrorsWindow object.

DRCErrorShape
An MWOffice DRCErrorShape object, for use with DRC/LVS error types that have multiple shapes (like
mwDRT_MultiPolygon)

Properties

Name Data Type Description


Vertices Vertices Returns a reference to a collection of Vertex objects.

DRCErrorShapes
A collection of MWOffice DRCErrorShape objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DRCErrorShape Returns a specific item of a Collection object either by
position or by key.

Methods
AddPolygon

Description: Adds a polygon shape to the DRCErrorShapes collection.

Returns: DRCErrorShape

Syntax: Function AddPolygon(XYPoints As SafeArray) As DRCErrorShape

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

2210 NI AWR Design Environment


ConnectivityHighlighter

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

ConnectivityHighlighter
An MWOffice ConnectivityHighlighter object.

Methods
HighlightAll

Description: Turns on highlight for all connectivity in the assoicated layout design.

Returns: Boolean

Syntax: Function HighlightAll() As Boolean

HighlightOff

Description: Turns off highlight for all connectivity in the associated layout design.

Returns: Boolean

Syntax: Function HighlightOff() As Boolean

HighlightProbe

Description: Turns on highlight for connectivity for shapes associated with a specific probe location in the associated
layout design.

Returns: Boolean

Syntax: Function HighlightProbe(x As Double, y As Double, Color As Long) As Boolean

HighlightSelectedOff

Description: Turns off highlight for connectivity for selected shapes in the associated layout design.

Returns: Boolean

Syntax: Function HighlightSelectedOff() As Boolean

HighlightShape

Description: Turns on highlight for connectivity associated with the given DrawingObject in the associated layout
design.

Returns: Boolean

Syntax: Function HighlightShape(pObj As DrawingObject, Color As Long) As Boolean

API Scripting Guide 2211


DrawingObject

DrawingObject
An MWOffice DrawingObject.

Click to see examples

Properties

Name Data Type Description


Attributes Attributes Returns a reference to a collection of Attribute objects.
BasePosition Vertex Returns a reference to a Vertex object.
Boundary Boundary Returns a reference to a Boundary object.
Cell Cell Returns a reference to a Cell object.
DisplayMode Boolean Returns/sets various DrawingObject display mode settings.
EMPorts EMPorts Returns a reference to an EMPorts collection.
EditHandles EditHandles Returns a reference to a collection of MWOffice EditHandle
objects.
Element Element Returns a reference to an Element object.
Faces Faces Returns a reference to a collection of Face objects.
Flipped Boolean Returns/sets a value which specifies if the DrawingObject
is flipped.
Frozen Boolean Returns/sets a value which specifies if the DrawingObject
is frozen.
Group Boolean Returns if the drawing object is a group of drawing objects.
GroupObjects GroupDrawingObjects Returns a reference to a collection of MWOffice
GroupDrawingObject objects.
InfoText String Returns the DrawingObject information text describing the
object.
IsElementObject Boolean Returns if the DrawingObject is associated with an element
object in schematic.
LayerMapping String Returns/sets a value which specifies the name of the layer
mapping applied to this DrawingObject
MarkedNegative Boolean Returns/sets if the shape is marked as a negative layer shape.
NetName String Returns/sets the shape network name associated with this
DrawingObject.
NetType mwShapeNetType Returns/sets the shape network type associated with this
DrawingObject.
PCBPinObject Boolean Returns/sets if the shape is marked as a PCB pin object.
Parameters LayoutParameters Returns a reference to a collection of LayoutParameter
objects
RotationAngle Double Returns/sets the rotation angle of the DrawingObject.
Segments DrawingSegments Returns a reference to a collection of MWOffice
DrawingSegment objects.

2212 NI AWR Design Environment


DrawingObject

Name Data Type Description


Selected Boolean Returns/sets a value which specifies if a DrawingObject is
selected.
Shapes Shapes Returns a reference to a collection of Shape objects.
SubObjects DrawingSubObjects Returns a reference to a collection of MWOffice
DrawingSubObject objects.
TypeBits Long Returns flags describing the DrawingObject type
Visible Boolean Returns if the drawing object has shapes which are on visible
layers.

Methods
Copy

Description: Create a copy of the drawing object located at the specified x and y location.

Returns: Boolean

Syntax: Function Copy(x As Double, y As Double) As Boolean

Delete

Description: Removes the object.

Returns: Boolean

Syntax: Function Delete() As Boolean

Flatten

Description: Flattens the drawing object into a collection of shapes returns a reference to the resulting shapes in the
design.

Returns: Shapes

Syntax: Function Flatten([FlattenLevel As Long = 65000], [mergePosNegLayers As Boolean = 0]) As Shapes

Move

Description: Moves the DrawingObject by the given values relative to the current location.

Returns: Boolean

Syntax: Function Move(dx As Double, dy As Double, [CCWRotation As Double = 0], [Flip As Boolean = 0],
[FlipHorizontal As Boolean = 0], [xOrigin As Double = 0], [yOrigin As Double = 0]) As Boolean

ResizeObject

Description: Updates the size and position of the drawing object within the layout.

Returns: Void

API Scripting Guide 2213


DrawingObjects

Syntax: Sub ResizeObject()

DrawingObjects
A collection of MWOffice DrawingObjects.

Properties

Name Data Type Description


ActiveNetName String Returns/sets the active shape network name to be used with
newly created DrawingObjects.
ActiveNetType mwShapeNetType Returns/sets the active shape network type to be used with
newly created DrawingObjects.
Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DrawingObject Returns a specific item of a Collection object either by
position or by key.
MarkNegative Boolean Returns/sets a value that indicates if newly added shapes to
the DrawingObjects collection should be marked negative.
PathWriter PathWriter Returns a reference to a MWOffice PathWriters object.
PolygonWriter PolygonWriter Returns a reference to a MWOffice PolygonWriter object.

Methods
AddArc

Description: Adds an arc object to the DrawingObject collection.

Returns: DrawingObject

Syntax: Function AddArc(xCenter As Double, yCenter As Double, Radius As Double, StartAngle As Double, EndAngle
As Double, [LayerName As String = ""], [UseProcessLayers As Boolean = 0], [LayerMapping As String = ""]) As
DrawingObject

AddArrayCell

Description: Adds an array cell object to the DrawingObjects collection.

Returns: DrawingObject

Syntax: Function AddArrayCell(LibraryName As String, CellName As String, x As Double, y As Double, Rows As


Int, Columns As Int, dx As Double, dy As Double, [RotationAngle As Double = 0], [Flipped As Boolean = 0]) As
DrawingObject

AddCell

Description: Adds a cell object to the DrawingObjects collection.

Returns: DrawingObject

2214 NI AWR Design Environment


DrawingObjects

Syntax: Function AddCell(LibraryName As String, CellName As String, x As Double, y As Double, [RotationAngle


As Double = 0], [Flipped As Boolean = 0]) As DrawingObject

AddDimensionLine

Description: Adds a dimension line to the DrawingObjects collection.

Returns: DrawingObject

Syntax: Function AddDimensionLine(x1 As Double, y1 As Double, x2 As Double, y2 As Double, x3 As Double, y3


As Double, [ArrowSize As Double = 0], [TextLocation As mwDimensionTextLocation = 0], [ArrowLocation As
mwDimensionArrowLocation = 0], [FontName As String = "Arial"], [FontHeight As Double = 0], [DisplayPrecision
As Long = 1], [ShowUnits As Boolean = 0], [ShowTolorance As Boolean = 0], [ToleranceLength As Long = 0]) As
DrawingObject

AddDrillHole

Description: Adds a drill hole object to the DrawingObjects collection.

Returns: DrawingObject

Syntax: Function AddDrillHole(x As Double, y As Double, ToolName As String) As DrawingObject

AddEllipse

Description: Adds an ellipse object to the DrawingObject collection.

Returns: DrawingObject

Syntax: Function AddEllipse(x As Double, y As Double, dx As Double, dy As Double, [LayerName As String = ""],
[UseProcessLayers As Boolean = 0], [LayerMapping As String = ""]) As DrawingObject

AddLayoutCell

Description: Adds a LayoutCell object to the DrawingObjects collection.

Returns: DrawingObject

Syntax: Function AddLayoutCell(Name As String, x As Double, y As Double, [RotationAngle As Double = 0], [Flipped
As Boolean = 0]) As DrawingObject

AddLayoutRuler

Description: Adds a layout ruler object to the DrawingObjects collection.

Returns: DrawingObject

Syntax: Function AddLayoutRuler(x1 As Double, y1 As Double, x2 As Double, y2 As Double, [Gap As Double =


4.99999987368938E-06], [TickHeight As Double = 1.49999996210681E-05], [TickLocation As
mwLayoutRulerTickLocation = -1], [DisplayPrecision As Int = 1], [Spacing As Double = 2.99999992421363E-05],
[ShowUnits As Boolean = 0], [FontName As String = "Arial"], [FontHeight As Double = 2.49999993684469E-05],
[FontBold As Boolean = 0], [FontItalic As Boolean = 0]) As DrawingObject

API Scripting Guide 2215


DrawingObjects

AddPath

Description: Adds a path object to the DrawingObjects collection.

Returns: DrawingObject

Syntax: Function AddPath(XYPoints As SafeArray, Width As Double, [EndStyle As mwPathEndType = 1], [MiterStyle
As mwPathMiterType = 1], [OffsetMiterAmount As Double = 0], [LayerName As String = ""], [UseProcessLayers As
Boolean = 0], [LayerMapping As String = ""]) As DrawingObject

AddPathEx

Description: Adds a path object to the DrawingObjects collection.

Returns: DrawingObject

Syntax: Function AddPathEx(XYPoints As SafeArray, Width As Double, [EndStyle As mwPathEndType = 1], [MiterStyle
As mwPathMiterType = 1], [OffsetMiterAmount As Double = 0], [PathBeginExtent As Double = 0], [PathEndExtent
As Double = 0], [LayerName As String = ""], [UseProcessLayers As Boolean = 0], [LayerMapping As String = ""]) As
DrawingObject

AddPolygon

Description: Adds a polygon object to the DrawingObjects collection.

Returns: DrawingObject

Syntax: Function AddPolygon(XYPoints As SafeArray, [LayerName As String = ""], [UseProcessLayers As Boolean


= 0], [LayerMapping As String = ""]) As DrawingObject

AddRectangle

Description: Adds a rectangle object to DrawingObjects collection.

Returns: DrawingObject

Syntax: Function AddRectangle(x As Double, y As Double, dx As Double, dy As Double, [LayerName As String = ""],
[UseProcessLayers As Boolean = 0], [LayerMapping As String = ""]) As DrawingObject

AddRoute

Description: Adds a Route object to the DrawingObjects collection.

Returns: DrawingObject

Syntax: Function AddRoute(Record As RouteRecord) As DrawingObject

AddText

Description: Adds a text object to the DrawingObjects collection.

Returns: DrawingObject

Syntax: Function AddText(x As Double, y As Double, Height As Double, Text As String, [RotationAngle As Double
= 0], [Flipped As Boolean = 0], [FontName As String = ""], [Bold As Boolean = 0], [Italic As Boolean = 0],

2216 NI AWR Design Environment


PolygonRecord

[DrawAsPolygons As Boolean = -1], [LayerName As String = ""], [UseProcessLayers As Boolean = 0], [LayerMapping
As String = ""]) As DrawingObject

AddTextEx

Description: Adds a text object to the DrawingObjects collection.

Returns: DrawingObject

Syntax: Function AddTextEx(x As Double, y As Double, Height As Double, Text As String, [DrawAsPolygons As
Boolean = -1], [LayerName As String = ""], [TextAlignment As mwTextAlignment = 5], [RotationAngle As Double =
0], [Flipped As Boolean = 0], [FontName As String = ""], [Bold As Boolean = 0], [Italic As Boolean = 0],
[UseProcessLayers As Boolean = 0], [LayerMapping As String = ""]) As DrawingObject

CreateRouteRecord

Description: Returns a reference to a MWOffice RouteRecord object.

Returns: RouteRecord

Syntax: Function CreateRouteRecord() As RouteRecord

NegateLayer

Description: Process layer shapes to invert complex polygons and subtract them from remaining layer shapes.

Returns: Boolean

Syntax: Function NegateLayer(LayerName As String, [pProfileShape As DrawingObject = 0]) As Boolean

NegateLayerShapes

Description: Process layer shapes to invert shapes marked as negative and subtract them from remaining layer shapes.

Returns: Boolean

Syntax: Function NegateLayerShapes(LayerName As String) As Boolean

PolygonRecord
An MWOffice PolygonRecord object.

Properties

Name Data Type Description


PCBPinObject Boolean Returns/Sets a value that indicates if the polygon should
marked as a PCB pin when it is created.

Methods
AddCircle

Description: Add a circle shaped polygon to the record object with the given center and radius values

API Scripting Guide 2217


PolygonRecord

Returns: Void

Syntax: Sub AddCircle(centerX As Double, centerY As Double, Radius As Double)

AddCircleCutout

Description: Adds a new circle cutout to the PolygonRecord object.

Returns: Void

Syntax: Sub AddCircleCutout(centerX As Double, centerY As Double, Radius As Double)

AddEllipse

Description: Add an ellipse shaped polygon to the record object with the given upper left corner and width and height

Returns: Void

Syntax: Sub AddEllipse(x As Double, y As Double, dx As Double, dy As Double)

AddEllipseCutout

Description: Adds a new ellipse cutout to the PolygonRecord object.

Returns: Void

Syntax: Sub AddEllipseCutout(x As Double, y As Double, dx As Double, dy As Double)

AddPolyArcSegment

Description: Adds a new arc segment to the current polygon or cutout polygon ot the PolygonRecord object.

Returns: Void

Syntax: Sub AddPolyArcSegment(x2 As Double, y2 As Double, centerX As Double, centerY As Double, dir As
mwDrawingArcDirection)

AddPolySegment

Description: Adds a new segment to the current polygon or cutout polygon to the PolygonRecord object.

Returns: Void

Syntax: Sub AddPolySegment(x2 As Double, y2 As Double)

Clear

Description: Clears the PolygonRecord of all polygon information so it can be reused.

Returns: Void

Syntax: Sub Clear()

2218 NI AWR Design Environment


PolygonRecord

HasCutouts

Description: Returns a value that indicates if the polygon contains cutouts.

Returns: Boolean

Syntax: Function HasCutouts() As Boolean

Mirror

Description: Mirrors the object represented by the PolygonRecord object about the y-axis.

Returns: Void

Syntax: Sub Mirror(aboutX As Double)

Offset

Description: Adds an offset to the object represented by the PolygonRecord object.

Returns: Void

Syntax: Sub Offset(dx As Double, dy As Double)

PolyCutoutBegin

Description: Method to indicate the start of a polygon cutout object to the PolygonRecord object.

Returns: Void

Syntax: Sub PolyCutoutBegin(x1 As Double, y1 As Double)

PolyCutoutEnd

Description: Method to indicate the end of a polygon cutout object to the PolygonRecord object.

Returns: Void

Syntax: Sub PolyCutoutEnd()

PolygonBegin

Description: Method to indicate the start of a new polygon object to the PolygonRecord object.

Returns: Void

Syntax: Sub PolygonBegin(x1 As Double, y1 As Double)

PolygonEnd

Description: Method to indcate the end of the polygon object to the PolygonRecord object.

Returns: Void

Syntax: Sub PolygonEnd()

API Scripting Guide 2219


PolygonWriter

Rotate

Description: Adds a counter-clockwise rotation to the object represented by the PolygonRecord object.

Returns: Void

Syntax: Sub Rotate(angleCCW As Double, aboutX As Double, aboutY As Double)

Scale

Description: Adds a scale factor to the object repersented by the PolygonRecord object.

Returns: Void

Syntax: Sub Scale(scaleFactor As Double, aboutX As Double, aboutY As Double)

PolygonWriter
An MWOffice PolygonWriter object.

Properties

Name Data Type Description


LayerMapping String Returns/sets the current layer mapping to be used by shapes
added by the PolygonWriter object.
LayerName String Returns/sets the current layer name to be used by shapes
added by the PolygonWriter object.
PCBPinObject Boolean Returns/Sets a value that indicates if the polygons added by
the PolygonWriter should marked as a PCB pins when the
are created.
UseProcessLayers Boolean Returns/sets the if the shapes added by the PolygonWriter
object should be set to use process layers.

Methods
AddPolygon

Description: Adds a new polygon to the PolygonWriter target design using the information specified in the PolygonRecord
object.

Returns: DrawingObject

Syntax: Function AddPolygon(pRecord As PolygonRecord) As DrawingObject

CachePolygon

Description: Add the polygon shape information to a named set of shapes to be created later.

Returns: Void

Syntax: Sub CachePolygon(Name As String, pRecord As PolygonRecord)

2220 NI AWR Design Environment


PathRecord

CreateCachedPolygons

Description: Add the polygon shapes from the named collection to the design with the given transform values.

Returns: Void

Syntax: Sub CreateCachedPolygons(Name As String, [offsetDx As Double = 0], [offsetDy As Double = 0], [rotCCW
As Double = 0], [rotAboutX As Double = 0], [rotAboutY As Double = 0], [Mirror As Boolean = 0], [mirrorAboutX As
Double = 0], [Scale As Double = 1], [scaleAboutX As Double = 0], [scaleAboutY As Double = 0])

CreatePolygonRecord

Description: Returns a new PolygonReference reference to be used to create polygon objects.

Returns: PolygonRecord

Syntax: Function CreatePolygonRecord() As PolygonRecord

PathRecord
An MWOffice PathRecord object.

Properties

Name Data Type Description


PCBPinObject Boolean Returns/Sets a value that indicates if the path object should
marked as a PCB pin when it is created.

Methods
AddArcSegment

Description: Adds a new arc segment to the current path object in the PathRecord object.

Returns: Void

Syntax: Sub AddArcSegment(x2 As Double, y2 As Double, cx As Double, cy As Double, dir As mwDrawingArcDirection)

AddSegment

Description: Adds a new segment to the current path object to in the PathRecord object.

Returns: Void

Syntax: Sub AddSegment(x2 As Double, y2 As Double)

Clear

Description: Clears the PathRecord of all path information so it can be reused.

Returns: Void

Syntax: Sub Clear()

API Scripting Guide 2221


PathWriter

Mirror

Description: Mirrors the object represented by the PathRecord object about the y-axis.

Returns: Void

Syntax: Sub Mirror(aboutX As Double)

Offset

Description: Adds an offset to the object represented by the PathRecord object.

Returns: Void

Syntax: Sub Offset(dx As Double, dy As Double)

PathBegin

Description: Method to indicate the start of a new path object to the PathRecord object.

Returns: Void

Syntax: Sub PathBegin(x1 As Double, y1 As Double)

PathEnd

Description: Method to indicate the ned of the path object to the PathRecord object.

Returns: Void

Syntax: Sub PathEnd()

Rotate

Description: Adds a counter-clockwise rotation to the object represented by the PathRecord object.

Returns: Void

Syntax: Sub Rotate(angleCCW As Double, aboutX As Double, aboutY As Double)

Scale

Description: Adds a scale factor to the object repersented by the PathRecord object.

Returns: Void

Syntax: Sub Scale(scaleFactor As Double)

PathWriter
An MWOffice PathWriter object.

Click to see examples

2222 NI AWR Design Environment


PathWriter

Properties

Name Data Type Description


EndType mwPathEndType Gets/sets the path end style to be used by shapes added by
the PathWriter object.
LayerMapping String Gets/sets the current layer mapping to be used by shapes
added by the PathWriter object.
LayerName String Gets/sets the current layer name to be used by shapes added
by the PathWriter object.
MiterAmount Double Gets/sets the path miter amount to be used by shapes added
by the PathWriter object.
MiterStyle mwPathMiterType Gets/sets the path miter style to be used by shapes added
by the PathWriter object.
PCBPinObject Boolean Returns/Sets a value that indicates if the path objects added
by the PathWriter should marked as a PCB pins when they
are created.
UseProcessLayers Boolean Gets/sets if the shapes added by the PathWriter object sould
be set to ues process layers.
Width Double Gets/sets the path width to be used by shapes added to the
PathWriter object.

Methods
AddPath

Description: Adds a new path to the PathWriter target desing using the information specified in the PathRecord object.

Returns: DrawingObject

Syntax: Function AddPath(pRecord As PathRecord) As DrawingObject

CachePath

Description: Add the path shape information to a named set of shapes to be created later.

Returns: Void

Syntax: Sub CachePath(Name As String, pPathRecord As PathRecord)

CreateCachedPaths

Description: Add the path shapes from the named collection to the design with the given transform values.

Returns: Void

Syntax: Sub CreateCachedPaths(Name As String, [offsetDx As Double = 0], [offsetDy As Double = 0], [rotCCW As
Double = 0], [rotAboutX As Double = 0], [rotAboutY As Double = 0], [Mirror As Boolean = 0], [mirrorAboutX As
Double = 0], [Scale As Double = 1])

API Scripting Guide 2223


SelectedDrawingObjects

CreatePathRecord

Description: Returns a new PathRecord reference to be used to create path objects.

Returns: PathRecord

Syntax: Function CreatePathRecord() As PathRecord

SelectedDrawingObjects
A collection of MWOffice SelectedDrawingObject objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
FirstSelectedIndex Long Returns the index of the first selected object.
Item DrawingObject Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Boolean

Syntax: Function Add(DrawingObject As DrawingObject) As Boolean

AddAll

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Boolean

Syntax: Function AddAll() As Boolean

AddFromArea

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Boolean

Syntax: Function AddFromArea(Left As Double, Top As Double, Right As Double, Bottom As Double, [Type As
mwAreaAddType = 0]) As Boolean

AddFromRegion

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Boolean

2224 NI AWR Design Environment


GroupDrawingObjects

Syntax: Function AddFromRegion(XYPoints As SafeArray, [Type As mwAreaAddType = 0]) As Boolean

AddOverlapped

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Boolean

Syntax: Function AddOverlapped(ppShape As Shape, [Type As mwAreaAddType = 0]) As Boolean

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

GroupDrawingObjects
A collection of MWOffice GroupDrawingObject objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DrawingObject Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Boolean

Syntax: Function Add(DrawingObject As DrawingObject) As Boolean

Remove

Description: Removes a specific member from a collection.

API Scripting Guide 2225


EMStructureInfo

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

EMStructureInfo
An MWOffice EMStructure Info object.

Click to see examples

Properties

Name Data Type Description


CacheSize Long Returns the recommended cache size for solving the
Electromagnetic Structure.
MemoryRequirement Long Returns the memory requirements to solve the
Electromagnetic Structure.
MeshSize Long Returns the mesh size of the Electromagnetic Structure.
PhysicalMemory Long Returns the physical memory available to solve the
Electromagnetic Structure.
TimePerFrequency Double Returns the time required to solve the Electromagnetic
Structure at each frequency.
TotalTime Double Returns the total time required to solve the Electromagnetic
Structure.

EMInitializationRecord
A MWOffice EMInitializationRecord object.

Properties

Name Data Type Description


EMMappingName String Returns/sets the EMMapping name to be used when doing
LPF initialization.
GlobalDocumentName String Returns/sets the name of the global definition document
containing the Stackup element when doing Stackup
initialization.
ProcessDefinitionName String Returns/sets the ProcessDefinition name when doing LPF
initialization.
StackupName String Returns/sets the name of the stackup element in the global
definition document when doing Stackup initialization.
Type mwEMInitType Returns/sets the type of initialization to be performed on
the EMStructure object

EMStructure
An MWOffice EMStructure object.

2226 NI AWR Design Environment


EMStructure

Click to see examples

Properties

Name Data Type Description


CanPaste Boolean Returns a value that determines the clipboard contents can
be pasted to the object.
Changed Boolean Returns/Sets a value that indicates if the object has changed
and needs to be saved or resimulated.
DrawingObjects DrawingObjects Returns a reference to a collection of DrawingObjects.
EMStructureTests ComponentTests Returns a reference to a collection of ComponentTest
objects.
Embedded Boolean Returns if the EMStructre is embedded in the project or
linked externally.
Enabled Boolean Returns/sets a value which specifies if the Electromagnetic
Structure is enabled.
Enclosure Enclosure Returns a reference to an Enclosure object.
Equations Equations Returns a reference to a collection of Equation objects.
FilePath String Returns the EMStructure file path.
Frequencies Frequencies Returns a reference to a collection of Frequency objects.
Info EMStructureInfo Returns a reference to an Electromagnetic Structure Info
object.
LockLevel mwDiagramLockLevel Returns a value that specifies the lock level of the
EMStructure object
MaterialLayers MaterialLayers Returns a reference to a collection of MaterialLayer objects.
Name String Returns/Sets the name used in code to identify an object.
Options Options Returns a reference to a collection of Option objects.
Ports EMPorts Returns a reference to an EMPorts collection.
Properties Properties Returns a reference to a collection of Property objects.
Schematic Schematic Returns a reference to a MWOffice Schematic object.
SelectedObjects SelectedDrawingObjects Returns a reference to a collection of DrawingObjects.
ShapeModifiers ShapeModifiers Returns a reference to a collection of ShapeModifier objects.
Shapes Shapes Returns a reference to a collection of Shape objects.
SimulationDirty Boolean Returns if the current simulation state is dirty for the
EMStructure object.
SimulationLog String Returns the contents of the EM simulation log
SimulationState Long Returns the current simulation state for the EMStructure
object.
Simulator mwEmSimulator Returns/sets the simulator for the EMStructure object.
UseProjectFrequencies Boolean Returns/sets a value which specifies if the global project
frequencies should be used for analysis.

API Scripting Guide 2227


EMStructure

Name Data Type Description


UseProjectOptions Boolean Returns/sets a value which specifies if the global project
options should be used.
Windows Windows Returns a reference to a collection of Window objects.

Methods
Activate

Description: Activates the objects.

Returns: Void

Syntax: Sub Activate()

CopyToClipboard

Description: Copies the object to the system clipboard.

Returns: Boolean

Syntax: Function CopyToClipboard() As Boolean

CopyToClipboardEx

Description: Copies the object to the system clipboard.

Returns: Boolean

Syntax: Function CopyToClipboardEx(Type As mwDesignViewType) As Boolean

CopyViewToClipboard

Description: Copies the object to the system clipboard.

Returns: Boolean

Syntax: Function CopyViewToClipboard([Type As mwDesignViewType = 0]) As Boolean

CreateMesh

Description: Generates a mesh for the current EMStructure. A mesh Annotation must be enabled to view the mesh.

Returns: Void

Syntax: Sub CreateMesh()

Export

Description: Exports a design document file from MWOffice.

Returns: Void

Syntax: Sub Export(Filename As String)

2228 NI AWR Design Environment


EMStructure

ExportEmInputData

Description: Exports the EMStructure EM Socket input data file to the specified filename.

Returns: Void

Syntax: Sub ExportEmInputData(Filename As String)

ExportEmInputDataXML

Description: Exports the EMStructure EM Socket input data file to the specified filename in XML format.

Returns: Boolean

Syntax: Function ExportEmInputDataXML(Filename As String, [Type As mwEMInputDataXMLType = 0]) As Boolean

ForceResimulate

Description: Marks the EMStructure as changed and clears existing results for resimulation.

Returns: Boolean

Syntax: Function ForceResimulate() As Boolean

InvokeCommand

Description: Invoke a menu command by specifying the name for the command. Arguments must be suppled for any
required input.

Returns: Void

Syntax: Sub InvokeCommand(CommandName As String, [Arguments], [pRet])

LockDiagram

Description: Changes the lock level of the EMStructure object to the given lock level

Returns: Boolean

Syntax: Function LockDiagram(NewLevel As mwDiagramLockLevel, [Password As String = ""]) As Boolean

NewWindow

Description: Displays the object in new window.

Returns: Window

Syntax: Function NewWindow([WindowType As mwWindowType = 3]) As Window

Paste

Description: Pastes the system clipboard to the object.

Returns: Boolean

API Scripting Guide 2229


EMStructure

Syntax: Function Paste(x As Double, y As Double, [CCWRotation As Double = 0], [Flipped As Boolean = 0]) As
Boolean

PasteRelative

Description: Pastes the system clipboard to the object.

Returns: Boolean

Syntax: Function PasteRelative(dx As Double, dy As Double, [CCWRotation As Double = 0], [Flipped As Boolean =
0]) As Boolean

PrintOut

Description: Sends the object to the current printer.

Returns: Void

Syntax: Sub PrintOut()

PrintOutEx

Description: Sends the object to the current printer.

Returns: Boolean

Syntax: Function PrintOutEx([Type As mwDesignViewType = 0]) As Boolean

PrintView

Description: Sends the object to the current printer.

Returns: Boolean

Syntax: Function PrintView([Type As mwDesignViewType = 0]) As Boolean

Simulate

Description: Submit the EMStructure document for simulation.

Returns: Boolean

Syntax: Function Simulate(pDefaultDataSetName As String) As Boolean

SimulationLogClear

Description: Clears the EM simulation log

Returns: Void

Syntax: Sub SimulationLogClear()

2230 NI AWR Design Environment


EMStructure

StartCommand

Description: Start a menu command by specifying the name for the command. The user will need to complete any
required input.

Returns: Void

Syntax: Sub StartCommand(CommandName As String, [pRet])

Update

Description: Update the layout stucture to be current.

Returns: Void

Syntax: Sub Update()

Options For Axiem

Number Name Description


1 AWR_JobSchedulerMaxProcs Maximum number of logical processors (as seen by OS) to
allocate for the job (0 = Use all available, -1 = Use all but
one, etc.)
2 AWR_JobSchedulerMinProcs Minimum number of logical processors (as seen by OS) to
allocate for the job (0 = Use all available, -1 = Use all but
one, etc.)
3 AWR_JobSchedulerThreadsPerProc The number of computational threads created for each
allocated logical processor (Recommended settings:
Axiem=1-2, Analyst=1)
4 AWR_JobSchedulerJobOSPriority The Operating System priority to assign to the job process
once it's running. (Default=Normal, or the value set in the
user.ini file, if any)
5 AWR_JobSchedulerJobRemotePreference Preference for how to dispatch the job if remote job servers
are available
6 AWR_JobSchedulerJobPerfPreference The preferred processor performance of the server to be
assigned to the job, if the job is executed remotely.
7 AWR_JobSchedulerJobMemCapPreference The preferred memory capacity of the server to be assigned
to the job, if the job is executed remotely.
8 AWR_JobSchedulerJobRunAsMWOJob ALL simulations for this document will be done in a separate
MWO simulation process
9 AWR_UseResultsForPartialSwp Allow a swept parameter simulation to use the results when
some of the sweep points failed to simulate
10 Mesh_meshDensity Specify mesh density
11 Mesh_maxX X max of cells per subsection limits
12 Mesh_maxY Y max of cells per subsection limits
13 Mesh_minX X min of cells per subsection limits
14 Mesh_minY Y min of cells per subsection limits

API Scripting Guide 2231


EMStructure

Number Name Description


15 Mesh_conformalCells Conformal meshing
16 Mesh_trngleCells Allow triangle meshing
17 SpecGlobalEquations Specify the global definition document to use as the global
equations for this document
18 Solver Type Select the solver type
19 eMCO_USE_DIRECT_BELOW Use Direct Solver when the # of unknowns is less than this
value
20 eMCO_LowFSolverGauge Low Frequency Solver will be used when max edge length
is less than this fraction of a wavelength
21 eMCO_eDeEmbeddingMethod Allow Global De-Embedding of ports. Port specific
de-embedding enabled at port level
22 eMCO_COUPLEDLINE_LIMIT_RATIO Use coupled line de-embedding when dist. between ports /
dist. to ground is less than this ratio
23 eMCO_YmatGmin Minimum amount of conductance to add between ground
and nodes to prevent singular matrices during de-embedding
and DC extrapolation
24 eMCO_YmatRmin Minimum series resistance between nodes to prevent
singular matrices during de-embedding and DC extrapolation
25 eMCO_YCondMethod Method used to determine when minimum conductance is
added to nodes during de-embedding
26 eAAFS_EnforcePassivity Enforce passivity of the resulting port parameters
27 eMCO_YEnfReciprocity Enforce reciprocity of the resulting port parameters
28 eMCO_YEnfReciprocalMethod Reciprocity enforcement method
29 eAAFS_UseAFS Enable Advanced Frequency Sweep
30 eMCO_AFS_TOL AFS Tolerance
31 eMCO_AFS_MAX_PTS Maximum number of simulation points (The high default
value means that AFS will simulate all requested frequencies
if convergence is not reached.)
32 eAAFS_BandLimit Enable AFS to run on a limited bandwidth between Start
Freq and Stop Freq
33 eAAFS_BandStart AFS Band Start Frequency in GHz
34 eAAFS_BandStop AFS Band Stop Frequency in GHz
35 eAPS_PORTS_AUTO_GROUNDING Enable automatic determination of ground reference
36 eAPS_PAG_ViaClearanceRatio This ratio X shortest-distance-to-ground sets the minimum
clearance between a port and a via for the port to be set as
an explicit port. If after extension the port is still within this
distance of a via, the port is set to implicit. Default is 0.5(x
Shortest-distance-to-ground)
37 eAPS_PAG_DualGndCapRatioLimit Explicit up/down grounding capacitance ratio limit. A
submissive ground limit will be added if the approximate
ratio of the capacitance to that ground vs the capacitance to
the dominant ground exceeds this value.

2232 NI AWR Design Environment


EMStructure

Number Name Description


38 eAPS_PAG_MaxInsetDistance Used in the case of plated or multilayer lines where an
inset/outset in seen between stacked metal layers.
Determines the horizontal extend used when determining
local connectivity between stacked shapes.
39 eAPS_PAG_MaxTraceWidth Used in determining if a shape underlying a port can be used
as a local ground. Shapes with an effective width parameter
(W=2*area/perimeter) greater than this value would be
considered a valid local ground candidate. The default value
of 0 for this parameter means that all shapes can be
considered valid local ground candidates.
40 eAPS_PAG_AllowExplictInterior If enabled Explicit grounding of interior ports will be
considered during auto port setup, otherwise implicit
grounding (None) will be used for these ports.
41 eAPS_PAG_ImplicitGndWaveLenMax A multiple of a wavelength at the highest simulation
frequency. Implicit grounding will be used for edge ports
which have an electrical length to the nearest ground less
than this value. For electrical distances to ground exceeding
this value, explicit grounding will be used.
42 eAPS_PORTS_AUTO_EXTENSION Enable obstruction aware auto extension of ports
43 eAPS_PAE_DistMultiple Used to determine an optimal extension length as a multiple
of Max(port width, min distance to ground). If a port can
be extended to this length without being obstructed, then
the length of the extension is determined by this parameter.
44 eAPS_PAE_ClearanceDistance Used to classify local obstructions in the horizontal direction
(X/Y) relative to the closest distance to ground from the
port. If the extension of a port causes the horizontal distance
between the extension and a secondary object to be less than
this value, the extension would be considered obstructed.
45 eAPS_PAE_ExtSearchAngle Used to classify local obstructions near the connection to
the embedded structure. This angle determines how close
an object can be relative to a port before it is considered an
obstruction and blocks the addition of an extension during
Auto Port Setup. A value of 0 represents the maximum
clipping of the exclusion region
46 eAPS_PAE_MinVertClearDistUp Used to classify local obstructions in the vertical direction
above the port. If zero, the distance to the nearest local
ground or boundary above the port is used. If non-zero, this
is a multiple of the closest distance to ground (up/dn) from
the port as long as this dimension is less than the distance
to ground in the upward direction. If the extension of a port
causes the vertical distance between the extension and a
secondary object above to be less than the value determined
by this parameter, the extension would be considered
obstructed.
47 eAPS_PAE_MinVertClearDistDn Used to classify local obstructions in the vertical direction
below the port. If zero, the distance to the nearest local

API Scripting Guide 2233


EMStructure

Number Name Description


ground or boundary below the port is used. If non-zero, this
is a multiple of the closest distance to ground (up/dn) from
the port as long as this dimension is less than the distance
to ground in the downward direction. If the extension of a
port causes the vertical distance between the extension and
a secondary object below to be less than the value
determined by this parameter, the extension would be
considered obstructed.
48 eAPS_PAE_MinExtAsPctOfDesiredExt A fraction of the optimum extension length used to specify
that that an extension is too short to be useful and thus no
extension should be used. Used to force all extended ports
to be a minimum extension length or not be extended at all.
49 eAPS_PORTS_AUTO_GROUPING Enable automatic grouping (Mutual/Coupled) of ports based
on orientation and proximity
50 eAPS_PAG_MaxClusterRadius Used to limit port groupings based on port proximity relative
to the closest distance to ground from the port. Horizontal
separation distances between ports below this ratio would
be considered valid group candidates.
51 eAPS_MutalGroupExtensions If Enabled, ports will be extended if possible, give the
restrictions of Group clearance ratio and Via clearance ratio
options.
52 eAPS_MutalGroupClearance Used to limit port groupings based on port proximity relative
to the closest distance to ground from the port. Horizontal
separation distances between ports below this ratio would
be considered valid group candidates.
53 eAX_MATRIX_ENTRY_ACCURACY Matrix Entry Accuracy
54 eMtxCalc_2DEnhSISimp Correctly model loss for thin mesh at high frequency
55 eMCO_Alt_Via_Res Use via width when determining surface impedance for vias
56 eMCO_MAX_ITER Maximum # of iterations used to obtain convergence before
solver failure
57 eMCO_GMRES_TOL The tolerance used to determine iterative solver success,
relative to previous iteration
58 eMCO_SUBSPACE_SIZE Retain information from the previous iterations. Increases
memory proportional to size times # unknowns
59 eMCO_ENABLE_MRHS Allows the solution of multiple ports (right hand sides) at
once when using an iterative matrix solver. At the expense
of increased memory usage, the solution process can be
expedited by as much as 2x when solving for multiple right
hand sides (ports) at once.
60 eAX_PRECONDITIONER_EFFICIENCY Preconditioner Efficiency
61 eAX_COMPRESSION_ACCURACY Determines the accuracy of approximation used to represent
the moment matrix
62 eAX_meshDecimation The default decimation control for shapes within the
document, this default control can be overridden on

2234 NI AWR Design Environment


EMStructure

Number Name Description


individual shapes within the document. The decimation
control specifies how aggressively the points defining a
shape will be modified in order to result in a simplified final
mesh. This control is relative, with with 5 possible states
None/Low/Medium/High/Very High. A setting of None
allows for modification of only degenerate polygons, such
as two polygon points being duplicate or nearly so. Very
high decimation allows extreme modification of polygon
points to reduce the number of mesh elements.
63 eAX_meshZeroThickness Determines the default behavior of how conductors in the
document are represented in the mesh, this default control
can be overridden on individual shapes within the document.
If zero thickness meshes are enabled, conductors are meshed
as infinitely thin. Otherwise a conductor is modeled with
finite thickness (top,bottom and side facets).
64 eAX_MESH_DECIMATION_OPTIONS On - Use mesher decimation and shape clean-up at normal
level. Off - Use shape clean-up at lowest setting if smallest
edge length is below minimum. Auto - If geometry has used
shape simplification rules, use shape clean-up at lowest
settings, else same as behavior as On.
65 eMCO_HARF_Error_Threshold The error threshold for High Aspect Ratio Facets (HARF).
Meshes with facets aspects higher than this value will not
be simulated.
66 eMD_RECORD_EXTREMES This parameter enables verbose printing of mesh extremes
in the status log.
67 eMCO_Path_Detection Enables extraction of rectangular sections within input
polygon regions
68 eAX_meshEdgeMeshing Determines if the final mesh contains narrow facets along
open edges of thin metal. Width of the edge mesh facets
will be equal to the specified 'Min Edge Length' if possible.
Using edge meshing results in greater simulation accuracy
at the expense of increased problem size because it allows
for high frequency current crowding.
69 eMD_NoEdgeMeshForThick This setting determines if conductors meshed as thick metal
will use edge meshing (See 'Use Edge Meshing' and 'Model
as Zero Thickness'). Typically edge meshing on thick metal
is not required, because the sidewall mesh captures the
current crowding effect at high frequencies. Edge meshing
thick conductors can result in better formed meshes as it
allows better transitions between via, thin and thick metals
if all are edge meshed.
70 eMD_EdgeMeshVias This setting determines if vias will use edge meshing (See
'Use Edge Meshing'). Typically edge meshing vias is
unnecessary due to their small cross sectional dimensions.
Edge meshing of vias in better formed meshes as it allows
better transitions between via, thin and thick metals if all
are edge meshed.

API Scripting Guide 2235


EMStructure

Number Name Description


71 eMD_MinimalZMesh This setting effects the meshing of vertical facets in vias or
thick conductors that is very similar to 'Edge Meshing' in
the x/y plane. While edge meshing is typically not needed
in the z direction, it can increase simulation accuracy near
geometrical locations where the current transitions from
vertical to horizontal facets.
72 eMCO_DO_USE_ABS_DIMS Determines the length dimensions units on this dialog.
Relative to cell grid - Relative to enclosure grid. Absolute
dimensions - In project units
73 eMCO_MESH_MIN_EDGE_RATIO The minimum desired edge length in the mesh relative to
the enclosure grid. This dimension will determine the width
of edge mesh if edge meshing is enabled. Further this value
will influence decimation if enabled.
74 eMCO_MESH_MIN_FEATURE_RATIO The minimum feature size retained in the mesh relative to
the enclosure grid.This dimension determines minimum
feature size required to be retained in the mesh.Features in
the mesh below this value may be eliminated in order to
improve the mesh quality.Importantly, lines with widths
below this value may eliminated from the mesh.A value of
zero means that the feature size is determined as a fractional
ratio of the Min Edge Length determined by the decimation
level.This last behavior is retained for legacy reasons.
75 eMCO_MESH_MIN_EDGE_DIM The minimum desired edge length in project units. This
dimension will determine the width of edge mesh if edge
meshing is enabled. Further this value will influence
decimation if enabled.
76 eMCO_MESH_MIN_FEATURE_DIM The minimum feature size retained in the mesh in project
units. This dimension determines minimum feature size
required to be retained in the mesh. Features in the mesh
below this value may be eliminated in order to improve the
mesh quality. Importantly, lines with widths below this
value may eliminated from the mesh. A value of zero means
that the feature size is determined as a fractional ratio of the
Min Edge Length determined by the decimation level. This
last behavior is retained for legacy reasons.
77 eAX_meshMaxAspectRatio Max desired geometrical edge length in the mesh relative
to the 'Min Edge Length'. Importantly the resulting max
geometrical edge length can be reduced beyond this desired
length if it exceeds the max electrical edge length. The max
electrical edge length is determined as fraction of the
minimum electrical wavelength. This fraction is determined
by the 'Mesh Density' setting and ranges from 1/32 to 1/8.
The max electrical wavelength is determined at the 'Meshing
Frequency' in the layer of the stackup with the highest index
of refraction.
78 eMCO_MAX_T_PLATED_LINE A port connected to a stacked configuration of conductors
and vias can be meshed in two ways depending upon the

2236 NI AWR Design Environment


EMStructure

Number Name Description


total thickness of the stacked configuration. If the total
thickness is less than the specified dimension, the port will
be meshed to excite the entire vertical cross section of the
stacked metal as if it was one metal (plated metal). If the
total thickness of the stacked configuration exceeds the
specified thickness, the port will be meshed as if it is
exciting the specified conductor of a via stack. The stack
thickness is determined locally at the x/y location of the
port and includes metals looking up and down in the z
direction.
79 AnimateUseLogColorScale Returns/sets if a color log scale should be used for
animation.
80 AnimateActiveCurrentLayer Returns/sets if only currents on the active layer should be
animated.
81 AnimateActive2DLayerOnly Returns/sets if only the active layer should be animated.
82 AnimateCurrentXComponents Returns/sets if the X current components should be
animated.
83 AnimateCurrentYComponents Returns/sets if the Y current components should be
animated.
84 Animate2DFramesPerCycle Returns/sets the number of 2D animation frames per cycle.
85 Animate3DFramesPerSycle Returns/sets the number of 3D animation frames per cycle.
86 AnimateLocScaleFactor Returns/sets the log color scale factor to be used in the
animation.
87 AnimationLightenFactor Returns/sets the lighten color scale factor for the animation.
88 AnimateStandaingWave Returns/sets if standing waves should be displayed in the
animation.
89 AnimationHideArrows Returns/sets if current arrows should be hidden during
animation.
90 HideNonActiveLayers Returns/sets if all non-active layers should be hidden in EM
layout.
91 FreezeNonActiveLayers Returns/sets if all non-active layers should be frozen in EM
layout.
92 ShowNonActiveHatch Returns/sets if hatch should be shown in non-active layers
in EM layout.
93 ShowBoundingBox Returns/sets if the boundary box should be shown in EM
layout.
94 ShowShapeOutlines Returns/sets if outlines only should be displayed in EM
layout.
95 ShowRedBlueStereo3D Returns/sets if stereo 3D should be shown in EM layout.
96 ShouldExtractLineType Returns/sets if line type should be modeled as it is in EM
layout.
97 BoundyLineThickness Returns/sets the boundary line thickness.

API Scripting Guide 2237


EMStructure

Number Name Description


98 ShapeLineThickness Returns/sets the shape line thickness.
99 HatchLineThickness Returns/sets the hatch line thickness.
100 ArrowLineThickness Returns/sets the arrow line thickness.
101 MeshConformalFill MeshConformalFill
102 MeshTriangleFill Returns/sets if triangle mesh cells should be used.
103 MeshDensityLevel Returns/sets the mesh density level.
104 MeshXMinCellsPerSubsection Returns/sets the minimum number of cells per subsection
in the X direction.
105 MeshYMinCellsPerSubsection Returns/sets the minimum number of cells per subsection
in the Y direction.
106 MeshXMaxCellsPerSubsection Returns/sets the maximum number of cells per subsection
in the X direction.
107 MeshYMaxCellsPerSubsection Returns/sets the maximum number of cells per subsection
in the Y direction.
108 MeshZeroThickness MeshZeroThickness
109 MeshEdgeMeshing Returns/sets the mesh edge meshing
110 MeshDecimation Returns/sets the mesh decimation
111 MeshMaxAspectRatio Returns/sets the mesh max aspect ratio
112 ShowCursorCoordLabel Returns/sets if cursor coordinates should be displayed.
113 DisplayAbsoluteCoords Returns/sets if cursor should be absolute or delta
coordinates.
114 CoordDisplayUseCellUnits Returns/sets if coordinates should be absolute or relative to
cell.
115 SolidCoordDisplayBackground Returns/sets if cursor coordinate display should use a solid
background.
116 OrthogonalDrawingMode Returns/sets if orthogonal drawing mode should be used.
117 DrawGridSnap Returns/sets if the snap grid should be displayed.
118 SnapToGrid Returns/sets if the cursor should snap to the snap grid.
119 GridSnapValue Returns/sets the value for the snap grid.
120 NumberInterpolationPoints Returns/sets the number of points used for interpolation.
121 InterpolationWindowSize Returns/sets the window size used for interpolation.
122 InterpolationSplineOrder Returns/sets the spline order used for interpolation.
123 InterpolationMethod Returns/sets the method used for interpolation.
124 InterpolationCoordinates Returns/sets the interpolation coordinate system type.
125 EnableInterpolation Returns/sets if parameter interpolation is enabled in EM
documents
126 ConsiderPassiveForNoise Returns/sets if passive elements should be considered in
noise calculations.

2238 NI AWR Design Environment


EMStructure

Number Name Description


127 SchematicSymbolName Returns sets the default symbol name used when the
document is placed as a subcircuit.

Options For EMSight

Number Name Description


1 AWR_JobSchedulerMaxProcs Maximum number of logical processors (as seen by OS) to
allocate for the job (0 = Use all available, -1 = Use all but
one, etc.)
2 AWR_JobSchedulerMinProcs Minimum number of logical processors (as seen by OS) to
allocate for the job (0 = Use all available, -1 = Use all but
one, etc.)
3 AWR_JobSchedulerThreadsPerProc The number of computational threads created for each
allocated logical processor (Recommended settings:
Axiem=1-2, Analyst=1)
4 AWR_JobSchedulerJobOSPriority The Operating System priority to assign to the job process
once it's running. (Default=Normal, or the value set in the
user.ini file, if any)
5 AWR_JobSchedulerJobRemotePreference Preference for how to dispatch the job if remote job servers
are available
6 AWR_JobSchedulerJobPerfPreference The preferred processor performance of the server to be
assigned to the job, if the job is executed remotely.
7 AWR_JobSchedulerJobMemCapPreference The preferred memory capacity of the server to be assigned
to the job, if the job is executed remotely.
8 AWR_JobSchedulerJobRunAsMWOJob ALL simulations for this document will be done in a separate
MWO simulation process
9 AWR_UseResultsForPartialSwp Allow a swept parameter simulation to use the results when
some of the sweep points failed to simulate
10 Mesh_meshDensity Specify mesh density
11 Mesh_maxX X max of cells per subsection limits
12 Mesh_maxY Y max of cells per subsection limits
13 Mesh_minX X min of cells per subsection limits
14 Mesh_minY Y min of cells per subsection limits
15 Mesh_conformalCells Conformal meshing
16 Mesh_trngleCells Allow triangle meshing
17 SpecGlobalEquations Specify the global definition document to use as the global
equations for this document
18 UseFastFrequencySweep Returns/sets if fast frequency sweep should be used.
19 DeembedPorts Returns/sets if ports and feed lines should be de-embedded.
20 ComputeLoadedCurrents Returns/sets if loaded currents should be computed.
21 UseSameSizeBox Returns/sets if the same size box should be used for
de-embedded circuit.

API Scripting Guide 2239


EMStructure

Number Name Description


22 SaveResultsInDocument Returns/sets if the results should be saved in the EM
document.
23 MaxDifferentialOrder Returns/sets the maximum differential order computed.
24 MatrixSolverType Returns/sets the matrix solver type used for analysis.
25 UseSinglePrecision Returns/sets if single precision should be used to save
memory.
26 FreqSweepErrorTolerance Returns/sets if fast frequency sweep error tolerance level.
27 UseRelativeError Returns/sets if relative error should be used.
28 IterativeSolverTolerance Returns/sets the iterative solver error tolerance level.
29 AFSEnable Returns/sets if advanced frequency sweep should be enabled.
30 AFSErrorTypeRelative Returns/sets if the error type should be relative or absolute.
31 AFSErrorTolerance Returns/sets the error tolerance for the advanced frequency
sweep in dB.
32 AFSGridPointCount Returns/sets the number of grid points used for the advanced
frequency sweep.
33 AFSMaxPointCount Returns/sets the advance frequency sweep maximum point
count.
34 AFSSpecifyBand Returns/sets with to use a specified band for the advanced
frequency sweep.
35 AFSBandStartFrequency Returns/sets the start frequency for the advanced frequency
sweep band.
36 AFSBandStopFrequency Returns/sets the stop frequency for the advanced frequency
sweep band.
37 AnimateUseLogColorScale Returns/sets if a color log scale should be used for
animation.
38 AnimateActiveCurrentLayer Returns/sets if only currents on the active layer should be
animated.
39 AnimateActive2DLayerOnly Returns/sets if only the active layer should be animated.
40 AnimateCurrentXComponents Returns/sets if the X current components should be
animated.
41 AnimateCurrentYComponents Returns/sets if the Y current components should be
animated.
42 Animate2DFramesPerCycle Returns/sets the number of 2D animation frames per cycle.
43 Animate3DFramesPerSycle Returns/sets the number of 3D animation frames per cycle.
44 AnimateLocScaleFactor Returns/sets the log color scale factor to be used in the
animation.
45 AnimationLightenFactor Returns/sets the lighten color scale factor for the animation.
46 AnimateStandaingWave Returns/sets if standing waves should be displayed in the
animation.
47 AnimationHideArrows Returns/sets if current arrows should be hidden during
animation.

2240 NI AWR Design Environment


EMStructure

Number Name Description


48 HideNonActiveLayers Returns/sets if all non-active layers should be hidden in EM
layout.
49 FreezeNonActiveLayers Returns/sets if all non-active layers should be frozen in EM
layout.
50 ShowNonActiveHatch Returns/sets if hatch should be shown in non-active layers
in EM layout.
51 ShowBoundingBox Returns/sets if the boundary box should be shown in EM
layout.
52 ShowShapeOutlines Returns/sets if outlines only should be displayed in EM
layout.
53 ShowRedBlueStereo3D Returns/sets if stereo 3D should be shown in EM layout.
54 ShouldExtractLineType Returns/sets if line type should be modeled as it is in EM
layout.
55 BoundyLineThickness Returns/sets the boundary line thickness.
56 ShapeLineThickness Returns/sets the shape line thickness.
57 HatchLineThickness Returns/sets the hatch line thickness.
58 ArrowLineThickness Returns/sets the arrow line thickness.
59 MeshConformalFill MeshConformalFill
60 MeshTriangleFill Returns/sets if triangle mesh cells should be used.
61 MeshDensityLevel Returns/sets the mesh density level.
62 MeshXMinCellsPerSubsection Returns/sets the minimum number of cells per subsection
in the X direction.
63 MeshYMinCellsPerSubsection Returns/sets the minimum number of cells per subsection
in the Y direction.
64 MeshXMaxCellsPerSubsection Returns/sets the maximum number of cells per subsection
in the X direction.
65 MeshYMaxCellsPerSubsection Returns/sets the maximum number of cells per subsection
in the Y direction.
66 MeshZeroThickness MeshZeroThickness
67 MeshEdgeMeshing Returns/sets the mesh edge meshing
68 MeshDecimation Returns/sets the mesh decimation
69 MeshMaxAspectRatio Returns/sets the mesh max aspect ratio
70 ShowCursorCoordLabel Returns/sets if cursor coordinates should be displayed.
71 DisplayAbsoluteCoords Returns/sets if cursor should be absolute or delta
coordinates.
72 CoordDisplayUseCellUnits Returns/sets if coordinates should be absolute or relative to
cell.
73 SolidCoordDisplayBackground Returns/sets if cursor coordinate display should use a solid
background.
74 OrthogonalDrawingMode Returns/sets if orthogonal drawing mode should be used.

API Scripting Guide 2241


EMStructure

Number Name Description


75 DrawGridSnap Returns/sets if the snap grid should be displayed.
76 SnapToGrid Returns/sets if the cursor should snap to the snap grid.
77 GridSnapValue Returns/sets the value for the snap grid.
78 NumberInterpolationPoints Returns/sets the number of points used for interpolation.
79 InterpolationWindowSize Returns/sets the window size used for interpolation.
80 InterpolationSplineOrder Returns/sets the spline order used for interpolation.
81 InterpolationMethod Returns/sets the method used for interpolation.
82 InterpolationCoordinates Returns/sets the interpolation coordinate system type.
83 EnableInterpolation Returns/sets if parameter interpolation is enabled in EM
documents
84 ConsiderPassiveForNoise Returns/sets if passive elements should be considered in
noise calculations.
85 SchematicSymbolName Returns sets the default symbol name used when the
document is placed as a subcircuit.

Options For ACE

Number Name Description


1 AWR_JobSchedulerMaxProcs Maximum number of logical processors (as seen by OS) to
allocate for the job (0 = Use all available, -1 = Use all but
one, etc.)
2 AWR_JobSchedulerMinProcs Minimum number of logical processors (as seen by OS) to
allocate for the job (0 = Use all available, -1 = Use all but
one, etc.)
3 AWR_JobSchedulerThreadsPerProc The number of computational threads created for each
allocated logical processor (Recommended settings:
Axiem=1-2, Analyst=1)
4 AWR_JobSchedulerJobOSPriority The Operating System priority to assign to the job process
once it's running. (Default=Normal, or the value set in the
user.ini file, if any)
5 AWR_JobSchedulerJobRemotePreference Preference for how to dispatch the job if remote job servers
are available
6 AWR_JobSchedulerJobPerfPreference The preferred processor performance of the server to be
assigned to the job, if the job is executed remotely.
7 AWR_JobSchedulerJobMemCapPreference The preferred memory capacity of the server to be assigned
to the job, if the job is executed remotely.
8 AWR_JobSchedulerJobRunAsMWOJob ALL simulations for this document will be done in a separate
MWO simulation process
9 AWR_UseResultsForPartialSwp Allow a swept parameter simulation to use the results when
some of the sweep points failed to simulate
10 Mesh_meshDensity Specify mesh density
11 Mesh_maxX X max of cells per subsection limits

2242 NI AWR Design Environment


EMStructure

Number Name Description


12 Mesh_maxY Y max of cells per subsection limits
13 Mesh_minX X min of cells per subsection limits
14 Mesh_minY Y min of cells per subsection limits
15 Mesh_conformalCells Conformal meshing
16 Mesh_trngleCells Allow triangle meshing
17 SpecGlobalEquations Specify the global definition document to use as the global
equations for this document
18 EXT_DISC EXT_DISC
19 EXT_CROSSOVER EXT_CROSSOVER
20 EXT_COUPLED EXT_COUPLED
21 USE_XMOD USE_XMOD
22 USE_CF_TLIN USE_CF_TLIN
23 REMOVE_SHORT REMOVE_SHORT
24 MAX_COUPLED MAX_COUPLED
25 MIN_LW_RATIO MIN_LW_RATIO
26 ERNOM_VALS1 ERNOM_VALS1
27 ERNOM_VALS2 ERNOM_VALS2
28 ERNOM_VALS3 ERNOM_VALS3
29 ERNOM_VALS4 ERNOM_VALS4
30 MAX_COUPLE_D MAX_COUPLE_D
31 MIN_SL_RATIO MIN_SL_RATIO
32 NUMERICAL_PREF NUMERICAL_PREF
33 MATCH_TOL MATCH_TOL
34 MODEL_PREF MODEL_PREF
35 SUB_SIMPLIFY SUB_SIMPLIFY
36 Model Mapping Model Mapping
37 S-Parameter Mapping S-Parameter Mapping
38 Model Accuracy Model Accuracy
39 Curve Model Curve Model
40 Coupled Line Model Coupled Line Model
41 XOVER_CALC_METH XOVER_CALC_METH
42 Show Simplified Stackup Show Simplified Stackup
43 HideNonActiveLayers Returns/sets if all non-active layers should be hidden in EM
layout.
44 FreezeNonActiveLayers Returns/sets if all non-active layers should be frozen in EM
layout.
45 ShowNonActiveHatch Returns/sets if hatch should be shown in non-active layers
in EM layout.

API Scripting Guide 2243


EMStructure

Number Name Description


46 ShowBoundingBox Returns/sets if the boundary box should be shown in EM
layout.
47 ShowShapeOutlines Returns/sets if outlines only should be displayed in EM
layout.
48 ShowRedBlueStereo3D Returns/sets if stereo 3D should be shown in EM layout.
49 ShouldExtractLineType Returns/sets if line type should be modeled as it is in EM
layout.
50 BoundyLineThickness Returns/sets the boundary line thickness.
51 ShapeLineThickness Returns/sets the shape line thickness.
52 HatchLineThickness Returns/sets the hatch line thickness.
53 ArrowLineThickness Returns/sets the arrow line thickness.
54 MeshConformalFill MeshConformalFill
55 MeshTriangleFill Returns/sets if triangle mesh cells should be used.
56 MeshDensityLevel Returns/sets the mesh density level.
57 MeshXMinCellsPerSubsection Returns/sets the minimum number of cells per subsection
in the X direction.
58 MeshYMinCellsPerSubsection Returns/sets the minimum number of cells per subsection
in the Y direction.
59 MeshXMaxCellsPerSubsection Returns/sets the maximum number of cells per subsection
in the X direction.
60 MeshYMaxCellsPerSubsection Returns/sets the maximum number of cells per subsection
in the Y direction.
61 MeshZeroThickness MeshZeroThickness
62 MeshEdgeMeshing Returns/sets the mesh edge meshing
63 MeshDecimation Returns/sets the mesh decimation
64 MeshMaxAspectRatio Returns/sets the mesh max aspect ratio
65 ShowCursorCoordLabel Returns/sets if cursor coordinates should be displayed.
66 DisplayAbsoluteCoords Returns/sets if cursor should be absolute or delta
coordinates.
67 CoordDisplayUseCellUnits Returns/sets if coordinates should be absolute or relative to
cell.
68 SolidCoordDisplayBackground Returns/sets if cursor coordinate display should use a solid
background.
69 OrthogonalDrawingMode Returns/sets if orthogonal drawing mode should be used.
70 DrawGridSnap Returns/sets if the snap grid should be displayed.
71 SnapToGrid Returns/sets if the cursor should snap to the snap grid.
72 GridSnapValue Returns/sets the value for the snap grid.
73 NumberInterpolationPoints Returns/sets the number of points used for interpolation.
74 InterpolationWindowSize Returns/sets the window size used for interpolation.

2244 NI AWR Design Environment


EMStructures

Number Name Description


75 InterpolationSplineOrder Returns/sets the spline order used for interpolation.
76 InterpolationMethod Returns/sets the method used for interpolation.
77 InterpolationCoordinates Returns/sets the interpolation coordinate system type.
78 EnableInterpolation Returns/sets if parameter interpolation is enabled in EM
documents
79 ConsiderPassiveForNoise Returns/sets if passive elements should be considered in
noise calculations.
80 SchematicSymbolName Returns sets the default symbol name used when the
document is placed as a subcircuit.

EMStructures
A collection of MWOffice EMStructure objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item EMStructure Returns a specific item of a Collection object either by
position or by key.
Options Options Returns a reference to a collection of Option objects.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: EMStructure

Syntax: Function Add(StructureName As String) As EMStructure

AddEx

Description: Adds an object to the collection and returns a reference to the created object.

Returns: EMStructure

Syntax: Function AddEx(StructureName As String, Simulator As mwEmSimulator) As EMStructure

AddInit

Description: Adds an object to the collection and returns a reference to the created object.

Returns: EMStructure

API Scripting Guide 2245


EMStructures

Syntax: Function AddInit(StructureName As String, Simulator As mwEmSimulator, pInitRecord As


EMInitializationRecord) As EMStructure

Copy

Description: Copies an object from another object collection into this object collection.

Returns: EMStructure

Syntax: Function Copy(Index, [NewName As String = ""]) As EMStructure

CreateInitRecord

Description: Returns a reference to a EMInitializationRecord object.

Returns: EMInitializationRecord

Syntax: Function CreateInitRecord() As EMInitializationRecord

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Import

Description: Adds a Netlist object to the collection from a file and returns a reference to the created object.

Returns: EMStructure

Syntax: Function Import(Filename As String) As EMStructure

LinkTo

Description: Adds an Electromagnetic structure referencing an external file and returns a reference to the created object.

Returns: EMStructure

Syntax: Function LinkTo(Filename As String) As EMStructure

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

2246 NI AWR Design Environment


EMStructures

Options For Axiem

Number Name Description


1 UseFastFrequencySweep Returns/sets if fast frequency sweep should be used.
2 DeembedPorts Returns/sets if ports and feed lines should be de-embedded.
3 ComputeLoadedCurrents Returns/sets if loaded currents should be computed.
4 UseSameSizeBox Returns/sets if the same size box should be used for
de-embedded circuit.
5 SaveResultsInDocument Returns/sets if the results should be saved in the EM
document.
6 MaxDifferentialOrder Returns/sets the maximum differential order computed.
7 MatrixSolverType Returns/sets the matrix solver type used for analysis.
8 UseSinglePrecision Returns/sets if single precision should be used to save
memory.
9 FreqSweepErrorTolerance Returns/sets if fast frequency sweep error tolerance level.
10 UseRelativeError Returns/sets if relative error should be used.
11 IterativeSolverTolerance Returns/sets the iterative solver error tolerance level.
12 AFSEnable Returns/sets if advanced frequency sweep should be enabled.
13 AFSErrorTypeRelative Returns/sets if the error type should be relative or absolute.
14 AFSErrorTolerance Returns/sets the error tolerance for the advanced frequency
sweep in dB.
15 AFSGridPointCount Returns/sets the number of grid points used for the advanced
frequency sweep.
16 AFSMaxPointCount Returns/sets the advance frequency sweep maximum point
count.
17 AFSSpecifyBand Returns/sets with to use a specified band for the advanced
frequency sweep.
18 AFSBandStartFrequency Returns/sets the start frequency for the advanced frequency
sweep band.
19 AFSBandStopFrequency Returns/sets the stop frequency for the advanced frequency
sweep band.
20 AnimateUseLogColorScale Returns/sets if a color log scale should be used for
animation.
21 AnimateActiveCurrentLayer Returns/sets if only currents on the active layer should be
animated.
22 AnimateActive2DLayerOnly Returns/sets if only the active layer should be animated.
23 AnimateCurrentXComponents Returns/sets if the X current components should be
animated.
24 AnimateCurrentYComponents Returns/sets if the Y current components should be
animated.
25 Animate2DFramesPerCycle Returns/sets the number of 2D animation frames per cycle.

API Scripting Guide 2247


EMStructures

Number Name Description


26 Animate3DFramesPerSycle Returns/sets the number of 3D animation frames per cycle.
27 AnimateLocScaleFactor Returns/sets the log color scale factor to be used in the
animation.
28 AnimationLightenFactor Returns/sets the lighten color scale factor for the animation.
29 AnimateStandaingWave Returns/sets if standing waves should be displayed in the
animation.
30 AnimationHideArrows Returns/sets if current arrows should be hidden during
animation.
31 HideNonActiveLayers Returns/sets if all non-active layers should be hidden in EM
layout.
32 FreezeNonActiveLayers Returns/sets if all non-active layers should be frozen in EM
layout.
33 ShowNonActiveHatch Returns/sets if hatch should be shown in non-active layers
in EM layout.
34 ShowBoundingBox Returns/sets if the boundary box should be shown in EM
layout.
35 ShowShapeOutlines Returns/sets if outlines only should be displayed in EM
layout.
36 ShowRedBlueStereo3D Returns/sets if stereo 3D should be shown in EM layout.
37 ShouldExtractLineType Returns/sets if line type should be modeled as it is in EM
layout.
38 BoundyLineThickness Returns/sets the boundary line thickness.
39 ShapeLineThickness Returns/sets the shape line thickness.
40 HatchLineThickness Returns/sets the hatch line thickness.
41 ArrowLineThickness Returns/sets the arrow line thickness.
42 MeshConformalFill MeshConformalFill
43 MeshTriangleFill Returns/sets if triangle mesh cells should be used.
44 MeshDensityLevel Returns/sets the mesh density level.
45 MeshXMinCellsPerSubsection Returns/sets the minimum number of cells per subsection
in the X direction.
46 MeshYMinCellsPerSubsection Returns/sets the minimum number of cells per subsection
in the Y direction.
47 MeshXMaxCellsPerSubsection Returns/sets the maximum number of cells per subsection
in the X direction.
48 MeshYMaxCellsPerSubsection Returns/sets the maximum number of cells per subsection
in the Y direction.
49 MeshZeroThickness MeshZeroThickness
50 MeshEdgeMeshing Returns/sets the mesh edge meshing
51 MeshDecimation Returns/sets the mesh decimation
52 MeshMaxAspectRatio Returns/sets the mesh max aspect ratio

2248 NI AWR Design Environment


EMStructures

Number Name Description


53 ShowCursorCoordLabel Returns/sets if cursor coordinates should be displayed.
54 DisplayAbsoluteCoords Returns/sets if cursor should be absolute or delta
coordinates.
55 CoordDisplayUseCellUnits Returns/sets if coordinates should be absolute or relative to
cell.
56 SolidCoordDisplayBackground Returns/sets if cursor coordinate display should use a solid
background.
57 OrthogonalDrawingMode Returns/sets if orthogonal drawing mode should be used.
58 DrawGridSnap Returns/sets if the snap grid should be displayed.
59 SnapToGrid Returns/sets if the cursor should snap to the snap grid.
60 GridSnapValue Returns/sets the value for the snap grid.
61 CkPt_AutoGen Automatically generate a checkpoint for every simulation
62 CkPt_MaxAuto Maximum number of checkpoints retained before garbage
collection is applied
63 CkPt_SaveProj Automatically save a copy of the project for each check
point
64 CkPt_ReloadProj Automatically load the saved project associated with a check
point
65 UseFastFrequencySweep Returns/sets if fast frequency sweep should be used.
66 DeembedPorts Returns/sets if ports and feed lines should be de-embedded.
67 ComputeLoadedCurrents Returns/sets if loaded currents should be computed.
68 UseSameSizeBox Returns/sets if the same size box should be used for
de-embedded circuit.
69 SaveResultsInDocument Returns/sets if the results should be saved in the EM
document.
70 MaxDifferentialOrder Returns/sets the maximum differential order computed.
71 MatrixSolverType Returns/sets the matrix solver type used for analysis.
72 UseSinglePrecision Returns/sets if single precision should be used to save
memory.
73 FreqSweepErrorTolerance Returns/sets if fast frequency sweep error tolerance level.
74 UseRelativeError Returns/sets if relative error should be used.
75 IterativeSolverTolerance Returns/sets the iterative solver error tolerance level.
76 AFSEnable Returns/sets if advanced frequency sweep should be enabled.
77 AFSErrorTypeRelative Returns/sets if the error type should be relative or absolute.
78 AFSErrorTolerance Returns/sets the error tolerance for the advanced frequency
sweep in dB.
79 AFSGridPointCount Returns/sets the number of grid points used for the advanced
frequency sweep.
80 AFSMaxPointCount Returns/sets the advance frequency sweep maximum point
count.

API Scripting Guide 2249


EMStructures

Number Name Description


81 AFSSpecifyBand Returns/sets with to use a specified band for the advanced
frequency sweep.
82 AFSBandStartFrequency Returns/sets the start frequency for the advanced frequency
sweep band.
83 AFSBandStopFrequency Returns/sets the stop frequency for the advanced frequency
sweep band.
84 OEA:SimMode OEA:SimMode
85 OEA:MinTimeConst OEA:MinTimeConst
86 OEA:MinKValue OEA:MinKValue
87 OEA:ExpansionDist OEA:ExpansionDist
88 OEA:MinMetalSepar OEA:MinMetalSepar
89 ACE:EXT_DISC ACE:EXT_DISC
90 ACE:EXT_CROSSOVER ACE:EXT_CROSSOVER
91 ACE:EXT_COUPLED ACE:EXT_COUPLED
92 ACE:USE_XMOD ACE:USE_XMOD
93 ACE:USE_CF_TLIN ACE:USE_CF_TLIN
94 ACE:REMOVE_SHORT ACE:REMOVE_SHORT
95 ACE:MAX_COUPLED ACE:MAX_COUPLED
96 ACE:MIN_LW_RATIO ACE:MIN_LW_RATIO
97 ACE:ERNOM_VALS1 ACE:ERNOM_VALS1
98 ACE:ERNOM_VALS2 ACE:ERNOM_VALS2
99 ACE:ERNOM_VALS3 ACE:ERNOM_VALS3
100 ACE:ERNOM_VALS4 ACE:ERNOM_VALS4
101 ACE:MAX_COUPLE_D ACE:MAX_COUPLE_D
102 ACE:MIN_SL_RATIO ACE:MIN_SL_RATIO
103 ACE:NUMERICAL_PREF ACE:NUMERICAL_PREF
104 ACE:MATCH_TOL ACE:MATCH_TOL
105 ACE:MODEL_PREF ACE:MODEL_PREF
106 ACE:SUB_SIMPLIFY ACE:SUB_SIMPLIFY
107 ACE:Model Mapping ACE:Model Mapping
108 ACE:S-Parameter Mapping ACE:S-Parameter Mapping
109 ACE:Model Accuracy ACE:Model Accuracy
110 ACE:Curve Model ACE:Curve Model
111 ACE:Coupled Line Model ACE:Coupled Line Model
112 ACE:XOVER_CALC_METH ACE:XOVER_CALC_METH
113 ACE:Show Simplified ACE:Show Simplified Stackup
Stackup

2250 NI AWR Design Environment


EMStructures

Number Name Description


114 Em3DP_TargetMaxMemLoadFraction The value is used to stop the AMR sequence if the projected
memory consumption for the next pass exceeds this fraction
of the total available system memory.
115 Em3DP_GenerateVerboseOutput This option controls the quantity of Log messages from the
simulator that are displayed during a simulation. More
detailed information on the solution process can be obtained
by checking this option.
116 EM3DP_IgnoreEnclosure This option controls if the enclosure defined in the MWO
layout is used in simulation.
117 EM3DP_SubstituteTrueArcs This option controls if faceted arcs are potentially replaced
with true arcs.
118 Em3DP_EnableRemoteRefineSolution This option controls if refine solution on remote machines
is enabled
119 Em3DP_ArchiveRefineSolutionFiles This option controls if refine solution intermediate files are
saved with project
120 Em3DP_PortAMR_MaxIterations Maximum number of adaptive passes during ports-only
portion of AMR sequence. If the sequence has not
terminated earlier for other reasons, e.g., convergence
tolerance was reached, then it will terminate after this
number of passes has been completed.
121 Em3DP_PortAMR_MinIterations Minimum number of adaptive passes during ports-only
portion of AMR sequence, irrespective of the error value.
122 Em3DP_PortAMR_MinConvIterations The minimum number of consecutive iterations with error
(equal to the magnitude of change in Target value over
successive adaptive passes) less than convergence criterion
before the AMR process will be terminated.
123 Em3DP_PortAMR_FrequencyModifier Frequency index (or indices) in band at which the mesh will
be adaptively refined during the ports-only portion of the
AMR sequence. Mid refers to median index, Low to lowest
frequency index, High to highest frequency index. Custom
allows choice of a frequency; the mesh will be adaptively
refined at the frequency in band nearest to the chosen
frequency.
124 Em3DP_PortAMR_CustomFrequency Custom frequency modifier for port AMR
125 Em3DP_PortAMRConv_Tolerance The AMR process is considered converged when the error
changes less than this fractional amount in successive
iterations. Lowering this value generally yields more
accurate results; raising it will reduce runtimes.
126 Em3DP_AMR_MaxIterations Maximum number of adaptive passes during full-solve
portion of AMR sequence. If the sequence has not
terminated earlier for other reasons, e.g., convergence
tolerance was reached, then it will terminate after this
number of passes has been completed.
127 Em3DP_AMR_MinIterations Minimum number of adaptive passes during full-solve
portion of AMR sequence, irrespective of the error value.

API Scripting Guide 2251


EMStructures

Number Name Description


128 Em3DP_AMR_MinConvIterations The minimum number of consecutive iterations with error
(equal to the magnitude of change in Target value over
successive adaptive passes) less than convergence criterion
before the AMR process will be terminated.
129 Em3DP_AMR_FrequencyModifier Frequency index (or indices) in band at which the mesh will
be adaptively refined during the full-solve portion of the
AMR sequence. Mid refers to median index, Low to lowest
frequency index, High to highest frequency index. Custom
allows choice of a frequency; the mesh will be adaptively
refined at the frequency in band nearest to the chosen
frequency.
130 Em3DP_AMR_CustomFrequency Custom frequency modifier for volumetric AMR
131 Em3DP_AMR_Target This is the quantity that will be monitored to determine
convergence of the full-solve AMR sequence. S is the
renormalized scattering matrix. The maximum value of the
error (equal to the magnitude of the difference between a
given matrix element in successive adaptive passes) for any
S-matrix element at the AMR frequency (or frequencies) is
used as the value for a given adaptive pass.
132 Em3DP_AMR_Tolerance The AMR process is considered converged when the error
(equal to the magnitude of the difference in Target values
in successive adaptive passes) changes less than this
fractional amount in successive iterations. Lowering this
value generally yields more accurate results; raising it will
reduce runtimes.
133 Em3DP_AMR_Tolerance2 The AMR process is considered converged when the error
(equal to the phase angle difference in Target values in
successive adaptive passes) changes less than this fractional
amount in successive iterations. Lowering this value
generally yields more accurate results; raising it will reduce
runtimes.
134 Em3DP_AMR_ToleranceSpecification If the magnitude of a scattering matrix term is less than this
value, its phase is ignored in determining AMR convergence.
135 Em3DP_meshZeroThickness Model extruded conductors as zero thickness
136 Em3DP_MeshSizeType Determines whether the mesh element size is defined as a
relative or absolute size.
137 Em3DP_RelativeMeshSize Maximum element edge length relative to 1/10th of the
diagonal of the bounding box of the structure.
138 Em3DP_AbsoluteMeshSize Maximum element edge length.
139 Em3DP_SizePropagationFactor Controls element size transition rate from coarse to fine
areas. Valid values are between 0.0 and 1.0, with smaller
values resulting in faster transitions.
140 Em3DP_CurveRefineLevel Controls the accuracy with which the mesh represents curved
surfaces and edges. Valid values are between 0.0 and 0.5,

2252 NI AWR Design Environment


EMStructures

Number Name Description


with smaller values more accurately representing curved
surfaces and edges.
141 Em3DP_AnisotropicCurveRefine If true, curvature refinement is mostly confined to curved
directions. This can drastically reduce element counts in
structure containing long, small diameter cylinders such as
bondwires.
142 Em3DP_RelativeMinCurveSize Defines a floor for the smallest element to be produced by
the Curvature Refinement Level. The value is relative to
the global maximum element size.
143 Em3DP_SmallFeatureSuppress Used to help alleviate meshing problems particularly with
complex and/or imported geometry.
144 Em3DP_AbsSmallFeatureTol Tolerance is a length. Recommended values are on the order
of 0.0. Making this value larger will decrease the likelihood
of meshing failures, but making it too large will have the
undesired side effect of altering the geometry significantly.
145 Em3DP_LocalMeshParamsEnable If this parameter is true then meshing will be governed by
attributes on the geometry (bodies, faces, and edges) that
control the meshing process locally.
146 Em3DP_FieldOutputFrequency Fields (E, H, and surface current Js) can be output at the
AMR frequencies, at all frequencies, or not at all. Field
output will slow the solution sequence somewhat, and will
also inflate the size of the solution datasets.
147 Em3DP_SolverSolveType Solve on the full model or on ports only.
148 Em3DP_SolverSweepType The Discrete sweep solves for each frequency point
independently. It is typically faster for simulations with
fewer frequencies per active process, especially if the
simulation includes many ports. The GAWE (Galerkin
Asymptotic Wave Expansion) sweep uses an asymptotic
method to approximate the solution in bands of frequencies
around expansion points. This method is faster than a
Discrete sweep for a large frequency count with a relatively
small number of ports. When the Automatic sweep type is
selected, the solver uses either a Discrete sweep or a GAWE
sweep, depending on which is likely to be faster for the
given frequency count, port count, and parallel
configuration.
149 Em3DP_SolverBasisSet The basis set dictates the accuracy of the field representation
within each mesh element. The higher the basis set order,
the more functions are used, generally resulting in a higher
accuracy result. The "H" basis sets (H0.5, H1.5, etc.) use
the same number and configuration of functions in each
element. The "C" basis sets use higher order functions
on/near metal edges and corners, with lower order functions
used away from these features. For example, the C2.5 basis
set uses the H2.5 basis (represents the electric field up to
3rd order) on metal corners/edges, then these transition to

API Scripting Guide 2253


EMStructures

Number Name Description


H1.5 (E field to 2nd order) one element layer away, and
finally transition to H0.5 (E-field to 1st order) functions
throughout the remainder of the volume.
150 Em3DP_SolverMinimumSolvedFrequency Use this parameter to protect against solving at low
frequencies where solutions of this high-frequency solver
may lose accuracy.
151 Em3DP_SolveInsideConductors This flag controls whether the solver will solve for the field
inside metal conductors. This is sometimes necessary to
achieve high accuracy solutions. Solving inside conductors
generally increases the solution time and should not be done
unless the skin-depth is comparable to the metal thickness
over at least a portion of the frequency band. Otherwise,
lossy metal will be approximated using impedance boundary
conditions on the metal surface, which will yield sufficient
accuracy in most cases without incurring the runtime
performance penalty of solving inside the metal.
152 Em3DP_ExtrapolateTowardDC This parameter determines solver behavior for any frequency
points below the minimum solved frequency. The solver
will either extrapolate from the solution above the minimum
solved frequency using a cubic-order polynomial fit, or if
None is selected the solver will duplicate the minimum
solved frequency results at all lower frequency points.
153 Em3DP_CharacteristicImpedanceMethod The characteristic impedance at a port can be computed
using one of three expressions: P/I^2 (called "Power
Current"), P*V^2 (called "Power Voltage"), and V/I
("Voltage Current"). For most single-moded transmission
lines these three definitions will give similar values, while
in waveguides they can be quite different and the proper
one to use will be problem-dependent.
154 Em3DP_PortSolverBasisSet The basis set refers to the set of functions that represent the
electromagnetic fields on the mesh elements (triangles for
port meshes). The higher the basis set order, the more
functions are used, generally resulting in a higher accuracy
result in exchange for somewhat longer solution times. The
basis sets that are allowed for port solutions are members
of the "H" family (H0.5, H1.5, etc.), where the H0.5 element
has only linear functions, H1.5 has functions up to 2nd order
(quadratic), etc. The Automatic setting ties the port basis
set to be one order higher than that used in the volume, e.g.,
if the volume basis set is H1.5, then the port basis set will
be H2.5.
155 Em3DP_PortEigenSolverMethod This flag controls whether the eigensolver uses a direct or
iterative method. The Direct method identifies all of the
eigenmodes and then selects the appropriate ones based
upon sorting criteria. The Direct method is very robust, but
it scales very poorly with mesh element count. The Iterative
methods converge only one, to at most a few modes of

2254 NI AWR Design Environment


EMStructures

Number Name Description


interest, but do so quite rapidly and in a fashion that scales
well as the port meshes increase in element count. Except
possibly for very small problems, the Iterative methods are
the best choice, and the Automatic selection is equivalent
to Iterative.
156 Em3DP_PortEigenSolverIterativeMethod The iterative methods include Port Arnoldi and Port
Lanczos, which implement the asymmetric Arnoldi and
Lanczos processes, respectively. The Automatic selection
is equivalent to Port Arnoldi.
157 Em3DP_PortEigenSolverIterativeMaxIterations This is the maximum number of iterations that the iterative
eigensolvers will use to converge the number of modes
requested at each port.
158 Em3DP_PortEigenSolverIterativeConvergenceTol The target residual for convergence of modes. A mode is
considered converged if the corresponding eigenpair (mode
field pattern and propagation constant) gives a residual to
the port finite-element matrix equation of less than this
value.
159 Em3DP_PortEigenLinearSolverMethod The Iterative eigensolver methods must solve a matrix
equation at each iteration, and this option controls the type
of solver that is used for this purpose. The options are Direct
and Iterative. The Direct solver performs an LU factorization
of the system, and the iterative method uses a variant of the
preconditioned conjugate gradient (PCG) method. The
Automatic selection is equivalent to Direct, and this is
almost always faster than the Iterative option.
160 Em3DP_PortEigenLinearSolverIterativeMethod Several iterative linear solver methods are available, all of
which are variants of the preconditioned conjugate gradient
method. The CG option invokes the standard preconditioned
conjugate gradient method; the BiStabCG invokes the
stabilized variant of biconjugate gradient, and CGS is the
conjugate gradient squared method.
161 Em3DP_PortEigenLinearSolverIterativeMaxIterations This is the maximum number of iterations the linear solver
will perform before stopping, irrespective of the size of the
matrix equation residual.
162 Em3DP_PortEigenLinearSolverIterativeConvergenceTolerance When the residual of the matrix equation falls below this
value the linear solver considers the result converged.
Setting this value too low can cause very long solution times,
and setting it too high will result in breakdown of the
eigensolver.
163 Em3DP_LinearSolverMethod The finite-element method requires the solution of a matrix
equation, and this option controls the type of solver that is
used for this purpose. The options are Direct and Iterative.
The Direct solver performs an LU factorization of the
system, and the iterative method uses a variant of the
preconditioned conjugate gradient (PCG) method. The
Automatic selection is equivalent to Direct, and this is

API Scripting Guide 2255


EMStructures

Number Name Description


almost always faster than the Iterative option, but it uses
significantly more computer memory.
164 Em3DP_LinearSolverDirectMethod There are two options for the Direct linear solver, both of
which perform an LU factorization of the matrix. The Serial
LU option has been optimized for use on a single machine
or desktop, and the Parallel LU option is best on multiple
computers or clusters. The Automatic selection will invoke
the appropriate option based upon the computer and
configuration.
165 Em3DP_LinearSolverIterativeMethod Several iterative linear solver methods are available, all of
which are variants of the preconditioned conjugate gradient
method. The CG option invokes the standard preconditioned
conjugate gradient method; the BiStabCG invokes the
stabilized variant of biconjugate gradient, and CGS is the
conjugate gradient squared method.
166 Em3DP_LinearSolverIterativePreconditioner Use of a matrix preconditioner improves the convergence
rate iterative methods. The options are diagonal scaling
(Jacobi), Gauss-Seidel, and P-Multigrid. Jacobi is the most
efficient in terms of computer memory. P-Multigrid uses
the most computer memory but will result in very short
iteration sequences for higher-order elements (it involves a
factorization of a portion of the matrix, and is equivalent to
using a Direct method if only the lowest order H0.5 basis
set is used).
167 Em3DP_LinearSolverIterativeMaxIterations This is the maximum number of iterations the linear solver
will perform before stopping, irrespective of the size of the
matrix equation residual.
168 Em3DP_LinearSolverIterativeConvergenceTolerance When the residual of the matrix equation falls below this
value the linear solver considers the result converged.
Setting this value too low can cause very long solution times,
and setting it too high will result in a loss of result accuracy.
169 Em3DP_AntennaFarFldEnable Output Frequency
170 Em3DP_AntennaFarFldSphSampleInc Sphere Sampling Increment, Theta
171 Em3DP_AntennaFarFldSphSampleIncPhi Sphere Sampling Increment, Phi
172 Em3DP_RefinerMeshCoarseningEnabled Controls whether the elements can be made larger in any
portion of the mesh during adaptive mesh refinement.
173 Em3DP_RefinerTargetMeshGrowthFraction This quantity controls how rapidly the mesh element count
increases during the AMR process, with the element count
increasing by approximately this fraction between successive
AMR iterations. Larger fractions cause more rapid
convergence of the solution, in terms of the iteration count,
but may result in excessive runtime and memory usage.
174 Solver Type Select the solver type
175 eMCO_USE_DIRECT_BELOW Use Direct Solver when the # of unknowns is less than this
value

2256 NI AWR Design Environment


EMStructures

Number Name Description


176 eMCO_LowFSolverGauge Low Frequency Solver will be used when max edge length
is less than this fraction of a wavelength
177 eMCO_eDeEmbeddingMethod Allow Global De-Embedding of ports. Port specific
de-embedding enabled at port level
178 eMCO_COUPLEDLINE_LIMIT_RATIO Use coupled line de-embedding when dist. between ports /
dist. to ground is less than this ratio
179 eMCO_YmatGmin Minimum amount of conductance to add between ground
and nodes to prevent singular matrices during de-embedding
and DC extrapolation
180 eMCO_YmatRmin Minimum series resistance between nodes to prevent
singular matrices during de-embedding and DC extrapolation
181 eMCO_YCondMethod Method used to determine when minimum conductance is
added to nodes during de-embedding
182 eAAFS_EnforcePassivity Enforce passivity of the resulting port parameters
183 eMCO_YEnfReciprocity Enforce reciprocity of the resulting port parameters
184 eMCO_YEnfReciprocalMethod Reciprocity enforcement method
185 eAAFS_UseAFS Enable Advanced Frequency Sweep
186 eMCO_AFS_TOL AFS Tolerance
187 eMCO_AFS_MAX_PTS Maximum number of simulation points (The high default
value means that AFS will simulate all requested frequencies
if convergence is not reached.)
188 eAAFS_BandLimit Enable AFS to run on a limited bandwidth between Start
Freq and Stop Freq
189 eAAFS_BandStart AFS Band Start Frequency in GHz
190 eAAFS_BandStop AFS Band Stop Frequency in GHz
191 eAPS_PORTS_AUTO_GROUNDING Enable automatic determination of ground reference
192 eAPS_PAG_ViaClearanceRatio This ratio X shortest-distance-to-ground sets the minimum
clearance between a port and a via for the port to be set as
an explicit port. If after extension the port is still within this
distance of a via, the port is set to implicit. Default is 0.5(x
Shortest-distance-to-ground)
193 eAPS_PAG_DualGndCapRatioLimit Explicit up/down grounding capacitance ratio limit. A
submissive ground limit will be added if the approximate
ratio of the capacitance to that ground vs the capacitance to
the dominant ground exceeds this value.
194 eAPS_PAG_MaxInsetDistance Used in the case of plated or multilayer lines where an
inset/outset in seen between stacked metal layers.
Determines the horizontal extend used when determining
local connectivity between stacked shapes.
195 eAPS_PAG_MaxTraceWidth Used in determining if a shape underlying a port can be used
as a local ground. Shapes with an effective width parameter
(W=2*area/perimeter) greater than this value would be
considered a valid local ground candidate. The default value

API Scripting Guide 2257


EMStructures

Number Name Description


of 0 for this parameter means that all shapes can be
considered valid local ground candidates.
196 eAPS_PAG_AllowExplictInterior If enabled Explicit grounding of interior ports will be
considered during auto port setup, otherwise implicit
grounding (None) will be used for these ports.
197 eAPS_PAG_ImplicitGndWaveLenMax A multiple of a wavelength at the highest simulation
frequency. Implicit grounding will be used for edge ports
which have an electrical length to the nearest ground less
than this value. For electrical distances to ground exceeding
this value, explicit grounding will be used.
198 eAPS_PORTS_AUTO_EXTENSION Enable obstruction aware auto extension of ports
199 eAPS_PAE_DistMultiple Used to determine an optimal extension length as a multiple
of Max(port width, min distance to ground). If a port can
be extended to this length without being obstructed, then
the length of the extension is determined by this parameter.
200 eAPS_PAE_ClearanceDistance Used to classify local obstructions in the horizontal direction
(X/Y) relative to the closest distance to ground from the
port. If the extension of a port causes the horizontal distance
between the extension and a secondary object to be less than
this value, the extension would be considered obstructed.
201 eAPS_PAE_ExtSearchAngle Used to classify local obstructions near the connection to
the embedded structure. This angle determines how close
an object can be relative to a port before it is considered an
obstruction and blocks the addition of an extension during
Auto Port Setup. A value of 0 represents the maximum
clipping of the exclusion region
202 eAPS_PAE_MinVertClearDistUp Used to classify local obstructions in the vertical direction
above the port. If zero, the distance to the nearest local
ground or boundary above the port is used. If non-zero, this
is a multiple of the closest distance to ground (up/dn) from
the port as long as this dimension is less than the distance
to ground in the upward direction. If the extension of a port
causes the vertical distance between the extension and a
secondary object above to be less than the value determined
by this parameter, the extension would be considered
obstructed.
203 eAPS_PAE_MinVertClearDistDn Used to classify local obstructions in the vertical direction
below the port. If zero, the distance to the nearest local
ground or boundary below the port is used. If non-zero, this
is a multiple of the closest distance to ground (up/dn) from
the port as long as this dimension is less than the distance
to ground in the downward direction. If the extension of a
port causes the vertical distance between the extension and
a secondary object below to be less than the value
determined by this parameter, the extension would be
considered obstructed.

2258 NI AWR Design Environment


EMStructures

Number Name Description


204 eAPS_PAE_MinExtAsPctOfDesiredExt A fraction of the optimum extension length used to specify
that that an extension is too short to be useful and thus no
extension should be used. Used to force all extended ports
to be a minimum extension length or not be extended at all.
205 eAPS_PORTS_AUTO_GROUPING Enable automatic grouping (Mutual/Coupled) of ports based
on orientation and proximity
206 eAPS_PAG_MaxClusterRadius Used to limit port groupings based on port proximity relative
to the closest distance to ground from the port. Horizontal
separation distances between ports below this ratio would
be considered valid group candidates.
207 eAPS_MutalGroupExtensions If Enabled, ports will be extended if possible, give the
restrictions of Group clearance ratio and Via clearance ratio
options.
208 eAPS_MutalGroupClearance Used to limit port groupings based on port proximity relative
to the closest distance to ground from the port. Horizontal
separation distances between ports below this ratio would
be considered valid group candidates.
209 eAX_MATRIX_ENTRY_ACCURACY Matrix Entry Accuracy
210 eMtxCalc_2DEnhSISimp Correctly model loss for thin mesh at high frequency
211 eMCO_Alt_Via_Res Use via width when determining surface impedance for vias
212 eMCO_MAX_ITER Maximum # of iterations used to obtain convergence before
solver failure
213 eMCO_GMRES_TOL The tolerance used to determine iterative solver success,
relative to previous iteration
214 eMCO_SUBSPACE_SIZE Retain information from the previous iterations. Increases
memory proportional to size times # unknowns
215 eMCO_ENABLE_MRHS Allows the solution of multiple ports (right hand sides) at
once when using an iterative matrix solver. At the expense
of increased memory usage, the solution process can be
expedited by as much as 2x when solving for multiple right
hand sides (ports) at once.
216 eAX_PRECONDITIONER_EFFICIENCY Preconditioner Efficiency
217 eAX_COMPRESSION_ACCURACY Determines the accuracy of approximation used to represent
the moment matrix
218 eAX_meshDecimation The default decimation control for shapes within the
document, this default control can be overridden on
individual shapes within the document. The decimation
control specifies how aggressively the points defining a
shape will be modified in order to result in a simplified final
mesh. This control is relative, with with 5 possible states
None/Low/Medium/High/Very High. A setting of None
allows for modification of only degenerate polygons, such
as two polygon points being duplicate or nearly so. Very

API Scripting Guide 2259


EMStructures

Number Name Description


high decimation allows extreme modification of polygon
points to reduce the number of mesh elements.
219 eAX_meshZeroThickness Determines the default behavior of how conductors in the
document are represented in the mesh, this default control
can be overridden on individual shapes within the document.
If zero thickness meshes are enabled, conductors are meshed
as infinitely thin. Otherwise a conductor is modeled with
finite thickness (top,bottom and side facets).
220 eAX_MESH_DECIMATION_OPTIONS On - Use mesher decimation and shape clean-up at normal
level. Off - Use shape clean-up at lowest setting if smallest
edge length is below minimum. Auto - If geometry has used
shape simplification rules, use shape clean-up at lowest
settings, else same as behavior as On.
221 eMCO_HARF_Error_Threshold The error threshold for High Aspect Ratio Facets (HARF).
Meshes with facets aspects higher than this value will not
be simulated.
222 eMD_RECORD_EXTREMES This parameter enables verbose printing of mesh extremes
in the status log.
223 eMCO_Path_Detection Enables extraction of rectangular sections within input
polygon regions
224 eAX_meshEdgeMeshing Determines if the final mesh contains narrow facets along
open edges of thin metal. Width of the edge mesh facets
will be equal to the specified 'Min Edge Length' if possible.
Using edge meshing results in greater simulation accuracy
at the expense of increased problem size because it allows
for high frequency current crowding.
225 eMD_NoEdgeMeshForThick This setting determines if conductors meshed as thick metal
will use edge meshing (See 'Use Edge Meshing' and 'Model
as Zero Thickness'). Typically edge meshing on thick metal
is not required, because the sidewall mesh captures the
current crowding effect at high frequencies. Edge meshing
thick conductors can result in better formed meshes as it
allows better transitions between via, thin and thick metals
if all are edge meshed.
226 eMD_EdgeMeshVias This setting determines if vias will use edge meshing (See
'Use Edge Meshing'). Typically edge meshing vias is
unnecessary due to their small cross sectional dimensions.
Edge meshing of vias in better formed meshes as it allows
better transitions between via, thin and thick metals if all
are edge meshed.
227 eMD_MinimalZMesh This setting effects the meshing of vertical facets in vias or
thick conductors that is very similar to 'Edge Meshing' in
the x/y plane. While edge meshing is typically not needed
in the z direction, it can increase simulation accuracy near
geometrical locations where the current transitions from
vertical to horizontal facets.

2260 NI AWR Design Environment


EMStructures

Number Name Description


228 eMCO_DO_USE_ABS_DIMS Determines the length dimensions units on this dialog.
Relative to cell grid - Relative to enclosure grid. Absolute
dimensions - In project units
229 eMCO_MESH_MIN_EDGE_RATIO The minimum desired edge length in the mesh relative to
the enclosure grid. This dimension will determine the width
of edge mesh if edge meshing is enabled. Further this value
will influence decimation if enabled.
230 eMCO_MESH_MIN_FEATURE_RATIO The minimum feature size retained in the mesh relative to
the enclosure grid.This dimension determines minimum
feature size required to be retained in the mesh.Features in
the mesh below this value may be eliminated in order to
improve the mesh quality.Importantly, lines with widths
below this value may eliminated from the mesh.A value of
zero means that the feature size is determined as a fractional
ratio of the Min Edge Length determined by the decimation
level.This last behavior is retained for legacy reasons.
231 eMCO_MESH_MIN_EDGE_DIM The minimum desired edge length in project units. This
dimension will determine the width of edge mesh if edge
meshing is enabled. Further this value will influence
decimation if enabled.
232 eMCO_MESH_MIN_FEATURE_DIM The minimum feature size retained in the mesh in project
units. This dimension determines minimum feature size
required to be retained in the mesh. Features in the mesh
below this value may be eliminated in order to improve the
mesh quality. Importantly, lines with widths below this
value may eliminated from the mesh. A value of zero means
that the feature size is determined as a fractional ratio of the
Min Edge Length determined by the decimation level. This
last behavior is retained for legacy reasons.
233 eAX_meshMaxAspectRatio Max desired geometrical edge length in the mesh relative
to the 'Min Edge Length'. Importantly the resulting max
geometrical edge length can be reduced beyond this desired
length if it exceeds the max electrical edge length. The max
electrical edge length is determined as fraction of the
minimum electrical wavelength. This fraction is determined
by the 'Mesh Density' setting and ranges from 1/32 to 1/8.
The max electrical wavelength is determined at the 'Meshing
Frequency' in the layer of the stackup with the highest index
of refraction.
234 eMCO_MAX_T_PLATED_LINE A port connected to a stacked configuration of conductors
and vias can be meshed in two ways depending upon the
total thickness of the stacked configuration. If the total
thickness is less than the specified dimension, the port will
be meshed to excite the entire vertical cross section of the
stacked metal as if it was one metal (plated metal). If the
total thickness of the stacked configuration exceeds the
specified thickness, the port will be meshed as if it is

API Scripting Guide 2261


ExternalEditor

Number Name Description


exciting the specified conductor of a via stack. The stack
thickness is determined locally at the x/y location of the
port and includes metals looking up and down in the z
direction.
235 AWR_JobSchedulerMaxProcs Maximum number of logical processors (as seen by OS) to
allocate for the job (0 = Use all available, -1 = Use all but
one, etc.)
236 AWR_JobSchedulerMinProcs Minimum number of logical processors (as seen by OS) to
allocate for the job (0 = Use all available, -1 = Use all but
one, etc.)
237 AWR_JobSchedulerThreadsPerProc The number of computational threads created for each
allocated logical processor (Recommended settings:
Axiem=1-2, Analyst=1)
238 AWR_JobSchedulerJobOSPriority The Operating System priority to assign to the job process
once it's running. (Default=Normal, or the value set in the
user.ini file, if any)
239 AWR_JobSchedulerJobRemotePreference Preference for how to dispatch the job if remote job servers
are available
240 AWR_JobSchedulerJobPerfPreference The preferred processor performance of the server to be
assigned to the job, if the job is executed remotely.
241 AWR_JobSchedulerJobMemCapPreference The preferred memory capacity of the server to be assigned
to the job, if the job is executed remotely.
242 AWR_JobSchedulerJobRunAsMWOJob ALL simulations for this document will be done in a separate
MWO simulation process
243 AWR_UseResultsForPartialSwp Allow a swept parameter simulation to use the results when
some of the sweep points failed to simulate
244 Mesh_meshDensity Specify mesh density
245 Mesh_maxX X max of cells per subsection limits
246 Mesh_maxY Y max of cells per subsection limits
247 Mesh_minX X min of cells per subsection limits
248 Mesh_minY Y min of cells per subsection limits
249 Mesh_conformalCells Conformal meshing
250 Mesh_trngleCells Allow triangle meshing
251 Default1 Example option

ExternalEditor
A MWOffice ExternalEditor object.

2262 NI AWR Design Environment


ExternalEditor

Properties

Name Data Type Description


CommandLine String Returns the comnand line passed to the ExternalEditor when
opened.
Extension String Returns the file name extension processed by the
ExternalEditor.
Name String Returns/Sets the name used in code to identify an object.
Path String Returns the path to the ExternalEditor executable.

Methods
Close

Description: Sends a message to have the ExternalEditor close.

Returns: Boolean

Syntax: Function Close() As Boolean

RunScript

Description: Passes a script to the ExternalEditor to execute.

Returns: Boolean

Syntax: Function RunScript(script As String) As Boolean

Save

Description: Sends a message to have the ExternalEditor save.

Returns: Boolean

Syntax: Function Save() As Boolean

Show

Description: Sends a message to have the ExternalEditor show or hide.

Returns: Boolean

Syntax: Function Show(Show As mwEECmdShow) As Boolean

Update

Description: Sends a message to have the ExternalEditor to update.

Returns: Boolean

Syntax: Function Update() As Boolean

API Scripting Guide 2263


EM3DStructure

EM3DStructure
A MWOffice EM3DStructure object.

Properties

Name Data Type Description


Changed Boolean Returns/sets a value that indicates if the EM3DStructure is
changed.
Embedded Boolean Returns a value that indicates if the EM3DStructure
document is embedded in the project or external.
Enabled Boolean Returns/sets a value that indicates if the EM3DStructure is
enabled.
FilePath String Returns a path to this EM3DStructure document.
Name String Returns/Sets the name used in code to identify an object.
Properties Properties Returns a reference to a collection of Property objects.
Schematic Schematic Returns a reference to a MWOffice Schematic object.
Windows Windows Returns a reference to a collection of Window objects.

Methods
Activate

Description: Brings any existing active window on the EM3DStructure object to the forground.

Returns: Void

Syntax: Sub Activate()

CopyToClipboard

Description: Copies the object to the system clipboard.

Returns: Boolean

Syntax: Function CopyToClipboard() As Boolean

CopyViewToClipboard

Description: Copies the object to the system clipboard.

Returns: Boolean

Syntax: Function CopyViewToClipboard() As Boolean

Export

Description: Exports the EM3DStructure object to a specified file.

Returns: Boolean

2264 NI AWR Design Environment


EM3DStructures

Syntax: Function Export(Filename As String) As Boolean

NewWindow

Description: Creates a new window on the EM3DStructure object.

Returns: Window

Syntax: Function NewWindow(__MIDL__IEM3DStructure0000 As mwWindowType) As Window

OpenExternalEditor

Description: Opens the EM3DStructure design in an external editor

Returns: ExternalEditor

Syntax: Function OpenExternalEditor(Type As mwExternalEditorType, [cmdShow As mwEECmdShow = 0]) As


ExternalEditor

PrintOut

Description: Sends the object to the current printer.

Returns: Boolean

Syntax: Function PrintOut() As Boolean

PrintView

Description: Sends the object to the current printer.

Returns: Boolean

Syntax: Function PrintView() As Boolean

Simulate

Description: Submit the EM3DStructure document for simulation.

Returns: Boolean

Syntax: Function Simulate(DefDataSetName As String) As Boolean

Update

Description: Update the structure to refresh any changes made by external editors.

Returns: Void

Syntax: Sub Update()

EM3DStructures
A collection of EM3DStructure objects.

API Scripting Guide 2265


EM3DStructures

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item EM3DStructure Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: EM3DStructure

Syntax: Function Add(StructureName As String) As EM3DStructure

AddLinked

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Void

Syntax: Sub AddLinked(StructureName As String, Filename As String, ppVal As EM3DStructure)

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Import

Description: Adds a Netlist object to the collection from a file and returns a reference to the created object.

Returns: EM3DStructure

Syntax: Function Import(Filename As String) As EM3DStructure

LinkTo

Description: Adds an Electromagnetic structure referencing an external file and returns a reference to the created object.

Returns: EM3DStructure

Syntax: Function LinkTo(Filename As String) As EM3DStructure

2266 NI AWR Design Environment


Face

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

Face
An MWOffice Face object.

Click to see examples

Properties

Name Data Type Description


AdjacentObjects ObjectNames Returns a reference to a collection of MWOffce ObjectName
objects.
Alignment mwFaceAlignment Returns/sets a value which specifies the alignment style of
a Face object.
AreaEnabled Boolean Returns/sets if the area portion of an area pin face is enabled
or if it is being treated as a segment face.
ConnectType Long Returns/set the connect type for this MWOffice Face object.
Connected Boolean Returns if the face is connected to a physical net.
ConnectedNetName String Returns the name of the PhysicalNet object the face is
connected to or an empty string if it is not connected.
ConnectionPoint Vertex Returns a reference to a Vertex object.
DrawingLayer String Returns the name of the drawing layer associated with this
Face object.
ElementName String Returns the name of the element associated with this Face
object.
Flipped Boolean Returns/sets a value which specifies if the Face object is
flipped.
GroupNumber Long Returns/sets the group number for this MWOffice Face
object.
GroupType mwFaceGroupType Returns/sets the group type for this MWOffice Face object.
Highlight Boolean Returns/sets the highlight state for this face object.
LayerProperty mwFaceMultiLayerProperty Returns/sets a value which specified the multi-layer drawing
property of a Face object.
NodeNumber Int Returns the unique node number of the Face object.
Offset Offset Returns a reference to a Vertex object.
OffsetAngle Double Returns/sets the offset angle of the Face object.
PortNumber Int Returns the port number of a Face object.

API Scripting Guide 2267


Faces

Name Data Type Description


SnapToAdjacent Boolean Returns/sets a value which specifies if the Face object should
snap to an adjacent face.
SnapToObject String Returns/sets the snap to object for this face format
$lt;name>.$lt;id>:$lt;port number> for example
MLIN:TL2:1.
SubPortNumber Int Returns the sub port number of the Face object.
Type mwFaceShapeType Returns the type segment or area pin of this face object.
Vertices Vertices Returns a reference to a collection of Vertex objects.

Faces
A collection of MWOffice Face objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Face Returns a specific item of a Collection object either by
position or by key.

Layout
An MWOffice Layout object.

Click to see examples

Properties

Name Data Type Description


Boundary Boundary Returns a reference to a Boundary object.
CanPaste Boolean Returns a value that determines the clipboard contents can
be pasted to the object.
ConnectivityHighlighter ConnectivityHighlighter Returns a reference to an MWOffice
ConnectivityHighlighter object.
DesignRuleChecker DesignRuleChecker Returns a reference to a DesignRuleChecker object.
DrawingObjects DrawingObjects Returns a reference to a collection of DrawingObjects.
EMPorts EMPorts Returns a reference to an EMPorts collection.
Equations Equations Returns a reference to a collection of Equation objects.
GridSnapMultiple Double Returns/sets a value which specifies the grid snap multiple.
GridVisible Boolean Returns/sets a value that specifies if the snap grid is visible
for the Layout.

2268 NI AWR Design Environment


Layout

Name Data Type Description


Info LayoutInfo Returns a reference to a MWOffice LayoutInfo object.
LayoutTests ComponentTests Returns a reference to a collection of ComponentTest
objects.
LayoutVsSchematicChecker LayoutVsSchematicChecker Returns a reference to a LayoutVsSchematicChecker object.
Name String Returns the name used in code to identify an object.
Options Options Returns a reference to a collection of Option objects.
Orthogonal Boolean Returns/sets a value which specifies if layout drawing should
be only orthogonal.
PhysicalNets PhysicalNets Returns a reference to a MWOffice PhysicalNets collection.
ProcessDefinition String Returns/sets the name of the layout process definition
associated with this layout.
SelectedObjects SelectedDrawingObjects Returns a reference to a collection of DrawingObjects.
ShapeModifiers ShapeModifiers Returns a reference to a collection of ShapeModifier objects.
SnapToGrid Boolean Returns/sets a value which specifies if grid snapping is
enabled.
ThreeDViews ThreeDViews Returns a reference to a MWOffice 3DViews collection.
UseProjectOptions Boolean Returns/sets a value which specifies if the global project
options should be used.
Views Views Returns a reference to a MWOffive Views collection.
Windows Windows Returns a reference to a collection of Window objects.

Methods
Activate

Description: Activates the objects.

Returns: Void

Syntax: Sub Activate()

CopyToClipboard

Description: Copies the object to the system clipboard.

Returns: Void

Syntax: Sub CopyToClipboard()

CopyToClipboardEx

Description: Copies the object to the system clipboard.

Returns: Boolean

Syntax: Function CopyToClipboardEx(Type As mwDesignViewType) As Boolean

API Scripting Guide 2269


Layout

CopyViewToClipboard

Description: Copies the object to the system clipboard.

Returns: Boolean

Syntax: Function CopyViewToClipboard([Type As mwDesignViewType = 0]) As Boolean

CreateCell

Description: Creates a GDS cell from the layout.

Returns: Cell

Syntax: Function CreateCell(LibraryName As String, CellName As String, [IncludeObjects As mwObjectIncludeType


= 1], [FlattenLayout As Boolean = -1]) As Cell

CreateSnapshot

Description: Returns a reference to a layout snapshot object.

Returns: Snapshot

Syntax: Function CreateSnapshot() As Snapshot

Export

Description: Exports a design document file from MWOffice.

Returns: Boolean

Syntax: Function Export(Filename As String, ExportMap, [Flat As Boolean = 0]) As Boolean

InvokeCommand

Description: Invoke a menu command by specifying the name for the command. Arguments must be supplied for all
required input.

Returns: Void

Syntax: Sub InvokeCommand(CommandName As String, [Arguments], [pRet])

NewWindow

Description: Displays the object in new window.

Returns: Window

Syntax: Function NewWindow(WindowType As mwLayoutWindowType) As Window

Paste

Description: Pastes the system clipboard to the object.

Returns: Boolean

2270 NI AWR Design Environment


Layout

Syntax: Function Paste(x As Double, y As Double, [CCWRotation As Double = 0], [Flipped As Boolean = 0]) As
Boolean

PasteRelative

Description: Pastes the system clipboard to the object.

Returns: Boolean

Syntax: Function PasteRelative(dx As Double, dy As Double, [CCWRotation As Double = 0], [Flipped As Boolean =
0]) As Boolean

PrintOut

Description: Sends the object to the current printer.

Returns: Void

Syntax: Sub PrintOut()

PrintOutEx

Description: Sends the object to the current printer.

Returns: Boolean

Syntax: Function PrintOutEx([Type As mwDesignViewType = 0]) As Boolean

PrintView

Description: Sends the object to the current printer.

Returns: Boolean

Syntax: Function PrintView([Type As mwDesignViewType = 0]) As Boolean

Refresh

Description: Refresh any windows open on the layout document.

Returns: Void

Syntax: Sub Refresh()

RegenerateLayout

Description: Deletes and regenerates all the cell objects in layout, may cause objects to shift in position.

Returns: Boolean

Syntax: Function RegenerateLayout() As Boolean

SnapTogether

Description: Snaps together the layout objects.

API Scripting Guide 2271


Layout

Returns: Void

Syntax: Sub SnapTogether(SnapType As mwLayoutSnapType)

StartCommand

Description: Start a menu command by specifying the name for the command. The user will need to complete any
required input.

Returns: Void

Syntax: Sub StartCommand(CommandName As String, [pRet])

Update

Description: Updates the size and positions of objects in the layout

Returns: Void

Syntax: Sub Update()

Options

Number Name Description


1 LayoutGridSpacing Returns/sets the grid spacing for layouts in the project.
2 LayoutDatabaseUnits Returns/sets the database units for layouts in the project.
3 LayoutAngleSnapDiv Returns/sets the number of snap divisions per quadrant for
layouts in the project.
4 LayoutSnapTogetherMode Returns/sets the snap-together mode.
5 LayoutNoRotateOnSnap Returns/sets if rotation should be allowed during snapping
in layouts.
6 FaceInsetOptions Returns/sets the automatic options for face insets on layouts.
7 LayoutPointsPerCircle Returns/Sets the number of points used per circle in layout
8 LayoutConnectionLineType Returns/Sets the type of lines drawn between connected
objects in layout, values come from
mwLayoutConnectionLineTypes enumeration
9 LayoutSnapToClosestFace Returns/sets if layout connections should snap to the closest
face for a node.
10 LayFixedCellOrigin Layout keep cell origin fixed rather than using fixed face
for placement
11 LayFixedSubCktOrigin Layout keep subcircuit origin fixed rather than using fixed
face for placement
12 LayCellOriginOnGrid Layout always keep cell origins on grid
13 LayExcludePcell Layout allows pcell origins to float
14 ExportMergeShapes Returns/sets if layout shapes on +/- layers should be merged
on export.
15 ExportSubcircuitsAsInstances Returns/sets if subcircuits should be exported as instances.

2272 NI AWR Design Environment


CellEditor

Number Name Description


16 LayCellLimitNameLen Layout limit cell names to comply with GDSII library
specifications.
17 LayExportCellFaces Returns/sets the options for exporting cell faces from layout.
18 LayCellRemoveIllegalChars Layout remove illegal characters from cell names on
import/export to comply with GDSII library specifications.
19 InstanceExportOptions Returns/sets the options for exporting instances from layout.
20 LayoutCellExportOptions Returns/sets the options for exporting layout cells from
layout.
21 LayExportWriteParamMap When exporting write layout cell parameter map.
22 LayExportPromptForLPF Prompt to load newer LPF files.
23 LayExportUseParentLPFForEM Use parent LPF for EM subcircuits.
24 LimitVerticesPerPolygon Returns/sets maximum number of vertices per polygon on
GDSII export
25 ExportUnionShapes Returns/sets if layout shapes should be union-ed on export.
26 PathWidth Returns/sets the default path width, value is in integer
nanometers.
27 PathMiterOffset Returns/sets the default miter offset, value is in integer
nanometers.
28 PathEndType Returns/sets the default path end style.
29 PathMiterType Returns/sets the default path miter style.
30 DrawPathAsPolygon Returns/sets if path is being drawn as polygon
31 LayPathDefProcessLineType Layout Path default line type when using process layers.
32 LayPathDefaultUseProcessLayers Paths by default use process layers.

CellEditor
An MWOffice CellEditor object.

Properties

Name Data Type Description


Boundary Boundary Returns a reference to a Boundary object.
CanPaste Boolean Returns a value that determines the clipboard contents can
be pasted to the object.
CellEditorTests ComponentTests Returns a reference to a collection of ComponentTest
objects.
DesignRuleChecker DesignRuleChecker Returns a reference to a DesignRuleChecker object.
DrawingObjects DrawingObjects Returns a reference to a collection of DrawingObjects.
GridSnapMultiple Double Returns/sets a value which specifies the grid snap multiple.
GridVisible Boolean Returns/sets a value that specifies if the snap grid is visible
for the Layout.

API Scripting Guide 2273


CellEditor

Name Data Type Description


Name String Returns the name used in code to identify an object.
Orthogonal Boolean Returns/sets a value which specifies if layout drawing should
be only orthogonal.
SelectedObjects SelectedDrawingObjects Returns a reference to a collection of DrawingObjects.
SnapToGrid Boolean Returns/sets a value which specifies if grid snapping is
enabled.
Views Views Returns a reference to a MWOffive Views collection.
Windows Windows Returns a reference to a collection of Window objects.

Methods
Activate

Description: Activates the objects.

Returns: Void

Syntax: Sub Activate()

CopyToClipboard

Description: Copies the object to the system clipboard.

Returns: Void

Syntax: Sub CopyToClipboard()

CopyToClipboardEx

Description: Copies the object to the system clipboard.

Returns: Boolean

Syntax: Function CopyToClipboardEx(Type As mwDesignViewType) As Boolean

CopyViewToClipboard

Description: Copies the object to the system clipboard.

Returns: Boolean

Syntax: Function CopyViewToClipboard([Type As mwDesignViewType = 0]) As Boolean

CreateCell

Description: Creates a GDS cell from the layout.

Returns: Cell

Syntax: Function CreateCell(LibraryName As String, CellName As String, [IncludeObjects As mwObjectIncludeType


= 1], [FlattenLayout As Boolean = -1]) As Cell

2274 NI AWR Design Environment


CellEditor

CreateSnapshot

Description: Returns a reference to a layout snapshot object.

Returns: Snapshot

Syntax: Function CreateSnapshot() As Snapshot

Export

Description: Exports a design document file from MWOffice.

Returns: Boolean

Syntax: Function Export(Filename As String, ExportMap, [Flat As Boolean = 0]) As Boolean

InvokeCommand

Description: Invoke a menu command by specifying the name for the command. Any required input will need to be
supplied in arguments.

Returns: Void

Syntax: Sub InvokeCommand(CommandName As String, [Arguments], [pRet])

NewWindow

Description: Displays the object in new window.

Returns: Window

Syntax: Function NewWindow() As Window

Paste

Description: Pastes the system clipboard to the object.

Returns: Boolean

Syntax: Function Paste(x As Double, y As Double, [CCWRotation As Double = 0], [Flipped As Boolean = 0]) As
Boolean

PasteRelative

Description: Pastes the system clipboard to the object.

Returns: Boolean

Syntax: Function PasteRelative(dx As Double, dy As Double, [CCWRotation As Double = 0], [Flipped As Boolean =
0]) As Boolean

PrintOut

Description: Sends the object to the current printer.

API Scripting Guide 2275


CellEditors

Returns: Void

Syntax: Sub PrintOut()

Refresh

Description: Refresh any windows open on the layout document.

Returns: Void

Syntax: Sub Refresh()

SaveCell

Description: Saves any edits to the cell back to the project.

Returns: Boolean

Syntax: Function SaveCell() As Boolean

StartCommand

Description: Start a menu command by specifying the name for the command. Any required input will need to be
supplied by the user interactively.

Returns: Void

Syntax: Sub StartCommand(CommandName As String, [pRet])

Update

Description: Updates the size and positions of objects in the layout

Returns: Void

Syntax: Sub Update()

CellEditors
A collection of MWOffice CellEditor objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item CellEditor Returns a specific item of a Collection object either by
position or by key.

2276 NI AWR Design Environment


Enclosure

Enclosure
An MWOffice Enclosure object.

Click to see examples

Properties

Name Data Type Description


EnclosureBottom BoundaryModel Returns the boundary model for the bottom of an Enclosure
object.
EnclosureTop BoundaryModel Returns the boundary model for the top of an Enclosure
object.
Height Double Returns the height value of the enclosure object.
XCellSize Double Returns the X value of the Cell size for the enclosure object.
XDimension Double Returns/sets the X dimension of the enclosure.
XDivisions Int Returns/sets the number of X divisions in the enclosure
object.
YCellSize Double Returns the Y value of the Cell size for the enclosure object.
YDimension Double Returns/sets the Y dimension of the enclosure.
YDivisions Int Returns/sets the number of Y divisions in the enclosure
object.

MaterialLayer
An MWOffice Material Layer object.

Click to see examples

Properties

Name Data Type Description


BulkConductivity Double Returns/sets the bulk conductivity of a MaterialLayer object.
DielectricConstant Double Returns/sets the relative dielectric constant of a
MaterialLayer object.
Hatch mwHatchStyle Returns/sets the hatch pattern of a MaterialLayer object.
LossTangent Double Returns/sets the loss tangent of a MaterialLayer object.
Thickness Double Returns/sets the thickness of a MaterialLayer object.
ViaHatch mwHatchStyle Returns/sets the hatch pattern for vias in a MaterialLayer
object.
ViewScale Double Returns/sets the view scale of a MaterialLayer object.

MaterialLayers
A collection of MWOffice Material Layer objects.

API Scripting Guide 2277


ShapeSubObject

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item MaterialLayer Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: MaterialLayer

Syntax: Function Add([Layer As Int = 1], [Hatch As mwHatchStyle = 5], [ViaHatch As mwHatchStyle = 4], [Thickness
As Double = 9.99999974737875E-05], [DielectricConstant As Double = 1], [LossTangent As Double = 0],
[BulkConductivity As Double = 0], [ViewScale As Double = 1]) As MaterialLayer

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

ShapeSubObject
An MWOffice ShapeSubObject object.

Properties

Name Data Type Description


Attributes Attributes Returns a reference to a collection of Attribute objects.
Boundary Boundary Returns a reference to a Boundary object.
PolyVertices Vertices Returns a reference to a collection of Vertex objects.
Segments ShapeSegments Returns a reference to a collection of ShapeSegment objects.
Type mwShapeSubObjectType Returns the type of the ShapeSubObject object.
Vertices Vertices Returns a reference to a collection of Vertex objects.

ShapeSubObjects
A collection of MWOffice ShapeSubObject objects.

2278 NI AWR Design Environment


ShapeSegment

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ShapeSubObject Returns a specific item of a Collection object either by
position or by key.

ShapeSegment
An MWOffice ShapeSegment object.

Properties

Name Data Type Description


Angle Double Returns the angle of the segment.
ArcSegment ShapeArcSegment Returns a reference to a MWOffice ShapeArcSegment
object.
Begin Vertex Returns a reference to a Vertex object.
End Vertex Returns a reference to a Vertex object.
IsArcSegment Boolean Returns true if teh segment is an arc segment.
Length Double Returns the length of the segment.

ShapeSegments
A collection of MWOffice ShapeSegment objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ShapeSegment Returns a specific item of a Collection object either by
position or by key.

ShapeArcSegment
An MWOffice ShapeArcSegment object.

Properties

Name Data Type Description


Center Vertex Returns a reference to a Vertex object.

API Scripting Guide 2279


ShapeArcSegments

Name Data Type Description


Direction mwShapeArcDirection Returns a value which indicates the direction of the
ShapeArcSegment.
Length Double Returns the distance along the arc points from the begin
point to the end point.
Points Vertices Returns a reference to a collection of Vertex objects.

ShapeArcSegments
A collection of MWOffice ShapeArcSegment objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ShapeArcSegment Returns a specific item of a Collection object either by
position or by key.

Shape
An MWOffice Shape object.

Click to see examples

Properties

Name Data Type Description


Attributes Attributes Returns a reference to a collection of Attribute objects.
Boundary Boundary Returns a reference to a Boundary object.
DrawingLayer DrawingLayer Returns a reference to a Drawing Layer object.
HierarchicalPath String Returns a value for some shapes which specifies the
hierarchical path for the shape
PolyVertices Vertices Returns a reference to a collection of Vertex objects.
Segments ShapeSegments Returns a reference to a collection of ShapeSegment objects.
SubObjects ShapeSubObjects Returns a reference to a collection of MWOffice
ShapeSubObject objects.
Type mwShapeType Returns a value which specifies the type of a Shape object.
Vertices Vertices Returns a reference to a collection of Vertex objects.

Shapes
A collection of MWOffice Shape objects.

2280 NI AWR Design Environment


Shapes

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Shape Returns a specific item of a Collection object either by
position or by key.
ReadOnly Boolean Returns a value which specifies if the shape collection is
read-only and cannot have shapes added.

Methods
AddArc

Description: Adds a arc shape to the Shapes collection.

Returns: Shape

Syntax: Function AddArc(xCenter As Double, yCenter As Double, Radius As Double, StartAngle As Double, EndAngle
As Double, [LayerName As String = ""]) As Shape

AddDrillHole

Description: Adds a drill hole shape to a Shapes collection.

Returns: Shape

Syntax: Function AddDrillHole(x As Double, y As Double, ToolName As String) As Shape

AddEllipse

Description: Adds an ellipse shape to a Shapes collection.

Returns: Shape

Syntax: Function AddEllipse(x As Double, y As Double, dx As Double, dy As Double, [LayerName As String = ""])
As Shape

AddFace

Description: Adds a cell face shape to the Shapes collection. Connect values are from mwPortFaceConnectTypes enum.

Returns: Shape

Syntax: Function AddFace(x1 As Double, y1 As Double, x2 As Double, y2 As Double, [PortNumber As Int = 0],
[ConnectType As Int = 0]) As Shape

AddFaceEx

Description: Adds a cell face shape to the Shapes collection. Connect values are from mwPortFaceConnectTypes enum.

API Scripting Guide 2281


Shapes

Returns: Shape

Syntax: Function AddFaceEx(x1 As Double, y1 As Double, x2 As Double, y2 As Double, [PortNumber As Int = 0],
[ConnectType As Int = 0], [LayerName As String = ""]) As Shape

AddPath

Description: Adds a path shape to a Shapes collection.

Returns: Shape

Syntax: Function AddPath(XYPoints As SafeArray, Width As Double, [LayerName As String = ""], [EndStyle As
mwPathEndType = 1], [MiterStyle As mwPathMiterType = 1], [OffsetMiterAmount As Double = 0]) As Shape

AddPin

Description: Adds a pin shape to the shapes collection. Connect values are from mwPortFaceConnectTypes enum.

Returns: Shape

Syntax: Function AddPin(XYPoints As SafeArray, [LayerName As String = ""], [PortNumber As Int = 0], [ConnectType
As Int = 0]) As Shape

AddPolygon

Description: Adds a polygon shape to a Shapes collection.

Returns: Shape

Syntax: Function AddPolygon(XYPoints As SafeArray, [LayerName As String = ""]) As Shape

AddRectangle

Description: Adds a rectangle shape to a Shapes collection.

Returns: Shape

Syntax: Function AddRectangle(x As Double, y As Double, dx As Double, dy As Double, [LayerName As String = ""])
As Shape

AddText

Description: Adds a text shape to a Shapes collection.

Returns: Shape

Syntax: Function AddText(x As Double, y As Double, Height As Double, Text As String, [LayerName As String = ""],
[RotationAngle As Double = 0], [FontName As String = ""], [Bold As Boolean = 0], [Italic As Boolean = 0],
[DrawAsPolygons As Boolean = -1]) As Shape

AddTextEx

Description: Adds a text shape to a Shapes collection.

Returns: Shape

2282 NI AWR Design Environment


DrawingSubObject

Syntax: Function AddTextEx(x As Double, y As Double, Height As Double, Text As String, [DrawAsPolygons As
Boolean = -1], [LayerName As String = ""], [TextAlignment As mwTextAlignment = 5], [RotationAngle As Double =
0], [FontName As String = ""], [Bold As Boolean = 0], [Italic As Boolean = 0]) As Shape

AddVia

Description: Adds a via shape to the Shapes collection. If the via should be a port the optional bPort is true.

Returns: Shape

Syntax: Function AddVia(x As Double, y As Double, dx As Double, dy As Double, [LayerName As String = ""], [IsPort
As Boolean = 0]) As Shape

DrawingSubObject
An MWOffice DrawingSubObject object.

Properties

Name Data Type Description


Attributes Attributes Returns a reference to a collection of Attribute objects.
Boundary Boundary Returns a reference to a Boundary object.
EditHandles EditHandles Returns a reference to a collection of MWOffice EditHandle
objects.
PolyVertices Vertices Returns a reference to a collection of Vertex objects.
Segments DrawingSegments Returns a reference to a collection of MWOffice
DrawingSegment objects.
Selected Boolean Returns a value indicating whether the DrawingSubObject
is selected.
Type mwDrawingSubObjectType Returns the type of the drawing subobject.
Vertices Vertices Returns a reference to a collection of Vertex objects.

Methods
Delete

Description: Deletes the DrawingSubObject from the parent DrawingObject.

Returns: Boolean

Syntax: Function Delete() As Boolean

Move

Description: Moves the DrawingSubObject by the given offset values.

Returns: Boolean

Syntax: Function Move(dx As Double, dy As Double) As Boolean

API Scripting Guide 2283


DrawingSubObjects

DrawingSubObjects
A collection of MWOffice DrawingSubObject objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DrawingSubObject Returns a specific item of a Collection object either by
position or by key.
ReadOnly Boolean Returns a value indicating whether the DrawingSubObjects
collection is read-only.

Methods
AddCircle

Description: Adds a circle to the DrawingSubObjects collection.

Returns: DrawingSubObject

Syntax: Function AddCircle(x As Double, y As Double, r As Double) As DrawingSubObject

AddEllipse

Description: Adds an ellipse ot the DrawingSubObjects collection.

Returns: DrawingSubObject

Syntax: Function AddEllipse(x As Double, y As Double, dx As Double, dy As Double) As DrawingSubObject

AddPolygon

Description: Adds a polygon to the DrawingSubObjects collection.

Returns: DrawingSubObject

Syntax: Function AddPolygon(XYPoints As SafeArray) As DrawingSubObject

AddRectangle

Description: Adds a rectangle to the DrawingSubObjects collection.

Returns: DrawingSubObject

Syntax: Function AddRectangle(x As Double, y As Double, dx As Double, dy As Double) As DrawingSubObject

Remove

Description: Removes a specific member from a collection.

2284 NI AWR Design Environment


DrawingSegment

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

DrawingSegment
An MWOffice DrawingSegment object.

Properties

Name Data Type Description


Angle Double Returns the angle of the segment.
ArcSegment DrawingArcSegment Returns a reference to a MWOffice DrawingArcSegment
object.
Begin Vertex Returns a reference to a Vertex object.
CanMakeArcSegment Boolean Returns if the segument supports conversion to an arc
segment.
End Vertex Returns a reference to a Vertex object.
IsArcSegment Boolean Returns if the segment is an arc segment.
Length Double Returns the length of the segment.

Methods
MakeArcSegment

Description: Makes the segment into an arc segment with a specific center point and direction.

Returns: DrawingArcSegment

Syntax: Function MakeArcSegment(centerX As Double, centerY As Double, dir As mwDrawingArcDirection) As


DrawingArcSegment

RevertArcSegment

Description: Reverts the segment from an arc segment into a normal straight segment.

Returns: Boolean

Syntax: Function RevertArcSegment() As Boolean

API Scripting Guide 2285


DrawingSegments

DrawingSegments
A collection of MWOffice DrawingSegment objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DrawingSegment Returns a specific item of a Collection object either by
position or by key.

DrawingArcSegment
An MWOffice DrawingArcSegment object.

Properties

Name Data Type Description


Center Vertex Returns a reference to a Vertex object.
Direction mwDrawingArcDirection Returns/sets a value which indicates the direction of the
DrawingArcSegment.
Length Double Returns the distance along the arc points from the begin
point to the end point.
Points Vertices Returns a reference to a collection of Vertex objects.

DrawingArcSegments
A collection of DrawingArcSegment objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DrawingArcSegment Returns a specific item of a Collection object either by
position or by key.

Snapshot
An MWOffice Snapshot object.

Click to see examples

2286 NI AWR Design Environment


Snapshot

Properties

Name Data Type Description


Boundary Boundary Returns a reference to a Boundary object.
Shapes Shapes Returns a reference to a collection of Shape objects.

Methods
CopyLayerToCellEditor

Description: Copies the shapes on the specified layer of this snapshot to the given cell editor.

Returns: Boolean

Syntax: Function CopyLayerToCellEditor(pCellEdit As CellEditor, srcLayerName As String, x As Double, y As Double,


[just As mwPlacementJustfication = 2]) As Boolean

CopyLayerToLayout

Description: Copies the shapes on the specified layer of this snapshot to the given layout.

Returns: Boolean

Syntax: Function CopyLayerToLayout(pLayout As Layout, srcLayerName As String, x As Double, y As Double, [just


As mwPlacementJustfication = 2]) As Boolean

CopyLayerToSnapshot

Description: Copies the shapes on the specified layer of this snapshot to the given Snapshot.

Returns: Boolean

Syntax: Function CopyLayerToSnapshot(pSnapshot As Snapshot, srcLayerName As String, x As Double, y As Double,


[just As mwPlacementJustfication = 2]) As Boolean

CopyShapesToLayer

Description: Copies all the shapes from a source layer and adds them to a destination layer in the snapshot.

Returns: Boolean

Syntax: Function CopyShapesToLayer(sourceLayer As String, destinationLayer As String) As Boolean

CopyToCellEditor

Description: Copies the shapes of this snapshot to the given cell editor.

Returns: Boolean

Syntax: Function CopyToCellEditor(pCellEdit As CellEditor, x As Double, y As Double, [just As


mwPlacementJustfication = 2]) As Boolean

API Scripting Guide 2287


Snapshot

CopyToLayout

Description: Copies the shapes of this snapshot to the given layout.

Returns: Boolean

Syntax: Function CopyToLayout(pLayout As Layout, x As Double, y As Double, [just As mwPlacementJustfication =


2]) As Boolean

CopyToSnapshot

Description: Copies the shapes of this snapshot to the given Snapshot.

Returns: Boolean

Syntax: Function CopyToSnapshot(pSnapshot As Snapshot, x As Double, y As Double, [just As mwPlacementJustfication


= 2]) As Boolean

DeleteLayerShapes

Description: Deletes all the shapes on a layer from the snapshot.

Returns: Boolean

Syntax: Function DeleteLayerShapes(LayerName As String) As Boolean

ExclusiveOrLayersEx

Description: Process the shapes on the given source layers to produce the exclusive or of overlapping shapes in the
snapshot.

Returns: Boolean

Syntax: Function ExclusiveOrLayersEx(sourceLayer1 As String, sourceLayer2 As String, destinationLayer As String,


[keepLayer1 As Boolean = -1], [keepLayer2 As Boolean = -1]) As Boolean

ExclusiveOrShapes

Description: Process the shapes of this snapshot produce the exclusive or of overalapped shapes.

Returns: Boolean

Syntax: Function ExclusiveOrShapes([Type As mwExclusiveOrShapesType = 0], [destLayer As String = ""]) As Boolean

Export

Description: Exports a design document file from MWOffice.

Returns: Boolean

Syntax: Function Export(Filename As String, ExportMap, [LibraryName As String = ""], [CellName As String = ""],
[Flat As Boolean = 0]) As Boolean

2288 NI AWR Design Environment


Snapshot

IntersectLayersEx

Description: Process the shapes on the given source layers to produce the intersection of overlapping shapes in the
snapshot.

Returns: Boolean

Syntax: Function IntersectLayersEx(sourceLayer1 As String, sourceLayer2 As String, destinationLayer As String,


[keepLayer1 As Boolean = -1], [keepLayer2 As Boolean = -1]) As Boolean

IntersectShapes

Description: Process the shapes of this snapshot to produce the intersecton of overlapped shapes.

Returns: Boolean

Syntax: Function IntersectShapes([Type As mwIntersectShapesType = 0], [destLayer As String = ""]) As Boolean

MoveShapesToLayer

Description: Moves all the shapes of a source layer to a destination layer in the shapshot.

Returns: Boolean

Syntax: Function MoveShapesToLayer(sourceLayer As String, destinationLayer As String) As Boolean

ResizeCopyLayerShapes

Description: Copies all the shapes from a src layer to a destination layer while resizing them by a give amount.

Returns: Boolean

Syntax: Function ResizeCopyLayerShapes(Offset As Double, srcLayerName As String, destLayerName As String) As


Boolean

ResizeLayerShapes

Description: Resizes the shapes on the given layer in place in the snapshot.

Returns: Boolean

Syntax: Function ResizeLayerShapes(Offset As Double, LayerName As String) As Boolean

ResizeShapes

Description: Resizes the shapes of this snapshot in place on each layer in the snapshot.

Returns: Boolean

Syntax: Function ResizeShapes(Offset As Double) As Boolean

SubtractLayersEx

Description: Process the shapes to subtract overlapping sections of shapes on layer B from shapes on layer A in the
snapshot.

API Scripting Guide 2289


LibraryElement

Returns: Boolean

Syntax: Function SubtractLayersEx(sourceLayer1 As String, sourceLayer2 As String, destinationLayer As String,


[keepLayer1 As Boolean = -1], [keepLayer2 As Boolean = -1]) As Boolean

UnionLayersEx

Description: Process the shapes on the given source layers to combine overlapping shapes in the snapshot.

Returns: Boolean

Syntax: Function UnionLayersEx(sourceLayer1 As String, sourceLayer2 As String, destinationLayer As String,


[keepLayer1 As Boolean = -1], [keepLayer2 As Boolean = -1]) As Boolean

UnionShapes

Description: Unions the shapes of this snapshot to combine overlapping shapes.

Returns: Boolean

Syntax: Function UnionShapes([Type As mwUnionShapesType = 0], [destLayer As String = ""]) As Boolean

LibraryElement
An MWOffice LibraryElement object.

Properties

Name Data Type Description


Attributes Attributes Returns a reference to a collection of Attribute objects.
BrowserPath String Returns the browser path for a MWOffice LibraryElement
object.
Description String Returns a text description of the MWOffice LibraryElement
object.
Name String Returns/Sets the name used in code to identify an object.
SymbolName String Returns the default symbol name for the MWOffice
LibraryElement object.
Type mwLibraryElementType Returns a value indicating the type of this MWOffice
LibraryElement object.

LibraryElements
A collection of MWOffice LibraryElement objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.

2290 NI AWR Design Environment


Library

Name Data Type Description


Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item LibraryElement Returns a specific item of a Collection object either by
position or by key.

Library
An MWOffice Library object.

Properties

Name Data Type Description


Libraries Libraries Returns a reference to a MWOffice Libraries collection.
LibraryElements LibraryElements Returns a reference to a MWOffice LibraryElements
collection.
Name String Returns the name used in code to identify an object.

Libraries
A collection of MWOffice Library objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Library Returns a specific item of a Collection object either by
position or by key.

MeasurementInfo
An MWOffice MeasurementInfo object contains information about measurement types available in the application.

Properties

Name Data Type Description


Category String Returns the category name of a MeasurementInfo object.
DataUnitType mwUnitMultType Returns a value which specifies the data unit type of the
object.
Description String Returns the description of the object.
Flags Long Returns the flags for a measurement type
HelpContext Long Returns the help file context id for the object.
Name String Returns the name used in code to identify an object.

API Scripting Guide 2291


MeasurementInfos

Name Data Type Description


SimId String Returns the simulator type id for a measurement type
SweepUnitType mwUnitMultType Returns a value which specifies the sweep unit type of the
object.

MeasurementInfos
A collection of MWOffice MeasurementInfo objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item MeasurementInfo Returns a specific item of a Collection object either by
position or by key.

Model
An MWOffice Model object.

Properties

Name Data Type Description


Category String Returns the category name of level of a Model object.
CategoryPath String Returns a string that defines the category path of the Model
object.
Company String Returns the company name of the author for the object.
Description String Returns the description of the object.
Frequencies SafeArray Returns/sets the frequency of a Model object.
HelpContext Long Returns the help file context id for the object.
HelpFile String Returns the name of the help file for the object.
Levels Long Returns the number of levels of a Model object.
Module String Returns the module name of a Model object.
ModuleFilename String Returns a string that specifies the path to the module
containing this model.
NCorMatrix SafeArray Returns the N Correction results of the Model object
simulate.
Name String Returns the name used in code to identify an object.
NodeCount Long Returns the number of nodes of a Model object.
ParameterDefinitions ParameterDefinitions Returns a reference to a collection of ParameterDefinition
objects.

2292 NI AWR Design Environment


Models

Name Data Type Description


Priority mwModelPriorityType Returns the priority type for the Model Object.
PropertyFlags Long Returns the property flags for the Model object.
SimulatorTypeID String Returns a string that identifies the simulator type identifier
for the Model Object.
Symbol String Returns the symbol name of a Model object.
Version Long Returns the version of the object.
YMatrix SafeArray Returns the Y results of the Model object simulate.

Methods
None

Models
A collection of MWOffice Model objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Model Returns a specific item of a Collection object either by
position or by key.

LayoutCell
An MWOffice LayoutCell object.

Properties

Name Data Type Description


CompanyName String Returns the company name of a LayoutCell object.
Description String Returns a description of a LayoutCell object.
ModuleFilename String Returns the module file name of the layout cell which is the
path to the Dll for the cell.
ModuleName String Returns the module name of a LayoutCell object.
Name String Returns the name used in code to identify an object.
NumberNodes Long Returns the number of nodes in the cell.
ParameterCount Long Returns the number of parameters
ParameterNames SafeArray Returns the name of the parameters contained in a
parameter's data.
Version Long Returns the version number of a LayoutCell object.

API Scripting Guide 2293


LayoutCells

LayoutCells
A collection of MWOffice LayoutCell objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item LayoutCell Returns a specific item of a Collection object either by
position or by key.

Optimizer
An MWOffice Optimizer object.

Click to see examples

Properties

Name Data Type Description


BestCost Double Returns the best cost reached by the optimiztion.
CancelOnStop Boolean Returns/sets a value which specifies if the optimizer should
cancel the current iteration on stop.
Cost Double Returns the cost from the current optimization iteration.
Iteration Long Returns the number of current iteration.
MaxIterations Long Returns/sets the maximum number of iterations to perform.
Properties Properties Returns a reference to a collection of Property objects.
Running Boolean Returns/sets the running state of the optimizer.
ShowAllUpdates Boolean Returns/sets a value which specifies if the optimizer should
show all iteration updates.
SimulatorIteration Long Returns the number of current simulator iteration.
StopAtMin Boolean Returns/sets a value which specifies if the optimization is
to stop when the min cost is hit.
StopOnErr Boolean Returns/sets a value which specifies if the optimization is
to stop when there is a simulation error.
Type Variant Returns/sets a value which specifies the type of optimizer.
TypeCount Long Returns the number of types of optimizers.
TypeName String Returns the name of a Optimizer type.
Windows Windows Returns a reference to a collection of Window objects.

2294 NI AWR Design Environment


Optimizer

Methods
Continue

Description: Continues the current optimization.

Returns: Void

Syntax: Sub Continue()

NewWindow

Description: Displays the object in new window.

Returns: Window

Syntax: Function NewWindow() As Window

Reset

Description: Resets the optimization process.

Returns: Void

Syntax: Sub Reset()

Revert

Description: Reverts the optimization to the previous state.

Returns: Void

Syntax: Sub Revert(Name As String)

Save

Description: Saves the current optimization.

Returns: Void

Syntax: Sub Save(Name As String)

Start

Description: Starts the optimization process.

Returns: Void

Syntax: Sub Start()

Stop

Description: Stops the optimization process.

Returns: Void

API Scripting Guide 2295


Optimizer

Syntax: Sub Stop()

Events
NewLowCost

Description: Occurs when a new low cost has been arrived at.

Returns: HRESULT

Syntax: Event NewLowCost(Cost As Double)

NewUserMessage

Description: Occurs when the optimizer needs to display a message to the user.

Returns: HRESULT

Syntax: Event NewUserMessage(Message As String, Title As String, Type As Long)

SettingChanged

Description: Occurs when a setting has changed in the Optimizer.

Returns: HRESULT

Syntax: Event SettingChanged(Hint As mwOptimizerSetting, Data)

Started

Description: Occurs when an Optimization has been started.

Returns: HRESULT

Syntax: Event Started()

StatusChanged

Description: Occurs when there has been a change in the Optimizer status.

Returns: HRESULT

Syntax: Event StatusChanged(Status As String)

Stopped

Description: Occurs when an Optimization has stopped.

Returns: HRESULT

Syntax: Event Stopped()

UpdateIteration

Description: Occurs when during Optimization to provide the current iteration.

2296 NI AWR Design Environment


Synthesizer

Returns: HRESULT

Syntax: Event UpdateIteration(Iteration As Long)

UpdateTotalCost

Description: Occurs when the Optimization total cost should be updated.

Returns: HRESULT

Syntax: Event UpdateTotalCost(Cost As Double)

Synthesizer
An MWOffice Synthesis object.

Properties

Name Data Type Description


Description String Returns a description of the model.
ElectricalParameter Double Returns/sets the value of the electrical parameters.
ElectricalParameterNames SafeArray Returns the names of the electrical parameters.
ElectricalParameters Long Returns the number of electrical parameters.
Model String Returns/set the model of the synthesizer.
PhysicalParameter Double Returns/sets the value of the physical parameters.
PhysicalParameterNames SafeArray Returns the names of the physical parameters.
PhysicalParameters Long Returns the number of physical parameters.

Methods
Analyze

Description: Calculates the electrical parameters based on the physical parameters.

Returns: Void

Syntax: Sub Analyze()

Reset

Description: Resets the synthesizer object.

Returns: Void

Syntax: Sub Reset()

SetSynthesizeParameter

Description: Sets the physical parameter to be synthesized.

Returns: Void

API Scripting Guide 2297


Sweeper

Syntax: Sub SetSynthesizeParameter(Index, Guess As Double, Lower As Double, Upper As Double)

Synthesize

Description: Synthesizes physical parameters based on the electrical parameters.

Returns: Void

Syntax: Sub Synthesize()

Sweeper
An MWOffice Sweeper object.

Click to see examples

Properties

Name Data Type Description


Value Double Returns/sets the value of an added Equation or Parameter.

Methods
AddVariable

Description: Adds an Equation or Parameter to the Sweeper.

Returns: Void

Syntax: Sub AddVariable(Key As String, Variable)

RemoveVariable

Description: Removes an Equation or Parameter from the Sweeper.

Returns: Void

Syntax: Sub RemoveVariable(Key As String)

Update

Description: Updates the measurements with the added values.

Returns: Void

Syntax: Sub Update(UpdateDisplay As Boolean, UpdateGraphs As Boolean)

TuneVariable
A MWOffice TuneVariable object.

2298 NI AWR Design Environment


TuneVariables

Properties

Name Data Type Description


Maximum Double Returns/sets the maximum value for the TuneVariable
object.
Minimum Double Returns/sets the minimum value for the TuneVariable object.
Name String Returns the file name of the project not including the file's
path specification.
Nominal Double Returns/sets the nominal value for the TuneVariable object.
Step Double Returns/sets the step value for the TuneVariable object.

Methods
TuneDown

Description: Decrements the tuner nominal value by the amount of step value towards the minimum value.

Returns: Boolean

Syntax: Function TuneDown() As Boolean

TuneUp

Description: Increments the tuner nominal value by the amount of step value towards the maximum value.

Returns: Boolean

Syntax: Function TuneUp() As Boolean

TuneVariables
A collection of MWOffice TuneVariable objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item TuneVariable Returns a specific item of a Collection object either by
position or by key.

Tuner
A MWOffice Tuner object.

API Scripting Guide 2299


Tuner

Properties

Name Data Type Description


Variables TuneVariables Returns a reference to a MWOffice TuneVariables
collection.

Methods
Clear

Description: Clear the frozen sweep outputs fom the graphics and output documents.

Returns: Boolean

Syntax: Function Clear() As Boolean

Freeze

Description: Freeze the current sweep output in the graphs and output documents.

Returns: Boolean

Syntax: Function Freeze() As Boolean

Restore

Description: Restore the state of the TuneVariables associated with the provided state name.

Returns: Boolean

Syntax: Function Restore(stateName As String) As Boolean

Save

Description: Save the current state of the TuneVariables under the provided state name.

Returns: Boolean

Syntax: Function Save(stateName As String) As Boolean

Sweep

Description: Perform a simulation sweep with the current TuneVariable state.

Returns: Boolean

Syntax: Function Sweep() As Boolean

Tag

Description: Tag the current state of the TuneVariables with the provided state name.

Returns: Boolean

2300 NI AWR Design Environment


ControlBarItem

Syntax: Function Tag(tagName As String) As Boolean

ControlBarItem
An MWOffice ControlBarItem object.

Properties

Name Data Type Description


Action Variant Returns the action of the ControlBarItem object.
Caption String Returns/Sets the caption of an object.
Image Long Returns the image index of the ControlBarItem object.

Methods
None

ControlBarItems
A collection of MWOffice ControlBarItem objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ControlBarItem Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: ControlBarItem

Syntax: Function Add(OnAction, [Before], [Image As Long], [Caption As String]) As ControlBarItem

Clear

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub Clear()

API Scripting Guide 2301


MenuBar

MenuBar
An MWOffice MenuBar object.

Properties

Name Data Type Description


Menus Menus Returns a reference to a collection of Menu objects.
Name String Returns the name used in code to identify an object.

Methods
FreezeUpdates

Description: Prevents the MenuBar from updating changes that are made to it.

Returns: Void

Syntax: Sub FreezeUpdates()

UnfreezeUpdates

Description: Allows the MenuBar to update when changes are made to it.

Returns: Void

Syntax: Sub UnfreezeUpdates()

MenuBars
A collection of MWOffice MenuBar objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item MenuBar Returns a specific item of a Collection object either by
position or by key.

Menu
An MWOffice Menu object.

Properties

Name Data Type Description


Caption String Returns/Sets the caption of an object.

2302 NI AWR Design Environment


Menus

Name Data Type Description


MenuItems MenuItems Returns a reference to a collection of MenuItem objects.

Methods
None

Menus
A collection of MWOffice Menu objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Menu Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Menu

Syntax: Function Add(Caption As String, [Before]) As Menu

Clear

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub Clear()

MenuItem
An MWOffice MenuItem object.

Properties

Name Data Type Description


Action Variant Returns the action of the MenuItem object.
Caption String Returns/Sets the caption of an object.

API Scripting Guide 2303


MenuItems

Methods
None

MenuItems
A collection of MWOffice MenuItem objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Object Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: MenuItem

Syntax: Function Add(OnAction, [Before], [Caption As String]) As MenuItem

AddMenu

Description: Adds a new menu to the collection.

Returns: Menu

Syntax: Function AddMenu(Caption As String, [Before]) As Menu

HotkeyTable
An MWOffice HotkeyTable object.

Properties

Name Data Type Description


Hotkeys Hotkeys Returns a reference to a collection of Hotkey objects.
Name String Returns the name used in code to identify an object.

HotkeyTables
A collection of MWOffice HotkeyTable objects.

2304 NI AWR Design Environment


Hotkey

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item HotkeyTable Returns a specific item of a Collection object either by
position or by key.

Methods
None

Hotkey
An MWOffice Hotkey object.

Properties

Name Data Type Description


Action Variant Returns the action of the Hotkey object.
Flags Long Returns the flags of the Hotkey object.
Key Long Returns the key of the Hotkey object.
Mnemonic String Returns the mnemonic of the Hotkey object.

Methods
None

Hotkeys
A collection of MWOffice Hotkey objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Hotkey Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

API Scripting Guide 2305


CommandTable

Returns: Hotkey

Syntax: Function Add(OnAction, Key As Long, Flags As Long) As Hotkey

Clear

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub Clear()

CommandTable
An MWOffice CommandTable object.

Properties

Name Data Type Description


BaseId Long Returns the base command id associated with the
CommandTable object if there is one.
Commands Commands Returns a reference to a collection of Command objects.
Name String Returns the name used in code to identify an object.

CommandTables
A collection of MWOffice CommandTable objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item CommandTable Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: CommandTable

Syntax: Function Add(Name As String, [Size As Long = 1000]) As CommandTable

Find

Description: Searches the CommandTables for specified Command object.

2306 NI AWR Design Environment


Command

Returns: Command

Syntax: Function Find(Name As String) As Command

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Command
An MWOffice Command object.

Click to see examples

Properties

Name Data Type Description


Caption String Returns/Sets the caption of an object.
HelpFile String Returns the help file of the Command object.
HelpId Long Returns the help file context id of the Command object.
Helpstring String Returns the help string of the Command object.
Id Long Returns the identification number of the Command object.
Image Long Returns the image index of the Command object.
Name String Returns the name used in code to identify an object.
Tooltip String Returns the tooltip of the Command object.

Methods
None

Commands
A collection of MWOffice Command objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Command Returns a specific item of a Collection object either by
position or by key.

API Scripting Guide 2307


DrawingShape

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Command

Syntax: Function Add(Name As String, [CmdId As Long], [Caption As String], [Image As Long], [Tooltip As String],
[Helpstring As String], [HelpFile As String], [HelpContextID As Long]) As Command

Clear

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub Clear()

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

DrawingShape
An MWOffice DrawingShape object.

Click to see examples

Properties

Name Data Type Description


Attributes Attributes Returns a reference to a collection of Attribute objects.
BasePosition Point Returns a reference to a Point object.
Flipped Boolean Returns/Sets a value that specifies the flipped state of the
DrawingShape object.
Points Points Returns a reference to a collection of Point objects.
RotationAngle Double Returns/Sets a value that specifies the rotation angle of the
DrawingShape object.
Selected Boolean Returns/Sets a value that specifies if the DrawingShape
object is selected.
Type mwDrawingShapeType Returns a value that specifies the type of the DrawingShape
object.
TypeBits Long Returns flags describing the DrawingShape type

2308 NI AWR Design Environment


DrawingShapes

Methods
Delete

Description: Removes the object.

Returns: Boolean

Syntax: Function Delete() As Boolean

Move

Description: Moves DrawingShape object by the given values relative to the current location.

Returns: Boolean

Syntax: Function Move(dx As Long, dy As Long, [CCWRotation As Double = 0], [Flip As Boolean = 0], [FlipHorizontal
As Boolean = 0], [xOrigin As Double = 0], [yOrigin As Double = 0]) As Boolean

DrawingShapes
A collection of MWOffice DrawingShape objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item DrawingShape Returns a specific item of a Collection object either by
position or by key.

Methods
AddArc

Description: Adds an arc shape to the DrawingShapes collection.

Returns: DrawingShape

Syntax: Function AddArc(Left As Long, Top As Long, Right As Long, Bottom As Long, xStart As Long, yStart As
Long, xEnd As Long, yEnd As Long) As DrawingShape

AddArrow

Description: Adds an arrow shape to the DrawingShapes collection.

Returns: DrawingShape

Syntax: Function AddArrow(XYPoints As SafeArray) As DrawingShape

API Scripting Guide 2309


DrawingShapes

AddEllipse

Description: Adds an ellipse shape to the DrawingShapes collection.

Returns: DrawingShape

Syntax: Function AddEllipse(Left As Long, Top As Long, Right As Long, Bottom As Long) As DrawingShape

AddLine

Description: Adds a line shape to the DrawingShapes collection.

Returns: DrawingShape

Syntax: Function AddLine(x1 As Long, y1 As Long, x2 As Long, y2 As Long) As DrawingShape

AddPolygon

Description: Adds a polygon shape to the DrawingShapes collection.

Returns: DrawingShape

Syntax: Function AddPolygon(XYPoints As SafeArray) As DrawingShape

AddPolyline

Description: Adds a polyline shape to the DrawingShapes collection.

Returns: DrawingShape

Syntax: Function AddPolyline(XYPoints As SafeArray) As DrawingShape

AddRectangle

Description: Adds a rectangle shape to the DrawingShapes collection.

Returns: DrawingShape

Syntax: Function AddRectangle(Left As Long, Top As Long, Right As Long, Bottom As Long) As DrawingShape

AddText

Description: Adds a text string shape to the DrawingShapes collection.

Returns: DrawingShape

Syntax: Function AddText(Left As Long, Top As Long, Height As Long, Text As String, [FontName As String =
"Arial"], [Bold As Boolean = 0], [Italic As Boolean = 0]) As DrawingShape

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

2310 NI AWR Design Environment


Argument

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

Argument
An MWOffice Argument object.

Properties

Name Data Type Description


Value String Returns the argument value as a string.

Arguments
A collection of MWOffice Argument objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Argument Returns a specific item of a Collection object either by
position or by key.

FlightLine
An MWOffice FlightLine object.

Properties

Name Data Type Description


Begin Vertex Returns a reference to a Vertex object.
End Vertex Returns a reference to a Vertex object.

FlightLines
A collection of MWOffice FlightLine objects.

API Scripting Guide 2311


NetShape

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item FlightLine Returns a specific item of a Collection object either by
position or by key.
Selected Boolean Returns/sets a value that indicates if the Flightlines
collection is selected.

NetShape
An MWOffice NetShape object.

Properties

Name Data Type Description


Boundary Boundary Returns a reference to a Boundary object.
LayerName String Returns/sets the drawing layer used by this NetShape when
not using process layers for drawing.
LineType Long Returns/sets the line type index associate with this NetShape
object.
NetID Long Returns/sets the physical net identifier associated with this
NetShape object.
Orphan Boolean Returns if this an orphan and not associated with a physical
net.
Points Vertices Returns a reference to a collection of Vertex objects.
PolyPoints Vertices Returns a reference to a collection of Vertex objects.
Selected Boolean Returns/sets if this NetShape object is selected.
UseProcessLayers Boolean Returns/sets if this NetShape object is using process layers
or drawing layers.

Methods
None

NetShapes
A collection of MWOffice NetShape objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.

2312 NI AWR Design Environment


PhysicalNet

Name Data Type Description


Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item NetShape Returns a specific item of a Collection object either by
position or by key.

Methods
AddEllipse

Description: Adds a new ellipse NetShape object to the NetShapes collection.

Returns: NetShape

Syntax: Function AddEllipse(x As Double, y As Double, dx As Double, dy As Double, [LayerName As String = ""],
[UseProcessLayers As Boolean = 0], [LayerMapping As String = ""]) As NetShape

AddPath

Description: Adds a new path NetShape object to the NetShapes collection.

Returns: NetShape

Syntax: Function AddPath(XYPoints As SafeArray, Width As Double, [EndStyle As mwPathEndType = 1], [MiterStyle
As mwPathMiterType = 1], [OffsetMiterAmount As Double = 0], [LayerName As String = ""], [UseProcessLayers As
Boolean = 0], [LayerMapping As String = ""]) As NetShape

AddPolygon

Description: Adds a new polygon NetShape object to the NetShapes collection.

Returns: NetShape

Syntax: Function AddPolygon(XYPoints As SafeArray, [LayerName As String = ""], [UseProcessLayers As Boolean


= 0], [LayerMapping As String = ""]) As NetShape

AddRectangle

Description: Adds a new rectangle NetShape object to the NetShapes collection.

Returns: NetShape

Syntax: Function AddRectangle(x As Double, y As Double, dx As Double, dy As Double, [LayerName As String = ""],
[UseProcessLayers As Boolean = 0], [LayerMapping As String = ""]) As NetShape

PhysicalNet
An MWOffice PhysicalNet object.

Click to see examples

API Scripting Guide 2313


PhysicalNets

Properties

Name Data Type Description


Complete Boolean Returns a value indicating if the physical connections for
this net are completely connected.
ElectNetName String Returns the name of the electrical net element associated
with this physical net.
FlightLines FlightLines Returns a reference to a MWOffice FlightLines collection.
Name String Returns/Sets the name used in code to identify an object.
NetHighlight Boolean Returns if the physical net is currently highlighted.
NetHighlightColor Long Returns the highlight color for the net.
NetID Long Returns a value indicating the identifier associated with this
physical net.
Pins Pins Returns a reference to a MWOffice Pins collection.
RouteConnectionModel mwRouteConnModel Returns/sets a value indicating the physical net's current
mode for route-to-route connections.
Routes Routes Returns a reference to a MWOffice Routes collection.
Shapes NetShapes Returns a reference to a MWOffice NetShapes collection.
ViaMode mwNetViaMode Returns/sets a value indicating the physical net's current
mode for automatic via insertion.

Methods
AssociateObject

Description: Associates the object with the physical net if possible

Returns: Boolean

Syntax: Function AssociateObject(pObj As DrawingObject) As Boolean

HighlightNet

Description: Sets the highlight state of the physical net to on or off and allows the specification of the highlight Color.

Returns: Boolean

Syntax: Function HighlightNet(bHighlightOn As Boolean, [Color As Long = 255]) As Boolean

PhysicalNets
A collection of MWOffice PhysicalNet objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.

2314 NI AWR Design Environment


RouteRecord

Name Data Type Description


Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item PhysicalNet Returns a specific item of a Collection object either by
position or by key.

RouteRecord
An MWOffice RouteRecord object.

Properties

Name Data Type Description


Guides RouteGuides Returns a reference to a MWOffice RouteGuides collection.
Objects RouteObjects Returns a reference to a MWOffice RouteObjects collection.
Segments RouteSegments Returns a reference to a MWOffice RouteSegments
collection.
Vias RouteVias Returns a reference to a MWOffice RouteVias collection.

Methods
AddGuide

Description: Adds a new route guide to the RouteRecord object.

Returns: RouteObject

Syntax: Function AddGuide(x1 As Double, y1 As Double, x2 As Double, y2 As Double, Begin As Long, End As Long)
As RouteObject

AddSegment

Description: Adds a new route segment to the RouteRecord object.

Returns: RouteObject

Syntax: Function AddSegment(x1 As Double, y1 As Double, x2 As Double, y2 As Double, Width As Double, LineType
As Long, BeginStyle As mwRouteSegmentEndStyleType, BeginExtent As Double, EndStyle As
mwRouteSegmentEndStyleType, EndExtent As Double) As RouteObject

AddVia

Description: Adds a new route via to the RouteRecord object.

Returns: RouteObject

Syntax: Function AddVia(xOrigin As Double, yOrigin As Double, xExtent As Double, yExtent As Double, xOffset As
Double, yOffset As Double, LineType1 As Long, LineType2 As Long, Direction As mwRouteViaDirectionType) As
RouteObject

API Scripting Guide 2315


Route

AddViaType

Description: Adds a new route via to the RouteRecord object.

Returns: RouteObject

Syntax: Function AddViaType(xOrigin As Double, yOrigin As Double, xExtent As Double, yExtent As Double, xOffset
As Double, yOffset As Double, LineType1 As Long, LineType2 As Long, typeIndex As Long, Direction As
mwRouteViaDirectionType) As RouteObject

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

Route
An MWOffice Route object.

Properties

Name Data Type Description


Associated Boolean Returns a value that indicates if the route is associated with
a physical net.
BendStyle mwRouteBendStyleType Returns/Sets the bend style to be used for the route object.
Boundary Boundary Returns a reference to a Boundary object.
Continuous Boolean Returns/Sets a value that indicates if this Route object is
continuous with all segments connected.
CustomSegmentEnds Boolean Returns/Sets if the ends styles for each segment should be
retain a custom style value.
FixedRadiusCurves Boolean Returns/Sets if curved bends should use a fixed or variable
radius for calculating the curve.
Global Boolean Returns/Sets a value that indicates if this Route object is
global.
Guides RouteGuides Returns a reference to a MWOffice RouteGuides collection.
Length Double Returns the sum of the centerline length of all the segments
in the route.
MiterAmount Double Returns/Sets the miter amount value to be used when the
bend style is set to miter bend style.
MiterAmountAbsolute Boolean Returns/Sets if the MiterAmount should be taken as an
absolute length or a width multipler should be set before
setting MiterAmount property.
NetID Long Returns/Sets a numerical identifier for the physical net
associated with this Route object.

2316 NI AWR Design Environment


Routes

Name Data Type Description


Objects RouteObjects Returns a reference to a MWOffice RouteObjects collection.
Segments RouteSegments Returns a reference to a MWOffice RouteSegments
collection.
Selected Boolean Returns/Sets a value indicating if the route is selected.
Status mwRouteStatusType Returns/Sets a value for the route placement status.
Topology mwRouteTopologyType Returns/Sets a value for the route topology
ViaCellName String Returns the name of the programmatic cell used to draw
vias on this Route object.
Vias RouteVias Returns a reference to a MWOffice RouteVias collection.

Methods
Delete

Description: Removes the object.

Returns: Boolean

Syntax: Function Delete() As Boolean

Disassociate

Description: Removes the association the Route and it's parent PhysicalNet

Returns: Boolean

Syntax: Function Disassociate() As Boolean

Routes
A collection of MWOffice Route objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Route Returns a specific item of a Collection object either by
position or by key.

Methods
AddRoute

Description: Adds the route described by the route record to the PhysicalNet object.

Returns: Route

API Scripting Guide 2317


RouteObject

Syntax: Function AddRoute(Record As RouteRecord) As Route

AddVias

Description: Add the vias in the route record to the existing route objects. Allows adding vias after routes have been
created.

Returns: Boolean

Syntax: Function AddVias(Record As RouteRecord) As Boolean

CreateRouteRecord

Description: Returns a reference to a MWOffice RouteRecord object.

Returns: RouteRecord

Syntax: Function CreateRouteRecord() As RouteRecord

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

RouteObject
An MWOffice RouteObject object.

Properties

Name Data Type Description


BeginNode Long Returns/Sets a value for the beginning connectivity node
number of this route object.
Boundary Boundary Returns a reference to a Boundary object.
EndNode Long Returns/Sets a value for the ending connectivity node
number of this route object.
Selected Boolean Returns/Sets a value indicating if the route object is selected.
Shapes Shapes Returns a reference to a collection of Shape objects.
Type mwRouteObjectType Returns a value indicating the type of the underlying route
object.

2318 NI AWR Design Environment


RouteObjects

Name Data Type Description


Vertices Vertices Returns a reference to a collection of Vertex objects.

RouteObjects
A collection MWOffice RouteObject objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item RouteObject Returns a specific item of a Collection object either by
position or by key.

RouteSegment
An MWOffice RouteSegment object.

Properties

Name Data Type Description


Begin Vertex Returns a reference to a Vertex object.
BeginExtent Double Returns/Sets the extent length value for the beginning of
this route segment.
BeginOffsetStyle mwRouteSegmentEndOffsetType Returns/Sets the offset style value for the beginning of this
route segment.
BeginStyle mwRouteSegmentEndStyleType Returns/Sets the style value for the beginning of this route
segment
End Vertex Returns a reference to a Vertex object.
EndExtent Double Returns/Sets the extent length value for the end of this route
segment.
EndOffsetStyle mwRouteSegmentEndOffsetType Returns/Sets the offset style value for the end of this route
segment.
EndStyle mwRouteSegmentEndStyleType Returns/Sets the style value for the end of this route
segment.
LineType Long Returns/Sets an index value for the technology line type of
this route segment.
Selected Boolean Returns/Sets a value indicating if the route segment is
selected.
Shapes Shapes Returns a reference to a collection of Shape objects.
Width Double Returns/Sets the width value for this route segment

API Scripting Guide 2319


RouteSegments

RouteSegments
A collection of MWOffice RouteSegment objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item RouteSegment Returns a specific item of a Collection object either by
position or by key.

RouteVia
An MWOffice RouteVia object.

Properties

Name Data Type Description


AutoSize Boolean Returns/sets a value indicating if the via should be autosized
to the overlap area between segments and pins.
ConnectType1 Long Returns/sets a value indicating the type of connection for
side one of the RouteVia object.
ConnectType2 Long Returns/sets a value indicating the type of connection for
side two of the RouteVia object.
Direction mwRouteViaDirectionType Returns/sets a value indicating the via direction for this via
object.
Enabled Boolean Returns/sets a value indicating if the via is enabled and
drawn within the design.
Extent Extent Return a reference to an Extent object.
LineType1 Long Returns/sets a value indicating the technology line type
associated with the first side of this via object.
LineType2 Long Returns/sets a value indicating the technology line type
associated with the second side of this via object.
Offset Offset Returns a reference to an Offset object.
Origin Vertex Returns a reference to a Vertex object.
Selected Boolean Returns/Sets a value indicating if the route object is selected.
Shapes Shapes Returns a reference to a collection of Shape objects.
typeIndex Long Returns/sets a value indicating the type of this via as defined
in the LPF

Methods
None

2320 NI AWR Design Environment


RouteVias

RouteVias
A collection MWOffice RouteVia objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item RouteVia Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: RouteVia

Syntax: Function Add(xOrigin As Double, yOrigin As Double, xExtent As Double, yExtent As Double, xOffset As
Double, yOffset As Double, LineType1 As Long, LineType2 As Long, Direction As mwRouteViaDirectionType) As
RouteVia

AddType

Description: Adds an object to the collection and returns a reference to the created object.

Returns: RouteVia

Syntax: Function AddType(xOrigin As Double, yOrigin As Double, xExtent As Double, yExtent As Double, xOffset
As Double, yOffset As Double, LineType1 As Long, LineType2 As Long, typeIndex As Long, Direction As
mwRouteViaDirectionType) As RouteVia

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

API Scripting Guide 2321


RouteGuide

RouteGuide
An MWOffice RouteGuide object.

Properties

Name Data Type Description


Begin Vertex Returns a reference to a Vertex object.
BeginLineType Long Returns/sets a value of the technology line type at the
starting point of this guide.
End Vertex Returns a reference to a Vertex object.
EndLineType Long Returns/sets a value of the technology line type at the ending
point of this guide.
Selected Boolean Returns/Sets a value indicating if the route object is selected.
Shapes Shapes Returns a reference to a collection of Shape objects.

RouteGuides
A collection of MWOffice RouteGuide objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item RouteGuide Returns a specific item of a Collection object either by
position or by key.

Extent
An MWOffice Extent object.

Properties

Name Data Type Description


cx Double Returns/sets the CX value of an Extent object.
cy Double Returns/sets the CY value of an Extent object.

Extents
A collection of MWOffice Extent objects.

2322 NI AWR Design Environment


Pin

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Extent Returns a specific item of a Collection object either by
position or by key.

Pin
An MWOffice Pin Object.

Properties

Name Data Type Description


Connected Boolean Returns if the Pin is connected to a PhysicalNet object.
ConnectedNetName String Returns the name of the PhysicalNet connected to the Pin
or empty string if it is not connected.
ElementName String Returns a string indicating the name of the element
associated with this Pin object.
FaceType Long Returns a value indicating the type of face associated with
this Pin object.
GroupNumber Long Returns a value indicating the group number index
associated with this Pin object.
GroupType Long Returns a value indicating the type of group with which this
Pin object is associated.
Name String Returns a string indicating the name of this Pin object.
PinNumber Long Returns a value indicating the pin sub number of the terminal
for this Pin object.
Points Vertices Returns a reference to a collection of Vertex objects.
PreferredSnapPin String Returns a string indicating the preferred snap Pin for this
Pin object
Terminal Long Returns a value indicating the terminal number associated
with the Pin object.

Pins
A collection of MWOffice Pin objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.

API Scripting Guide 2323


LayoutModeSet

Name Data Type Description


Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Pin Returns a specific item of a Collection object either by
position or by key.

LayoutModeSet
An MWOffice LayoutModeSet object.

Properties

Name Data Type Description


Active Boolean Returns a value indicating if the current layout mode set is
active.
Name String Returns the name used in code to identify an object.
Options Options Returns a reference to a collection of Option objects.

Options

Number Name Description


1 RestrictSelection Returns/sets a bitfield of values describing selection
restrictions on specific object types. Values for this field
should be taken from the mwLayoutObjectSelectFilters
enumeration
2 DrawDim Returns/sets a bitfield of values describing dimmed drawing
options for specific object types. Values for this field should
be taken from the mwLayoutObjectSelectFilters enumeration
3 OutlineOnly Returns/sets a bitfield of values describing outline drawing
options for specific object types. Values for this field should
be taken from the mwLayoutObjectSelectFilters enumeration
4 MinimumDetail Returns/sets a bitfield of values describing minimum detail
drawing options for specific object types. Values for this
field should be taken from the mwLayoutObjectSelectFilters
enumeration
5 NotVisible Returns/sets a bitfield of values describing visible drawing
options for specific object types. Values for this field should
be taken from the mwLayoutObjectSelectFilters enumeration
6 SelectPinWidth Returns/sets a drawing option value for the highlight line
width of a selected pin or face object. Values for this field
should be taken from the mwLayoutObjectSelectFilters
enumeration
7 RouteGravity Returns/sets a value describing the gravity strength used for
guides and alignment when drawing and editing route
objects.

2324 NI AWR Design Environment


LayoutModeSet

Number Name Description


8 RoutePinWidth Returns/sets if routes drawn starting from a pin should use
the width of the pin as the initial routing width.
9 ExtraDimColors Returns/sets if layers drawn with dim colors should be drawn
extra dim.
10 OrthogonalOnlyRoutes Returns/sets if routes should only allow orthogonal segments
11 StartRouteOnPinLayer Returns/sets if routes drawing starting from a pin should
initially use the pin layer
12 DrawAbstsract Returns/sets if objects should be drawn in abstract mode
with minimum detail
13 AutoZoom Returns/sets if auto zoom mode should be enabled when
viewing layouts.
14 DrawViewsAsX Returns/sets if route vias should be drawn as just an X rather
than with full layer details
15 SelectMode Returns/sets if select mode should be enabled to change the
selection characteristics of objects in layout
16 AutoSelectonRightClick Returns/sets if objects under the cursor should be selected
before the context menu is displayed
17 LayerConfiguration Returns/sets the name of the layer configuration in use for
this layout mode.
18 ViewDetails Returns/sets a value that control the level of detail drawn
on objects in the layout view
19 DrawInstancesAsBoxes Returns/sets if instance below a specific hierarchy level
should be drawn as boxes
20 InstancesAsBoxLevel Returns/sets the hierarchy level at which instance will be
drawn as boxes.
21 ShowObscuredOutlines Returns/sets if obscured shape outlines should be shown
22 DrawFaceLines Returns/sets if face/pin outlines should be drawn
23 DrawAllFlightLines Returns/sets if flight lines should be drawn at just the top
level or at all levels of hierarchy
24 DrawAnchors Returns/sets if anchor emblems should be drawn on
anchored objects
25 DrawCrossHairs Returns/sets if cross hairs should be drawn at the cursor
point to the window boundaries
26 DrawSelectionBoxes Returns/sets if handle boxes should be drawn in addition to
highlighting on selected objects
27 DrawSubcircuitBounds Returns/sets if subcircuit drawing should include annotation
lines showing the boundary of the circuit instance
28 DrawInstanceLabels Returns/sets if instance name label should be drawn over
instance objects
29 UseDimColors Returns/sets if dim colors should be used to display lower
levels of hierarchy in the design

API Scripting Guide 2325


LayoutModeSets

Number Name Description


30 DrawInstancePins Returns/sets if instance pin locations should be drawn
highlighted when instances are drawn
31 LayEnableDynHighlight Enable dynamic highlight for previewing selection.
32 LayViewTextReadable Always rotate view text to be readable.
33 LayDrawPathCenterlines Draw the centerlines on path objects and routes.
34 LayDynFlightLines Dynamically update flight lines when editing electrical net
route and shape objects.
35 DrawOriginMarkers Returns/sets if origin markers should be drawn.

LayoutModeSets
A collection of MWOffice LayoutModeSet objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item LayoutModeSet Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: LayoutModeSet

Syntax: Function Add(pName As String) As LayoutModeSet

GetActive

Description: Returns the active state of a Window object.

Returns: LayoutModeSet

Syntax: Function GetActive() As LayoutModeSet

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

2326 NI AWR Design Environment


ParameterDefaultValue

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

SetActive

Description: Activates the objects.

Returns: Boolean

Syntax: Function SetActive(Index) As Boolean

ParameterDefaultValue
A MWOffice ParameterDefaultValue object.

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
UnitType mwUnitType Returns/Sets the unit type of the ParameterDefaultValue
object.
Value Double Returns/Sets value of the ParameterDefaultValue object.

ParameterDefaultValues
A MWOffice ParameterDefaultValue object.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ParameterDefaultValue Returns a specific item of a Collection object either by
position or by key.

API Scripting Guide 2327


LayoutProcessDefinition

LayoutProcessDefinition
An MWOffice LayoutProcessDefinition object.

Properties

Name Data Type Description


Capacitors ProcessTypeInfos Returns a reference to a MWOffice ProcessTypeInfos
collection.
ConnectionRules ConnectionRules Returns a reference to a collection of ConnectionRule
objects.
CrossoverRules CrossoverRules Returns a reference to a collection of CrossoverRule objects.
DefaultFont FontInfo Returns a reference to a MWOffice FontInfo object.
DependentProcessDefinitionNames ObjectNames Returns a reference to a collection of MWOffce ObjectName
objects.
DrawUtility String Returns a string name for the drawing utility to be used for
this layout process.
DrcRules String Returns a filename path for the DRC rules file for this layout
process.
LayerSetup LayerSetup Returns a reference to a MWOffice LayerSetup object.
LineTypes ProcessTypeInfos Returns a reference to a MWOffice ProcessTypeInfos
collection.
Name String Returns/Sets the name used in code to identify an object.
Pads ProcessTypeInfos Returns a reference to a MWOffice ProcessTypeInfos
collection.
ParameterDefaultValues ParameterDefaultValues Returns a reference to a collection of ParameterDefaultValue
objects.
Properties ProcessProperties Returns a reference to a MWOffice ProcessProperties
collection.
Structures ProcessTypeInfos Returns a reference to a MWOffice ProcessTypeInfos
collection.
ViaCellName String Returns a string name for the cell used to draw vias between
different layers in routes in the process.
ViaFenceEntries ProcessViaFenceEntries Returns a reference to a collection of ProcessViaFenceEntry
objects.
ViaFillEntries ProcessViaFillEntries Returns a refrerence to a collection of ProcessViaFillEntry
objects.
ViaTypes ProcessViaTypes Returns a reference to a MWOffice ProcessViaTypes
collection.
Vias ProcessTypeInfos Returns a reference to a MWOffice ProcessTypeInfos
collection.

2328 NI AWR Design Environment


LayoutProcessDefinitions

Methods
Export

Description: Exports a design document file from MWOffice.

Returns: Boolean

Syntax: Function Export(Filename As String) As Boolean

UpdateAllDependentProcessDefinitions

Description: Update all dependent LayoutProcessDefinitions.

Returns: Boolean

Syntax: Function UpdateAllDependentProcessDefinitions([EMMapping As Boolean = -1], [FileMapping As Boolean


= -1], [ModelMapping As Boolean = -1], [DrawingLayers As Boolean = -1], [UnusedLayers As Boolean = -1]) As
Boolean

UpdateDependentProcessDefinition

Description: Update a specific dependent LayoutProcessDefinition object.

Returns: Boolean

Syntax: Function UpdateDependentProcessDefinition(procName As String, [EMMapping As Boolean = -1], [FileMapping


As Boolean = -1], [ModelMapping As Boolean = -1], [DrawingLayers As Boolean = -1], [UnusedLayers As Boolean =
-1]) As Boolean

LayoutProcessDefinitions
A collection of MWOffice LayoutProcessDefinition objects.

Properties

Name Data Type Description


ActiveIndex Long Returns the index of the active object within the collection.
Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item LayoutProcessDefinition Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: LayoutProcessDefinition

API Scripting Guide 2329


ProcessLayerInfo

Syntax: Function Add(Name As String) As LayoutProcessDefinition

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Import

Description: Adds a Netlist object to the collection from a file and returns a reference to the created object.

Returns: LayoutProcessDefinition

Syntax: Function Import(Filename As String, ReplaceDefault As Boolean) As LayoutProcessDefinition

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

ProcessLayerInfo
An MWOffice ProcessLayerInfo object.

Click to see examples

Properties

Name Data Type Description


Bridges ProcessBridgeInfos Returns a reference to a MWOffice ProcessBridgeInfos
collection.
Flags Long Returns a bitfield value indicating the current flags set for
the ProcessLayerInfo object within the process type.
MinWidth Double Returns a value indicating the current minimum layer width
within the process type.
Name String Returns/Sets the name used in code to identify an object.
Offset Double Returns a value indicating the current layer offset within
the process type.

ProcessLayerInfos
A collection of MWOffice ProcessLayerInfo objects.

2330 NI AWR Design Environment


ProcessTypeInfo

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ProcessLayerInfo Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: ProcessLayerInfo

Syntax: Function Add(Name As String, [Offset As Double = 0], [MinimumWidth As Double = 0], [Flags As Long =
0]) As ProcessLayerInfo

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub RemoveAll()

ProcessTypeInfo
An MWOffice ProcessTypeInfo object.

Properties

Name Data Type Description


Layers ProcessLayerInfos Returns a reference to a MWOffice ProcessLayerInfo object.

API Scripting Guide 2331


ProcessTypeInfos

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
Number Long Returns a number index for this MWOffice ProcessTypeInfo
object.
typeIndex Long Returns a type index for this MWOffice ProcessTypeInfo
object.

ProcessTypeInfos
A collection of MWOffice ProcessTypeInfo objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ProcessTypeInfo Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: ProcessTypeInfo

Syntax: Function Add(Name As String) As ProcessTypeInfo

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Void

2332 NI AWR Design Environment


ProcessBridgeInfo

Syntax: Sub RemoveAll()

ProcessBridgeInfo
An MWOffice ProcessBridgeInfo object.

Properties

Name Data Type Description


RemoveEdgeOffset Double Returns a value of the amount of the bridge layer edge to
remove.
RemoveOffset Double Returns a value of the amount of the bridge layer to remove.
ShouldRemove Boolean Returns a value indicating if the bridge layer should be
removed.
ShouldRemoveEdge Boolean Returns a value indicating if the bridge layer edge should
be removed.
TypeName String Returns/Sets the name used in code to identify an object.

ProcessBridgeInfos
A collection of MWOffice ProcessBridgeInfo objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ProcessBridgeInfo Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: ProcessBridgeInfo

Syntax: Function Add(Name As String, [ShouldRemove As Boolean = -1], [RemoveOffset As Double = 0],
[ShouldRemoveEdge As Boolean = -1], [EdgeRemoveOffset As Double = 0]) As ProcessBridgeInfo

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

API Scripting Guide 2333


FontInfo

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub RemoveAll()

FontInfo
An MWOffice FontInfo object.

Properties

Name Data Type Description


Bold Boolean Returns/sets a value indicating if the font style should be
bold
Height Double Returns/sets a value indicating the height in base length
units for the font.
Italic Boolean Returns/sets a value indicating of the font style should be
italic
Name String Returns/Sets the name used in code to identify an object.

FontInfos
A collection of MWOffice FontInfo objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item FontInfo Returns a specific item of a Collection object either by
position or by key.

ProcessProperty
An MWOffice ProcessProperty object.

2334 NI AWR Design Environment


ProcessProperties

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
Value Double Returns the value of a Property object.

ProcessProperties
A collection of MWOffice ProcessProperties objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ProcessProperty Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: ProcessProperty

Syntax: Function Add(Name As String, [Value As Double = 0]) As ProcessProperty

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Void

API Scripting Guide 2335


ProcessViaType

Syntax: Sub RemoveAll()

ProcessViaType
An MWOffice ProcessViaType object.

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
Number Long Returns a value indicating the numeric index of this
ProcessViaType object.
ValidBetween Boolean Returns a value indicating if the via type is valid between
two given line types.
ValidLineTypeEnds ProcessViaLineTypePairs Returns a reference to a collection of MWOffice
ProcessViaLineType objects.
ValidLineTypeRanges ProcessViaLineTypePairs Returns a reference to a collection of MWOffice
ProcessViaLineType objects.
typeIndex Long Returns a value indecating the type index of this
ProcessViaType object.

ProcessViaTypes
A collection of MWOffice ProcessViaType objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ProcessViaType Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: ProcessViaType

Syntax: Function Add(Name As String) As ProcessViaType

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

2336 NI AWR Design Environment


BusNetName

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub RemoveAll()

BusNetName
An MWOffice BusNetName object.

Properties

Name Data Type Description


BasePosition Point Returns a reference to a Point object.
BitCount Long Returns a count of the number of bits in this BusNetName
object.
BundleInfo BundleInfo Returns a reference to a MWOffice BundleInfo object.
Flipped Boolean Returns/sets a value indicating if the BusNetName object
is flipped.
Font FontInfo Returns a reference to a MWOffice FontInfo object.
Name String Returns/Sets the name used in code to identify an object.
Priority Long Returns a value that indicates the priority of this
BusNetName object.
RotationAngle Double Returns/sets a value for the counter clockwise rotation angle
of the BusNetName object.
Selected Boolean Returns/sets a value indicating if the BusNetName object
is selected

Methods
Delete

Description: Removes the object.

Returns: Boolean

API Scripting Guide 2337


BusNetNames

Syntax: Function Delete() As Boolean

Move

Description: Moves the BusNetName by an amount relative to it's current position

Returns: Boolean

Syntax: Function Move(dx As Long, dy As Long, [CCWRotation As Double = 0], [Flip As Boolean = 0], [FlipHorizontal
As Boolean = 0], [xOrigin As Double = 0], [yOrigin As Double = 0]) As Boolean

BusNetNames
A collection of MWOffice BusNetName objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item BusNetName Returns a specific item of a Collection object either by
position or by key.

BundleBit
An MWOffice BundleBit object.

Properties

Name Data Type Description


BitIndex Long Returns the index within the BundleBus of this BundleBit.
BusName String Returns the name of the bus associated with this BundleBit.
Name String Returns/Sets the name used in code to identify an object.

BundleBits
A collection of MWOffuce BunldeBit objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item BundleBit Returns a specific item of a Collection object either by
position or by key.

2338 NI AWR Design Environment


BundleBus

BundleBus
An MWOffice BundleBus object.

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.

BundleBuses
A collection of MWOffice BundleBus objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item BundleBus Returns a specific item of a Collection object either by
position or by key.

BundleInfo
An MWOffice BundleInfo object.

Properties

Name Data Type Description


Bits BundleBits Returns a reference to a collection of MWOffice BundleBit
objects.
Buses BundleBuses Returns a reference to a collection of MWOffice BundleBus
objects.
Name String Returns/Sets the name used in code to identify an object.

BundleInfos
A collection of MWOffice BundleInfo objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.

API Scripting Guide 2339


EditHandle

Name Data Type Description


Item BundleInfo Returns a specific item of a Collection object either by
position or by key.

EditHandle
An MWOffice EditHandle object.

Properties

Name Data Type Description


Position Vertex Returns a reference to a Vertex object.

Methods
None

EditHandles
A collection of MWOffice EditHandle objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item EditHandle Returns a specific item of a Collection object either by
position or by key.

SelectFilterItem
An MWOffice SelectFilterItem object.

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
RestrictSelection Boolean Returns/Sets if the item type is prevented from being
selected

SelectFilterItems
A collection of MWOffice SelectFilterItem objects.

2340 NI AWR Design Environment


SelectFilter

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item SelectFilterItem Returns a specific item of a Collection object either by
position or by key.

SelectFilter
An MWOffice SelectFilter object.

Properties

Name Data Type Description


FilterItems SelectFilterItems Returns/Sets if the item type is prevented from being
selected
Name String Returns/Sets the name used in code to identify an object.

CSelectFilters
A collection of MWOffice SelectFilter objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item SelectFilter Returns a specific item of a Collection object either by
position or by key.

MathUtil
An MWOffice MathUtil object.

Properties

Name Data Type Description


E Double Returns the natural logarithmic base specified by the
constant e.
PI Double Returns the ratio of the circumference of a circle to its
diameter specified by the constant PI.
Rand Double Returns a pseudo-random floating point number in the range
[0..1)

API Scripting Guide 2341


MathUtil

Methods
ACos

Description: Returns the principal value of the arc cosine of a value, result is expressed in radians.

Returns: Double

Syntax: Function ACos(cosValue As Double) As Double

ACosh

Description: Returns the arc hyperbolic cosine of a value, result is expressed in radians.

Returns: Double

Syntax: Function ACosh(coshValue As Double) As Double

ASin

Description: Returns the principal value of the arc sine of a value, result is expressed in radians.

Returns: Double

Syntax: Function ASin(sinValue As Double) As Double

ASinh

Description: Returns the arc hyperbolic sine of a value, result is expressed in radians.

Returns: Double

Syntax: Function ASinh(sinhValue As Double) As Double

ATan

Description: Returns the principal value of the arc tangent of a value, result is expressed in radians.

Returns: Double

Syntax: Function ATan(tanValue As Double) As Double

ATan2

Description: Returns the principal value of the arc tangent of y / x, result is expressed in radians.

Returns: Double

Syntax: Function ATan2(y As Double, x As Double) As Double

ATanh

Description: Returns the arc hyperbolic tangent of a value, result is expressed in radians.

Returns: Double

2342 NI AWR Design Environment


MathUtil

Syntax: Function ATanh(tanhValue As Double) As Double

Abs

Description: Returns the absolute value of a specified number.

Returns: Double

Syntax: Function Abs(val As Double) As Double

Avg

Description: Returns the average value of a set of specified numbers.

Returns: Double

Syntax: Function Avg(Values As SafeArray) As Double

Ceil

Description: Returns the smallest integral value that is not smaller than the specified number, rounds up.

Returns: Double

Syntax: Function Ceil(Value As Double) As Double

CelsiusToFahrenheit

Description: Converts a temperature value expressed in degrees Celsius to a temperature expressed in Fahrenheit

Returns: Double

Syntax: Function CelsiusToFahrenheit(Celsius As Double) As Double

Cos

Description: Returns the cosine of an angle value expressed in radians.

Returns: Double

Syntax: Function Cos(angleRadians As Double) As Double

Cosh

Description: Returns the hyperbolic cosine of a value specified in radians.

Returns: Double

Syntax: Function Cosh(angleRadians As Double) As Double

DegreesToRadians

Description: Converts an angle value specified in degrees to an angle value in radians.

Returns: Double

API Scripting Guide 2343


MathUtil

Syntax: Function DegreesToRadians(Degrees As Double) As Double

FahrenheitToCelsius

Description: Converts a temperature value expressed in degrees Fahrenheit to a temperature expressed in Celsius

Returns: Double

Syntax: Function FahrenheitToCelsius(Fahrenheit As Double) As Double

Floor

Description: Returns the largest integral value that is not larger than the specified number, rounds down.

Returns: Double

Syntax: Function Floor(Value As Double) As Double

Int

Description: Returns the integer portion of a specified number.

Returns: Int

Syntax: Function Int(val As Double) As Int

Log10

Description: Returns the base 10 logarithm of a specified number.

Returns: Double

Syntax: Function Log10(Value As Double) As Double

LogN

Description: Returns the base e natural logarithm of a specified number.

Returns: Double

Syntax: Function LogN(Value As Double) As Double

Max

Description: Returns the maximum of two specified numbers.

Returns: Double

Syntax: Function Max(val1 As Double, val2 As Double) As Double

MicronsToMils

Description: Covnerts a length value expressed in microns to a length expressed in mils

Returns: Double

2344 NI AWR Design Environment


MathUtil

Syntax: Function MicronsToMils(Microns As Double) As Double

MilsToMicrons

Description: Covnerts a length value expressed in mils to a length value expressed in microns

Returns: Double

Syntax: Function MilsToMicrons(Mils As Double) As Double

Min

Description: Returns the minimum of two specified numbers.

Returns: Double

Syntax: Function Min(val1 As Double, val2 As Double) As Double

Pow

Description: Returns the result of raising a base value to the given exponent value.

Returns: Double

Syntax: Function Pow(base As Double, exp As Double) As Double

RadiansToDegrees

Description: Converts an angle value specified in radians to an angle value in degrees.

Returns: Double

Syntax: Function RadiansToDegrees(Radians As Double) As Double

Round

Description: Returns the integral number that is nearest to the specified number.

Returns: Double

Syntax: Function Round(Value As Double) As Double

Sin

Description: Returns the sin of an angle value expressed in radians.

Returns: Double

Syntax: Function Sin(angleRadians As Double) As Double

Sinh

Description: Returns the hyperbolic sine of a value specified in radians.

Returns: Double

API Scripting Guide 2345


StackupUtil

Syntax: Function Sinh(angleRadians As Double) As Double

Srand

Description: Initializes the pseudo-random number generator with the value provided as a seed.

Returns: Boolean

Syntax: Function Srand(seedVal As Long) As Boolean

StdDev

Description: Returns the standard deviation of a set of specified numbers.

Returns: Double

Syntax: Function StdDev(Values As SafeArray) As Double

Tan

Description: Returns the tangent of an angle value expressed in radians.

Returns: Double

Syntax: Function Tan(angleRadians As Double) As Double

Tanh

Description: Returns the hyperbolic tangent of a value specified in radians.

Returns: Double

Syntax: Function Tanh(angleRadians As Double) As Double

Trunc

Description: Returns the integral value of the specified number rounded toward zero.

Returns: Double

Syntax: Function Trunc(Value As Double) As Double

exp

Description: Returns the base e exponential value of a specified number.

Returns: Double

Syntax: Function exp(Value As Double) As Double

StackupUtil
An MWOffice StackupUtil object.

2346 NI AWR Design Environment


StackupUtil

Methods
AddConductorMaterial

Description: Add a conductor material to the designated STACKUP

Returns: Void

Syntax: Sub AddConductorMaterial(cond_name As String, Conductivity As Double)

AddDielectricMaterial

Description: Add a dielectric material to the designated STACKUP

Returns: Void

Syntax: Sub AddDielectricMaterial(diel_name As String, er As Double, tanD As Double)

ClearStackup

Description: Remove all materials and dielectric layers

Returns: Void

Syntax: Sub ClearStackup()

InsertDielectricLayer

Description: Add a dielectric layer to the designated STACKUP. Layer numbers are from top to bottom

Returns: Void

Syntax: Sub InsertDielectricLayer(diel_name As String, layer_num As Int, Thickness As Double)

MapConductor

Description: Associate a drawing layer for a conductor with an EM layer

Returns: Void

Syntax: Sub MapConductor(drawing_layer As String, mat_name As String, Thickness As Double, em_layer As Int)

MapVia

Description: Associate a drawing layer for a VIA with an EM from/to layer

Returns: Void

Syntax: Sub MapVia(drawing_layer As String, mat_name As String, from_em_layer As Int, to_em_layer As Int)

SetStackup

Description: Designate the STACKUP that will be operated on by this utility

Returns: Void

API Scripting Guide 2347


ZipArchiveItem

Syntax: Sub SetStackup(Stackup As Element)

SyncLpf

Description: Push data from STACKUP to named LPF. 3D data is thickness and z-position. Layer data is color and
hatch.

Returns: Void

Syntax: Sub SyncLpf(lpf_name As String, update_3d As Boolean, update_layers As Boolean)

ZipArchiveItem
An MWOffice ZipArchiveItem object.

Properties

Name Data Type Description


AccessTime String Returns the last access time for the ZipArchiveItem as a
string.
Attributes FileAttributes Returns a reference to a collection of MWOffice
FileAttribute objects.
CompressedSize Long Returns the compressed size of the ZipArchiveItem in bytes.
CreateTime String Returns the creation time for the ZipArchiveItem as a string.
Extension String Returns the file name extension for the ZipArchiveItem as
a string.
ModifyTime String Returns the last modification time for the ZipArchiveItem
as a string.
Name String Returns/Sets the name used in code to identify an object.
UncompressedSize Long Returns the uncompressed size of the ZipArchiveItem in
bytes.

Methods
None

ZipArchiveItems
A collection of MWOffice ZipArchiveItem objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.

2348 NI AWR Design Environment


ZipArchiveWriter

Name Data Type Description


Item ZipArchiveItem Returns a specific item of a Collection object either by
position or by key.
Valid Boolean Returns a value that indicates if the archive was successfully
opened and the collection is valid.

Methods
ExtractAll

Description: Extracts an all items from the archive to a given directory.

Returns: Boolean

Syntax: Function ExtractAll(OutputDirectory As String) As Boolean

ExtractItem

Description: Extracts the item from the archive to a given directory.

Returns: Boolean

Syntax: Function ExtractItem(Index, OutputDirectory As String) As Boolean

ZipArchiveWriter
An MWOffice ZipArchiveWriter object.

Properties

Name Data Type Description


IsValid Boolean Returns true if files and directories can be added to the
archive.

Methods
AddContents

Description: Add the contents of a directory to the archive file.

Returns: Boolean

Syntax: Function AddContents(Directory As String) As Boolean

AddDirectory

Description: Add a directory and it's contents to the archive file.

Returns: Boolean

Syntax: Function AddDirectory(DirectoryName As String) As Boolean

API Scripting Guide 2349


BrowseForFolderDialog

AddFile

Description: Adds a file to the archive.

Returns: Boolean

Syntax: Function AddFile(Filename As String) As Boolean

Close

Description: Closes and writes the archive file.

Returns: Boolean

Syntax: Function Close() As Boolean

BrowseForFolderDialog
An MWOffice BrowseForFolderDialog object.

Properties

Name Data Type Description


BrowseForComputer Boolean Returns/Sets if the dialog should return only computers.
Section of anything else will disable the OK button.
BrowseForPrinter Boolean Returns/Sets if the dialog should return only printers.
Selection of anything else will disable the OK button.
DirectoryPath String Returns/Sets the directory path of the
BrowseForFolderDialog object.
EditBox Boolean Returns/Sets if a type-in edit box should be incuded in the
dialog for user input. (included by default with new ui).
IncludeFiles Boolean Returns/Sets if the dialog should display files as well as
folders.
IncludeURLs Boolean Returns/Sets if the dialog should display URLs. (New UI
and IncludeFiles must be enabled as well.)
NoNewFolderButton Boolean Returns/Sets if the new folder button should not appear on
the dialog.
OnlyFileSystemDirs Boolean Returns/Sets if file system directories only should be
returned. Selecting non-file system directores will disable
the OK button.
StatusText Boolean Returns/Sets if the dialog should display status text. (not
available in new ui)
Title String Returns/Sets the dialog title string for the
BrowseForFolderDialog object.
UsageHint Boolean Returns/Sets if a usage hint should be added to the dialog
box. Hint is in place of edit box overrides this flag.
UseNewUI Boolean Returns/Sets if the newer dialog UI should be used. (includes
edit box by default)

2350 NI AWR Design Environment


FileFilterEntry

Name Data Type Description


ValidateEntry Boolean Returns/Sets if values entered in the text entry box should
be validated before being returned as a path.

Methods
None

FileFilterEntry
A MWOffice FileFitlerEntry object.

Properties

Name Data Type Description


Filter String Returns/Sets the filter string for a FileFilterEntry object.
Name String Returns/Sets the name used in code to identify an object.

FileFilterEntries
A Collection of MWOffice FileFilterEntry objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item FileFilterEntry Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: FileFilterEntry

Syntax: Function Add(Name As String, Filter As String) As FileFilterEntry

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

API Scripting Guide 2351


FilePathEntry

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

FilePathEntry
A MWOffice FilePathEntry object.

Properties

Name Data Type Description


Directory String Returns just the directory portion of the full file specification
for the FilePathEntry object.
Extension String Returns just the extension portion of the full file
specification for the FilePathEntry object.
Filename String Returns just the filename portion of the full file specification
for the FilePathEntry object.
FullPath String Returns/Sets the full path specification for the FilePathEntry
object.

FilePathEntries
A collection of MWOffice FilePathEntry objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item FilePathEntry Returns a specific item of a Collection object either by
position or by key.

2352 NI AWR Design Environment


FilePathDialog

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: FilePathEntry

Syntax: Function Add(FilePath As String) As FilePathEntry

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

FilePathDialog
A MWOffice FilePathDialog object.

Properties

Name Data Type Description


AllowMultiSelect Boolean Returns/Sets a value that allows multiple selections in the
filename list box.
DefaultExtension String Returns/Sets the default extention to be appended if the user
does not specify one.
DontAddToRecent Boolean Returns/Sets a value that indicates if the file path should
not be added to the recent files list.
ExplorerStyle Boolean Returns/Sets a value that indicates if an explorer dialog
should be displayed.
ExtensionIsDifferent Boolean Returns/Sets a value that indicates the user entered a file
name different from that specified in DefaultExtension. This
message is returned to the caller.
ExtensionOffset Long Returns/Sets a value that indicates the offset to the character
position of the file extension in the returned file path string.
FileCreatePrompt Boolean Returns/Sets a value that asks if the user wants to create a
file that doesn't currently exist.

API Scripting Guide 2353


FileUtil

Name Data Type Description


FileMustExist Boolean Returns/Sets a value that lets the user only enter valid path
names. If an invalid path is entered a warning message is
displayed.
FileOffset Long Returns/Sets a value that indicates the offset to the character
position of the file name in the returned file path string.
FilePaths FilePathEntries Returns a reference to a collection of FilePathEntry objects.
Filename String Returns/Sets the name of the file to be opened or saved.
FilterIndex Int Returns/Sets the filter to use when initially displaying file
names.
Filters FileFilterEntries Returns a reference to a collection of FileFilterEntry objects.
HideReadOnly Boolean Returns/Sets a value that hides the read-only checkbox.
InitialDirectory String Returns/Sets the initial directory displayed in the dialog.
NoChangeDirectory Boolean Returns/Sets a value that sets the current directory back to
what it was when the dialog was initiated.
NoPlacesBar Boolean Returns/Sets a value that indicates if the explorer style dialog
should not show the places bar with commonly used desktop
folders.
NoTestFileCreate Boolean Returns/Sets a value that indicates if the dialog should not
perform a write protected directory check when closed.
NoValidate Boolean Returns/Sets a value so the dialog will perform no check of
the file name and requires the caller to perform the validity
check.
OverwritePrompt Boolean Returns/Sets a value that will display a message asking the
user if it is ok to overwrite an existing file.
PathMustExist Boolean Returns/Sets a value that requires that the full path to the
file must exist.
ReadOnly Boolean Returns/Sets a value that indicates if the Read-Only
checkbox should initially be selected when the dialog is
displayed.
Title String Returns/Sets the dialog title string.

Methods
None

FileUtil
An MWOffice FileUtil object.

Properties

Name Data Type Description


TempFileName String Returns a file path name for a unique temporary file that
can be used for intermediate results or log file output

2354 NI AWR Design Environment


FileUtil

Methods
CreateBrowseForFolderDialog

Description: Returns a reference to a BrowseForFolderDialog object.

Returns: BrowseForFolderDialog

Syntax: Function CreateBrowseForFolderDialog() As BrowseForFolderDialog

CreateOpenFileDialog

Description: Returns a reference to a FilePathDialogObject.

Returns: FilePathDialog

Syntax: Function CreateOpenFileDialog() As FilePathDialog

CreateSaveFileDialog

Description: Returns a reference to a FilePathDialogObject.

Returns: FilePathDialog

Syntax: Function CreateSaveFileDialog() As FilePathDialog

GetFileInfo

Description: Returns a reference to a MWOffice FileInfo object.

Returns: FileInfo

Syntax: Function GetFileInfo(Filename As String) As FileInfo

GetFolderInfo

Description: Returns a reference to a MWOffice FolderInfos collection.

Returns: FolderInfo

Syntax: Function GetFolderInfo(Filename As String) As FolderInfo

NewZipArchive

Description: Returns a reference to an MWOffice ZipArchiveWriter object.

Returns: ZipArchiveWriter

Syntax: Function NewZipArchive(Filename As String) As ZipArchiveWriter

OpenZipArchive

Description: Return a reference to a collection of ZipArchiveItem objects.

Returns: ZipArchiveItems

API Scripting Guide 2355


FileAttribute

Syntax: Function OpenZipArchive(Filename As String) As ZipArchiveItems

ShowFile

Description: Opens and displays a file in the AWRDE or in an Explorer window.

Returns: Boolean

Syntax: Function ShowFile(FilePath As String, [Type As mwShowFileType = 0], [Flags As Long = 0]) As Boolean

FileAttribute
An MWOffice FileAttribute object.

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
Value Boolean Returns a value that indicates if the associated object has
this attribute.

FileAttributes
A collection of FileAttribute objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item FileAttribute Returns a specific item of a Collection object either by
position or by key.

ScriptRoutine
A MWOffice ScriptRoutine object.

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.

Methods
None

2356 NI AWR Design Environment


ScriptRoutines

ScriptRoutines
A collection of ScriptRoutine objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ScriptRoutine Returns a specific item of a Collection object either by
position or by key.

ScriptModule
A MWOffice ScriptModule object.

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
Path String Returns the file path for the script module if one exists.
Routines ScriptRoutines Returns a reference to a collection of ScriptRoutine objects.

Methods
None

ScriptModules
A collection of ScriptModule objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ScriptModule Returns a specific item of a Collection object either by
position or by key.

Methods
None

API Scripting Guide 2357


SimulationResult

SimulationResult
An MWOffice SimulationResult object.

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
SaveWithResults Boolean Returns/Sets if this simulation result should be included
when the simulation results are saved.

SimulationResults
A collection of MWOffice SimulationResult objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item SimulationResult Returns a specific item of a Collection object either by
position or by key.

Methods
Restore

Description: Restore collection values form persistent storage.

Returns: Boolean

Syntax: Function Restore(Filename As String) As Boolean

Save

Description: Save collection values to persistent storage.

Returns: Boolean

Syntax: Function Save(Filename As String, [SaveMinSet As Boolean = 0], [SaveDynamicData As Boolean = 0],
[SaveExtendedData As Boolean = 0]) As Boolean

SimulationFilter
An MWOffice SimulationFilter object.

2358 NI AWR Design Environment


SimulationFilter

Properties

Name Data Type Description


ConfigurationNames SafeArray Returns/Sets an array of strings for the associated
SimulationFilter property.
DocNames SafeArray Returns/Sets an array of strings for the associated
SimulationFilter property.
Enabled Boolean Returns/sets a value which specifies if the object is enabled.
Name String Returns/Sets the name used in code to identify an object.
SimulationTypeNames SafeArray Returns/Sets an array of strings for the associated
SimulationFilter property.
VendorNames SafeArray Returns/Sets an array of strings for the associated
SimulationFilter property.

Methods
AddConfigurationName

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Boolean

Syntax: Function AddConfigurationName(ConfigurationName As String) As Boolean

ClearConfigurationNames

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub ClearConfigurationNames()

ConfigurationNameExist

Description: Returns whether an item matching the specified criteria exists in the collection.

Returns: Boolean

Syntax: Function ConfigurationNameExist(ConfigurationName As String) As Boolean

DocNameAdd

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Boolean

Syntax: Function DocNameAdd(docName As String) As Boolean

DocNameExist

Description: Returns whether an item matching the specified criteria exists in the collection.

API Scripting Guide 2359


SimulationFilter

Returns: Boolean

Syntax: Function DocNameExist(docName As String) As Boolean

DocNameRemove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function DocNameRemove(docName As String) As Boolean

DocNamesClear

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub DocNamesClear()

RemoveConfigurationName

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function RemoveConfigurationName(ConfigurationName As String) As Boolean

SimulationTypeAdd

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Boolean

Syntax: Function SimulationTypeAdd(SimulationType As String) As Boolean

SimulationTypeExist

Description: Returns whether an item matching the specified criteria exists in the collection.

Returns: Boolean

Syntax: Function SimulationTypeExist(SimulationType As String) As Boolean

SimulationTypeRemove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function SimulationTypeRemove(SimulationType As String) As Boolean

SimulationTypesClear

Description: Removes all objects in a collection.

2360 NI AWR Design Environment


SimulationFilters

Returns: Void

Syntax: Sub SimulationTypesClear()

VendorNameAdd

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Boolean

Syntax: Function VendorNameAdd(VendorName As String) As Boolean

VendorNameExist

Description: Returns whether an item matching the specified criteria exists in the collection.

Returns: Boolean

Syntax: Function VendorNameExist(VendorName As String) As Boolean

VendorNameRemove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function VendorNameRemove(VendorName As String) As Boolean

VendorNamesClear

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub VendorNamesClear()

SimulationFilters
A collection of MWOffice SimulationFilter objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item SimulationFilter Returns a specific item of a Collection object either by
position or by key.

API Scripting Guide 2361


SwitchList

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: SimulationFilter

Syntax: Function Add(Name As String) As SimulationFilter

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Void

Syntax: Sub Remove(Name As String)

RemoveAll

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub RemoveAll()

SwitchList
An MWOffice SwitchList object.

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
ViewNames SafeArray Returns/Sets an array of strings for the associated SwitchList
property.

SwitchLists
A collection of MWOffice SwitchList objects.

2362 NI AWR Design Environment


ConnectionRule

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item SwitchList Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: SwitchList

Syntax: Function Add(Name As String) As SwitchList

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Void

Syntax: Sub Remove(Name As String)

RemoveAll

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub RemoveAll()

ConnectionRule
A MWOffice ConnectionRule object.

Properties

Name Data Type Description


Enable Boolean Returns/sets if the ConnectionRule object is enabled.

API Scripting Guide 2363


ConnectionRules

Name Data Type Description


Rule String Returns/sets the rule of a ConnectionRule object.

ConnectionRules
A collection of MWOffice ConnectionRule objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Item ConnectionRule Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: ConnectionRule

Syntax: Function Add(Rule As String, [bEnable As Boolean = -1]) As ConnectionRule

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

UpdateConnectivity

Description: Updates the connectivity to show changes in the rules.

Returns: Boolean

Syntax: Function UpdateConnectivity() As Boolean

CrossoverRuleEntry
A MWOffice CrossoverRuleEntry object.

Properties

Name Data Type Description


FromLineTypeName String Returns/Sets the from line type name.
LineOffset Double Returns/Sets the line offset amount.
Name String Returns the name used in code to identify an object.

2364 NI AWR Design Environment


CrossoverRuleEntries

Name Data Type Description


ToLineTypeName String Returns/Sets the to line type name.

CrossoverRuleEntries
A collection of MWOffice CrossoverRuleEntry objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item CrossoverRuleEntry Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: CrossoverRuleEntry

Syntax: Function Add(FromLineTypeName As String, ToLineTypeName As String, LineOffset As Double) As


CrossoverRuleEntry

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

CrossoverRule
A MWOffice CrossoverRule object.

API Scripting Guide 2365


CrossoverRules

Properties

Name Data Type Description


Entries CrossoverRuleEntries Returns a reference to a collection of CrossoverRuleEnties.
Flags Long Returns/sets the flags value in the CrossoverRule.
Name String Returns the name used in code to identify an object.

CrossoverRules
A collection of MWOffice CrossoverRule objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item CrossoverRule Returns a specific item of a Collection object either by
position or by key.

Methods
CreateNew

Description: Adds an object to the collection and returns a reference to the created object.

Returns: CrossoverRule

Syntax: Function CreateNew() As CrossoverRule

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

ProcessViaFillEntry
A MWOffice ProcessViaFillEntry object.

2366 NI AWR Design Environment


ProcessViaFillEntries

Properties

Name Data Type Description


Alignment mwViaAlignType Returns/sets the via alignment type for the
ProcessViaFillEntry.
CellName String Returns/sets the via cell name for the ProcessViaFillEntry.
Clearance Double Returns/sets the via clearance from any edge of the filled
shape.
Name String Returns/Sets the name used in code to identify an object.
OffsetX Double Returns/sets the via offset in the X direction for the
ProcessViaFillEntry.
OffsetY Double Returns/sets the via offset in the Y direction for the
ProcessViaFillEntry.
SpacingType mwViaSpacingType Returns/sets the via spacing type for the
ProcessViaFillEntry.
SpacingX Double Returns/sets the via spacing in the X direction for the
ProcessViaFillEntry.
SpacingY Double Returns/sets the via spacing in the Y direction for the
ProcessViaFillEntry.
StaggerMode mwViaFillStaggerMode Returns/sets if the alternate rows of vias should be staggered
for the ProcessViaFillEntry
libName String Returns/sets the via cell library name for the
ProcessViaFillEntry.

ProcessViaFillEntries
A collection of MWOffice ProcessViaFillEntry objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ProcessViaFillEntry Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: ProcessViaFillEntry

API Scripting Guide 2367


ProcessViaFenceEntry

Syntax: Function Add(entryName As String, libName As String, CellName As String, SpacingX As Double, SpacingY
As Double, Clearance As Double, [SpacingType As mwViaSpacingType = 0], [OffsetX As Double = 0], [OffsetY As
Double = 0], [bStaggerMode As mwViaFillStaggerMode = 0]) As ProcessViaFillEntry

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

ProcessViaFenceEntry
A MWOffice ProcessViaFenceEntry object.

Properties

Name Data Type Description


CellName String Returns/sets the via cel name for the ProcessViaFenceEntry.
MergePerimeters Boolean Returns/sets the pre-merge mode for fencing around
perimeter shapes.
Name String Returns/Sets the name used in code to identify an object.
OffsetX Double Returns/sets the via offset in the X direction for the
ProcessViaFillEntry.
OffsetY Double Returns/sets the via offset in the Y direction for the
ProcessViaFillEntry.
OpenPathEnds Boolean Returns/sets the if the path ends should be left open or
should have vias.
PathAspectRatio Double Returns/sets the aspect ratio value used to recognize path
objects for open/closed path ends.
PerimeterOversize Double Returns/sets the oversize amount for fencing around
perimeter shapes.
Spacing Double Returns/sets the via spacing for the ProcessViaFenceEntry.
SpacingType mwViaSpacingType Returns/sets the via spacing type for the
ProcessViaFenceEntry.
libName String Returns/sets the via cell library name for the
ProcessViaFenceEntry.

2368 NI AWR Design Environment


ProcessViaFenceEntries

ProcessViaFenceEntries
A collection of MWOffice ProcessViaFenceEntry objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ProcessViaFenceEntry Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: ProcessViaFenceEntry

Syntax: Function Add(entryName As String, libName As String, CellName As String, Spacing As Double, [SpacingType
As mwViaSpacingType = 0], [OffsetX As Double = 0], [OffsetY As Double = 0], [MergePerimeters As Boolean = -1],
[PerimeterOversize As Double = 0], [OpenPathEnds As Boolean = -1], [PathAspectRatio As Double = 5]) As
ProcessViaFenceEntry

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

API Scripting Guide 2369


ProcessViaLineType

ProcessViaLineType
An MWOffice ProcessViaLineType object.

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
Number Long Returns the numeric index of this line type.
typeIndex Long Returns the type index of this line type.

ProcessViaLineTypePair
An MWOffice ProcessViaLineTypePair object.

Properties

Name Data Type Description


First ProcessViaLineType Return a reference to a MWOffice ProcessViaLineType
object.
Second ProcessViaLineType Return a reference to a MWOffice ProcessViaLineType
object.

ProcessViaLineTypePairs
A collection of MWOffice ProcessViaLineTypePair objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ProcessViaLineTypePair Returns a specific item of a Collection object either by
position or by key.
PairExists Boolean Returns whether an item matching the specified criteria
exists in the collection.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: ProcessViaLineTypePair

Syntax: Function Add(First, Second) As ProcessViaLineTypePair

2370 NI AWR Design Environment


CellMapping

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(First, Second) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub RemoveAll()

CellMapping
An MWOffice CellMapping object.

Properties

Name Data Type Description


CellName String Returns the cell mapping cell name.
ElementName String Returns the cell mapping element name.

CellMappings
A collection of MWOffice CellMapping objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item CellMapping Returns a specific item of a Collection object either by
position or by key.

EMPortTermination
A MWOffice EMPortTermination object.

Properties

Name Data Type Description


ExcitationAngle Double Returns/Sets the excitation phase angle used if the port is
an excitation port.

API Scripting Guide 2371


EMPortTerminations

Name Data Type Description


ExcitationPort Boolean Returns/Sets if the EMPortTermination represents an
excitation or termination port.
ExcitationSignalSize Double Returns/Sets the excitation signal size used if the port is an
excitation port.
Impedance ComplexNumber Returns/Sets the termination impedance used if the port is
a termination and not a excitation port.

EMPortTerminations
A collection of MWOffice EMPortTermination objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item EMPortTermination Returns a specific item of a Collection object either by
position or by key.

EMPort
A MWOffice EMPort object.

Properties

Name Data Type Description


Conductor String Returns/Sets the conductor name for the EMPort object.
Deembed Boolean Returns/Sets if the EMPort should be de-embedded up to
the reference plane distance.
EntityID Long Returns/Sets the entity identifier for the EMPort object.
Excitation ComplexNumber Returns a reference to a complex value representing the port
excitation.
Flags Long Returns/Sets the attribute flags for the EMPORt object. Flag
values for this field come from the mwEMPortFlags
enumeration.
GroupNumber Long Returns/Sets the group number for the EMPort object.
GroupType mwEMGroupType Returns/Sets the group type for the EMPort object.
Impedance ComplexNumber Returns a reference to a complex value representing the port
impedance.
Layer Long Returns/Sets the layer index for this EMPort object.
LineType Long Returns/Sets the line type index for this EMPort object.
NetID Long Returns/Sets the physical net id for this EMPort object.

2372 NI AWR Design Environment


EMPorts

Name Data Type Description


Number Long Returns the port number of this EMPort object.
PhysicalThickness Double Returns/Sets the physical thickness value for this EMPort
object.
ReferencePlaneDist Double Returns/Sets the reference plane distance for the EMPort
object.
Termination EMPortTermination Returns a reference to a EMPortTermination object.
Thickness Double Returns/Sets the conductor thickness value for this EMPort
object.
Type mwEMPortType Returns the type of this EMPort object.
Vertices Vertices Returns a reference to a collection of vertices representing
the points defining the EMPort object.

EMPorts
A collection of MWOffice EMPort objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item EMPort Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: EMPort

Syntax: Function Add(Type As mwEMShapePortType, p1x As Double, p1y As Double, p2x As Double, p2y As Double)
As EMPort

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

API Scripting Guide 2373


CellInfo

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

CellInfo
A MWOffice CellInfo object.

Properties

Name Data Type Description


FaceCount Long Returns a count of the faces in the MWOffice Cell object.
PinCount Long Returns a count of the pins in the MWOffice Cell object.
ReferenceCount Long Returns a count of the references to this MWOffice Cell
object.
ShapeCount Long Returns a count of the shapes in the MWOffice Cell object.

SweepLabel
A SweepLabel object contains information about the swept variable values for a particular measurement trace.

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
UnitType mwUnitType Returns the unit type of the swept variable
Value Double Returns the value in base units of the swept variable

SweepLabels
A collection of MWOffice SweepLabel objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item SweepLabel Returns a specific item of a Collection object either by
position or by key.

LayoutInfo
A MWOffice LayoutInfo object.

2374 NI AWR Design Environment


ComponentTest

Properties

Name Data Type Description


CellCount Long Returns a count of the layout PCell objects in the MWOffice
Layout object.
FaceCount Long Returns a count of the faces in the MWOffice Layout object.
FlightLineCount Long Returns a count of the flight lines in the MWOffice Layout
object.
PinCount Long Returns a count of the pins in the MWOffice Layout object.
ShapeCount Long Returns a count of the shapes in the MWOffice Layout
object.

ComponentTest
A MWOffice ComponentTest object.

Properties

Name Data Type Description


Attributes Attributes Returns a reference to a collection of Attribute objects.
Description String Returns a description of the component test and results.
Name String Returns the name used in code to identify an object.

Methods
RunTest

Description: Runs the component test and optionally returns results.

Returns: Boolean

Syntax: Function RunTest([Arguments], [pRet]) As Boolean

SaveResult

Description: Saves the various types of output results from the component test to a file.

Returns: Boolean

Syntax: Function SaveResult(Filename As String, Type As mwComponentTestResultType) As Boolean

ComponentTests
A collection of ComponentTest objects.

API Scripting Guide 2375


StatusItem

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ComponentTest Returns a specific item of a Collection object either by
position or by key.

StatusItem
A MWOffice StatusItem object.

Properties

Name Data Type Description


Category mwStatusItemCategory Returns the category of the MWOffice StatusItem object.
Date String Returns the date from the MWOffice StatusItem object.
ErrorCode Long Returns the code value associated with the MWOffice
StatusItem object.
Flags Long Returns the flags associated with the MWOffice StatusItem
object.
Group StatusGroup Returns the Group object that the status item is a member
of.
Text String Returns the text associated with the MWOffice StatusItem
object.
Time String Returns the time from the MWOffice StatusItem object.

Methods
Activate

Description: Activate the object associated with the status item.

Returns: Void

Syntax: Sub Activate()

Delete

Description: Deletes the status item.

Returns: Void

Syntax: Sub Delete()

2376 NI AWR Design Environment


StatusItems

StatusItems
A collection of MWOffice StatusItem objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item StatusItem Returns a specific item of a Collection object either by
position or by key.

Methods
None

StatusGroup
A MWOffice StatusGroup object.

Properties

Name Data Type Description


Items StatusItems Returns a reference to a collection of MWOffice StatusItem
objects.
Name String Returns/Sets the name used in code to identify an object.

Methods
RemoveAllItems

Description: Returns a reference to a collection of MWOffice StatusItem objects.

Returns: Void

Syntax: Sub RemoveAllItems()

Search

Description: Returns a reference to a collection MWOffice StatusItems matching the given criteria.

Returns: StatusItems

Syntax: Function Search(PartialString As String, [Category As mwStatusItemCategory = -1]) As StatusItems

StatusGroups
A collection of MWOffice StatusGroup objects.

API Scripting Guide 2377


StatusWindow

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item StatusGroup Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: StatusGroup

Syntax: Function Add(Name As String, Owner As Object) As StatusGroup

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

StatusWindow
The MWOffice StatusWindow object.

Properties

Name Data Type Description


Visible Boolean Returns/Sets if the StatusWindow object is visible.

Status
A collection of MWOffice StatusGroup objects.

Properties

Name Data Type Description


Groups StatusGroups Returns a reference to a collection of MWOffice
StatusGroup objects.
Items StatusItems Returns a reference to a collection of MWOffice StatusItem
objects.
Window StatusWindow Returns a reference to a MWOffice StatusWindow object.

2378 NI AWR Design Environment


CursorInfo

Methods
CopyToClipboard

Description: Copy the status window contents to the clipboard.

Returns: Boolean

Syntax: Function CopyToClipboard() As Boolean

RemoveAllItems

Description: Removes all the status items.

Returns: Void

Syntax: Sub RemoveAllItems()

Search

Description: Returns a reference to a collection MWOffice StatusItems matching the given criteria.

Returns: StatusItems

Syntax: Function Search(PartialString As String, [Category As mwStatusItemCategory = -1]) As StatusItems

CursorInfo
A MWOffice CursorInfo object.

Properties

Name Data Type Description


ControlKeyDown Boolean Returns the if the control key was pressed when the
CursorInfo was recored.
PositionX Variant Returns the X coordinate of the most recent recorded
position of the CursorInfo object.
PositionY Variant Returns the Y coordinate of the most recent recorded
position of the CursorInfo object.
ShiftKeyDown Boolean Returns if the shift key was pressed when the CursorInfo
was recorded.

View
A MWOffice View object.

Properties

Name Data Type Description


Cursor CursorInfo Returns a reference to a MWOffice CursorInfo object.

API Scripting Guide 2379


View

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
ViewName String Returns the static view name for this view

Methods
ReDraw

Description: Refreshes the view by redrawing the contents.

Returns: Void

Syntax: Sub ReDraw()

ViewAll

Description: Zooms the view to display all content.

Returns: Void

Syntax: Sub ViewAll()

ViewArea

Description: Zooms the view to display the area defined by the given coordinates.

Returns: Void

Syntax: Sub ViewArea(x1, y1, x2, y2)

ZoomIn

Description: Zooms the view in to the center of the current location to display approximately half the current area.

Returns: Void

Syntax: Sub ZoomIn()

ZoomOut

Description: Zooms the view out at the current location to display approximately twice the current area.

Returns: Void

Syntax: Sub ZoomOut()

ZoomPrev

Description: Returns the window display to the previously displayed zoom level.

Returns: Void

Syntax: Sub ZoomPrev()

2380 NI AWR Design Environment


Views

ZoomSelected

Description: Zooms the view to display the area which includes all selected objects.

Returns: Void

Syntax: Sub ZoomSelected()

Views
A collection of MWOffice View objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item View Returns a specific item of a Collection object either by
position or by key.

ThreeDView
A MWOffice 3DView object.

Properties

Name Data Type Description


AntiAliased Boolean Returns/Sets if the viewing model should be anti-aliased
AutoRotate mwViewAutoRotate Returns/Sets the auto rotate mode for the 3DView object.
Cursor CursorInfo Returns a reference to a MWOffice CursorInfo object.
ExtrudedOnly Boolean Returns/Sets if the viewing model should include extruded
shapes only
Name String Returns/Sets the name used in code to identify an object.
Phi Double Returns/Sets the spherical coordinate viewing angle phi for
the 3D view in degrees.
RotationCenter Vertex3D Returns a reference to a Vertex3D object.
SelectedShapes Boolean Returns/Sets if the viewing model should show only the
selected shapes
Shaded Boolean Returns/Sets if the viewing model is shaded or wireframe
ShapesMerged Boolean Returns/Sets if the viewing model should show the shapes
merged on +/- layers
ShowEdges Boolean Returns/Sets if the viewing model should show edges
Stippling Boolean Returns/Sets if the viewing model should use stippling for
color shading

API Scripting Guide 2381


ThreeDView

Name Data Type Description


Texturing Boolean Returns/Sets if the viewing model should include texturing
Theta Double Returns/Sets the spherical coordinate viewing angle theta
for the 3D view in degrees.
ViewFrom mwViewFrom Returns/Sets a predefined view direction for the 3DView
object.
ViewName String Returns the static view name for this view
Visual Long Returns/Sets visual attributes for the content display in the
3DView object.
Wireframe Boolean Returns/Sets if the viewing model is wireframe or shaded
ZoomFactor Double Returns/Sets the magnification zoomfactor for the 3D view.
(zoomfactor = 1.0 for model fit to view larger values to
zoom-in)

Methods
ReDraw

Description: Refreshes the view by redrawing the contents.

Returns: Void

Syntax: Sub ReDraw()

ViewAll

Description: Zooms the view to display all content.

Returns: Void

Syntax: Sub ViewAll()

ViewArea

Description: Zooms the view to display the area defined by the given coordinates.

Returns: Void

Syntax: Sub ViewArea(x1, y1, x2, y2)

ZoomIn

Description: Zooms the view in to the center of the current location to display approximately half the current area.

Returns: Void

Syntax: Sub ZoomIn()

ZoomOut

Description: Zooms the view out at the current location to display approximately twice the current area.

2382 NI AWR Design Environment


ThreeDViews

Returns: Void

Syntax: Sub ZoomOut()

ZoomPrev

Description: Returns the window display to the previously displayed zoom level.

Returns: Void

Syntax: Sub ZoomPrev()

ZoomSelected

Description: Zooms the view to display the area which includes all selected objects.

Returns: Void

Syntax: Sub ZoomSelected()

ThreeDViews
A collection of MWOffice 3D View objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ThreeDView Returns a specific item of a Collection object either by
position or by key.

EmbeddedDesign
A MWOffice EmbeddedDesign object.

Properties

Name Data Type Description


DesignName String Returns the name of the design displayed by this
EmbeddedDesign object.
Extension String Returns the extension of the design type displayed by this
EmbeddedDesign object.
Height Double Returns/sets the height of the embedded design region.
Width Double Returns/sets the width of the embedded design region.
x Double Returns/sets the x-coordinate of the embedded design
position.

API Scripting Guide 2383


EmbeddedDesigns

Name Data Type Description


y Double Returns/sets the y-coordinate of the embedded design
position.

EmbeddedDesigns
A collection of MWOffice EmbeddedDesign objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item EmbeddedDesign Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: EmbeddedDesign

Syntax: Function Add(docName As String, Type As mwEmbeddedDocType, x As Double, y As Double, Width As


Double, Height As Double) As EmbeddedDesign

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

EMail
A MWOffice EMail object.

2384 NI AWR Design Environment


FileInfo

Properties

Name Data Type Description


Attachments FileInfos Returns a reference to a MWOffice FileInfos collection.
BccRecipients String Returns/Sets the Bcc: recipient line for this MWOffice
EMail object.
Body String Returns/Sets the body content text for this MWOffice EMail
object.
CcRecipients String Returns/Sets the Cc: recipient line for this MWOffice EMail
object.
Subject String Returns/Sets the subject line for this MWOffice EMail
object.
ToRecipients String Returns/Sets the To: recipient line for this MWOffice EMail
object.

FileInfo
A MWOffice FileInfo object.

Properties

Name Data Type Description


Attributes FileAttributes Returns a reference to a MWOffice FileAttribute object.
Extension String Returns the extension portion of the file name.
FileExists Boolean Returns a value indicating whether this MWOffice FileInfo
object exists.
IsDirectory Boolean Returns a value indicating whether this MWOffice FileInfo
object references a directory.
Name String Returns/Sets the name used in code to identify an object.
Path String Returns/Sets the file path for this MWOffice FileInfo object.
ReadOnly Boolean Returns/Sets a value indicating whether this MWOffice
FileInfo object is readonly.

FileInfos
A collection of MWOffice FileInfo objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.

API Scripting Guide 2385


FolderInfo

Name Data Type Description


Item FileInfo Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: FileInfo

Syntax: Function Add(FilePath As String) As FileInfo

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub RemoveAll()

FolderInfo
A MWOffice FolderInfo object.

Properties

Name Data Type Description


Files FileInfos Returns a reference to a MWOffice FileInfos collection.
FolderExists Boolean Returns a value indicating whether this MWOffice
FolderInfo exists and is a directory.
Folders FolderInfos Returns a reference to a MWOffice FolderInfos collection.
Name String Returns/Sets the name used in code to identify an object.
Path String Returns/Sets the file path for this MWOffice FolderInfo
object.

FolderInfos
A collection of MWOffice FolderInfo objects.

2386 NI AWR Design Environment


ProjectTreeView

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item FolderInfo Returns a specific item of a Collection object either by
position or by key.

ProjectTreeView
A MWOffice project TreeView object.

Properties

Name Data Type Description


Nodes TreeNodes Returns a reference to a MWOffice TreeNodes collection.
SelectedItem TreeNode Returns/sets the object's selected child item.
Visible Boolean Returns/sets a value which specifies if the object is visible.

Methods
Hide

Description: Hides the project TreeView window.

Returns: Void

Syntax: Sub Hide()

Show

Description: Shows the project TreeView window.

Returns: Void

Syntax: Sub Show()

TreeNode
A MWOffice TreeNode object.

Properties

Name Data Type Description


Checked Boolean Returns/sets the checked state of the MWOffice TreeNode
object.
Children TreeNodes Returns a reference to a MWOffice TreeNodes collection.

API Scripting Guide 2387


TreeNode

Name Data Type Description


Expanded Boolean Returns/sets the expanded state of the MWOffice TreeNode
object.
Name String Returns the name of the MWOffice TreeNode object.
Selected Boolean Returns/sets a value which specifies if the object is selected.
Text String Returns the text of the MWOffice TreeNode object.
Visible Boolean Returns the visible state of the MWOffice TreeNode object.

Methods
Check

Description: Checks the MWOffice TreeNode object

Returns: Void

Syntax: Sub Check(Recurse As Boolean)

Collapse

Description: Collapses the MWOffice TreeNode object

Returns: Void

Syntax: Sub Collapse(Recurse As Boolean)

Expand

Description: Expands the MWOffice TreeNode object

Returns: Void

Syntax: Sub Expand(Recurse As Boolean)

Select

Description: Selects the MWOffice TreeNode object

Returns: Void

Syntax: Sub Select()

Uncheck

Description: Unchecks the MWOffice TreeNode object

Returns: Void

Syntax: Sub Uncheck(Recurse As Boolean)

2388 NI AWR Design Environment


TreeNodes

TreeNodes
A collection of MWOffice TreeNode objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item TreeNode Returns a specific item of a Collection object either by
position or by key.

ProjectItem
A MWOffice ProjectItem object.

Properties

Name Data Type Description


Name String Returns/Sets the name used in code to identify an object.
TreeNode TreeNode Returns a reference to a MWOffice TreeNode object.
Type mwProjectItemType Returns the type of the MWOffice ProjectItem object.

ProjectItems
A collection of MWOffice ProjectItem objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item ProjectItem Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: ProjectItem

Syntax: Function Add(pDisp As Object) As ProjectItem

API Scripting Guide 2389


UserFolder

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

UserFolder
A MWOffice Folder object.

Properties

Name Data Type Description


Folders UserFolders Returns a reference to a MWOffice Folders collection.
Name String Returns/Sets the name used in code to identify an object.
Parent UserFolder Returns a reference to a MWOffice Folder object.
ProjectItems ProjectItems Returns a reference to a MWOffice ProjectItems collection.
TreeNode TreeNode Returns a reference to a MWOffice TreeNode object.

Methods
None

UserFolders
A collection of MWOffice Folder objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item UserFolder Returns a specific item of a Collection object either by
position or by key.

2390 NI AWR Design Environment


WizardDoc

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: UserFolder

Syntax: Function Add(Name As String) As UserFolder

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Boolean

Syntax: Function RemoveAll() As Boolean

WizardDoc
A MWOffice WizardDoc instance object.

Properties

Name Data Type Description


Description String Returns a description of the MWOffice Wizard object.
Name String Returns the name of and instance of a MWOffice Wizard
object.

Methods
Edit

Description: Edits an instance of an MWOffice WizardDoc.

Returns: Void

API Scripting Guide 2391


WizardDocs

Syntax: Sub Edit()

Remove

Description: Removes a specific member from a collection.

Returns: Void

Syntax: Sub Remove()

WizardDocs
A collection of MWOffice WizardDoc objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item WizardDoc Returns a specific item of a Collection object either by
position or by key.

Methods
CreateNew

Description: Creates a new instance of the MWOffice Wizard object.

Returns: Object

Syntax: Function CreateNew(WizardType, Run As Boolean) As Object

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

Wizard
A MWOffice Wizard definition object.

Click to see examples

Properties

Name Data Type Description


Description String Returns a description of the MWOffice Wizard object.

2392 NI AWR Design Environment


Wizards

Name Data Type Description


Name String Returns the name of the MWOffice Wizard object.

Methods
CreateNew

Description: Creates a new instance of the MWOffice Wizard object.

Returns: Object

Syntax: Function CreateNew() As Object

Run

Description: Creates an instance of the MWOffice Wizard object and runs it.

Returns: Object

Syntax: Function Run() As Object

Wizards
A collection of MWOffice Wizard objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Wizard Returns a specific item of a Collection object either by
position or by key.

Annotation
A MWOffice Annotation object.

Properties

Name Data Type Description


Enabled Boolean Returns/sets a value which specifies if the Annotation object
is enabled.
Name String Returns/sets the name of the MWOffice Annotation object.

Methods
None

API Scripting Guide 2393


Annotations

Annotations
A collection of MWOffice Annotation objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item Annotation Returns a specific item of a Collection object either by
position or by key.

Methods
Add

Description: Adds an object to the collection and returns a reference to the created object.

Returns: Annotation

Syntax: Function Add(Name As String) As Annotation

GetUniqueName

Description: Returns a unique name to be used when adding objects to the collection.

Returns: String

Syntax: Function GetUniqueName(baseName As String) As String

Remove

Description: Removes a specific member from a collection.

Returns: Boolean

Syntax: Function Remove(Index) As Boolean

RemoveAll

Description: Removes all objects in a collection.

Returns: Void

Syntax: Sub RemoveAll()

RegressionTester
A MWOffice RegressionTester object.

2394 NI AWR Design Environment


RegressionTester

Methods
CompareEMInputDataFiles

Description: Compare two EM Input Data files for equivalence.

Returns: Boolean

Syntax: Function CompareEMInputDataFiles(refFile As String, testFile As String) As Boolean

CompareGdsiiFiles

Description: Compare two GDSII files for equivalence.

Returns: Boolean

Syntax: Function CompareGdsiiFiles(refFile As String, testFile As String) As Boolean

GenerateReferenceDataFiles

Description: Generate new regression test reference data files.

Returns: Boolean

Syntax: Function GenerateReferenceDataFiles() As Boolean

GenerateReferenceEM3DModelFiles

Description: Generate new EM 3D model regression test reference data files.

Returns: Boolean

Syntax: Function GenerateReferenceEM3DModelFiles() As Boolean

GenerateReferenceEMInputDataFiles

Description: Generate new EM input data regression test reference data files.

Returns: Boolean

Syntax: Function GenerateReferenceEMInputDataFiles() As Boolean

GenerateReferenceGdsiiFiles

Description: Generate new GDSII regression test reference data files.

Returns: Boolean

Syntax: Function GenerateReferenceGdsiiFiles() As Boolean

RunRegressionTestList

Description: Initiates running a named regression test.

Returns: RegressionResult

API Scripting Guide 2395


RegressionResult

Syntax: Function RunRegressionTestList(Path As String, append As Boolean) As RegressionResult

RegressionResult
A MWOffice RegressionResult object.

Properties

Name Data Type Description


Failed Long Returns a count of the regression tests that failed.
Passed Long Returns a count of the regression tests that passed.

JobEntry
A MWOffice JobEntry object.

Properties

Name Data Type Description


Description String Returns a string description of the JobEntry object.
Details Attributes Returns a reference to a collection of Attribute objects.
ExitCode Long Returns the exit code returned by the job when it ended
Valid for HasEnded == True
HasEnded Boolean Returns if the JobEntry object has ended running.
HasStarted Boolean Returns if the JobEntry object has started running.
Id Long Returns a unique identifier value for a JobEntry object.
IsRunning Boolean Returns if the JobEntry object is currently running.
Name String Returns/Sets the name used in code to identify an object.
Owner String Returns the user name of the owner for the JobEntry object.
Project String Returns the name of the project associated with the JobEntry
object.
StartTime String Returns a string with the start time for the JobEntry object.
Empty if the Job has not started.
Status mwJobStatusType Returns a value indicating the current status of a JobEntry
object.

Methods
Cancel

Description: Cancels the JobEntry object if it has not yet started or ended.

Returns: Boolean

Syntax: Function Cancel() As Boolean

2396 NI AWR Design Environment


JobEntries

Pause

Description: Suspends the JobEntry object if it is currently in a running state.

Returns: Boolean

Syntax: Function Pause() As Boolean

Resume

Description: Resumes the JobEntry object if it is in a suspended state.

Returns: Boolean

Syntax: Function Resume() As Boolean

JobEntries
A collection of JobEntry objects.

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item JobEntry Returns a specific item of a Collection object either by
position or by key.

JobQueue
A MWOffice JobQueue object.

Properties

Name Data Type Description


Enabled Boolean Returns a value which determines if the JobQueue is enabled
or disabled.
Entries JobEntries Returns a reference to a collection of JobEntry objects.
Local Boolean Returns a value which determines if the JobQueue is local
or remote.
Name String Returns/Sets the name used in code to identify an object.
Query JobSchedulerQuery Returns a reference to a JobSchedulerQuery object.

JobQueues
A collection of JobQueue objects.

API Scripting Guide 2397


JobSchedulerQuery

Properties

Name Data Type Description


Count Long Returns the number of objects in the collection.
Exists Boolean Returns whether an item matching the specified criteria
exists in the collection.
Item JobQueue Returns a specific item of a Collection object either by
position or by key.

JobSchedulerQuery
A MWOffice JobSchedulerQuery object.

Properties

Name Data Type Description


ComputeNodes SafeArray Returns an array of strings for the list of compute nodes.

JobMonitor
A MWOffice JobMonitor object.

Properties

Name Data Type Description


Queues JobQueues Returns a reference to a collection of JobQueue objects.

PageSetup
A MWOffice PageSetup object.

Properties

Name Data Type Description


BottomMargin Double Returns/Sets the size of the bottom page margin.
DetailLevel mwPageSetupDetailLevel Returns/Sets the output detail level.
LeftMargin Double Returns/Sets the size of the left page margin.
Orientation mwPageSetupOrientation Returns/Sets the page orientation.
PaperSize mwPrintPaperSize Returns/Sets the output paper size.
PaperSource mwPrintPaperSource Returns/Sets the output paper source.
RightMargin Double Returns/Sets the size of the right page margin.
ScaleOutput Boolean Returns/Sets if the output should be scaled.
TopMargin Double Returns/Sets the size of the top page margin.
scaleFactor Double Returns/Sets the scale factor for output scaling.

2398 NI AWR Design Environment


RoutePropertyInfo

RoutePropertyInfo
A MWOffice RoutePropertyInfo object.

Properties

Name Data Type Description


DefaultLineType Long Returns/sets the default line type when not using HV routing.
DefaultWidth Double Returns/sets the default routing width when not using HV
routing.
HorizontalLineType Long Returns/sets the default horizontal line type when using HV
routing.
HorizontalVerticalRouting Boolean Returns/sets if Horizontal/Vertical routing should be used.
HorizontalWidth Double Returns/sets the default horizontal width when using HV
routing.
VerticalLineType Long Returns/sets the default vertical line type when using HV
routing.
VerticalWidth Double Returns/sets the default vertical width when using HV
routing.

mwFeatureTypeFlags
Constants that define the project features.

Name Value
mwFTF_CircuitSimulator 1
mwFTF_NonLinearSimulator 2
mwFTF_EMSimulator 4
mwFTF_Layout 8
mwFTF_SystemSimulator 16
mwFTF_AdvancedSystem 32
mwFTF_AdvancedMWO 64
mwFTF_MMIC 128

mwShapeToolFlags
Constants that define the types of shape tools.

Name Value
mwSTF_Rectangle 1
mwSTF_Polygon 2
mwSTF_Path 4
mwSTF_Ellipse 8

API Scripting Guide 2399


mwAlignToolFlags

Name Value
mwSTF_Intersect 16
mwSTF_Union 32
mwSTF_Subtract 64
mwSTF_Xor 128
mwSTF_Resize 256
mwSTF_ResizeCopy 512
mwSTF_Ring 1024
mwSTF_DrillHole 2048
mwSTF_Group 4096
mwSTF_UnGroup 8192
mwSTF_ArrayCopy 16384
mwSTF_StretchArea 32768
mwSTF_Sliced 65536
mwSTF_Text 131072
mwSTF_Ruler 262144
mwSTF_DimLine 524288

mwAlignToolFlags
Constants that define the types of alignment tools.

Name Value
mwATF_Top 1
mwATF_Bottom 2
mwATF_VertCenter 4
mwATF_Left 8
mwATF_Right 16
mwATF_HorzCenter 32
mwATF_SpaceV 64
mwATF_SpaceH 128

mwProjectToolFlags
Constants that define the types of project tools.

Name Value
mwPTF_Undo 1
mwPTF_Redo 2
mwPTF_ZoomArea 4

2400 NI AWR Design Environment


mwLinearSolveType

Name Value
mwPTF_ZoomOut 8
mwPTF_AutoView 16
mwPTF_Tune 32
mwPTF_SnapTogether 64
mwPTF_SnapToFit 128
mwPTF_SnapAll 256
mwPTF_AnchorTool 512
mwPTF_Measure 1024
mwPTF_ViewSchematic 2048
mwPTF_ViewLayout 4096
mwPTF_View3D 8192
mwPTF_GridMult 16384
mwPTF_DRC 32768

mwLinearSolveType
Constants that define the solution types available in the linear circuit simulator.

Name Value
mwLST_Smart 0
mwLST_Sparse 1
mwLST_Full 2

mwNonLinearSolveType
Constants that define the solution types available in the non-linear circuit simulator.

Name Value
mwNLST_Smart 0
mwNLST_Iterative 1
mwNLST_Direct 2

mwEMSolverType
Constants that define the matrix solution types available in the EM simulator.

Name Value
mwEMST_DefaultDirect 0
mwEMST_FullDirect 1
mwEMST_SymetricDirect 2
mwEMST_IterativeLarge 3

API Scripting Guide 2401


mwEMSolverToleranceLevel

Name Value
mwEMST_IterativeMedium 4
mwEMST_IterativeSmall 5
mwEMST_IterativeCustom 6

mwEMSolverToleranceLevel
Constants that define the tolerance level for the matrix solver.

Name Value
mwEMSL_Low 0
mwEMSL_Medium 1
mwEMSL_High 2
mwEMSL_VeryHigh 3

mwEMMeshDensity
Constants that define the mesh density levels available for EM simulation.

Name Value
mwEMMD_High 0
mwEMMD_Normal 1
mwEMMD_Medium 2
mwEMME_Low 3

mwColor
Constants that define different types of standard colors.

Name Value
mwCLR_AliceBlue 16775408
mwCLR_AntiqueWhite 14150650
mwCLR_Aqua 16776960
mwCLR_Aquamarine 13959039
mwCLR_Azure 16777200
mwCLR_Beige 14480885
mwCLR_Bisque 12903679
mwCLR_Black 0
mwCLR_BlanchedAlmond 13495295
mwCLR_Blue 16711680
mwCLR_BlueViolet 14822282
mwCLR_Brown 2763429

2402 NI AWR Design Environment


mwColor

Name Value
mwCLR_BurlyWood 8894686
mwCLR_CadetBlue 10526303
mwCLR_Chartreuse 65407
mwCLR_Chocolate 1993170
mwCLR_Coral 5275647
mwCLR_CornflowerBlue 15570276
mwCLR_Cornsilk 14481663
mwCLR_Crimson 3937500
mwCLR_Cyan 16776960
mwCLR_DarkBlue 9109504
mwCLR_DarkCyan 9145088
mwCLR_DarkGoldenrod 755384
mwCLR_DarkGray 11119017
mwCLR_DarkGreen 25600
mwCLR_DarkKhaki 7059389
mwCLR_DarkMagenta 9109643
mwCLR_DarkOliveGreen 3107669
mwCLR_DarkOrange 36095
mwCLR_DarkOrchid 13382297
mwCLR_DarkRed 139
mwCLR_DarkSalmon 8034025
mwCLR_DarkSeaGreen 9157775
mwCLR_DarkSlateBlue 9125192
mwCLR_DarkSlateGray 5197615
mwCLR_DarkTurquoise 13749760
mwCLR_DarkViolet 13828244
mwCLR_DeepPink 9639167
mwCLR_DeepSkyBlue 16760576
mwCLR_DimGray 6908265
mwCLR_DodgerBlue 16748574
mwCLR_Firebrick 2237106
mwCLR_FloralWhite 15792895
mwCLR_ForestGreen 2263842
mwCLR_Fuchsia 16711935
mwCLR_Gainsboro 14474460
mwCLR_GhostWhite 16775416
mwCLR_Gold 55295

API Scripting Guide 2403


mwColor

Name Value
mwCLR_Goldenrod 2139610
mwCLR_Gray 8421504
mwCLR_Green 32768
mwCLR_GreenYellow 3145645
mwCLR_Honeydew 15794160
mwCLR_HotPink 11823615
mwCLR_IndianRed 6053069
mwCLR_Indigo 8519755
mwCLR_Ivory 15794175
mwCLR_Khaki 9234160
mwCLR_Lavender 16443110
mwCLR_LavenderBlush 16118015
mwCLR_LawnGreen 64636
mwCLR_LemonChiffon 13499135
mwCLR_LightBlue 15128749
mwCLR_LightCoral 8421616
mwCLR_LightCyan 16777184
mwCLR_LightGoldenrodYellow 13826810
mwCLR_LightGray 13882323
mwCLR_LightGreen 9498256
mwCLR_LightPink 12695295
mwCLR_LightSalmon 8036607
mwCLR_LightSeaGreen 11186720
mwCLR_LightSkyBlue 16436871
mwCLR_LightSlateGray 10061943
mwCLR_LightSteelBlue 14599344
mwCLR_LightYellow 14745599
mwCLR_Lime 65280
mwCLR_LimeGreen 3329330
mwCLR_Linen 15134970
mwCLR_Magenta 16711935
mwCLR_Maroon 128
mwCLR_MediumAquamarine 11193702
mwCLR_MediumBlue 13434880
mwCLR_MediumOrchid 13850042
mwCLR_MediumPurple 14381203
mwCLR_MediumSeaGreen 7451452

2404 NI AWR Design Environment


mwColor

Name Value
mwCLR_MediumSlateBlue 15624315
mwCLR_MediumSpringGreen 10156544
mwCLR_MediumTurquoise 13422920
mwCLR_MediumVioletRed 8721863
mwCLR_MidnightBlue 7346457
mwCLR_MintCream 16449525
mwCLR_MistyRose 14804223
mwCLR_Moccasin 11920639
mwCLR_NavajoWhite 11394815
mwCLR_Navy 8388608
mwCLR_OldLace 15136253
mwCLR_Olive 32896
mwCLR_OliveDrab 2330219
mwCLR_Orange 42495
mwCLR_OrangeRed 17919
mwCLR_Orchid 14053594
mwCLR_PaleGoldenrod 11200750
mwCLR_PaleGreen 10025880
mwCLR_PaleTurquoise 15658671
mwCLR_PaleVioletRed 9662683
mwCLR_PapayaWhip 14020607
mwCLR_PeachPuff 12180223
mwCLR_Peru 4163021
mwCLR_Pink 13353215
mwCLR_Plum 14524637
mwCLR_PowderBlue 15130800
mwCLR_Purple 8388736
mwCLR_Red 255
mwCLR_RosyBrown 9408444
mwCLR_RoyalBlue 14772545
mwCLR_SaddleBrown 1262987
mwCLR_Salmon 7504122
mwCLR_SandyBrown 6333684
mwCLR_SeaGreen 5737262
mwCLR_SeaShell 15660543
mwCLR_Sienna 2970272
mwCLR_Silver 12632256

API Scripting Guide 2405


mwGraphColorIndex

Name Value
mwCLR_SkyBlue 15453831
mwCLR_SlateBlue 13458026
mwCLR_SlateGray 9470064
mwCLR_Snow 16448255
mwCLR_SpringGreen 8388352
mwCLR_SteelBlue 11829830
mwCLR_Tan 9221330
mwCLR_Teal 8421376
mwCLR_Thistle 14204888
mwCLR_Tomato 4678655
mwCLR_Turquoise 13688896
mwCLR_Violet 15631086
mwCLR_Wheat 11788021
mwCLR_White 16777215
mwCLR_WhiteSmoke 16119285
mwCLR_Yellow 65535
mwCLR_YellowGreen 3329434

mwGraphColorIndex
Constants that define indexes for the graph color values for graph color options.

Name Value
mwGCI_Black 0
mwGCI_Red 1
mwGCI_Green 2
mwGCI_Blue 3
mwGCI_Magenta 4
mwGCI_Brown 5
mwGCI_Cyan 6
mwGCI_Yellow 7
mwGCI_Gray 8
mwGCI_LtGray 9

mwGraphLineStyleIndex
Constants that define indexes for the graph line style values for graph line style options.

2406 NI AWR Design Environment


mwGraphLineWeightIndex

Name Value
mwGLS_SolidLine 0
mwGLS_DashedLine 1
mwGLS_DottedLine 2
mwGLS_DotDashLine 3

mwGraphLineWeightIndex
Consants that define index for the graph line weight values for graph line weight options.

Name Value
mwGLW_1PixelWidth 0
mwGLW_2PixelWidth 1
mwGLW_3PixelWidth 2
mwGLW_4PixelWidth 3
mwGLW_5PixelWidth 4

mwGraphLegendStyleIndex
Constants that define index values pf legend styles for the legend text entries.

Name Value
mwGLE_DataName 0
mwGLE_MeasurementName 1
mwGLE_BothNames 2

mwGraphYieldRangeStyle
Constants that define different modes for dispalying range values for yield data.

Name Value
mwGYR_MinAndMax 0
mwGYR_Envelope 1
mwGYR_RangeBox 2

mwGraphYieldDisplayStyle
Constants that define different modes for displaying traces for yield data.

Name Value
mwGYD_AllTraces 0
mwGYD_Passed 1
mwGYD_Failed 2

API Scripting Guide 2407


mwLayoutViewDetails

Name Value
mwGYD_Mean 3

mwLayoutViewDetails
Constants that define different levels of layout viewing details.

Name Value
mwLVD_AllDetails 0
mwLVD_NormalDetails 1
mwLVD_LowDetails 2
mwLVD_VeryLowDetails 3

mwLayoutSelectMode
Constants that define different types of layout selection modes.

Name Value
mwLSM_AutoSelect 0
mwLSM_ManualSelect 1

mwLayoutRouteGravity
Constants that define different levels of layout route inference snap gravity.

Name Value
mwLRG_NoneGravity 0
mwLRG_WeakGravity 1
mwLRG_NormalGravity 2
mwLRG_StrongGravity 3

mwSysNoiseModeling
Constants that define different modes of system noise modeling.

Name Value
mwSNM_Noiseless 0
mwSNM_RFBudgetOnly 1
mwSNM_RFBudgetAndTimeDomain 2

mwLayoutSnapMode
Constants that define different types of layout snap modes.

2408 NI AWR Design Environment


mwInterpolationMethod

Name Value
mwLSM_Auto 0
mwLSM_Manual 1
mwLSM_Selected 2

mwInterpolationMethod
Constants that define different methods for value interpolation.

Name Value
mwIM_Linear 0
mwIM_RationalFunction 1
mwIM_SplineCurve 2

mwInterpolationCoords
Constants that define different interpolation coordinate system types.

Name Value
mwIC_Cartesian 0
mwIC_Polar 1

mwInstanceExportOptions
Constants that define different options for exporting instances from layout.

Name Value
mwIEO_NoChangesToCellNames 0
mwIEO_AppendNumberToDuplicates 1
mwIEO_AppendLibNameToDuplicates 2
mwIEO_AppendLibNameToAll 3

mwFaceInsetOptions
Constants that define different options for inserting layout cell faces.

Name Value
mwFIO_NoInset 0
mwFIO_InsetNonOrthogOneQtrDbUnit 1
mwFIO_InsetNonOrthogOneHalfDbUnit 2
mwFIO_InsetNonOrthogThreeQtrDbUnit 3
mwFIO_InsetNonOrthogOneDbUnit 4
mwFIO_InsetAllOneQtrDbUnit 5

API Scripting Guide 2409


mwPortFaceConnectTypes

Name Value
mwFIO_InsetAllOneHalfDbUnit 6
mwFIO_InsetAllThreeQtrDbUnit 7
mwFIO_InsetAllOneDbUnit 8

mwPortFaceConnectTypes
Constants that define different types of face connection options.

Name Value
mwCT_Unknown 0
mwCT_CapTopPlate 1
mwCT_CapBotPlate 2
mwCT_SpiralExit 3
mwCT_SpiralTurn 4
mwCT_ViaTop 5
mwCT_ViaBottom 6
mwCT_Resistor 7
mwCT_Resistor2 8
mwCT_Resistor3 9
mwCT_Disabled 10
mwCT_LineEnd 100
mwCT_LineEndN 199
mwCT_LineJunction 200
mwCT_LineJunctionN 299
mwCT_ArtworkLine 300
mwCT_ArtworkLineN 399
mwCT_PassThroughBase 399
mwCT_PassThrough 400
mwCT_PassThroughN 499

mwPathEndTypeOptions
Constants that define different options for path end types.

Name Value
mwPETO_ExtendedHalfWidth 0
mwPETO_FlushEnd 1
mwPETO_Rounded 2

2410 NI AWR Design Environment


mwPathMiterTypeOptions

mwPathMiterTypeOptions
Constants that define different options for path miter types.

Name Value
mwPMTO_Square 0
mwPMTO_Mitered 1
mwPMTO_OffsetMiter 2

mwRectangleAttributes
Constants that define different types of Rectangle attributes.

Name Value
mwRA_LayerIndex 0

mwPolygonAttributes
Constants that define different types of Polygon attributes.

Name Value
mwPOA_LayerIndex 0
mwPOA_Area 1

mwLayoutCellAttributes
Constants that define different types of Layout Cell attributes.

Name Value
mwLCA_LineTypeIndex 0
mwLCA_UsesProcessLayers 1
mwLCA_LayerMappingIndex 2
mwLCA_Anchor 3
mwLCA_Frozen 4
mwLCA_CellName 5
mwLCA_ElementName 6

mwLayoutShapeAttributes
Constants that define different types of Layout Shape attributes.

Name Value
mwLSA_LineTypeIndex 0
mwLSA_UsesProcessLayers 1

API Scripting Guide 2411


mwLayoutPinAttributes

Name Value
mwLSA_LayerMappingIndex 2
mwLSA_LayerIndex 3

mwLayoutPinAttributes
Constants that define different types of Layout Pin attributes.

Name Value
mwLPA_PortNumber 0
mwLPA_ConnectType 1
mwLPA_PinGroup 2
mwLPA_GroupType 3

mwLayoutRoutePathAttributes
Constants that define different types of Layout Route attributes.

Name Value
mwLRP_NetworkId 0
mwLRP_Associated 1

mwLayoutNetShapeAttributes
Constants that define different types of LayoutNetShape attributes.

Name Value
mwLNS_NetworkId 0
mwLNS_Associated 1

mwLayoutCellShapeAttributes
Constants that define the different types of LayoutCellShape attributes.

Name Value
mwLCS_CellName 0
mwLCS_IsArtwork 1

mwLayoutSubcircuitAttributes
Constanst that define the different types of LayoutSubcircuit attributes.

Name Value
mwLSA_MasterDocName 0

2412 NI AWR Design Environment


mwLayoutGroupAttributes

mwLayoutGroupAttributes
Constants that define the different types of Layout Group attributes.

Name Value
mwLGA_GroupChildCount 0

mwLayoutLayerAttributes
Constants that define the different types of LayoutLayer attributes.

Name Value
mwLLA_LayerName 0

mwLayoutMagnificationAttributes
Constants that define different types of layout magnification attributes.

Name Value
mwLMA_Magnification 0

mwLayout3DPlacementAttributes
Constants that define different types of layout 3D placement attributes.

Name Value
mwTDP_EmLayer 0
mwTDP_ZOffset 1
mwTDP_XAngle 2
mwTDP_YAngle 3

mwLayoutOrientationAttributes
Constants that define different types of layout orientation attributes.

Name Value
mwLOA_FixedPosition 0
mwLOA_FlipState 1
mwLOA_RotationAngle 2

mwLayoutCellStretcherAttributes
Constants that define different types of layout cell stretcher attributes.

API Scripting Guide 2413


mwLayoutDragLayoutObjectAttributes

Name Value
mwLCS_ParameterName 0
mwLCS_Multiplier 1
mwLCS_Offset 2
mwLCS_UpperLimit 3
mwLCS_LowerLimit 4
mwLCS_IsBound 5
mwLCS_Direction 6
mwLCS_ArrowHeight 7

mwLayoutDragLayoutObjectAttributes
Constants that define different types of layout drag object attributes.

Name Value
mwDLO_UseForAnchor 0
mwDLO_StretchToFix 1

mwLayoutFontAttributes
Constants that define different types of layout font attributes.

Name Value
mwLFA_FontName 0
mwLFA_BoldStyle 1
mwLFA_ItalicStyle 2
mwLFA_FontHeight 3

mwSchematicFontAttributes
Constants that define different types of schematic font attributes.

Name Value
mwSFA_FontName 0
mwSFA_BoldStyle 1
mwSFA_ItalicStyle 2
mwSFA_FontHeight 3

mwLayoutTextAttributes
Constants that define different types of layout text attributes.

2414 NI AWR Design Environment


mwLayoutDimensionLineAttributes

Name Value
mwLTA_DrawTextAsPoly 0
mwLTA_DrawTextArrow 1
mwLTA_ArrowPointX 2
mwLTA_ArrowPointY 3
mwLTA_TextString 4

mwLayoutDimensionLineAttributes
Constants that define different types of layout dimension line attributes.

Name Value
mwDLA_ArrowLocation 0
mwDLA_TextLocation 1
mwDLA_ArrowLength 2
mwDLA_GapLength 3
mwDLA_Precision 4
mwDLA_ShowUnits 5
mwDLA_ShowTolerance 6
mwDLA_LengthTolerance 7
mwDLA_Length 8

mwLayoutRulerAttributes
Constants that define different types of layout ruler attributes.

Name Value
mwLRA_RulerSpacing 0
mwLRA_GapLength 1
mwLRA_TickHeight 2
mwLRA_Precision 3
mwLRA_ShowUnits 4
mwLRA_MinorTickSpacing 5
mwLRA_MinorTickHeight 6
mwLRA_ShowMinorTicks 7
mwLRA_ShowLabels 8
mwLRA_Length 9

mwLayoutPolyAttributes
Constants that define different types of layout polygon attributes.

API Scripting Guide 2415


mwLayoutEllipseAttributes

Name Value
mwLP_Area 0

mwLayoutEllipseAttributes
Constants that define different types of layout ellipse attributes.

Name Value
mwLEA_Area 0
mwLEA_Width 1
mwLEA_Height 2
mwLEA_Eccentricity 3

mwLayoutPathAttributes
Constants that define different types of layout path attributes.

Name Value
mwLPA_PathWidth 0
mwLPA_PathEndType 1
mwLPA_MiterType 2
mwLPA_OffsetMiterAmount 3
mwLPA_BeginExt 4
mwLPA_EndExt 5
mwLPA_Length 6

mwLayoutPolylineAttributes
Constants that define different types of layout polyline attributes.

Name Value
mwLPLA_Length 0

mwLayoutArcAttributes
Constants that define different types of layout arc attributes.

Name Value
mwLAA_CenterX 0
mwLAA_CenterY 1
mwLAA_Radius 2
mwLAA_StartAngle 3
mwLAA_StopAngle 4

2416 NI AWR Design Environment


mwLayoutFaceAttributes

mwLayoutFaceAttributes
Constants that define different types of layout face attributes.

Name Value
mwFAT_FaceJustification 0
mwFAT_XOffset 1
mwFAT_YOffset 2
mwFAT_AngleOffset 3

mwLayoutDrillHoleAttributes
Constants that define different types of layout drill hole attributes.

Name Value
mwDHA_DrillHoleIndex 0

mwEmExtractAtrributes
Constants that define different types of layout EM extraction attributes.

Name Value
mwEEA_IsEMExtract 0
mwEEA_GroupName 1

mwEllipseAttributes
Constants that define different types of Ellipse attributes.

Name Value
mwEA_LayerIndex 0
mwEA_Area 1
mwEA_Width 2
mwEA_Height 3
mwEA_Eccentricity 4

mwArcAttributes
Constants that define different types of Arc attributes.

Name Value
mwAA_LayerIndex 0
mwAA_CenterX 1
mwAA_CenterY 2

API Scripting Guide 2417


mwPolylineAttributes

Name Value
mwAA_Radius 3
mwAA_StartAngle 4
mwAA_StopAngle 5
mwAA_Length 6

mwPolylineAttributes
Constants that defined different types of Polyline attributes.

Name Value
mwPLA_LayerIndex 0
mwPLA_Length 1

mwPathAttributes
Constants that define attributes of a shape path object.

Name Value
mwPA_LayerIndex 0
mwPA_PathWidth 1
mwPA_PathEndType 2
mwPA_MiterType 3
mwPA_OffsetMiterAmount 4
mwPA_BeginExt 5
mwPA_EndExt 6
mwPA_Length 7
mwPA_Area 8

mwArrayCellAttributes
Constants that define attributes of an array cell object.

Name Value
mwACA_IsArrayCell 0
mwACA_ArrayCellRows 1
mwACA_ArrayCellCols 2
mwACA_ArrayCellDx 3
mwACA_ArrayCellDy 4

mwCellStretcherAttributes
Constants that define different attribute types for cell stretcher shapes

2418 NI AWR Design Environment


mwSymbolTextAttributes

Name Value
mwCSA_StretchType 0
mwCSA_ParameterName 1
mwCSA_Multipler 2
mwCSA_Offset 3
mwCSA_UpperLimit 4
mwCSA_LowerLimit 5
mwCSA_ArrowHeight 6
mwCSA_IsBound 7
mwCSA_Region 8

mwSymbolTextAttributes
Constants that define different types of symbol text attributes.

Name Value
mwSTA_Height 1
mwSTA_Width 2
mwSTA_Rotation 3
mwSTA_Text 4
mwSTA_Font 5

mwSymbolPathAttributes
Constants that define different types of symbol path attributes.

Name Value
mwSPA_Width 1
mwSPA_MiterType 2
mwSPA_MiterOffset 3
mwSPA_endType 4
mwSPA_bOffset 5
mwSPA_eOffset 6

mwLayoutConnectionLineTypes
Constants that define different types of layout connection line drawing.

Name Value
mwLCL_StaightLines 0
mwLCL_CenterPointLines 1
mwLCL_MinimumSpanningLines 2

API Scripting Guide 2419


mwSpiceExtractionModelLevel

mwSpiceExtractionModelLevel
Constants that define different spice model extraction levels

Name Value
mwSML_Simplest 0
mwSML_1stOrder 1
mwSML_2ndOrder 2
mwSML_Distributed 3
mwSML_MostAccurate 4

mwINetModelingLevel
Constants that define different iNet modeling accuracy levels

Name Value
mwNML_ShortCircuits 0
mwNML_RCLumped 1
mwNML_RLCLumped 2
mwNML_Distrubuted 3
mwNML_EmExtraction 4

mwModelCompatibilityVersion
Constants that define different model compatibility version levels

Name Value
mwMCV_Version553 553
mwMCV_Version600 600
mwMCV_Version650 650
mwMCV_Version750 750
mwMCV_Version800 800
mwMCV_Version900 900

mwRouteObstructionLevel
Constants that define different routing obstruction avoidance levels

Name Value
mwROL_IgnoreObstructions 0
mwROL_IgnoreExistingNets 1
mwROL_AvoidObjstructions 2

2420 NI AWR Design Environment


mwModelExtractType

mwModelExtractType
Constants that define different model options for an element.

Name Value
mwMET_CircuitBasedModel 0
mwMET_EMExtractedModel 1

mwDrawingTextAttributes
Constants that define different types of drawing text attributes.

Name Value
mwDTA_Height 1
mwDTA_Text 2
mwDTA_Font 3
mwDTA_Bold 4
mwDTA_Italic 5

mwDefaultFaceAlignType
Constants that define different types of default face alignments.

Name Value
mwDFA_Center 0
mwDFA_Variable 1

mwApplicationAttributeType
Constants that define different types of application attribute types

Name Value
mwAAT_IniFilePath 1
mwAAT_EnvIniFilePath 2
mwAAT_ClientDirectory 3
mwAAT_BuildNumber 4
mwAAT_AppVersion 5
mwAAT_AppVersionShort 6
mwAAT_AppStreamVersion 7
mwAAT_AppName 8
mwAAT_AppNameDetailed 9
mwAAT_FoundryProcName 10
mwAAT_TestMode 11

API Scripting Guide 2421


mwApplicationDirectoryType

Name Value
mwAAT_RegressionCaptureMode 12
mwAAT_ProcessID 13
mwAAT_BuildRevision 14
mwAAT_AppProgId 15
mwAAT_AppAttributeCount 16

mwApplicationDirectoryType
Constants that define different types of application directories.

Name Value
mwADT_AppDir 0
mwADT_AppData 1
mwADT_AppDataUser 2
mwADT_AppDataCommon 3
mwADT_TempFile 4
mwADT_AppDataLogs 5
mwADT_AppDataLibraryCache 6
mwADT_Examples 7
mwADT_Libraries 8
mwADT_EmModels 9
mwADT_Models 10
mwADT_Cells 11
mwADT_Symbols 12
mwADT_Signals 13
mwADT_Textures 14
mwADT_Data 15
mwADT_HSpice 16
mwADT_TestResults 17
mwADT_EmModelsUser 18
mwADT_Logs 19
mwADT_LibraryCache 20
mwADT_Analog 21
mwADT_Projects 22
mwADT_Scripts 23
mwADT_ScriptsUser 24
mwADT_CurrentProject 25
mwADT_Documents 26

2422 NI AWR Design Environment


mwApplicationFileType

Name Value
mwADT_DesignKits 27
mwADT_Measurements 28

mwApplicationFileType
Constants that define different types of application files.

Name Value
mwAFT_Temporary 0
mwAFT_CommonIni 1
mwAFT_UserIni 2
mwAFT_Customizations 3
mwAFT_DataCache 4
mwAFT_FlexLmLicense 5
mwAFT_Executable 6
mwAFT_EMSightCache 7
mwAFT_MWOfficeExe 8
mwAFT_Project 9
mwAFT_GlobalScript 10

mwLayoutCellExportOptions
Constants that define different types of layout cell export options

Name Value
mwLCE_ExportFlattenedOption 0
mwLCE_ExportAsInstancesOption 1
mwLCE_ExportSpecifiedAsInstances 2

mwObjectSelectFilters
Constants that define bits for specific object types for restricting selection

Name Value
mwOSF_None 0
mwOSF_Graphics 1
mwOSF_Equation 2
mwOSF_Text 4
mwOSF_CommonElement 8
mwOSF_Wire 16
mwOSF_Annotation 32

API Scripting Guide 2423


mwLayoutObjectSelectFilters

Name Value
mwOSF_iNet 64
mwOSF_MovableProbe 128
mwOSF_LayCell 256
mwOSF_SubCell 512
mwOSF_ParamFrame 1024
mwOSF_BySize 2048
mwOSF_CellPort 4096
mwOSF_AreaPin 8192
mwOSF_LayPort 16384
mwOSF_ByPositionFixed 32768
mwOSF_BySize2 65536
mwOSF_ArtworkCell 131072
mwOSF_EMPort 262144
mwOSF_EMSubCell 524288
mwOSF_LayModifier 1048576
mwOSF_PinObject 28672
mwOSF_InstObject 768

mwLayoutObjectSelectFilters
Constants that define bits for specific object types for restricting selection in layout

Name Value
mwLSF_None 0
mwLSF_Graphics 1
mwLSF_Text 4
mwLSF_iNet 64
mwLSF_LayCell 256
mwLSF_SubCell 512
mwLSF_CellPort 4096
mwLSF_AreaPin 8192
mwLSF_LayPort 16384
mwLSF_ArtworkCell 131072
mwLSF_EMPort 262144
mwLSF_LayModifier 1048576

mwModelPropertyFlags
Constants that define different bits for model flag types.

2424 NI AWR Design Environment


mwViewVisiual

Name Value
mwEF_Default 0
mwEF_HideName 1
mwEF_NamOnly 2
mwEF_HasNoiseModel 4
mwEF_IsDiodeModel 8
mwEF_IsBipolarModel 16
mwEF_Linear_or_NL 32
mwEF_ConnectToSim 64
mwEF_UseUniqueSim 128
mwEF_AggregateModel 256
mwEF_SpecSampleRate 512
mwEF_IsSysSimModel 1024
mwEF_HideModel 2048
mwEF_UseSimInstId 4096
mwEF_DC_Source 8192
mwEF_MultiBranch 16384
mwEF_NoAddIdInName 32768
mwEF_ExtractBlock 65536
mwEF_DynamicModel 131072
mwEF_IsDynamicRecord 262144
mwEF_ExtractedElement 524288
mwEF_IncludeInTopOnly 1048576
mwEF_AllowDuplicates 2097152
mwEF_ExtractFromSelf 8

mwViewVisiual
Constants that define the different predefined visual modes in a 3D view.

Name Value
mwVV_WireFrame 1
mwVV_Shaded 2
mwVV_ShowEdges 4
mwVV_Texturing 8
mwVV_AntiAliased 16
mwVV_ExtrudedOnly 32
mwVV_ShapesMerged 64
mwVV_ShapesSelected 128

API Scripting Guide 2425


mwNetViaSizeOpts

Name Value
mwVV_Stippling 256

mwNetViaSizeOpts
Constants that define different types of iNet route to pin via size options.

Name Value
mwVSO_ViaCoversPinRouteIntersection 0
mwVSO_ViaConversEntirePin 1
mwVSO_ViaMinimalSize 2

mwDefRouteConnModelTypes
Constants that define different types of route-to-route connection models.

Name Value
mwDRCM_CenterlineModel 0
mwDRCM_CenterlineAndAdjacent 1

mwEMPortFlags
Constants that define flags which can be used in the EM port flags field.

Name Value
mwEMF_Default 0
mwEMF_EdgeToGround 1
mwEMF_ExtendUpward 2
mwEMF_ExtendAsMetal 4
mwEMF_ExtendUpDown 8
mwEMF_EndOfTypes 16

mwSmithGridAttributes
Constants that define the different types of attributes for a Smith Chart type Graph.

Name Value
mwSGA_None 0
mwSGA_SmithChartStyle 1
mwSGA_DefaultSweepRange 2
mwSGA_SweepDisplayMin 3
mwSGA_SweepDisplayMax 4
mwSGA_ImpedanceGridVisible 5

2426 NI AWR Design Environment


mwPolarGridAttributes

Name Value
mwSGA_AdmittanceGridVisible 6
mwSGA_ValuesVisible 7
mwSGA_AutoSize 8
mwSGA_ChartSize 9
mwSGA_AutoContour 10
mwSGA_ContourDensity 11
mwSGA_GraticuleColor 12
mwSGA_ImpedanceColor 13
mwSGA_AdmittanceColor 14
mwSGA_ImpedanceLineStyle 15
mwSGA_AdmittanceLineStyle 16
mwSGA_SweepMinimum 17
mwSGA_SweepMaximum 18

mwPolarGridAttributes
Constants that define the different types of attributes for a Polar Chart type Graph.

Name Value
mwPGA_None 0
mwPGA_PolarChartStyle 1
mwPGA_DefaultSweepRange 2
mwPGA_SweepDisplayMin 3
mwPGA_SweepDisplayMax 4
mwPGA_GraticuleColor 5
mwPGA_MajorDivisionsColor 6
mwPGA_MinorDivisionsColor 7
mwPGA_MagnitudeLineStyle 8
mwPGA_AngleLineStyle 9
mwPGA_MagniAutoDivisions 10
mwPGA_AngleAutoDivisions 11
mwPGA_MagnitudeLimit 12
mwPGA_MagnitudeDivisions 13
mwPGA_MagnitudeSubdivisions 14
mwPGA_MagnitudeMaximum 15
mwPGA_MagnitudeMinimum 16
mwPGA_AngleDivisions 17
mwPGA_AngleSubdivisions 18

API Scripting Guide 2427


mwRectGridAttributes

Name Value
mwPGA_ShowMagDivisions 19
mwPGA_ShowMagSubdivisions 20
mwPGA_ShowMagValues 21
mwPGA_ShowAngDivisions 22
mwPGA_ShowAngSubdivisions 23
mwPGA_ShowAngValues 24
mwPGA_SweepMinimum 25
mwPGA_SweepMaximum 26

mwRectGridAttributes
Constants that define the different types of attributes for a Rectangular Chart type Graph.

Name Value
mwRGA_None 0
mwRGA_RectChartType 1
mwRGA_GraticuleColor 2
mwRGA_MajorDivisionsColor 3
mwRGA_MinorDivisionsColor 4
mwRGA_XAxisLineStyle 5
mwRGA_LeftYAxisLineStyle 6
mwRGA_RightYAxisLineStyle 7
mwRGA_ShowTickMarks 8
mwRGA_TickMarkSize 9
mwRGA_UseDefaultXLabel 10
mwRGA_DefaultXLabel 11

mwPlot3DGridAttributes
Constants that define the different types of attributes for a 3D Plot type Graph.

Name Value
mwP3A_None 0
mwP3A_AxisGridColorX 1
mwP3A_AxisGridColorY 2
mwP3A_AxisGridColorZ 3
mwP3A_AxisLabelX 4
mwP3A_AxisLabelY 5
mwP3A_AxisLabelZ 6

2428 NI AWR Design Environment


mwPlot3DGridAttributes

Name Value
mwP3A_UseAutoDivisionsX 7
mwP3A_UseAutoDivisionsY 8
mwP3A_UseAutoDivisionsZ 9
mwP3A_ManualDivisionsX 10
mwP3A_ManualDivisionsY 11
mwP3A_ManualDivisionsZ 12
mwP3A_AutoDivisionsX 13
mwP3A_AutoDivisionsY 14
mwP3A_AutoDivisionsZ 15
mwP3A_ShowDivisionValuesX 16
mwP3A_ShowDivisionValuesY 17
mwP3A_ShowDivisionValuesZ 18
mwP3A_UseAutoRangeX 19
mwP3A_UseAutoRangeY 20
mwP3A_UseAutoRangeZ 21
mwP3A_ManualRangeMinX 22
mwP3A_ManualRangeMaxX 23
mwP3A_ManualRangeMinY 24
mwP3A_ManualRangeMaxY 25
mwP3A_ManualRangeMinZ 26
mwP3A_ManualRangeMaxZ 27
mwP3A_AutoRangeMinX 28
mwP3A_AutoRangeMaxX 29
mwP3A_AutoRangeMinY 30
mwP3A_AutoRangeMaxY 31
mwP3A_AutoRangeMinZ 32
mwP3A_AutoRangeMaxZ 33
mwP3A_EnableLighting 34
mwP3A_LightPositionX 35
mwP3A_LightPositionY 36
mwP3A_LightPositionZ 37
mwP3A_LightLevelAmbient 38
mwP3A_LightLevelDiffuse 39
mwP3A_LightLevelSpecular 40
mwP3A_LightMaterialAmbient 41
mwP3A_LightMaterialDiffuse 42
mwP3A_LightMaterialSpecular 43

API Scripting Guide 2429


mwTabularGridAttributes

Name Value
mwP3A_LightMaterialShininess 44
mwP3A_LightMaterialEmission 45
mwP3A_UseDefaultLabelX 46
mwP3A_ShowUnitsLabelX 47
mwP3A_UseDefaultLabelY 48
mwP3A_ShowUnitsLabelY 49

mwTabularGridAttributes
Constants that define the different types of attributes for a Tabular Grid type Graph.

Name Value
mwTGA_None 0
mwTGA_NumberFormat 1
mwTGA_DisplayFormat 2
mwTGA_DataPrecision 3
mwTGA_SweepPrecision 4

mwSimStateFlags
Constants that define flags for the different types of simulation dirty states.

Name Value
mwSSF_SimClean 0
mwSSF_SimStructureDirty 1
mwSSF_SimFrequencyDirty 2
mwSSF_ParameterDirty 8
mwSSF_NeedsUpdate 16

mwShowFileFlags
Constants that define flags for the options when displaying a file using the file util ShowFile.

Name Value
mwSFF_USEEXPLORER 16
mwSFF_AUTOUPDATE 32
mwSFF_FILEBUFFER 64

mwShapePreprocessorAttributes
Constants that define the different types of Preprocessor attributes.

2430 NI AWR Design Environment


mwBooleanEngineVersions

Name Value
mwSPA_PreprocessorRules 0

mwBooleanEngineVersions
Constanst that define the different types of boolean engines that can be used for shape processing in layout.

Name Value
mwBEV_BooleanLatest 0
mwBEV_BooleanPolyBool 1
mwBEV_BooleanBoost 2
mwBEV_BooleanClipper 3

mwBooleanCornerStyles
Constanst that define the different types of corner styles that can be used when resizing shapes with acute angles

Name Value
mwBCS_CornerRounded 0
mwBCS_CornerSharp 1

mwWindowState
Constants that define the different window states.

Name Value
mwWS_Maximized 1
mwWS_Minimized 2
mwWS_Normal 3

mwOptimizerSetting
Constants that define the different optimizer settings.

Name Value
mwOS_OptimizerSelected 100
mwOS_MaxIterations 101
mwOS_StopAtMin 102
mwOS_Property 103
mwOS_StopRequested 104
mwOS_ResultsSaved 105
mwOS_ResultsReverted 106
mwOS_ResultsCleared 107

API Scripting Guide 2431


mwStatisticalDist

Name Value
mwOS_ResetYield 108
mwOS_StopOnErr 109

mwStatisticalDist
Constants that define different types of statistical distributions.

Name Value
mwSD_Deterministic 0
mwSD_UniformDist 1
mwSD_NormalDist 2
mwSD_ModelDist 3
mwSD_LogNormal 4
mwSD_Discrete 5
mwSD_NormalMinusTol 6
mwSD_NormalClipped 7

mwVarPropMode
Constants that define different types of variable passing down hierarchy

Name Value
mwVPM_None 0
mwVPM_Weak 1
mwVPM_Strong 2

mwEquationVariableType
Constants that define different types of equation variables

Name Value
mwEVT_VariableDefinition 0
mwEVT_ParameterDefinition 1
mwEVT_DisplayValue 2

mwEquationDataType
Constants that define different types of data for equations

Name Value
mwEDT_Real 0
mwEDT_Complex 1

2432 NI AWR Design Environment


mwUnitType

Name Value
mwEDT_Integer 2
mwEDT_String 3
mwEDT_ElementName 4
mwEDT_DataModel 5
mwEDT_InfoString 6
mwEDT_None 7
mwEDT_Enumeration 8
mwEDT_RealVector 9
mwEDT_FileName 10
mwEDT_ComplexVector 11

mwUnitType
Constants that define different types of units.

Name Value
mwUT_None 0
mwUT_Frequency 1
mwUT_Capacitance 2
mwUT_Inductance 3
mwUT_Resistance 4
mwUT_Conductance 5
mwUT_Length 6
mwUT_LengthEnglish 7
mwUT_Temperature 8
mwUT_Angle 9
mwUT_Time 10
mwUT_Voltage 11
mwUT_Current 12
mwUT_PowerLog 13
mwUT_Power 14
mwUT_DB 15
mwUT_String 16
mwUT_Scaler 17
mwUT_DBOnlyPower 18
mwUT_WattsOnlyPower 19
mwUT_TextOnly 20

API Scripting Guide 2433


mwParameterStyle

mwParameterStyle
Constants that define different types of parameter styles.

Name Value
mwPS_Hide 0
mwPS_HideUnits 1
mwPS_HideEmpty 2
mwPS_HideVarName 3
mwPS_LeftJustify 4
mwPS_BoldFont 5
mwPS_HideIfSecondary 6

mwParameterStyleSetting
Constants that define different types of parameter style settings.

Name Value
mwPSS_SetStyle 0
mwPSS_ClearStyle 1
mwPSS_UseDefaultStyle 2

mwParamDefDataType
Constants that define the data types of a ParameterDefinition.

Name Value
mwPDDT_Real 0
mwPDDT_Complex 1
mwPDDT_Integer 2
mwPDDT_String 3
mwPDDT_ElementName 4
mwPDDT_DataModel 5
mwPDDT_InfoString 6
mwPDDT_None 7
mwPDDT_Enumeration 8
mwPDDT_RealVector 9
mwPDDT_FileName 10

mwParameterDefinitionFlagType
Constants that define different types of parameter default flags for parameter definitions.

2434 NI AWR Design Environment


mwNodeType

Name Value
mwPDF_Default 0
mwPDF_Hide 1
mwPDF_HideIfEmpty 2
mwPDF_HideUnits 3
mwPDF_LJustify 4
mwPDF_ReadOnly 5
mwPDF_EmptyStringOk 6
mwPDF_HideVarName 7
mwPDF_BoldFont 8
mwPDF_Secondary 9
mwPDF_IsPortNumber 10
mwPDF_UniqueVectLength 11
mwPDF_NonStructural 12
mwPDF_Structural 13
mwPDF_ReadDataTable 14
mwPDF_ParDefIsCopy 15
mwPDF_ConnectToSim 16
mwPDF_ChangeStructural 17
mwPDF_DynamicModParam 18
mwPDF_StreamParDef 19
mwPDF_ChangeNotDirty 20
mwPDF_NoAffectLayout 21
mwPDF_NoTune 22
mwPDF_Synthesized 23
mwPDF_Binned 24
mwPDF_ChangeConnectivity 25
mwPDF_NoDocNameSync 26
mwPDF_LayCell_EleParam 27

mwNodeType
Constants that define different types of element nodes.

Name Value
mwNT_Electrical 0
mwNT_Input 1
mwNT_Output 2
mwNT_BiDirectional 3

API Scripting Guide 2435


mwNodeDataType

mwNodeDataType
Constants that define different types of node data types.

Name Value
mwNDT_Unset 0
mwNDT_Real 1
mwNDT_Digital 2
mwNDT_Complex 3
mwNDT_FixedPoint 4

mwNodeFlags
Constants that define different types of node flags.

Name Value
mwNF_Default 0
mwNF_Secondary 1
mwNF_BlockBuffer 2
mwNF_ModSignal 4
mwNF_NoDigital 8
mwNF_DispLabel 16
mwNF_RFSignal 32
mwNF_AllowDataTypeChange 64
mwNF_RW_BiDirection 128

mwDisplayModeType
Constants that define the different types of drawing object display modes.

Name Value
mwDMT_Highlighted 1
mwDMT_BuddySelected 2
mwDMT_BuddyUnselected 4
mwDMT_ObjectMarked 8
mwDMT_ObjectCondemned 16

mwPropertyDataType
Constants that define different data types of property objects.

Name Value
mwPDT_Boolean 0

2436 NI AWR Design Environment


mwShapeType

Name Value
mwPDT_Byte 1
mwPDT_Integer 2
mwPDT_Long 3
mwPDT_Single 4
mwPDT_Double 5
mwPDT_Text 6
mwPDT_Date 7

mwShapeType
Constants that define different types of shapes.

Name Value
mwST_Rectangle 0
mwST_Polygon 1
mwST_Path 2
mwST_Ellipse 3
mwST_Text 4
mwST_DrillHole 5
mwST_Port 6
mwST_CellStretcher 7
mwST_Arc 8
mwST_Pin 9
mwST_Polyline 10

mwFillStyle
Constants that define different fill style types.

Name Value
mwFS_None 0
mwFS_Solid 1
mwFS_FineCross 2
mwFS_FineDiagonalCross 3
mwFS_InverseCross 4
mwFS_Checkered 5
mwFS_GridPoint 6
mwFS_InverseFineCross 7
mwFS_FineBackwardDiagonal 8

API Scripting Guide 2437


mwLineStyle

Name Value
mwFS_FineForwardDiagonal 9
mwFS_FineHorizontal 10
mwFS_HeavyHorizontal 11
mwFS_FineVertical 12
mwFS_HeavyVertical 13
mwFS_MediumHorizontal 14
mwFS_MediumVertical 15
mwFS_CoarseGridPoint 16
mwFS_Brick 17
mwFS_DotCross 18
mwFS_LaceRows 19
mwFS_ForwardDiagonal 20
mwFS_BackwardDiagonal 21
mwFS_Horizontal 22
mwFS_Vertical 23
mwFS_Cross 24
mwFS_DiagonalCross 25

mwLineStyle
Constants that define different line style types.

Name Value
mwLS_Solid 0
mwLS_Dash 1
mwLS_Dot 2
mwLS_DashDot 3
mwLS_DashDotDot 4

mwShapeSubObjectType
Constants that define different types fo shape sub-objects.

Name Value
mwSSO_CutoutPolygon 0
mwSSO_CutoutCircle 1
mwSSO_CutoutEllipse 2

2438 NI AWR Design Environment


mwShapeArcDirection

mwShapeArcDirection
Constants that define different arc segment directions.

Name Value
mwSAD_CounterClockwise 0
mwSAD_Clockwise 1

mwPathEndType
Constants that define different types of path ends.

Name Value
mwPET_Various 0
mwPET_ExtendedHalfWidth 1
mwPET_Flush 2
mwPET_Rounded 3
mwPET_ExtendedUserDefined 4

mwPathMiterType
Constants that define different types of path miters.

Name Value
mwPMT_Various 0
mwPMT_Square 1
mwPMT_Mitered 2
mwPMT_OffsetMitered 3
mwPMT_Curved 4
mwPMT_Rounded 5

mwTextAlignment
Constants that define different types of Text alignment.

Name Value
mwTAl_TopLeft 1
mwTAl_TopCenter 2
mwTAl_TopRight 3
mwTAl_CenterLeft 4
mwTAl_CenterCenter 5
mwTAl_CenterRight 6
mwTAl_BottomLeft 7

API Scripting Guide 2439


mwFaceAlignment

Name Value
mwTAl_BottomCenter 8
mwTAl_BottomRight 9

mwFaceAlignment
Constants that define different types of face alignments.

Name Value
mwFA_Left 0
mwFA_Center 1
mwFA_Right 2
mwFA_OffsetFix 3
mwFA_OffsetVar 4
mwFA_Adapt 5

mwFaceMultiLayerProperty
Constants that define different types of face multi-layer drawing properties.

Name Value
mwFLP_Default 0
mwFLP_Flush 1
mwFLP_Inside 2
mwFLP_Outside 3
mwFLP_Bridge1 4
mwFLP_Bridge2 5
mwFLP_Bridge3 6
mwFLP_Bridge4 7

mwFaceShapeType
Constants that define different types of face shapes, segment for faces and area for pins

Name Value
mwFST_SegmentFaceType 0
mwFST_AreaFaceType 1

mwFaceGroupType
Constants that define different types of face groups

2440 NI AWR Design Environment


mwWindowType

Name Value
mwFGT_StrongPinGroup 0
mwFGT_WeakPinGroup 1
mwFGT_MustConnectPinGroup 2

mwWindowType
Constants that define the different window types.

Name Value
mwWT_Unknown 0
mwWT_Datafile 1
mwWT_DesignNotes 2
mwWT_EmStructure 3
mwWT_EmStructure3D 4
mwWT_Graph 5
mwWT_NetList 6
mwWT_GlobalEquation 7
mwWT_OutputEquation 8
mwWT_Schematic 9
mwWT_SchematicLayout 10
mwWT_Schematic3DLayout 11
mwWT_SystemDiagram 12
mwWT_SystemDiagramLayout 13
mwWT_SystemDiagram3DLayout 14
mwWT_Optimizer 15
mwWT_LayoutCell 16
mwWT_EmLayoutStructure 17
mwWT_EmLayoutStructure3D 18
mwWT_EmLayoutStructureSchematic 19
mwWT_EmLayoutG3DStructure 20

mwWindowTileDirection
Cosntants that define the different window tile directions.

Name Value
mwWTD_Horizontal 0
mwWTD_Vertical 1

API Scripting Guide 2441


mwDimensionTextLocation

mwDimensionTextLocation
Constants that define different types of text locations for dimension line objects.

Name Value
mwDTL_CenterPar 0
mwDTL_CenterPer 1
mwDTL_RightPar 2
mwDTL_LeftPar 3

mwDimensionArrowLocation
Constants that define different types of arrow locations for dimension line objects.

Name Value
mwDAL_Inside 0
mwDAL_Outside 1

mwLayoutRulerTickLocation
Constants that define different types of layout ruler tick mark locations.

Name Value
mwLRT_AboveRuler -1
mwLRT_BelowRuler 1

mwRouteObjectType
Constants that define different types of route object types

Name Value
mwROT_PathRouteObject 0
mwROT_ViaRouteObject 1
mwROT_GuideRouteObject 2

mwRouteSegmentEndStyleType
Constants that define different route segment end style types

Name Value
mwEST_TruncateEndStyle 0
mwEST_ExtendedEndStyle 1
mwEST_VariableEndStyle 2
mwEST_ChamferEndStyle 3

2442 NI AWR Design Environment


mwRouteViaDirectionType

Name Value
mwEST_CustomEndStyle 4
mwEST_RoundedEndStyle 5

mwRouteViaDirectionType
Constants that define different route via direction types

Name Value
mwVDT_Layer1ToLayer2ViaDirection 0
mwVDT_Layer2ToLayer1ViaDirection 1

mwRouteSegmentEndOffsetType
Constants that define different route segment end offset style types.

Name Value
mwEOS_NormalEndOffsetType 0
mwEOS_FlushEndOffsetType 1
mwEOS_ExtendedEndOffsetType 2

mwDrawingArcDirection
Constants that define different arc segment directions.

Name Value
mwDAD_CounterClockwise 0
mwDAD_Clockwise 1

mwShapeNetType
Constants that define different types of networks for layout shape objects.

Name Value
mwSNT_Normal 0

mwObjectIncludeType
Constants that define the types of objects to be included in an operation.

Name Value
mwOIT_SelectedObjects 0
mwOIT_AllObjects 1

API Scripting Guide 2443


mwDesignRuleType

mwDesignRuleType
Constants that define different types of design rule types

Name Value
mwDRT_Width 0
mwDRT_Notch 1
mwDRT_Jog 2
mwDRT_Seperation 3
mwDRT_Extension 4
mwDRT_Overlap 5
mwDRT_ExtensionInv 6
mwDRT_PolygonArea 7
mwDRT_Angle 8
mwDRT_NoHole 9
mwDRT_MustHaveHole 10
mwDRT_OnGrid 11
mwDRT_MaxVertices 12
mwDRT_MaxSideLength 13
mwDRT_ObjectError 14
mwDRT_MultiPolygon 15
mwDRT_Edge 16
mwDRT_Polygon 17
mwDRT_Notch_In 18
mwDRT_Notch_Out 19
mwDRT_Unknown 20

mwDesignRuleState
Constants that define different types of design rule states

Name Value
mwDRS_Error 0
mwDRS_FalseError 1
mwDRS_CheckedError 2

mwDesignRuleErrorFileFormat
Constants that define different types of DRC error file formats.

2444 NI AWR Design Environment


mwAreaAddType

Name Value
mwDREF_AWR 0
mwDREF_Calibre 1
mwDREF_Assura 2

mwAreaAddType
Constants that define different constraints for adding objects in an area

Name Value
mwAAT_ContainedObjects 0
mwAAT_OverlappedObjects 1

mwDesignViewType
Constants that defined different views on a design

Name Value
mwDVT_DesignView2D 0
mwDVT_DesignView3D 1

mwComponentTestResultType
Constants that define the different types of component test result types.

Name Value
mwDMT_TestRunResultData 0
mwDMT_TestRunPerformanceData 1

mwLayoutSnapType
Constants that define different types of layout snap types.

Name Value
mwLST_AllObjects 0
mwLST_SelectedOnly 1

mwLayoutWindowType
Constants that define the different layout window styles.

Name Value
mwLWT_Layout2D 0
mwLWT_Layout3D 1

API Scripting Guide 2445


mwRouteTopologyType

mwRouteTopologyType
Constants that define different route topologies

Name Value
mwRTT_NoneRouteTopology 0
mwRTT_StripeRouteTopology 1
mwRTT_StandardCellWireRouteTopology 2
mwRTT_IOWireRouteTopology 3
mwRTT_BlockWireRouteTopology 4
mwRTT_RingRouteTopology 5
mwRTT_PadRingRouteTopology 6
mwRTT_BlockRingRouteTopology 7
mwRTT_CoreWireRouteTopology 8

mwRouteStatusType
Constants that define different route status types

Name Value
mwRST_NormalRouteStatus 0
mwRST_FixedRouteStatus 1
mwRST_LockedRouteStatus 2

mwRouteBendStyleType
Constants that define different types of bend styles for route objects.

Name Value
mwBS_SquareBendStyle 0
mwBS_MiterBendStyle 1
mwBS_CurveBendStyle 2

mwNetViaMode
Constants that define different types of via modes.

Name Value
mwNVM_FullVias 0
mwNVM_MinimalVias 1
mwNVM_ManualVias 2
mwNVM_SemiAutoVias 3
mwNVM_Minimal2Vias 4

2446 NI AWR Design Environment


mwRouteConnModel

mwRouteConnModel
Constants that define different types of route-to-route connection models for a physical net.

Name Value
mwRCM_UseProjectDefault 0
mwRCM_CenterlineConnectionModel 1
mwRCM_CenterLineAndAdjacentModel 2

mwViewFrom
Constants that define the different predefined view from perspectives in a 3D view

Name Value
mwVF_Ortho 0
mwVF_Top 1
mwVF_Front 2
mwVF_Back 3
mwVF_Left 4
mwVF_Right 5
mwVF_Bottom 6
mwVF_None 7

mwViewAutoRotate
Constants that define the different modes for auto rotation within a 3D view.

Name Value
mwVAW_RotateNone 0
mwVAW_RotateNormal 1
mwVAW_RotateChangeSlope 2

mwLVSHighlightLoc
Constants that define where an LVS SchematicHighlight item should be highlighted.

Name Value
mwLVSHL_NoHighlighting 0
mwLVSHL_HighlightInSchematic 1
mwLVSHL_HighlightInLayout 2
mwLVSHL_HighlightInSchemAndLay 3

API Scripting Guide 2447


mwShapeModifierType

mwShapeModifierType
Constants that define the different types of shape modifiers.

Name Value
mwMD_ShapeModifier 0
mwMD_GlobalModifier 1

mwShapeModifierPriority
Constants that define the different types of modifier priority levels.

Name Value
mwSMP_NormalShape 1
mwSMP_FlattenShape 2
mwSMP_GlobalModifier 3
mwSMP_ShapeProcessor 4

mwEMPortType
Constants that define the different types of EM ports.

Name Value
mwEMP_None 1
mwEMP_Left 2
mwEMP_Bottom 3
mwEMP_Right 4
mwEMP_Top 5
mwEMP_CenterX 6
mwEMP_CenterY 7
mwEMP_Via 8
mwEMP_GapX 9
mwEMP_GapY 10
mwEMP_FullLine 11
mwEMP_HalfLine 12
mwEMP_Extract 13

mwEMGroupType
Constants that define the different types of EM port group types.

Name Value
mwEMG_None 0

2448 NI AWR Design Environment


mwEMShapePortType

Name Value
mwEMG_NoneOld 1
mwEMG_Series 2
mwEMG_Mutual 3
mwEMG_Coupled 4

mwEMShapePortType
Constants that define the different types of EM shape port types.

Name Value
mwSPT_EdgePort 1
mwSPT_InternalPort 2
mwSPT_ViaPort 3
mwSPT_ExtractPort 4

mwPlacementJustfication
Constants that define the different types of placement justification styles.

Name Value
mwPJ_BBoxCenter 0
mwPJ_BBoxUpperLeft 1
mwPJ_BBoxLowerLeft 2
mwPJ_BBoxUpperRight 3
mwPJ_BBoxLowerRight 4
mwPJ_SameOrigin 5

mwUnionShapesType
Constanst that define the different types of shape union types.

Name Value
mwUST_UnionOnExistingLayers 0
mwUST_UnionToDestinationLayer 1

mwIntersectShapesType
Constants that define the different types of shape intersection types.

Name Value
mwIST_IntersectOnExistingLayers 0
mwIST_IntersectToDestinationLayer 1

API Scripting Guide 2449


mwExclusiveOrShapesType

mwExclusiveOrShapesType
Constants that define the different types of shape exclusive or types.

Name Value
mwEST_ExclusiveOrOnExistingLayers 0
mwEST_ExclusiveOrOnDestinationLayer 1

mwCellExportFormat
Constants that define different types of cell export formats.

Name Value
mwCEF_GDSII 0
mwCEF_DXF 1

mwLayoutParamDataType
Constants that define the data types of a LayoutParameter.

Name Value
mwLPDT_Real 0
mwLPDT_Integer 1
mwLPDT_String 2
mwLPDT_RealVector 3
mwLPDT_IntVector 4

mwDrawingSubObjectType
Constants that define differnet types of drawing sub-objects.

Name Value
mwDSO_CutoutPolygon 0
mwDSO_CutoutCircle 1
mwDSO_CutoutEllipse 2

mwElementType
Constants that define different types of elements.

Name Value
mwET_Circuit 0
mwET_System 1

2450 NI AWR Design Environment


mwSubcktGroundType

mwSubcktGroundType
Constants that define different types of sub-circuit grounding.

Name Value
mwSG_Normal 0
mwSG_Explicit 1
mwSG_Balanced 2

mwModelParseType
Constants that define different types of model parse types.

Name Value
mwMPT_Unknown 0
mwMPT_AWRNet 1
mwMPT_AWRModel 2
mwMPT_LibraModel 3
mwMPT_MWHarmModel 4
mwMPT_HSPICE_trans 5
mwMPT_HSPICE_native 6
mwMPT_PSpice 7
mwMPT_Touchstone 8
mwMPT_MMICAD 9

mwSchematicExportFormat
Constants that define different types of schematic export formats.

Name Value
mwSEF_MWOSchematicFile 0

mwSchematicNetlistExportFormat
Constants that define different types of schematic netlist export formats.

Name Value
mwNEF_MWONetlistFile 0

mwDrawingShapeType
Constants that define different types of drawing shape objects.

API Scripting Guide 2451


mwDiagramLockLevel

Name Value
mwDST_Unknown 0
mwDST_Line 1
mwDST_Arc 2
mwDST_Polygon 3
mwDST_Polyline 4
mwDST_Text 5
mwDST_Ellipse 6
mwDST_Rectangle 7
mwDST_Arrow 8

mwDiagramLockLevel
Constants that define different types of lock levels for schematic and system diagrams

Name Value
mwDLL_Unlocked 0
mwDLL_LockedForEdit 1
mwDLL_LockedForViewing 2

mwEmbeddedDocType
Values that define different embedded document types.

Name Value
mwEDT_Unknown 0
mwEDT_Schematic 1
mwEDT_SchematicLayout 2
mwEDT_SchematicLayout3D 3
mwEDT_EMLayout 4
mwEDT_EMLayout3D 5
mwEDT_SystemDiagram 6
mwEDT_Graph 7

mwSystemExportFormat
Constants that define different types of system export formats.

Name Value
mwSYF_MWOSystemFile 0

2452 NI AWR Design Environment


mwHatchStyle

mwHatchStyle
Constants that define different types of Hatch fill styles.

Name Value
mwHS_None 0
mwHS_Solid 1
mwHS_Horizontal 2
mwHS_Vertical 3
mwHS_ForwardDiagonal 4
mwHS_BackwardDiagonal 5
mwHS_Cross 6
mwHS_DiagonalCross 7

mwBoundaryModelType
Constants that define different types of boundary models.

Name Value
mwBMT_PerfectConductor 0
mwBMT_SpecifiedMaterial 1
mwBMT_ApproximateOpen 2
mwBMT_InfiniteWaveguide 3
mwBMT_ReadConductor 4
mwBMT_Dielectric 5

mwEmSimulator
Constants that define the different types of electromagnetic simulators.

Name Value
mwEMS_AwrAxiem 0
mwEMS_AwrAxiem32 1
mwEMS_AwrAxiem64 2
mwEMS_AwrEmSight 3
mwEMS_AwrAnalyst 4
mwEMS_AwrAce 5
mwEMS_SonnetEm 6
mwEMS_ZelandIe3d 7
mwEMS_OeaNetan 8
mwEMS_CST 9

API Scripting Guide 2453


mwEMInputDataXMLType

Name Value
mwEMS_HFSSAsync 10
mwEMS_CSTAsync 11
mwEMS_SonnetAsync 12

mwEMInputDataXMLType
Constants that define the different types of XML Input Data formats.

Name Value
mwEIX_EMSocketDataFile 0
mwEIX_EMSocketSimplifiedDataFile 1

mwGraphType
Constants that define different types of graphs.

Name Value
mwGT_Polar 1
mwGT_SmithChart 2
mwGT_Rectangular 3
mwGT_Tabular 4
mwGT_Antenna 5
mwGT_Histogram 6
mwGT_ThreeDim 7
mwGT_Constellation 8

mwMeasDataType
Constants that define different measurement data types.

Name Value
mwMDT_UnKnown 0
mwMDT_ReflectionData 1
mwMDT_AdmittanceData 2
mwMDT_ImpedanceData 3
mwMDT_GainCircleData 4
mwMDT_NoiseData 5
mwMDT_StabilityData 6
mwMDT_CurveTraceData 7
mwMDT_SpectrumData 8
mwMDT_SourceMapData 9

2454 NI AWR Design Environment


mwThickness

Name Value
mwMDT_HistogramData 10
mwMDT_MultiTraceData 11
mwMDT_LoadPullContour 12
mwMDT_DiscreteTimeData 13

mwThickness
Constants that define the thickness of a line or trace.

Name Value
mwHairline 1
mwThin 2
mwMedium 3
mwThick 4
mwFat 5

mwScaleType
Constants that define the type of scale of an Axis object.

Name Value
mwScaleLinear 1
mwScaleLogarithmic 2

mwDashStyle
Constants that define the dash styles of a line.

Name Value
mwLineSolid 1
mwLineThick 2
mwLineThin 3
mwLineThickThin 4

mwTraceSymbols
Constants that define the different symbols for traces objects.

Name Value
mwSymbolTriangle 1
mwSymbolSquare 2
mwSymbolDiamond 3

API Scripting Guide 2455


mwPlotAxis

Name Value
mwSymbolRomanX 4
mwSymbolHorizontalBar 5
mwSymbolVerticalBar 6
mwSymbolForwardSlash 7
mwSymbolBackSlash 8
mwSymbolArrow 9
mwSymbolCircle 10
mwSymbolSmallX 11
mwSymbolCross 12

mwPlotAxis
Constants that define different axes for plotting.

Name Value
mwPA_Left 0
mwPA_Right 1

mwTraceStyle
Constants that define different styles for a graph trace object.

Name Value
mwTraceStyleAuto 1
mwTraceStyleLinear 2
mwTraceStyleScatter 3
mwTraceStyleSpectral 4
mwTraceStyleHistogram 5
mwTraceStyleDigital 6
mwTraceStyleSampled 7
mwTraceStyleVariationBars 8

mwTraceSteppedColorStyle
Constants that define different stepped color styles for a graph trace object.

Name Value
mwSteppedColorStyleNone 1
mwSteppedColorStyleStepped 2
mwSteppedColorStyleGradient 3
mwSteppedColorStyleGradientRed 4

2456 NI AWR Design Environment


mwMarkerSearchMode

Name Value
mwSteppedColorStyleGradientGreen 5
mwSteppedColorStyleGradientBlue 6
mwSteppedColorStyleShaded 7

mwMarkerSearchMode
Constants that define different search modes for markers.

Name Value
mwMST_Absolute 0
mwMST_Delta 1

mwMarkerSearchDirection
Constants that define different search directions for markers.

Name Value
mwMSD_SearchRight 0
mwMSD_SearchLeft 1

mwMarkerSearchVariable
Constants that define different search variable types for markers.

Name Value
mwMSV_X 0
mwMSV_Y 1

mwMarkerType
Constants that define different types of graph markers.

Name Value
mwMT_Normal 0
mwMT_Parameter 1
mwMT_DataSet 2
mwMT_AutoSearch 3
mwMT_Offset 4

mwMarkerAutoSearchMode
Constants that define different auto-search marker modes.

API Scripting Guide 2457


mwMarkerOffsetMode

Name Value
mwMAM_Max 0
mwMAM_Min 1
mwMAM_Peak 2
mwMAM_Valley 3
mwMAM_Value 4
mwMAM_XIndex 5

mwMarkerOffsetMode
Constants that define different offset marker modes.

Name Value
mwMOM_X 0
mwMOM_Y 1

mwMarkerSymbolType
Constants that define different types of marker symbols.

Name Value
mwMST_None 0
mwMST_TriangleUp 1
mwMST_Rectangle 2
mwMST_Diamond 3
mwMST_HourGlass 4
mwMST_LineHorizontal 5
mwMST_LineVertical 6
mwMST_LineUpDiagonal 7
mwMST_LineDownDiagonal 8
mwMST_TriangleDown 9
mwMST_Circle 10
mwMST_Cross 11
mwMST_Plus 12

mwGraphMarkerType
Constants that define different output data types for graph cursors and markers.

Name Value
mwGMT_ReflectionCoefficient 0
mwGMT_Impdedence 1

2458 NI AWR Design Environment


mwGraphMarkerFormat

Name Value
mwGMT_Admittance 2
mwGMT_Unknown 3

mwGraphMarkerFormat
Constants that define different output formats for graph cursors and markers.

Name Value
mwGMF_RealImaginary 0
mwGMF_MagnitudeAngle 1
mwGMF_DbMagnitudeAngle 2

mwPrecisionMode
Constants that define the different types of precision display modes.

Name Value
mwPM_Auto 1
mwPM_Manual 2

mwPrecisionStyle
Constants that define the different types of precision display styles.

Name Value
mwPS_FixedSigFigures 1
mwPS_FixedRightDecimal 2
mwPS_Scientific 3

mwLineMarkerType
Constants that define different types of LineMarker objects.

Name Value
mwLM_HorizontalLineMarker 1
mwLM_VerticalLineMarker 2

mwLineMarkerTrackType
Constants that define different types of LineMarker track types.

Name Value
mwLMT_XAxis 1
mwLMT_LeftYAxis 2

API Scripting Guide 2459


mwDataFileType

Name Value
mwLMT_RightYAxis 3

mwDataFileType
Constants that define different types of data files.

Name Value
mwDFT_SNP 0
mwDFT_RAW 1
mwDFT_IV 2
mwDFT_TXT 3
mwDFT_MDIF 4
mwDFT_GMDIF 5
mwDFT_DSCR 6
mwDFT_GMDIFD 7

mwCellLibraryType
Constants that define the different cell library types.

Name Value
mwCLT_GDSII 0
mwCLT_DXF 1
mwCLT_OA 2

mwOptGoalType
Constants that define different types of optimization goals.

Name Value
mwOGT_Equals 0
mwOGT_LessThan 1
mwOGT_GreaterThan 2

mwLayoutExportFormat
Constants that define different types of layout export formats.

Name Value
mwLEF_GDSII_Hierarchical 0
mwLEF_GDSII_Flat 1
mwLEF_DXF 2

2460 NI AWR Design Environment


mwViaSpacingType

Name Value
mwLEF_Gerber 3
mwLEF_DrillFile 4
mwLEF_Pads 5

mwViaSpacingType
Constants that define the different types of via spacings for via fill entries and via fence entries.

Name Value
mwVST_CenterToCenter 0
mwVST_EdgeToEdge 1

mwViaFillStaggerMode
Constants that define the different types of via stagger mode for via fill entries.

Name Value
mwVSM_StaggerNone 0
mwVSM_StaggerRows 1
mwVSM_StaggerColumns 2

mwViaAlignType
Constants that define the different types of via alignments for via fill entries.

Name Value
mwVAT_ConstantSpacing 0
mwVAT_ConstantClearance 1

mwNetlistType
Constants that define different types of netlists.

Name Value
mwNLT_AWR 0
mwNLT_SPICE 1
mwNLT_PSPICE 1
mwNLT_TSTONE 2
mwNLT_Touchstone 2
mwNLT_HSPICE 3
mwNLT_HSPICE_NATIVE 4
mwNLT_Native_HSPICE 4

API Scripting Guide 2461


mwYieldGoalType

Name Value
mwNLT_Native_APLAC 7
mwNLT_Spectre 8
mwNLT_HSPICE2 10

mwYieldGoalType
Constants that define different types of yield goals.

Name Value
mwYGT_LessThan 0
mwYGT_GreaterThan 1

mwSymbolShapeType
Constants that define different types of symbol shapes.

Name Value
mwSST_Line 0
mwSST_Arc 1
mwSST_Polygon 2
mwSST_Path 3
mwSST_Text 4
mwSST_Ellipse 5
mwSST_Node 6
mwSST_Polyline 7
mwSST_MetaText 8

mwSymbolType
Constants that define different types of symbol categories like project or system symbols

Name Value
mwST_SystemSymbolType 0
mwST_ProjectSymbolType 1

mwSymbolSelectMode
Constants that define different types of symbol select modes.

Name Value
mwSM_NormalSelect 0
mwSM_EdgeSelect 1

2462 NI AWR Design Environment


mwUnitMultType

mwUnitMultType
Constants that define different types of multipliers.

Name Value
mwUMT_f 0
mwUMT_p 1
mwUMT_n 2
mwUMT_u 3
mwUMT_m 4
mwUMT_c 5
mwUMT_none 6
mwUMT_k 7
mwUMT_Mega 8
mwUMT_Giga 9
mwUMT_Tera 10
mwUMT_mil 11
mwUMT_inch 12
mwUMT_feet 13
mwUMT_mile 14
mwUMT_DegC 15
mwUMT_DegK 16
mwUMT_DegF 17
mwUMT_Rad 18
mwUMT_Deg 19
mwUMT_dbm 20
mwUMT_dbw 21

mwErrorType
Constants that define different types of errors.

Name Value
mwET_None 0
mwET_Warning 1
mwET_Error 2
mwET_Fatal 3

mwEMInitType
Constants that define the different types of EMStructure initialization types.

API Scripting Guide 2463


mwModelPriorityType

Name Value
mwEMI_Stackup 0
mwEMI_LPF 1
mwEMI_Default 2

mwModelPriorityType
Constants that define different types of priorities for Model objects.

Name Value
mwMPT_UNINIT 0
mwMPT_ALL 1
mwMPT_WIRE 2
mwMPT_LINEAR 3
mwMPT_TUNEOPT 4
mwMPT_MEAS 5
mwMPT_NONLINEAR 6
mwMPT_SOURCE 7
mwMPT_IO 8
mwMPT_GROUND 9
mwMPT_ISOLATED 10
mwMPT_SINK 11

mwLibraryElementType
Constants that define the different types of library elements.

Name Value
mwLET_Unknown 0
mwLET_Model 1
mwLET_XML 2
mwLET_DataFile 3
mwLET_Subcircuit 4

mwDockBorder
Constants that define the locations that a window can be docked to.

Name Value
mwDB_Top 1
mwDB_Bottom 2
mwDB_Left 3

2464 NI AWR Design Environment


mwDockState

Name Value
mwDB_Right 4

mwDockState
Constants that define the different dockable states of a window.

Name Value
mwDS_Docked 1
mwDS_Floating 2
mwDS_Normal 3

mwStatusItemCategory
Constants that define the category of a status item.

Name Value
mwRIC_Error 0
mwRIC_Warning 1
mwRIC_Info 2

mwJobStatusType
Constants that define the different types of job status states for JobProcess objects.

Name Value
mwJS_Unknown 0
mwJS_Rejected 1
mwJS_Pending 2
mwJS_Scheduled 3
mwJS_Removed 4
mwJS_Running 5
mwJS_Suspended 6
mwJS_Canceling 7
mwJS_Ended 8
mwJS_Canceled 9
mwJS_Killed 10
mwJS_Crashed 11
mwJS_Failed 12
mwJS_Sending 13
mwJS_Receiving 14

API Scripting Guide 2465


mwShowFileType

mwShowFileType
Constants that define the different types of files that can be displayed by the file utility ShowFile.

Name Value
mwSFT_PlainText 0
mwSFT_RichText 1

mwPageSetupOrientation
Constants that define the different types of page orientations.

Name Value
mwPSO_Portrait 0
mwPSO_Landscape 1

mwPageSetupDetailLevel
Constants that define the diffeent levels of output detail.

Name Value
mwPSD_MaximumVisability 0
mwPSD_MinimumComplexity 1

mwPrintPaperSize
Constants that define the different sizes of paper for printing.

Name Value
mwPPS_Letter 0
mwPPS_LetterSmall 1
mwPPS_Tabloid 2
mwPPS_Ledger 3
mwPPS_Legal 4
mwPPS_Statement 5
mwPPS_Executive 6
mwPPS_A3 7
mwPPS_A4 8
mwPPS_A4_SMALL 9
mwPPS_A5 10
mwPPS_B4 11
mwPPS_B5 12
mwPPS_Folio 13

2466 NI AWR Design Environment


mwPrintPaperSize

Name Value
mwPPS_Quarto 14
mwPPS_10X14 15
mwPPS_11X17 16
mwPPS_Note 17
mwPPS_Env_9 18
mwPPS_Env_10 19
mwPPS_Env_11 20
mwPPS_Env_12 21
mwPPS_Env_14 22
mwPPS_CSheet 23
mwPPS_DSheet 24
mwPPS_ESheet 25
mwPPS_Env_DL 26
mwPPS_Env_C5 27
mwPPS_Env_C3 28
mwPPS_Env_C4 29
mwPPS_Env_C6 30
mwPPS_Env_C65 31
mwPPS_Env_B4 32
mwPPS_Env_B5 33
mwPPS_Env_B6 34
mwPPS_Env_Italy 35
mwPPS_Env_Monarch 36
mwPPS_Env_Personal 37
mwPPS_Fanfold_US 38
mwPPS_Fanfold_Std_German 39
mwPPS_Fanfold_Lgl_German 40
mwPPS_ISO_B4 41
mwPPS_Japanese_Postcard 42
mwPPS_9X11 43
mwPPS_10X11 44
mwPPS_15X11 45
mwPPS_Env_Invite 46
mwPPS_Letter_Extra 47
mwPPS_Legal_Extra 48
mwPPS_Tabloid_Extra 49
mwPPS_A4_Extra 50

API Scripting Guide 2467


mwPrintPaperSize

Name Value
mwPPS_Letter_Transverse 51
mwPPS_A4_Transverse 52
mwPPS_Letter_Extra_Transverse 53
mwPPS_A_Plus 54
mwPPS_B_Plus 55
mwPPS_Letter_Plus 56
mwPPS_A4_Plus 57
mwPPS_A5_Transverse 58
mwPPS_B5_Transverse 59
mwPPS_A3_Extra 60
mwPPS_A5_Extra 61
mwPPS_B5_Extra 62
mwPPS_A2 63
mwPPS_A3_Transverse 64
mwPPS_A3_Extra_Transverse 65
mwPPS_Dbl_Japanese_Postcard 66
mwPPS_A6 67
mwPPS_JEnv_KAKU2 68
mwPPS_JEnv_KAKU3 69
mwPPS_JEnv_CHOU3 70
mwPPS_JEnv_CHOU4 71
mwPPS_Letter_Rotated 72
mwPPS_A3_Rotated 73
mwPPS_A4_Rotated 74
mwPPS_A5_Rotated 75
mwPPS_B4_JIS_Rotated 76
mwPPS_B5_JIS_Rotated 77
mwPPS_Japanese_Postcard_Rotated 78
mwPPS_Dbl_Japanese_Postcard_Rotated 79
mwPPS_A6_Rotated 80
mwPPS_JEnv_KAKU2_Rotated 81
mwPPS_JEnv_KAKU3_Rotated 82
mwPPS_JEnv_CHOU3_Rotated 83
mwPPS_JEnv_CHOU4_Rotated 84
mwPPS_B6_JIS 85
mwPPS_B6_JIS_Rotated 86
mwPPS_12X11 87

2468 NI AWR Design Environment


mwPrintPaperSource

Name Value
mwPPS_JEnv_YOU4 88
mwPPS_JEnv_YOU4_Rotated 89
mwPPS_P16K 90
mwPPS_P32K 91
mwPPS_P32KBIG 92
mwPPS_PEnv_1 93
mwPPS_PEnv_2 94
mwPPS_PEnv_3 95
mwPPS_PEnv_4 96
mwPPS_PEnv_5 97
mwPPS_PEnv_6 98
mwPPS_PEnv_7 99
mwPPS_PEnv_8 100
mwPPS_PEnv_9 101
mwPPS_PEnv_10 102
mwPPS_P16K_Rotated 103
mwPPS_P32K_Rotated 104
mwPPS_P32KBig_Rotated 105
mwPPS_PEnv_1_Rotated 106
mwPPS_PEnv_2_Rotated 107
mwPPS_PEnv_3_Rotated 108
mwPPS_PEnv_4_Rotated 109
mwPPS_PEnv_5_Rotated 110
mwPPS_PEnv_6_Rotated 111
mwPPS_PEnv_7_Rotated 112
mwPPS_PEnv_8_Rotated 113
mwPPS_PEnv_9_Rotated 114
mwPPS_PEnv_10_Rotated 115

mwPrintPaperSource
Constants that define the different sources of paper for printing

Name Value
mwPSR_Upper 0
mwPSR_OnlyOne 1
mwPSR_Lower 2
mwPSR_Middle 3

API Scripting Guide 2469


mwSystemSimulatorState

Name Value
mwPSR_Manual 4
mwPSR_Evelope 5
mwPSR_EnvManual 6
mwPSR_Auto 7
mwPSR_Tractor 8
mwPSR_SmallFmt 9
mwPSR_LargeFmt 10
mwPSR_LargeCapacity 11
mwPSR_FormSource 12
mwPSR_User 13

mwSystemSimulatorState
Constants that define different types of simulator run states

Name Value
mwSSS_Stopped 0
mwSSS_Running 1
mwSSS_Paused 2
mwSSS_Starting 3

mwProjectVersionType
Constants that define different types of project version values.

Name Value
mwPV_Latest 1
mwPV_Previous 2
mwPV_VersionNumber 3

mwProjectItemType
Constants that define the different types of project items.

Name Value
mwPIT_Schematic 0
mwPIT_SystemDiagram 1
mwPIT_EMStructure 2
mwPIT_Netlist 3
mwPIT_DataFile 4
mwPIT_Graph 5

2470 NI AWR Design Environment


mwProjectTemplateType

Name Value
mwPIT_Annotation 6
mwPIT_Measurement 7
mwPIT_OptimizerGoal 8
mwPIT_YieldGoal 9
mwPIT_OutputFile 10
mwPIT_DesignNotes 11
mwPIT_GlobalDefinitions 12
mwPIT_OutputEquations 13
mwPIT_Wizard 14
mwPIT_WizardInstance 15
mwPIT_Other 16
mwPIT_SampleProjectItem 17
mwPIT_DataSetFolder 18
mwPIT_DataSet 19

mwProjectTemplateType
Constants that define different types of project template type values.

Name Value
mwPT_NormalTemplate 1

mwDataSetFlags
Constants that define flag types associated with data sets.

Name Value
mwDSF_Default 0
mwDSF_IsPartialDataSet 1
mwDSF_MeshOnly 2
mwDSF_NotFinalIter 4
mwDSF_PortOnly 8
mwDSF_IncludesGeometry 16
mwDSF_ForOptimization 32
mwDSF_IncludesG3DModel 64
mwDSF_KeepSweepValOrder 128
mwDSF_NoAutoLoadInProject 256
mwDSF_KeepWriteStreamOpen 512
mwDSF_IncompleteDataSet 1024

API Scripting Guide 2471


mwExternalEditorType

Name Value
mwDSF_KeepReadStreamOpen 2048
mwDSF_DocCleanOnOpen 4096
mwDSF_Pinned 8192
mwDSF_Updating 16384
mwDSF_DisableAutoDelete 32768
mwDSF_ForTuning 65536
mwDSF_ForYield 131072
mwDSF_ClockStringReset 262144
mwDSF_DistSimResult 524288
mwDSF_InMemoryDataSet 1048576

mwExternalEditorType
Constants that define the different types of external editors for EM3DStructure objects.

Name Value
mwEET_SpaceClaimEditor 1
mwEET_OrionEditor 2

mwEECmdShow
Constants that define the different types of external editor show states.

Name Value
mwEECS_Hide 0
mwEECS_Show 1

2472 NI AWR Design Environment


Index
A
API
COM automation, 11
NI AWRDE, 11
API examples, 11

C
Code modules, 18
COM automation API, 11

M
Modules
code, 18
object, 18

O
Object modules, 18

S
scripting, 11
Scripts
importing, 15
running, 16
SDE, 11

API Scripting Guide Index1


Index

Index2 NI AWR Design Environment

You might also like