0% found this document useful (0 votes)
2K views420 pages

HFSS Scripting

Tutorial on writing HFSS Script using VB Script.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views420 pages

HFSS Scripting

Tutorial on writing HFSS Script using VB Script.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 420

HFSS:

Scripting Guide

ANSYS, Inc.
Southpointe

November 2013
ANSYS Electromagnetics Suite 15.0

275 Technology Drive


Canonsburg, PA 15317
ansysinfo@ansys.com
http://www.ansys.com
(T) 724-746-3304
(F) 724-514-9494

ANSYS, Inc. is
certified to ISO
9001:2008.

Copyright and Trademark Information


2013 SAS IP, Inc. All rights reserved. Unauthorized use, distribution or duplication is prohibited.
ANSYS, HFSS, HFSS-IE, and Optimetrics and any and all ANSYS, Inc. brand, product, service and
feature names, logos and slogans are registered trademarks or trademarks of ANSYS, Inc. or its
subsidiaries in the United States or other countries. All other brand, product, service and feature
names or trademarks are the property of their respective owners.

Disclaimer Notice
THIS ANSYS SOFTWARE PRODUCT AND PROGRAM DOCUMENTATION INCLUDE TRADE SECRETS
AND ARE CONFIDENTIAL AND PROPRIETARY PRODUCTS OF ANSYS, INC., ITS SUBSIDIARIES, OR
LICENSORS. The software products and documentation are furnished by ANSYS, Inc., its
subsidiaries, or affiliates under a software license agreement that contains provisions concerning
non-disclosure, copying, length and nature of use, compliance with exporting laws, warranties,
disclaimers, limitations of liability, and remedies, and other provisions. The software products and
documentation may be used, disclosed, transferred, or copied only in accordance with the terms
and conditions of that software license agreement.
ANSYS, Inc. is certified to ISO 9001:2008.

U.S. Government Rights


For U.S. Government users, except as specifically granted by the ANSYS, Inc. software license
agreement, the use, duplication, or disclosure by the United States Government is subject to
restrictions stated in the ANSYS, Inc. software license agreement and FAR 12.212 (for non-DOD
licenses).

Third-Party Software
See the legal information in the product help files for the complete Legal Notice for ANSYS
proprietary software and third-party software. If you are unable to access the Legal Notice,
please contact ANSYS, Inc.
Published in the U.S.A.

Table of Contents

1. Introduction to VBScript
A Sample HFSS Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
VBScript Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
Declaring Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Array Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4

VBScript Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4


Operator Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . .
Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1-5
1-5
1-5
1-6

Controlling Program Execution . . . . . . . . . . . . . . . . . . . . . 1-6


Using If...Then...Else . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Using Select Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Using a For...Next Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7

Converting Between Data Types . . . . . . . . . . . . . . . . . . . .


Interacting with a Script . . . . . . . . . . . . . . . . . . . . . . . . . . .
Recommended VBScript References . . . . . . . . . . . . . . . .
Copyright and Trademark Notices . . . . . . . . . . . . . . . . . . .

1-7
1-7
1-8
1-9

2. HFSS and VBScript


Overview of HFSS Script Variables . . . . . . . . . . . . . . . . . . 2-2
Contents-1
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Recording a Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Stopping Script Recording . . . . . . . . . . . . . . . . . . . . . . . . .
Running a Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Pausing and Resuming a Script . . . . . . . . . . . . . . . . . . . .
Stopping a Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Modifying a Script for Easier Playback . . . . . . . . . . . . . . .
HFSS Scripting Conventions . . . . . . . . . . . . . . . . . . . . . . .

2-6
2-6
2-6
2-7
2-7
2-7
2-8

Syntax Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Script Command Conventions . . . . . . . . . . . . . . . . . . . . .
Named Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Setting Numerical Values . . . . . . . . . . . . . . . . . . . . . . . . .

2-8
2-8
2-9
2-10

Executing a Script from Within a Script . . . . . . . . . . . . . . . 2-11


Editing Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12

3. Ansoft Application Object Script Commands


GetAppDesktop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
GetDesiredRamMBLimit . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
GetHPCLicenseType . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
GetMaximumRamMBLimit . . . . . . . . . . . . . . . . . . . . . . . . 3-3
GetMPISpawnCmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
GetMPIVendor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
GetNumberOfProcessors . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
GetUseHPCForMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
SetDesiredRamMBLimit . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
SetHPCLicenseType . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
SetMaximumRamMBLimit . . . . . . . . . . . . . . . . . . . . . . . . 3-6
SetMPISpawnCmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
SetMPIVendor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
SetNumberOfProcessors . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
SetUseHPCForMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7

4. Desktop Object Script Commands


CloseAllWindows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
CloseProject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Contents-2
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

CloseProjectNoForce . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
EnableAutoSave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
GetActiveProject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
GetAutoSaveEnabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
GetDesigns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
GetDistributedAnalysisMachines . . . . . . . . . . . . . . . . . . . 4-6
GetName [Desktop] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6
GetLibraryDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6
GetProjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6
GetProjectDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
GetProjectList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
GetTempDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
GetVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
NewProject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
OpenMultipleProjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
OpenProject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
PauseScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
Print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
QuitApplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
RestoreWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
RunProgram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
RunScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
SetActiveProject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
SetActiveProjectByPath . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
SetLibraryDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
SetProjectDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
SetTempDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
Sleep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13

5. Project Object Script Commands


Close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
CopyDesign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
CutDesign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
Contents-3
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

DeleteDesign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
GetActiveDesign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
GetDesign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
GetName [Project] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
GetPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
GetTopDesignList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
InsertDesign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
Paste [Design] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
Redo [Project Level] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5
Save . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5
SaveAs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5
SetActiveDesign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
SimulateAll . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
Undo [Project] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6

6. Material Script Commands


AddMaterial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
DoesMaterialExist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
EditMaterial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
ExportMaterial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
RemoveMaterial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4

7. Property Script Commands


ChangeProperty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4

Additional Property Scripting Commands . . . . . . . . . . . . . 7-9


GetProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9
GetPropertyValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
GetArrayVariables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
GetVariables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10
GetVariableValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
SetPropertyValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
SetVariableValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12

Additional Property Scripting Example . . . . . . . . . . . . . . . 7-12


Example Use of Record Script and Edit Properties . . . . . 7-13
Contents-4
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

8. Dataset Script Commands


AddDataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
DeleteDataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
EditDataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
ImportDataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3

9. Design Object Script Commands


ApplyMeshOps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3
Analyze . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3
AnalyzeDistributed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-4
AssignDCThickness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-4
ConstructVariationString . . . . . . . . . . . . . . . . . . . . . . . . . 9-5
DeleteLinkedDataVariation . . . . . . . . . . . . . . . . . . . . . . . 9-6
ExportConvergence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6
ExportMeshStats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7
ExportProfile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7
GetEdit SourcesCount . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-8
GetModule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9
GetName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9
GetNominalVariation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9
GetSolutionType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-10
GetSolveInsideThreshold . . . . . . . . . . . . . . . . . . . . . . . . . 9-10
GetSourceContexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-10
GetVariationVariableValue . . . . . . . . . . . . . . . . . . . . . . . . 9-10
Redo [Design] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-11
RenameDesignInstance . . . . . . . . . . . . . . . . . . . . . . . . . . 9-11
SARSetup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-11
SetActiveEditor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-12
SetDesignSettings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-12
SetSolutionType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-13
SetSolveInsideThreshold . . . . . . . . . . . . . . . . . . . . . . . . . 9-13
SetSourceContexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14
Solve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14
Contents-5
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

RunToolkit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14
Undo [Design] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-16

10. Model Setup Script Commands


Assign Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2
DeleteArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3
EditArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-4

11. 3D Modeler Editor Script Commands


Draw Menu Commands . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2
CreateBondwire . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-3
CreateBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-4
CreateCircle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-5
CreateCone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-5
CreateCutplane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-6
CreateCylinder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-6
CreateEllipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-7
CreateEquationCurve . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-7
CreateEquationSurface . . . . . . . . . . . . . . . . . . . . . . . . . 11-8
CreateHelix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-9
CreatePoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10
CreatePolyline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10
CreateRectangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-12
CreateRegion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-13
CreateRegularPolyhedron . . . . . . . . . . . . . . . . . . . . . . . 11-15
CreateRegularPolygon . . . . . . . . . . . . . . . . . . . . . . . . . . 11-15
CreateSphere . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-16
CreateSpiral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-16
CreateTorus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-17
EditPolyline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-18
InsertPolylineSegment . . . . . . . . . . . . . . . . . . . . . . . . . . 11-18
SweepAlongPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-19
SweepAlongVector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-20
SweepAroundAxis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-21
Contents-6
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Edit Menu Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-21


Copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-21
DeletePolylinePoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-22
DuplicateAlongLine . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-22
DuplicateAroundAxis . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-23
DuplicateMirror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-24
Mirror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-25
Move . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-25
OffsetFaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-26
Paste [Model Editor] . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-26
Rotate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-26
Scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-27

Modeler Menu Commands . . . . . . . . . . . . . . . . . . . . . . . 11-27


AssignMaterial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-28
Chamfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-29
Connect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-29
CoverLines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-29
CoverSurfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-30
CreateEntityList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-30
CreateFaceCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-30
CreateObjectCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-32
CreateObjectFromEdges . . . . . . . . . . . . . . . . . . . . . . . . 11-34
CreateObjectFromFaces . . . . . . . . . . . . . . . . . . . . . . . . 11-35
CreateRelativeCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-36
DeleteLastOperation . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-36
DetachFaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-37
EditEntityList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-37
EditFaceCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-38
EditObjectCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-38
EditRelativeCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-40
Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-40
ExportModelImageToFile . . . . . . . . . . . . . . . . . . . . . . . . 11-41
Fillet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-42
Contents-7
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

GenerateHistory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-43
HealObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-43
Import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-45
ImportDXF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-46
ImportGDSII . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-47
Intersect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-49
MoveCStoEnd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-49
MoveFaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-50
ProjectSheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-51
PurgeHistory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-52
Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-52
SeparateBody . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-52
SetModelUnits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-53
SetWCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-53
ShowWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-54
Split . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-54
Subtract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-54
SweepFacesAlongNormal . . . . . . . . . . . . . . . . . . . . . . . 11-55
ThickenSheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-56
UncoverFaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-56
Unite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-57

Other oEditor Commands . . . . . . . . . . . . . . . . . . . . . . . . 11-57


ChangeProperty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-58
Delete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-59
GetBodyNamesByPosition . . . . . . . . . . . . . . . . . . . . . . . 11-59
GetEdgeByPosition . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-60
GetEdgeIDsFromFace . . . . . . . . . . . . . . . . . . . . . . . . . . 11-60
GetEdgeIDsFromObject . . . . . . . . . . . . . . . . . . . . . . . . . 11-61
GetFaceArea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-61
GetFaceCenter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-61
GetFaceByPosition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-61
GetFaceIDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-62
GetModelBoundingBox . . . . . . . . . . . . . . . . . . . . . . . . . 11-62
Contents-8
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

GetObjectsInGroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-63
GetObjectIdByName . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-63
GetObjectName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-63
GetObjectNameByFaceID . . . . . . . . . . . . . . . . . . . . . . . 11-64
GetMatchedObjectName . . . . . . . . . . . . . . . . . . . . . . . . 11-64
GetModelUnits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-64
GetNumObjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-65
GetSelections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-65
GetUserPosition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-65
GetVertexIDsFromEdge . . . . . . . . . . . . . . . . . . . . . . . . . 11-66
GetVertexIDsFromFace . . . . . . . . . . . . . . . . . . . . . . . . . 11-66
GetVertexIDsFromObject . . . . . . . . . . . . . . . . . . . . . . . . 11-67
PageSetup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-67
RenamePart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-67

12. Output Variable Script Commands


CreateOutputVariable . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2
DeleteOutputVariable . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2
EditOutputVariable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-3
GetOutputVariables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-4
GetOutputVariableValue . . . . . . . . . . . . . . . . . . . . . . . . 12-4

13. Reporter Editor Script Commands


AddCartesianXMarker . . . . . . . . . . . . . . . . . . . . . . . . . . 13-3
AddDeltaMarker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-3
AddMarker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4
AddNote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4
AddTraces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-5
ClearAllMarkers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-7
CopyTracesData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-7
CopyReportData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-8
CopyReportDefinitions . . . . . . . . . . . . . . . . . . . . . . . . . . 13-8
CopyTraceDefinitions . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-8
CreateReport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-9
Contents-9
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

CreateReportFromTemplate . . . . . . . . . . . . . . . . . . . . . 13-12
DeleteAllReports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-12
DeleteReports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-12
DeleteTraces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-13
ExportPlotImageToFile [Reporter] . . . . . . . . . . . . . . . . . 13-13
ExportToFile [Reporter] . . . . . . . . . . . . . . . . . . . . . . . . . 13-15
FFTOnReport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-15
GetAllReportNames . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-16
GetDisplayType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-17
ImportIntoReport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-18
PasteReports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-18
PasteTraces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-19
RenameReport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-19
RenameTrace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-19
UpdateAllReports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-20
UpdateReports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-20
UpdateTraces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-21
UpdateTracesContextandSweeps . . . . . . . . . . . . . . . . . 13-23

14. Boundary and Excitation Module Script Commands


General Commands Recognized by the Boundary/Excitations
Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-2
AutoIdentifyPorts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-3
AutoIdentifyTerminals . . . . . . . . . . . . . . . . . . . . . . . . . . 14-4
ChangeImpedanceMult . . . . . . . . . . . . . . . . . . . . . . . . . 14-4
DeleteAllBoundaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-4
DeleteAllExcitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-5
DeleteBoundaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-5
GetBoundaryAssignment . . . . . . . . . . . . . . . . . . . . . . . . 14-5
GetBoundaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-5
GetBoundariesOfType . . . . . . . . . . . . . . . . . . . . . . . . . . 14-6
GetDefaultBaseName . . . . . . . . . . . . . . . . . . . . . . . . . . 14-6
GetExcitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-6
Contents-10
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

GetExcitationsOfType . . . . . . . . . . . . . . . . . . . . . . . . . . 14-7
GetNumBoundaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-7
GetNumBoundariesOfType . . . . . . . . . . . . . . . . . . . . . . 14-7
GetNumExcitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-7
GetNumExcitationsOfType . . . . . . . . . . . . . . . . . . . . . . . 14-8
GetPortExcitationCounts . . . . . . . . . . . . . . . . . . . . . . . . 14-8
ReassignBoundary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-8
RenameBoundary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-9
ReprioritizeBoundaries . . . . . . . . . . . . . . . . . . . . . . . . . . 14-9
SetDefaultBaseName . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-9

Script Commands for Creating and Modifying


Boundaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-11
AssignCurent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-12
AssignFiniteCond . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-13
AssignFloquet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-14
AssignIERegion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-17
AssignImpedance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-17
AssignIncidentWave . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-18
AssignLayeredImp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-19
AssignLumpedPort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-21
AssignLumpedRLC . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-23
AssignMagneticBias . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-23
AssignMaster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-24
AssignPerfectE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-25
AssignPerfectH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-25
AssignRadiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-26
AssignScreeningImpedance . . . . . . . . . . . . . . . . . . . . . 14-27
AssignSlave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-30
AssignSymmetry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-31
AssignTerminal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-31
AssignVoltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-32
AssignWavePort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-32
EditCurrent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-35
Contents-11
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

EditDiffPairs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-35
EditFiniteCond . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-36
EditImpedance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-37
EditIncidentWave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-38
EditLayeredImpedance . . . . . . . . . . . . . . . . . . . . . . . . . 14-39
EditMaster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-39
EditPerfectE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-39
EditPerfectH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-39
EditLumpedPort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-40
EditLumpedRLC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-41
EditMagneticBias . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-41
EditRadiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-41
EditSlave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-42
EditSymmetry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-42
EditTerminal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-43
EditVoltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-43
EditWavePort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-43
SetTerminalReferenceImpedances . . . . . . . . . . . . . . . . 14-44
UnassignIERegions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-44

Script Commands for Creating and Modifying Boundaries


in HFSS-IE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-46
AssignAperature [HFSS-IE] . . . . . . . . . . . . . . . . . . . . . . 14-46
AssignFiniteCond [HFSS-IE] . . . . . . . . . . . . . . . . . . . . . 14-46
AssignImpedance [HFSS-IE] . . . . . . . . . . . . . . . . . . . . . 14-47
AssignInfiniteGroundPlane [HFSS-IE] . . . . . . . . . . . . . . 14-47
AssignLumpedPort [HFSS-IE] . . . . . . . . . . . . . . . . . . . . 14-48

Script Commands for Creating and Modifying PMLs . . . 14-49


CreatePML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-49
ModifyPMLGroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-51
PMLGroupCreated . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-51
PMLGroupModified . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-52
RecalculatePMLMaterials . . . . . . . . . . . . . . . . . . . . . . . 14-52

Contents-12
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

15. Mesh Operations Module Script Commands


General Commands Recognized by the Mesh
Operations Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-2
DeleteOp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-2
GetOperationNames . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-2
RenameOp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-2

Script Commands for Creating and Modifying Mesh


Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-4
AssignLengthOp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-4
AssignModelResolutionOp . . . . . . . . . . . . . . . . . . . . . . . 15-5
AssignSkinDepthOp . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-5
AssignTrueSurfOp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-6
EditLengthOp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-7
EditModelResolutionOp . . . . . . . . . . . . . . . . . . . . . . . . . 15-7
EditSkinDepthOp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-8
EditTrueSurfOp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-8

16. Analysis Setup Module Script Commands


DeleteDrivenSweep . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-2
DeleteSetups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-2
DeleteSweep [HFSS-IE] . . . . . . . . . . . . . . . . . . . . . . . . . 16-2
EditFrequencySweep . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-2
EditSetup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-3
EditSweep [HFSS-IE] . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-4
GetSetupCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-4
GetSetups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-5
GetSweepCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-5
GetSweeps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-5
InsertFrequencySweep . . . . . . . . . . . . . . . . . . . . . . . . . 16-6
InsertSetup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-8
InsertSetup [HFSS-IE] . . . . . . . . . . . . . . . . . . . . . . . . . . 16-12
InsertSetup [Transient] . . . . . . . . . . . . . . . . . . . . . . . . . . 16-13
InsertSweep [HFSS-IE] . . . . . . . . . . . . . . . . . . . . . . . . . 16-15
Contents-13
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

RenameDrivenSweep . . . . . . . . . . . . . . . . . . . . . . . . . . 16-18
RenameSetup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-18
RenameSweep [HFSS-IE] . . . . . . . . . . . . . . . . . . . . . . . 16-19
RevertAllToInitial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-19
RevertSetupToInitial . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-19

17. Optimetrics Module Script Commands


General Commands Recognized by the Optimetrics
Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-5
CopySetup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-5
DeleteSetups [Optimetrics] . . . . . . . . . . . . . . . . . . . . . . 17-5
DistributedAnalyzeSetup . . . . . . . . . . . . . . . . . . . . . . . . 17-6
ExportDXConfigFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-6
ExportOptimetricsProfile . . . . . . . . . . . . . . . . . . . . . . . . 17-6
ExportOptimetricsResult . . . . . . . . . . . . . . . . . . . . . . . . 17-7
ExportParametricResults . . . . . . . . . . . . . . . . . . . . . . . . 17-7
GetSetupNames [Optimetrics] . . . . . . . . . . . . . . . . . . . . 17-8
GetSetupNamesByType [Optimetrics] . . . . . . . . . . . . . . 17-8
ImportSetup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-9
RenameSetup [Optimetrics] . . . . . . . . . . . . . . . . . . . . . . 17-9
SolveSetup [Optimetrics] . . . . . . . . . . . . . . . . . . . . . . . . 17-10

Parametric Script Commands . . . . . . . . . . . . . . . . . . . . . 17-11


EditSetup [Parametric] . . . . . . . . . . . . . . . . . . . . . . . . . . 17-11
GenerateVariationData (Parametric) . . . . . . . . . . . . . . . 17-11
InsertSetup [Parametric] . . . . . . . . . . . . . . . . . . . . . . . . 17-11

Optimization Script Commands . . . . . . . . . . . . . . . . . . . . 17-15


EditSetup [Optimization] . . . . . . . . . . . . . . . . . . . . . . . . . 17-15
InsertSetup [Optimization] . . . . . . . . . . . . . . . . . . . . . . . 17-15

Sensitivity Script Commands . . . . . . . . . . . . . . . . . . . . . 17-19


EditSetup [Sensitivity] . . . . . . . . . . . . . . . . . . . . . . . . . . 17-19
InsertSetup [Sensitivity] . . . . . . . . . . . . . . . . . . . . . . . . . 17-19

Statistical Script Commands . . . . . . . . . . . . . . . . . . . . . . 17-21


EditSetup [Statistical] . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-21
InsertSetup [Statistical] . . . . . . . . . . . . . . . . . . . . . . . . . 17-23
Contents-14
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

18. Solutions Module Script Commands


DeleteImportData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-2
EditSources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-2
DeleteFullVariation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-5
DeleteSolutionVariation . . . . . . . . . . . . . . . . . . . . . . . . . 18-6
DeleteVariation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-7
ExportForSpice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-8
ExportEigenmodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-9
ExportForHSpice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-10
ExportNetworkData . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-11
ExportNMFData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-13
GetAdaptiveFreq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-14
GetISolutionVersionID . . . . . . . . . . . . . . . . . . . . . . . . . . 18-14
GetSolveRangeInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-14
GetValidISolutionList . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-15
HasFields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-15
HasMatrixData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-15
HasMesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-16
ImportSolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-16
ImportTable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-17
IsFieldAvailableAt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-18
ListMatchingVariations . . . . . . . . . . . . . . . . . . . . . . . . . . 18-19
ListValuesOfVariable . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-19
ListVariations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-20

19. Field Overlays Module Script Commands


CreateFieldPlot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-2
DeleteFieldPlot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-6
GetFieldPlotNames . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-6
ModifyFieldPlot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-7
RenameFieldPlot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-8
RenamePlotFolder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-9
SetFieldPlotSettings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-9
Contents-15
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

SetPlotFolderSettings . . . . . . . . . . . . . . . . . . . . . . . . . . 19-10

20. Fields Calculator Script Commands


AddNamedExpression . . . . . . . . . . . . . . . . . . . . . . . . . . 20-3
AddNamedExpr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-3
CalcOp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-3
CalculatorRead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-4
CalcStack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-4
CalculatorWrite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-5
ChangeGeomSettings . . . . . . . . . . . . . . . . . . . . . . . . . . 20-5
ClcEval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-5
ClcMaterial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-6
ClearAllNamedExpr . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-6
CopyNamedExprToStack . . . . . . . . . . . . . . . . . . . . . . . . 20-6
DeleteNamedExpr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-7
EnterComplex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-7
EnterComplexVector . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-7
EnterLine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-8
EnterPoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-8
EnterQty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-9
EnterScalar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-9
EnterScalarFunc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-9
EnterSurf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-10
EnterVector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-10
EnterVectorFunc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-10
EnterVol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-11
ExportOnGrid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-11
ExportToFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-12
GetTopEntryValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-13
LoadNamedExpressions . . . . . . . . . . . . . . . . . . . . . . . . 20-13
SaveNamedExpressions . . . . . . . . . . . . . . . . . . . . . . . . 20-14

21. Radiation Module Script Commands


General Commands Recognized by the Radiation
Contents-16
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21-2
DeleteFarFieldSetup . . . . . . . . . . . . . . . . . . . . . . . . . . . 21-2
DeleteNearFieldSetup . . . . . . . . . . . . . . . . . . . . . . . . . . 21-2
GetSetupNames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21-2
RenameSetup [Radiation] . . . . . . . . . . . . . . . . . . . . . . . 21-3

Script Commands for Creating and Modifying Radiation


Setups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21-4
EditFarFieldSphereSetup . . . . . . . . . . . . . . . . . . . . . . . . 21-4
EditNearFieldLineSetup . . . . . . . . . . . . . . . . . . . . . . . . . 21-4
EditNearFieldSphereSetup . . . . . . . . . . . . . . . . . . . . . . 21-5
InsertFarFieldSphereSetup . . . . . . . . . . . . . . . . . . . . . . 21-5
InsertNearFieldLineSetup . . . . . . . . . . . . . . . . . . . . . . . 21-6
InsertNearFieldSphereSetup . . . . . . . . . . . . . . . . . . . . . 21-7

Script Commands for Modifying Antenna Array Setups . 21-8


EditAntennaArraySetup . . . . . . . . . . . . . . . . . . . . . . . . . 21-8

Script Commands for Exporting Antenna Parameters


and Max Field Parameters . . . . . . . . . . . . . . . . . . . . . . . 21-12
ExportRadiationParametersToFile . . . . . . . . . . . . . . . . . 21-12

22. User Defined Solutions Commands


CreateUserDefinedSolution . . . . . . . . . . . . . . . . . . . . . . 22-2
DeleteUserDefinedSolutions . . . . . . . . . . . . . . . . . . . . . 22-4
EditUserDefinedSolution . . . . . . . . . . . . . . . . . . . . . . . . 22-4

23. NdExplorer Script Commands


NdExplorer Manager Script Commands . . . . . . . . . . . . . 23-1
ExportFullWaveSpice [NdExplorer] . . . . . . . . . . . . . . . . 23-1
ExportNetworkData [NdExplorer] . . . . . . . . . . . . . . . . . . 23-2
ExportNMFData [NdExplorer] . . . . . . . . . . . . . . . . . . . . 23-3

24. Example Scripts


Variable Helix Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24-2
HFSS Data Export Script . . . . . . . . . . . . . . . . . . . . . . . . . 24-6

Contents-17
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Contents-18
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to VBScript

HFSS uses the Microsoft Visual Basic Scripting Edition (VBScript) scripting
language to record macros. VBScript is based on the Microsoft Visual Basic
programming language.
Using scripts is a fast, effective way to accomplish tasks you want to repeat.
When you execute a script, the commands in the script are performed.
You can write a script using any text editor or you can record a script from
within the HFSS interface. After recording the script from within HFSS, you
can then modify it if necessary using a text editor.
Although HFSS records scripts in VBScript format, it can also execute scripts
in JavaScriptTM format. If you are running a script from a command prompt,
the script can be written in any language that provides the Microsoft COM
methods. The HFSS scripting documentation refers to VBScript format only.
This chapter provides an overview of key VBScript components. For more
details about VBScript, please see the Recommended VBScript References
section at the end of this chapter.

Introduction to VBScript 1-1


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

A Sample HFSS Script


Following is an example of an HFSS script. It includes comment lines, which are preceded by
either an apostrophe ( ) or the word REM, that offer explanations for each preceding line or
lines. VBScript keywords appear in bold font.
--------------------------------------------- Script Recorded by Ansoft HFSS Version 10.0
11:03 AM May 3, 2005
---------------------------------------------Dim oDesign
Dim oEditor
Dim oModule
REM Dim is used to declare variables. Dim means dimension. In VBScript you can use Dim,
REM Public, or Private to declare variables. As VBScript has no built-in data types (like
REM integer, string, etc.), all variables are treated as variants, which can store any type of
REM information. In this example, the three variables will be used as objects. When
REM recording scripts in HFSS, variants that will be used as objects always begin with o.
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
You can use Set to assign an object reference to a variable. A copy of the object is not
created for that variable. Here CreateObject is a function that takes a string as input
and returns an object. The object is assigned to the variable oAnsoftApp.
Set oDesktop = oAnsoftApp.GetAppDesktop()
GetAppDesktop is a function of oAnsoftApp. This function does not take an input and it
returns an object. The object is assigned to the variable oDesktop.
oDesktop.NewProject
In VBScript, a Sub procedure is a procedure that is called by name, can receive arguments,
and can perform a specific task with a group of statements. Here the Sub procedure
NewProject of the object oDesktop is called. This Sub does not take an input.
Set oProject = oDesktop.GetActiveProject
oProject.InsertDesign "Hfss", "HFSSDesign1", "DrivenModal", ""
1-2 Introduction to VBScript
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

In a Sub or Function procedure call, you can group the input parameters inside
parentheses or without parentheses. Here the four strings are the input parameters of
the Sub procedure InsertDesign of the object oProject.
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.CreateBox Array("NAME:BoxParameters", "XPosition:=", _
"0mm", "YPosition:=", "0mm", "ZPosition:=", "0mm", _
"XSize:=", "1.6mm", "YSize:=", "1.2mm", "ZSize:=", _
"0.8mm"), Array("NAME:Attributes", "Name:=", "Box1", "Flags:=", _
"", "Color:=", "(132 132 193)", "Transparency:=", _
0.400000005960464, "PartCoordinateSystem:=",

"Global", "MaterialName:=", "vacuum", "SolveInside:=", true)


oEditor.CreateBox is a Sub procedure that takes two array variables as input. The
first array is for the boxs geometric parameters and the second array is for the boxs
attributes. You can modify the italicized entries to create a different box. In VBScript,
Array is a function that returns a variant containing an array. The underscore
character ( _ ) here indicates that the statement continues to the next line. The
underscore character must be placed outside of string constants, or else VBScript will
recognize the character as part of the string constant rather than an indication that the
string continues on the next line. Following is an example of proper use of the underscore
character:
Msgbox("Please include units when creating variables " & _
"that require dimensions."
Following is an example of improper use of the underscore character:
Msgbox("Please include units when creating variables _
that require dimensions."
For additional HFSS script examples, see Chapter 20, Example Scripts.

VBScript Variables
A VBScript variable is a placeholder representing information that may change during the time
your script is running. Use a variable name in a script to view or modify its value.

Introduction to VBScript 1-3


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Declaring Variables
To declare variables explicitly in a script, use the Dim, Public, or Private statements. For
example:
Dim box_xsize
After declaring a variable, you can assign information to it. For example:
box_xsize = "3mm"

Array Variables
Create an array variable when you want to assign more than one related value to a single variable. An array variable contains a series of values. For example:
Dim Primitives(2)
All arrays in VBScript are zero-based, so the array above actually contains 3 elements. You assign
data to each of the arrays elements using an index into the array. Data can be assigned to the
elements of an array as follows:
Primitives(0) = "Box1"
Primitives(1) = "Cone1"
Primitives(2) = "Cylinder1"
Similarly, the data can be retrieved from any element using an index into a particular array element. For example:
one_prim = Primitives(1)
You can also use the Array function to assign an array of elements to a variable. For example:
Dim Primitives
Primitives = Array ("Box1", "cone1", "Cylinder1")
Note

When using the Array function, do not use parentheses on the variable when it is
declared. For example, use Dim myarray, not Dim myarray().

VBScript Operators
VBScript provides operators, which are grouped into these categories: arithmetic operators,
comparison operators, and logical operators.
Please see the online VBScript Users Guide for more details.

1-4 Introduction to VBScript


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Operator Precedence
When several operations occur in an expression, each part is evaluated and resolved in a predetermined order, called operator precedence. You can use parentheses to override the order of
precedence and force some parts of an expression to be evaluated before others. Operations
within parentheses are always performed before those outside the parentheses. Within parentheses, however, standard operator precedence is maintained.
When expressions contain operators from more than one category, arithmetic operators are
evaluated first, comparison operators are evaluated next, and logical operators are evaulated
last. Comparison operators all have equal precedence, that is, they are evaluated in the left-toright order in which they appear. Arithmetic and logical operators are evaluated in the following
order of precedence.

Arithmetic Operators
Following is a list of VBScripts arithmetic operators.
Symbol

Description

Exponentiation

Unary negation

Multiplication

Division

Integer division

Mod

Modulus arithmetic

Addition

Subtraction

&

String concatenation

Comparison Operators
Following is a list of VBScripts comparison operators.
Symbol
=

Description
Equality

<>

Inequality

<

Less than

>

Greater than
Introduction to VBScript 1-5
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<=

Less than or equal to

>=

Greater than or equal to

Is

Object equivalence

Logical Operators
Following is a list of VBScripts logical operators:
Symbol

Description

Not

Logical negation

And

Logical conjunction

Or

Logical disjunction

Xor

Logical exclusion

Eqv

Logical equivalence

Imp

Logical implication

Controlling Program Execution


You can use conditional statements to control the flow of a script. There are two types of conditional statements in VBScript:
If...Then...Else
Select Case

Using If...Then...Else
Following is an example that demonstrates the If...Then...Else conditional statement:
If obj = "Box1" Then
<statements to execute>
ElseIf obj = "Cylinder1" Then
<statements to execute>
Else
<statements to execute>
End If

Using Select Case


Following is an example that demonstrates the Select Case conditional statement:
1-6 Introduction to VBScript
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Select Case primitive_name


Case "Box1"
<statements to execute>
Case "Cylinder1"
<statements to execute>
Case Else
<statements to execute>
End Select

Using a For...Next Loop


The For...Next type of loop allows you to run a group of statements repeatedly. It uses a
counter to run statements a specified number of times. Following is an example that demonstrates the For...Next loop:
For variable = start To end
<statements to execute>
Next
You can exit early from a For...Next loop with the Exit For statement.

Converting Between Data Types


To convert data from one subtype to another, use the following VBScript functions:
CStr

Syntax: CStr(variablename).
Converts variablename to a string. For example, it can be used to
convert the number 2.5 to the string "2.5".

CBool

Syntax: CBool(variablename).
Converts variablename to a boolean. If variablename is 0 or "0",
CBool returns False. Otherwise it returns True.

CDbl

Syntax: CDbl(variablename).
Converts variablename to a double precision number. For example,
it can be used to convert the string "2.5" to the number 2.5.

CInt

Syntax: CInt(variablename).
Converts variablename to an integer.

Interacting with a Script


VBScript provides two functions that enable you to interact with a script while it is running:
the InputBox function and the MsgBox function.
Introduction to VBScript 1-7
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

The InputBox function displays a dialog box with an input field. The value that is typed into
the input field is returned. For example:
Dim users_string
users_string = InputBox ("text prompt", "title of the pop-up dialog _
box", "default text for the input box")
The last two arguments to the function are optional.
The MsgBox function shows a message and returns a number based on the button the user
presses. For example:
MsgBox ("message text")

Recommended VBScript References


Microsoft Corporation. VBScript Users Guide.
Available http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/
vbstutor.asp.
Childs, M., Lomax, P., and Petrusha, R. VBScript in a Nutshell: A Desktop Quick Reference.
May 2002. OReilly & Associates. ISBN: 1-56592-720-6.

1-8 Introduction to VBScript


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Copyright and Trademark Notices


The information contained in the HFSS Scripting online help is subject to change without notice.
Ansoft makes no warranty of any kind with regard to this material, including, but not limited to, the
implied warranties of merchantability and fitness for a particular purpose. Ansoft shall not be liable
for errors contained herein or for incidental or consequential damages in connection with the furnishing, performance, or use of this material.
This document contains proprietary information which is protected by copyright. All rights are
reserved.
ANSYS, Inc.
275 Technology Drive
Canonsburg, PA 15317
Tel: (+1) 724-746-3304
Fax: (+1) 724-514-9494
General Information: AnsoftInfo@ansys.com
Technical Support: AnsoftTechSupport@ansys.com
Maxwell 3D, Maxwell Strata, HFSS, HFSS-IE, Full-Wave Spice, and Optimetrics are registered
trademarks or trademarks of SAS IP Inc. All other trademarks are the property of their respective owners.
2012 SAS IP Inc., All rights reserved.

Introduction to VBScript 1-9


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

1-10 Introduction to VBScript


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

HFSS and VBScript

This chapter provides an overview of HFSS scripting using VBScript. Information is included on the following topics:

HFSS script variables.


Recording, running, pausing, resuming, and stopping a script.
Modifying a script for easier playback.
HFSS scripting conventions, including script command syntax used
in this guide, named arguments, and setting numerical values.
Executing a script from within a script.
Modifying properties.

HFSS and VBScript 2-1


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Overview of HFSS Script Variables


When you record an HFSS script, the beginning of the script looks like the following:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
Set oProject = oDesktop.SetActiveProject("Project1")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
Set oModule = oDesign.GetModule("BoundarySetup")
The lines above define the variables used by HFSS in the script and assign values to the variables. The variables are used in the following hierarchy:

Class hierarchy of variables.

2-2 HFSS and VBScript


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

oAnsoftApp
The oAnsoftApp object provides a handle for VBScript to access the AnsoftHfss product.
One example of accessing this object is:
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
oDesktop
The oDesktop object is used to perform desktop-level operations, including project management.
One example of accessing this object is:
Set oDesktop = oAnsoftApp.GetAppDesktop()
See Chapter 3, Desktop Object Script Commands, for details about script commands recognized
by the oDesktop object.
oProject
The oProject object corresponds to one project open in the product. It is used to manipulate
the project and its data. Its data includes variables, material definitions and one or more
designs. One example of accessing this object is:
Set oProject = oDesktop.GetActiveProject()
See the following chapters for details about the script commands recognized by the oProject
object:

Chapter 4, Project Object Script Commands


Chapter 5, Material Script Commands
Chapter 6, Property Script Commands
Chapter 7, Dataset Script Commands

oDesign
The oDesign object corresponds to an instance of a design in the project. This object is used to
manipulate the design and its data. Its data includes variables, modules, and editors.
One example of accessing this object is:
Set oDesign = oProject.GetActiveDesign()

HFSS and VBScript 2-3


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

See the following chapters for details about the script commands recognized by the oDesign
object:

Chapter 8, Design Object Script Commands


Chapter 9, Output Variable Script Commands
Chapter 11, Reporter Editor Script Commands

oEditor
The oEditor object corresponds to an editor, such as the 3D Modeler. This object is used to add
and modify data in the editor.
One example of accessing this object is:
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
The AnsoftHfss product scripting supports the following editors:
Editor

Name in Script

3D Modeler Editor

"3D Modeler"

Reporter Editor

There is no Reporter editor object in the script. Instead,


Reporter editor commands are executed by the HFSS
design object oDesign.

See Chapter 10, 3D Modeler Editor Script Commands, for details about the script commands recognized by the oEditor object and Chapter 11, Reporter Editor Script Commands for details
about Reporter editor commands.
oModule
The oModule object corresponds to a module in the design. Modules are used to handle a set of
related functionality.
One example of accessing this object is:
Set oModule = oDesign.GetModule("BoundarySetup")

2-4 HFSS and VBScript


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

The AnsoftHfss product scripting supports the following modules:


Module
Boundary/Excitations Module

Name in Script
"BoundarySetup"

Chapter 12, Boundary and


Excitation Module Script
Commands

"MeshSetup"

Chapter 13, Mesh Operations


Module Script Commands

"AnalysisSetup"

Chapter 14, Analysis Module


Script Commands

"Optimetrics"

Chapter 15, Optimetrics Script


Commands

"Solutions"

Chapter 16, Solutions Module


Script Commands

"FieldsReporter"

Chapter 17, Field Overlays


Module Script Commands

"RadField"

Chapter 18, Radiation Module


Script Commands

Corresponds to the Boundaries and


Excitations branches in the
project tree.
Mesh Operations Module
Corresponds to the Mesh
Operations branch in the project
tree.
Analysis Module
Corresponds to the Analysis branch
in the project tree.
Optimetrics Module
Corresponds to the Optimetrics
branch in the project tree.
Solutions Module
Corresponds to the operations in
the Solution Data dialog box,
which is accessed by clicking
HFSS>Results>
Solution Data.
Field Overlays Module
Corresponds to the Field Overlays
branch in the project tree.
Radiation Module
Corresponds to the Radiation
branch in the project tree.

Chapter

HFSS and VBScript 2-5


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Recording a Script
Once you start to record a script, your subsequent actions are added to the script. Each interface command has one or more associated script commands that are recorded to the script. The
script is recorded to a text file in .vbs (VBScript) file format.

1 Click Tools>Record Script.


2
3
4
5

The Save As dialog box appears.


Use the file browser to locate the folder in which you want to save the script, such as
C:\Ansoft\HFSS9\Scripts, and then double-click the folders name.
Type the name of the script in the File name text box, and then click Save.
The script is saved in the folder you selected by the file name filename.vbs.
Perform the steps that you want to record.
When you have finished recording the script, click Stop Script Recording on the Tools menu.

Stopping Script Recording

ClickTools>Stop Script Recording.


HFSS stops recording to the script.

Running a Script
1 Click Tool>Run Script.
The Open dialog box appears.

2 Use the file browser to locate the folder in which you saved the script, and then double-click
3

the folders name.


Type the name of the script in the File name text box, or click its name, and then click
Open.
HFSS executes the script.
To supply script arguments when running from Tools>Run Script, use the edit field at the
bottom of the file selection dialog. You can access the script arguments using the AnsoftScriptHost.arguments collection from vbscript. This is a standard COM collection.

To run a script from a command line (as described in the HFSS Online Help in the Running HFSS
from a Command Line section), use:
-runscriptandexit or -runscript arguments to the HFSS command line syntax.
You can give -scriptargs parameter to the script and specify the arguments described in the
HFSS online help.
If you run the script from DOS prompt as a .vbs file (that is, you don't launch HFSS, but just
launch vbs directly, or use wscript.exe or cscript.exe), the arguments will be in the
2-6 HFSS and VBScript
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

WSH.arguments collection, not the AnsoftScriptHost.arguments collection. To handle this,


you can write this:
on error resume next
dim args
Set args = AnsoftScript.arguments
if(IsEmpty(args)) then
Set args = WSH.arguments
End if
on error goto 0
'At this point, args has the arguments no matter if you are running
'under windows script host or Ansoft script host
msgbox "Count is " & args.Count
for i = 0 to args.Count - 1
msgbox args(i)
next

Pausing and Resuming a Script


To pause a script during its execution:

Click Tools>Pause Script.

To resume a script after pausing it:

Click Tools>Resume Script.

Stopping a Script

On the Tools menu, click Stop Script.


HFSS stops executing the script that has been paused.

Modifying a Script for Easier Playback


In the sample script on page 2-2, note that the oProject variable is set to "Project1". That
means that the script must be played back within Project1 to operate correctly. Alternatively,
oProject could be set to the active project without specifying a project name.
For example:
Set oProject = oDesktop.GetActiveProject()
Using the line above, the script can be played back in any project.
HFSS and VBScript 2-7
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

HFSS Scripting Conventions


Syntax Conventions
The following data types will be used throughout this scripting guide:
<string>

A quoted string.

<bool>

A boolean value. Should be set to either true or false (no quotes).


Example: "SolveInside:=", true

<double>

A double precision value.


Example: 1.2

<int>

An integer. Example: 1

<value>

Can be a number, a VBScript variable, or a quoted string containing a


valid HFSS expression.
Examples:
-"XSize:=", 1
-"XSize:=", "3mm"
-"XSize:=", VBScript_Var
-"XSize:=", "Hfss_Var + 10mm"

Script Command Conventions


The majority of this guide lists individual script commands. The following conventions are used
to describe them:
Script Command Name
Use:

Describes the function of the script command.

Command:

Lists the interface command that corresponds to the script command. Menu
commands are separated by carats. For example,
HFSS>Excitations>Assign>Wave Port.

Syntax:

Demonstrates the correct syntax for the command. Carat


brackets < > enclose information or arguments that you
must enter.

Return Value:

Describes the return value, if any.

Parameters:

Describes the arguments or information in the syntax


description, if an explanation is needed.

2-8 HFSS and VBScript


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:

Provides a working example of the script command, if


needed.

Passing Arguments to Scripts


Thare are two ways to pass arguments to scripts:
1 When running from command line using -runscriptandexit or -runscript, you can give
-scriptargs parameters and specify arguments.
All arguments following the -scriptargs flag are enclosed in double quotes. For example

C:\Ansoft\HFSS13\hfss.exe -RunScriptAndExit _
C:\scripts\test.vbs -scriptsargs "arg1 arg2 arg3"
When running from Tools>Run script, there is an edit field at the bottom of the file selection dialog that you can use to enter script arguments.

The user can access the script arguments using the AnsoftScriptHost.arguments collection from
vbscript. This is a standard COM collection.
There is an issue if the user runs the script from DOS prompt as a .vbs file (that is, you dont
open hfss, but launch vbs directly, or use wscript.exe or cscript.exe). The arguments will be in
the WSH.arguments collection, not the AnsoftScriptHost.arguments collection. To handle this,
you can write this:
on error resume next
dim args
Set args = AnsoftScript.arguments
if(IsEmpty(args)) then
Set args = WSH.arguments
End if
on error goto 0
'At this point, args has the arguments no matter if you are running
'under windows script host or Ansoft script host
msgbox "Count is " & args.Count
for i = 0 to args.Count - 1
msgbox args(i)
next

Named Arguments
Many HFSS script commands use named arguments. The names can appear in three ways:
1. Named data, name precedes data.
HFSS and VBScript 2-9
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

For example: ...,"SolveInside:=", true, ...


2. Named Array, name precedes array.
For example: ...,"Attributes:=", Array(...),...
3. Named Array, name inside array.
For example: ..., Array("NAME:Attributes",...),...
In the first and second examples, the name is formatted as "<Name>:=". This signals HFSS that
this is a name for the next argument in the script command. In the third example, the name is
formatted as "NAME:<name>" and is the first element of the Array.
The names are used both to identify what the data means to you and to inform HFSS which data
is being given. The names must be included or the script will not play back correctly. However, if
you are writing a script, you do not need to pass in every piece of data that the command can
take. For example, if you are modifying a boundary, the script will be recorded to include every
piece of data needed for the boundary, whether or not it was modified. If you are writing a
script by hand, you can just add the data that changed and omit anything that you do not want
to change. HFSS will use the names to determine which data you provided.
For example, when editing an impedance boundary, HFSS records the edit impedance boundary
command as follows:
oModule.EditImpedance "Imped1", Array("NAME:Imped1", _
"Resistance:=", "100", "Reactance:=", "50", _
"InfGroundPlane:=", false)
If you only want to change the resistance, then you can leave out the other data arguments
when you are manually writing a script:
oModule.EditImpedance "Imped1", Array("NAME:Imped1", _
"Resistance:=", "100")

Setting Numerical Values


For script arguments that expect a number, the following options are possible:

Pass in the number directly. For example:


oModule.EditVoltage "Voltage1", Array("NAME:Voltage1", _
"Voltage:=", 3.5)

2-10 HFSS and VBScript


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Pass in a string containing the number with units. For example:


oModule.EditVoltage "Voltage1", Array("NAME:Voltage1", _
"Voltage:=", "3.5V" )

Pass in an HFSS defined variable name. For example:


oModule.EditVoltage "Voltage1", Array("NAME:Voltage1", _
"Voltage:=", "$var1" )

Pass in a VBScript variable. For example:


vb_var = "3.5V"
oModule.EditVoltage "Voltage1", Array("NAME:Voltage1", _
"Voltage:=", vb_var)

Executing a Script from Within a Script


HFSS provides a script command that enables you to launch another script from within the script
that is being executed:
oDesktop.RunScript

<ScriptName>

If the full path to the script is not specified, HFSS searches for the specified script in the following locations, in this order:

Personal library directory.


This is the PersonalLib subdirectory in the project directory. The project directory can be
specified in the General Options dialog box (click Tools>Options>General Options to open
this dialog box) under the Project Options tab.

User library directory.


This is the userlib subdirectory in the library directory. The library directory can be specified
in the General Options dialog box (click Tools>Options>General Options to open this dialog
box) under the Project Options tab.

System library directory.


This is the syslib subdirectory in the library directory. The library directory can be specified
in the General Options dialog box (click Tools>Options>General Options to open this dialog
box) under the Project Options tab.

HFSS installation directory.

HFSS and VBScript 2-11


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Editing Properties
Any data that is shown in the dockable Properties dialog box or in the modal Properties pop-up
window is called a property. For example, project and local variables are properties. The XSize
of a box in the Geometry editor is also a property. See Chapter 6, Property Script Commands,
for an explanation of how to manipulate properties in a script.

2-12 HFSS and VBScript


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Ansoft Application Object


Script Commands

The Application object commands permit you to set parameters for RAM and
processor use. Application object commands should be executed by the
oAnsoftApp object.
oAnsoftApp.<CommandName> <args>
GetAppDesktop
GetDesiredRamMBLimit
GetHPCLicenseType
GetMaximumRamMBLimit
GetMPISpawnCmd
GetMPIVendor
GetNumberOfProcessors
GetUseHPCForMP
SetDesiredRamMBLimit
SetHPCLicenseType
SetMaximumRamMBLimit
SetNumberOfProcessors
SetUseHPCForMP
SetMPISpawnCmd
SetMPIVendor

Ansoft Application Object Script Commands 3-1


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

GetAppDesktop
Use:

GetAppDesktop is a function of oAnsoftApp. This function does not take


an input and it returns an object. The object is assigned to the variable
oDesktop.

Syntax:

GetAppDesktop()

Return Value:

Object.

Parameters:

None

Example:
Set oDesktop = oAnsoftApp.GetAppDesktop()

GetDesiredRamMBLimit
Use:

Gets the Desired RAM Limit (MB) value in HFSS. Not used in HFSS-IE.

Syntax:

GetDesiredRamMBLimit()

Return Value:

Returns the Desired RAM Limit in megabytes (MB).


Type: <int>

Parameters:

<ProductName>
Type: String, HFSS (default)

Example:
desired_ram = oAnsoftApp.GetDesiredRamMBLimit()

GetHPCLicenseType
Use:

Gets the specified HPC license type.

Syntax:

GetHPCLicenseType(BSTR productName, BSTR* type)

Return Value:
Parameters:

<ProductName>
Ansoft Product such as HFSS.
<type>
pool or pack

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
3-2 Ansoft Application Object Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Set oDesktop = oAnsoftApp.GetAppDesktop()


oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project6")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
oAnsoftApp.GetUseHPCForMP
oAnsoftApp.GetHPCLicenseType
oAnsoftApp.SetHPCLicenseType("Pool")
oAnsoftApp.SetUseHPCForMP(1)

GetMaximumRamMBLimit
Use:

Gets the Maximum RAM Limit (MB) value in HFSS. Not used in HFSS-IE.

Syntax:

GetMaximumRamMBLimit()

Return Value:

Returns the Maximum RAM Limit in megabytes (MB).


Type: <int>

Parameters:

<ProductName>
Type: String, HFSS (default), HFSSIE

Example:
max_ram = oAnsoftApp.GetMaximumRamMBLimit()

GetMPISpawnCmd
Use:

For Linux authentication, gets the remote spawn command, either SSH
(default) or RSH.

Command:

Tools>Options>HFSS Options, Solver tab, or Tools>Options>HFSS-IE


Options, Solver tab.

Syntax:

GetMPISpawnCmd <product>

Return Value:

SSH or RSH

Parameters:

<ProductName>
Type: String, HFSS (default), HFSS-IE

Example:

GetMPIVendor
Use:

For HFSS or HFSS-IE analysis using distributed memory, get the MPI vendor.

Command:

Tools>Options>HFSS Options, Solver tab, or Tools>Options>HFSS-IE


Options, Solver tab

Syntax:

GetMPIVendor <product>

Return Value:

return <string>, either "PlatformComputing" or "Intel"


Ansoft Application Object Script Commands 3-3

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Parameters:

<ProductName>
Type: String, HFSS (default), HFSSIE

Example:
"GetMPIVendor HFSS

GetNumberOfProcessors
Use:

Gets the Number of Processors value.

Syntax:

GetNumberOfProcessors()

Return Value:

Returns the Number of Processors.


Type: <int>

Parameters:

<ProductName>
Type: String, HFSS (default)

Example:
numprocessors = oAnsoftApp.GetNumberOfProcessors()

GetUseHPCForMP
Use:

Gets the Tools>Options>HFSS Options Solver tab selection for Use HPC
licenses for multiprocessing and distributed frequency points, rather
than the MP License.

Syntax:

GetUseHPCForMP(BSTR productName, BOOL* flag)

Return Value:

None

Parameters:

<productName>
Type: String, HFSS (default), or HFSSIE
<Bool>
0 is False, 1 is True.

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
3-4 Ansoft Application Object Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Set oProject = oDesktop.SetActiveProject("Project6")


Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
oAnsoftApp.GetUseHPCForMP
oAnsoftApp.GetHPCLicenseType
oAnsoftApp.SetHPCLicenseType("Pool")
oAnsoftApp.SetUseHPCForMP(1)

SetDesiredRamMBLimit
Use:

Sets the Desired RAM Limit (MB) value in HFSS. Not used in HFSS-IE.

Syntax:

SetDesiredRamMBLimit(<DesiredRAMLimit> <ProductName>)

Return Value:

None

Parameters:

<DesiredRAMLimit>
Type: <int>
<ProductName>
Type: String, HFSS (default)

Example:
oAnsoftApp.SetDesiredRamMBLimit(2000)

SetHPCLicenseType
Use:

Sets the HPC license type.

Syntax:

SetHPCLicenseType(BSTR type, BSTR productName)

Parameters:

<type>
Type: String, pool (default) or pack
<ProductName>
Type: String, HFSS (default) or HFSSIE

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project6")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Ansoft Application Object Script Commands 3-5
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

oAnsoftApp.GetUseHPCForMP
oAnsoftApp.GetHPCLicenseType
oAnsoftApp.SetHPCLicenseType("Pool")
oAnsoftApp.SetUseHPCForMP(1)

SetMaximumRamMBLimit
Use:

Sets the Maximum RAM Limit (MB) value in HFSS. Not used in HFSS-IE.

Syntax:

SetMaximumRamMBLimit(<MaximumRAMLimit> <ProductName>)

Return Value:

None

Parameters:

<MaximumRAMLimit>
Type: <int>
<ProductName>
Type: String, HFSS (default)

Example:
oAnsoftApp.SetMaximumRamMBLimit(2000)

SetMPISpawnCmd
Use:

For Linux authentication, sets the remote spawn command as SSH (default)
or RSH.

Command:

Tools>Options>HFSS Options, Solver tab, or Tools>Options>HFSS-IE


Options, Solver tab.

Syntax:

SetMPISpawnCmd <cmd>,<product>

Return Value:

None

Parameters:

<cmd>
Type: String, SSH (default), RSH.
<ProductName>
Type: String, HFSS (default), HFSS-IE

Example:

SetMPIVendor
Use:

For using distributed memory processing, set the Vendor.

Command:

Tools>Options>HFSS-IE Options, Solver tab or Tools>OptionsHFSS


Options, Solver tab.

Syntax:

SetMPIVendor <string>, <product>

Return Value:

None

3-6 Ansoft Application Object Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Parameters:

<string>
Type: String, Intel (default), or Platform Computing.
<ProductName>
Type: String, HFSS (default), or HFSSIE

Example:

SetNumberOfProcessors
Use:

Sets the Number of Processors value.

Syntax:

SetNumberOfProcessors(<NumProcessors> <ProductName>)

Return Value:

None

Parameters:

<NumProcessors>
Type: <int>
<ProductName>
Type: String, HFSS (default)

Example:
oAnsoftApp.SetNumberOfProcessors(2)

SetUseHPCForMP
Use:

Equivalent to Tools>Options>HFSS Options Solver tab selection for Use


HPC licenses for multiprocessing and distributed frequency points, rather
than the MP License.

Syntax:

SetUseHPCForMP(BOOL flag, BSTR productName)

Parameters:

<flag>
Type: String,
<ProductName>
Type: String, HFSS (default) or HFSSIE

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Ansoft Application Object Script Commands 3-7
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Set oDesktop = oAnsoftApp.GetAppDesktop()


oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project6")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
oAnsoftApp.GetUseHPCForMP
oAnsoftApp.GetHPCLicenseType
oAnsoftApp.SetHPCLicenseType("Pool")
oAnsoftApp.SetUseHPCForMP(1)

3-8 Ansoft Application Object Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Desktop Object Script


Commands

Desktop commands should be executed by the oDesktop object. Some new


commands permit you to query objects when you do not know the names.
Set oDesktop =
CreateObject("AnsoftHfss.HfssScriptInterface")
oDesktop.CommandName <args>
CloseAllWindows
CloseProject
CloseProjectNoForce
Count
EnableAutoSave
GetAutoSaveEnabled
GetActiveProject
GetDesigns
GetDistributedAnalysisMachines
GetName
GetLibraryDirectory
GetProjects
GetProjectDirectory
GetProjectList
GetTempDirectory
GetVersion
Desktop Object Script Commands 4-1
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

NewProject
OpenMultipleProjects
OpenProject
PauseScript
Print
QuitApplication
RestoreWindow
RunProgram
RunScript
SetActiveProject
SetActiveProjectByPath
SetLibraryDirectory
SetProjectDirectory
SetTempDirectory
Sleep

4-2 Desktop Object Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

CloseAllWindows
Use:

Closes all MDI child windows on the desktop.

Command:

From main menu, Window>CloseAll.

Syntax:

CloseAllWindows()

Return Value:

None

Parameters:

None

Example:
Desktop.CloseAllWindows()

CloseProject
Use:

Closes a specified project. Changes to the project will not be saved. Save
the project using the Project command Save or SaveAs before closing to
save changes.

Command:

File>Close

Syntax:

CloseProject <ProjectName>

Return Value:

None

Parameters:

<ProjectName>
Type: <string>

Example:
oDesktop.CloseProject "Project1"

CloseProjectNoForce
Use:

Closes a specified project unless there are simulations ongoing. Changes to


the project will not be saved. Save the project using the Project command
Save or SaveAs before closing to save changes.

Command:

File>Close

Syntax:

CloseProjectNoForce <ProjectName>

Return Value:

None

Parameters:

<ProjectName>
Type: <string>

Example:
oDesktop.CloseProjectNoForce "Project1"

Desktop Object Script Commands 4-3


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Count
Use:

Gets the total number of queried projects or designs obtained by


GetProjects() and GetDesigns() commands. See the example query.

Syntax:

Count

Return Value:

Returns an integer value.

Parameters:

None

Example:

set projects = oDesktop.GetProjects()


numprojects = projects.Count

Example:
' iterate through projects and designs using for each
for each prj in oDesktop.GetProjects()
msgbox prj.GetName()
for each design in prj.GetDesigns()
msgbox design.GetName()
next
next
' iterate through using integer index
Dim projects
set projects = oDesktop.GetProjects()
for i = 0 to projects.Count - 1
msgbox projects(i).GetName()
dim designs
set designs = projects(i).GetDesigns()
for j = 0 to designs.Count
msgbox designs(j).GetName()
next
next
' lookup by name

EnableAutoSave
Use:

Enable or disable autosave feature.

Syntax:

EnableAutoSave(bool)

Return Value:

None

4-4 Desktop Object Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Parameters:

None

Example:
oDesktop.EnableAutoSave(true)

GetActiveProject
Use:

Returns the project that is active in the desktop.

Command:

None

Syntax:

GetActiveProject

Return Value:

The project that is active in the desktop.

Parameters:

None

Example:
Set oProject = oDesktop.GetActiveProject ()

GetAutoSaveEnabled
Use:

Checks to see if the autosave feature is enabled.

Command:

None

Syntax:

GetAutoSaveEnabled

Return Value:

Boolean

Parameters:

None

Example:
oDesktop.GetAutoSaveEnabled()

GetDesigns
Use:

For querying designs within a queried project obtained by the GetProjects()


command. Once you have the designs you can iterate through them using
standard VBScript methods. See the example query.

Syntax:

GetDesigns()

Return Value:

Returns a COM collection of designs in the given project.

Parameters:

None

Example:
set projects = oDesktop.GetProjects()
set designs = projects(0).GetDesigns()

Desktop Object Script Commands 4-5


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

GetDistributedAnalysisMachines
Use:

Gets a list of machines used for distributed analysis. You can iterate
through the list using standard VBScript methods.

Syntax:

GetDistributedAnalysisMachines()

Return Value:

Returns a COM collection of machines used for distributed analysis.

Parameters:

None

Example:
For each machine in oDesktop.GetDistributedAnalysisMachines()
msgbox machine
next

GetName [Desktop]
Use:

Gets names of queried projects or designs obtained by GetProjects() and


GetDesigns() commands. See the example query.

Syntax:

GetName()

Return Value:

Returns a name of type string.

Parameters:

None

Example:
set projects = oDesktop.GetProjects()
project_name = projects(0).GetName()

GetLibraryDirectory
Use:

Gets the library directory path.

Syntax:

GetLibraryDirectory

Return Value:

Returns a directory path.


Type: <string>

Parameters:

None

Example:
libdir = oDesktop.GetLibraryDirectory

GetProjects
Use:

For querying projects. Once you have the projects you can iterate through
them using standard VBScript methods. See the example query.

Syntax:

GetProjects()

Return Value:

Returns a COM collection of opened projects.

4-6 Desktop Object Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Parameters:

None

Example:
set projects = oDesktop.GetProjects()

GetProjectDirectory
Use:

Gets the project directory path.

Syntax:

GetProjectDirectory

Return Value:

Returns a directory path.


Type: <string>

Parameters:

None

Example:
projdir = oDesktop.GetProjectDirectory

GetProjectList
Use:

Returns a list of all projects that are open in the desktop.

Command:

None

Syntax:

GetProjectList()

Return Value:

An array of strings, the names of all open projects in the desktop.

Parameters:

None

Example:
list_of_projects = oDesktop.GetProjectList()

GetTempDirectory
Use:

Gets the temp directory path.

Syntax:

GetTempDirectory

Return Value:

Returns a directory path.


Type: <string>

Parameters:

None

Example:
tempdir = oDesktop.GetTempDirectory

GetVersion
Use:

Returns a string representing the version.

Syntax:

GetVersion()

Return Value:

string
Desktop Object Script Commands 4-7

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Parameters:

None

Example:
msgbox(oDesktop.GetVersion()), displays "10.0"

NewProject
Use:

Creates a new project. The new project becomes the active project.

Command:

File>New

Syntax:

NewProject

Return Value:

An object reference to the newly-added project.

Parameters:

None

Example:
Set oProject = oDesktop.NewProject

OpenMultipleProjects
Use:

Opens all files of a specified type in a specified directory.

Command:

File>Multiple Open

Syntax:

OpenMultipleProjects <Directory> <FileType>

Return Value:

None

Parameters:

<Directory>
Type: <string>
<FileType>
Type: <string>

Example:
oDesktop.OpenMultipleProjects "D:/Projects", "*.hfss"

OpenProject
Use:

Opens a specified project.

Command:

File>Open

Syntax:

OpenProject <FileName>

Return Value:

An object reference to the newly-opened project.

Parameters:

<FileName>: Full path of the project to open.


Type: <string>

Example:
4-8 Desktop Object Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

oDesktop.OpenProject "D:/Projects/Project1.hfss"

PauseScript
Use:

Pauses the scripts execution and displays a message in a pop-up dialog box
to the user. The script execution will not resume until the user clicks
Tools>Resume Script.

Command:

Tools>Pause Script

Syntax:

PauseScript <Message>

Return Value:

None

Parameters:

<Message>
Type: <string>

Example:
oDesktop.PauseScript "Text to display in pop-up dialog box"

Print
Use:

Prints the contents of the active view window.

Command:

File>Print

Syntax:

Print

Return Value:

None

Parameters:

None

Example:
oDesktop.Print

QuitApplication
Use:

Exits the desktop.

Command:

File>Exit

Syntax:

QuitApplication

Return Value:

None

Parameters:

None

Example:
oDesktop.QuitApplication

RestoreWindow
Use:

Restores a minimized HFSS window.

Command:

None
Desktop Object Script Commands 4-9

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Syntax:

RestoreWindow

Return Value:

None

Parameters:

None

Example:
oDesktop.RestoreWindow

RunProgram
Use:

Runs an external program.

Command:

None

Syntax:

RunProgram <ProgName>, <ProgPath>, <WorkPath>, <ArgArray>

Return Value:

None

Parameters:

<ProgName>
Type: <string>
Name of the program to run.
<ProgPath>
Type: <string>
Location of the program. Pass in an empty string to use the system path.
<WorkPath>
Type: <string>
Working directory in which program will start.
<ArgArray>
Type: Array of strings
Arguments to pass to the program. If no arguments, pass in None.

Example:
oDesktop.RunProgram "winword.exe", _
"C:\Program Files\Microsoft Office\Office10",_
"", None

RunScript
Use:

Launches another script from within the script currently being executed.

Command:

Tools>Run Script

Syntax:

RunScript <ScriptPath>

4-10 Desktop Object Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Return Value:

None

Parameters:

<ScriptPath>
Type: <string>
Name or full path of the script to execute. If the full path to the script is not specified,
HFSS searches for the specified script in the following locations, in this order:

Personal library directory.


This is the PersonalLib subdirectory in the project directory. The project directory can be specified in the General Options dialog box (click
Tools>Options>General Options to open this dialog box) under the Project
Options tab.

User library directory.


This is the userlib subdirectory in the library directory. The library directory can
be specified in the General Options dialog box (click Tools>Options>General Options to open this dialog box) under the Project Options tab.

System library directory.


This is the syslib subdirectory in the library directory. The library directory can
be specified in the General Options dialog box (click Tools>Options>General Options to open this dialog box) under the Project Options tab.

HFSS installation directory.

Example:
oDesktop.RunScript("C:/Project/test1.vbs")

SetActiveProject
Use:

Returns a specified project as the active project in the desktop.

Command:

None

Syntax:

SetActiveProject <ProjectName>

Return Value:

The specified project becomes active in the desktop.

Parameters:

<ProjectName>
Type: <string>

Example:
Set oProject = oDesktop.SetActiveProject ("Project1")

SetActiveProjectByPath
Use:

If a user has two projects open with the same name, the result of
SetActiveProject is ambiguous (The first one listed in selected). This
command permits unambiguous specification of the active project.

Syntax:

SetActiveProjectByPath()
Desktop Object Script Commands 4-11
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Return Value:

The specified project becomes active in the desktop.

Parameters:

<fullPathProjectName>

Example:
Set oProject = oDesktop.SetActiveProjectByPath("C:\working\tee.hfss")

SetLibraryDirectory
Use:

Sets the library directory path. The specified directory must already exist
and contain a syslib folder.

Syntax:

SetLibraryDirectory <DirectoryPath>

Return Value:

None

Parameters:

<DirectoryPath>
Type: <string>

Example:
oDesktop.SetLibraryDirectory "c:\libraries"

SetProjectDirectory
Use:

Sets the project directory path. The directory will be automatically created
if it does not already exist.

Syntax:

SetProjectDirectory <DirectoryPath>

Return Value:

None

Parameters:

<DirectoryPath>
Type: <string>

Example:
oDesktop.SetProjectDirectory "c:\projects"

SetTempDirectory
Use:

Sets the temp directory path. The directory will be automatically created if
it does not already exist.

Syntax:

SetTempDirectory <DirectoryPath>

Return Value:

None

Parameters:

<DirectoryPath>
Type: <string>

Example:
oDesktop.SetTempDirectory "c:\temp"

4-12 Desktop Object Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Sleep
Use:

Suspends execution of HFSS for the specified number of milliseconds, up to


60,000 milliseconds (1 minute).

Command:

none

Syntax:

Sleep <TimeInMilliseconds>

Return Value:

None

Parameters:

<TimeInMilliseconds>
Type: <int>

Example:
oDesktop.Sleep 1000

Desktop Object Script Commands 4-13


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

4-14 Desktop Object Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Project Object Script


Commands

Project commands should be executed by the oProject object. One example of accessing this object is:
Set oProject = oDesktop.GetActiveProject()
Close
CopyDesign
CutDesign
DeleteDesign
GetActiveDesign
GetDesign
GetName [Project]
GetPath
GetTopDesignList
InsertDesign
Paste
Redo
Save
SaveAs
SetActiveDesign
SimulateAll
Undo

Project Object Script Commands 5-1


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Close
Use:

Closes the active project. Unsaved changes will be lost.

Command:

None

Syntax:

Close

Return Value:

None

Parameters:

None

Example:
oProject.Close

CopyDesign
Use:

Copies a design.

Command:

Edit>Copy

Syntax:

CopyDesign <DesignName>

Return Value:

None

Example:
oProject.CopyDesign "HFSSDesign1"

CutDesign
Use:

Cuts a design from the active project. The design is stored in memory and
can be pasted in any HFSS project.

Command:

Edit>Cut

Syntax:

CutDesign <DesignName>

Return Value:

None

Example:
oProject.CutDesign "HFSSDesign1"

Warning

This is a legacy command that is no longer supported and should not be


used as it may have unintended effects on solved designs.

DeleteDesign
Use:

Deletes a specified design in the project.

Command:

Edit>Delete

Syntax:

DeleteDesign <DesignName>

Return Value:

None

Example:
5-2 Project Object Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

oProject.DeleteDesign "HFSSDesign2"

GetActiveDesign
Use:

Returns the design in the active project.

Command:

None

Syntax:

GetActiveDesign

Return Value:

The active design.

Parameters:

None

Example:
Set oDesign = oProject.GetActiveDesign ()

GetDesign
Use:

Returns the specified design.

Command:

None

Syntax:

GetDesign <DesignName>

Return Value:

The specified design.

Parameters:

<DesignName>
Type: <string>
Name of the design to return.

Example:
Set oDesign = oProject.GetDesign ("HFSSDesign1")

GetName [Project]
Use:

Returns the project name.

Command:

None

Syntax:

GetName

Return Value:

The active projects name.

Parameters:

None

Example:
name = oProject.GetName ()

GetPath
Use:

Returns the location of the project on disk.

Command:

None
Project Object Script Commands 5-3

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Syntax:

GetPath

Return Value:

The path to the project, which does not include the project name.

Parameters:

None

Example:
path = oProject.GetPath ()

GetTopDesignList
Use:

Returns a list of the names of the top-level designs.

Command:

None

Syntax:

GetTopDesignList

Return Value:

An array of strings that are the names of the top-level designs.

Parameters:

None

Example:
name_list = oProject.GetTopDesignList ()

InsertDesign
Use:

Inserts a new design in the project. In HFSS scripts, the last argument will
always be empty.

Command:

Project>Insert HFSS Design

Syntax:

InsertDesign "HFSS", <DesignName>, <SolutionType>, ""

Return Value:

Object

Parameters:

<DesignName>
Type: <string>
Name of the new design.
<SolutionType>
Type: <string>
Solution type of the new design. Can be "DrivenModal",
"DrivenTerminal", or "Eigenmode".

Example:
Set oDesign = oProject.InsertDesign("HFSS", "HFSSDesign3",_
"DrivenModal", "")

Paste [Design]
Use:

Pastes a design in the active project.

5-4 Project Object Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Command:

Edit>Paste

Syntax:

Paste

Return Value:

None

Parameters:

None

Example:
oProject.Paste

Redo [Project Level]


Use:

Reapplies the last project-level command.

Command:

Edit>Redo

Syntax:

Redo

Return Value:

None

Parameters:

None

Example:
oProject.Redo

Save
Use:

Saves the active project.

Command:

File>Save

Syntax:

Save

Return Value:

None

Parameters:

None

Example:
oProject.Save

SaveAs
Use:

Saves the project under a new name.

Command:

File>Save As

Syntax:

SaveAs <FileName> <OverWrite>

Return Value:

None

Parameters:

<FileName>
Type: <string>
New name for the file.

Project Object Script Commands 5-5


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<OverWrite>
Type: <bool>
Set to true if an existing project by that name should be overwritten.
Example:
oProject.SaveAs "D:/projects/project1.hfss", true

SetActiveDesign
Use:

Sets a new design to be the active design.

Command:

None

Syntax:

SetActiveDesign <DesignName>

Return Value:

The named design becomes active.

Parameters:

<DesignName>
Type: <string>
Name of the design to set as the active design.

Example:
Set oDesign = oProject.SetActiveDesign ("HFSSDesign2")

SimulateAll
Use:

Runs the SimulateAll project-level script command from the script,


which will simulate all HFSS solution setups and Optimetrics setups for all
design instances in the project.

Command:

None

Syntax:

None

Return Value:

SimulateAll script command.

Parameters:

None

Example:
oProject.SimulateAll

Undo [Project]
Use:

Cancels the last project level command.

Command:

Edit>Undo

Syntax:

Undo

Return Value:

None

Parameters:

None

Example:
5-6 Project Object Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

oProject.Undo

Project Object Script Commands 5-7


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

5-8 Project Object Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Material Script Commands

Material commands other than the DoesMaterialExist command should be


executed by the oProject object. The DoesMaterialExist command is executed by the oDefinitionManager object. Material commands apply to all
products.
Set oProject = oDesktop.SetActiveProject("Project1")
oProject.CommandName <args>
AddMaterial
DoesMaterialExist
EditMaterials
ExportMaterial
RemoveMaterial

Material Script Commands 6-1


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

AddMaterial
Use:

Adds a local material.

Command:

Add Material command in the material editor.

Syntax:

AddMaterial Array("NAME:<MaterialName>",
<MatProperty>, <MatProperty>, ...)

Return Value:

None

Parameters:

<MatProperty> (simple material)


"<PropertyName>:=", <value>
<MatProperty> (anisotropic material)
Array("NAME:<PropertyName>",
"property_type:=", "AnisoProperty",
"unit:=", <string>",
"component1:=", <value>,
"component2:=", <value>,
"component3:=", <value>))
<PropertyName>
Type: <string>
Should be one of the following: "permittivity",
"permeability", "conductivity"
"dielectric_loss_tangent",
"magnetic_loss_tangent", "saturation_mag",
"lande_g_factor", "delta_H"
property_type
Type: <string>
Should be "AnisoProperty".
unit
Type: <string>
Possible values:
delta_H: "Oe"
saturation_mag: "Gauss", "uGauss", "Tesla",

"uTesla"

other properties: "" (empty string)


6-2 Material Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:
Set oDefinitionManager = oProject.GetDefinitionManager()
oDefinitionManager.AddMaterial Array("NAME:Material2",_
"dielectric_loss_tangent:=", "44",
Array("NAME:saturation_mag",_
"property_type:=", "AnisoProperty",_
"unit:=", "Gauss",_
"component1:=", "11", _
"component2:=", "22", _
"component3:=", "33"), _
"delta_H:=", "44Oe")

DoesMaterialExist
Use:

Checks for the presence of a material in the library by name

Command:

None

Syntax:

DoesMaterialExist(<MaterialName>)

Return Value:

Boolean

Parameters:

<materialName>
Type: <string>
Name of the material to search for in the material database

Example:
Set oProject = oDesktop.SetActiveProject("cir_th")
Set oDesign = oProject.SetActiveDesign("Design1")
Set oDefinitionManager = oProject.GetDefinitionManager()
if(oDefinitionManager.DoesMaterialExist("vacuum")) then
MsgBox("It Exists")
else
MsgBox("It Doesn't Exist...Creating")
oDefinitionManager.AddMaterial Array("NAME:Material5", _
"CoordinateSystemType:=", "Cartesian", _
Array("NAME:AttachedData"), _
Array("NAME:magnetic_coercivity",
"property_type:=", "VectorProperty", _
"Magnitude:=", "-1A_per_meter", _
Material Script Commands 6-3
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"DirComp1:=", "1", _
"DirComp2:=", _
"2", "DirComp3:=", "3"))
end if

EditMaterial
Use:

Modifies an existing material.

Command:

View/Edit Materials command in the material editor.

Syntax:

EditMaterial <OriginalName>, Array("NAME:<NewName>",

Return Value:

None

Parameters:

<OriginalName>

<MatProperty>, <MatProperty>, ...)

Type: <string>
Name of the material before editing.
<NewName>
Type: <string>
New name for the material.

ExportMaterial
Use:

Exports a local material to a library.

Command:

Export to Library command in the material editor.

Syntax:

ExportMaterial <ExportData>, <Library location>

Return Value:

None

Parameters:

<ExportData>
Array("NAME:<LibraryName>",
<MaterialName>, <MaterialName>, ...)

Example:
oProject.ExportMaterial Array("NAME:mo0907b",_
"Material1", "Material2", "Material3"),_
"UserLib"

RemoveMaterial
Use:

Removes a material from a library.

Command:

Remove Material(s) command in the material editor.

6-4 Material Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Syntax:

RemoveMaterial <MaterialName>, <IsProjectMaterial>,

Return Value:

None

Parameters:

<MaterialName>

<LibraryName>, <LibraryLocation>

Type: <string>
Name of the material to be removed.
<IsProjectMaterial>
Type: <bool>
If true, HFSS assumes the material is a project material. In this case, the last two
parameters will be ignored.
<LibraryName>
Type: <string>
The name of the user or personal library where the material resides.
<LibraryLocation>
Type: <string>
Should be "UserLib" or "PersonalLib".
Example:
oProject.RemoveMaterial "Material1", false, "mo0907", "UserLib"
oProject.RemoveMaterial "Material1", true, "Local", "Project"

Material Script Commands 6-5


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

6-6 Material Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Property Script Commands

Property commands should be executed by the oProject object.


Set oProject = oDesktop.SetActiveProject("Project1")
oProject.CommandName <args>
Conventions Used in this Chapter

Property
Refers to a single item that can be modified in the dockable Properties dialog box or
in the modal Properties pop-up window.

<PropServer>
Refers to the item whose properties are being modified. This is usually a compound
name giving all the information needed by the editor, design, or project to locate the
item being edited.

<PropTab>
Corresponds to one tab in the Property dialog box the tab under which properties
are being edited.

<PropName>
Name of a single property .
<PropServer> and <PropTab> Names
Project
Project Variables:
<PropServer>
"ProjectVariables"
Property Script Commands 7-1

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<PropTab>
"ProjectVariableTab"
AnsoftHfss Design
Local Variables:
<PropServer>
"LocalVariables"
<PropTab>
"LocalVariableTab"
AnsoftHfss Modules
<PropServer>
Format is: <ModuleName>:<ItemName>, where <ItemName> is the
boundary name, solution setup name, etc., depending on which module
is being edited.
Example: <PropServer> for the boundary "PerfE1" is
"BoundarySetup:PerfE1"
<PropTab>
Boundary module: "HfssTab"
Mesh Operations module: "MeshSetupTab"
Analysis module: "HfssTab"
Optimetrics module: "OptimetricsTab"
Solutions module: Does not support properties.
Field Overlays module: "FieldsPostProcessorTab"
Radiation module: "RadFieldSetupTab"
AnsoftHfss 3D Model Editor
Object in the module:
<PropServer>
Name of the object. For example: "Box1".
<PropTab>
7-2 Property Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Geometry3DAttributeTab"
Operation on an object:
<PropServer>
Format is <ObjName>:<OperationName>:<int>
Concatenation of object name, operation name, and the index of the operation.
For example: "Box2:CreateBox:2" refers to the second
"CreateBox" command in Box2s history.
<PropTab>
"Geometry3DCmdTab"
Reporter
Operations on Report properties:
Format is <ReportSetup>
For example, to set the Company Name in the plot header to My Company:
Set oModule = oDesign.GetModule("ReportSetup")
oModule.ChangeProperty Array("NAME:AllTabs",_
Array("NAME:Header",_ Array("NAME:PropServers",_
"XY Plot1:Header"), Array("NAME:ChangedProps",_
Array("NAME:Company Name", "Value:=", "My Company"))))
ChangeProperty
GetProperties
GetPropertyValue
GetArrayVariables
GetVariables
SetPropertyValue
SetVariableValue
Additional Property Scripting Example
Example Use of Record Script and Edit Properties

Property Script Commands 7-3


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

ChangeProperty
Use:

Changes to properties are scripted using the ChangeProperty command.


This command can be executed by the oEditor to change editor
properites, by the oDesign to change design level properties, and by the
oProject to change project level properties. The command can be used to
create, edit, and/or remove properties. In HFSS, only Variable and
Separator properties can be deleted.
Use the script recording feature and edit a property, and then view the resulting script
entry or use GetPropertyValue for the desired property to see the expected format.

Command:

None

Syntax:

ChangeProperty Array("Name:AllTabs", <PropTabArray>,


<PropTabArray>, ...)
ChangeProperty(<modulename>:<setup name>:<sweep name>)

Return Value:

None

Parameters:

<PropTabArray>
Array("Name:<PropTab>",
<PropServersArray>,
<NewPropsArray>,
<ChangedPropsArray>,
<DeletedPropsArray>)
<PropServersArray>
Array("Name:PropServers", <PropServer>,
<PropServer>, ...)
<NewPropsArray>
Array("Name:NewProps", <PropDataArray>,
<PropDataArray>,...)
<ChangedPropsArray>
Array("Name:ChangedProps",<PropDataArray>,
<PropDataArray>, ...)
<DeletedPropsArray>
Array("Name:DeletedProps", <PropName>,
<PropName>, ...)

7-4 Property Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<PropDataArray>
Array("NAME:<PropName>",
"PropType:=", <PropType>,
"NewName:=", <string>,
"Description:=", <string>,
"NewRowPosition:=", <int>,
"ReadOnly:=", <bool>,
"Hidden:=", <bool>,
<PropTypeSpecificArgs>)
<PropType>
Type: string
Identifies the type of property when a new property is added. In HFSS, only separator
properties and variable properties can be added.
"SeparatorProp"
"VariableProp"
"TextProp"
"NumberProp"
"ValueProp"
"CheckboxProp"
"MenuProp"
"PointProp"
"VPointProp"
"V3DPointProp"
"ButtonProp"
NewName
Specify the new name of a property if the propertys name is being edited. In HFSS,
the name can only be changed for separators and variables.
Description
Specify a description of the property. In HFSS, the description can only be changed
for separators and variables.
NewRowPosition
Used to reorder rows in the Property dialog box. In HFSS, this only applies to the
Property Script Commands 7-5
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Project>Project Variables panel and the Hfss>Design Properties panel. Specify the new zero-based row index of the variable or separator.
ReadOnly
Used to mark a property as "read only" so it can not be modified. In HFSS, this flag
can only be set for variables and separators.
Hidden
Used to hide a property so it can not be viewed outside of the Property dialog box.
In HFSS, this flag can only be set for variables and separators.
<PropTypeSpecificArgs>
SeparatorProp: no arguments
TextProp: "Value:=", <string>
NumberProp: "Value:=", <double>
ValueProp: "Value:=", <value>
CheckboxProp: "Value:=", <bool>
MenuProp: "Value:=", <string>
PointProp"X:=", <double>, "Y:=", <double>
VPointProp: "X:=", <value>, "Y:=", <value>
V3DPointProp: "X:=",<value>, "Y:=",<value>,
"Z:=",<value>
Material Button: "Material:=", <string>
Color Button: "R:=",<int>,"G:=",<int>,"B:=",<int>
Transparency Button:"Value:=", <double>
<PropTypeSpecificArgs> for VariableProps
Syntax:
"Value:=", <value>, <OptimizationFlagsArray>,
<TuningFlagsArray>, <SensitivityFlagsArray>,
<StatisticsFlagsArray>
Parameters:
<OptimizationFlagsArray>
Array("NAME:Optimization",
"Included:=", <bool>,
7-6 Property Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Min:=", <value>,
"Max:=", <value>)
<Tuning flagsArray>
Array("NAME:Tuning",
"Included:=", <bool>,
"Step:=", <value>,
"Min:=", <value>,
"Max:=", <value>)
<SensitivityFlagsArray>
Array("NAME:Sensitivity",
"Included:=", <bool>,
"Min:=", <value>,
"Max:=", <value>,
"IDisp:=", <value> )
<StatisticsFlagsArray>
Array("NAME:Statistical",
"Included:=", <bool>,
"Dist:=", <Distribution>,
"StdD:=", <value>,
"Min:=", <value>,
"Max:=", <value>,
"Tol:=", <string>)
<Distribution>
Type: string
Value should be "Gaussian" or "Uniform"
StdD
Standard deviation.
Min
Low cut-off for the distribution.
Property Script Commands 7-7
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Max
High cut-off for the distribution.
Tol
Tolerance for uniform distributions. Format is "<int>%".
Example: "20%".
Example:

Adding a new project level variable "$width":


oProject.ChangeProperty Array("NAME:AllTabs",_
Array("NAME:ProjectVariableTab",_
Array("NAME:PropServers", "ProjectVariables"),_
Array("NAME:NewProps",_
Array("NAME:$width",_
"PropType:=", "VariableProp",_
"Value:=", "3mm",_
"Description:=", "my new variable"))))

Example:

Deleting the design level variable "height":


oDesign.ChangeProperty Array("NAME:AllTabs",_
Array("NAME:LocalVariableTab",_
Array("NAME:PropServers", "DefinitionParameters"),_
Array("NAME:DeletedProps", "height"))

Example:

Changing a propertys value. If the following command were executed, then


the value of the property "XSize" of the PropServer
"Box1:CreateBox:1" on the "Geometry3DCmdTab" tab would be
changed. (oEditor is the Geometry3D editor in HFSS.)
oEditor.ChangeProperty Array("NAME:AllTabs",_
Array("NAME:Geometry3DCmdTab",_
Array("NAME:PropServers","Box1:CreateBox:1"),_
Array("NAME:ChangedProps",_
Array("NAME:XSize", "Value:=", "1.4mil"))))

Example:

Changing the Company Name, Design Name, the background color, and the
Axis scaling in a Report.

Set oProject = oDesktop.SetActiveProject("wgcombiner")


Set oDesign = oProject.SetActiveDesign("HFSSDesign2")
Set oModule = oDesign.GetModule("ReportSetup")
7-8 Property Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

oModule.ChangeProperty Array("NAME:AllTabs", Array("NAME:Header", _


Array("NAME:PropServers", "XY Plot1:Header"), _
Array("NAME:ChangedProps", Array("NAME:Company Name", _
"Value:=", "My Company"))))
oModule.ChangeProperty Array("NAME:AllTabs", Array("NAME:Header",_
Array("NAME:PropServers", "XY Plot1:Header"), _
Array("NAME:ChangedProps", Array("NAME:Design Name", _
"Value:=", "WG Combiner"))))
oModule.ChangeProperty Array("NAME:AllTabs", Array("NAME:General",_
Array("NAME:PropServers", "XY Plot1:General"), _
Array("NAME:ChangedProps", Array("NAME:Back Color", _
"R:=", 128, "G:=", 255, "B:=", 255))))
oModule.ChangeProperty Array("NAME:AllTabs", Array("NAME:Axis", _
Array("NAME:PropServers", "XY Plot1:AxisX"), _
Array("NAME:ChangedProps", Array("NAME:Axis Scaling", _
"Value:=", "Log"))))

Additional Property Scripting Commands


Following are other commands that can be used to manipulate properties from a script.

GetProperties
Use:

Gets a list of all the properties belonging to a specific PropServer and


PropTab. This can be executed by the oProject, oDesign, or oEditor
variables.

Command:

None

Syntax:

GetProperties( <PropTab>, <PropServer> )


GetProperties(<modulename>:<setup name>:<sweep name>)

Return Value:

Variant array of strings the names of the properties belonging to the prop
server.

Example:
Dim all_props
all_props = oDesign.GetProperties("HfssTab",_
"BoundarySetup:WavePort1")

Property Script Commands 7-9


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

GetPropertyValue
Use:

Gets the value of a single property. This can be executed by the oProject,
oDesign, or oEditor variables.
Use the script recording feature and edit a property, and then view the resulting script to
see the format for that property.

Command:

None

Syntax:

GetPropertyValue(<PropTab>, <PropServer>, <PropName>)


GetPropertyValue(<modulename>:<setup name>:<sweep name>)

Return Value:

String representing the property value.

Example:
value_string = _
oEditor.GetPropertyValue("Geometry3DCmdTab",_
"Box1:CreateBox:1", "XSize")

GetArrayVariables
Use:

Returns a list of array variables. To get a list of indexed Project variables,


execute this command using oProject. To get a list of indexed local
variables, use oDesign.

Syntax:

GetArrayVariables()

Return Value:

Variant array of strings the names of the array variables.

Example:
Dim var_array
project_var_array = oProject.GetArrayVariables()
local_var_array = oDesign.GetArrayVariables()

GetVariables
Use:

Returns a list of all variables. To get a list of non-indexed Project variables,


execute this command using oProject. To get a list of non-indexed local
variables, use oDesign.

Syntax:

GetVariables()

Return Value:

Variant array of strings the names of the variables.

Example:
Dim var_array
project_var_array = oProject.GetVariables()
local_var_array = oDesign.GetVariables()

7-10 Property Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

GetVariableValue
Use:

Gets the value of a single variable. To get the value of Project variables,
execute this command using oProject. To get the value of local variables,
use oDesign.

Command:

None

Syntax:

GetVariableValue( <VarName> )

Return Value:

A string representing the value of the variable.

Parameters:

<VarName>
Type: string
Name of the variable to access.

Example:
project_var_value_string = oProject.GetVariableValue("var_name")
Example:
local_var_value_string = oDesign.GetVariableValue("var_name")

SetPropertyValue
Use:

Sets the value of one property. This is not supported for properties of the
following types: ButtonProp, PointProp, V3DPointProp, and
VPointProp. Only the ChangeProperty command can be used to modify
these properties. This can be executed by the oProject, oDesign, or
oEditor variables.
Use the script recording feature and edit a property, and then view the resulting script
entry or use GetPropertyValue for the desired property to see the expected format.

Command:

None

Syntax:

SetPropertyValue <PropTab>, <PropServer>, <PropName>,


<PropValue>

Return Value:

None

Parameters:

<PropValue>
Type: String
Contains the value to set the property. The formatting is different depending on what
type of property is being edited.

Example:

oEditor.SetPropertyValue _
"Geometry3DCmdTab","Box1:CreateBox:1",_
"XSize", "3mm"

Property Script Commands 7-11


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

SetVariableValue
Use:

Sets the value of a variable. To set the value of a Project variable, execute
this command using oProject. To set the value of a local variable, use
oDesign.

Syntax:

SetVariableValue <VarName>, <VarValue>

Return Value:

None

Parameters:

<VarValue>
Type: <value>
New value for the variable.

Example:
oProject.SetVariableValue "$Var1", "3mm"
Example:
var_value = "2Ohm"
oDesign.SetVariableValue "Var2", var_value

Additional Property Scripting Example


Following is a sample script that uses the GetPropertyValue, SetPropertyValue, and
GetProperties functions. The script gets all the properties of the first CreateBox command
of "Box1". It then loops through the properites and for each one, shows the user the current
value and asks if the value should be changed.
Example:
Dim all_props
Dim prop
all_props = oEditor.GetProperties("Geometry3DCmdTab",_
"Box1:CreateBox:1")
For Each prop In all_props
val = oEditor.GetPropertyValue("Geometry3DCmdTab",_
"Box1:CreateBox:1", prop)
new_val = InputBox("New Value of " + prop + ":",_
"Current Value of '" + prop + "' is " + val, val)
If new_val <> val Then
oEditor.SetPropertyValue "Geometry3DCmdTab",_
"Box1:CreateBox:1", prop, new_val
val = _
7-12 Property Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

oEditor.SetPropertyValue("Geometry3DCmdTab",_
"Box1:CreateBox:1", prop)
MsgBox("Now the value of '" + prop + "' is " + val)
End If
Next

Example Use of Record Script and Edit Properties


A simple way to see how to format the string arguments for a design object or property of interest is to use the script recording command in HFSS, and then to edit the property. Open the
script file and look at the o.Editor.ChangeProperty entry to see the string arguments.
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 10.0
' 2:44 PM

Nov 18, 2005

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("wg_combiner")
Set oDesign = oProject.SetActiveDesign("HFSSModel1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DAttributeTab", Array("NAME:PropServers", _
"Polyline1"), Array("NAME:ChangedProps", Array("NAME:Display Wireframe",
"Value:=", true), Array("NAME:Display Wireframe", "Value:=", _
false), Array("NAME:Transparent", "Value:=", 0.2))))

Property Script Commands 7-13


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

7-14 Property Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Dataset Script Commands

Dataset commands should be executed by the oProject object.


Set oProject = oDesktop.SetActiveProject("Project1")
oProject.CommandName <args>
AddDataSet
DeleteDataSet
EditDataSet
ImportDataSet

Dataset Script Commands 8-1


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

AddDataset
Use:

Adds a dataset.

Command:

Project>Datasets>Add

Syntax:

AddDataset <DatasetDataArray>

Return Value:

None

Parameters:

<DatasetDataArray>
Array("NAME:<DatasetName>",
Array("NAME:Coordinates", <CoordinateArray>,
<CoordinateArray>, ...)
<DatasetName>
Type: <string>
Name of the dataset.
<CoordinateArray>
Array("NAME:Coordinate",
"X:=", <double>, "Y:=", <double>)

Example:
oProject.AddDataset Array("NAME:ds1",_
Array("NAME:Coordinates",_
Array("NAME:Coordinate", "X:=", 1, "Y:=", 2,_
Array("NAME:Coordinate", "X:=", 3, "Y:=", 4),_
Array("NAME:Coordinate", "X:=", 5, "Y:=", 7),_
Array("NAME:Coordinate", "X:=", 6, "Y:=", 20)))

DeleteDataset
Use:

Deletes the specified dataset.

Command:

Project>Datasets>Remove

Syntax:

DeleteDataset <DatasetName>

Return Value:

None

8-2 Dataset Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

EditDataset
Use:

Modifies a dataset. When a dataset is modified, its name as well as its data
can be changed.

Command:

Project>Datasets>Edit

Syntax:

EditDataset <OriginalName> <DatasetDataArray>

Return Value:

None

Parameters:

<OriginalName>
Type: <string>
Name of the dataset before editing.

Example:
oProject.EditDataset "ds1" Array("NAME:ds2",_
Array("NAME:Coordinates",_
Array("NAME:Coordinate", "X:=", 1, "Y:=", 2),_
Array("NAME:Coordinate", "X:=", 3, "Y:=", 4)))

ImportDataset
Use:

Imports a dataset from a named file.

Command:

Project>Dataset...>Import

Syntax:

ImportDataset <path>

Return Value:

None

Parameters:

<Path>
Type: <string>
Path of the dataset.

Example:
Set oProject = oDesktop.SetActiveProject("OptimTee")
oProject.ImportDataset "F:/work/BSR_1_dk.tab"

Dataset Script Commands 8-3


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

8-4 Dataset Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Design Object Script


Commands

Design object commands should be executed by the oDesign object.


oDesign.CommandName <args>
Conventions Used in this Chapter
<ModuleName>
Name used to access one of the following HFSS modules:

Boundary module: "BoundarySetup"


Mesh Operations module: "MeshSetup"
Analysis module: "AnalysisSetup"
Optimetrics module: "Optimetrics"
Solutions module: "Solutions"
Field Overlays module: "FieldsReporter"
Radiation module: "RadField"
ApplyMeshOps
Analyze
AnalyzeDistributed
AssignDCThickness
ConstructVariationString
DeleteLinkedDataVariation
ExportConvergence
Design Object Script Commands 9-1

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

ExportMeshStats
ExportProfile
GetEdit SourcesCount
GetModule
GetName
GetNominalVariation
GetSolutionType
GetSolveInsideThreshold
GetSourceContexts
GetVariationVariableValue
Redo
RenameDesignInstance
SARSetup
SetActiveEditor
SetDesignSettings
SetSolutionType
SetSolveInsideThreshold
SetSourceContexts
Solve
RunToolkit
Undo

9-2 Design Object Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

ApplyMeshOps
Use:

If there are any mesh operations that were defined and not yet performed
in the current variation for the specified solution setups, they will be
applied to the current mesh. If necessary, an initial mesh will be computed
first. No further analysis will be performed.

Command:

HFSS>Analysis Setup>Apply Mesh Operations

Syntax:

ApplyMeshOps <SetupNameArray>

Return Value:

<SetupNameArray>
Type: <int>
-1: completed with error
0: completed successfully

Example:
status = oDesign.ApplyMeshOps Array("Setup1","Setup2")

Analyze
Use:

Solves a single solution setup and all of its frequency sweeps.

Command:

Right-click a solution setup in the project tree, and then click Analyze on
the shortcut menu.

Syntax:

Analyze(<SetupName>)

Parameters:

<setupName>

Return Value:

None

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 12.0.0
' 2:54 PM Dec 15, 2008
' ---------------------------------------------Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Tee")
Design Object Script Commands 9-3
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Set oDesign = oProject.SetActiveDesign("TeeModel")


oDesign.Analyze "Setup1"

AnalyzeDistributed
Use:

Perform a distributed analysis.

Command:

None

Syntax:

AnalyzeDistributed <SetupName>

Return Value:

<AnalysisStatus>
Type: <int>
-1: completed with error
0: completed successfully

Parameters:

<SetupName>

Example:

For frequency sweeps:


oDesign.AnalyzeDistributed "Setup1"

AssignDCThickness
Use:

Assign DC Thickness to more accurately compute DC resistance of a thin


conducting object for which Solve Inside is not selected.

Command:

HFSS>Assign DC Thickness

Syntax:

AssignDCThickness Array(<ObjectName>) Array


(<ThicknessValue>) <string>

Return Value:

None

Parameters:

<ObjectName>
Type: <string>
Array of object names. Any objects not specified in the arguments are unchanged
after the command is processed.
<ThicknessValue>
Type: <real> or <string>, either Infinite or Effective.
Array of DC thickness values (including units) corresponding to each object name.
You can also specify an infinite thickness or have it calculated automatically.
<string>
Type: <string>
"EnableAuto" is equivalent to checking the checkbox in the second tab of the DC
thickness dialog. "DisableAuto" is equivalent to clearing that checkbox. Omitting the
string means leaves the checkbox unchanged.

Example:
9-4 Design Object Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Set oModule = oDesign.GetModule("BoundarySetup")


oModule.AssignDCThickness Array("Box2"), Array("1mm")
The following example includes the use of Automatic and Infinite settings.
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("hfss_uhf_probe")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignDCThickness Array("Arm_1", "Arm_2"), _
Array("" & Chr(34) & "<Effective>" & Chr(34) & "", _
"" & Chr(34) & "<Infinite>" & Chr(34) & "")

ConstructVariationString
Use:

Lists and orders the variables and values associated with a design variation.

Command:

None

Syntax:

ConstructVariationString(<ArrayOfVariableNames>,
<ArrayOfVariableValuesIncludingUnits>)

Return Value:

Returns variation string with the variables ordered to correspond to the


order of variables in design variations. The values for the variables are
inserted into the variation string.

Parameters:

<ArrayOfVariableNames>
Type: string
<ArrayOfVariableValuesIncludingUnits>
Type: string

Example:
varstring = oDesign.ConstructVariationString(Array("x_size", "y_size"), Array("2mm", "1mm"))
Design Object Script Commands 9-5
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

DeleteLinkedDataVariation
Use:

Deletes linked solution data, except field data, for the specified variations.

Syntax:

DeleteLinkedDataVariation
Array(<DesignVariationKey>, <DesignVariationKey>, )

Return Value:

None

Parameters:

<DesignVariationKey>
Type: <string>
Design variation string.

Example:
oDesign.DeleteLinkedDataVariation Array("gap_front=" &
Chr(39) & "0.2mm" & Chr(39) & " gap_up_down=" & Chr(39) &
"0.2mm" & Chr(39) & "")

ExportConvergence
Use:

Exports convergence data (max mag delta S, E, freq) to file for the given
variation.

Command:

None

Syntax:

ExportConvergence <SetupName>, <VariationString>,


<FilePath> <overwriteIfExists>

Return Value:

None

Parameters:

<SetupName>
Type: <string>
Example: "Setup1"
<VariationString>
Type: <string>
Example: "radius = 3mm"
The empty variation string ("") is interpreted to mean the current nominal variation.
<FilePath>
Type: <string>
Example: "c:\convergence.conv"
overwriteIfExists <Boolean>
If "overwriteIfExists" is TRUE, then the playback of the script overwrites an existing
file. If FALSE, it does not. The default is "TRUE".
Type: <string>
Example: overwriteIfExists=TRUE

9-6 Design Object Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:
oDesign.ExportConvergence "Setup1", "x_size = 2mm",
"c:\convergence.conv"

ExportMeshStats
Use:

Exports the mesh statistics to a file.

Command:

None.

Parameters:

<SetupName>
Type: <string>
Example: "Setup1"
<VariationString>
Type: <string>
Example: "radius = 3mm"
The empty variation string ("") is interpreted to mean the current nominal variation.
<FilePath>
Type: <string>
Example: "c:\convergence.conv"
overwriteIfExists <Boolean>
If "overwriteIfExists" is TRUE, then the playback of the script overwrites an existing
file. If FALSE, it does not. The default is "TRUE".
Type: <string>
Example: overwriteIfExists=TRUE

Example:
oDesign.ExportMeshStats "Setup1", "offset=" & Chr(39) &
"0.09in" & Chr(39) & "","C:\mydir\meshstats.ms" "tat"

ExportProfile
Use:

Exports a solution profile to file.

Syntax:

ExportProfile <SetupName>, <VariationString>, <FilePath>,


<overwriteIfExists>

Return Value:

None

Parameters:

<SetupName>
Type: <string>
Example: "Setup1"
<VariationString>
Design Object Script Commands 9-7

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Type: <string>
Example: "radius = 3mm"
The empty variation string ("") is interpreted to mean the current nominal variation.
<FilePath>
Type: <string>
Example: "c:\profile.prof"
overwriteIfExists <Boolean>
If "overwriteIfExists" is TRUE, then the playback of the script overwrites an existing
file. If FALSE, it does not. The default is "TRUE".
Type: <string>
Example: overwriteIfExists=TRUE
Example:
oDesign.ExportProfile "Setup1", "", "c:\profile.prof"

GetEdit SourcesCount
Use:

Returns the number of sources that are listed in the Edit Sources panel.

Command:

None

Syntax:

GetEditSources

Return Value:

<int>

Parameters:

None

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 15.0.0
' 7:37:36 AM

Jul 27, 2012

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject
9-8 Design Object Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Set oDesign = oProject.GetActiveDesign


Set oModule = oDesign.GetModule("Solutions")
Dim count
count = oModule.GetEditSourcesCount
MsgBox(count)

GetModule
Use:

Returns the IDispatch for the specified module.

Command:

none

Syntax:

GetModule <ModuleName>

Return Value:

Module object.

Example:
Set oModule = oDesign.GetModule "BoundarySetup"

GetName
Use:

Returns the name of the Design.

Command:

none

Syntax:

GetName

Return Value:

The name of the Design.


Type: <string>

Example:
name_string = oDesign.GetName

GetNominalVariation
Use:

Gets the nominal variation string

Command:

None

Syntax:

GetNominalVariation()

Return Value:

Returns a string representing the nominal variation

Parameters:

None

Example:
var = oDesign.GetNominalVariation()

Design Object Script Commands 9-9


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

GetSolutionType
Use:

Returns the solution type for the design. This command command does not
apply to HFSS-IE.

Command:

none

Syntax:

GetSolutionType

Return Value:

<SolutionType>
Type: <string>
Possible values are: "DrivenModal", "DrivenTerminal", "Eigenmode",
Transient or Transient Network.

Example:
oDesign.GetSolutionType

GetSolveInsideThreshold
Use:

Returns the solve inside threshold. This command command does not apply
to HFSS-IE.

Command:

none

Syntax:

GetSolveInsideThreshold

Return Value:

Double representing the solve inside threshold.

Example:
oDesign.GetSolveInsideThreshold

GetSourceContexts
Use:

Obtain sources currently enabled as context in the Edit Sources dialog


Source Context tab.

Command:

None

Syntax:

GetSource Contexts

Return Value:

Array of enabled source names

Parameters:

None

Example:
SetoModule = oDesign.GetModule(Solutions)
oModule.GetSourceContexts

GetVariationVariableValue
Use:

Finds the value of a variable for a specific variation string.

Command:

None

9-10 Design Object Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Syntax:

GetVariationVariableValue(<VariationString>,
<VariableName>)

Return Value:

Returns a double precision value in SI units, interpreted to mean the value


of the variable contained in the variation string.

Parameters:

<VariationString>
Type: string
<VariableName>
Type: string

Example:
Example: varval = _
oDesign.GetVariationVariableValue("x_size = 2mm y_size = 1mm",_
"y_size")

Redo [Design]
Use:

Reapplies the last design-level command.

Command:

Edit>Redo

Syntax:

Redo

Return Value:

None

Example:
oDesign.Redo

RenameDesignInstance
Use:

Renames a design instance.

Command:

Right click a design instance in the project tree, and then click Rename on
the shortcut menu.

Syntax:

RenameDesignInstance <OldName>, <NewName>

Return Value:

None

Example:
oDesign.RenameDesignInstance "HFSSDesign1", "HFSSDesign2"

SARSetup
Use:

Sets up for the specific absorption rate (SAR) computation.This command


command does not apply to HFSS-IE.

Command:

HFSS>Fields>SAR Setting

Syntax:

SARSetup <TissueMass>, <MaterialDensity>


Design Object Script Commands 9-11
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Return Value:

None

Parameters:

<TissueMass>
Type: <double>
Double between 1 and 10 in grams.
<MaterialDensity>
Type: <double>
Positive double in gram/cm3.

Example:
oDesign.SARSetup 1, 1

SetActiveEditor
Use:

Sets the active editor.

Command:

None

Syntax:

SetActiveEditor(<EditorName>)

Return Value:

Editor object

Example:
Set oEditor = oDesign.SetActiveEditor("3D Modeler")

SetDesignSettings
Use:

To set the design settings for materials override.

Command:

HFSS>Design Settings

Syntax:

SetDesignSettings <MaterialsOverrideArray>

Return Value:

None

Parameters:

<MaterialsOverrideArray>
Array("NAME:Design Settings Data",
"Allow Material Override:=", <Boolean>,
"Calculate Lossy Dielectrics:=", <Boolean>)

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
9-12 Design Object Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")


Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project53")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
oDesign.SetDesignSettings Array("NAME:Design Settings Data",
"Allow Material Override:=", true,
"Calculate Lossy Dielectrics:=", true)

SetSolutionType
Use:

Sets the solution type for the design. This command command does not
apply to HFSS-IE.

Command:

HFSS>Solution Type

Syntax:

SetSolutionType <SolutionType>

Return Value:

None

Parameters:

<SolutionType>
Type: <string>
Possible values are: "DrivenModal", "DrivenTerminal", Transient, Transient Network, or "Eigenmode"

Example:
oDesign.SetSolutionType "DrivenTerminal"

SetSolveInsideThreshold
Use:

Set the solve inside threshold to the supplied double. This command
command does not apply to HFSS-IE.

Command:

None

Syntax:

SetSolveInsideThreshold(<threshold>)

Return Value:

None

Parameters:

<threshold>
Type: <double>
Siemens/m

Example:
oDesign.SetSolveInsideThreshold(100000)

Design Object Script Commands 9-13


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

SetSourceContexts
Use:

For Near or Far Field projects for Driven Modal or Driven Terminal Network
Analysis Solutions, specify the port name and all modes/terminals of that
port to be enabled as Source Context.

Command:

Fields>Edit Sources

Syntax:

SetSourceContexts Array(<sourceID>,...)

Return Value:

None.

Parameters:

<sourceID>
Type: <string>

Example:
SetoModule = oDesign.GetModule(Solutions)
oModule.SetSourceContexts Array(Box1_T1, Box1_T2,
Box1_T3, Current1, IncPWave1)

Solve
Use:

Performs a blocking simulation. The next script command will not be


executed until the simulation is complete.

Command:

HFSS>Analyze

Syntax:

Solve <SetupNameArray>

Return Value:

Type: <int>
-1: simulation error
0: normal completion

Parameters:

<SetupNameArray>: Array(<SetupName>, <SetupName>, ...)


<SetupName>
Type: <string>
Name of the solution setup to solve.

Example:
return_status = oDesign.Solve Array("Setup1", "Setup2")

RunToolkit
Use:

Run a Python toolkit script, applying it to the Active Project. The script
itself may have prerequisites, such as sweeps defined, or specific model
characteristics, such as port definitions.

Command:

HFSS>Toolkit><IronPythonScript>

Syntax:

RunToolkit "<LibName>", "<IronPythonScriptName>", Array()

Return Value:

User Defined Solutions and user Defined Outputs.

9-14 Design Object Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Parameters:

<LibName>
Type: <string>
Name of the library in which the script is located.
<IronPythonScriptName>
Type: <string>
Name of the IronPython script.
Array(<array>)
Type: <Array>
Additional parameters or files required by the script.

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 16.0.0
' 10:12:18 AM

May 14, 2013

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("test_HAC")
Set oDesign = oProject.SetActiveDesign("RCS1")
oDesign.RunToolkit "SysLib", "HearingAidCompliance", Array()
Set oModule = oDesign.GetModule("AnalysisSetup")
oModule.InsertFrequencySweep "Setup1", Array("NAME:Sweep", "IsEnabled:=", true, "SetupType:=", _
"LinearStep", "StartValue:=", "1GHz", "StopValue:=", "10GHz",
"StepSize:=", _
"0.1GHz", "Type:=", "Interpolating", "SaveFields:=", false, "SaveRadFields:=", _
false, "InterpTolerance:=", 0.5, "InterpMaxSolns:=", 250, "InterpMinSolns:=", _

Design Object Script Commands 9-15


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

0, "InterpMinSubranges:=", 1, "ExtrapToDC:=", false, "InterpUseS:=", true, "InterpUsePortImped:=", _


false, "InterpUsePropConst:=", true, "UseDerivativeConvergence:=",
false, "InterpDerivTolerance:=", _
0.2, "UseFullBasis:=", true, "EnforcePassivity:=", true, "PassivityErrorTolerance:=", _
0.0001)

Undo [Design]
Use:

Cancels the last design-level command.

Command:

Edit>Undo

Syntax:

Undo

Return Value:

None

Example:
oDesign.Undo

9-16 Design Object Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

10

Model Setup Script


Commands

Model Setup Script Commands should be executed by:


Set oModule = oDesign.GetModule("ModelSetup")
These commands are:
AssignArray
DeleteArray
EditArray

Model Setup Script Commands 10-1


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Assign Array
Use:

Create an array based on a unit cell model.

Command:

HFSS>Model>Create Array

Syntax:

AssignArray <arrayParameters>

Return Value:

None

Parameters:

Aray(NAME:<string>",
"Type:=", "Regular",
"Name:=", "<string>",
"UseAirObjects:=", <boolean>,
"RowMasterBnd:=", "Master<n>",
"ColumnMasterBnd:=", "Master<n>",
"RowDimension:=", <value>,
"ColumnDimension:=", <value>,
"PostProcessRow:=", <value>,
"PostProcessCol:=", <value>,
"Active:=", "All" | [<arraycoords>] |"None" )

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 14.0.0
' 1:42:56 PM

Mar 03, 2011

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("terminalArray")
Set oDesign = oProject.SetActiveDesign("HFSSDesign")
Set oModule = oDesign.GetModule("ModelSetup")
oModule.AssignArray Array("NAME:A",
10-2 Model Setup Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Type:=", "Regular",
"Name:=", "A",
"UseAirObjects:=", true,
"RowMasterBnd:=", "Master1",
"ColumnMasterBnd:=", "Master2",
"RowDimension:=", 2,
"ColumnDimension:=", 2,
"PostProcessRow:=", 1,
"PostProcessCol:=", 1,
"Active:=", "All")

DeleteArray
Use:

Delete an existing array based on a unit cell model.

Command:

Delete

Syntax:

DeleteArray

Return Value:

None

Parameters:

None

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 14.0.0
' 10:22:10 AM

Feb 23, 2011

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("forcreatearraycube")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("ModelSetup")
oModule.DeleteArray
Model Setup Script Commands 10-3
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

EditArray
Use:

To edit properties of an existing array.

Command:

Properties

Syntax:

EditArray <arrayParameters>

Return Value:

None

Parameters:

Aray(NAME:<string>",
"Type:=", "Regular",
"Name:=", "<string>",
"UseAirObjects:=", <boolean>,
"RowMasterBnd:=", "Master<n>",
"ColumnMasterBnd:=", "Master<n>",
"RowDimension:=", <value>,
"ColumnDimension:=", <value>,
"PostProcessRow:=", <value>,
"PostProcessCol:=", <value>,
"Active:=", "All" | [<arraycoords>] |"None" )

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 14.0.0
' 1:42:56 PM

Mar 03, 2011

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("terminalArray")
Set oDesign = oProject.SetActiveDesign("HFSSDesign")
Set oModule = oDesign.GetModule("ModelSetup")
oModule.EditArray Array("NAME:A",
10-4 Model Setup Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Type:=", "Regular",
"Name:=", "A",
"UseAirObjects:=", true,
"RowMasterBnd:=", "Master1",
"ColumnMasterBnd:=", "Master2",
"RowDimension:=", 2,
"ColumnDimension:=", 3,
"PostProcessRow:=", 1,
"PostProcessCol:=", 3,
"Active:=", "[0,0], [0,1], [0,2]")

Model Setup Script Commands 10-5


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

10-6 Model Setup Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

11

3D Modeler Editor Script


Commands

3D Modeler commands should be executed by the "3D Modeler" editor.


Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.CommandName <args>
Conventions Used in this Chapter
<Attributes Array>
Array("NAME:Attributes",
"Name:=", <string>,
"Flags:=", <string>,
"Color:=", <string>,
"Transparency:=", <value>,
"PartCoordinateSystem:=", <string>,
"MaterialName:=", <string>,
"Solveinside:=", <bool>)
Flags
Format is a string containing any of the following flags separated by the # character:

NonModel
Wireframe
Example: "Flags:=", "NonModel#Wireframe"

3D Modeler Editor Script Commands 11-1


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Color
Format is a string containing an R,G,B triple formatted as "(R G B)".
Example: "Color:=",

"(255

255

255)"

Transparency
Specify a number between 0 and 1.
PartCoordinateSystem
Orientation of the primitive. The name of one of the defined coordinate systems
should be specified.
<SelectionsArray>
Array("NAME:Selections",
"Selections:=", <string>)
Selections
Comma-separated list of parts on which to perform the operation.
Example: "Selections:=", "Rect1, Rect2"
Draw Menu Commands
Edit Menu Commands
Modeler Menu Commands
Other oEditor Commands

Draw Menu Commands


CreateBondWire
CreateBox
CreateCircle
CreateCone
CreateCutplane
CreateCylinder
CreateEllipse
CreateEquationCurve
CreateEquationSurface
CreateHelix
CreatePoint
CreatePolyline
11-2 3D Modeler Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

CreateRectangle
CreateRegion
CreateRegularPolyhedron
CreateRegularPolygon
CreateSphere
CreateSpiral
CreateTorus
EditPolyline
SweepAlongPath
SweepAlongVector
SweepAroundAxis

CreateBondwire
Use:

Creates a bondwire primitive.

Command:

Draw>Bondwire

Syntax:

CreateBondwire <ParametersArray>, <AttributesArray>

Return Value:

The name of the newly created object.

Parameters:

<ParametersArray>
Array("NAME:BondwireParameters",
"WireType:=", <string>,
"WireDiameter:=", <value>,
"NumSides:=", <value>,
"XPadPos:=", <value>,
"YPadPos:=", <value>,
"ZPadPos:=", <value>,
"XDir:=", <value>,
"YDir:=", <value>,
"ZDir:=", <value>,
"Distance:=", <value>,
"h1:=", <value>,
"h2:=", <value>,
"alpha:=", <value>,
"beta:=", <value>,
"WhichAxis:=", <string>)
WireType
3D Modeler Editor Script Commands 11-3

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Should be one of: "JEDEC_4Points", "JEDEC_5Points"


Example: "WireType:=", "JEDEC_4Points"
WhichAxis
Axis normal to the plane where the wire is drawn. Possible values are: "X", "Y",
"Z"
Example: "WhichAxis:=", "Z" means the bond wire will be drawn on the XY
plane.

CreateBox
Use:

Creates a box primitive.

Command:

Draw>Box

Syntax:

CreateBox <BoxParametersArray>, <AttributesArray>

Return Value:

The name of the newly created object.

Parameters:

<BoxParametersArray>
Array("NAME:BoxParameters",
"XPosition:=", <value>,
"YPosition:=", <value>,
"ZPosition:=", <value>,
"XSize:=",<value>,
"YSize:=",<value>,
"ZSize:=",<value>)

Example:
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.CreateBox Array("NAME:BoxParameters", _
"CoordinateSystemID:=", -1, "XPosition:=",

"1mm", "YPosition:=", "1mm", "ZPosition:=", "0mm", _


"XSize:=", "1mm", "YSize:=", "1mm", "ZSize:=", "1mm"),_
Array("NAME:Attributes", "Name:=", "Box1", "Flags:=", "", _
"Color:=", "(132 132 193)", "Transparency:=", 0, _
"PartCoordinateSystem:=", "Global", "MaterialName:=",

"vacuum", "SolveInside:=", true)_


oEditor.DuplicateAlongLine Array("NAME:Selections",
"Selections:=", "Box1"), _
Array("NAME:DuplicateToAlongLineParameters",_
"CoordinateSystemID:=", -1, "CreateNewObjects:=", true, _
11-4 3D Modeler Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"XComponent:=", "1mm", "YComponent:=", "1mm", "ZComponent:=",

"0mm", "NumClones:=", "2"), _


Array("NAME:Options", "DuplicateBoundaries:=", true)

CreateCircle
Use:

Creates a circle primitive.

Command:

Draw>Circle

Syntax:

CreateCircle <CircleParametersArray>, <AttributesArray>

Return Value:

The name of the newly created object.

Parameters:

<CircleParametersArray>
Array("NAME:CircleParameters",
"XCenter:=", <value>,
"YCenter:=", <value>,
"ZCenter:=", <value>,
"Radius:=", <value>,
"WhichAxis:=", <string>
"NumSegments:=", "<integer>")
WhichAxis
Axis of normal vector to the circle. Possible values are: "X", "Y", "Z"
Example: "WhichAxis:=", "Z" means the circle will be drawn in the
XY plane.

CreateCone
Use:

Creates a cone primitive.

Command:

Draw>Cone

Syntax:

CreateCone <ConeParametersArray>, <AttributesArray>

Return Value:

The name of the newly created object.

Parameters:

<ConeParametersArray>
Array("NAME:ConeParameters",
"XCenter:=", <value>,
"YCenter:=", <value>,
"ZCenter:=", <value>,
"WhichAxis:=", <string>,
"Height:=", <value>,
3D Modeler Editor Script Commands 11-5

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"BottomRadius:=", <value>,
"TopRadius:=", <value>)
WhichAxis
Axis of the cone. Possible values are: "X", "Y", "Z"
Example: "WhichAxis:=", "Z"

CreateCutplane
Use:

Creates a cutplane. Only the name and color attributes from


<AttributesArray> are supported.

Command:

Draw>Plane

Syntax:

CreateCutplane <CutplaneParametersArray>,
<AttributesArray>

Return Value:

The name of the newly created object.

Parameters:

<CutplaneParametersArray>
Array("NAME:PlaneParameters",
"PlaneBaseX:=", <value>,
"PlaneBaseY:=", <value>,
"PlaneBaseZ:=", <value>,
"PlaneNormalX:=", <value>,
"PlaneNormalY:=", <value>),
"PlaneNormalZ:=", <value>)

CreateCylinder
Use:

Creates a cylinder primitive.

Command:

Draw>Cylinder

Syntax:

CreateCylinder <CylinderParametersArray>,

Return Value:

The name of the newly created object.

Parameters:

<CylinderParametersArray>

<AttributesArray>

Array("NAME:CylinderParameters",
"XCenter:=", <value>,
"YCenter:=", <value>,
"ZCenter:=", <value>,
"Radius:=", <value>,
11-6 3D Modeler Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Height:=", <value>,
"WhichAxis:=", <string>
"NumSides:=", "<integer>")
WhichAxis
Axis of the cylinder. Possible values are: "X", "Y", "Z"
Example: "WhichAxis:=", "Z"

CreateEllipse
Use:

Creates an ellipse primitive.

Command:

Draw>Ellipse

Syntax:

CreateEllipse <EllipseParametersArray>, <AttributesArray>

Return Value:

The name of the newly created object.

Parameters:

<EllipseParametersArray>
Array("NAME:EllipseParameters",
"XCenter:=", <value>,
"YCenter:=", <value>,
"ZCenter:=", <value>,
"MajRadius:=", <value>,
"Ratio:=", <value>,
"WhichAxis:=", <string>
"NumSegments:=", "<integer>")
WhichAxis
Axis of normal vector to the ellipse. Possible values are: "X", "Y", "Z"
Example: "WhichAxis:=", "Z" means the ellipse will be drawn in the XY
plane.

CreateEquationCurve
Use:

Create an equation-based curve.

Command:

Draw>Equation Based Curve

Syntax:

CreateEquationCurve Array <Parameters> Array<Attributes>

Return Value:

None

Parameters:
Array("NAME:EquationBasedCurveParameters",
3D Modeler Editor Script Commands 11-7
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"XtFunction:=", "<value>",
"YtFunction:=", "<value>",
"ZtFunction:=", "<value>",
"tStart:=", "<value>",
"tEnd:=", "<value>",
"NumOfPointsOnCurve:=", "<value>",
"Version:=", <ID>),
Array("NAME:Attributes",
"Name:=", "<textn>",
"Flags:=", "",
"Color:=", "(<int> <int> <int>)",
"Transparency:=", <value>,
"PartCoordinateSystem:=", "<id>",
"UDMId:=", "",
"MaterialValue:=", "" & Chr(34)
& "vacuum"
& Chr(34) & "",
"SolveInside:=", <boolean>)
Example:

CreateEquationSurface
Use:

Create an equation based surface.

Command:

Draw>Create Equation Based Surface

Syntax:

CreateEquationSurface Array <parameters> Array


<attributes>

Return Value:
Parameters:
Array("NAME:EquationBasedSurfaceParameters",
"XuvFunction:=", "1",
"YuvFunction:=", "1",
"ZuvFunction:=", "1",
"uStart:=", "2",
"uEnd:=", "2",
"vStart:=", "2",
"vEnd:=", "2",
11-8 3D Modeler Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Version:=", 1),
Array("NAME:Attributes", "Name:=", "EquationSurface1",
"Flags:=", "",
"Color:=", "(132 132 193)",
"Transparency:=", 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=", "",
"MaterialValue:=", ""
& Chr(34)
& "vacuum"
& Chr(34)
& "", "SolveInside:=", true)
Example:

CreateHelix
Use:

Creates a helix by sweeping the specified 2D objects.

Command:

Draw>Helix

Syntax:

CreateHelix <SelectionsArray>, <HelixParametersArray>

Return Value:

The name of the newly created object.

Parameters:

<SelectionsArray>
Array("NAME:Selections",
"Selections:=", <string>)
Selections
Comma-separated list of parts to sweep.
Example: "Selections:=", "Rect1, Rect2"
<HelixParametersArray>
Array("NAME:HelixParameters",
"XCenter:=", <value>,
"YCenter:=", <value>,
"ZCenter:=", <value>,
"XStartDir:=", <value>,
"YStartDir:=", <value>,
"ZStartDir:=", <value>,
3D Modeler Editor Script Commands 11-9

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Thread:=", <value>,
"NumThread:=", <value>,
"RightHand:=", <bool>)

CreatePoint
Use:

Creates a point. Only the name and color attributes from


<AttributesArray> are supported.

Command:

Draw>Point

Syntax:

CreatePoint <PointParametersArray>, <AttributesArray>

Return Value:

The name of the newly created object.

Parameters:

<PointParametersArray>
Array("NAME:PointParameters",
"PointX:=", <value>,
"PointY:=", <value>,
"PointZ:=", <value>)

CreatePolyline
Use:

Creates a polyline primitive.

Command:

Draw>Polyline

Syntax:

CreatePolyline <PolylineParametersArray>,
<AttributesArray>

Return Value:

The name of the newly created object.

Parameters:

<PolylineParametersArray>
Array("NAME:PolylineParameters",
"IsPolylineCovered:=", <bool>,
"IsPolylineClosed:=", <bool>,
<PolylinePointsArray>,
<PolylineSegmentsArray>)
<PolylinePointsArray>
Array("NAME:PolylinePoints", <OnePointArray>,
<OnePointArray>, ...)
<OnePointArray>
Array("NAME:PLPoint",

11-10 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"X:=", <value>,
"Y:=", <value>,
"Z:=", <value>))
<PolylineSegmentsArray>
Array("NAME:PolylineSegments",
<OneSegmentArray>, <OneSegmentArray>, ...)
<OneSegmentArray>
Array("NAME:PLSegment",
"SegmentType:=", <string>,
"StartIndex:=", <value>,
"NoOfPoints:=", <value>)
SegmentType
Can be "Line", "Arc", "Spline", or "AngularArc"
Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 14.0.0
' 9:49:26 AM

Mar 09, 2011

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project58")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")

3D Modeler Editor Script Commands 11-11


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

oEditor.CreatePolyline Array("NAME:PolylineParameters",
"IsPolylineCovered:=", true,
"IsPolylineClosed:=", false,
Array("NAME:PolylinePoints",
Array("NAME:PLPoint", "X:=", "1.4mm",
"Y:=", "-2mm",
"Z:=", "0mm"),
Array("NAME:PLPoint", "X:=", "0mm", "Y:=", "-2mm", "Z:=", "0mm"),
Array("NAME:PLPoint", "X:=", "-0.8mm", "Y:=", "-1.6mm",
"Z:=", "0mm"),
Array("NAME:PLPoint", "X:=", "-1.4mm", "Y:=", "-0.6mm",
"Z:=", "0mm")),
Array("NAME:PolylineSegments", Array("NAME:PLSegment",
"SegmentType:=", "Line",
"StartIndex:=", 0, "NoOfPoints:=", 2),
Array("NAME:PLSegment", "SegmentType:=", "Line",
"StartIndex:=", 1, "NoOfPoints:=", 2),
Array("NAME:PLSegment", "SegmentType:=", "Line", "StartIndex:=", 2,
"NoOfPoints:=", 2)),
Array("NAME:PolylineXSection", "XSectionType:=", "None",
"XSectionOrient:=", "Auto", "XSectionWidth:=", "0mm",
"XSectionTopWidth:=", "0mm", "XSectionHeight:=", "0mm",
"XSectionNumSegments:=", "0", "XSectionBendType:=", "Corner")),
Array("NAME:Attributes", "Name:=", "Polyline2", "Flags:=", "",
"Color:=", "(132 132 193)",
"Transparency:=", 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=", "", "MaterialValue:=", ""
& Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=", true)

CreateRectangle
Use:

Creates a rectangle primitive.

Command:

Draw>Rectangle

Syntax:

CreateRectangle <RectangleParametersArray>,
<AttributesArray>

Return Value:

The name of the newly created object.

11-12 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Parameters:

<RectangleParametersArray>
Array("NAME:RectangleParameters",
"XStart:=", <value>,
"YStart:=", <value>,
"ZStart:=", <value>,
"Width:=", <value>,
"Height:=", <value>,
"WhichAxis:=", <string>)
WhichAxis
Axis of normal vector to the rectangle. Possible values are: "X", "Y", "Z"
Example: "WhichAxis:=", "Z" means the rectangle will be drawn in
the XY plane.

CreateRegion
Use:

Defines a region containing the design.

Command:

Draw>Create Region

Syntax:

CreateRegion <RegionParameters> <RegionAttributes>

Return Value:

The name of the newly created object.

Parameters:

<RegionParameters>
Array("NAME:RegionParameters", _
"+XPaddingType:=", <Offset_Type>,
"+XPadding:=", "<X_value>", _
"-XPaddingType:=", <Offset_Type>,
"-XPadding:=", "<-X_value>", _
"+YPaddingType:=", <Offset_Type>,
"+YPadding:=", "<Y_value>",
"-YPaddingType:=", <Offset_Type>,
"-YPadding:=", "<-Y_value>", _
"+ZPaddingType:=", <Offset_Type>,
"+ZPadding:=", "<Z_value>", _
"-ZPaddingType:=", <Offset_Type>,
"-ZPadding:=", "<-Z_value>")
<Offset_Type>
Type: String
3D Modeler Editor Script Commands 11-13

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Can be one of:


"Percentage Offset",
"Absolute Offset",
"Absolute Position",
<RegionAttributes>
Array("NAME:Attributes",
"Name:=", "Region", _
"Flags:=", "Wireframe<# or >", _
"Color:=", "(<red_int> <green_int> <blue_int>)", _
"Transparency:=", <real>, _
"PartCoordinateSystem:=", "<ID>", _
"MaterialName:=", "<MaterialName>", _
"SolveInside:=", <Boolean>)
Example:
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.CreateRegion Array("NAME:RegionParameters",
"+XPaddingType:=", "Absolute Offset", _
"+XPadding:=", "1um", _
"-XPaddingType:=", "Absolute Offset", _
"-XPadding:=", "1um", _
"+YPaddingType:=", "Absolute Offset", _
"+YPadding:=", "1um",
"-YPaddingType:=", "Absolute Offset", _
"-YPadding:=", "1um", _
"+ZPaddingType:=", "Absolute Offset", _
"+ZPadding:=", "1um", _
"-ZPaddingType:=", "Absolute Offset", _
"-ZPadding:=", "1um"),
Array("NAME:Attributes", "Name:=",

"Region", "Flags:=", "Wireframe#", _


"Color:=", "(255 0 0)", _
"Transparency:=", 0, _
"PartCoordinateSystem:=", "Global", _
"MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", _
"SolveInside:=", true)
11-14 3D Modeler Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

CreateRegularPolyhedron
Use:

Creates a regular polyhedron primitive.

Command:

Draw>Regular Polyhedron

Syntax:

CreateRegularPolyhedron <PolyhedronParametersArray>,

Return Value:

The name of the newly created object.

Parameters:

<PolyhedronParametersArray>

<AttributesArray>

Array("NAME:PolyhedronParameters",
"XCenter:=", <value>,
"YCenter:=", <value>,
"ZCenter:=", <value>,
"XStart:=",

<value>,

"YStart:=",

<value>,

"ZStart:=",

<value>,

"Height:=",

<value>,

"NumSides:=", <value>,
"WhichAxis:=", <string>)
NumSides:
Specify a number greater than 2.
WhichAxis
Axis of the polyhedron. Possible values are: "X", "Y", "Z"
Example: "WhichAxis:=", "Z"

CreateRegularPolygon
Use:

Creates a regular polygon primitive.

Command:

Draw>RegularPolygon

Syntax:

CreateRegularPolygon <PolygonParametersArray>,
<AttributesArray>

Return Value:

The name of the newly created object.

Parameters:

<PolygonParametersArray>
Array("NAME:RegularPolygonParameters",
"XCenter:=",<value>,
3D Modeler Editor Script Commands 11-15

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"YCenter:=",<value>,
"ZCenter:=",<value>,
"XStart:=", <value>,
"YStart:=", <value>,
"ZStart:=", <value>,
"NumSides:=", "12",
"WhichAxis:=", <string>)
NumSides
Specify a number greater than 2.
WhichAxis
Axis of normal vector to the polygon. Possible values are: "X", "Y", "Z"
Example: "WhichAxis:=", "Z" means the polygon will be drawn in the XY
plane.

CreateSphere
Use:

Creates a sphere primitive.

Command:

Draw>Sphere

Syntax:

CreateSphere <SphereParametersArray>, <AttributesArray>

Return Value:

The name of the newly created object.

Parameters:

<SphereParametersArray>
Array("NAME:SphereParameters",
"XCenter:=", <value>,
"YCenter:=", <value>,
"ZCenter:=", <value>,
"Radius:=", <value>)

CreateSpiral
Use:

Creates a spiral by sweeping the specified 2D objects.

Command:

Draw>Spiral

Syntax:

CreateSpiral <SelectionsArray>, <SpiralParametersArray>

Return Value:

The name of the newly created object.

Parameters:

<SelectionsArray>
Array("NAME:Selections",

11-16 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Selections:=", <string>)
Selections
Comma separated list of parts to sweep.
Example: "Selections:=", "Rect1, Rect2"
<SpiralParametersArray>
Array("NAME:SpiralParameters",
"XCenter:=", <value>,
"YCenter:=", <value>,
"ZCenter:=", <value>,
"XStartDir:=", <value>,
"YStartDir:=", <value>,
"ZStartDir:=", <value>,
"NumThread:=", <value>,
"RightHand:=", <bool>,
"RadiusIncrement:=", <value>)

CreateTorus
Use:

Creates a torus primitive.

Command:

Draw>Torus

Syntax:

CreateTorus <TorusParametersArray>, <AttributesArray>

Return Value:

The name of the newly created object.

Parameters:

<TorusParametersArray>
Array("NAME:TorusParameters",
"XCenter:=", <value>,
"YCenter:=", <value>,
"ZCenter:=", <value>,
"MajorRadius:=", <value>,
"MinorRadius:=", <value>,
"WhichAxis:=", <string>)
WhichAxis
Axis of the torus. Possible values are: "X", "Y", "Z"
Example: "WhichAxis:=", "Z"
3D Modeler Editor Script Commands 11-17

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

EditPolyline
Use:

Modifies a polyline primitive. Specify the name of the polyline to modify and
the new set of data for the polyline.

Command:

Draw>Line Segment>Insert Segment Before>Straight


Draw>Line Segment>Insert Segment Before>Spline
Draw>Line Segment>Insert Segment Before>3 Point Arc
Draw>Line Segment>Insert Segment Before>Center Point Arc
Draw>Line Segment>Insert Segment After>Straight
Draw>Line Segment>Insert Segment After>Spline
Draw>Line Segment>Insert Segment After>3 Point Arc
Draw>Line Segment>Insert Segment After>Center Point Arc
Edit>Delete Start Point
Edit>Delete End Point.

Syntax:

EditPolyline <SelectionsArray>,
<PolylineParametersArray>,

Return Value:

None

Parameters:

<SelectionsArray>
Array("NAME:Selections",
"Selections:=", "string")
Selections
Name of the polyline to modify. The name should be formatted as
"<PolylineName>:CreatePolyline:1".
Example: "Selections:=", "Polyline1:CreatePolyline:1"

InsertPolylineSegment
Use:

Inserts a polyline segment either before or after an existing segment of a


polyline primitive.

Command:

Draw>Line Segment>Insert Segment Before>Straight


Draw>Line Segment>Insert Segment Before>Spline
Draw>Line Segment>Insert Segment Before>3 Point Arc
Draw>Line Segment>Insert Segment Before>Center Point Arc
Draw>Line Segment>Insert Segment After>Straight
Draw>Line Segment>Insert Segment After>Spline
Draw>Line Segment>Insert Segment After>3 Point Arc

11-18 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Draw>Line Segment>Insert Segment After>Center Point Arc


Syntax:

InsertPolylineSegment <InsertPolylineSegmentArray>

Return Value:

None

Parameters:

<InsertPolylineSegmentArray>
Array("Name:Insert Polyline Segment",
"Selections:=", <string>,
"Segment Index:=", <value>,
"At Start:=", <bool>,
"SegmentType:=", <string>
<PolylinePointsArray>)
<PolylinePointsArray>
Array("Name:Polyline Points", <OnePointArray>,
<OnePointArray>, ...)
<OnePointArray>
Array("Name:PLPoint",
"X:=", <value>,
"Y:=", <value>,
"Z:=", <value>)
Selections
Name of the polyline to modify. The name should be formatted as
"<PolylineName>:CreatePolyline:1".
Example: "Selections:=", "Polyline1:CreatePolyline:1"
SegmentType
Can be "Line", "Arc", "Spline", or "AngularArc"

SweepAlongPath
Use:

Sweeps the specified 1D or 2D parts along a path. The last 1D object


specified is the path for the sweep.

Command:

Draw>Sweep>Along Path

Syntax:

SweepAlongPath <SelectionsArray>,
<PathSweepParametersArray>
3D Modeler Editor Script Commands 11-19
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Return Value:

None

Parameters:

<PathSweepParametersArray>
Array("NAME:PathSweepParameters",
"DraftAngle:=", <value>,
"DraftType:=", <string>,
"TwistAngle:=", <value>)
DraftType
Possible values are "Extended", "Round", "Natural"

Example:

oEditor.SweepAlongPath _
Array("NAME:Selections", "Selections:=",
"Polygon1,Polyline1"),_
Array("NAME:PathSweepParameters", _
"DraftAngle:=", "0deg",_
"DraftType:=", "Round",_
"TwistAngle:=", "30deg")

SweepAlongVector
Use:

Sweeps the specified 1D or 2D parts along a vector.

Command:

Draw>Sweep>Along Vector

Syntax:

SweepAlongVector <SelectionsArray>,

Return Value:

None

Parameters:

<VecSweepParametersArray>

<VecSweepParametersArray>

Array("NAME:VectorSweepParameters",
"DraftAngle:=", <value>,
"DraftType:=", <string>,
"SweepVectorX:=", <value>, _
"SweepVectorY:=", <value>,
"SweepVectorZ:=", <value)
DraftType
Possible values are "Extended", "Round", "Natural"

11-20 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

SweepAroundAxis
Use:

Sweeps the specified 1D or 2D parts around an axis.

Command:

Draw>Sweep>Around Axis

Syntax:

SweepAroundAxis <SelectionsArray>,
<AxisSweepParametersArray>

Return Value:

None

Parameters:

<AxisSweepParametersArray>
Array("NAME:AxisSweepParameters",
"DraftAngle:=",

<value>,

"DraftType:=", <string>,
"SweepAxis:=", <string>,
"SweepAngle:=", <value>)
DraftType
Possible values are "Extended", "Round", "Natural"
SweepAxis
Possible values are "X", "Y", "Z"

Edit Menu Commands


Copy
DeletePolyLinePoint
DuplicateAlongLine
DuplicateAroundAxis
DuplicateMirror
Mirror
Move
OffsetFaces
Paste
Rotate
Scale

Copy
Use:

Copies specified parts.

Command:

Edit>Copy
3D Modeler Editor Script Commands 11-21

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Syntax:

Copy <SelectionsArray>

Return Value:

None

DeletePolylinePoint
Use:

Deletes either a start or end point from an existing polyline segment.

Command:

Edit>Delete Start Point


Edit>Delete End Point

Syntax:

DeletePolylinePoint <DeletePointArray>

Return Value:

None

Parameters:

<DeletePointArray>
Array("Name:Delete Point",
"Selections:=", <string>,
"Segment Index:=", <value>,
"At Start:=", <bool>)
Selections
Name of the polyline to modify. The name should be formatted as
"<PolylineName>:CreatePolyline:1".
Example: "Selections:=", "Polyline1:CreatePolyline:1"

DuplicateAlongLine
Use:

Duplicates specified parts along line.

Command:

Edit>Duplicate>Along Line

Syntax:

DuplicateAlongLine <SelectionsArray>,
<DupLineParametersArray> <DupBoundariesArray>

Return Value:

None

Parameters:

<DupLineParametersArray>
Array("NAME:DuplicateToAlongLineParameters",
"XComponent:=", <value>,
"YComponent:=", <value>,
"ZComponent:=", <value>,
"NumClones:=", <value>)
NumClones
Specify a number greater than 1.

11-22 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<DupBoundariesArray>
Array("NAME:Options", "DuplicateBoundaries:=", <bool>)
Example:
oEditor.DuplicateAlongLine Array("NAME:Selections", _
"Selections:=", "Box1", _
"NewPartsModelFlag:=", "Model"), _
Array("NAME:DuplicateToAlongLineParameters", _
"CreateNewObjects:=", true, "XComponent:=", "0mm", _
"YComponent:=", "1.2mm", _
"ZComponent:=", "0mm", _
"NumClones:=", "2"), _
Array("NAME:Options", "DuplicateBoundaries:=", false)

DuplicateAroundAxis
Use:

Duplicates specified parts around an axis.

Command:

Edit>Duplicate>Around Axis

Syntax:

DuplicateAroundAxis <SelectionsArray>,

Return Value:

None

Parameters:

<DupAxisParametersArray>

<DupAxisParametersArray> <DupBoundariesArray>

Array("NAME:DuplicateAroundAxisParameters",
"WhichAxis:=", <string>,
"AngleStr:=", <value>,
"NumClones:=",<value>)
WhichAxis
Axis to duplicate around. Possible values are: "X", "Y", "Z"
Example: "WhichAxis:=", "Z"
NumClones:
Specify a number greater than 1.
<DupBoundariesArray>
Array("NAME:Options", "DuplicateBoundaries:=", <bool>)

3D Modeler Editor Script Commands 11-23


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:
oEditor.DuplicateAroundAxis Array("NAME:Selections", _
"Selections:=", "Box1", _
"NewPartsModelFlag:=", "Model"), _
Array("NAME:DuplicateAroundAxisParameters", _
"CreateNewObjects:=", false, _
"WhichAxis:=", "Z", _
"AngleStr:=", "90deg", _
"NumClones:=", "2"), _
Array("NAME:Options", "DuplicateBoundaries:=", false)

DuplicateMirror
Use:

Duplicate specified parts according to a mirror plane.

Command:

Edit>Duplicate>Mirror

Syntax:

DuplicateMirror <SelectionsArray>,
<DupMirrorParametersArray>

Return Value:

None

Parameters:

<DupMirrorParametersArray>
Array("NAME:DuplicateToMirrorParameters",
"DuplicateMirrorBaseX:=", <value>,
"DuplicateMirrorBaseY:=", <value>,
"DuplicateMirrorBaseZ:=", <value>,
"DuplicateMirrorNormalX:=", <value>,
"DuplicateMirrorNormalY:=", <value>,
"DuplicateMirrorNormalZ:=", <value>)
<DupBoundariesArray>
Array("NAME:Options", "DuplicateBoundaries:=", <bool>)

Example:
oEditor.DuplicateMirror Array("NAME:Selections", _
"Selections:=", "Box1", _
"NewPartsModelFlag:=", "Model"), _
Array("NAME:DuplicateToMirrorParameters", _
"DuplicateMirrorBaseX:=", "0mm", _
11-24 3D Modeler Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"DuplicateMirrorBaseY:=", "0mm", _
"DuplicateMirrorBaseZ:=", "0mm", _
"DuplicateMirrorNormalX:=", "0mm", _
"DuplicateMirrorNormalY:=", "-1mm", _
"DuplicateMirrorNormalZ:=", "0mm"), _
Array("NAME:Options", "DuplicateBoundaries:=", false)

Mirror
Use:

Mirrors specified parts.

Command:

Edit>Arrange>Mirror

Syntax:

Mirror <SelectionsArray>, <MirrorParametersArray>

Return Value:

None

Parameters:

<MirrorParametersArray>
Array("NAME:MirrorParameters",
"MirrorBaseX:=", <value>,
"MirrorBaseY:=", <value>,
"MirrorBaseZ:=", <value>,
"MirrorNormalX:=", <value>,
"MirrorNormalY:=", <value>,
"MirrorNormalZ:=", <value>)

Example:
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.Mirror Array("NAME:Selections", "Selections:=", "Box1", _
"NewPartsModelFlag:=", "Model"), _
Array("NAME:MirrorParameters", _
"MirrorBaseX:=", "-0.8mm", _
"MirrorBaseY:=", "-1mm", _
"MirrorBaseZ:=", "0mm", _
"MirrorNormalX:=", "0.948683298050514mm", _
"MirrorNormalY:=", "-0.316227766016838mm", _
"MirrorNormalZ:=", "0mm")

Move
Use:

Moves specified parts.

Command:

Edit>Arrange>Move
3D Modeler Editor Script Commands 11-25

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Syntax:

Move <SelectionsArray>, <MoveParametersArray>

Return Value:

None

Parameters:

<MoveParametersArray>
Array("NAME:TranslateParameters",
"TranslateVectorX:=", <value>,
"TranslateVectorY:=", <value>,
"TranslateVectorZ:=", <value>)

OffsetFaces
Use:

Offsets faces of specified parts.

Command:

Edit>Arrange>Offset

Syntax:

OffsetFaces <SelectionsArray>, <OffsetParametersArray>

Return Value:

None

Parameters:

<OffsetParametersArray>
Array("NAME:OffsetParameters",
"OffsetDistance:=", <value>)

Paste [Model Editor]


Use:

Pastes copied objects and returns an array of pasted objects from the 3D
model editor.

Command:

Edit>Paste

Syntax:

Paste

Return Value:

One dimensional array of pasted object names. The order is not guarenteed
to be alphabetical.

Parameters:

None.

Example:
arrayEntities = oEditor.Paste

Rotate
Use:

Rotates specified parts.

Command:

Edit>Arrange>Rotate

Syntax:

Rotate <SelectionsArray>, <RotateParametersArray>

Return Value:

None

Parameters:

<RotateParametersArray>
Array("NAME:RotateParameters",

11-26 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"RotateAxis:=", <string>
"RotateAngle:=", <value>)
RotateAxis
Possible values are: "X", "Y", "Z"

Scale
Use:

Scales specified parts.

Command:

Edit>Scale

Syntax:

Scale <SelectionsArray>, <ScaleParametersArray>

Return Value:

None

Parameters:

<ScaleParametersArray>
Array("NAME:ScaleParameters",
"ScaleX:=", <value>,
"ScaleY:=", <value>,
"ScaleZ:=", <value>)

Modeler Menu Commands


AssignMaterial
Chamfer
Connect
CoverLines
CoverSurfaces
CreateEntityList
CreateFaceCS
CreateObjectCS
CreateObjectFromEdge
CreateObjectFromFaces
CreateRelativeCS
DeleteLastOperation
DetachFaces
EditEntityList
EditFaceCS
3D Modeler Editor Script Commands 11-27
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

EditObjectCS
EditRelativeCS
Export
Fillet
Generate History
Import
ImportDXF
ImportGDSII
Intersect
MoveCStoEnd
MoveFaces
ProjectSheet
PurgeHistory
Section
SeparateBody
SetModelUnits
SetWCS
ShowWindow
Split
Subtract
SweepFacesAlongNormal
ThickenSheet
UncoverFaces
Unite

AssignMaterial
Use:

Assigns a material to the specified objects. Only the MaterialName and


SolveInside parameters of <AttributesArray> are supported.

Command:

Modeler>Assign Material

Syntax:

AssignMaterial <SelectionsArray>, <AttributesArray>

Return Value:

None

Example:
oEditor.AssignMaterial _
Array("NAME:Selections", "Selections:=", "Polygon1"),
Array("NAME:Attributes", _
"MaterialName:=", "tungsten",_
11-28 3D Modeler Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"SolveInside:=", false)

Chamfer
Use:

Creates a chamfer.

Command:

Modeler>Chamfer

Syntax:

Chamfer (<ObjectName> <ChamferParameters>)

Return Value:

None

Parameters:

<ObjectName>
Array("NAME:Selections", _
"Selections:=", <string>),
<ChamferParameters>
Array("NAME:Parameters", _
Array("NAME:ChamferParameters", _
"CoordinateSystemID:=", <value>,
"Edges:=", <ArrayOfEdgeIDs>,
"LeftRange:=", <value>))

Example:
oEditor.Chamfer Array("Name:Selections", _
"Selections:=", "Box1"), Array("NAME:Parameters", _
Array("NAME:ChamferParameters", _
"CoordinateSystemID:=", -1, _
"Edges:=", Array(13), "LeftRange:=", "1mm"))

Connect
Use:

Connects specified 1D parts to form a sheet.

Command:

Modeler>Surface>Connect

Syntax:

Connect <SelectionsArray>

Return Value:

None

CoverLines
Use:

Covers the specified 1D objects to form a sheet.

Command:

Modeler>Surface>Cover Lines

Syntax:

CoverLines <SelectionsArray>

Return Value:

None
3D Modeler Editor Script Commands 11-29

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

CoverSurfaces
Use:

Covers the specified objects to form a solid object.

Command:

Modeler>Surface>Cover Faces

Syntax:

CoverSurfaces <SelectionsArray>

Return Value:

None

CreateEntityList
Use:

Creates a list of entities. The list can contain objects or faces, but not
both. Only the Name attribute from <AttributesArray> is supported.

Command:

Modeler>List>Create>Object List
Modeler>List>Create>Face List

Syntax:

CreateEntityList <EntityListParametersArray>,
<AttributesArray>

Return Value:

None

Parameters:

<EntityListParametersArray>
Array("NAME:GeometryEntityListParameters",
"EntityType:=", <string>,
"EntityList:=", <array>
EntityType
Possible values are "Object", "Face"
EntityList
Array of integers the IDs of the objects or faces to put in the list. To get the IDs, use
GetObjectIDByName

CreateFaceCS
Use:

Creates a face coordinate system. Only the Name attribute of the


<AttributesArray> parameter is supported.

Command:

Modeler>Coordinate System>Create>Face CS

Syntax:

CreateFaceCS <FaceCSParametersArray>, <AttributesArray>

Return Value:

None

Parameters:

<FaceCSParametersArray>
Array("NAME:FaceCSParameters",

11-30 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"FaceID:=", <int>,
"PartID:=", <int>,
Array("NAME:OriginPosn",
"IsAttachedToEntity:=", <bool>,
"EntityID:=", <value>,
"PositionType:=", <string>,
"UParam:=", <value>,
"VParam:=", <value>,
"XPosition:=", <value>,
"YPosition:=", <value>,
"ZPosition:=", <value>)
Array("NAME:AxisPosn",
"IsAttachedToEntity:=", <bool>
"EntityID:=",

<value>

"PositionType:=", <string>,
"UParam:=", <value>,
"VParam:=", <value>,
"XPosition:=", <value>,
"YPosition:=", <value>,
"ZPosition:=", <value>)
"WhichAxis:=", <string>)
FaceID
ID of the face on which to create the coordinate system.
PartID
ID of the object on which the face ID lies.
IsAttachedToEntity
Specifies whether the point is anchored (to a vertex, edge, or face).
If IsAttachedToEntity is true, provide the UParam and VParam
parameters. Otherwise, provide the XPosition, YPosition, and
ZPosition parameters.
EntityID
3D Modeler Editor Script Commands 11-31
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

ID of the vertex, edge, or face to which the point is anchored.


PositionType
Place where the point is anchored.
Possible values are: "FaceCenter", "EdgeCenter", "OnVertex",
"OnEdge", "OnFace"
UParam, VParam
Numbers between 0 and 1 representing the relative position of the point on the edge
or face.
Example: UParam = .5, VParam = .5 would be the center of a face.
XPosition, YPosition, ZPosition
Fixed position of the point.
WhichAxis
Possible values are "X", "Y", "Z"

CreateObjectCS
Use:

Creates an Object coordinate system.

Command:

Modeler>Coordinate System>Create>Object><Offset | Rotated | Both>

Syntax:

CreateObjectCS <ParameterArrays>

Return Value:

None

Parameters:

Array("NAME:ObjectCSParameters",
"PartID:=", <ID>,
"ReverseXAxis:=", <Boolean>,
"ReverseYAxis:=", <Boolean>,
Array("NAME:Origin",
"IsAttachedToEntity:=", <Boolean>,
"EntityID:=", <ID>,
"PositionType:=", "<OnPositionID>,
String, one of OnVertex, FaceCenter, OnEdge, AbsolutePosition
"UParam:=", <integer>,
"VParam:=", <Integer>,
"XPosition:=", "<Integer>",
"YPosition:=", "<Integer>",

11-32 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"ZPosition:=", "<Integer>"),
Array("NAME:xAxis",
"DirectionType:=", "AbsoluteDirection",
"EdgeID:=", <Int>,
"FaceID:=", <Int>,
"xDirection:=", "<int>",
"yDirection:=", "<Int>",
"zDirection:=", "<Int>",
"UParam:=", <int>,
"VParam:=", <Int>),
Array("NAME:yAxis",
"DirectionType:=", "AbsoluteDirection",
"EdgeID:=", <Int>,
"FaceID:=", <int>,
"xDirection:=", "<int>",
"yDirection:=", "<int>",
"zDirection:=", "<int>",
"UParam:=", <int>,
"VParam:=", <int>)),
Array("NAME:Attributes",
"Name:=", "<ObjectCSName>")
Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("coax_bend")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")

3D Modeler Editor Script Commands 11-33


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

oEditor.CreateObjectCS Array("NAME:ObjectCSParameters",
"PartID:=", 24,
"ReverseXAxis:=", false,
"ReverseYAxis:=", false,
Array("NAME:Origin",
"IsAttachedToEntity:=",
true, "EntityID:=", 30,
"PositionType:=", "OnVertex",
"UParam:=", 0,
"VParam:=", 0,
"XPosition:=", "0",
"YPosition:=", "0",
"ZPosition:=", "0"),
Array("NAME:xAxis",
"DirectionType:=", "AbsoluteDirection",
"EdgeID:=", -1,
"FaceID:=", -1,
"xDirection:=", "1",
"yDirection:=", "0",
"zDirection:=", "0",
"UParam:=", 0,
"VParam:=", 0),
Array("NAME:yAxis",
"DirectionType:=", "AbsoluteDirection",
"EdgeID:=", -1,
"FaceID:=", -1,
"xDirection:=", "0",
"yDirection:=", "1",
"zDirection:=", "0",
"UParam:=", 0, "VParam:=", 0)),
Array("NAME:Attributes",
"Name:=", "ObjectCS1")

CreateObjectFromEdges
Use:

Creates a polyline from the specified object edge.

Command:

Modeler>Create Object From Edge

Syntax:

CreateObjectFromEdges <SelectionsArray>,

Return Value:

None

Parameters:

<SelectionsArray>

<ObjFromEdgeParametersArray>

Array("NAME:Selections",
11-34 3D Modeler Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Selections:=" <ObjName>)
<ObjFromEdgeParametersArray>
Array("NAME:Parameters",
<EdgeParametersArray>)
<EdgeParametersArray>
Array("Name:BodyFromEdgeToParameters",
"CoordinateSystemID:=", <int>,
"Edges:=", <EdgeIDarray>)
Example:
oEditor.CreateEdgeFromEdges _
Array("NAME:Selections", "Selections:=", "Box1"),_
Array("NAME:Parameters", _
Array("NAME:BodyFromEdgeToParameters", _
"CoordinateSystemID:=", -1, _
"Edges:=", Array(13)))

CreateObjectFromFaces
Use:

Creates 2D objects from the specified faces.

Command:

Modeler>Surface>Create Object From Face

Syntax:

CreateObjectFromFaces <SelectionsArray>,
<ObjFromFaceParametersArray>

Return Value:

None

Parameters:

<ObjFromFaceParametersArray>
Array("NAME:Parameters",
<FacesOfOneObjToDetach>, <FacesOfOneObjToDetach>,
...)
<FacesOfOneObjToDetach>
Array("Name:BodyFromFaceToParameters",
"FacesToDetach:=", <array>)
FacesToDetach
Array of integers the IDs of the faces to use to create objects.
3D Modeler Editor Script Commands 11-35

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:
oEditor.CreateObjectFromFaces _
Array("NAME:Selections", "Selections:=", "Box1"),_
Array("NAME:Parameters", _
Array("NAME:BodyFromFaceToParameters", _
"FacesToDetach:=", Array(185)))

CreateRelativeCS
Use:

Creates a relative coordinate system. Only the Name attribute of the


<AttributesArray> parameter is supported.

Command:

Modeler>Coordinate System>Create>Relative CS->Offset


Modeler>Coordinate System>Create>Relative CS->Rotated
Modeler>Coordinate System>Create>Relative CS->Both

Syntax:

CreateRelativeCS <RelativeCSParametersArray>,

Return Value:

None

Parameters:

<RelativeCSParametersArray>

<AttributesArray>

Array("NAME:RelativeCSParameters",
"OriginX:=", <value>,
"OriginY:=", <value>,
"OriginZ:=", <value>,
"XAxisXvec:=", <value>,
"XAxisYvec:=", <value>,
"XAxisZvec:=", <value>,
"YAxisXvec:=", <value>,
"YAxisYvec:=", <value>,
"YAxisZvec:=", <value>)

DeleteLastOperation
Use:

Deletes the last operation for specified objects.

Command:

Modeler>Delete Last Operation

Syntax:

DeleteLastOperation <SelectionsArray>

Return Value:

None

11-36 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

DetachFaces
Use:

Detaches the specified faces.

Command:

Modeler>Surface>Detach Faces

Syntax:

DetachFaces <SelectionsArray>,
<DetachFacesParametersArray>

Return Value:

None

Parameters:

<DetachFacesParametersArray>
Array("NAME:Parameters",
<FacesOfOneObjToDetach>,
<FacesOfOneObjToDetach>, ...)
<FacesOfOneObjToDetach>
Array("Name:DetachFacesToParameters",
"FacesToDetach:=", <array>)
FacesToDetach
An array of integers the face IDs of the faces to detach.

Example:
oEditor.DetachFaces _
Array("NAME:Selections", "Selections:=",_
"Box5,Box4"),_
Array("NAME:Parameters", _
Array("NAME:DetachFacesToParameters", _
"FacesToDetach:=", Array(123, 122)),
Array("NAME:DetachFacesToParameters", _
"FacesToDetach:=", Array(94)))

EditEntityList
Use:

Modifies an entity list.

Command:

Modeler>List>Reassign

Syntax:

EditEntityList <SelectionsArray>,
<EntityListParametersArray>

Return Value:

None

3D Modeler Editor Script Commands 11-37


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

EditFaceCS
Use:

Recreates an existing face coordinate system. The name of the coordinate


system to modify should be specified in the <AttributesArray>
parameter.

Command:

Modeler->Coordinate System->Edit

Syntax:

EditFaceCS <FaceCSParametersArray>, <AttributesArray>

Return Value:

None

EditObjectCS
Use:

Edit an existing Object CS.

Command:

Modeler>Coordinate System>Edit

Syntax:

EditObjectCS <Array>

Return Value:

None

Parameters:

Array("NAME:ObjectCSParameters",
"PartID:=", <ID>,
"ReverseXAxis:=", <Boolean>,
"ReverseYAxis:=", <Boolean>,
Array("NAME:Origin",
"IsAttachedToEntity:=", <Boolean>,
"EntityID:=", <ID>,
"PositionType:=", "<OnPositionID>,
String, one of OnVertex, FaceCenter, OnEdge, AbsolutePosition
"UParam:=", <integer>,
"VParam:=", <Integer>,
"XPosition:=", "<Integer>",
"YPosition:=", "<Integer>",
"ZPosition:=", "<Integer>"),
Array("NAME:xAxis",
"DirectionType:=", "AbsoluteDirection",
"EdgeID:=", <Int>,
"FaceID:=", <Int>,
"xDirection:=", "<int>",
"yDirection:=", "<Int>",
"zDirection:=", "<Int>",
"UParam:=", <int>,

11-38 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"VParam:=", <Int>),
Array("NAME:yAxis",
"DirectionType:=", "AbsoluteDirection",
"EdgeID:=", <Int>,
"FaceID:=", <int>,
"xDirection:=", "<int>",
"yDirection:=", "<int>",
"zDirection:=", "<int>",
"UParam:=", <int>,
"VParam:=", <int>)),
Array("NAME:Attributes",
"Name:=", "<ObjectCSName>")
Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project53")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.SetWCS Array("NAME:SetWCS Parameter",
"Working Coordinate System:=", "ObjectCS1")
oEditor.EditObjectCS Array("NAME:ObjectCSParameters",
"PartID:=", 6,
"ReverseXAxis:=", false,
"ReverseYAxis:=", false,
Array("NAME:Origin", "IsAttachedToEntity:=", false,
"EntityID:=", -1,
"PositionType:=", "AbsolutePosition",
"UParam:=", 0, "VParam:=", 0,
3D Modeler Editor Script Commands 11-39
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"XPosition:=", "0mm", "YPosition:=", "0mm",


"ZPosition:=", "0mm"),
Array("NAME:xAxisPos", "IsAttachedToEntity:=", true,
"EntityID:=", 13,
"PositionType:=", "OnEdge",
"UParam:=", 0.75, "VParam:=", 0,
"XPosition:=", "0", "YPosition:=", "0", "ZPosition:=", "0"),
Array("NAME:yAxisPos", "IsAttachedToEntity:=", true,
"EntityID:=", 7,
"PositionType:=", "FaceCenter",
"UParam:=", 0, "VParam:=", 0,
"XPosition:=", "0", "YPosition:=", "0", "ZPosition:=", "0")),
Array("NAME:Attributes", "Name:=", "ObjectCS1")

EditRelativeCS
Use:

Modifies a relative coordinate system. Use <AttributesArray> to


indicate the name of the coordinate system to modify.

Command:

Modeler>Coordinate System>Edit

Syntax:

EditRelativeCS <RelativeCSParametersArray>,
<AttributesArray>

Return Value:

None

Parameters:

<ParametersArray>
Array("NAME:RelativeCSParameters",
"OriginX:=", <value>,
"OriginY:=", <value>,
"OriginZ:=", <value>,
"XAxisXvec:=", <value>,
"XAxisYvec:=", <value>,
"XAxisZvec:=", <value>,
"YAxisXvec:=", <value>,
"YAxisYvec:=", <value>,
"YAxisZvec:=", <value>)

Export
Use:

Exports the model to a file.

11-40 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Command:

Modeler>Export

Syntax:

Export <ExportParametersArray>

Return Value:

None

Parameters:

<ExportParametersArray>
Array("NAME:ExportParameters",
"File Name:=", <string>,
"Major Version:=", <int>,
"Minor Version:=", <int>)
Major Version
Can be 1 or any ACIS major version supported by HFSS software.
Minor Version
Can be 1 or any ACIS minor version supported by HFSS software.

ExportModelImageToFile
Use:

Export an image of the model to a file.

Command:

Modeler>Export...

Syntax:

ExportModelImageToFile "<path>/
<imageName>.<formatsuffix>" 0,0, Array(<SaveImageParams>)

Return Value:

None

Parameters:

<path>
<imagename>
<formatsuffix>, You can export the following graphics formats:

Extension

Contents

.bmp

Bitmap files.

.gif

Graphics Interchange Format files.

.jpeg

Joint Photographics Experts Group files.

.tiff

Tagged Image File Format files.

.wrl

Virtual Reality Modeling Language (VRML) files.


0,0,
3D Modeler Editor Script Commands 11-41

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array("NAME:SaveImageParams",
"ShowAxis:=","<string>",
"ShowGrid:=", "<string>",
"ShowRuler:=", "<string>")
Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 15.0.0
' 2:28:32 PM

Jul 30, 2012

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("dra_diel")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.ExportModelImageToFile

"C:/MyPath/Downloads/dra_example.jpg", 0, 0,
Array("NAME:SaveImageParams", "ShowAxis:=", _
"Default", "ShowGrid:=", "Default", "ShowRuler:=", "Default")

Fillet
Use:

Creates a fillet.

Command:

Modeler>Fillet

Syntax:

Fillet(<ObjectName> <FilletParameters>)

Return Value:

None

Parameters:

<ObjectName>
Array("NAME:Selections", _
"Selections:=", <string>),
<FilletParameters>
Array("NAME:Parameters", _

11-42 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array("NAME:FilletParameters", _
"CoordinateSystemID:=", <value>,
"Edges:=", <ArrayOfEdgeIDs>,
"Radius:=", <value>,
"Setback:=", <value>))
Example:
oEditor.Fillet Array("Name:Selections", "Selections:=", _
"Box1"), Array("NAME:Parameters", Array("NAME:FilletParameters", _
"CoordinateSystemID:=", -1, "Edges:=", Array(13), "Radius:=", _
"1mm", "Setback:=", "0mm"))

GenerateHistory
Use:

Generates the history for specified 1D objects.

Command:

Modeler>Generate History

Syntax:

GenerateHistory <SelectionsArray>

Return Value:

None

HealObject
Use:

To heal an imported object.

Command:

Modeler>Model Healing>Heal

Syntax:

HealObject <parameters>

Return Value:

None

Parameters:

Array("NAME:Selections",

"Selections:=", "<objectID>",
"NewPartsModelFlag:=", "Model"),
Array("NAME:ObjectHealingParameters",
"Version:=", 1,
"AutoHeal:=", <boolean>,
"TolerantStitch:=", <boolean>,
"SimplifyGeom:=", <boolean>,
"TightenGaps:=", <boolean>,
"StopAfterFirstStitchError:=", <boolean>,
"MaxStitchTol:=", <smallvalue>,
"ExplodeAndStitch:=", <boolean>,
3D Modeler Editor Script Commands 11-43
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"GeomSimplificationTol:=", <value>,
"MaximumGeneratedRadiusForSimplification:=", <value>,
"SimplifyType:=", 2,
"TightenGapsWidth:=", <value>,
"RemoveSliverFaces:=", <boolean>,
"RemoveSmallEdges:=", <boolean>,
"RemoveSmallFaces:=", <boolean>,
"SliverFaceTol:=", <value>,
"SmallEdgeTol:=", <value>,
"SmallFaceAreaTol:=", <value>,
"BoundingBoxScaleFactor:=", <value>,
"RemoveHoles:=", <boolean>,
"RemoveChamfers:=", <boolean>,
"RemoveBlends:=", <boolean>,
"HoleRadiusTol:=", <value>,
"ChamferWidthTol:=", <value>,
"BlendRadiusTol:=", <value>,
"AllowableSurfaceAreaChange:=", <value>,
"AllowableVolumeChange:=", <value>)
Example:
oEditor.HealObject Array("NAME:Selections",
"Selections:=", "Box1",
"NewPartsModelFlag:=", "Model"),
Array("NAME:ObjectHealingParameters",
"Version:=", 1,
"AutoHeal:=", false,
"TolerantStitch:=", true,
"SimplifyGeom:=", true,
"TightenGaps:=", true,
"StopAfterFirstStitchError:=", false,
"MaxStitchTol:=", 0.001,
"ExplodeAndStitch:=", true,
"GeomSimplificationTol:=", -1,
"MaximumGeneratedRadiusForSimplification:=", -1,
11-44 3D Modeler Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"SimplifyType:=", 2,
"TightenGapsWidth:=", 1E-006,
"RemoveSliverFaces:=", true,
"RemoveSmallEdges:=", true,
"RemoveSmallFaces:=", true,
"SliverFaceTol:=", 0,
"SmallEdgeTol:=", 0.1,
"SmallFaceAreaTol:=", 0.1,
"BoundingBoxScaleFactor:=", 1250,
"RemoveHoles:=", true,
"RemoveChamfers:=", true,
"RemoveBlends:=", true,
"HoleRadiusTol:=", 0.1,
"ChamferWidthTol:=", 0.1,
"BlendRadiusTol:=", 0.1,
"AllowableSurfaceAreaChange:=", 5,
"AllowableVolumeChange:=", 5)

Import
Use:

Imports a 3D model file.

Command:

Modeler>Import

Syntax:

Import <ImportParametersArray>

Return Value:

None

Parameters:

<ImportParametersArray>
Array("NAME:NativeBodyParameters",
"CoordinateSystemID:=", <ID>,
"HealOption:=", <integer>,
"CheckModel:=", <boolean>,
"Options:=", "",
"FileType:=", "UnRecognized",
"MaxStitchTol:=", <value>,
"SourceFile:=", "string")

3D Modeler Editor Script Commands 11-45


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

ImportDXF
Use:

Imports an AutoCAD model file and a tech file. The tech file is an ASCII file
that lists the units, the layer name followed by tab delimited color,
elevations and thickness.

Command:

Modeler>Import

Syntax:

ImportDXF <ImportParametersArray>

Return Value:

None

Parameters:

<ImportParametersArray>
Array("NAME:options",
"FileName:=", <path>,
"Scale:=", <real>,
"UnionOverlapping:=", <boolean>,
"AutoDetectClosed:=", <boolean>,
"SelfStitch:=", <boolean>,
"DefeatureGeometry:=", <boolean>,
"DefeatureDistance:=", <real>,
"RoundCoordinates:=", <boolean>,
"RoundNumDigits:=", <integer>,
"WritePolyWithWidthAsFilledPoly:=", <boolean>,
"ImportMethod:=", <integer>,
"2DSheetBodies:=", <boolean>,
Array("NAME:LayerInfo",
Array("NAME:<layerName>",
"source:=", "<integer>",
"display_source:=", "<integer>",
"import:=", <boolean>,
"dest:=", "<integer>",
"dest_selected:=", <boolean>,
"layer_type:=", "<string>",
"paint:=", <boolean>),
Array("NAME:TechFileLayers", "layer:=",
Array("name:=", "ground",
"color:=", "purple",
"elev:=", 0,
"thick:=", 0.0001),
)))

11-46 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

oEditor.Import Array("NAME:NativeBodyParameters",
"CoordinateSystemID:=", -1,
"HealOption:=", <integer>,
"CheckModel:=", <boolean>,
"Options:=", "",
"FileType:=", "UnRecognized",
"MaxStitchTol:=", <real>,
"SourceFile:=", "<path>" & ".sm3")
Example:
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.ImportDXF Array("NAME:options", "FileName:=",

"C:/mymodel.dxf", ...
Array("NAME:TechFileLayers", ...
"layer:=", Array("name:=", "BOTTOMLAYER",
"color:=", "purple",
"elev:=", 0,
"thick:=", 200),
)))
oEditor.Import Array("NAME:NativeBodyParameters",
"CoordinateSystemID:=", -1,
"HealOption:=", 0,
"CheckModel:=", true,
"Options:=", "",
"FileType:=", "UnRecognized",
"MaxStitchTol:=", 0.001,
"SourceFile:=", "C:design." & ".sm3")

ImportGDSII
Use:

Imports a GDSII 3D model file.

Command:

Modeler>Import

Syntax:

ImportGDSII <ImportParametersArray>

Return Value:

None

Parameters:
3D Modeler Editor Script Commands 11-47
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"FileName:=", "<string>",
"NodeConversionType:=", "<string>",
"MaxLayerNumber:=", <integer>,
"ApproxPolyToCircle:=", <boolean>,
"FlattenHierarchy:=", <boolean>,
"ImportMethod:=", <integer>,
Array("NAME:LayerMap",
Array("NAME:LayerMapInfo",
"LayerNum:=", <integer>,
"Import:=", <booleaninteger>,
"IsVIA:=", <booleaninteger>,
"IsLayerNew:=", <booleanInteger>,
"DestLayer:=", "<string>",
"layer_type:=", "<string>",
"IsPresentInLayout:=", <boolean>),
"OrderMap:=", Array("entry:=",
Array("order:=", <integer>,
"layer:=", "<string>"),
"entry:=", Array("order:=",
<integer>, "layer:=", "Signal25"),
"entry:=", Array("order:=", <integer+1>,
"layer:=", "Signal30"),
...),
Array("NAME:Structs",
Array("NAME:GDSIIStruct", "ImportStruct:=", <boolean>,
"CreateNewCell:=", <boolean>,
"StructName:=", "string>",
Array("NAME:Elements")),
Array("NAME:GDSIIStruct", "ImportStruct:=",<boolean>,
"CreateNewCell:=", <boolean>,
"StructName:=", "<string>",
Array("NAME:Elements"))))
oEditor.Import Array("NAME:NativeBodyParameters",
11-48 3D Modeler Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"CoordinateSystemID:=", <ID>,
"HealOption:=", <integer>,
"CheckModel:=", <boolean>,
"Options:=", "",
"FileType:=", "UnRecognized",
"MaxStitchTol:=", <value>,
"SourceFile:=", "string")
Example:
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.ImportGDSII Array("NAME:options", ...

Intersect
Use:

Intersects specified objects.

Command:

Modeler>Boolean>Instersect

Syntax:

Intersect <SelectionsArray>, <IntersectParametersArray>

Return Value:

None

Parameters:

<IntersectParametersArray>
Array("NAME:IntersectParameters",
"KeepOriginals:=",

<bool>)

MoveCStoEnd
Use:

Moves the named ObjectCS to the end of the History tree.

Command:

Modeler>Coordinate System>Move CS to End

Syntax:

MoveCSToEnd Array("NAME:Selections",
"Selections:=", "<ObjectCSName>")

Return Value:

None

Parameters:

<ObjectCSName>

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
3D Modeler Editor Script Commands 11-49
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("coax_bend")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.MoveCSToEnd Array("NAME:Selections",
"Selections:=", "ObjectCS1")

MoveFaces
Use:

Moves the specified faces along normal or along a vector.

Command:

Modeler>Surface>Move Faces>Along Normal


Modeler>Surface>Move Faces>Along Vector

Syntax:

MoveFaces <SelectionsArray>, <MoveFacesParametersArray>

Return Value:

None

Parameters:

<MoveFacesParametersArray>
Array("NAME:Parameters",
<FacesOfOneObjToMove>, <FacesOfOneObjToMove>, ...)
<FacesOfOneObjToMove>
Array("Name:MoveFacesParameters",
"MoveAlongNormalFlag:=",

<bool>,

"OffsetDistance:=", <value>,
"MoveVectorX:=", <value>,
"MoveVectorY:=", <value>,
"MoveVectorZ:=", <value>,
"FacesToMove:=", <array>)
MoveAlongNormalFlag
Specifies whether to move along the face normal or along a vector.
If false, provide the MoveVectorX, MoveVectorY, and MoveVectorZ parameters.
FacesToMove
11-50 3D Modeler Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array of integers the IDs of the faces to move


Example:
oEditor.MoveFaces _
Array("NAME:Selections", "Selections:=", _
"Box2,Box1"), _
Array("NAME:Parameters", _
Array("NAME:MoveFacesParameters", _
"MoveAlongNormalFlag:=", true, _
"OffsetDistance:=", "1mm", _
"FacesToMove:=", Array(218)),
Array("NAME:MoveFacesParameters", _
"MoveAlongNormalFlag:=", false,_
"OffsetDistance:=", "1mm", _
"MoveVectorX:=", "1mm", _
"MoveVectorY:=", "0mm", _
"MoveVectorZ:=", "0mm", _
"FacesToMove:=", Array(185)))

ProjectSheet
Use:

Project planar sheet object, typically for modeling thin conformal deposits.
Typically followed by Thicken Sheet.

Command:

Modeler>Surface>Project Sheet

Syntax:

ProjectSheet
(Array("NAME:Selections",Selections:="...,...,""),
Array("NAME:ProjectSheetParameters")

Return Value:

None

Parameters:

None

Example:
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.ProjectSheet Array("NAME:Selections", "Selections:=",
"Box1,Box2,Polyline1"),
array("NAME:ProjectSheetParameters")

3D Modeler Editor Script Commands 11-51


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

PurgeHistory
Use:

Purges the construction history of the selected object. For complex objects
this simplifies the object and can improve modeler speed.

Command:

Modeler>Purge History

Syntax:

PurgeHistory <PurgeHistoryArray>

Return Value:

None

Parameters:

<PurgeHistoryArray>
Array(Name:Selections,
Selections:=, <string>,
NewPartsModelFlag:=, <string>)
Selections
Name of the object to purge.
NewPartsModelFlag
Flag to indicate model properties, Model or NonModel.

Example:
oEditor.PurgeHistory Array("NAME:Selections", _
"Selections:=", "Polygon1", "NewPartsModelFlag:=", "Model")

Section
Use:

Creates a 2D cross-section of the selection in the specified plane.

Command:

Modeler>Surface>Section

Syntax:

Section <SelectionsArray>, <SectionParametersArray>

Return Value:

None

Parameters:

<SectionParametersArray>
Array("NAME:SectionToParameters",
"SectionPlane:=", <string>)
Section Plane
Possible values are "XY", "YZ", "ZX"

SeparateBody
Use:

Separates bodies of specified multi-lump objects.

Command:

Modeler>Boolean>Separate Bodies

Syntax:

SeparateBody <SelectionsArray>

Return Value:

None

11-52 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Parameters:

<SelectionsArray>
Selections:=",<objectNames>"
"NewPartsModelFlag:=", "Model"

Example:
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.SeparateBody Array("NAME:Selections",
"Selections:=", "Rectangle1,Circle1",
"NewPartsModelFlag:=", "Model")

SetModelUnits
Use:

Sets the model units.

Command:

Modeler>Units

Syntax:

SetModelUnits <ModelUnitsParametersArray>

Return Value:

None

Parameters:

<ModelUnitsParametersArray>
Array("NAME:Units Parameter",
"Units:=", <string>,
"Rescale:=", <bool>)
Units
Possible values are: "cm", "ft", "in", "meter", "mil", "mm", "nm",
"uin", "um"

SetWCS
Use:

Sets the working coordinate system.

Command:

Modeler>Coordinate System>Set Working CS

Syntax:

SetWCS <WCSParametersArray>

Return Value:

None

Parameters:

<WCSParametersArray>
Array("NAME:SetWCS Parameter",
"Working Coordinate System:=", <string>)
Working Coordinate System
Name of the coordinate system to set as the WCS.
3D Modeler Editor Script Commands 11-53

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

ShowWindow
Use:

Opens the selected 3D model editor window.

Syntax:

ShowWindow

Return Value:

None

Parameters:

None

Example:
Set oDesign = oProject.GetActiveDesign
Set oModeler = oDesign.SetActiveEditor("3D Modeler")
oEditor.ShowWindow

Split
Use:

Splits specified objects along a plane.

Command:

Modeler->Boolean->Split

Syntax:

Split <SelectionsArray>, <SplitParametersArray>

Return Value:

None

Parameters:

<SplitParametersArray>
Array("NAME:SplitToParameters",
"SplitPlane:=", <string>,
"WhichSide:=", <string>)
SplitPlane
Possible values are "XY", "YZ", "ZX"
WhichSide
Side to keep. Possible values are "Both", "PositiveOnly", "NegativeOnly"

Subtract
Use:

Subtracts specified objects.

Command:

Modeler->Boolean->Subtract

Syntax:

Subtract <SubtractSelectionsArray>,

Return Value:

None

Parameters:

<SubtractSelectionsArray>

<SubtractParametersArray>

Array("NAME:Selections",
11-54 3D Modeler Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Blank Parts:=", <string>,


"Tool Parts:=", <string>)
Blank Parts
Comma-separated list of parts to use as the blank in the subtract operation.
Example: "Blank Parts:=", "Box1, Box2"
Tool Parts
Comma-separated list of parts to use as the tool in the subtract operation.
Example: "Blank Parts:=", "Box3, Box4"
<SubtractParametersArray>
Array("NAME:SubtractParameters",
"KeepOriginals:=",

<bool>)

Example:
oEditor.Subtract _
Array("NAME:Selections", _
"Blank Parts:=", "Polygon1",_
"Tool Parts:=",

"Box1"),_

Array("NAME:SubtractParameters", _
"KeepOriginals:=", false)

SweepFacesAlongNormal
Use:

Sweep a face along normal.

Command:

Modeler>Sweep Faces Along Normal

Syntax:

SweepFacesAlongNormal <selection> <parameters>

Return Value:

None

Parameters:

Array("NAME:Selections",
"Selections:=", "<faceID>",
"NewPartsModelFlag:=", "Model"),
Array("NAME:Parameters",
Array("NAME:SweepFaceAlongNormalToParameters",
"FacesToDetach:=", Array( <faceID>),
"LengthOfSweep:=", "<value><units>")
)
3D Modeler Editor Script Commands 11-55

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:
oEditor.SweepFacesAlongNormal
Array("NAME:Selections",
"Selections:=", "Rectangle1",
"NewPartsModelFlag:=", "Model"),
Array("NAME:Parameters",
Array("NAME:SweepFaceAlongNormalToParameters",
"FacesToDetach:=",
Array( 57),
"LengthOfSweep:=", "0.5mm")
)

ThickenSheet
Use:

Thicken a sheet object to convert it to a 3D object.

Command:

Modeler>Surface>Thicken Sheet

Syntax:

Thicken Sheet <SelectionParameters>


<SheetThickenParameters>

Return Value:

None

Parameters:

Array("NAME:Selections",
"Selections:=", "<objectID>",
"NewPartsModelFlag:=", "Model"),
Array("NAME:SheetThickenParameters",
"Thickness:=", "<value><units>",
"BothSides:=", <boolean>)

Example:
oEditor.ThickenSheet Array("NAME:Selections",
"Selections:=", "Rectangle1",
"NewPartsModelFlag:=", "Model"),
Array("NAME:SheetThickenParameters",
"Thickness:=", "1.01mm",
"BothSides:=", false)

UncoverFaces
Use:

Uncovers specified faces.

Command:

Modeler>Surface>Uncover Faces

Syntax:

UncoverFaces <SelectionsArray>, <UncoverParametersArray>

Return Value:

None

11-56 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Parameters:

<UncoverParametersArray>
Array("NAME:Parameters",
<FacesOfOneObjToUncover>,
<FacesOfOneObjToUncover>,...)
<FacesOfOneObjToUncover>
Array("Name:UncoverFacesParameters",
"FacesToUncover:=", <array>)
FacesToUncover
An array of integers the face IDs of the faces to uncover.

Example:
oEditor.UncoverFaces _
Array("NAME:Selections", "Selections:=", _
"Box3,Box2"),_
Array("NAME:Parameters", _
Array("NAME:UncoverFacesParameters", _
"FacesToUncover:=", Array(69)),
Array("NAME:UncoverFacesParameters", _
"FacesToUncover:=", Array(36)))

Unite
Use:

Unites the specified objects.

Command:

Modeler>Boolean>Unite

Syntax:

Unite <SelectionsArray>, <UniteParametersArray>

Return Value:

None

Parameters:

<UniteParametersArray>
Array("NAME:UniteParameters",
"KeepOriginals:=", <bool>)

Other oEditor Commands


ChangeProperty
Delete
GetBodyNamesByPosition
3D Modeler Editor Script Commands 11-57
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

GetEdgeByPosition
GetEdgeIDsFromObject
GetEdgeIDsFromFace
GetFaceArea
GetFaceByPosition
GetFaceCenter
GetFaceIDs
GetModelBoundingBox
GetObjectsInGroup
GetObjectIDByName
GetObjectName
GetObjectNameByFaceID
GetMatchedObjectName
GetModelUnits
GetNumObjects
GetSelections
GetVertexIDsFromEdge
GetVertexIDsFromFace
GetVertexIDsFromObject
GetUserPosition
PageSetup
RenamePart

ChangeProperty
Use:

Change the properties used to create an object in the history tree

Command:

Select a command in the History Tree and select Properties.

Syntax:

ChangeProperty <array>

Return Value:

None

Parameters:

Varies, depending on the properties associated with the


select object command.

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 14.0.0
' 9:49:26 AM

Mar 09, 2011

' ---------------------------------------------Dim oAnsoftApp


11-58 3D Modeler Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project58")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DCmdTab",
Array("NAME:PropServers", "Polyline2:CreatePolyline:1"),
Array("NAME:ChangedProps",
Array("NAME:Type", "Value:=", "Isosceles Trapezoid"),
Array("NAME:Width/Diameter", "Value:=", "0.1mm"),
Array("NAME:Top Width", "Value:=", "0.05mm"),
Array("NAME:Height", "Value:=", "0.02mm"))))
oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DCmdTab", Array("NAME:PropServers", "Polyline2:CreatePolyline:1"),
Array("NAME:ChangedProps",
Array("NAME:Bend Type", "Value:=", "Corner"))))

Delete
Use:

Deletes specified objects, coordinate systems, points, planes, etc.

Command:

None

Syntax:

Delete <SelectionsArray>

Return Value:

None

GetBodyNamesByPosition
Use:

Gets the IDs of objects that contact the given point.

Command:

None.

Syntax:

GetBodyNamesByPosition(<positionParameters>).

Return Value:

Retuurns a list of IDs.

Parameters:

<PositionParameters>
Array("NAME:Parameters", _
3D Modeler Editor Script Commands 11-59

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Xposition:=", <value>,
"YPosition:=", <value>,
"ZPosition:=", <value>)
Example:
bodyNames = oEditor.GetBodyNamesByPosition(Array("NAME:Parameters", _
"XPosition:=", "a", _
"YPosition:=", "0mm", _
"ZPosition:=", "0mm"))

GetEdgeByPosition
Use:

Gets the edge IDcorresponding to position input.

Syntax:

GetEdgeByPosition(<PositionParameters>)

Return Value:

Returns an integer edge ID.

Parameters:

<PositionParameters>
Array("NAME:EdgeParameters", _
"BodyName:=", <string>,
"Xposition:=", <value>,
"YPosition:=", <value>,
"ZPosition:=", <value>)

Example:
edgeid = oEditor.GetEdgeByPosition(Array("NAME:EdgeParameters", _
"BodyName:=", "Box1", "XPosition:=", "3.4mm", _
"YPosition:=", "2.8mm", "ZPosition:=", "0.4mm"))

GetEdgeIDsFromFace
Use:

Get the edge IDs of given a face ID.

Command:

None

Syntax:

GetEdgeIDsFromFace <Face ID>

Return Value:

An array of edge IDs

Parameters:

<FaceID>
ID of the face

Example:
Dim oEdgeIDs
oEdgeIDs = Array()
oEdgeIDs = oEditor.GetEdgeIDsFromFace(10)
11-60 3D Modeler Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

GetEdgeIDsFromObject
Use:

Get the edge IDs of given an object name

Command:

None

Syntax:

GetEdgeIDsFromObject <Object Name>

Return Value:

An array of edge IDs

Parameters:

<ObjectName>
Name of the object

Example:

Example:

Dim oEdgeIDs
oEdgeIDs = Array()
oEdgeIDs = oEditor.GetEdgeIDsFromObject(Box1)

GetFaceArea
Use:

Get area of given face ID.

Command:

None.

Syntax:

GetFaceArea <face ID>

Return Value:

Double value for face area.

Parameters:

<FaceID>
Face ID

Example:
Dim oArea
oArea = oEditor.GetFaceArea(10)

GetFaceCenter
Use:

Given a face ID, return the center position

Command:

none

Syntax:

GetFaceCenter <FaceID>

Return Value:

An array containing face center position

Parameters:

<FaceID>

Example:
Dim oFaceCenter
oFaceCenter = oEditor.GetFaceCenter(oFaceID)

GetFaceByPosition
Use:

Gets the face id corresponding to position input.


3D Modeler Editor Script Commands 11-61
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Syntax:

GetFaceByPosition(<FaceByPositionParametersArray>)

Return Value:

Returns an integer face id

Parameters:

(<FaceByPositionParametersArray>)
Array("NAME:FaceParameters",
"BodyName:=", <string>,
"XPosition:=", <value>,
"YPosition:=", <value>,
"ZPosition:=", <value>)
BodyName
Name of the body on which the point lies.

Example:
Dim faceid
faceid = oEditor.GetFaceByPosition(Array("NAME:Parameters", _
"BodyName:=" "Box1", "XPosition:=", "3.4mm", "YPosition:=, _
"2.8mm", "ZPosition:=", "0.4mm"))

GetFaceIDs
Use:

Get the face IDs of given an object name

Command:

None.

Syntax:

GetFaceIDs <Object Name>

Return Value:

An array of face IDs

Parameters:

<ObjectName>
Name of the object

Example:
Dim oFaceIDs
oFaceIDs = Array()
oFaceIDs = oEditor.GetFaceIDs(Box1)

GetModelBoundingBox
Use:

Gets the bounding box of the current model.

Syntax:

GetModelBoundingBox()

Return Value:

Returns the Xmin, Ymin, Zmin, Xmax, Ymax, Zmax values that define the
bounding box.

Parameters:

None

11-62 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:
Dim oBoundingBox
oBoundingBox = oEditor.GetModelBoundingBox()

GetObjectsInGroup
Use:

Returns the objects for the specified group.

Syntax:

GetObjectsInGroup(<GroupName>)

Return Value:

The objects in the group.

Parameters:

<groupName>
Type: <string>
One of <materialName>, <assignmentName>, "Non Model", "Solids", "Unclassified", "Sheets", "Lines"

Example:
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
Dim oObject
Dim oObjects
Set oObjects = oEditor.GetObjectsInGroup( "Sheets" )
For Each oObject in oObjects
MsgBox oObject
Next

GetObjectIdByName
Use:

Get Object IDs to provide for CreateEntityList.

Syntax:

GetObjectIDByName("<objectName>")

Return Value:

<Object ID>

Parameters:

<objectName>
Type: <string>

Example:
oObjectID = oEditor.GetObjectIDByName("Box2")

GetObjectName
Use:

Gets an object name corresponding to the 0 base index of the creation


order.

Syntax:

GetObjectName(<Index>)
3D Modeler Editor Script Commands 11-63
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Return Value:

Returns the object name of the corresponding object.

Parameters:

<Index>
Type: <string>
The 0 base index of the creation order

Example:
objectname = oEditor.GetObjectName(3)

GetObjectNameByFaceID
Use:

Gets an object name corresponding to the input face id.

Syntax:

GetObjectName(<FaceID>)

Return Value:

Returns the name of the corresponding object.

Parameters:

<FaceID>
Type: <string>

Example:
objectname = oEditor.GetObjectNameByFaceID(Face10)

GetMatchedObjectName
Use:

Gets all object names containing the input text string.

Syntax:

GetMatchedObjectName(<ObjectNameWildcardText>)

Return Value:

Array of object names containing wildcard text.

Parameters:

<ObjectNameWildcardText>
Type: <string>
Text to be used for object name matching.

Example:
objectnames = oEditor.GetMatchedObjectName("Box*")

GetModelUnits
Use:

Get the model units.

Command:

None.

Syntax:

GetModelUnits

Return Value:

A string contains current model units.

Parameters:

None.

Example:
Dim oUnit
11-64 3D Modeler Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

oUnit = oEditor.GetModelUnits()

GetNumObjects
Use:

Gets the number of objects in a design.

Syntax:

GetNumObjects

Return Value:

Returns the number of objects.


Type: <int>

Parameters:

None

Example:
totalobjects = oEditor.GetNumObjects

GetSelections
Use:

Informational.

Syntax:

GetSelections

Return Value:

Array of IDs.

Parameters:

None

Example:
Set oProject = oDesktop.SetActiveProject("Project6")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
Dim A
A = Array()
A = oEditor.GetSelections
Dim B
B = Join(A,",")
'Debug.Write "The Selections are " &B
MsgBox(B)
Dim C
C = Array("NAME:Selections", "Selections:=", B)
oEditor.Delete C

GetUserPosition
Use:

Returns the coordinates of an interactive position input in the 3D model


window.

Syntax:

GetUserPosition(<PositionInputPrompt>)
3D Modeler Editor Script Commands 11-65
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Return Value:

Array of coordinates

Parameters:

<PositionInputPrompt>
Type: <string>

Example:
Dim position
Dim coord
position = oEditor.GetUserPosition("Enter a point")
For Each coord in position
Msgbox(coord)
Next

GetVertexIDsFromEdge
Use:

Get the vertex IDs of given a edge ID.

Command:

None.

Syntax:

GetVertexIDsFromEdge <Edge ID>

Return Value:

An array of edge IDs.

Parameters:

<EdgeID>
ID of the edge.

Example:
Dim oVertexIDs
oVertexIDs = Array()
oVertexIDs = oEditor.GetVertexIDsFromEdge(10)

GetVertexIDsFromFace
Use:

Get the vertex IDs of given a face ID.

Command:

None.

Syntax:

GetVertexIDsFromFace <Face ID>

Return Value:

An array of vertex IDs

Parameters:

<FaceID>
ID of the face

Example:
Dim oVertexIDs
oVertexIDs = Array()
oVertexIDs = oEditor.GetVertexIDsFromFace(10)

11-66 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

GetVertexIDsFromObject
Use:

Get the vertex IDs of given an object name

Command:

None.

Syntax:

GetVertexIDsFromObject <Object Name>

Return Value:

An array of edge IDs

Parameters:

<ObjectName>
Name of the object

Example:
Dim oVertexIDs
oVertexIDs = Array()
oVertexIDs = oEditor.GetVertexIDsFromObject(Box1)

PageSetup
Use:

Specifies the page settings for printing.

Command:

File>Page Setup

Syntax:

PageSetup <PageSetupParametersArray>

Return Value:

None

Parameters:

<PageSetupParametersArray>
Array("NAME:PageSetupData",
"margins:=",
Array("left:=", <value>,
"right:=", <value>,
"top:=", <value>,
"bottom:=", <value>))

RenamePart
Use:

Renames an object.

Command:

None

Syntax:

RenamePart <RenameParametersArray>

Return Value:

None

Parameters:

<RenameParametersArray>
Array("NAME:Rename Data",
"Old Name:=", <string>,
"New Name:=", <string>)

3D Modeler Editor Script Commands 11-67


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

11-68 3D Modeler Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

12

Output Variable Script


Commands

The Output variable commands should be executed by the "OutputVariable"


module. First obtain the output variable module from oDesign and use it for
outputvariable commands.
Set oModule = oDesign.GetModule("OutputVariable")
oModule.CommandName <args>
The old output variable commands are still supported but they are deprecated and produce a warning in the message window. The old Output variable commands were executed by the oModule object.
Set oDesign = oProject.GetDesign ("HfssDesign1")
Set oModule = oDesign.GetModule("OutputVariable")

CreateOutputVariable
DeleteOutputVariable
EditOutputVariable
GetOutputVariables
GetOutputVariableValue

Output Variable Script Commands 12-1


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

CreateOutputVariable
Use:

Add a new output variable to the output variable list. Output variables are
associated with a name and an expression. The name of an output variable
is not permitted to collide with design variables or Sim values or with other
output variable names. It cannot have spaces or any arithmetic and other
operators in it. The definitions can not be cyclic. For example, A = 2*B,
B=3*A is not allowed.

Command:

HFSS>Results>Output Variable

Syntax:

CreateOutputVariable <OutputVarName>, <Expression>,


<Solution Name>, <reportTypeName>, <ContextArray>

Return Value:

None.

Parameters:

<OutputVarName>
Type: <string>
Name of the output variable
<Expression>
Type: <value>
Value to assign to the variable
<SolutionName>
Type: <string>
The name of the solution as seen in the output variable UI.
<reportTypeName >
Type: <string>
The name of the report type as seen in the output variable UI.
<ContextArray>
Type: <variant>
Context for which the output variable expression is being evaluated.

Example:
Set oModule = oDesign.GetModule("OutputVariable")
oModule.CreateOutputVariable "test","mag(S(WavePort1,WavePort1))", _
"Setup1 : LastAdaptive", "Modal Solution Data", _
Array("Domain:=", "Sweep")

DeleteOutputVariable
Use:

Deletes an existing output variable. The variable can only be deleted if it is


not in use by any traces.

Command:

HFSS>Output Variables, dialog Delete Button

12-2 Output Variable Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Syntax:

DeleteOutputVariable <OutputVarName>

Return Value:

None

Parameters:

<OutputVarName>
Type: <string>
Name of the output variable.

Example:
Set oModule = oDesign.GetModule("OutputVariable")
oModule.DeleteOutputVariable efield_online

EditOutputVariable
Use:

Changes the name or expression of an existing output variable.

Syntax:

EditOutputVariable <OrigVarName>, <NewExpression>,


<NewVarName>, <SolutionName>, <reportTypeName>,
<ContextArray>
Provide empty quotes "" as the NewVarName or NewExpression if it should not be
changed.

Return Value:

None

Parameters:

<OrigVarName>
Type: <string>
Name of the original output variable.
<NewExpression>
Type: <string>
New value to assign to the variable.
<NewVarName>
Type: <string>
New name of the variable if any, else pass empty string.
<SolutionName>
Type: <string>
Name of the solution as seen in the output variable UI.
For example: "Setup1 : Last Adaptive"
<ReportTypeName>
Type: <string>
The name of the report type as seen in the output variable UI.
<ContextArray>
Type: <variant>
Context for which the output variable expression is being evaluated
Output Variable Script Commands 12-3

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array(Context:=, <Context>)
Example:
Set oModule = oDesign.GetModule("OutputVariable")
oModule.EditOutputVariable "test", "dB(S(WavePort1,WavePort1)) ", _
"testNew", "Setup1 : LastAdaptive", "Modal Solution Data", _
Array("Domain:=", "Sweep")

GetOutputVariables
Use:

Gets a list of output variables.

Command:

None

Syntax:

GetOutputVariables

Return Value:

Array of output variable names

Parameters:

None.

Example:
Set oAnsoftApp = CreateObject("AnsoftMaxwell.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("iris")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("OutputVariable")
Dim vec
Set vec = oModule.GetOutputVariables
MsgBox(vec.Count)
For i = 0 to vec.Count - 1
MsgBox(vec.Item(i))
Next

GetOutputVariableValue
Use:

Gets the double value of an output variable. Only those expressions that
return a double value are supported. The expression is evaluated only for a
single point.

Syntax:

GetOutputVariableValue(<OutputVarName>,
<IntrinsicVariation>, <SolutionName>, <ReportTypeName>,
<ContextArray>)

Return Value:

Double value of the output variable.

Parameters:

<OutputVarName>

12-4 Output Variable Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Type: <string>
Name of the output variable.
<IntrinsicVariation>
Type: <string>
A set of intrinsic variable value pairs to use when evaluating the output expression.
Example: "Freq='20GHz' Theta='20deg' Phi='30deg' in HFSS
"" in Q3D Extractor
<SolutionName>
Type: <string>
Name of the solution as listed in the output variable UI.
For example: "Setup1 : Last Adaptive"
<ReportTypeName>
Type: <string>
The name of the report type as seen in the output variable UI. Possible values are:
"Modal Solution Data" - Only for Driven Modal solution-type problems with
ports.
"Terminal S Parameters" - Only for Driven Terminal solution-type problems
with ports.
"Eigenmode Parameters" - Only for Eigenmode solution-type problems.
"Fields"
"Far Fields" - Only for problems with radiation or PML boundaries.
"Near Fields" - Only for problems with radiation or PML boundaries.
Emission Test
<Context>
Type: Array
Context for which the output variable expression is being evaluated. This can be
empty if there is no context (for example, for S- parameters). The Reporter uses interpolation to evaluate the values at the given special sweeps. If a requested specialsweep value is outside the range the Reporter does not do extrapolation. Rather it
issues an error message indicating values outside the available range for a primary
sweep.
Example:
Array("Context:=","Infinite Sphere1")
or Array("Context:=","Polyline1")
or Array()
Example:
' ----------------------------------------------------------Output Variable Script Commands 12-5
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

' Sample script to get output variable values in 2.0 products


' ----------------------------------------------------------Dim oAnsoftApp
Dim oDesktop
Dim projects
Dim oProject
Dim oDesign
Dim oModule
Dim val
' ----------------------------------------------------------' Get all of the VBS objects needed to talk to the product
' ----------------------------------------------------------Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
Set projects = oDesktop.GetProjects()
Set oProject = projects(0)
Set oDesign = oProject.GetDesign ("HfssDesign1")
Set oModule = oDesign.GetModule("OutputVariable")
' ----------------------------------------------------------' fieldOV calculated at a point so we don't need distance
' ----------------------------------------------------------val = oModule.GetOutputVariableValue ( "fieldOV", _
"Freq='1GHz'",_
"Setup1 : LastAdaptive", "Fields", _
Array("Context:=", "Point1" ) )
' ----------------------------------------------------------' SValue11 is a Hfss matrix parameter defined as
' S(WavePort1,WavePort1)
' it needs no context
' ----------------------------------------------------------val = oModule.GetOutputVariableValue ( "SValue11", _
"Freq='1GHz'",_
"Setup1 : LastAdaptive", _
"Modal Solution Data", _
Array())
12-6 Output Variable Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

' ----------------------------------------------------------' Now, look at the original output variable in a different design
' variation
' ----------------------------------------------------------val = oModule.GetOutputVariableValue ( "fieldOV", _
"Distance='0' _
Freq='1GHz' xsize='0.4mm' ysize='4.1mm'", _
"Setup1 : LastAdaptive", "Fields", _
Array("Context:=", "Polyline1", "PointCount:=", 1 ) )
' ----------------------------------------------------------' Look at the same variable at a position 1mm along the line
' ----------------------------------------------------------val = oModule.GetOutputVariableValue ( "fieldOV", _
"Distance='1mm'
Freq='1GHz'", _
"Setup1 : LastAdaptive", _
"Fields", _
Array("Context:=", "Polyline1", "PointCount:=", 3 ) _
)
MsgBox( "2 val " & FormatNumber(val) )

Output Variable Script Commands 12-7


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

12-8 Output Variable Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

13

Reporter Editor Script


Commands

Reporter commands should be executed by the oDesign object. One example of accessing this object is:
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("ReportSetup")
All Report and Trace properties can be edited using the ChangeProperty
commands. This includes Title properties, General properties, and Background properties such as border color, fonts, X and Y axis scaling, and number display.
Note: HFSS version 11 and above supports Reporter scripting. When you execute Tools>Record Script, HFSS Operations performed in the Reporter are
automatically recorded.
AddCartesianXMarker
AddDeltaMarker
AddMarker
AddNote
AddTraces
ClearAllMarkers
CopyTracesData
CopyReportData
CopyReportDefinitions
CopyTraceDefinitions
CreateReport
Reporter Editor Script Commands 13-1
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

CreateReportFromTemplate
DeleteAllReports
DeleteReports
DeleteTraces
FFTOnReport

ExportPlotImageToFile
ExportToFile
GetAllReportNames
GetDisplayType
ImportIntoReport
PasteReport
PasteTraces
RenameReport
RenameTrace
UpdateAllReports
UpdateReports
UpdateTrace
UpdateTracesContextandSweeps

13-2 Reporter Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

AddCartesianXMarker
Use:

Adds a marker to a report on the X axis.

Command:

Report2D>Marker>Add X Marker

Syntax:

AddCartesianXMarker <ReportName>, <MarkerID>, <Xcoord>

Return Value:

None

Parameters:

<ReportName>
Type: <string>
Name of Report.
<MarkerID>
Type: <string>
ID of the marker, for example: M1.
<XCoord>
Type: <real>
X location for the marker.

Example:
oModule.AddCartesianXMarker "XY Plot1", "MX1", 0

AddDeltaMarker
Use:

Add markers to calculate differences between two trace points on a plot.

Command:

Report2D>Marker>Add Delta Marker

Syntax:

AddDeltaMarker <ReportName>, <MarkerID_1>, <TraceID_1>,


<Xcoord_1>, <MarkerID_2>, <TraceID_2> <Xcoord_2>

Return Value:

None

Parameters:

<ReportName>
Type: <string>
Name of Report.
<MarkerID>
Type: <string>
ID for the markers.
<TraceID>
Type: <string>
Typically given by expression plus solution name plus coordinate system type.
<XCoord>
Type: <real>
Reporter Editor Script Commands 13-3

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

X location for the marker.


Example:
oModule.AddDeltaMarker "XY Plot 1",
"m3", "dB(S(LumpPort1 LumpPort1)) : Setup1 : Sweep1 : Cartesian", _
"3.22GHz", _
"m4", "dB(S(LumpPort1 LumpPort1)) : Setup1 : Sweep1 : Cartesian",_
"3.93GHz"

AddMarker
Use:

Adds a marker to a trace on a report.

Command:

Report2D>Marker>Add Marker

Syntax:

AddMarker <ReportName>, <MarkerID>, <TraceID>, <Xcoord>,

Return Value:

None

Parameters:

<ReportName>
Type: <string>
Name of Report.
<MarkerID>
Type: <string>
ID for the marker.
<TraceID>
Type: <string>
Typically given by expression plus solution name plus coordinate system type.
<XCoord>
Type: <real>
X location for the marker.

Example:
Set oModule = oDesign.GetModule("ReportSetup")
oModule.AddMarker "XY Plot1", "m1",

"mag(S(Port1 Port1)) : Setup1 : LastAdaptive : Cartesian", "0.3in"

AddNote
Use:

Adds a note at a specified location to a given report.

Command:

Right-click on the plot and select Add Note

Syntax:

AddNote <ReportName> <NoteDataArray>)

Return Value:

None

13-4 Reporter Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Parameters:

<ReportName>
Type: <string>
Name of report.
<NoteDataArray>
Type: Array
Array(NAME:<NoteDataName>, <NoteArray>)
<NoteDataName>
Type: String
<NoteArray>
Array(NAME:<NoteDataSourceName>,
SourceName:=, <SourceName>,
"HaveDefaultPos:=", <boolean>,
"DefaultXPos:=", <XPos>,
"DefaultYPos:=", <YPos>,
String:=, <Note>))

Example:
Set oModule = oDesign.GetModule("ReportSetup")
oModule.AddNote "XY Plot1", Array("NAME:NoteDataSource",
Array("NAME:NoteDataSource", "SourceName:=", "Note1",
"HaveDefaultPos:=", true, "DefaultXPos:=", 1996, "DefaultYPos:=", _
3177, "String:=", "This is a note"))

AddTraces
Use:

Creates a new trace and adds it to the specified report.

Command:

Modify Report>Add Trace

Syntax:

Add Traces <ReportName> <SolutionName> <ContextArray


<FamiliesArray> <ReportDataArray>

Return Value:

None

Parameters:

<ReportName>
Type: <string>
Name of Report.
<SolutionName>
Type: <string>
Name of the solution as listed in the Modify Report dialog box.
Reporter Editor Script Commands 13-5

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

For example: "Setup1 : Last Adaptive"


<ContextArray>
Type: Array of strings
Context for which the expression is being evaluated. This can be an empty string if
there is no context.
Array(Domain:=, <DomainType>)
<DomainType>
ex. Sweep or Time
Array(Context:=, <GeometryType>)
<GeometryType>
ex. Infinite Spheren, Spheren, Polylinen
<FamiliesArray>
Type: Array of strings
Contains sweep definitions for the report.
Array(<VariableName>:= , <ValueArray>)
<ValueArray>
Array(All) or Array(Value1, Value2, ...Valuen)
examples of <VariableName>
Freq, Theta, Distance
<ReportDataArray>
Type: Array of strings
This array contains the report quantity and X, Y, and (Z) axis definitions.
Array(X Component:=, <VariableName>, Y Component:=, <VariableName> |
<ReportQuantityArray>)
<ReportQuantityArray>
ex. Array(dB(S(Port1, Port1)))
Example:
oModule.AddTraces "XY Plot1", "Setup1 : Sweep1", _
Array("Domain:=", "Time", "HoldTime:=", 1, "RiseTime:=", 0, _
13-6 Reporter Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"StepTime:=", 6.24999373748E-012, "Step:=", false, _


"WindowWidth:=", 1, _
"WindowType:=", 0, "KaiserParameter:=", 1, _
"MaximumTime:=", 6.2437437437444E-009), _
Array("Time:=", Array("All"), "OverridingValues:=", Array("0s", _
"6.24999373748188e-012s", ... )),
Array("X Component:=", "Time", _
"Y Component:=", Array("TDRZ(WavePort1)")), _
Array()

ClearAllMarkers
Use:

Clears all markers from a report.

Command:

Report2d>Markers>ClearAllMarkers

Syntax:

ClearAllMarkers <ReportName>

Return Value:

None

Parameters:

<ReportName>
Type: <string>
Name of Report.

Example:
Set oProject = oDesktop.SetActiveProject("dra_antenna")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("ReportSetup")
oModule.ClearAllMarkers "XY Plot 1"

CopyTracesData
Use:

Copy trace data for a paste operation.

Command:

Select a trace in the Project tree, right-click and select Copy Data

Syntax:

CopyTracesData <ReportName> <TracesArray>)

Return Value:

None

Parameters:

<ReportName>
Type: <string>
Name of Report.
<TracesArray>
Type: Array of Strings
Trace definitions from which to copy corresponding data.
Reporter Editor Script Commands 13-7

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:
oModule.CopyTracesData "Transmission", Array("mag(S(Port1,Port2))")

CopyReportData
Use:

Copy all data corresponding to the specified reports.

Command:

Select a report in the Project tree, right-click and select Copy Data

Syntax:

CopyReportData <ReportsArray>

Return Value:

None

Parameters:

<ReportsArray>
Type: Array of strings
Names of reports from which to copy data.

Example:
oModule.CopyReportData Array("Transmission, Reflection")

CopyReportDefinitions
Use:

Copy the definition of a report for paste operations.

Command:

Select a report in the Project tree, right-click and select Copy Definition

Syntax:

CopyReportDefinitions <ReportsArray>

Return Value:

None

Parameters:

<ReportsArray>
Type: Array of strings
Names of reports from which to copy the definitions.

Example:
oModule.CopyReportDefinitions Array("Transmission, Reflection")

CopyTraceDefinitions
Use:

Copy trace definitions for a paste operation.

Command:

Select a trace in the Project tree, right-click and select Copy Definition

Syntax:

CopyTraceDefinitions <ReportName> <TracesArray>

Return Value:

None

Parameters:

<ReportName>
Type: <string>
Name of Report.
<TracesArray>

13-8 Reporter Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Type: Array of strings.


Trace definitions to copy.
Example:
oModule.CopyTraceDefinitions "Transmission",
Array("mag(S(Port1,Port2))")

CreateReport
Use:

Creates a new report with a single trace and adds it to the Results branch in
the project tree.

Command:

HFSS>Results>Create <type> Report

Syntax:

CreateReport <ReportName> <ReportType> <DisplayType>


<SolutionName> <ContextArray> <FamiliesArray>
<ReportDataArray>

Return Value:

None

Parameters:

<ReportName>
Type: <string>
Name of Report.
<ReportType>
Type: <string>
Possible values are:
"Modal S Parameters" - Only for Driven Modal solution-type problems with
ports.
"Terminal S Parameters" - Only for Driven Terminal solution-type problems
with ports.
"Eigenmode Parameters" - Only for Eigenmode solution-type problems.
"Fields"
"Far Fields" - Only for problems with radiation or PML boundaries.
"Near Fields" - Only for problems with radiation or PML boundaries.
Emission Test
<DisplayType>
Type: <string>
If ReportType is "Modal S Parameters", "Terminal S Parameters", or "Eigenmode Parameters", then set to one of the following:
"Rectangular Plot", "Polar Plot", "Radiation Pattern",
"Smith Chart", "Data Table", "3D Rectangular Plot", or
"3D Polar Plot".

Reporter Editor Script Commands 13-9


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

If <ReportType> is "Fields", then set to one of the following:


"Rectangular Plot", "Polar Plot", "Radiation Pattern",
"Data Table", or "3D Rectangular Plot".
If <ReportType> is "Far Fields" or "Near Fields", then set to one of the
following:
"Rectangular Plot", "Radiation Pattern", "Data Table",
"3D Rectangular Plot", or "3D Polar Plot"
If <ReportType> is Emission Test, then set to one of
the following:
Rectangular Plot or Data Table
<SolutionName>
Type: <string>
Name of the solution as listed in the Modify Report dialog box.
For example: "Setup1 : Last Adaptive"
<ContextArray>
Type: Array of strings
Context for which the expression is being evaluated. This can be an empty string if
there is no context.
Array(Domain:=, <DomainType>)
<DomainType>
ex. Sweep or Time
Array(Context:=, <GeometryType>)
<GeometryType>
ex. Infinite Spheren, Spheren, Polylinen
<FamiliesArray>
Type: Array of strings
Contains sweep definitions for the report.
Array(<VariableName>:= , <ValueArray>)
<ValueArray>
13-10 Reporter Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array(All) or Array(Value1, Value2, ...Valuen)


examples of <VariableName>
Freq, Theta, Distance
<ReportDataArray>
Type: Array of strings
This array contains the report quantity and X, Y, and (Z) axis definitions.
Array(X Component:=, <VariableName>, Y Component:=, <VariableName> |
<ReportQuantityArray>)
<ReportQuantityArray>
ex. Array(dB(S(Port1, Port1)))
Example:
oModule.CreateReport Rept2DRectFreq",_
"Modal Solution Data", XY Plot", _
"Setup1 : Sweep1",_
Array("Domain:=", "Sweep"), _
Array("Freq:=", Array("All")), _
Array("X Component:=", "Freq",
"Y Component:=", _ Array("dB(S(LumpPort1,LumpPort1))")), _
Array()
Example:
Set oModule = oDesign.GetModule("ReportSetup")
oModule.CreateReport "3D Cartesian Plot1", "Far Fields",_
"3D Cartesian Plot", "Setup1 : LastAdaptive", _
Array("Context:=", "Infinite Sphere1", "Domain:=", "Sweep"),
Array("Theta:=", Array("All"), "Phi:=", Array("All"), _
"Freq:=", Array("10GHz")), _
Array("X Component:=", "Theta", _
"Y Component:=", "Phi", _
"Z Component:=", Array("rETotal")), _
Array()
Example:
Reporter Editor Script Commands 13-11
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

oModule.CreateReport "ReptSmithFreq",_
"Modal Solution Data", "Smith Plot", "Setup1 : Sweep1", _
Array("Domain:=", "Sweep"), _
Array("Freq:=", Array("All")),_
Array("Polar Component:=", _
Array("ln(Y(LumpPort1,LumpPort1))")), _
Array()

CreateReportFromTemplate
Use:

Create a report from a saved template.

Command:

HFSS>Results>PersonalLib><TemplateName>

Syntax:

CreateReportFromTemplate <TemplatePath>

Return Value:

A new report.

Parameters:

<TemplatePath>
Type: <string>
Path to report template.

Example:
Set oProject = oDesktop.SetActiveProject("wg_combiner")
Set oDesign = oProject.SetActiveDesign("wg_combiner")
Set oModule = oDesign.GetModule("ReportSetup")
oModule.CreateReportFromTemplate

"C:\MyHFSS11Projects\PersonalLib\" & _
"ReportTemplates\TestTemplate.rpt"

DeleteAllReports
Use:

Deletes all existing reports.

Command:

Right-click the report to delete in the project tree, and then click Delete
All Reports on the shortcut menu.

Syntax:

DeleteAllReports

Return Value:

None

Example:
oModule.DeleteAllReports

DeleteReports
Use:

Deletes an existing report or reports.

13-12 Reporter Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Command:

Right-click the report to delete in the project tree, and then click Delete on
the shortcut menu.

Syntax:

DeleteReports(<ReportNameArray>)

Return Value:

None

Parameters:

<ReportNameArray>
Type: Array of strings

Example:
oModule.DeleteReports Array(Rept2DRectFreq)

DeleteTraces
Use:

Deletes an existing traces or traces.

Command:

Right-click the report to delete in the project tree, and then click Delete on
the shortcut menu.

Syntax:

DeleteTraces(<TraceSelectionArray>)

Return Value:

None

Parameters:

<TraceSelectionArray>
Type: Array of strings
Array(<ReportName>:=, <TracesArray>, <TracesArray>,... )
<ReportName>
Type: <string>
Name of Report.
<TracesArray>
Type: Array of strings
This array contains the traces to delete within a report.
Array(<Trace>, <Trace>, ...)
<Trace>
Type: string

Example:
oModule.DeleteTraces Array("XY Plot 1:=", Array("dB(S(LumpPort1,LumpPort1))"), XY Plot 2:=, Array(Mag_E))

ExportPlotImageToFile [Reporter]
Use:

Create field plot exports of existing field plots from a given view points, and
with the model being auto-sized automatically for each view.

Command:

None.
Reporter Editor Script Commands 13-13

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Syntax:

ExportPlotImageToFile(<FileName>, "", <plotItemName>,


<setViewTopDownDirectionByRelativeCS>)

Return Value:

An image file.

Parameters:

<FileName>
Type: <string>
Full path plus file name.
""
Type: <EmptyString>
<PlotItemName>
Type: <string>
Name of fields to plot.
<SetViewTopDownDirectionByRelativeCS>
Type: <string>
Name of relative coordinate system to use for the field plot.

Example:
This example demonstrates the creation of E-field plots of three different orientations:

Mag_E1 created in-plane with the XY-plane of the Global coordinate system
Mag_E2 created in-plane with the XY-plane of the RelativeCS1 coordinate system
Mag_E3 created in-plane with the XY-plane of the RelativeCS2 coordinate system
Dim oAnsoftApp, oDesktop, oProject, oDesign, oEditor, oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject()
Set oDesign = oProject.GetActiveDesign()
Set oModule = oDesign.GetModule("FieldsReporter")
'First set the module FieldsReporter
oModule.ExportPlotImageToFile "C:\TestEPITF1.jpg", "", "Mag_E1",
"Global"
oModule.ExportPlotImageToFile "C:\TestEPITF2.jpg", "", "Mag_E2",
"RelativeCS1"
oModule.ExportPlotImageToFile "C:\TestEPITF3.jpg", "", "Mag_E3",
"RelativeCS2"

13-14 Reporter Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

ExportToFile [Reporter]
Use:

From a data table or plot, generates text format, comma delimited, tab
delimited, or .dat type output files.

Command:

Right-click on report name in the Project tree and select Export Data.

Syntax:

ExportToFile <ReportName>, <FileName>

Return Value:

None

Parameters:

<ReportName>
Type: string
<FileName>
Type: string
Path and file name.
.txt

Post processor format file

.csv

Comma-delimited data file

.tab

Tab-separated file

.dat

Ansoft plot data file

Example:
oDesign.ExportToFile Plot1, c:\report1.dat

FFTOnReport
Use:

Perform an FFT on a selected report.

Command:

HFSS>Results>Perform FFT on Report

Syntax:

FFTOnReport <plotName>, <FFTWindowType>, <function>

Return Value:

Creates a plot named FFT PlotName

Parameters:

<PlotName>
Type: string
<FFTWindowType>
Type: string
Rectangular, Tri, Van Hann, Hamming, Blackman,Lanczos, Weber, Welch.
<function>
Type: string
<none>, ang_deg, ang_rad, arg, cang_deg, cang_rad, dB, dB1 normalize, dB20normalize, dBc, im, mag, normalize, re.
Reporter Editor Script Commands 13-15

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 14.0.0
' 3:39:35 PM

Mar 16, 2011

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("OptimTee")
Set oDesign = oProject.SetActiveDesign("TeeModel")
Set oModule = oDesign.GetModule("Solutions")
oModule.FFTOnReport "XY Plot 1", "Rectangular", "dB"

GetAllReportNames
Use:

Gets the names of existing reports in a design.

Syntax:

GetAllReportNames()

Return Value:

Array of report names.

Parameters:

None

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHFSS.HFSSScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
13-16 Reporter Editor Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject
Set oDesign = oProject.GetActiveDesign
Set oReportModule = oDesign.GetModule("ReportSetup")
Dim names
names = oReportModule.GetAllReportNames
For index = 0 to UBound(names)
MsgBox(names(index))
Next
Set oFieldReportModule = oDesign.GetModule("FieldsReporter")
Set collection = oFieldReportModule.GetFieldPlotNames
For index = 0 to collection.Count-1
MsgBox(collection.Item(index))
Next

GetDisplayType
Use:

Get the display type of a report.

Command:

None

Syntax:

GetDisplayType <reportName>

Return Value:

Report <displaytype> of a report.


<DisplayType>
Type: <string>
If ReportType is "Modal S Parameters", "Terminal S Parameters", or "Eigenmode Parameters", then returns one of the following:
"Rectangular Plot", "Polar Plot", "Radiation Pattern",
"Smith Chart", "Data Table", "3D Rectangular Plot", or
"3D Polar Plot".
If <ReportType> is "Fields", then returns one of the following:
"Rectangular Plot", "Polar Plot", "Radiation Pattern",
"Data Table", or "3D Rectangular Plot".
If <ReportType> is "Far Fields" or "Near Fields", then returns one of
the following:
"Rectangular Plot", "Radiation Pattern", "Data Table",
"3D Rectangular Plot", or "3D Polar Plot"
Reporter Editor Script Commands 13-17

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

If <ReportType> is Emission Test, then returns one of


the following:
Rectangular Plot or Data Table
Parameters:

<ReportName>
Type: <string>
Report name.

Example:
Set oDesign = oProject.SetActiveDesign("wg_combiner")
Set oModule = oDesign.GetModule("ReportSetup")
MyPlotDisplayType = oModule.GetDisplayType "XY Plot1"

ImportIntoReport
Use:

Imports .tab, .csv, and .dat format files into a report.

Command:

Right-click on report name in the Project tree and select Export Data.

Syntax:

ImportIntoReport <ReportName>, <FileName>

Return Value:

None

Parameters:

<ReportName>
Type: string
<FileName>
Type: string
Path and file name.
.csv

Comma-delimited data file

.tab

Tab-separated file

.dat

Ansoft plot data file

Example:
oDesign.ImportIntoReport Plot1, c:\report1.dat

PasteReports
Use:

Paste copied reports to results in the current project.

Command:

Paste

Syntax:

PasteReports

13-18 Reporter Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Return Value:

None

Parameters:

None

Example:
oModule.PasteReports

PasteTraces
Use:

To paste copied traces to a named plot.

Command:

Paste

Syntax:

PasteTraces <plotName>

Return Value:

None

Parameters:

<plotName>
Type: <string>
Name of plot.

Example:
oModule.PasteTraces "XY Plot1"

RenameReport
Use:

Renames an existing report.

Command:

Select a report on the Project tree, right-click and select Rename

Syntax:

RenameReport <OldReportName>, <NewReportName>

Return Value:

None

Parameters:

<OldReportName>
Type: string
<NewReportName>
Type: string

Example:
oModule.RenameReport "XY Plot1", "Reflection"

RenameTrace
Use:

To rename a trace in a plot

Command:

None

Syntax:

RenameTrace <plotName> <traceID> <newName>

Return Value:

None

Parameters:

<plotName>
Reporter Editor Script Commands 13-19

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Type: <string>
Name of plot.
<traceID>
Type: <string>
Name of trace.
<newName>
Type: <string>
New trace name.
Example:
oModule.RenameTrace "XY Plot1", "dB(S(WavePort1,WavePort1))1",_
Port1dbS"

UpdateAllReports
Use:

Updates the specified reports in the Results branch in the project tree.

Command:

HFSS>Results>Update All Reports

Syntax:

UpdateReports Array("<plotname>")

Return Value:

None.

Parameters:

<plotname>
Type: <string>
Name of plot.

Example:
Set oModule = oDesign.GetModule("ReportSetup")
oModule.UpdateAllReports

UpdateReports
Use:

Updates the specified reports in the Results branch in the project tree.

Command:

Update Report

Syntax:

UpdateReports Array("<plotname>")

Return Value:

None.

Parameters:

<plotname>
Type: <string>
Name of plot.

Example:
Set oModule = oDesign.GetModule("ReportSetup")
oModule.UpdateReports Array("XY Plot 1")

13-20 Reporter Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

UpdateTraces
Use:

Update the traces in a report for which traces are not automatically
updated by the Report Traces dialog, Update Report, Real Time selection.

Command:

Report dialogue, Apply Traces button

Syntax:

UpdateTraces <plotName> Array(<TraceDef>) Array()

Return Value:
Parameters:

<ReportName>
Type: <string>
Name of Report.
<SolutionName>
Type: <string>
Name of the solution as listed in the Modify Report dialog box.
For example: "Setup1 : Last Adaptive"
<ContextArray>
Type: Array of strings
Context for which the expression is being evaluated. This can be an empty string if
there is no context.
Array(Domain:=, <DomainType>)
<DomainType>
ex. Sweep or Time
Array(Context:=, <GeometryType>)
<GeometryType>
ex. Infinite Spheren, Spheren, Polylinen
<FamiliesArray>
Type: Array of strings
Contains sweep definitions for the report.
Array(<VariableName>:= , <ValueArray>)
<ValueArray>
Array(All) or Array(Value1, Value2, ...Valuen)
examples of <VariableName>
Freq, Theta, Distance
Reporter Editor Script Commands 13-21

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<ReportDataArray>
Type: Array of strings
This array contains the report quantity and X, Y, and (Z) axis definitions.
Array(X Component:=, <VariableName>, Y Component:=, <VariableName> |
<ReportQuantityArray>)
<ReportQuantityArray>
ex. Array(dB(S(Port1, Port1)))
Array()
Type: Empty array.
Denotes the end of the UpdateTraces command.
Example:
Set oModule = oDesign.GetModule("ReportSetup")
oModule.UpdateTraces "XY Plot1", _ Array("dB(S(WavePort1,WavePort1))"), _
"Setup1 : Sweep1", _
Array("Domain:=", "Sweep"), _
Array("Freq:=", Array("All")), _
Array("X Component:=", "Freq", _
"Y Component:=", Array("dB(S(WavePort1,WavePort1))")), _
Array()
Example:
oModule.UpdateTraces "XY Plot 1", Array("dB(S(WavePort1,WavePort1))"), _
"Setup1 : Sweep1", _
Array("Domain:=", "Time", "HoldTime:=", 1, _
"RiseTime:=", 0, "StepTime:=", 0, "Step:=", false, _
"WindowWidth:=", 1, _
"WindowType:=", 0, "KaiserParameter:=", 1, _
"MaximumTime:=", 0), _
Array("Time:=", Array("All")), _
Array("X Component:=", "Time", _
"Y Component:=", Array("dB(S(WavePort1,WavePort1))")), _
Array()

13-22 Reporter Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

UpdateTracesContextandSweeps
Use:

Use this command to edit sweeps and context of multiple traces without
affecting their component expressions.

Command:

Modify Report with multiple traces selected.

Syntax:

UpdateTracesContextandSweeps

Return Value:

None.

Parameters:

<ReportName>
Type: <string>
Name of Report.
Array(<traceIDs>)
<traceID>
Type: <string>
Name of trace.
<SolutionName>
Type: <string>
Name of the solution as listed in the Modify Report dialog box.
For example: "Setup1 : Last Adaptive"
<ContextArray>
Type: string.
Context for which the expression is being evaluated. This can be an empty string if
there is no context.
ex. Sweep or Time
Array<pointSet>
Type: <string>
Point set for the selected traces, for example, X and Y values for the plot.

Example:
Set oProject = oDesktop.SetActiveProject("Tee")
Set oDesign = oProject.SetActiveDesign("TeeModel")
Set oModule = oDesign.GetModule("ReportSetup")
oModule.UpdateTracesContextAndSweeps _
"Active S Parameter Quick Report", _
Array( _
Reporter Editor Script Commands 13-23
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"dB(ActiveS(Port1:1))", "dB(ActiveS(Port2:1))"), _
"Setup1 : Sweep1", Array(), _
Array("Freq:=", _
Array( _
"9GHz", "9.05GHz", "9.1GHz", "9.15GHz", "9.2GHz", _
"9.25GHz", "9.3GHz", "9.35GHz",

"9.4GHz", "9.45GHz", "9.5GHz", "9.55GHz", _


"9.6GHz", "9.65GHz", "9.7GHz",

"9.75GHz", "9.8GHz", "9.85GHz", "9.9GHz", "9.95GHz", "10GHz"),_


"offset:=", Array("All"))

13-24 Reporter Editor Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

14

Boundary and Excitation


Module Script Commands

Boundary and excitation commands should be executed by the


"BoundarySetup" module.
Set oModule = oDesign.GetModule("BoundarySetup")
Conventions Used in this Chapter
<BoundName>
Type: string.
Name of a boundary.
<AssignmentObjects>
Type: Array of strings.
An array of object names.
<AssignmentFaces>
Type: Array of integers.
An array of face IDs. The ID of a face can be determined through the user interface
using the 3D Modeler>Measure>Area command. The face ID is given in the Measure Information dialog box.
<LineEndPoint>
Array(<double>, <double>, <double>)

Boundary and Excitation Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Legal Names for Boundaries in HFSS Scripts


Perfect E

Radiation

Perfect H

Symmetry

Finite Conductivity

Master

Impedance

Slave

Layered Impedance

Lumped RLC

Legal Names for Excitations in HFSS Scripts


Wave Port

Hertizian-Dipole Incident Wave

Lumped Port

Cylindrical Incident Wave

Voltage

Gaussian Beam

Current

Linear Antenna Incident Wave

Magnetic Bias

Far Field Incident Wave

Plane Incident Wave

Near Field Incident Wave

General Commands Recognized by the Boundary/Excitations Module


Script Commands for Creating and Modifying Boundaries
Script Commands for Creating and Modifying Boundaries in HFSS-IE
Script Commands for Creating and Modifying PMLs

General Commands Recognized by the Boundary/Excitations Module


AutoIdentifyPorts
AutoIdentifyTerminals
ChangeImpedanceMult
DeleteAllBoundaries
DeleteAllExcitations
DeleteBoundaries
GetBoundaryAssignment
GetBoundaries
GetBoundariesOfType
GetDefaultBaseName
GetExcitation
GetExcitationsOfType
14-2 Boundary and Excitation Module Script
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

GetNumBoundaries
GetNumBoundariesOfType
GetNumExcitations
GetNumExcitationsOfType
GetPortExcitationsCount
ReassignBoundary
RenameBoundary
ReprioritizeBoundaries
SetDefaultBaseName

AutoIdentifyPorts
Use:

Automatically assign ports and terminals in a terminal design.

Command:

HFSS>Excitations>Assign>Wave Port|Lumped Port

Syntax:

AutoIdentifyPorts <FaceIDArray> <IsWavePort>,


<ReferenceConductorsArray> <BaseNameforCreatedPorts>
<UseConductorNamesAsBaseNameforTerminals>

Return Value:

None.

Parameters:

<FaceIDArray>
Array(NAME:Faces, <FaceID>, <FaceID>, ...)
<IsWavePort>
Type: Boolean
true = waveport, false = lumped port
<ReferenceConductorsArray>
Array(NAME:ReferenceConductors, <ConductorName>, <ConductorName>, ...)
<BaseNameforCreatedPorts>
Type: <string>
<empty string> = default name for the wave or lumped port, <string> = base name to
use for created ports
<UseConductorNamesAsBaseNameforTerminals>
Type: Boolean
true = use conductor names, false = use port object name as base name

Example:
Set oModule = oDesign.GetModule("BoundarySetup"
oModule.AutoIdentifyPorts Array("NAME:Faces", 52), true, _
Array("NAME:ReferenceConductors", Conductor1) true

Boundary and Excitation Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

AutoIdentifyTerminals
Use:

Automatically identify the terminals within the given ports.

Command:

HFSS>Excitations>Assign>Auto Assign Terminals

Syntax:

AutoIdentifyTerminals <ReferenceConductorsArray>,
<PortNames> <UseConductorNamesAsBaseNameforTerminals>

Return Value:

None

Parameters:

<ReferenceConductors>
Array(NAME:ReferenceConductors, <ConductorName>, <ConductorName>, ...)
<portNames>
List of names.
<UseConductorNamesAsBaseNameforTerminals>
Type: Boolean
true = use conductor names, false = use port object name as base name

Example:
Set oModule = oDesign.GetModule("BoundarySetup"
oModule.AutoIdentifyTerminals Array("NAME:ReferenceConductors", Conductor1), WavePort1 true

ChangeImpedanceMult
Use:

Modifies the port impedance multiplier.

Command:

HFSS>Excitations>Edit Impedance Mult

Syntax:

ChangeImpedanceMult <MultVal>

Return Value:

None

Parameters:

<MultVal>
Type: <value>
New value for the impedance multiplier.

Example:
oModule.ChangeImpedanceMult 0.5

DeleteAllBoundaries
Use:

Deletes all boundaries.

Command:

HFSS>Boundaries>Delete All

Syntax:

DeleteAllBoundaries

Return Value:

None

Example:

oModule.DeleteAllBoundaries

14-4 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

DeleteAllExcitations
Use:

Deletes all excitations.

Command:

HFSS>Excitations>Delete All

Syntax:

DeleteAllExcitations

Return Value:

None

Example:
oModule.DeleteAllExcitations

DeleteBoundaries
Use:

Deletes the specified boundaries and excitations.

Command:

Delete command in the List dialog box. Click HFSS>List to open the List
dialog box.

Syntax:

DeleteBoundaries <NameArray>

Return Value:

None

Parameters:

<NameArray>
Type: Array of strings
An array of boundary names.

Example:
oModule.DeleteBoundaries Array("PerfE1", "WavePort1")

GetBoundaryAssignment
Use:

Gets a list of face IDs associated with the given boundary or excitation
assignment.

Syntax:

GetBoundaryAssignment(<BoundaryName>)

Return Value:

Returns integer array of face IDs.

Parameters:

<BoundaryName>
Type: <string>
Previously defined boundary or excitation name.

Example:
list = oModule.GetBoundaryAssignment("Rad1")

GetBoundaries
Use:

Gets boundary names for a project.

Syntax:

GetBoundaries()

Return Value:

Array of boundary names.


Boundary and Excitation Module Script Commands

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Parameters:

None

Example:
bndinfo_array = oModule.GetBoundaries()

GetBoundariesOfType
Use:

Gets boundary names of the given type.

Syntax:

GetBoundariesOfType(<BoundaryType>)

Return Value:

Array of boundary names of the given type.

Parameters:

<BoundaryType>
Type:<string>
Name of legal boundary type.
For example: "Radiation".

Example:
bndname_array = oModule.GetBoundariesOfType("Perfect E")

GetDefaultBaseName
Use:

Gets the default base name for boundaries for a project.

Syntax:

GetDefaultBaseName <BoundaryType>

Return Value:

String of boundary default base name.

Parameters:

<BoundaryType>
Type:<string>
Name of legal boundary type.
For example: "Radiation".

Example:
bnddefault_BaseName = oModule.GetDefaultBaseName "Radiation"

GetExcitations
Use:

Gets excitation port and terminal names for a model.

Syntax:

GetExcitations()

Return Value:

Pairs of strings. The first is the name of the excitation (e.g. "port1:1") and
the second is its type ("Wave Port")

Parameters:

None

Example:
excite_name_array = oModule.GetExcitations()

14-6 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

GetExcitationsOfType
Use:

Gets excitation names of the given type.

Syntax:

GetExcitationsOfType(<ExcitationType>)

Return Value:

Array of excitation names of the given type.

Parameters:

<ExcitationType>
Type: <string>
Name of legal excitation type.
For example: "Plane Incident Wave.

Example:
excite_name_array = _
oModule.GetExcitationsOfType("Wave Port")

GetNumBoundaries
Use:

Gets the number of boundaries in a design.

Syntax:

GetNumBoundaries()

Return Value:

Integer count

Parameters:

None

Example:
numbound = oModule.GetNumBoundaries()

GetNumBoundariesOfType
Use:

Gets the number of boundaries of the given type.

Syntax:

GetNumBoundariesOfType(<BoundaryType>)

Return Value:

Integer count

Parameters:

<BoundaryType>
Type: <string>

Example:
numbound = oModule.GetNumBoundariesOfType("Perfect E")

GetNumExcitations
Use:

Gets the number of excitations in a design, including all defined modes and
terminals of ports.

Syntax:

GetNumExcitations()

Return Value:

Integer count

Parameters:

None
Boundary and Excitation Module Script Commands

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:
numexcite = oModule.GetNumExcitations()

GetNumExcitationsOfType
Use:

Gets the number of excitations of the given type, including all defined
modes and terminals of ports.

Syntax:

GetNumExcitationsOfType(<ExcitationType>)

Return Value:

Integer count

Parameters:

<ExcitationType>
Type: <string>

Example:
numexcite = oModule.GetNumExcitationsOfType("Voltage")

GetPortExcitationCounts
Use:

Gets all port names and corresponding number of modes/terminals for each
port excitation.

Syntax:

GetPortExcitationCounts()

Return Value:

Array of port names (Type: <string>) and corresponding mode/terminal


counts (Type: <integer>).

Parameters:

None

Example:
portinfo = oModule.GetPortExcitationCounts()

ReassignBoundary
Use:

Specifies a new geometry assignment for a boundary.

Command:

HFSS>Boundaries>Reassign or HFSS>Excitations>Reassign

Syntax:

ReassignBoundary Array("Name:<BoundName>",
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)

Return Value:

None

Example:
oModule.ReassignBoundary Array("NAME:PerfE1",_
"Objects:=", Array("Box2", "Box3"),_
"Faces:=", Array(12, 11))

14-8 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

RenameBoundary
Use:

Renames a boundary or excitation.

Command:

Right-click a boundary in the project tree, and then click Rename on the
shortcut menu.

Syntax:

RenameBoundary <OldName>, <NewName>

Return Value:

None

Parameters:

<OldName>
Type: <string>
<NewName>
Type: <string>

Example:
oModule.RenameBoundary "PerfE1"

"PerfE"

ReprioritizeBoundaries
Use:

Specifies the order in which the boundaries and excitations are recognized
by the solver. The first boundary in the list has the highest priority. Note:
this command is only valid if all defined boundaries and excitations appear
in the list. All ports must be listed before any other boundary type.

Command:

HFSS>Boundaries>Reprioritize

Syntax:

ReprioritizeBoundaries <NewOrderArray>

Return Value:

None

Parameters:

<NewOrderArray>
Array("NAME:NewOrder", <BoundName>, <BoundName>, ...)

Example:
oModule.ReprioritizeBoundaries Array("NAME:NewOrder", _
"Imped1", "PerfE1", "PerfH1")

SetDefaultBaseName
Use:

Sets the default base name for boundaries for a project.

Syntax:

SetDefaultBaseName <BoundaryType>, <DefaultName>

Return Value:

String of boundary default base name.

Parameters:

<BoundaryType>
Type:<string>
Name of legal boundary type.
Boundary and Excitation Module Script Commands

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

For example: "Radiation".


<NewName>
Type: <string>
Example:
bnddefault_BaseName = oModule.SetDefaultBaseName "Radiation",_
"RadBnd"

14-10 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Script Commands for Creating and Modifying Boundaries


Following are script commands for creating and modifying boundaries that are recognized by the
"BoundarySetup" module. In the following commands, all named data can be included or
excluded as desired and may appear in any order.
AssignCurrent
AssignFiniteCond
AssignFloquet
AssignIERegion
AssignImpedance
AssignIncidentWave
AssignLayeredImp
AssignLumpedPort
AssignLumpedRLC
AssignMagneticBias
AssignMaster
AssignPerfectE
AssignPerfectH
AssignRadiation
AssignRadiation
AssignScreeningImpedance
AssignSymmetry
AssignTerminal
AssignVoltage
AssignWavePort
EditCurrent
EditDiffPairs
EditFiniteCond
EditImpedance
EditIncidentWave
EditLayeredImpedance
EditMaster
EditPerfectE
EditPerfectH
EditLumpedPort
EditLumpedRLC
Boundary and Excitation Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

EditMagneticBias
EditRadiation
EditSlave
EditSymmetry
EditTerminal
EditVoltage
EditWavePort
SetTerminalReferenceImpedances
UnassignIERegions

AssignCurent
Use:

Creates a current source.

Command:

HFSS>Excitations>Assign>Current

Syntax:

AssignCurrent <CurrentArray>

Return Value:

None

Parameters:

<CurrentArray>
Array("NAME:<BoundName>",
"Objects:=", <AssignmentObjects>,
"Current:=", <value>,
<DirectionArray>,
"Faces:=", <AssignmentFaces>)
<DirectionArray>
Array("NAME:Direction",
"Start:=", <LineEndPoint>,
"End:=", <LineEndPoint>)

Example:
oModule.AssignCurrent Array("NAME:Current1",_
"Current:=", "1000mA",_
Array("NAME:Direction",_
"Start:=", Array(-0.4, 0.4, -1.6),_
"End:=", Array(-0.4, 0.4, 0)), _
"Faces:=", Array(12))

14-12 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

AssignFiniteCond
Use:

Creates a finite conductivity boundary.

Command:

HFSS>Boundaries>Assign>Finite Conductivity

Syntax:

AssignFiniteCond <FiniteCondArray>

Return Value:

None

Parameters:

<FiniteCondArray>
Array("NAME:<BoundName>",
"UseMaterial:=",<bool>,
"Material:=", <string>,
"Conductivity:=", <value>,
"Permeability:=", <value>,
"Roughness:=" <value>,
"InfGroundPlane:=", <bool>,
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>
Radius:=", "<value>", "Ratio:=", "<value>"))
UseMaterial
If True, provide Material parameter.
If False, provide Conductivity and Permeability parameters.
For Huray Roughness, use Radius and Ratio. For Groisse roughness model, use Roughness.

Example:
oModule.AssignFiniteCond Array("NAME:FiniteCond1",_
"UseMaterial:=", false,_
"Conductivity:=", "58000000",_
"Permeability:=", "1",_
"InfGroundPlane:=", false,_
"Faces:=", Array(12))
Example:
oModule.AssignFiniteCond Array("NAME:FiniteCond1",_
"UseMaterial:=", true, _
"Material:=", "copper",_
"InfGroundPlane:=", false,_
"Faces:=", Array(12)
Boundary and Excitation Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Radius:=", "1um", "Ratio:=", "1"))

AssignFloquet
Use:

Create a Floquet port.

Command:

HFSS>Excitations>Assign>Floquet

Syntax:

AssignFloquetPort <FloquetPortArray>

Return Value:

None.

Parameters:

<FloquetPortArray>
Array("NAME:<BoundName>",
"Faces:=", <FaceIDArray>,
<ModesArray>,
"NumModes:=", <Int>,
"RenormalizeAllTerminals:=", <Boolean>,
"DoDeembed:=", <Boolean>,
Array("NAME:Modes", Array("NAME:Mode1",
"ModeNum:=", <Int>,
"UseIntLine:=", <Boolean>),
Array("NAME:Mode2", "ModeNum:=", <Int>,
"UseIntLine:=", <Boolean>)),
"ShowReporterFilter:=", <Boolean>,
"UseScanAngles:=", <Boolean>,
"Phi:=", "<numdeg>",
"Theta:=", "<numdeg>",
Array("NAME:LatticeAVector",
"Start:=", Array("<num><units>", "num><units>",
"<num><units>"),
"End:=", Array("<num><units>", "num><units>",
"<num><units>")),
Array("NAME:LatticeBVector",
"Start:=", Array("<num><units>", "num><units>",
"<num><units>"),
"End:=", Array("<num><units>", "num><units>",
"<num><units>")),
Array("NAME:ModesCalculator",
"Frequency:=", "<Value>GHz",
"FrequencyChanged:=", <Boolean>,
"PhiStart:=", "<num>deg",

14-14 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"PhiStop:=", "<num>deg",
"PhiStep:=", "<num>deg",
"ThetaStart:=", "<num>deg",
"ThetaStop:=", "<num>deg",
"ThetaStep:=", "<num>deg"),
Array("NAME:ModesList",
Array("NAME:Mode",
"ModeNumber:=", <ModeID>,
"IndexM:=", <Index>,
"IndexN:=", <Index>,
"KC2:=", <value>,
"PropagationState:=", "Propagating",
"Attenuation:=", 0,
"PolarizationState:=", "TE",
"AffectsRefinement:=", <Boolean>),
Array("NAME:Mode",
"ModeNumber:=", <ModeID>,
"IndexM:=", <Index>,
"IndexN:=", <Index>,
"KC2:=", <value>,
"PropagationState:=", "<Propagating>",
"Attenuation:=", <value>,
"PolarizationState:=", "<TE or TM>",
"AffectsRefinement:=", <Boolean>)))
Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 13.0.0
' 1:54:11 PM

Jun 15, 2010

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Boundary and Excitation Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project44")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignFloquetPort Array("NAME:FloquetPort1",
"Faces:=", Array(7),
"NumModes:=", 2,
"RenormalizeAllTerminals:=", true,
"DoDeembed:=", false,
Array("NAME:Modes", Array("NAME:Mode1", "ModeNum:=", 1,
"UseIntLine:=", false),
Array("NAME:Mode2", "ModeNum:=", 2, "UseIntLine:=", false)),
"ShowReporterFilter:=", false,
"UseScanAngles:=", true, "Phi:=", "0deg", "Theta:=", "0deg",
Array("NAME:LatticeAVector", "Start:=", Array("0mm", "0mm", "0.8mm"),
"End:=", Array( "0mm", "0.6mm", "0.8mm")),
Array("NAME:LatticeBVector", "Start:=", Array("0mm", "0mm", "0.8mm"),
"End:=", Array("0.8mm", "0mm", "0.8mm")),
Array("NAME:ModesCalculator", "Frequency:=", "1GHz",
"FrequencyChanged:=", false,
"PhiStart:=", "0deg", "PhiStop:=", "0deg", "PhiStep:=", "0deg", "ThetaStart:=", "0deg", "ThetaStop:=", "0deg", "ThetaStep:=", "0deg"),
Array("NAME:ModesList", Array("NAME:Mode", "ModeNumber:=", 1,
"IndexM:=", 0, "IndexN:=", 0, "KC2:=", 0,
"PropagationState:=", "Propagating",
"Attenuation:=", 0,
"PolarizationState:=", "TE",
"AffectsRefinement:=", false),
Array("NAME:Mode", "ModeNumber:=", 2,
"IndexM:=", 0, "IndexN:=", 0,
"KC2:=", 0,
"PropagationState:=", "Propagating",
"Attenuation:=", 0,
14-16 Boundary and Excitation Module Script
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"PolarizationState:=", "TM", "AffectsRefinement:=", false)))

AssignIERegion
Use:

Assign an IE Region to a conductor contained within a FEBI Radiation


boundary.

Command:

Assign IE Region

Syntax:

AssignIERegion <"geometryName">

Return Value:

None

Parameters:

<GeometryName>
Type: String
Name of the geometry assigned as an IE Region.

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 14.0.0
' 2:26:27 PM

Mar 07, 2011

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project58")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignIERegion "Box1"

AssignImpedance
Use:

Creates an impedance boundary for an HFSS design.

Command:

HFSS>Boundaries>Assign>Impedance

Syntax:

AssignImpedance <ImpedanceArray>

Return Value:

None
Boundary and Excitation Module Script Commands

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Parameters:

<ImpedanceArray>
Array("NAME:<BoundName>",
"Resistance:=", <value>,
"Reactance:=", <value>,
"InfGroundPlane:=", <bool>,
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)

Example:
oModule.AssignImpedance Array("NAME:Imped1",_
"Resistance:=", "50",_
"Reactance:=", "50",_
"InfGroundPlane:=", false,_
"Faces:=", Array(12))

AssignIncidentWave
Use:

Creates an incident wave excitation.

Command:

HFSS>Excitations>Assign>IncidentWave

Syntax:

AssignIncidentWave <IncidentWaveArray>

Return Value:

None

Parameters:

<IncidentWaveArray>
Array("NAME:<BoundName>",
"IsCartesian:=",<bool>
"EoX:=", <value>,
"EoY:=", <value>,
"EoZ:=", <value>,
"kX:=", <value>,
"kY:=", <value>,
"kZ:=", <value>
"PhiStart:=",<value>,
"PhiStop:=", <value>,
"PhiPoints:=", <int>,
"ThetaStart:=", <value>,
"ThetaStop:=", <value>,
"ThetaPoints:=", <int>,
"EoPhi:=", <value>,

14-18 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"EoTheta:=", <value>)
IsCartesian
If true, provide the EoX, EoY, EoZ, kX, kY, kZ parameters.
If false, provide the PhiStart, PhiStop, PhiPoints, ThetaStart, ThetStop, ThetaPoints, EoPhi, EoTheta parameters.
Example:
oModule.AssignIncidentWave Array("NAME:IncWave1",_
"IsCartesian:=", true,_
"EoX:=", "1", "EoY:=", "0", "EoZ:=", "0",_
"kX:=", "0", "kY:=", "0", "kZ:=", "1")
Example:
oModule.AssignIncidentWave Array("NAME:IncWave2",_
"IsCartesian:=", false,_
"PhiStart:=","0deg",_
"PhiStop:=", "90deg",_
"PhiPoints:=", 2,_
"ThetaStart:=", "0deg",_
"ThetaStop:=", "180deg",_
"ThetaPoints:=", 3, _
"EoPhi:=", "1", "EoTheta:=", "0")

AssignLayeredImp
Use:

Creates a layered impedance boundary.

Command:

HFSS>Boundaries>Assign>Layered Impedance

Syntax:

AssignLayeredImp <LayeredImpArray>

Return Value:

None

Parameters:

<LayeredImpArray>
Array("NAME:<BoundName>",
"Frequency:=", <value>,
"Roughness:=", <value>,
"IsInternal:=", <bool>,
<LayersArray>,
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)
Boundary and Excitation Module Script Commands

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<LayersArray>
Array("NAME:Layers",
<OneLayerArray>, <OneLayerArray>, ...)
<OneLayerArray>
Array("NAME:<LayerName>",
"LayerType:=", <LayerType>,
"Thickness:=",<value>,
"Material:=", <string>)
<LayerName>
Type: <string>
Specifies the layer number, such as "Layer1" or "Layer2"
<LayerType>
Type: <string>
Should be specified for the last layer only.
Possible values: "Infinite", "PerfectE", or "PerfectH"
Thickness
Thickness of the layer. Should be specified for all layers except the last layer.
Material
Material assigned on the layer. For the last layer, do not specify a material if the
LayerType is "PerfectE" or "PerfectH".
InfGroundPlane <boolean>
For HFSS designs, you can specify whether one layer is an infinite ground plane.
Example:
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignLayeredImp Array("NAME:Layered1",
"Objects:=", Array("Rectangle1"),
"Frequency:=", "10GHz",
"Roughness:=", "0um",
"IsInternal:=", false,
14-20 Boundary and Excitation Module Script
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array("NAME:Layers",
Array("NAME:Layer1",
"Thickness:=",

"1um",

"Material:=", "vacuum"),
Array("NAME:Layer2",
"LayerType:=", "Infinite",
"Thickness:=",

"1um",

"Material:=", "vacuum")),
"InfGroundPlane:=", true)

AssignLumpedPort
Use:

Creates a lumped port.

Command:

HFSS>Excitations>Assign>Lumped Port

Syntax:

AssignLumpedPort <LumpedPortArray>

Return Value:

None

Parameters:

<LumpedPortArray>
Array("NAME:<BoundName>",
"Faces:=", <FaceIDArray>,
"RenormalizeAllTerminals:=", <boolean>
"DoDeembed:=" <boolean"
<ModesArray>,
TerminalIDList:=, <TerminalsArray>,
"FullResistance:=", <value>,
"FullReactance:=", <value>,
)

Example:
oModule.AssignLumpedPort Array("NAME:LumpPort1",_
Array("NAME:Modes",_
"Resistance:=", "50Ohm",_
"Reactance:=","0Ohm",_
Array("NAME:Mode1",_
"ModeNum:=",1,_
"UseIntLine:=", true,_
Array("NAME:IntLine",_
"Start:=", Array(-0.4, 0.4, -1.6),_
Boundary and Excitation Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"End:=", Array(-0.4, 0.4, 0)),_


"CharImp:=", "Zpv")),_
"Faces:=", Array(11))
Example:
oModule.AssignLumpedPort Array("NAME:LumpPort1", _
"Faces:=", Array(52), "TerminalIDList:=", Array(), _
"FullResistance:=", "50ohm", "FullReactance:=", "0ohm")
Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 14.0.0
' 2:18:20 PM

May 20, 2011

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("calib_modal_test")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignLumpedPort "lp2", Array("NAME:lp2",
"RenormalizeAllTerminals:=", true,
"DoDeembed:=", true,
Array("NAME:Modes", Array("NAME:Mode1",
"ModeNum:=", 1,
"UseIntLine:=", true,
Array("NAME:IntLine",
"Start:=", Array( "120mm", "50mm", "40mm"),
"End:=", Array("120mm", "50mm", "120mm")),
"CharImp:=", "Zpi")),
"ShowReporterFilter:=", false,
"ReporterFilter:=", Array(true), "FullResistance:=", "50ohm",
"FullReactance:=", "0ohm")

14-22 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

AssignLumpedRLC
Use:

Creates a lumped RLC boundary.

Command:

HFSS>Boundaries>Assign>Lumped RLC

Syntax:

AssignLumpedRLC <LumpedRLCArray>

Return Value:

None

Parameters:

<LumpedRLCArray>
Array("NAME:<BoundName>",
"UseResist:=",<bool>,
"Resistance:=", <value>,
"UseInduct:=", <bool>,
"Inductance:=", <value>,
"UseCap:=", <bool>,
"Capacitance:=", <value>,
<CurrentLineArray>,
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)
<CurrentLineArray>
Array("NAME:CurrentLine", _
"Start:=", <LineEndPoint>,
"End:=", <LineEndPoint>)

Example:
oModule.AssignLumpedRLC Array("NAME:LumpRLC1",_
"UseResist:=", true,_
"Resistance:=", "10Ohm",_
"UseInduct:=", true,_
"Inductance:=", "10nH",_
"UseCap:=", true,_
"Capacitance:=","10pF",_
Array("NAME:CurrentLine", _
"Start:=", Array(-0.4, -1.2, -1.6),_
"End:=", Array(-0.4, -1.2, 0)),
"Faces:=", Array(12))

AssignMagneticBias
Use:

Creates a magnetic bias source.


Boundary and Excitation Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Command:

HFSS>Excitations>Assign>Magnetic Bias

Syntax:

AssignMagneticBias <MagneticBiasArray>

Return Value:

None

Parameters:

<MagneticBiasArray>
Array("NAME:<BoundName>",
"IsUniformBias:=", <bool>,
"Bias:=", <value>,
"XAngle:=", <value>,
"YAngle:=", <value>,
"ZAngle:=", <value>,
"Project:=",<string>,
"Objects:=", <AssignmentObjects>)
IsUniformBias
If true, supply the Bias, XAngle, YAngle, and ZAngle parameters.
If false, supply the Project parameter.

Example:
oModule.AssignMagneticBias Array("NAME:MagBias1",_
"IsUniformBias:=", true,_
"Bias:=", "1",_
"XAngle:=", "10deg",_
"YAngle:=", "10deg",_
"ZAngle:=", "10deg",_
"Objects:=", Array("Box2"))
Example:
oModule.AssignMagneticBias Array("NAME:MagBias2",_
"IsUniformBias:=", false,_
"Project:=","D:/Maxwell/testing/m3dfs.pjt",_
"Objects:=", Array("Box2"))

AssignMaster
Use:

Creates a master boundary.

Command:

HFSS>Boundaries>Assign>Master

Syntax:

AssignMaster <MasterArray>

Return Value:

None

14-24 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Parameters:

<MasterArray>
Array("NAME:<BoundName>",
<CoordSysArray>,
"ReverseV:=", <bool>,
"Faces:=", <AssignmentFaces>)
<CoordSysArray>
Array("NAME:CoordSysVector",
"Origin:=", <CoordSysPoint>,
"UPos:=", <LineEndPoint>)

Example:
oModule.AssignMaster Array("NAME:Master1",_
Array("NAME:CoordSysVector",_
"Origin:=", Array(-1.4, -1.4, -0.8),_
"UPos:=", Array(-1.4, -1.4, 0)),_
"ReverseV:=", false,_
"Faces:=", Array(12))

AssignPerfectE
Use:

Creates a perfect E boundary.

Command:

HFSS>Boundaries>Assign>Perfect E

Syntax:

AssignPerfectE <PerfectEArray>

Return Value:

None

Parameters:

<PerfectEArray>
Array("NAME:<BoundName>",
"InfGroundPlane:=", <bool>,
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)

Example:
oModule.AssignPerfectE Array("NAME:PerfE1",_
"InfGroundPlane:=", false,_
"Faces:=", Array(12))

AssignPerfectH
Use:

Creates a perfect H boundary.


Boundary and Excitation Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Command:

HFSS>Boundaries>Assign>PerfectH

Syntax:

AssignPerfectH <PerfectHArray>

Return Value:

None

Parameters:

<PerfectHArray>
Array("Name:<BoundName>",
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)

Example:
oModule.AssignPerfectH Array("NAME:PerfH1",_
"Faces:=", Array(12))

AssignRadiation
Use:

Creates a radiation boundary.

Command:

HFSS>Boundaries>Assign>Radiation

Syntax:

AssignRadiation <RadiationArray>

Return Value:

None

Parameters:

<RadiationArray>
Array("NAME:<BoundName>",
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>
"IsIncidentField:=", <boolean>, _
"IsEnforcedHField:=", <boolean>, _
"IsEnforcedEField:=", <boolean>, _
"IsFssReference:=", <boolean>, _
"IsForPML:=", <boolean>, _
"UseAdaptiveIE:=", <boolean>, _
"IncludeInPostproc:=", <boolean>))

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 14.0.0
' 2:27:20 PM

Sep 13, 2011

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
14-26 Boundary and Excitation Module Script
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project59")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignRadiation Array("NAME:Rad1", _
"Objects:=", Array("Box1"), _
"IsIncidentField:=", false, _
"IsEnforcedField:=", false, _
"IsFssReference:=", false, _
"IsForPML:=", false, _
"UseAdaptiveIE:=", true, _
"IncludeInPostproc:=", true)

AssignScreeningImpedance
Use:

Creates a screening impedance boundary.

Command:

HFSS>Boundaries>Assign>Screening Impedance

Syntax:

AssignScreeningImpedance <ScreeningArray>

Return Value:

None.

Parameters:

<ScreeningArray>
Array("NAME:<name>",
"Objects:=", Array( "<name>"),
"IsAnisotropic:=", <Boolean>,
If true, you need to specify the coordinate system
"CoordSystem:=", <integer or name>,
"HasExternalLink:=", <Boolean>,
true or false. If False, specify XResistence and XReactance values. Also see the first
example.
"XResistance:=", "<value>",
"XReactance:=", "<value>"
If true, then specify the external link array with the project and solution to use. Also
Boundary and Excitation Module Script Commands

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

see the second example.


Array("NAME:XLink",
"Project:=", "<projectName>.hfss",
"Design:=", "<DesignName>",
"Soln:=", "Setup1 : LastAdaptive",
Array("NAME:Params", "<variable>:=", "<value>"),
"ForceSourceToSolve:=", <Boolean>,
"PreservePartnerSoln:=", <Boolean>,
"PathRelativeTo:=", "TargetProject"),
Array("NAME:YLink",
"Project:=", "<projectName>.hfss",
"Design:=", "HFSSDesign1",
"Soln:=", "Setup1 : LastAdaptive",
Array("NAME:Params", "<variable>:=", "<value>"),
"ForceSourceToSolve:=", <Boolean>
"PreservePartnerSoln:=", <Boolean>,
"PathRelativeTo:=", "TargetProject"))
Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project53")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignScreeningImpedance Array("NAME:Screening1",
"Faces:=", Array(12),
"IsAnisotropic:=", false,
"HasExternalLink:=", false,
"XResistance:=", "377", "XReactance:=", "0")

14-28 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 13.0.0
' 4:17:23 PM

Oct 29, 2010

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project53")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignScreeningImpedance Array("NAME:Screening1",
"Objects:=", Array( "Rectangle1"),
"IsAnisotropic:=", true,
"CoordSystem:=", 1,
"HasExternalLink:=", true,
Array("NAME:XLink",
"Project:=", "mydesign.hfss",
"Design:=", "HFSSDesign1",
"Soln:=", "Setup1 : LastAdaptive",
Array("NAME:Params", "bend_angle:=", "50deg"),
"ForceSourceToSolve:=", false,
"PreservePartnerSoln:=", false,
"PathRelativeTo:=", "TargetProject"),
Array("NAME:YLink", "Project:=", "mydesign.hfss",
"Design:=", "HFSSDesign1",
"Soln:=", "Setup1 : LastAdaptive",
Array("NAME:Params", "bend_angle:=", "50deg"),
"ForceSourceToSolve:=", true,
"PreservePartnerSoln:=", true,
"PathRelativeTo:=", "TargetProject"))

Boundary and Excitation Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

AssignSlave
Use:

Creates a slave boundary.

Command:

HFSS>Boundaries>Assign>Slave

Syntax:

AssignSlave <SlaveArray>

Return Value:

None

Parameters:

<SlaveArray>
Array("NAME:<BoundName>",
<CoordSysArray>,
"ReverseV:=", <bool>,
"Master:=", <string>,
"UseScanAngles:=", <bool>,
"Phi:=", <value>,
"Theta:=", <value>,
"Phase:=", <value>,
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)
<UseScanAngles>
If UseScanAngles is True, then Phi and Theta should be specified.
If it is False, then Phase should be specified.

Example:
oModule.AssignSlave Array("NAME:Slave1",_
Array("NAME:CoordSysVector", _
"Origin:=", Array(-1, 0, 0.2),_
"UPos:=", Array(-1, 0, 0)),_
"ReverseV:=", false,_
"Master:=", "Master1",_
"UseScanAngles:=", true,_
"Phi:=", "10deg",_
"Theta:=", "0deg",_
"Faces:=", Array(12))
Example:
oModule.AssignSlave Array("NAME:Slave2",_
Array("NAME:CoordSysVector",_
"Origin:=", Array(-1, 0, 0.2),_
14-30 Boundary and Excitation Module Script
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"UPos:=", Array(-2, 0, 0.2)),_


"ReverseV:=", false,_
"Master:=", "Master1",_
"UseScanAngles:=",false,_
"Phase:=", "10deg",_
"Faces:=", Array(11))

AssignSymmetry
Use:

Creates a symmetry boundary.

Command:

HFSS>Boundaries>Assign>Symmetry

Syntax:

AssignSymmetry <SymmetryArray>

Return Value:

None

Parameters:

<SymmetryArray>
Array("NAME:<BoundName>",
"IsPerfectE:=", <bool>
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)

Example:
oModule.AssignSymmetry Array("NAME:Sym1",_
"IsPerfectE:=", true,_
"Faces:=", Array(12))

AssignTerminal
Use:

Assigning terminals to a port.

Command:

HFSS>Excitations>Assign>Terminal

Syntax:

AssignTerminal <TerminalArray>

Return Value:

None

Parameters:

<TerminalArray>
Array(NAME: <TerminalName>, Edges:, <EdgeIDArray>, ParentBndID:= ,
<PortName>, TeminalResistance:=, <value>)
<TerminalName>
Type: String
<EdgeIDArray>
Type: Array of strings
<PortName>
Type: String
Boundary and Excitation Module Script Commands

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Name of Port.
<value>
Type: string
Value and units for the resistance.
Example:
oModule.AssignTerminal Array("NAME:Rectangle1_T1", _
"Edges:=", Array(36), "ParentBndID:=",

"WavePort1", "TerminalResistance:=", "50ohm")

AssignVoltage
Use:

Creates a voltage source.

Command:

HFSS>Excitations>Assign>Voltage

Syntax:

AssignVoltage <VoltageArray>

Return Value:

None

Parameters:

<VoltageArray>
Array("NAME:<BoundName>",
"Voltage:=", <value>,
<DirectionArray>,
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)
<DirectionArray>
Array("NAME:Direction",_
"Start:=",<LineEndPoint>,
"End:=", <LineEndPoint>)

Example:
oModule.AssignVoltage Array("NAME:Voltage1",_
"Voltage:=", "1000mV",_
Array("NAME:Direction",_
"Start:=", Array(-0.4, -1.2, 0),_
"End:=", Array(-1.4, -1.2, 0)),_
"Faces:=", Array(7))

AssignWavePort
Use:

Creates a wave port.

14-32 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Command:

HFSS>Excitations>Assign>Wave Port

Syntax:

AssignWavePort <WavePortArray>

Return Value:

None

Parameters:

<WavePortArray>
Array("NAME:<BoundName>",
"Faces:=", <FaceIDArray>,
"NumModes:=", <int>,
"PolarizeEField:=",<bool>,
"DoDeembed:=", <bool>,
"DeembedDist:=", <value>,
"DoRenorm:=", <bool>,
"RenormValue:=",<value>,
<ModesArray>,
TerminalIDList:=, <TerminalsArray>
)
NumModes
Number of modes for modal problems.
Number of terminals for terminal problems.
<ModesArray>
Specify for modal problems.
Array("NAME:Modes",
<OneModeArray>, <OneModeArray>, ...)
<OneModeArray>
Array("NAME:<ModeName>",
"ModeNum:=", <int>,
"UseIntLine:=", <bool>,
<IntLineArray>)
<ModeName>
Type: <string>
Name of the mode. Format is "Mode<int>". For example "Mode1".
<IntLineArray>
Boundary and Excitation Module Script Commands

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array("NAME:IntLine",
"Start:=", <LineEndPoint>,
"End:=", <LineEndPoint>,
"CharImp:=", <string>)
CharImp
Characteristic impedance of the mode. Possible values are "Zpi", "Zpv", or
"Zvi"
Example:

Modal problem:
oModule.AssignWavePort Array("NAME:WavePort1",_
"NumModes:=", 2,_
"PolarizeEField:=",false,_
"DoDeembed:=", true,_
"DeembedDist:=", "10mil",_
"DoRenorm:=", true,_
"RenormValue:=","50Ohm",
Array("NAME:Modes",_
Array("NAME:Mode1",_
"ModeNum:=", 1,_
"UseIntLine:=", true,_
Array("NAME:IntLine",_
"Start:=", Array(-0.4, -1.2, 0),_
"End:=", Array(-1.4, 0.4, 0)),_
"CharImp:=", "Zpi"), _
Array("NAME:Mode2",_
"ModeNum:=", 2,_
"UseIntLine:=", false)),_
"Faces:=", Array(7))

Example:

Terminal problem:
oModule.AssignWavePort Array("NAME:WavePort1",_
"Faces:=", Array(11)
"NumModes:=", 2,_
"PolarizeEField:=", false,_
"DoDeembed:=", false,

14-34 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

TeminalIDList:=, Array()
)

EditCurrent
Use:

Modifies a current source.

Command:

Double-click the excitation in the project tree to modify its settings.

Syntax:

EditCurrent <BoundName> <CurrentArray>

Return Value:

None

EditDiffPairs
Use:

Edits the properties of differential pairs defined from terminal excitations


on wave ports.

Command:

HFSS>Excitations>Differential Pairs

Syntax:

EditDiffPairs <DifferentialPairsArray>

Return Value:

None

Parameters:

<DifferentialPairsArray>
Array("NAME:EditDiffPairs",
<OneDiffPairArray>, <OneDiffPairArray>,...)
<OneDiffPairArray>
Array("NAME:Pair1",_
"PosBoundary:=", <string>,
"NegBoundary:=", <string>,
"CommonName:=", <string>,
"CommonRefZ:=", <value>,
"DiffName:=", <string>,
"DiffRefZ:=", <value>,
IsActive:=, <boolean>)
PosBoundary
Name of the terminal to use as the positive terminal.
NegBoundary
Name of the terminal to use as the negative terminal.

Boundary and Excitation Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

CommonName
Name for the common mode.
CommonRefZ
Reference impedance for the common mode.
DiffName
Name for the differential mode.
DiffRefZ
Reference impedance for the differential mode.
Example:
oModule.EditDiffPairs Array("NAME:EditDiffPairs", Array("NAME:Pair1",
"PosBoundary:=", _
"Rectangle1_T1", "NegBoundary:=", "Rectangle2_T1", _
"CommonName:=", "Comm1", "CommonRefZ:=", "25ohm", _
"DiffName:=", "Diff1", "DiffRefZ:=", "100ohm", "IsActive:=", true))

EditFiniteCond
Use:

Modifies a finite conductivity boundary.

Command:

Double-click the boundary in the project tree to modify its settings.

Syntax:

EditFiniteCond <BoundName> <FiniteCondArray>

Return Value:

None

Parameters:

<FiniteCondArray>
Array("NAME:<BoundName>",
"UseMaterial:=",<bool>,
"Material:=", <string>,
"Conductivity:=", <value>,
"Permeability:=", <value>,
"Roughness:=" <value>,
"InfGroundPlane:=", <bool>,
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>
Radius:=", "<value>", "Ratio:=", "<value>"))

14-36 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

UseMaterial
If True, provide Material parameter.
If False, provide Conductivity and Permeability parameters.
For Huray Roughness, use Radius and Ratio. For Groisse roughness model, use Roughness.
Parameters:
Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 14.0.0
' 2:12:43 PM

May 20, 2011

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project56")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.EditFiniteCond "FiniteCond1", Array("NAME:FiniteCond1",
"UseMaterial:=", true,
"Material:=", "copper",
"UseThickness:=", false,
"Radius:=", "0.4um",
"Ratio:=", "2.9",
"InfGroundPlane:=", true)

EditImpedance
Use:

Modifies an impedance boundary.

Command:

Double-click the boundary in the project tree to modify its settings.

Syntax:

EditImpedance <BoundName> <ImpedanceArray>

Return Value:

None
Boundary and Excitation Module Script Commands

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

EditIncidentWave
Use:

Modifies an incident wave excitation.

Command:

Double-click the excitation in the project tree to modify its settings.

Syntax:

EditIncidentWave <BoundName> <IncidentWaveArray>

Return Value:

None

Parameters:
Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Cube_RCS_00a")
Set oDesign = oProject.SetActiveDesign("PEC_d1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.EditIncidentWave "IncPWave1",
Array("NAME:IncPWave1", "IsCartesian:=", false,
"PhiStart:=", "$phi_inc",
"PhiStop:=", "$phi_inc",
"PhiPoints:=", 1,
"ThetaStart:=", "$theta_inc",
"ThetaStop:=", "$theta_inc",
"ThetaPoints:=", 1, "EoPhi:=", "$phi_pol",
"EoTheta:=", "$theta_pol",
"OriginX:=", "0mm",
"OriginY:=", "0mm",
"OriginZ:=", "0mm",
"TransientActive:=", 1,
"TimeProfile:=", "Broadband Pulse",
"HfssFrequency:=", "1GHz",
14-38 Boundary and Excitation Module Script
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"MinFreq:=", "100MHz",
"MaxFreq:=", "1GHz",
"Delay:=", "0.2s",
"NumFreqsExtracted:=", 401,
"SweepMinFreq:=", "100MHz",
"SweepMaxFreq:=", "1GHz",
"IsPropagating:=", true,
"IsEvanescent:=", false, "IsEllipticallyPolarized:=", false)

EditLayeredImpedance
Use:

Modifies a layered impedance boundary.

Command:

Double-click the boundary in the project tree to modify its settings.

Syntax:

EditLayeredImp <BoundName> <LayeredImpArray>

Return Value:

None

EditMaster
Use:

Modifies a master boundary.

Command:

Double-click the boundary in the project tree to modify its settings.

Syntax:

Edit <BoundName> <MasterArray>

Return Value:

None

EditPerfectE
Use:

Modifies a perfect E boundary.

Command:

Double-click the boundary in the project tree to modify its settings.

Syntax:

EditPerfectE <BoundName>, <PerfectEArray>

Return Value:

None

EditPerfectH
Use:

Modifies a perfect H boundary.

Command:

Double-click the boundary in the project tree to modify its settings.

Syntax:

EditPerfectH <BoundName> <PerfectHArray>

Return Value:

None

Boundary and Excitation Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

EditLumpedPort
Use:

Modifies a lumped port.

Command:

Double-click the excitation in the project tree to modify its settings.

Syntax:

EditLumpedPort <BoundName> <LumpedPortArray>

Parameters:

<LumpedPortArray>
Array("NAME:<BoundName>",
"Faces:=", <FaceIDArray>,
"RenormalizeAllTerminals:=", <boolean>
"DoDeembed:=" <boolean"
<ModesArray>,
TerminalIDList:=, <TerminalsArray>,
"FullResistance:=", <value>,
"FullReactance:=", <value>,
)

Return Value:

None

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 14.0.0
' 2:18:20 PM May 20, 2011
' ---------------------------------------------Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("calib_modal_test")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.EditLumpedPort "lp2", Array("NAME:lp2", "RenormalizeAllTerminals:=", true, "DoDeembed:=", _

14-40 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

true, Array("NAME:Modes", Array("NAME:Mode1", "ModeNum:=", 1, "UseIntLine:=", true,


Array("NAME:IntLine", "Start:=", Array( _
"120mm", "50mm", "40mm"), "End:=", Array("120mm", "50mm", "120mm")), "CharImp:=", _
"Zpi")), "ShowReporterFilter:=", false, "ReporterFilter:=", Array(true), "FullResistance:=", _
"50ohm", "FullReactance:=", "0ohm")

EditLumpedRLC
Use:

Modifies a lumped RLC boundary.

Command:

Double-click the boundary in the project tree to modify its settings.

Syntax:

EditLumpedRLC <BoundName> <LumpedRLCArray>

Return Value:

None

EditMagneticBias
Use:

Modifies a magnetic bias excitation.

Command:

Double-click the excitation in the project tree to modify its settings.

Syntax:

EditMagneticBias <BoundName> <MagneticBiasArray>

Return Value:

None

Parameters:

EditRadiation
Use:

Modifies a radiation boundary.

Command:

Double-click the boundary in the project tree to modify its settings.

Syntax:

EditRadiation <BoundName> <RadiationArray>

Return Value:

None

Parameters:

<RadiationArray>
Array("NAME:<BoundName>",
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>
"IsIncidentField:=", <boolean>, _
"IsEnforcedHField:=", <boolean>, _
"IsEnforcedEField:=", <boolean>, _
"IsFssReference:=", <boolean>, _
"IsForPML:=", <boolean>, _
"UseAdaptiveIE:=", <boolean>, _
"IncludeInPostproc:=", <boolean>))
Boundary and Excitation Module Script Commands

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 14.0.0
' 2:34:08 PM

Sep 13, 2011

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project59")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.EditRadiation "Rad1", _
Array("NAME:Rad1", _
"IsIncidentField:=", true, _
"IsEnforcedField:=", false, _
"IsFssReference:=", false, _
"IsForPML:=", false, _
"UseAdaptiveIE:=", false, _
"IncludeInPostproc:=", true)

EditSlave
Use:

Modifies a slave boundary.

Command:

Double-click the boundary in the project tree to modify its settings.

Syntax:

EditSlave <BoundName> <SlaveArray>

Return Value:

None

EditSymmetry
Use:

Modifies a symmetry boundary.

Command:

Double-click the boundary in the project tree to modify its settings.

14-42 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Syntax:

EditSymmetry <BoundName> <SymmetryArray>

Return Value:

None

EditTerminal
Use:

Modifies properties of a terminal

Command:

Edit Properties for a selected terminal

Syntax:

EditTerminal <TerminalArray>)

Return Value:

None

Parameters:

<TerminalArray>
Array(NAME: <TerminalName>, ParentBndID:=, <PortName>, TerminalResistance:=, <value>)
<TerminalName>
Type:String
<PortName>
Type: String
<value>
Type: <string>
Value and units of resistance.

Example:
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.EditTerminal "Rectangle2_T1", Array("NAME:Rectangle2_T1", _
"ParentBndID:=", "WavePort1", "TerminalResistance:=", "75ohm")

EditVoltage
Use:

Modifies a voltage source.

Command:

Double-click the excitation in the project tree to modify its settings.

Syntax:

EditVoltage <BoundName> <VoltageArray>

Return Value:

None

EditWavePort
Use:

Modifies a wave port.

Command:

Double-click the excitation in the project tree to modify its settings.

Syntax:

EditWavePort <BoundName> <WavePortArray>

Return Value:

None

Example:
Boundary and Excitation Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

SetTerminalReferenceImpedances
Use:

To set the reference impedance for all terminals within a specified port.

Command:

HFSS>Excitations>Set Terminal Reference Impedances or HFSSIE>Excitations>Set Terminal Reference Impedances

Syntax:

SetTerminalReferenceImpedances <value>, <PortName>

Return Value:

None

Parameters:

<value>
Type: <string>
The value and units for the the impedance
<PortName>
Type: <string>
The name of the port.

Example:
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.SetTerminalReferenceImpedances "75ohm", "WavePort1"

UnassignIERegions
Use:

Unassign one or more IE Regions assigned to conducting objects.

Command:

Unassign IE Regions

Syntax:

UnassignIERegion Array (<"geometryName">)

Return Value:

None

Parameters:

<GeometryName>
Type: String
Name of one or more geometries assigned as an IE Region.

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 14.0.0
' 2:51:43 PM

Mar 07, 2011

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
14-44 Boundary and Excitation Module Script
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project58")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.UnassignIERegions Array("Box1")

Boundary and Excitation Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Script Commands for Creating and Modifying Boundaries in HFSS-IE


AssignAperature [HFSS-IE]
AssignFiniteCond [HFSS-IE]
AssignImpedance [HFSS-IE]
AssignInfiniteGroundPlane [HFSS-IE]
AssignLumpedPort [HFSS-IE]

AssignAperature [HFSS-IE]
Use:

Creates an aperature boundary on a sheet in an HFIE design.

Command:

HFSS-IE>Boundary>Assign>Aperature...

Syntax:

AssignAperture Array("NAME:<boundName>", "Objects:=",


Array("<sheetName>"))

Parameters:

<boundName>
Type: <string>
Boundary name.
<sheetName>
Type: <string>
Name of the sheet object to which you assign the boundary

Return Value:

None

Example:
Set oProject = oDesktop.SetActiveProject("Project15")
Set oDesign = oProject.SetActiveDesign("HFIEDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignAperture Array("NAME:Aperture1", _
"Objects:=", Array("Rectangle1"))

AssignFiniteCond [HFSS-IE]
Use:

Creates a finite conductivity boundary.

Command:

HFSS-IE>Boundaries>Assign>Finite Conductivity

Syntax:

AssignFiniteCond <FiniteCondArray>

Return Value:

None

Parameters:

<FiniteCondArray>
Array("NAME:<BoundName>",
"Objects:=", <AssignmentObjects>,
"UseMaterial:=",<bool>,
"Material:=", <string>,

14-46 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Conductivity:=", <value>,
"Permeability:=", <value>,
"InfGroundPlane:=", <bool>,
"Faces:=", <AssignmentFaces>)
UseMaterial
If True, provide Material parameter.
If False, provide Conductivity and Permeability parameters.
Example:
oModule.AssignFiniteCond Array("NAME:FiniteCond1",_
"Objects:=", Array("Rectangle2"), _
"UseMaterial:=", false, _
"Conductivity:=", "58000000", _
"Permeability:=", "1", _
"Roughness:=", "0um", _
"UseThickness:=", false)

AssignImpedance [HFSS-IE]
Use:

Creates an impedance boundary for an HFIE design.

Command:

HFSS-IE>Boundaries>Assign>Impedance

Syntax:

AssignImpedance <ImpedanceArray>

Return Value:

None

Parameters:

<ImpedanceArray>
Array("NAME:<BoundName>",
"Resistance:=", <value>,
"Reactance:=", <value>,
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)

Example:
oModule.AssignImpedance Array("NAME:Imped1",_
"Resistance:=", "50",_
"Reactance:=", "50",_
"Faces:=", Array(12))

AssignInfiniteGroundPlane [HFSS-IE]
Use:

Creates an infinite ground plane in HFIE.

Command:

HFSS-IE>Boundaries>Assign>Infinite Ground Plane


Boundary and Excitation Module Script Commands

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Syntax:

AssignInfGndPlane <Array>

Return Value:

None

Parameters:

<Array>
"NAME:"<InfGndPlaneName>
"ZLocation:=", <value>
"Roughness:=", <value>
"Material:=", "<name>"

Example:
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignInfGndPlane Array("NAME:InfGndPlane1", _
"ZLocation:=", "0mm", _
"Roughness:=", "0mm", _
"Material:=", "Copper")

AssignLumpedPort [HFSS-IE]
Use:

Creates a lumped port.

Command:

HFSS>Excitations>Assign>Lumped Port

Syntax:

AutoIdentifyPorts <LumpedPortArray>

Return Value:

None

Parameters:

Array

Example:
Set oDesign = oProject.SetActiveDesign("HFSSIEDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AutoIdentifyPorts Array("NAME:Faces", 12), _
Array("NAME:ReferenceConductors", "Box1"), _
"LumpPort1", true

14-48 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Script Commands for Creating and Modifying PMLs


Following are script commands for creating and modifiying PMLs that are recognized by the
"BoundarySetup" module.
The PML Setup wizard allows you to set up one or more PMLs in the model. There is not a single
Create PML or Edit PML command that represents the work performed by the PML Setup wizard. Instead, a series of geometry and material commands are executed. As a result, when a
script is being recorded, a series of geometry and material creation commands is what is actually recorded in the script for a PML setup. This is followed by a script command stating that
PMLs have been set up or modified.
CreatePML
ModifyPMLGroup
PMLGroupCreated
PMLGroupModified
RecalculatePMLMaterial

CreatePML
Use:

Command to create a new PML group from the script. This is equivalent to
creating a new PML group in the user interface.

Command:

None

Syntax:

For manually created PMLs:


CreatePML Array("UserDrawnGroup:=", true,
"PMLObj:=", <string>,
"BaseObj:=", <string>,
"Thickness:=", <value>,
"Orientation:=", <string>,
"RadDist:=", <value>,
"UseFreq:=", <bool>,
"MinFreq:=", <value>,
"MinBeta:=", <double>)
"RadIncidentField:=", <bool>
"RadFssReference:=", <bool>
For automatically created PMLs:
CreatePML Array("UserDrawnGroup:=", false,
"PMLFaces:=", <AssignmentFaces>,
"CreateJoiningObjs:=", <bool>,
"Thickness:=", <value>,
Boundary and Excitation Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"RadDist:=", <value>,
"UseFreq:=", <bool>,
"MinFreq:=", <value>,
"MinBeta:=", <double>)
"RadIncidentField:=", <bool>
"RadFssReference:=", <bool>
Return Value:

None

Parameters:

PMLObj
Name of the object to use as the PML cover.
BaseObj
Name of the base object touching the PML cover object.
Orientation
String representing the orientation of the PML.
Possible values are: "XAxis", "YAxis", and "ZAxis"
UseFreq
If true, provide the MinFreq parameter.
If false, provide the MinBeta parameter.

Example:
oModule.CreatePML Array("UserDrawnGroup:=", false,_
"PMLFaces:=", Array(120), "CreateJoiningObjs:=",_
true,_
"Thickness:=", "0.33mm", "RadDist:=", "1.6mm",_
"UseFreq:=", true, "MinFreq:=", "1GHz")
Example:
oModule.CreatePML Array("UserDrawnGroup:=", true,_
"PMLObj:=", "Box1", "BaseObj:=", "Box2", _
"Thickness:=", "0.3mm", "Orientation:=", "ZAxis", _
"RadDist:=", "1.6mm", "UseFreq:=", false, _
"MinBeta:=", "2")
14-50 Boundary and Excitation Module Script
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

ModifyPMLGroup
Use:

Command to modify a PML group. Note: This is the scripting equivalent to


clicking Update in the PML Setup wizard. This does not actually modify the
materials. It only modifies the data stored by the PML Setup wizard.

Command:

None

Syntax:

ModifyPMLGroup Array("NAME:<GroupName>",
"RadDist:=", <value>,
"UseFreq:=", <bool>,
"MinFreq:=", <value>,
"MinBeta:=", <double>)

Return Value:

None

Parameters:

<GroupName>
Name of the PML group to modify.
UseFreq
If true, provide the MinFreq argument.
If false, provide the MinBeta argument.

Example:
oModule.ModifyPMLGroup Array("NAME:PMLGroup1",
"RadDist:=", "1.166666667mm",
"UseFreq:=", false, "MinBeta:=", 2)

PMLGroupCreated
Use:

Command added by HFSS after a PML has been created. It is not responsible
for creating the PML objects and materials. It just contains the information
needed by the PML Setup wizard for future modification of the PML. This
script command is not intended to be modified by you. Removing this
command from the script will prevent future modification of the PML
through the user interface after the script is played back.

Command:

HFSS>Boundaries>Assign>PML Setup Wizard

Syntax:

PMLGroupCreated <args>

Return Value:

None

Boundary and Excitation Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

PMLGroupModified
Use:

Command added by HFSS after a PMLs parameters are modified. This


updates the PML Setup wizards data. This script command is not intended
to be modified by you. Removing this command from the script will prevent
future modification of the PML through the user interface after the script is
played back.

Command:

Modify existing PML in the PML Setup wizard.

Syntax:

PMLGroupModified <args>

Return Value:

None

RecalculatePMLMaterials
Use:

Scripting equivalent to clicking Recalculate Materials in the PML Setup


wizard. This will update the PML materials to match the current state of the
PML Setup wizard data.

Command:

None

Syntax:

RecalculatePMLMaterials

Return Value:

None

Example:
oModule.RecalculatePMLMaterials

14-52 Boundary and Excitation Module Script


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

15

Mesh Operations Module


Script Commands

Mesh setup and operations commands should be executed by the "MeshSetup" module.
Set oModule = oDesign.GetModule("MeshSetup")
oModule.CommandName <args>
Conventions Used in this Chapter
<OpName>
Type: <string>
Name of a mesh operation.
<AssignmentObjects>
Type: Array of strings
An array of object names.
<AssignmentFaces>
Type: Array of integers.
An array of face IDs. The ID of a face can be determined through the user interface
using the 3D Modeler>Measure>Area command. The face ID is given in the Measure Information dialog box.
General Commands Recognized by the Mesh Operations Module
Script Commands for Creating and Modifying Mesh Operations

Mesh Operations Module Script Commands 15-1


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

General Commands Recognized by the Mesh Operations Module


DeleteOp
GetOperationName
RenameOp

DeleteOp
Use:

Deletes the specified mesh operations.

Command:

Delete command in the List dialog box. Click HFSS>List to access the List
dialog box.

Syntax:

DeleteOp <NameArray>

Return Value:

None

Parameters:

<NameArray>
Type: Array of strings.
An array of mesh operation names.

Example:
oModule.DeleteOp Array("Length1", "SkinDepth1",_
"Length2")

GetOperationNames
Use:

Gets the names of mesh operations defined in a design.

Syntax:

GetOperationNames(<OperationType>)

Return Value:

Array of mesh operation names.

Parameters:

<OperationType>
Type: <string>
For example: "Skin Depth Based"

Example:
Set opnames = oModule.GetOperationNames("Length Based")
For Each name in opnames
Msgbox name
Next

RenameOp
Use:

Renames a mesh operation.

Command:

Right-click the mesh operation in the project tree, and then click Rename
on the shortcut menu.

Syntax:

RenameOp <OldName>, <NewName>

15-2 Mesh Operations Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Return Value:

None

Parameters:

<OldName>
Type: <string>
Old name for the mesh operation.
<NewName>
Type: <string>
New name for the mesh operation.

Example:
oModule.RenameOp "SkinDepth1", "NewName"

Mesh Operations Module Script Commands 15-3


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Script Commands for Creating and Modifying Mesh Operations


AssignLengthOp
AssignModelResolutionOp
AssignSkinDepthOp
AssignTrueSurfOp
EditLengthOp
EditModelResolutionOp
EditSkinDepthOp
EditTrueSurfOp

AssignLengthOp
Use:

Assigns length-based operations to the selection.

Command:

HFSS>Mesh Operations>Assign>On Selection or HFSS>Mesh


Operations>Assign>Inside Selection>Length Based.

Syntax:

AssignLengthOp <LengthOpParams>

Return Value:

None

Parameters:

<LengthOpParams>
Array("NAME:<OpName>",
"RefineInside:=", <bool>,
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>,
"RestrictElem:=", <bool>
"NumMaxElem:=", <integer>
"RestrictLength:=", <bool>
"MaxLength:=", <value>)
RefineInside
If true, Objects should be specified. Implies apply restrictions to tetrahedra inside
the object.
If false, Faces and/or Objects can be specified. Implies apply restrictions to triangles on the surface of the face or object.
RestrictElem
If true, NumMaxElem should be specified.
RestrictLength

15-4 Mesh Operations Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

If true, MaxLength should be specified.


Example:

Assigning length-based operations to the inside tetrahedra of an object:


oModule.AssignLengthOp Array("NAME:Length1", _
"RefineInside:=", true, _
"Objects:=", Array("Box1"), _
"RestrictElem:=", true, _
"NumMaxElem:=", 1000, _
"RestrictLength:=",

true, _

"MaxLength:=", "1mm")

AssignModelResolutionOp
Use:

Assigns a model resolution name, value and unit for mesh operations, or
specify to UseAutoFeaturelength. If UseAutoFeature length is true, the
Defeature length is not used.

Command:

HFFS>Mesh Operations>Assign>Model Resolution

Syntax:

AssignModelResolutionOp Array(<ModelResParams>)

Return Value:

None

Parameters:

Array("NAME:<string>",
"Objects:=", Array( "<modelname>"), _
"UseAutoLength:=", <Boolean>, _
"DefeatureLength:=", "<value><units>")

Example:
Set oDesign = oProject.SetActiveDesign("wg_combiner")
Set oModule = oDesign.GetModule("MeshSetup")
oModule.AssignModelResolutionOp Array("NAME:ModelResolution1",
"Objects:=", Array( "waveguide"), _
"UseAutoLength:=", true, _
"DefeatureLength:=", "71.5891053163818mil")

AssignSkinDepthOp
Use:

Assigns a skin-depth based operations to the selection.

Command:

HFSS>Mesh Operations>Assign>On Selection>Skin Depth Based

Syntax:

AssignSkinDepthOp <SkinDepthOpParams>

Return Value:

None

Parameters:

<SkinDepthOpParams>
Mesh Operations Module Script Commands 15-5

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array("NAME:<OpName>",
"Faces:=", <AssignmentFaces>,
"RestrictElem:=", <bool>,
"NumMaxElem:=", <int>,
"SkinDepth:=", <value>,
"SurfTriMaxLength:=", <value>,
"NumLayers:=", <int>)
RestrictElem
If true, NumMaxElem should be specified.
Example:
oModule.AssignSkinDepthOp Array("NAME:SkinDepth1", _
"Faces:=", Array(7), _
"RestrictElem:=", true, _
"NumMaxElem:=", 1000, _
"SkinDepth:=", "1mm", _
"SurfTriMaxLength:=", "1mm", _
"NumLayers:=", 2)

AssignTrueSurfOp
Use:

Assigns a true surface-based mesh operation on the selection.

Command:

HFSS>Mesh Operations>Assign>Surface Approximation

Syntax:

AssignTrueSurfOp <TrueSurfOpParams>

Return Value:

None

Parameters:

<TrueSurfOpParams>
Array("NAME:<OpName>",
"Faces:=", <AssignmentFaces>,
"SurfDevChoice:=",

<RadioOption>,

"SurfDev:=", <value>,
"NormalDevChoice:=", <RadioOption>,
"NormalDev:=", <value>,
"AspectRatioChoice:=", <RadioOption>,
"AspectRatio:=", <double>)
<RadioOption>
15-6 Mesh Operations Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Type: <int>
0: Ignore
1: Use defaults
2: Specify the value
Example:
oModule.AssignTrueSurfOp Array("NAME:TrueSurf1",
"Faces:=", Array(9), _
"SurfDevChoice:=",

2, _

"SurfDev:=", "0.04123105626mm", _
"NormalDevChoice:=", 2, _
"NormalDev:=", "15deg", _
"AspectRatioChoice:=", 1)

EditLengthOp
Use:

Edits an existing length-based operation. This can not be used to modify


assignments. Instead, the mesh operation should be deleted and a new one
created.

Command:

Double-click the operation in the project tree to modify its settings.

Syntax:

EditLengthOp <OpName>, <LengthOpParams>

Return Value:

None

Example:
oModule.EditLengthOp "Length1", Array("NAME:Length1", _
"RefineInside:=", false, _
"RestrictElem:=", false, _
"RestrictLength:=", true, _
"MaxLength:=", "2mm")

EditModelResolutionOp
Use:

Assigns a model resolution name, value and unit for mesh operations. If
UseAutoLength is true, the Defeature length is not used.

Command:

Double-click the operation in the project tree to modify its settings.

Syntax:

EditModelResolutionOp Array(<ModelResParams>)

Return Value:
Parameters:

Array("NAME:<string>",
"Objects:=", Array( "<modelname>"), _
Mesh Operations Module Script Commands 15-7

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"UseAutoLength:=", <Boolean>, _
"DefeatureLength:=", "<value><units>")
Example:
Set oDesign = oProject.SetActiveDesign("wg_combiner")
Set oModule = oDesign.GetModule("MeshSetup")
oModule.EditModelResolutionOp "ModelResolution1", _ Array("NAME:ModelResolution1", "UseAutoLength:=", false, _
"DefeatureLength:=", "71.5891053163818mil")

EditSkinDepthOp
Use:

Modifies an existing skin-depth based mesh operation. Assignments cannot


be changed using this command. To change the assignment, you must delete
operation and create it using a new assignment.

Command:

Double-click the operation in the project tree to modify its settings.

Syntax:

EditSkinDepthOp <OpName>, <SkinDepthOpParams>

Return Value:

None

Example:
oModule.EditSkinDepthOp "SkinDepth1",
Array("NAME:SkinD",_
"RestrictElem:=", false, _
"SkinDepth:=", "2mm", _
"SurfTriMaxLength:=", "1mm", _
"NumLayers:=", 2)

EditTrueSurfOp
Use:

Modifies an existing true surface approximation-based mesh operation.


Assignments cannot be changed using this command. To change the
assignment, delete this operation and create it using a new assignment.

Command:

Double-click the operation in the project tree to modify its settings.

Syntax:

EditTrueSurfOp <OpName>, <TrueSurfOpParams>

Return Value:

None

Example:
oModule.EditTrueSurfOp "TrueSurf2",
Array("NAME:trusurf", _
"SurfDevChoice:=", 2, _
"SurfDev:=","0.03mm", _
15-8 Mesh Operations Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"NormalDevChoice:=", 1, _
"AspectRatioChoice:=", 2, _
"AspectRatio:=", 10)

Mesh Operations Module Script Commands 15-9


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

15-10 Mesh Operations Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

16

Analysis Setup Module


Script Commands

HFSS analysis setup commands should be executed by the Analysis module,


referred to in HFSS scripts as the "AnalysisSetup" module.
Set oModule = oDesign.GetModule("AnalysisSetup")
DeleteDrivenSweep
DeleteSetups
DeleteSweep [HFSS-IE]
EditFrequencySweep
EditSetup
EditSweep [HFSS-IE]
GetSetupCount
GetSetups
GetSweepCount
GetSweeps
InsertFrequencySweep
InsertSweep [HFSS-IE]
InsertSetup
InsertSetup [HFSS-IE]
InsertSetup [Transient]
RenameDrivenSweep
RenameSetup
RenameSweep [HFSS-IE]
Analysis Setup Module Script Commands 16-1
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

RevertAllToInitial
RevertSetupToInitial

DeleteDrivenSweep
Use:

Deletes a frequency sweep. For HFSS-IE use DeleteSweep.

Command:

Right-click a frequency sweep in the project tree, and then click Rename on
the shortcut menu.

Syntax:

DeleteDrivenSweep <SetupName>, <SweepName>

Return Value:

None

DeleteSetups
Use:

Deletes one or more solution setups, which are specified by an array of


solution setup names.

Command:

Right-click a solution setup in the project tree, and then click Delete on the
shortcut menu, or delete selected solution setups in the List dialog box.

Syntax:

DeleteSetups <SetupArray>

Return Value:

None

Parameters:

<SetupArray>
Array(<name1>, <name2>, ...)

Example:
oModule.DeleteSetups Array("Setup1", "Setup2")

DeleteSweep [HFSS-IE]
Use:

Deletes a frequency sweep.

Command:

Right-click a frequency sweep in the project tree, and then click Rename on
the shortcut menu.

Syntax:

DeleteSweep <SetupName>, <SweepName>

Return Value:

None

EditFrequencySweep
Use:

Modifies an existing frequency sweep. For HFSS-IE use EditSweep [HFSS-IE]

Command:

Double-click a frequency sweep in the project tree to modify its settings.

Syntax:

EditFrequencySweep <SetupName>, <SweepName>,


<AttributesArray>

Return Value:

None

Parameters:

<SetupName>
Type: <string>

16-2 Analysis Setup Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Name of the solution setup containing the sweep to be edited.


<SweepName>
Type: <string>
Name of the sweep to be edited.
<Attributes Array>
Array("NAME:<SweepName>",
"IsEnabled:=", <boolean>,
"SetupType:=", <SetupType>,
<FrequencyInformation>,
"Type:=", <SweepType>,
<SaveFieldsList>
<DCExtrapInfo>)
See the InsertFrequencySweep command for details.
Example:
oModule.EditFrequencySweep "Setup1", "Sweep3", _
Array("NAME:Sweep3", "IsEnabled:=", true, _
"SetupType:=", "SinglePoints", _
"ValueList:=", Array("1GHz", "2GHz", "3GHz"), _
"Type:=", "Discrete", _
"SaveFieldsList:=", Array(false, false, false), _
"ExtrapToDC:=", false)

EditSetup
Use:

Modifies an existing solution setup.

Command:

Double-click a solution setup in the project tree to modify its settings.

Syntax:

EditSetup <SetupName>, <AttributesArray>

Return Value:

None

Parameters:

<SetupName>
Type: <string>
Name of the solution setup being edited.
<AttributesArray>
Array("NAME:<NewSetupName>", <NamedParameters>)
Analysis Setup Module Script Commands 16-3

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

See the InsertSetup command for details and examples.

EditSweep [HFSS-IE]
Use:

Modifies an existing sweep in HFSS-IE.

Command:

Double-click a frequency sweep in the project tree to modify its settings.

Syntax:

EditSweep <SetupName>, <SweepName>, <AttributesArray>

Return Value:

None

Parameters:

<SetupName>
Type: <string>
Name of the solution setup containing the sweep to be edited.
<SweepName>
Type: <string>
Name of the sweep to be edited.
<Attributes Array>
Array("NAME:<SweepName>",
"IsEnabled:=", <boolean>,
"SetupType:=", <SetupType>,
<FrequencyInformation>,
"Type:=", <SweepType>,
<SaveFieldsList>
<DCExtrapInfo>)
See the InsertFrequencySweep command for details.

Example:
oModule.EditSweep "Setup1", "Sweep3", _
Array("NAME:Sweep3", "IsEnabled:=", true, _
"SetupType:=", "SinglePoints", _
"ValueList:=", Array("1GHz", "2GHz", "3GHz"), _
"Type:=", "Discrete", _
"SaveFieldsList:=", Array(false, false, false), _
"ExtrapToDC:=", false)

GetSetupCount
Use:

Gets the number of analysis setups in a design.

16-4 Analysis Setup Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Syntax:

GetSetups()

Return Value:

Number of setups.

Parameters:

None

Example:
setupcount = oModule.GetSetupCount()

GetSetups
Use:

Gets the names of analysis setups in a design.

Syntax:

GetSetups()

Return Value:

Array of analysis setup names.

Parameters:

None

Example:
setupnames = oModule.GetSetups()

GetSweepCount
Use:

Gets the number of sweeps in a given analysis setup.

Syntax:

GetSweepCount(<SetupName>)

Return Value:

Number of sweeos for the named setup.

Parameters:

<SetupName>
Type: <string>
Name of the setup.

Example:
sweepcount = oModule.GetSweepCount("Setup1")

GetSweeps
Use:

Gets the names of all sweeps in a given analysis setup.

Syntax:

GetSweeps(<SetupName>)

Return Value:

Array of sweep names.

Parameters:

<SetupName>
Type: <string>
Name of the setup.

Example:
sweepnames = oModule.GetSweeps("Setup1")

Analysis Setup Module Script Commands 16-5


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

InsertFrequencySweep
Use:

Adds a frequency sweep to a Driven solution-type setup.

Command:

HFSS>Analysis Setup>Add Sweep

Syntax:

InsertFrequencySweep <SetupName>, <AttributesArray>

Return Value:

None

Parameters:

<SetupName>
Type: <string>
Name of the solution setup into which the sweep will be inserted.
<Attributes Array>
Array("NAME:<SweepName>",
"IsEnabled:=", true,
"SetupType:=", <SetupType>,
"Type:=", <SweepType>,
<FrequencyInformation>,
<SaveFieldsList>
<DCExtrapInfo>)
<SweepType>
Type: <string>
Ex. "Discrete", "Fast", or "Interpolating".
<SetupType>
Type: <string>
Ex. "LinearSetup", "LinearCount", or "SinglePoints".
<FrequencyInformation>
This will vary based on the sweep and solution type. See the examples below.
<DCExtrapInfo>
Information about whether and how to perform DC extrapolation. This parameter is
not used for Discrete sweeps. See the examples below.

Example:

Discrete Sweep

oModule.InsertFrequencySweep "Setup1", Array("NAME:Sweep2", _


"IsEnabled:=", true,
16-6 Analysis Setup Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"SetupType:=", "LinearStep", _
"StartValue:=", "19.5GHz", _
"StopValue:=", "20.4GHz", _
"StepSize:=", "0.1GHz", _
"Type:=", "Discrete", _
"SaveFields:=", false, "ExtrapToDC:=", false)
Example:

Fast Sweep

oModule.InsertFrequencySweep "Setup1", Array("NAME:Sweep4", _


"IsEnabled:=", true,
"SetupType:=", "LinearStep", _
"StartValue:=", "0GHz", _
"StopValue:=", "20.4GHz", _
"StepSize:=", "0.1GHz", _
"Type:=", "Fast", "SaveFields:=", true, _
"ExtrapToDC:=", true, _
"MinSolvedFreq:=", "0.1GHz")
Example:

Interpolating Sweep

oModule.InsertFrequencySweep "Setup1", Array("NAME:Sweep3", _


"IsEnabled:=", true, "SetupType:=",

"LinearStep", "StartValue:=", "0GHz", _


"StopValue:=", "2.5GHz", "StepSize:=", "0.005GHz",
"Type:=", "Interpolating", _
"SaveFields:=", false, _
"InterpTolerance:=", 0.5, _
"InterpMaxSolns:=", 50, "InterpMinSolns:=", 0, _
"InterpMinSubranges:=", 1, _
"ExtrapToDC:=", true, "MinSolvedFreq:=", "0.005GHz", _
"InterpUseS:=", true, _
"InterpUseT:=", false, "InterpUsePortImped:=", false, _
"InterpUsePropConst:=", true, "UseFullBasis:=", true)

Analysis Setup Module Script Commands 16-7


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:

Discrete sweeps with linear step and log scale:

oModule.InsertFrequencySweep "Setup1", Array("NAME:Sweep2", _


"IsEnabled:=", true,
"SetupType:=", "LinearStep", _
"StartValue:=", "0.005GHz", _
"StopValue:=", "2.5GHz", _
"StepSize:=", "0.005GHz", _
"Type:=", "Discrete", "SaveFields:=", false, _
"ExtrapToDC:=", false)
oModule.InsertFrequencySweep "Setup1", Array("NAME:Sweep3", _
"IsEnabled:=", true, "SetupType:=", "LogScale", _
"StartValue:=", "1GHz", _
"StopValue:=", "10GHz", _
"SamplesPerDecade:=", 4, _
"Type:=", "Discrete", _
"SaveFields:=", false, "ExtrapToDC:=", false)
Example:

A Fast sweep, specified using the starting and stopping frequencies and the
step count:

oModule.InsertFrequencySweep "Setup1", Array("NAME:Sweep4", _


"IsEnabled:=", true, "SetupType:=", "LinearCount", _
"StartValue:=", "1GHz", _
"StopValue:=", "10GHz", _
"Count:=", 3, _
"Type:=", "Fast", _
"SaveFields:=", true, "ExtrapToDC:=", false)

InsertSetup
Use:

Adds a new solution setup.

Command:

HFSS>Analysis Setup>Add Solution Setup

Syntax:

InsertSetup <SetupType>, <AttributesArray>

Return Value:

None

Parameters:

<SetupType>

16-8 Analysis Setup Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Type: <string>
"HfssDriven" or "HfssEigen". Must match the HFSS solution type.
<AttributesArray>
Array("NAME:<SetupName>", <Named Parameters>)
<Named Parameters>
The named parameters will vary according to the solution type. To see the required
parameters for a specific set of parameters and their format, use the record script
function, and view the resulting script in a text edtor. See the examples below.
Example:

A Driven solution type with a mesh link. References to dependent solve in


old scripts are converted to mesh link form.
Set oModule = oDesign.GetModule("AnalysisSetup")
oModule.InsertSetup "HfssDriven",
Array("NAME:Setup1",
"Frequency:=", "1GHz",
"MaxDeltaE:=", 0.1,
"MaximumPasses:=", 6,
"MinimumPasses:=", 1,
"MinimumConvergedPasses:=", 1,
"PercentRefinement:=", 30,
"IsEnabled:=", true,
Array("NAME:MeshLink",
"Project:=", "Tee.hfss",
"Design:=", "TeeModel",
"Soln:=", "Setup1 : LastAdaptive",
Array("NAME:Params", "offset:=", "0in"),
"ForceSourceToSolve:=", false,
"PreservePartnerSoln:=", false,
"PathRelativeTo:=", "SourceProduct",
"ApplyMeshOp:=", true),
"BasisOrder:=", 1,
"UseIterativeSolver:=", false,
"DoLambdaRefine:=", false,
"DoMaterialLambda:=", true,
"SetLambdaTarget:=", false,
Analysis Setup Module Script Commands 16-9

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Target:=", 0.3333,
"UseMaxTetIncrease:=", false,
"MaxTetIncrease:=", 1000000,
"EnableSolverDomains:=", false,
"ThermalFeedback:=", false,
"UsingConstantDelta:=", 0,
"ConstantDelta:=", "0s",
"NumberSolveSteps:=", 1)
Example:

A Driven solution type with ports:


Set oModule = oDesign.GetModule("AnalysisSetup")
oModule.InsertSetup "HfssDriven",
Array("NAME:Setup2",
"Frequency:=", "1GHz",
"PortsOnly:=", false,
"MaxDeltaS:=", 0.02,
"UseMatrixConv:=", false,
"MaximumPasses:=", 6,
"MinimumPasses:=", 1,
"MinimumConvergedPasses:=", 1,
"PercentRefinement:=", 30,
"IsEnabled:=", true,
"BasisOrder:=", 1,
"UseIterativeSolver:=", true,
"IterativeResidual:=", 0.0001,
"DoLambdaRefine:=", true,
"DoMaterialLambda:=", false,
"SetLambdaTarget:=", false,
"Target:=", 0.3333,
"UseMaxTetIncrease:=", false,
"MaxTetIncrease:=", 1000000,
"PortAccuracy:=", 2,
"UseABCOnPort:=", true,
"SetPortMinMaxTri:=", false,
"EnableSolverDomains:=", false,

16-10 Analysis Setup Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"ThermalFeedback:=", false,
"UsingConstantDelta:=", 0,
"ConstantDelta:=", "0s",
"NumberSolveSteps:=", 1)
Example:

An Eigenmode solution type:


Set oProject = oDesktop.SetActiveProject("cavity")
Set oDesign = oProject.SetActiveDesign("HFSSModel1")
Set oModule = oDesign.GetModule("AnalysisSetup")
oModule.InsertSetup "HfssEigen",
Array("NAME:Setup2",
"MinimumFrequency:=", "1.77347GHz",
"NumModes:=", 1,
"MaxDeltaFreq:=", 10,
"ConvergeOnRealFreq:=", true,
"MaximumPasses:=", 3,
"MinimumPasses:=", 1,
"MinimumConvergedPasses:=", 1,
"PercentRefinement:=", 30,
"IsEnabled:=", true,
"BasisOrder:=", 1,
"UseIterativeSolver:=", false,
"DoLambdaRefine:=", true,
"DoMaterialLambda:=", true,
"SetLambdaTarget:=", false,
"Target:=", 0.2,
"UseMaxTetIncrease:=", false,
"MaxTetIncrease:=", 1000000,
"UsingConstantDelta:=", 0,
"ConstantDelta:=", "0s",
"NumberSolveSteps:=", 1)

Example:

A Driven solution type with ports and matrix convergence:


Set oDesign = oProject.SetActiveDesign("packagehfss")
Set oModule = oDesign.GetModule("AnalysisSetup")
oModule.InsertSetup "HfssDriven",
Analysis Setup Module Script Commands 16-11

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array("NAME:Setup2",
"Frequency:=", "1GHz",
"PortsOnly:=", false,
"MaxDeltaS:=", 0.02,
"UseMatrixConv:=", true,
Array("NAME:ConvergenceMatrix",
"AllDiagEntries:=", true,
"MagMinThreshold:=", 0.01,
"Entry:=", Array("Port1:=", "abc", "ModeNum1:=", 1)),
"MaximumPasses:=", 6,
"MinimumPasses:=", 1,
"MinimumConvergedPasses:=", 1,
"PercentRefinement:=", 30,
"IsEnabled:=", true,
"BasisOrder:=", 1,
"UseIterativeSolver:=", false,
"DoLambdaRefine:=", true,
"DoMaterialLambda:=", true,
"SetLambdaTarget:=", false,
"Target:=", 0.3333,
"UseMaxTetIncrease:=", false,
"MaxTetIncrease:=", 1000000,
"PortAccuracy:=", 2,
"UseABCOnPort:=", true,
"SetPortMinMaxTri:=", false,
"EnableSolverDomains:=", false,
"ThermalFeedback:=", false,
"UsingConstantDelta:=", 0,
"ConstantDelta:=", "0s",
"NumberSolveSteps:=", 1)

InsertSetup [HFSS-IE]
Use:

Adds a new HFSS-IE solution setup.

Command:

HFSS>Analysis Setup>Add Solution Setup

Syntax:

InsertSetup <SetupType>, <AttributesArray>

16-12 Analysis Setup Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Return Value:

None

Parameters:

<SetupType>
Type: <string>
HFIESetup. Must match the HFSS solution type.
<AttributesArray>
Array("NAME:<SetupName>", <Named Parameters>)
<Named Parameters>
The named parameters will vary according to the solution type. To see the required
parameters for a specific set of parameters and their format, use the record script
function, and view the resulting script in a text edtor. See the HFSS-IE example
below.

Example:
oModule.InsertSetup "HFIESetup", Array("NAME:Setup3",
"MaximumPasses:=", 6,
"MinimumPasses:=", 1,
"MinimumConvergedPasses:=", 1,
"PercentRefinement:=", 30,
"Enabled:=", true,
"AdaptiveFreq:=", "1GHz",
"DoLambdaRefine:=", true,
"UseDefaultLambdaTarget:=", true,
"Target:=", 0.25,
"DoMaterialLambda:=", true,
"MaxDeltaS:=", 0.02,
"MaxDeltaE:=", 0.1,
"UsePOSolver:=", true)

InsertSetup [Transient]
Use:

Add a new solution setup to a Transient design

Command:

FSS>Analysis Setup>Add Solution Setup

Syntax:

InsertSetup <SetupType>, <AttributesArray>

Return Value:

None

Parameters:

<SetupType>
Type: <string>
"HfssTransient". Must match the HFSS solution type.

Analysis Setup Module Script Commands 16-13


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<AttributesArray>
Array("NAME:<SetupName>", <Named Parameters>)
<Named Parameters>
The named parameters will vary according to the solution type. To see the required
parameters for a specific set of parameters and their format, use the record script
function, and view the resulting script in a text edtor. See the examples below.
Example:

Transient Solution Type

Set oModule = oDesign.GetModule("AnalysisSetup")


oModule.InsertSetup "HfssTransient",
Array("NAME:Setup1",
"Frequency:=", "1GHz",
"MaxDeltaE:=", 0.1,
"MaximumPasses:=", 20,
"IsEnabled:=", true,
"BasisOrder:=", -1,
"NoAdditionalRefinementOnImport:=", true,
Array("NAME:Transient",
"UseAutoTermination:=", 1,
"SteadyStateCriteria:=", 0.001,
"UseMinimumDuration:=", 0,
"TerminateOnMaximum:=", 1,
"UseMaxTime:=", 1,
"MaxTime:=", "20000ps"))
Example:

Transient Network Solution Type

Set oDesign = oProject.SetActiveDesign("HFSSDesign1")


Set oModule = oDesign.GetModule("AnalysisSetup")
oModule.InsertSetup "HfssTransient",
Array("NAME:Setup1",
"Frequency:=", "0.55GHz",
"MaxDeltaE:=", 0.1,
"MaximumPasses:=", 20,
"IsEnabled:=", true,
"BasisOrder:=", -1,
"NoAdditionalRefinementOnImport:=", true,
16-14 Analysis Setup Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array("NAME:Transient", "TimeProfile:=", "TDR",


"HfssFrequency:=", "0.55GHz",
"MinFreq:=", "0Hz",
"MaxFreq:=", "25028.5714285714MHz",
"NumFreqsExtracted:=", 401,
"RiseTime:=", "35ps",
"SyncTDRMidpoint:=", 1,
"TDRMidpoint:=", "17.5ps",
"UseAutoTermination:=", 0,
"TerminateOnMaximum:=", 1,
"UseMaxTime:=", 1,
"MaxTime:=", "20000ps"))

InsertSweep [HFSS-IE]
Use:

Adds a frequency sweep to a Driven solution-type setup in HFSS-IE.

Command:

HFSS-IE>Analysis Setup>Add Sweep

Syntax:

InsertSweep <SetupName>, <AttributesArray>

Return Value:

None

Parameters:

<SetupName>
Type: <string>
Name of the solution setup into which the sweep will be inserted.
<Attributes Array>
Array("NAME:<SweepName>",
"IsEnabled:=", true,
"SetupType:=", <SetupType>,
"Type:=", <SweepType>,
<FrequencyInformation>,
<SaveFieldsList>
<DCExtrapInfo>)
<SweepType>
Type: <string>
Ex. "Discrete", "Fast", or "Interpolating".

Analysis Setup Module Script Commands 16-15


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<SetupType>
Type: <string>
Ex. "LinearSetup", "LinearCount", or "SinglePoints".
<FrequencyInformation>
This will vary based on the sweep and solution type. See the examples below.
<DCExtrapInfo>
Information about whether and how to perform DC extrapolation. This parameter is
not used for Discrete sweeps. See the examples below.
Example:

Discrete Sweep

oModule.InsertSweep "Setup1", Array("NAME:Sweep2", _


"IsEnabled:=", true,
"SetupType:=", "LinearStep", _
"StartValue:=", "19.5GHz", _
"StopValue:=", "20.4GHz", _
"StepSize:=", "0.1GHz", _
"Type:=", "Discrete", _
"SaveFields:=", false, "ExtrapToDC:=", false)
Example:

Fast Sweep

oModule.InsertSweep "Setup1", Array("NAME:Sweep4", _


"IsEnabled:=", true,
"SetupType:=", "LinearStep", _
"StartValue:=", "0GHz", _
"StopValue:=", "20.4GHz", _
"StepSize:=", "0.1GHz", _
"Type:=", "Fast", "SaveFields:=", true, _
"ExtrapToDC:=", true, _
"MinSolvedFreq:=", "0.1GHz")
Example:

Interpolating Sweep

16-16 Analysis Setup Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

oModule.InsertSweep "Setup1", Array("NAME:Sweep3", _


"IsEnabled:=", true, "SetupType:=",

"LinearStep", "StartValue:=", "0GHz", _


"StopValue:=", "2.5GHz", "StepSize:=", "0.005GHz",
"Type:=", "Interpolating", _
"SaveFields:=", false, _
"InterpTolerance:=", 0.5, _
"InterpMaxSolns:=", 50, "InterpMinSolns:=", 0, _
"InterpMinSubranges:=", 1, _
"ExtrapToDC:=", true, "MinSolvedFreq:=", "0.005GHz", _
"InterpUseS:=", true, _
"InterpUseT:=", false, "InterpUsePortImped:=", false, _
"InterpUsePropConst:=", true, "UseFullBasis:=", true)
Example:

Discrete sweeps with linear step and log scale:

oModule.InsertSweep "Setup1", Array("NAME:Sweep2", _


"IsEnabled:=", true,
"SetupType:=", "LinearStep", _
"StartValue:=", "0.005GHz", _
"StopValue:=", "2.5GHz", _
"StepSize:=", "0.005GHz", _
"Type:=", "Discrete", "SaveFields:=", false, _
"ExtrapToDC:=", false)
oModule.InsertSweep "Setup1", Array("NAME:Sweep3", _
"IsEnabled:=", true, "SetupType:=", "LogScale", _
"StartValue:=", "1GHz", _
"StopValue:=", "10GHz", _
"SamplesPerDecade:=", 4, _
"Type:=", "Discrete", _
"SaveFields:=", false, "ExtrapToDC:=", false)
Example:

A Fast sweep, specified using the starting and stopping frequencies and the
step count:
Analysis Setup Module Script Commands 16-17

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

oModule.InsertSweep "Setup1", Array("NAME:Sweep4", _


"IsEnabled:=", true, "SetupType:=", "LinearCount", _
"StartValue:=", "1GHz", _
"StopValue:=", "10GHz", _
"Count:=", 3, _
"Type:=", "Fast", _
"SaveFields:=", true, "ExtrapToDC:=", false)

RenameDrivenSweep
Use:

Renames an existing frequency sweep in HFSS. For HFSS-IE use


RenameSweep.

Command:

Right-click a frequency sweep in the project tree, and then click Rename on
the shortcut menu.

Syntax:

RenameDrivenSweep <SetupName>, <OldSweepName>,


<NewSweepName>

Return Value:

None

Example:
oModule.RenameDrivenSweep "Setup1", "Sweep1", _
"MySweep"

RenameSetup
Use:

Renames an existing solution setup.

Command:

Right-click a solution setup in the project tree, and then click Rename on
the shortcut menu.

Syntax:

RenameSetup <OldName>, <NewName>

Return Value:

None

Parameters:

<OldName>
Type: <string>
Name of the solution setup being renamed.
<NewName>
Type: <string>
New name for the solution setup.

16-18 Analysis Setup Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

RenameSweep [HFSS-IE]
Use:

Renames an existing frequency sweep in HFSS-IE.

Command:

Right-click a frequency sweep in the project tree, and then click Rename on
the shortcut menu.

Syntax:

RenameSweep <SetupName>, <OldSweepName>,


<NewSweepName>

Return Value:

None

Example:
oModule.RenameSweep "Setup1", "Sweep1", _
"MySweep"

RevertAllToInitial
Use:

Marks the current mesh for all solution setups as invalid. This will force the
next simulation to begin with the initial mesh.

Command:

HFSS>Analysis Setup>Revert to Initial Mesh

Syntax:

RevertAllToInitial

Return Value:

None

RevertSetupToInitial
Use:

Marks the current mesh for a solution setup as invalid. This will force the
next simulation to begin with the initial mesh.

Command:

Right-click a setup in the project tree, and then click Revert to Initial Mesh
on the shortcut menu.

Syntax:

RevertSetupToInitial <SetupName>

Return Value:

None

Analysis Setup Module Script Commands 16-19


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

16-20 Analysis Setup Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

17

Optimetrics Module Script


Commands

Optimetrics script commands should be executed by the "Optimetrics"


module.
Set oModule = oDesign.GetModule("Optimetrics")
oModule.CommandName <args>
General Commands Recognized by the Optimetrics Module
Parametric Script Commands
Optimization Script Commands
Sensitivity Script Commands
Statistical Script Commands
Conventions Used in this Chapter
<VarName>
Type: <string>
Name of a variable.
<VarValue>
Type: <string>
Value with unit (i.e., <value>, but cannot be an expression).
<StartV>
Type: <VarValue>
The starting value of a variable.
Optimetrics Module Script Commands 17-1
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<StopV>
Type: <VarValue>
The stopping value of a variable.
<MinV>
Type: <VarValue>
The minimum value of a variable.
<MaxV>
Type: <VarValue>
The maximum value of a variable.
<IncludeVar>
Type: <bool>
Specifies whether the variable is included in the analysis.
<StartingPoint>
Array("NAME:StartingPoint",

"<VarName>:=",

<VarValue>, .... "<VarName>:=", <VarValue>)


<SaveField>
Type: <bool>
Specifies whether HFSS will remove the non-nominal field solution.
<MaxIter>
Type: <int>
Maximum iteration allowed in an analysis.
<PriorSetup>
Type: <string>
The name of the embedded parametric setup.
<Precede>
Type: <bool>
17-2 Optimetrics Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

If true, the embedded parametric setup will be solved before the


analysis begins.
If false, the embedded parametric setup will be solved during each
iteration of the analysis.
<Constraint>
Array("NAME:LCS",
"lc:=", Array("<VarName>:=",
<Coeff>, "<VarName>:=", <Coeff>,
<Cond>, "rhs:=", <Rhs>), ...

"rel:=",

"lc:=", Array("<VarName>:=", <Coeff>, ..."


<VarName>:=", <Coeff>, "rel:=", <Cond>, "rhs:=",
<Rhs>))
<Coeff>
Type: <double>
Coefficient for a variable in the linear constraint.
<Cond>
Type: <string>
Inequality condition.
<Rhs>
Type: <double>
Inequality value.
<OptiGoalSpec>
"Solution:=", <Soln>, "Calculation:=", <Calc>,
"Context:=, <Geometry>
Array("NAME:Ranges",
"Range:", Array("Var:=",
<VarName>, "Type:=", <RangeType>, "Start:=",
<StartV>, "Stop:=", <StopV>), ...
"Range:", Array("Var:=", <VarName>, "Type:=",
<RangeType>, "Start:=", <StartV>, "Stop:=",
Optimetrics Module Script Commands 17-3
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<StopV>))
<Soln>
Type: <string>
Name of the HFSS solution.
<Calc>
Type: <string>
An expression that is composed of a basic solution quantity and an
output variable.
<Geometry>
Type: <string>
Name of geometry needed in the evaluation of <Calc>.
<RangeType>
Type: <string>
if "r", start and stop values specify a range for the variable.

17-4 Optimetrics Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

General Commands Recognized by the Optimetrics Module


Following are general script commands recognized by the Optimetrics module:
CopySetup
DeleteSetups (Optimetrics)
RenameSetup (Optimetrics)
SolveSetup (Optimetrics)
GetSetupNames (Optimetrics)
GetSetupNamesByType (Optimetrics)
DistributedAnalyzeSetup
ExportDXConfigFile
ExportOptimetricsProfile
ExportOptimetricsResult
ExportParametricResults
ImportSetup

CopySetup
Use:

Copy the specified Optimetrics setup.

Command:

None

Syntax:

CopySetup <SetupName>

Return Value:

None

Parameters:

SetupName
Type: <string>

Example:

oModule.CopySetup OptimizationSetup1

DeleteSetups [Optimetrics]
Use:

Deletes the specified Optimetrics setups.

Command:

Right-click the setup in the project tree, and then click Delete on the
shortcut menu.

Syntax:

DeleteSetups <NameArray>

Return Value:

None

Parameters:

<NameArray>
Type: Array of strings.
An array of setup names.

Example:
oModule.DeleteSetups Array("OptimizationSetup1")

Optimetrics Module Script Commands 17-5


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

DistributedAnalyzeSetup
Use:

Distributes all variable value instances within a parametric sweep to


different machines already specified from within the user interface

Command:

Right-click the parametric setup name in the project tree and select
Distribute Analysis.

Syntax:

DistributedAnalyzeSetup <ParametricSetupName>

Return Value:

None

Parameters:

<ParametricSetupName>
Type: <string>

Example:
oModule.DistributedAnalyzeSetup "ParametricSetup1"

ExportDXConfigFile
Use:

Create an xml file with the setup information for Design Xplorer.

Command:

Right click on the Design Xplorer setup in the project tree and choose
Export External Connector Addin Configuration

Syntax:

ExportDXConfigFile <SetupName>, <FileName>

Return Value:

None

Parameters:

<SetupName>
Type: <string>
Must be one of existing DesignExplorer setup names.
<FileName>
Type : <string: file path>
Must be a valid file path and name.

Example:

oModule.ExportDXConfigFile "DesignXplorerSetup1",
"c:/exportdir/DXSetup1.xml")

ExportOptimetricsProfile
Use:

Export Optimetrics profile data.

Command:

Right click on the Optimetrics setup in the project tree and choose View
Analysis Result On the Post Analysis Display dialog, click the Profile tab
and click on the Export button.

Syntax:

ExportOptimetricsProfile <SetupName>, <FileName>,


[profileNum]

Return Value:

None

Parameters:

<SetupName>

17-6 Optimetrics Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Type: <string>
Must be one of the existing Parametric, Optimization, Sensitivity, Statistical or
DesignXplorer setup names.
<FileName>
Type : <string: file path>
Must be a valid file path and name with extension of csv, tab, dat, or txt..
[profileNum]
Type : <string>
Must be a numeric string. Optional: defaulted to last profile number. It should be a
zero indexed profile number.
Example:

oModule.ExportOptimetricsProfile "StatisticalSetup1",
"c:/exportdir/test.csv"

ExportOptimetricsResult
Use:

Export an existing Optimization, Sensitivity, Statistical or DesignXplorer


result. (Does not export Parametric results.)

Command:

Right click on the desired Optimetrics setup in the project tree and choose
View Analysis Result On the Post Analysis Display dialog, click the Result
tab, then select Table view, and click on the Export button.

Syntax:

ExportOptimetricsProfile <SetupName>, <FileName>,


[useFullOutputName]

Return Value:

None

Parameters:

<SetupName>
Type: <string>
Must be one of the existing Optimization, Sensitivity, Statistical, or DesignXplorer
setup names.
<FileName>
Type : <string: file path>
Must be a valid file path and name with extension of csv, tab, dat, or txt..
[useFullOutputName]
Type : <boolean>
Optional: defaulted to false. If set to true values will be printed with units. This
parameter is ignored for Optimization and Statistical results.

Example:

oModule. ExportOptimetricsResult "StatisticalSetup1",


"c:/exportdir/test.csv", false

ExportParametricResults
Use:

Export existing Parametric results.

Optimetrics Module Script Commands 17-7


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Command:

Right click on the desired Parametric setup in the project tree and choose
View Analysis Result On the Post Analysis Display dialog, click the Result
tab, then select Table view, and click on the Export button.

Syntax:

ExportParametricResults <SetupName>, <FileName>,


<bOutputUnits>

Return Value:

None

Parameters:

<SetupName>
Type: <string>
Must be one of the existing Parametric setup names.
<FileName>
Type : <string: file path>
Must be a valid file path and name with extension of csv, tab, dat, or txt..
<bOutputUnits>
Type : <boolean>
If set to true values will be printed with units.

Example:

oModule. ExportParametricResults "ParametricSetup1", "c:/


exportdir/test.csv", false

GetSetupNames [Optimetrics]
Use:

Gets a list of Optimetrics setup names.

Syntax:

GetSetupNames()

Return Value:

Collection of Optimetrics setup names

Parameters:

None

Example:

For each name in


oModule.GetSetupNames()
Msgbox name
Next

GetSetupNamesByType [Optimetrics]
Use:

Gets a list of Optimetrics setup names by type.

Syntax:

GetSetupNamesByType(<Optimetrics type>)

Return Value:

Collection of Optimetrics setup names of the given type.

Parameters:

<Optimetrics type>
Type: String
Examples: parametric, optimization, statistical, sensitivity

17-8 Optimetrics Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:

For each name in


oModule.GetSetupNamesByType(optimization)
Msgbox name
Next

ImportSetup
Use:

Import an Optimetric setup from a file.

Command:

None

Syntax:

ImportSetup <SetupTypeName>, <SetupInfo>

Return Value:

None

Parameters:

SetupTypeName
Type: <string>
Must be one of "OptiParametric" , "OptiOptimization", "OptiSensitivity", "OptiStatistical", or "OptiDesignExplorer".
<SetupInfo>
Array("NAME:<SetupName>", "FilePath")
<SetupName>
Type: <string>
Name of the setup.
FilePath
Type : <string: file path>
Must be a valid file path and name.

Example:

oModule.ImportSetup "OptiStatistical",
Array("NAME:StatisticalSetup1",
"c:/importdir/mySetupInfoFile")

RenameSetup [Optimetrics]
Use:

Renames the specified Optimetrics setup.

Command:

Right-click the setup in the project tree, and then click Rename on the
shortcut menu.

Syntax:

RenameSetup <OldName> <NewName>

Return Value:

None

Parameters:

<OldName>
Type: <string>
<NewName>
Optimetrics Module Script Commands 17-9

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Type: <string>
Example:
oModule.RenameSetup "OptimizationSetup1" "MyOptimization"

SolveSetup [Optimetrics]
Use:

Solves the specified Optimetrics setup.

Command:

Right-click the setup in the project tree, and then click Analyze on the
shortcut menu.

Syntax:

SolveSetup <SetupName>

Return Value:

None

Parameters:

oModule.SolveSetup "OptimizationSetup1"

17-10 Optimetrics Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Parametric Script Commands


EditSetup [Parametric]
GenerateVariationData [Parametric]
InsertSetup [Parametric]

EditSetup [Parametric]
Use:

Modifies an existing parametric setup.

Command:

Right-click the setup in the project tree, and then click Properties on the
shortcut menu.

Syntax:

EditSetup <SetupName>, <ParametricParams>

Return Value:

None

GenerateVariationData (Parametric)
Use:

Generate variation data before parametric solve for CAD integrated project

Command:

Right click on the parametric setup in the project tree and choose
"Generate Variation Data"

Syntax:

GenerateVariationData <SetupName>

Return Value:

None

Parameters:

<SetupName>
Name of th esetup.

Example:
oModule.GenerateVariationData "ParametricSetup1"

InsertSetup [Parametric]
Use:

Inserts a new setup.

Command:

Right-click the Optimetrics folder in the project tree, and then click Add>
Parametric on the shortcut menu.

Syntax:

InsertSetup "OptiParametric", <ParametricParams>

Return Value:

None

Parameters:

<Parametric Params>
Array("NAME:<SetupName>", "SaveFields:=",
<SaveField>, <StartingPoint>, "Sim. Setups:=",
<SimSetups>,
<SweepDefs>, <SweepOps>,
Array("NAME:Goals", Array("NAME:Goal",
Optimetrics Module Script Commands 17-11

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<OptiGoalSpec>), ... Array("NAME:Goal",


<OptiGoalSpec>))
<SetupName>
Type: <string>
Name of the parametric setup.
<SimSetups>
Type: Array of strings.
An array of HFSS solution setup names.
<SweepDefs>
Array("NAME:Sweeps",
Array("NAME:SweepDefinition", "Variable:=",
<VarName>, "Data:=", <SweepData>,
"Synchronize:=", <SyncNum>), ...
Array("NAME:SweepDefinition", "Variable:=",
<VarName>, "Data:=", <SweepData>,
"Synchronize:=", <SyncNum>))
<SweepData>
"<SweepType>, <StartV>, <StopV>, <StepV>"
<SweepType>
Type: <string>
The type of sweep data.
<SyncNum>
Type: <int>
SweepDatas with the same value are synchronized.
<SweepOps>
Array("NAME:Sweep Operations", "<OpType>:=,
Array(<VarValue>, , <VarValue>), ...
<OpType>:=, Array(<VarValue>, , <VarValue>))
17-12 Optimetrics Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<OpType>
Type: <string>
The sweep operation type.
Example:
oModule.InsertSetup "OptiParametric",
Array("NAME:ParametricSetup1", _
"SaveFields:=", true,

Array("NAME:StartingPoint"), _
"Sim. Setups:=", Array("Setup1"),_
Array("NAME:Sweeps", _
Array("NAME:SweepDefinition", _
"Variable:=", "$width", _
"Data:=", "LIN 12mm 17mm 2.5mm", _
"OffsetF1:=", false, _
"Synchronize:=",

0),

Array("NAME:SweepDefinition", _
"Variable:=", "$length", _
"Data:=",

"LIN 8mm 12mm 2mm", _

"OffsetF1:=", false, _
"Synchronize:=", 0)),
Array("NAME:Sweep Operations"), _
Array("NAME:Goals", _
Array("NAME:Goal", _
"Solution:=",

"Setup1 : LastAdaptive", _

"Calculation:=", "returnloss", _
"Context:=", "",_
Array("NAME:Ranges", _
"Range:=", Array("Var:=", "Freq", "Type:=", "s", _
"Start:=", "8GHz", "Stop:=", "8GHz"))), _
Array("NAME:Goal", _
"Solution:=",

"Setup1 : LastAdaptive",_

"Calculation:=", "reflect", _
"Context:=", "", _
Array("NAME:Ranges", _
Optimetrics Module Script Commands 17-13
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Range:=", Array("Var:=", "Freq", "Type:=", "s", _


"Start:=", "8GHz", "Stop:=", "8GHz")))))

17-14 Optimetrics Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Optimization Script Commands


EditSetup [Optimization]
InsertSetup [Optimization]

EditSetup [Optimization]
Use:

Modifies an existing optimization setup.

Command:

Right-click the setup in the project tree, and then click Properties on the
shortcut menu.

Syntax:

EditSetup <SetupName>, <OptimizationParams>

Return Value:

None

InsertSetup [Optimization]
Use:

Inserts a new optimization setup.

Command:

Right-click the Optimetrics folder in the project tree, and then click
Add>Optimization on the shortcut menu.

Syntax:

InsertSetup "OptiOptimization", <OptimizationParams>

Return Value:

None

Parameters:

<OptimizationParams>
Array("NAME:<SetupName>", "SaveFields:=",
<SaveField>,

<StartingPoint>, "Optimizer:=",

<Optimizer>,
"MaxIterations:=", <MaxIter>, "PriorPSetup:=",
<PriorSetup>, "PreSolvePSetup:=", <Preceed>,
<OptimizationVars>, <Constraint>,
Array("NAME:Goals", Array("NAME:Goal",
<OptiGoalSpec>, <OptimizationGoalSpec>), ...
Array("NAME:Goal", <OptiGoalSpec>,
<OptimizationGoalSpec>)),
"Acceptable_Cost:=", <AcceptableCost>, "Noise:=",
<Noise>, "UpdateDesignWhenDone:=", <UpdateDesign"
<OptimizationVars>
Array("NAME:Variables", "VarName:=", Array("i:=",
<IncludeVar>, "Min:=", <MinV>, "Max:=", <MaxV>,
"MinStep:=", <MinStepV>, "MaxStep:=", <MaxStepV>),
Optimetrics Module Script Commands 17-15
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

. "VarName:=", Array("i:=", <IncludeVar>,


"Min:=", <MinV>, "Max:=", <MaxV>,
"MinStep:=", <MinStepV>, "MaxStep:=", <MaxStepV>))
<MinStepV>
Type : <VarValue>
The minimum step of the variable.
<MaxStepV>
Type: <VarValue>
The maximum step of the variable.
<AcceptableCost>
Type: <double>
The acceptable cost value for the optimizer to stop.
<Noise>
Type: <double>
The noise of the design.
<UpdateDesign>
Type: <bool>
Specifies whether or not to apply the optimal variation to the design after the optimization is done.
<OptimizationGoalSpec>
"Condition:=", <OptimizationCond>,
Array("NAME:GoalValue", "GoalValueType:=",
<GoalValueType>,
"Format:=", <GoalValueFormat>, "bG:=",
Array("v:=", <GoalValue>)), "Weight:=", <Weight>)
<OptimizationCond>
Type: <string>
Either "<=", "==", or ">="

17-16 Optimetrics Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<GoalValueType>
Type: <string>
Either "Independent" or "Dependent"
<GoalValueFormat>
Type:<string>
Either "Real/Imag" or "Mag/Ang".
<GoalValue>
Type: <string>
Value in string. Value can be a real number, complex number, or expression.
Example:
oModule.InsertSetup "OptiOptimization",_
Array("NAME:OptimizationSetup1", _
"SaveFields:=",

false, _

Array("NAME:StartingPoint", "$length:=", "8mm", _


"$width:=", "14.5mm"), _
"Optimizer:=",

"Quasi Newton", _

"MaxIterations:=", 100, _
"PriorPSetup:=", "ParametricSetup1", _
"PreSolvePSetup:=",

true, _

Array("NAME:Variables", _
"$length:=", Array("i:=", true, "Min:=", "6mm", _
"Max:=", "18mm", _
"MinStep:=", "0.001mm", "MaxStep:=", _
"1.2mm"), _
"$width:=", Array("i:=",

true, "Min:=", _

"6.5mm", "Max:=", "19.5mm", _


"MinStep:=", "0.001mm", "MaxStep:=", _
"1.3mm")), _
Array("NAME:LCS"), _
Array("NAME:Goals", _
Array("NAME:Goal", _
"Solution:=",

"Setup1 : LastAdaptive", _

"Calculation:=", "reflect", _
Optimetrics Module Script Commands 17-17
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Context:=", "", _
Array("NAME:Ranges", _
"Range:=", Array("Var:=",

"Freq", _

"Type:=", "s", _
"Start:=", "8GHz", "Stop:=", "8GHz")), _
"Condition:=",

"<=", _

Array("NAME:GoalValue", _
"GoalValueType:=", "Independent", _
"Format:=",

"Real/Imag", _

"bG:=", Array("v:=", "[0.0001]")), _


"Weight:=", "[1]")),
"Acceptable_Cost:=",

0.0002, _

"Noise:=", 0.0001, _
"UpdateDesign:=", true, _
"UpdateIteration:=", 5, _
"KeepReportAxis:=",

true, _

"UpdateDesignWhenDone:=", true)

17-18 Optimetrics Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Sensitivity Script Commands


EditSetup [Sensitivity]
InsertSetup [Sensitivity]

EditSetup [Sensitivity]
Use:

Modifies an existing sensitivity setup.

Command:

Right-click the setup in the project tree, and then click Properties on the
shortcut menu.

Syntax:

EditSetup <SetupName>, <SensitivityParams>

Return Value:

None

InsertSetup [Sensitivity]
Use:

Inserts a new sensitivity setup.

Command:

Right-click Optimetrics in the project tree, and then click Add>Sensitivity


on the shortcut menu.

Syntax:

InsertSetup "OptiSensitivity", <SensitivityParams>

Return Value:

None

Parameters:

<SensitivityParams>
Array("NAME:<SetupName>",
"SaveFields:=", <SaveField>,
<StartingPoint>,
"MaxIterations:=", <MaxIter>,
"PriorPSetup:=", <PriorSetup>,
"PreSolvePSetup:=", <Preceed>,

<SensitivityVars>,

<Constraint>,
Array("NAME:Goals",
Array("NAME:Goal", <OptiGoalSpec>), ...,
Array("NAME:Goal", <OptiGoalSpec>)),
"Master Goal:=". <MasterGoalID>,
"MasterError:=", <MasterError>)
<SensitivityVars>
Array("NAME:Variables",
"VarName:=", Array("i:=", <IncludeVar>,
"Min:=", <MinV>, "Max:=", <MaxV>,
Optimetrics Module Script Commands 17-19
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"IDisp:=", <InitialDisp>),...
"VarName:=", Array("i:=", <IncludeVar>,
"Min:=", <MinV>, "Max:=", <MaxV>,
"IDisp:=", <InitialDisp>))
<InitialDisp>
Type : <VarValue>
The initial displacement of the variable.
<MasterGoalID>
Type: <int>
Index of the master goal. Index starts from zero.
<MasterError>
Type: <double>
Error associated with the master goal.
Example:
oModule.InsertSetup "OptiSensitivity", _
Array("NAME:SensitivitySetup1",_
"SaveFields:=", true,_
Array("NAME:StartingPoint"), _
"MaxIterations:=", 20,_
"PriorPSetup:=", "",_
"PreSolvePSetup:=",

true, _

Array("NAME:Variables"), _
Array("NAME:LCS"),_
Array("NAME:Goals",_
Array("NAME:Goal", _
"Solution:=", "Setup1 : LastAdaptive",_
"Calculation:=", "returnloss",_
"Context:=", "",_
Array("NAME:Ranges",_
"Range:=", Array("Var:=", "Freq", "_
Type:=", "s",_
"Start:=", "8GHz", "Stop:=", "8GHz"))),_
17-20 Optimetrics Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array("NAME:Goal",_
"Solution:=", "Setup1 : LastAdaptive",_
"Calculation:=", "reflect",_
"Context:=", "",_
Array("NAME:Ranges",_
"Range:=", Array("Var:=","Freq",_
"Type:=", "s",_
"Start:=", "8GHz", "Stop:=", "8GHz")))),_
"Master Goal:=",

1,_

"MasterError:=", 0.001)

Statistical Script Commands


EditSetup [Statistical]
InsertSetup Statistical

EditSetup [Statistical]
Use:

Modifies an existing statistical setup.

Command:

Right-click the setup in the project tree, and click Properties on the
shortcut menu.

Syntax:

EditSetup <SetupName>, <StatisticalParams>

Return Value:

None

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 13.0.0
' 3:04:05 PM

May 18, 2010

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("optiguides")
Optimetrics Module Script Commands 17-21
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Set oDesign = oProject.SetActiveDesign("HFSSModel1")


Set oModule = oDesign.GetModule("Optimetrics")
oModule.EditSetup "StatisticalSetup1", Array("NAME:StatisticalSetup1",
Array("NAME:ProdOptiSetupData",
"SaveFields:=", true, "CopyMesh:=", false),
Array("NAME:StartingPoint", "$length:=", "7.824547736mm",
"$width:=", "14.8570192mm"),
"MaxIterations:=", 50,
"PriorPSetup:=", "",
Array("NAME:Variables",
"$length:=", Array("i:=", true,
"int:=", false,
"Dist:=", "Uniform",
"Tol:=", "10%", "StdD:=", "0.2mm", "Min:=", "-3",
"Max:=", "3", "Shape:=", "1", "Scale:=", "0.04mm",
"Location:=", "0.4mm",
"Dataset:=", "", "LatinHypercube:=", "true", "VarMin:=", "0.2mm",
"VarMax:=", "0.6mm", "Prob:=", "0.01",
"Mean:=", "0.4mm"),
"$width:=", Array("i:=", true,
"int:=", false,
"Dist:=", "Gaussian",
"Tol:=", "10%",
"StdD:=", "0.2mm",
"Min:=", "-3", "Max:=", "3",
"Shape:=", "1",
"Scale:=", "0.04mm",
"Location:=", "0.4mm",
"Dataset:=", "",
"LatinHypercube:=", "true",
"VarMin:=", "0.2mm", "VarMax:=", "0.6mm",
"Prob:=", "0.02",
"Mean:=", "0.4mm")),
Array("NAME:Goals", Array("NAME:Goal",
"ReportType:=", "Modal Solution Data",
"Solution:=", "Setup1 : PortOnly",
Array("NAME:SimValueContext", "Domain:=", "Sweep"),
"Calculation:=", "returnloss",

17-22 Optimetrics Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Name:=", "returnloss",
Array("NAME:Ranges",
"Range:=", Array("Var:=", "Freq",
"Type:=", "s",
"Start:=", "8.2GHz", "Stop:=", "0"))),
Array("NAME:Goal",
"ReportType:=", "Modal Solution Data",
"Solution:=", "Setup1 : PortOnly",
Array("NAME:SimValueContext",
"Domain:=", "Sweep"),
"Calculation:=", "reflect",
"Name:=", "reflect",
Array("NAME:Ranges",
"Range:=", Array("Var:=", "Freq",
"Type:=", "s",
"Start:=", "8.2GHz", "Stop:=", "0")))))

InsertSetup [Statistical]
Use:

Inserts a new statistical setup.

Command:

Right-click Optimetrics in the project tree, and then click Add>Statistical


on the shortcut menu.

Syntax:

InsertSetup "OptiStatistical", <StatisticalParams>

Return Value:

None

Parameters:

<StatisticalParams>
Array("NAME:<SetupName>",
"SaveFields:=", <SaveField>,
<StartingPoint>,
"MaxIterations:=",
<MaxIter>,
"PriorPSetup:=", <PriorSetup>,
"PreSolvePSetup:=", <Preceed>,
<StatisticalVars>,
Array("NAME:Goals",
Array("NAME:Goal", <OptiGoalSpec>), ,
Array("NAME:Goal", <OptiGoalSpec>))),
<StatisticalVars>
Array("NAME:Variables",
Optimetrics Module Script Commands 17-23

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"VarName:=", Array("i:=", <Boolean>,


"int:=", <Boolean>,
"Dist:=", <DistType>,
"Tol:=", <Tolerance>,
"StdD:=", <StdD>,
"Min:=", <MinCutoff>,
"Max:=", <MaxCutoff>, ...
"Shape:=", "<VarParameter>",
"Scale:=", "<VariableParameter>",
"Location:=", "<VariableParameter>",
"Dataset:=", "",
"LatinHypercube:=", "<Boolean>",
"VarMin:=", "<VariableValue>",
"VarMax:=", "<VariableValue>",
"Prob:=", "<Probability>",
"Mean:=", "<Mean>")
)
<DistType>
Type : <string>
Distrbution can be "Gaussian","Uniform", LogNormal or UserDefined.
<Tolerance>
Type: <VarValue>
The tolerance for the variable when distribution is Uniform.
<StdD>
Type: <VarValue>
The standard deviation for the variable when distribution is Gaussian.
<MinCutoff>
Type: <double>
Formerly the minimum cut-off for the variable when distribution is Gaussian. Legacy.
<MaxCutoff>
Type: <double>
Formerly the maximum cut-off for the variable when distribution is Gaussian. Leg17-24 Optimetrics Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

acy.
<Prob>
Type: <double>
Probability for Gaussian distribution. A value >= 0 and < 0.1.
<Mean>
Type: <double>
Mean for Gaussian distribution.

Example:
' ---------------------------------------------' Script Recorded by Ansoft HFSS Version 13.0.0
' 3:29:39 PM

May 18, 2010

' ---------------------------------------------Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("OptimTee")
Set oDesign = oProject.SetActiveDesign("TeeModel")
oDesign.ChangeProperty Array("NAME:AllTabs",
Array("NAME:LocalVariableTab",
Array("NAME:PropServers", "LocalVariables"),
Array("NAME:ChangedProps",
Array("NAME:offset",
Array("NAME:Statistical", "Included:=", true)))))
Set oModule = oDesign.GetModule("Optimetrics")
oModule.InsertSetup "OptiStatistical", Array("NAME:StatisticalSetup1",
Array("NAME:ProdOptiSetupData",
"SaveFields:=", false, "CopyMesh:=", false),
Array("NAME:StartingPoint", "offset:=", "0in"),
Optimetrics Module Script Commands 17-25
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"MaxIterations:=", 50, "PriorPSetup:=", "",


Array("NAME:Variables",
"offset:=", Array("i:=", true,
"int:=", false,
"Dist:=", "Gaussian",
"Tol:=", "10%",
"StdD:=", ".5in",
"Min:=", "-3",
"Max:=", "3",
"Shape:=", "1",
"Scale:=", "0in",
"Location:=", "0in",
"Dataset:=", "",
"LatinHypercube:=", "true",
"VarMin:=", "-1in",
"VarMax:=", "1in",
"Prob:=", "0.01",
"Mean:=", "0in")),
Array("NAME:Goals", Array("NAME:Goal",
"ReportType:=", "Modal Solution Data",
"Solution:=", "Setup1 : LastAdaptive", Array("NAME:SimValueContext"),
"Calculation:=", "Power11",
"Name:=", "Power11",
Array("NAME:Ranges",
"Range:=", Array("Var:=", "Freq", "Type:=", "d",
"DiscreteValues:=", "10GHz")))))

17-26 Optimetrics Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

18

Solutions Module Script


Commands

Solutions commands should be executed by the "Solutions" module.


Set oModule = oDesign.GetModule("Solutions")
oModule.CommandName <args>
DeleteImportData
EditSources
DeleteFullVariation
DeleteSolutionVariation
DeleteVariation
ExportForSpice
ExportEigenmodes
ExportForHSpice
ExportNetworkData
ExportNMFData
GetAdaptiveFreq
GetISolutionVersionID
GetSolveRangeInfo
GetValidSolutionList
HasFields
HasMatrixData
HasMesh
ImportSolution
ImportTable
Solutions Module Script Commands 18-1
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

IsFieldAvailableAt
ListMatchingVariations
ListValuesOfVariables
ListVariations

DeleteImportData
Use:

Deletes imported solution or table data in HFSS. Not in HFSS-IE

Command:

HFSS>Results>Import Solutions

Syntax:

DeleteImportData <ImportSpecArray>

Return Value:

None

Parameters:

<ImportSpecArray>
Array(<ImportSpec>, ...)
<ImportSpec>
Type: <string>
Format of string is "importname:solnnameORtablename".

Example:
oModule.DeleteImportData _
Array("Import1:Adaptive_1", "Import2:DataTable")

EditSources
Use:

Indicates which source excitations should be used for fields post processing.

Command:

HFSS>Fields>Edit Sources

Syntax:

EditSources<FieldType>, <SourceArray>,
<MultiplicityArray>, <MagnitudeArray>,
<PhaseArray>, <TerminatedArray>,
<ImpedanceArray>, <IncludePostProcessing>

Return Value:

None

Parameters:

<FieldType>
Type: <string>
Possible values are:
"NoIncidentWave", "ScatteredFields", "TotalFields",
"IncidentFields", "EigenStoredEnergy", or "EigenPeakElectricField"
<SourceArray>
Array("NAME:SourceNames", <Source1Name>,

18-2 Solutions Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<Source2Name>, ...)
A source name is typically the name of the associated excitation.
<MultiplicityArray>
Array("NAME:Modes", <port1NumModes>, <port2NumModes>,
...)
or
Array("NAME:Terminals", <port1NumTerminals>, ...)
A non-port source should indicate multiplicity of 1.
<MagnitudeArray>
Array("NAME:Magnitudes", <Source1Mag>, <Source2Mag>,
...)
This gives the Mag of the complex excitation for each source.
<PhaseArray>
Array("NAME:Phases", <Source1Phase>, <Source2Phase>,
...)
This gives the Phase in degrees of the complex excitation for each source. For Eigenmoded stored energy problems, phase array is not recorded by Tools>Record Script
to File, , and is not needed when running scripts for such problems.
<TerminatedArray>
Array("NAME:Terminated", <IsSource1Terminated>, ...)
Only used for a Driven Terminal solution-type problem.
If it is Driven Terminal, then each source must have an entry, but
entries for non port sources are ignored.
<ImpedanceArray>
Array("NAME:Impedances", <Source1ComplexImped>, ...)
Only for a Driven Terminal solution-type problem.
If it is Driven Terminal, there must be an entry for each terminated
source. Complex format is a string representation as "re + im j".
<IncludePostProcessing>
Type: <bool>
Specifies whether to include post processing effects.
Solutions Module Script Commands 18-3
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<useIncidentVoltage>
Type: <bool>
For driven terminal projects, this specifies whether to use incident voltage. The
default for this argument if missing is "false", so that legacy driven terminal projects
behave as if using total voltage.
Example:
oModule.EditSources "NoIncidentWave", _
Array("NAME:SourceNames", "WavePort1", _
"WavePort2"), Array("NAME:Terminals", 2, 2), _
Array("NAME:Magnitudes", 1, 0), _
Array("NAME:Phases",

0, 0),_

Array("NAME:Terminated", false, true, true, false), _


Array("NAME:Impedances",

"50 + 80 j", "50 + 90 j")

Example:
oModule.EditSources "NoIncidentWave", _
Array("NAME:SourceNames", "EigenMode"), _
Array("NAME:Modes",

2), Array("NAME:Magnitudes", _

0, 1), Array("NAME:Phases", 0, 45), _


Array("NAME:Terminated"), Array("NAME:Impedances")
Example:
oModule.EditSources "TotalFields", _
Array("NAME:SourceNames", "WavePort1", _
"LumpPort1", "IncWave1", "Voltage1", "Current1"),_
Array("NAME:Modes", 1, 1, 6, 1, 1), _
Array("NAME:Magnitudes",

17, 19, 1, 3, 5, 7, 9, 11, 13, 15), _


Array("NAME:Phases", 0, 20, 2, 4, _
6, 8, 10, 12, 14, 16), Array("NAME:Terminated"),_
Array("NAME:Impedances")
Example:
oModule.EditSources "NoIncidentWave",
Array("NAME:Names", "P01__NET179_", _
"P02__NET178_", "P03__NET178_", "P04__NET179_"),
Array("NAME:Terminals", 1, 1, 1, 1),
Array("NAME:Magnitudes", "1", "0", "0", "0"),
18-4 Solutions Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array("NAME:Phases", "0deg", "0deg", "0deg", "0deg"),


Array("NAME:Terminated", false, false, false, false),
Array("NAME:Impedances"), true, true
Example:
Set oDesign = oProject.SetActiveDesign("PEC_d1")
oDesign.SetSolutionType "Transient Network"
Set oModule = oDesign.GetModule("Solutions")
oModule.EditSources "ScatteredFields",
Array("NAME:Names", "IncPWave1"),
Array("NAME:Terminals", 1),
Array("NAME:Magnitudes", "1"),
Array("NAME:Phases", "0deg")
oModule.EditSources "ScatteredFields",
Array("NAME:Names", "IncPWave1"), Array("NAME:Terminals", 1),
Array("NAME:TransientMagnitudes", "1"),
Array("NAME:Delays", "0.2s")

DeleteFullVariation
Use:

Use to selectively make deletions or delete all solution data.

Command:

HFSS>Results>Clean Up Solutions...

Syntax:

DeleteFullVariation Array(<parameters>), boolean

Parameters:

<DataSpecifierArray>
Array(<DesignVariationKey>, )
<DesignVariationKey>
Type: <string>
Design variation string.
<Boolean>
Type: boolean
Whether to also delete linked data.

Example:
Set oDesign = oProject.SetActiveDesign("HFSSModel1")
oDesign.DeleteFullVariation Array(""), false
Example:
Solutions Module Script Commands 18-5
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("ogive")
Set oDesign = oProject.SetActiveDesign("IEDesign1")
oDesign.DeleteFullVariation Array(""), true
Example:
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Tee")
Set oDesign = oProject.SetActiveDesign("TeeModel")
oDesign.DeleteFullVariation Array("offset=" &Chr(39) & "0.2in" _
& Chr(39) & "", "offset=" & Chr(39) & "0in" & Chr(39) & ""), false

DeleteSolutionVariation
Use:

Deletes all solution data for specific solutions and design variations. This is
supported for backward compatibility. You should use DeleteFullVariation.

Command:

HFSS>Results>Clean Up Solutions

Syntax:

DeleteSolutionVariation
Array(<DataSpecifierArray>, ...)

Return Value:

None

Parameters:

<DataSpecifierArray>
Array(<DesignVariationKey>, <SetupName>, <SolnName>)
<DesignVariationKey>
Type: <string>
Design variation string.
<SetupName>
Type: <string>
Name of the solution setup.

18-6 Solutions Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<SolnName>
Type: <string>
Name of the solutions within the solution setup.
Example:
oModule.DeleteSolutionVariation Array( _
Array("width=2in", "Setup1", "Adaptive_1") _
Array("width=2in", "Setup1", "Sweep1") )

DeleteVariation
Use:

Deletes matrix, field, and/or mesh solution data for specific variations,
across all solutions.

Command:

HFSS>Results>Browse Solutions

Syntax:

DeleteVariation <VariationArray>, <FullVariations>,


<MeshAndFieldsOnly>, <FieldsOnly>

Return Value:

None

Parameters:

<VariationArray>
Array(<DesignVariationKey>, <DesignVariationKey>,...)
<FullVariations>
Type: <bool>
Specifies whether to delete meshes, fields, matrix data, profile, and convergence data.
<MeshAndFieldsOnly>
Type: <bool>
Specifies whether to delete only meshes and fields.
<FieldsOnly>
Type: <bool>
Specifies whether to delete fields only.

Example:
oModule.DeleteVariation _
Array("width=2in", "width=2.5in"), _
TRUE, FALSE, FALSE

Solutions Module Script Commands 18-7


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

ExportForSpice
Use:

Exports matrix solution data to a file in a format suitable for Spice analysis.
Available only for Driven Terminal solution types with ports. Output in an
appropriate format will be generated for each of the non-empty file names
provided.

Command:

None

Syntax:

ExportForSpice
<DesignVariationKey>, <SolnSelectionArray>, <SpiceType>,
<BandWidth>, <FWSFile>, <LumpedElementFile>,
<PoleZeroSpiceFile>, <PoleZeroMatlabFile>,
<PartialFractionFile>, <FittingErrorInPercent>,
<MaximumOrder>,
<UseCommonGround>,
<EnforcePassivity>

Return Value:

None

Parameters:

<SpiceType>
Type: <int>
Possible values are:
0: PSpice
2: Maxwell Spice
<BandWidth>
Type: <int>
Possible values are:
0: Low (narrow) band width
<FWSFile>
Type: <string>
<LumpedElementFile>
Type: <string>
<PoleZeroSpiceFile>
Type: <string>

18-8 Solutions Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<PoleZeroMatlabFile>
Type: <string>
<PartialFractionFile>
Type: <string>
<FittingErrorInPercent>
Type: <Float>
<MaximumOrder>
Type: <Integer>
<UseCommonground>
Type: 0/1
<EnforcePassivity>
Type: 0/1
Example:
oModule.ExportForSpice "width=2in", _
Array("Setup1:Sweep1"), 2, 0, _
"c:\mydir\Sweep1.fws", "", "", "", ""

ExportEigenmodes
Use:

Exports a tab delimited table of Eigenmodes in HFSS. Not in HFSS-IE.

Command:

None

Syntax:

ExportEigenmodes
<setupName> <solutionName> <DesignVariationKey>
<filename>

Return Value:

None

Parameters:
<SolutionName>
Type: <string>
Name of the solutions within the solution setup.
<DesignVariationKey>
Type: <string>
Design variation string.
Example:
Solutions Module Script Commands 18-9
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Set oModule = oDesign.GetModule("Solutions")


oModule.ExportEigenmodes "Setup1 : LastAdaptive", "",

"C:\mydir\myeigenmode" & _
".eig"

ExportForHSpice
Use:

Exports matrix solution data to a file in a format suitable for HSpice


analysis. Available only for Driven Terminal solution types with ports.
Output in an appropriate format will be generated for each of the nonempty file names provided.

Command:

None

Syntax:

ExportForHSpice
<DesignVariationKey>, <SolnSelectionArray>, <SpiceType>,
<BandWidth>, <FWSFile>, <LumpedElementFile>,
<PoleZeroSpiceFile>, <PoleZeroMatlabFile>,
<PartialFractionFile>,
<FittingErrorInPercent>, <MaximumOrder>, <MinimumOrder>,
<EnforcePassivity>

Return Value:

None

Parameters:

<SpiceType>
Type: <int>
Possible value is:
1: HSpice
<BandWidth>
Type: <int>
Possible value is:
0: Low (narrow) band width
<FWSFile>
Type: <string>
<LumpedElementFile>
Type: <string>
<PoleZeroSpiceFile>

18-10 Solutions Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Type: <string>
<PoleZeroMatlabFile>
Type: <string>
<PartialFractionFile>
Type: <string>
<FittingErrorInPercent>
Type: <float>
The accuracy to use in fitting the pole zero model.
<MaximumOrder>
Type: <int>
Maximum number of poles in rational function expansion.
<UseCommonGround>
Type:<init>
0/1
<EnforcePassivity>
Type: : <int>
0/1
Example:
oModule.ExportForHSpice "width=2in", _
Array("Setup1:Sweep1"), 1, 0, _
"c:\mydir\Sweep1.fws", "", "", "", "", _
.005, 20, 200

ExportNetworkData
Use:

Exports matrix solution data to a file. Available only for Driven solution
types with ports.

Command:

None

Syntax:

ExportNetworkData
<DesignVariationKey>, <SolnSelectionArray>, <FileFormat>,
<OutFile>,<FreqsArray>, <DoRenorm>, <RenormImped>
<dataType> <pass> <complexFormat>

Return Value:

None

Parameters:

<SolnSelectionArray>
Solutions Module Script Commands 18-11

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array(<SolnSelector>, <SolnSelector>, ...)


If more than one array entry, this indicates a combined Interpolating sweep.
<SolnSelector>
Type: <string>
Gives solution setup name and solution name, separated by a colon.
<FileFormat>
Type: <int>
Possible values are:
2 : Tab delimited spreadsheet format (.tab)
3 : Touchstone (.sNp)
4 : CitiFile (.cit)
7 : Matlab (.m)
8 : Terminal Z0 spreadsheet
<OutFile>
Type: <string>
Full path to the file to write out.
<FreqsArray>
Type: Array of doubles.
The frequencies to export. To export all frequencies, use Array("all").
<DoRenorm>
Type: <bool>
Specifies whether to renormalize the data before export.
<RenormImped>
Type: <double>
Real impedance value in ohms, for renormalization. Required in syntax,
but ignored if DoRenorm is false.
<DataType>
Type: "S", "Y", or "Z"
The matrix to export.
<Pass>
Type: string, from 1 to N.
18-12 Solutions Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

The pass to export. This is ignored if the sourceName is a frequency sweep. Leaving
out this value or specifying -1 gets all passes.
<ComplexFormat>
Type: "0", "1", or "2"
The format to use for the exported data.
0 = Magnitude/Phase.
1= Real/Imaginary.
2= db/Phase.
<TouchstonePrecision>
Type: <int>
Default if not specified is 15.
Example:

Export all frequencies:


oModule.ExportNetworkData "width=2in", _
Array("Setup1:Sweep1"),2, "c:\mydir\out.tab", _
Array("all"), false, 0

Example:

Export specific frequencies:


oModule.ExportNetworkData "width=2in", _
Array("Setup1:Sweep1", "Setup1:Sweep2"), 3, _
"c:\mydir\out.s2p", Array(1.0e9, 1.5e9, 2.0e9), _
true, 50.0

Example:

Specify Precision for Touchstone output.

oModule.ExportNetworkData "", Array("Setup1:Sweep1"), 3,

"C:/Ring_hybrid HFSSDesign.s4p", _
Array( "All"), true, 50, "S", -1, 0, 15

ExportNMFData
Use:

Exports matrix solution data to a file in neutral model format. Available


only for Driven solution types with ports. Variables can be held constant by
setting their values in the variation field. For example: "length='50mm'
width='30mm'". All other independent variables will be treated as NMF
parameters.

Command:

None

Syntax:

ExportNMFData
<SolnSelectionArray>, <OutFile>, <FreqsArray>,
<DesignVariationKey>, <DoRenorm>, <RenormImped>

Return Value:

None
Solutions Module Script Commands 18-13

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:
oModule.ExportNMFData Array("Setup1:Sweep1"), _
"c:\mydir\out.nmf", Array("all"), "", FALSE, 0

GetAdaptiveFreq
Use:

To obtain an adaptive frequency for a specified setup.

Syntax:

GetAdaptiveFreq(<SetupName>)

Return Value:

Returns a frequency value.


Type: <double>
Example: "15500000000.0"

Parameters:

<SetupName>
Type: <string>

Example:
set oModule = oDesign.GetModule("Solutions")
adaptfreq = oModule.GetAdaptiveFreq("Setup1")

GetISolutionVersionID
Use:

To obtain the solution ID to help track solution validity.

Syntax:

GetISolutionVersionID(BSTR fullSolutionName)

Return Value:

Returns a solution ID.

Parameters:

None

Example:
versionID = oModule.GetISolutionVersionID(BSTR fullSolutionName)

GetSolveRangeInfo
Use:

To determine the frequency range of a particular simulation setup. For fast


sweeps and interpolating sweeps this command returns the start and stop
frequencies. For discrete sweeps, it returns a list of frequencies. For an
adaptive solution, it returns the adaptive frequency.

Syntax:

GetSolveRangeInfo(<SolutionName>)

Return Value:

An array of frequencies.

Parameters:

<SolutionName>
Type: <string>

Example:
set oModule = oDesign.GetModule("Solutions")
18-14 Solutions Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

freqrange = oModule.GetSolveRangeInfo("Setup1:Sweep1")

GetValidISolutionList
Use:

Gets all available solution names that exist in a design.

Syntax:

GetValidISolutionList(<IncludeImportedSolutions>)

Return Value:

Array of names

Parameters:

<IncludeImportedSolutions>

Type: <Boolean>
If no parameter is given the default is False.
Example:
solution = oModule.GetValidISolutionList(True)

HasFields
Use:

To determine if fields exist for a particular solution.

Syntax:

HasFields(<SolutionName>, <DesignVariation>)

Return Value:

Returns 1 or 0 ( 1= true, 0 = false)


Type: Boolean

Parameters:

<SolutionName>
Type: <string>
Example: "Setup1:LastAdaptive"
<DesignVariation>
Type: <string>
Example: "x_size = 2mm"

Example:
set oModule = oDesign.GetModule("Solutions")
fieldsExist = oModule.HasFields("Setup1:Sweep1", _
"x_size=2mm")

HasMatrixData
Use:

To determine if matrix data exists for a particular solution.

Syntax:

HasMatrixData(<SolutionName>, <DesignVariation>)

Return Value:

Returns 1 or 0 ( 1= true, 0 = false)


Type: Boolean

Parameters:

<SolutionName>
Solutions Module Script Commands 18-15

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Type: <string>
Example: "Setup1:LastAdpative"
<DesignVariation>
Type: <string>
Example: "radius = 4in"
Example:
set oModule = oDesign.GetModule("Solutions")
matrixExist = 0Module.HasMatrixData("Setup1:Adaptive_1",_
"radius = 4in")

HasMesh
Use:

To determine if a current mesh exists for a particular simulation setup, not


including the initial mesh.

Syntax:

HasMesh(<SetupName>, <DesignVariation>)

Return Value:

Returns 1 or 0 ( 1= true, 0 = false)


Type: Boolean

Parameters:

<SetupName>
Type: <string>
<DesignVariation>
Type: <string>

Example:
set oModule = oDesign.GetModule("Solutions")
meshexist = oModule.HasMesh("Setup1", "x_size = 2in _
y_size = 1in")

ImportSolution
Use:

Imports a matrix solution in HFSS, which can then be used in creating


reports or in the display of matrix data. The imported solution need not
have the same characteristics as the current design. Imported terminal data
that meets the required criteria can be used for full-wave Spice export. Not
used in HFSS-IE.

Command:

HFSS>Results>Import Solutions

Syntax:

ImportSolution <FileName>, <ImportName>, <SolnArray>

Return Value:

None

Parameters:

<FileName>
Type: <string>

18-16 Solutions Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Location of the source data. The type of the data file will be determined strictly by its
file extension. Supported types are Touchstone (.sNp or .yNp or .zNp or .tou), and
Ansoft Designer (.flp).
<ImportName>
Type: <string>
Identifying name to use for the import, analogous to solution setup name.
<SolnArray>
Type: Array of strings
The names of the solutions selected for import from the file. The only import format
supporting multiple solutions in one file is HFSS8.x format.
Example:
oModule.ImportSolution "c:\mydir\in.s2p", _
"MeasuredData", Array("Sweep1")

ImportTable
Use:

Imports a data table for use in plotting reports in HFSS. Not used in HFSS-IE.
The table can have multiple independent real-valued columns of data, and
multiple dependent real- or complex-valued columns of data. The data
supported imports are either tab delimited format (.tab) or comma
delimited format (.csv). The first row may contain column names. Complex
data columns are inferred from the column data format. In tab delimited
format, "(double, double)" denotes a complex number. In comma
delimited format, "(double, double)" denotes a complex number.

Command:

HFSS>Results>Import Solutions

Syntax:

ImportTable
<FileName>, <ImportName>, <TableName>,
<ComplexIsRealImag>, <IsMatrixData>,
<ColNames>, <ColIndependentFlags>

Return Value:

None

Parameters:

<FileName>
Type: <string>
Location of the source data.
<ImportName>
Type: <string>
Solutions Module Script Commands 18-17

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Identifying name to use for the import, analogous to solution setup name.
<TableName>
Type: <string>
Identifying name for the table, analogous to solution name.
<ComplexIsRealImag>
Type: <bool>
Whether to use real/imag to interpret data for any complex column.
If false, then use mag/phase(degrees).
<IsMatrixData>
Type: <bool>
Controls whether the table data can be used in matrix data reports or in field data
reports.
<ColNames>
Array("ColName1", ...)
Non-empty array used only if you want to override the column names obtained from
the table data file, in which case all column names are required.
<ColIndependentFlags>
Array(<bool>, ...)
Indicates which columns are independent. If this is the empty array, the default is that
only the first column is independent. If this is the non- empty array, a flag must be
present for every column.
Example:
oModule.ImportTable "c:\mydir\mytable.tab", _
"ImportData", "Measurements", TRUE, TRUE, _
Array(), Array(TRUE, TRUE, FALSE, FALSE, FALSE)

IsFieldAvailableAt
Use:

To determine if a field solution exists for a particular frequency in a


simulation.

Syntax:

IsFieldAvailableAt(<SolutionName>, <DesignVariation>,
<Freq>)

18-18 Solutions Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Return Value:

Returns 1 or 0 ( 1= true, 0 = false)


Type: Boolean

Parameters:

<SolutionName>
Type: <string>
<DesignVariation>
Type: <string>
Example: "y_start = 3mm"
<Freq>
Type: <double>

Example:
set oModule = oDesign.GetModule("Solutions")
fieldsExist = oModule.IsFieldAvailableAt _
("Setup1:Sweep1", " ", "9000000000.0")

ListMatchingVariations
Use:

Gets a list of solved variations that include the specified variable values.

Command:

None

Syntax:

ListMatchingVariations
(<FullSolutionName>, <ArrayOfMatchingVariableNames>,
<ArrayOfMatchingVariableValueStringsIncludingUits>)

Return Value:

An array of strings corresponding to solved variations. The match variables


may be a partial set of design variables and the match values are one per
variable in the same order as the variables.

Parameters:

<FullSolutionName>
Type: String
<ArrayOfMatchingVariableNames>
Type: String
<ArrayOfMatchingVariableValueStringsIncludingUnits>
Type: String

Example:
list = oModule.ListMatchingVariations("Setup1 : LastAdaptive",_
Array("x_size", "y_size"), Array("2mm", "1mm"))

ListValuesOfVariable
Use:

Gets the values of a specified variable corresponding to the solved


variations.
Solutions Module Script Commands 18-19
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Command:

None

Syntax:

ListValuesOfVariable(<FullSolutionName>, <VariableName>)

Return Value:

An array of double precision values in SI units interpreted as the specified


variable corresponding to the solved variations.

Parameters:

<FullSolutionVariableName>
Type: String
<VariableName>
Type: String

Example:
list = oModule.ListValuesOfVariable("Setup1 : _LastAdaptive", "x_size")

ListVariations
Use:

Get a list of solved variations.

Command:

None

Syntax:

ListVariations(<FullSolutionName>)

Return Value:

An array of strings corresponding to solved variations.

Parameters:

<FullSolutionName>
Type: String

Example:
list = oModule.ListVariations("Setup1 : LastAdaptive")

18-20 Solutions Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

19

Field Overlays Module


Script Commands

Field overlay commands should be executed by the Field Overlays module,


which is called "FieldsReporter" in HFSS scripts.
Set oModule = oDesign.GetModule("FieldsReporter")
oModule.CommandName <args>
CreateFieldPlot
DeleteFieldPlot
GetFieldPlotName
ModifyFieldPlot
RenameFieldPlot
RenamePlotFolder
SetFieldPlotSettings
SetPlotFolderSettings

Field Overlays Module Script Commands 19-1


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

CreateFieldPlot
Use:

Creates a field/mesh plot.

Command:

HFSS>Fields>Plot Fields>Mag_E

Syntax:

CreateFieldPlot

Return Value:

None

Parameters:

<PlotParameterArray>

<PlotParameterArray>

Array("NAME:<PlotName>",
"SolutionName:=", <string>,
"QuantityName:=", <string>,
"PlotFolder:=", <string>,
"UserSpecifyName:=",

<int>,

"UserSpecifyFolder:=", <int>,
"IntrinsicVar:=", <string>,
"PlotGeomInfo:=", <PlotGeomArray>,
"FilterBoxes:=", <FilterBoxArray>,
<PlotOnPointsSettings>,
<PlotOnLineSettings>,
<PlotOnSurfaceSettings>,
<PlotOnVolumeSettings>)
SolutionName
Name of the solution setup and solution formatted as:
"<SolveSetupName> : <WhichSolution>",
where <WhichSolution> can be "Adaptive_<n>",
"LastAdaptive", or "PortOnly".
For example: "Setup1 : Adaptive_2"
HFSS requires a space on either side of the : character. If it is
missing, the plot will not be created.
QuantityName
Type of plot to create. Possible values are:
Mesh plots: "Mesh"
Field plots: "Mag_E", "Mag_H", "Mag_Jvol", "Mag_Jsurf",
"ComplexMag_E", "ComplexMag_H", "ComplexMag_Jvol",
"ComplexMag_Jsurf", "Vector_E", "Vector_H",
19-2 Field Overlays Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"Vector_Jvol", "Vector_Jsurf", "Vector_RealPoynting",


"Local_SAR", "Average_SAR"
PlotFolder
Name of the folder to which the plot should be added. Possible values
are: "E Field",

"H Field", "Jvol", "Jsurf", "SAR

Field", and "MeshPlots".


UserSpecifyName
0 if default name for plot is used, 1 otherwise.
Not needed. <PlotName> will be respected regardless of whether this
flag is set.
UserSpecifyFolder
0 if default folder for plot is used, 1 otherwise.
Not needed. The specified PlotFolder will be respected regardless of
whether this flag is set.
IntrinsicVar
Formatted string that specifies the frequency and phase at which to make the plot.
For example: "Freq='1GHz' Phase='30deg'"
<PlotGeomArray>
Array(<NumGeomTypes>, <GeomTypeData>,
<GeomTypeData>, ...)
For example: Array(4, "Volume", "ObjList", 1, "Box1",
"Surface", "FacesList", 1, "12", "Line", 1,
"Polyline1", "Point", 2, "Point1", "Point2")
<NumGeomTypes>
Type: <int>
Number of different geometry types (volume, surface, line, point)
plotted on at the same time.
<GeomTypeData>
Field Overlays Module Script Commands 19-3
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<GeomType>, <ListType>, <NumIDs>, <ID>, <ID>, ...)


<GeomType>
Type: <string>
Possible values are "Volume", "Surface", "Line", "Point".
<ListType>
Type: <string>
Possible values are "ObjList", or "FacesList".
These are used for the GeomType of "Line" or "Point".
<NumIDs>
Type: <int>
Number of IDs or object names that will follow.
<ID>
Type: <int> or <string>
ID of a face or name of an object, line, or point on which to plot.
<FilterBoxArray>
Array of names of objects to use to restrict the plot range.
Array(<NumFilters>, <ObjName>, <ObjName>, ...)
Example: Array(1, "Box1")
Example: Array(0)

no filtering

<PlotOnPointSettings>
Array("NAME:PlotOnPointSettings",
"PlotMarker:=", <bool>,
"PlotArrow:=", <bool>)
<PlotOnLineSettings>
Array("NAME:PlotOnLineSettings",
Array("NAME:LineSettingsID",
"Width:=", <int>,
"Style:=", <string>),
"IsoValType:=", <string>,
19-4 Field Overlays Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"ArrowUniform:=", <bool>,
"NumofArrow:=",

<int>)

Style
Possible values are "Cylinder", "Solid", "Dashdash",
"Dotdot", "Dotdash"
IsoValType
Possible values are "Tone", "Fringe", "Gourard"
<PlotOnSurfaceSettings>
Array("NAME:PlotOnSurfaceSettings",
"Filled:=", <bool>,
"IsoValType:=", <string>,
"SmoothShade:=", <bool>,
"AddGrid:=", <bool>,
"MapTransparency:=", <bool>,
"Transparency:=", <doubl.e>,
"ArrowUniform:=", <bool>
"ArrowSpacing:=",

<double>

"GridColor:=", Array(<int>, <int>, <int>)


IsoValType
Possible values are: "Tone", "Line", "Fringe", "Gourard"
GridColor
Array containing the R, G, B components of the color. Components
should be in the range 0 to 255.
<PlotOnVolumeSettings>
Array("NAME:PlotOnVolumeSettings",
"PlotIsoSurface:=", <bool>,
"CloudDensity:=", <double>,
"PointSize:=", <int>,
"ArrowUniform:=", <bool>,
"ArrowSpacing:=", <double>)
Field Overlays Module Script Commands 19-5
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:
oModule.CreateFieldPlot Array("NAME:Mag_E1", _
"SolutionName:=",

"Setup1 : LastAdaptive", _

"QuantityName:=", "Mag_E", _
"PlotFolder:=", "E Field1", _
"UserSpecifyName:=",

0, _

"UserSpecifyFolder:=", 0, _
"IntrinsicVar:=", "Freq='1GHz' Phase='0deg'",_
"PlotGeomInfo:=", Array( 1, "Surface",_
"FacesList", 1, "7"),_
"FilterBoxes:=", Array(0),
Array("NAME:PlotOnSurfaceSettings", _
"Filled:=", false, _
"IsoValType:=", "Fringe", _
"SmoothShade:=", true, _
"AddGrid:=", false, _
"MapTransparency:=", true, _
"Transparency:=", 0, _
"ArrowUniform:=", true, _
"ArrowSpacing:=",

0.100000001490116, _

"GridColor:=", Array(255, 255, 255)))

DeleteFieldPlot
Use:

Deletes one or more plots.

Command:

HFSS>Fields>Delete Plot

Syntax:

DeleteFieldPlot <NameArray>

Return Value:

None

Parameters:

<NameArray>
Array of strings the names of the plots to delete.

Example:
oModule.DeleteFieldPlot Array("Mag_E1", "Vector_E1")

GetFieldPlotNames
Use:

Gets the names of field overlay plots defined in a design.

Syntax:

GetFieldPlotNames()

19-6 Field Overlays Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Return Value:

Array of field plot names.

Parameters:

None

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHFSS.HFSSScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject
Set oDesign = oProject.GetActiveDesign
Set oReportModule = oDesign.GetModule("ReportSetup")
Dim names
names = oReportModule.GetAllReportNames
For index = 0 to UBound(names)
MsgBox(names(index))
Next
Set oFieldReportModule = oDesign.GetModule("FieldsReporter")
Set collection = oFieldReportModule.GetFieldPlotNames
For index = 0 to collection.Count-1
MsgBox(collection.Item(index))
Next

ModifyFieldPlot
Use:

Modifies a plot definition.

Command:

HFSS>Fields>Modify Plot

Syntax:

ModifyFieldPlot <OriginalName> <PlotParameterArray>

Return Value:

None

Example:
oModule.ModifyFieldPlot "Vector_E1",_
Array("NAME:Vector_E2", _
"SolutionName:=",

"Setup1 : LastAdaptive", _
Field Overlays Module Script Commands 19-7

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"QuantityName:=", "Vector_E", _
"PlotFolder:=", "E Field1",

"UserSpecifyName:=", 0, _
"UserSpecifyFolder:=", 0, _
"IntrinsicVar:=","Freq='1GHz' Phase='30deg'", _
"PlotGeomInfo:=", Array(1,_
"Surface","FacesList", 1, "7"), _
"FilterBoxes:=", Array(0), _
Array("NAME:PlotOnSurfaceSettings", _
"Filled:=",

false, _

"IsoValType:=", "Fringe", _
"SmoothShade:=", true, _
"AddGrid:=", false, _
"MapTransparency:=",

true, _

"Transparency:=", 0, _
"ArrowUniform:=", true, _
"ArrowSpacing:=",

0.100000001490116, _

"GridColor:=", Array(255, 255, 255)))

RenameFieldPlot
Use:

Renames a plot.

Command:

Right-click the plot you want to rename in the project tree, and then click
Rename on the shortcut menu.

Syntax:

RenameFieldPlot <OldName> <NewName>

Return Value:

None

Parameters:

<OldName>
Type: <string>
Original name of the plot.
<NewName>
Type: <string>
New name of the plot.

Example:
oModule.RenameFieldPlot "Vector_E1", "Vector_E2"

19-8 Field Overlays Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

RenamePlotFolder
Use:

Renames a plot folder.

Command:

Right-click a plot folder in the project tree, and then click Rename on the
shortcut menu.

Syntax:

RenamePlotFolder <OldName> <NewName>

Return Value:

None

Parameters:

<OldName>
Type: <string>
Original name of the folder.
<NewName>
Type: <string>
New name of the folder.

Example:
oModule.RenamePlotFolder "E Field", "Surface Plots"

SetFieldPlotSettings
Use:

Sets plot attributes.

Command:

HFSS>Fields>Modify Plot Attributes, under the Plots tab.

Syntax:

SetFieldPlotSettings <PlotName> <PlotItemAttributes>

Return Value:

None

Parameters:

<PlotName>
Type: <string>
Name of the plot to modify.
<PlotItemAttributes>
Array("NAME:FieldsPlotItemSettings",
<PlotOnPointsSettings>,
<PlotOnLineSettings>,
<PlotOnSurfaceSettings>,
<PlotOnVolumeSettings>)
See description of CreateFieldPlot command for details.

Example:
oModule.SetFieldPlotSettings "Mag_E2", _
Array("NAME:FieldsPlotItemSettings", _
Field Overlays Module Script Commands 19-9
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array("NAME:PlotOnLineSettings", _
Array("NAME:LineSettingsID", _
"Width:=", 4,
"Style:=", "Cylinder"), _
"IsoValType:=", "Tone", _
"ArrowUniform:=", true, _
"NumofArrow:=",

100), _

Array("NAME:PlotOnSurfaceSettings", _
"Filled:=", false, _
"IsoValType:=", "Tone", _
"SmoothShade:=",

true, _

"AddGrid:=", false, _
"MapTransparency:=", true, _
"Transparency:=", 0, _
"ArrowUniform:=",

true, _

"ArrowSpacing:=", 0.100000001490116, _
"GridColor:=", Array(255, 255, 255)))

SetPlotFolderSettings
Use:

Sets the attributes of all plots in the specified folder.

Command:

HFSS>Fields>Modify Plot Attributes

Syntax:

SetPlotFolderSettings <PlotFolderName>
<PlotFolderAttributes>

Return Value:

None

Parameters:

<PlotFolderName>
Type: <string>
Name of the folder with the attributes to modify.
<PlotFolderAttributes>
Array("NAME:FieldsPlotSettings",
"Real time mode:=", <bool>,
<ColorMapSettings>,
<Scale3DSettings>,
<Marker3DSettings>,
<Arrow3DSettings>)

19-10 Field Overlays Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<ColorMapSettings>
Array("NAME:ColorMapSettings",
"ColorMapType:=", <string>,
"SpectrumType:=", <string>,
"UniformColor:=", Array(<int>, <int>, <int>),
"RampColor:=", Array(<int>, <int>, <int>)
ColorMapType
Possible values are "Uniform", "Ramp", "Spectrum"
SpectrumType
Possible values are "Rainbow", "Temperature", "Magenta", "Gray"
UniformColor, RampColor
Array containing the R, G, B components of the color. Components should be in the
range 0 to 255.
<Scale3DSettings>
Array("NAME:Scale3DSettings",
"m_nLevels:=",

<int>,

"m_autoScale:=", <bool>,
"minvalue:=", <double>,
"maxvalue:=",

<double>,

"log:=", <bool>,
"IntrinsicMin:=", <double>,
"IntrinsicMax:=",

<double>)

<Marker3DSettings>
Array("NAME:Marker3DSettings",
"MarkerType:=", <int>,
"MarkerMapSize:=",

<bool>,

"MarkerMapColor:=", <bool>,
"MarkerSize:=", <double>)

Field Overlays Module Script Commands 19-11


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

MarkerType
9: Sphere
10: Box
11: Tetrahedron
12: Octahedron
default: Sphere
<Arrow3DSettings>
Array("NAME:Arrow3DSettings",
"ArrowType:=",

<int>,

"ArrowMapSize:=", <bool>,
"ArrowMapColor:=", <bool>,
"ShowArrowTail:=", <bool>,
"ArrowSize:=",

<double>)

ArrowType
0: Line
1: Cylinder
2: Umbrella
default: Line
Example:
oModule. SetPlotFolderSettings "E Field1", _
Array("NAME:FieldsPlotSettings", _
"Real time mode:=",

true,

Array("NAME:ColorMapSettings", _
"ColorMapType:=", "Spectrum", _
"SpectrumType:=", "Rainbow", _
"UniformColor:=", Array(127, 255, 255), _
"RampColor:=", Array(255,

127, 127)), _

Array("NAME:Scale3DSettings", _
"m_nLevels:=",

27, _

"m_autoScale:=", true, _
"minvalue:=", 9.34379863739014, _
"maxvalue:=",

13683.755859375, _

"log:=", false, _
19-12 Field Overlays Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"IntrinsicMin:=", 9.34379863739014, _
"IntrinsicMax:=",

13683.755859375), _

Array("NAME:Marker3DSettings", _
"MarkerType:=", 0, _
"MarkerMapSize:=",

true, _

"MarkerMapColor:=", false, _
"MarkerSize:=", 0.25), _
Array("NAME:Arrow3DSettings", _
"ArrowType:=",

1, _

"ArrowMapSize:=", true, _
"ArrowMapColor:=", true, _
"ShowArrowTail:=", true, _
"ArrowSize:=",

0.25))

Field Overlays Module Script Commands 19-13


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

19-14 Field Overlays Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

20

Fields Calculator Script


Commands

Fields Calculator commands should be executed by the Field Overlays module, which is called "FieldsReporter" in HFSS scripts.
Set oModule = oDesign.GetModule("FieldsReporter")
oModule.CommandName <args>
The command associated with each of the following scripting commands will
be a button pressed in the Fields Calculator.
AddNamedExpression
AddNamedExpr
CalcOp
CalculatorRead
CalcStack
CalculatorWrite
ChangeGeomSettings
ClcEval
ClcMaterial
ClearAllNamedExpr
CopyNamedExprToStack
DeleteNamedExpr
EnterComplex
EnterComplexVector
EnterLine
EnterPoint
Fields Calculator Script Commands 20-1
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

EnterQty
EnterScalar
EnterScalarFunc
EnterSurf
EnterVector
EnterVectorFunc
EnterVol
ExportOnGrid
ExportToFile
GetTopEntryValue
LoadNamedExpressions
SaveNamedExpressions

20-2 Fields Calculator Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

AddNamedExpression
Use:

Creates a named expression using the expression at the top of the stack.

Command:

Click Add.

Syntax:

AddNamedExpression <Name>

Return Value:

None

Parameters:

<ExpressionName> and <FieldType>.


Type: <string>
Name for the new named expression.
<FieldType>
Type: <string>

Example:
oModule.AddNamedExpression "Mag_JxE", "Fields"

AddNamedExpr
Use:

Creates a named expression using the expression at the top of the stack.

Command:

Click Add.

Syntax:

AddNamedExpr <Name>

Return Value:

None

Parameters:

<ExpressionName>
Type: <string>
Name for the new named expression.
<FieldType>
Type: <string>

Example:
oModule.AddNamedExpr "Mag_JxE", "Fields"

CalcOp
Use:

Performs a calculator operation.

Command:

Operation commands like Mag, +, etc.

Syntax:

CalcOp <OperationString>

Return Value:

None

Parameters:

<OperationString>
Type: String
The text on the corresponding calculator button.
Examples: Mag, +
Fields Calculator Script Commands 20-3

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

CalculatorRead
Use:

Gets a register file and applies it to the calculator stack.

Command:

Click Read

Syntax:

CalculatorRead <InputFilePath>, <SolutionName>,


<FieldType>, <VariablesArray>

Return Value:

None

Parameters:

<InputFilePath>
Path to and including name of input register file.
<SolutionName>
Type: <string>
Example: "Setup1 : LastAdaptive"
<FieldType>
Type: <string>
<VariablesArray>
Array of variable names, value pairs.

Example:
oModule.CalculatorRead "c:\test.reg", _
"Setup1 : LastAdaptive", "Fields", _
Array("Freq:=", "1GHz", "Phase:=", "0deg")

CalcStack
Use:

Performs an operation on the stack.

Command:

Stack operation buttons such as Push and Pop.

Syntax:

CalcStack <OperationString>

Return Value:

None

Parameters:

<Operation String>
Type: <string>
The text on the corresponding calculator button.

Example:
oModule.CalcStack "push"

20-4 Fields Calculator Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

CalculatorWrite
Use:

Writes contents of top register to file.

Command:

Click Write

Syntax:

CalculatorWrite <OutputFilePath>, <SolutionNameArray>,


<VariablesArray>

Return Value:

None

Parameters:

<OutputFilePath>
Path to and including name of output register file.
<SolutionNameArray>
Array("Solution:=", <string>)
<VariablesArray>
Array of variable names, value pairs.

Example:
oModule.CalculatorWrite "c:\test.reg", _
Array("Solution:=", "Setup1 : LastAdaptive"), _
Array("Freq:=", "1GHz", "Phase:=", "0deg")

ChangeGeomSettings
Use:

Changes the line discretization setting.

Command:

Geom Settings

Syntax:

ChangeGeomSettings <int>

Return Value:

None

Parameters:

The line discretization setting.

ClcEval
Use:

Evaluates the expression at the top of the stack using the provided solution
name and variable values.

Command:

Click Eval.

Syntax:

ClcEval <SolutionName> <VariablesArray>

Return Value:

None

Parameters:

<SolutionName>
Type: <string>

Fields Calculator Script Commands 20-5


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

<VariablesArray>
Array of variable name, value pairs.
Example:
oModule.ClcEval "Setup1: LastAdaptive", _
Array ("Freq:=", "10GHz",_
"Phase:=", "0deg")

ClcMaterial
Use:

Performs a material operation on the top stack element.

Command:

Click Matl.

Syntax:

ClcMaterial <MaterialString>, <OperationString>

Return Value:

None

Parameters:

<Material String>
Type: <string>
The material property to apply.
<OperationString>
Type: <string>
Possible values are "mult", or "div".

Example:
oModule.ClcMaterial "Permeability (mu)" "mult"

ClearAllNamedExpr
Use:

Clears all user-defined named expressions from the list.

Command:

Click ClearAll.

Syntax:

ClearAllNamedExpr

Return Value:

None

Parameters:

None

CopyNamedExprToStack
Use:

Copies the named expression selected to the calculator stack.

Command:

Select a named expression and then click Copy to stack.

Syntax:

CopyNamedExprToStack <Name>

Return Value:

None

20-6 Fields Calculator Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Parameters:

<Name>
Type: <string>
The name of the expression to be copied to the top of the stack.

Example:
oModule.CopyNamedExprToStack "Mag_JxE"

DeleteNamedExpr
Use:

Deletes the selected named expression from the list.

Command:

Select a named expression and then click Delete.

Syntax:

DeleteNamedExpr <Name>

Return Value:

None

Parameters:

<Name>
Type: <string>
The name of the named expression to be deleted.

Example:
oModule.DeleteNamedExpr "Mag_JxE"

EnterComplex
Use:

Enters a complex number onto the stack.

Command:

Click Number, and then click Scalar. Complex option is selected.

Syntax:

EnterComplex "<Real> + <Imaginary> j"

Return Value:

None

Parameters:

<Real>
Type: <double>
Real component of the scalar.
<Imaginary>
Type: <double>
Imaginary component of the scalar.

Example:
oModule.EnterComplex "1 + 2 j"

EnterComplexVector
Use:

Enters a complex vector onto the stack.


Fields Calculator Script Commands 20-7
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Command:

Click Number, and then click Vector. Complex option is selected.

Syntax:

EnterComplexVector Array ("<X Re> + <X Im> j",


"<Y Re> + <Y Im> j", "<Z Re> + <Z Im> j")

Return Value:

None

Parameters:

<X Re>, <YRe>, <ZRe>


Type: <double>
Real components of the X, Y, and Z values respectively.
<X Im>, <YIm>, <ZIm>
Type: <double>
Imaginary components of the X, Y, and Z values respectively.

Example:
oModule.EnterComplexVector Array("1 + 2 j",_
"1 + 2 j",_
"1 + 2 j")

EnterLine
Use:

Enters a line defined in the 3D Modeler editor.

Command:

Click Geometry and then select Line.

Syntax:

EnterLine <LineName>

Return Value:

None

Parameters:

<LineName>
Type: <string>
Name of a line defined in the 3D Modeler editor.

Example:
oModule.EnterLine "Line1"

EnterPoint
Use:

Enters a point defined in the 3D Modeler editor.

Command:

Click Geometry and then select Point.

Syntax:

EnterPoint <PointName>

Return Value:

None

Parameters:

<PointName>
Type: <string>
Name of a point defined in the 3D Modeler editor.

20-8 Fields Calculator Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Example:
oModule.EnterPoint "Point1"

EnterQty
Use:

Enters a field quantity.

Command:

Click Quantity, and then select from the list.

Syntax:

EnterQty <FieldQuantityString>

Return Value:

None

Parameters:

<Field Quantity String>


Type: <string>
The field quantity to be entered onto the stack.

Example:
oModule.EnterQty "E"

EnterScalar
Use:

Enters a scalar onto the stack.

Command:

Click Number and then click Scalar. Complex option not selected.

Syntax:

EnterScalar <Scalar>

Return Value:

None

Parameters:

<Scalar>
Type: <double>
The real number to enter onto the stack.

EnterScalarFunc
Use:

Enters a scalar function.

Command:

Click Function and then select Scalar.

Syntax:

EnterScalarFunc <VarName>

Return Value:

None

Parameters:

<VarName>
Type: <string>
Name of a variable to enter as a scalar function onto the stack.

Example:
oModule.EnterScalarFunc "Phase"

Fields Calculator Script Commands 20-9


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

EnterSurf
Use:

Enters a surface defined in the 3D Modeler editor.

Command:

Click Geometry and then select Surface.

Syntax:

EnterSurf <SurfaceName>

Return Value:

None

Parameters:

<SurfaceName>
Type: <string>
Name of a surface defined in the 3D Modeler editor.

Example:
oModule.EnterSurf "Rectangle1"

EnterVector
Use:

Enters a vector onto the stack.

Command:

Click Number, and then click Vector. Complex option not selected.

Syntax:

EnterVector Array (<X>, <Y>, <Z>)

Return Value:

None

Parameters:

<X>
Type: <double>
X component of the vector.
<Y>
Type: <double>
Y component of the vector.
<Z>
Type: <double>
Z component of the vector.

Example:
oModule.EnterVector Array (1.0, 1.0, 1.0)

EnterVectorFunc
Use:

Enters a vector function.

Command:

Click Function and then select Vector.

Syntax:

EnterVectorFunc Array(<XVarName>, <YVarName>,


<ZVarName>)

20-10 Fields Calculator Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Return Value:

None

Parameters:

<XVarName>, <YVarName>, <ZVarName>


Type: <string>
Name of a variable for the X, Y, and Z coordinates, respectively, to enter as a vector
function on the stack.

Example:
oModuleEnterVectorFunc Array("X", "Y", "Z")

EnterVol
Use:

Enters a volume defined in the 3D Modeler editor.

Command:

Click Geometry and then select Volume.

Syntax:

EnterVol <VolumeName>

Return Value:

None

Parameters:

<VolumeName>
Type: <string>
Name of a volume defined in the 3D Modeler editor.

Example:
oModule.EnterVol "Box1"

ExportOnGrid
Use:

Evaluates the top stack element at a set of points specified by a grid and
exports the data to a file.

Command:

Click Export, and then click On Grid.

Syntax:

ExportOnGrid <OutputFile> <MinArray> <MaxArray>


<SpacingsArray>, <setup>, <Boolean>, <coordinate system>
[<CS Offset Array>]

Return Value:

None

Parameters:

<OutputFile>
Type: <string>
Name of the output file.
<MinArray>, <MaxArray>, <SpacingsArray>
Type: Array<double, double, double>
Min, Max, and Spacing for the coordinate components of the grid system, Cartesian
(default), Cylindrical or Spherical.
<setup>
Type: <string>
Fields Calculator Script Commands 20-11

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Name of the simulation setup


<Setup Array>
Type: Array(Freq:=,<ValueUnits>, Phase:=,<ValueDeg>),
Freq
<Boolean>
Type: True, False
Whether a non-default coordinate system is specified
<Coordinate sytem>
Type: <string>,
[Cartesian (default)| Cylindrical | Spherical]
<CS Offset Array>
Type: Array<double, double, double>
Origin for the offset coordinate system.
Example:
oModule.ExportOnGrid "J:\TestSuite\EdgeLossDensity\aaa.fld",
Array( "0mm", "0deg", "-25mm"),
Array("20mm", "90deg", "125mm"),
Array("10mm", "45deg", "50mm"),
"Setup1 : LastAdaptive",
Array("Freq:=", "10000Hz", "Phase:=", "0deg"),
true, "Cylindrical",
Array("0mm", "0mm", "0mm")

ExportToFile
Use:

Evaluates the top stack element at a set of points specified in an external


file and exports the data to a file.

Command:

Click Export, and then click To File.

Syntax:

ExportToFile <OutputFile> <PtsFile>

Return Value:

None

Parameters:

<OutputFile>
Type: <string>
Name of the output file.
<PtsFile>
Type: <string>

20-12 Fields Calculator Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Name of the file containing the points at which to evaluate the top stack element. The
file should contain tab- or space-separated x,y,z values of data points.

GetTopEntryValue
Use:

Gets the value of the top entry of the calculator stack.

Syntax:

GetTopEntryValue(<SolutionName>, <VariablesArray>)

Return Value:

Returns an array of variants, which is either a scalar (one double) or a


vector (3 doubles) based on the quantity on top of the stack.

Parameters:

<SolutionName>
Type: <string>
Example: "Setup1: LastAdaptive"
<VariablesArray>
Array of variable name, value pairs.

Example:
dim topvalue
topvalue = _
oModule.GetTopEntryValue("Setup1:LastAdaptive", _
Array("Freq:=", "1GHz", "Phase:=", "0deg", _
"x_size:=", "2mm"))
If cdbl(topvalue(0)) <- 180.0 then ...

LoadNamedExpressions
Use:

Loads a named expression definition from a saved file.

Command:

In the Fields Calculator, click Load From... in the Library area.

Syntax:

LoadNamedExpressions <FileName>, <FieldType>,


<NamedExpressions>

Return Value:

None

Parameters:

<FileName>
Type:<String>
Filename and full path to the file to hold the named expression definition.
<FieldType>
Type:<String>
For products with just one filed type, it is set to "Fields".
<NamedExpressions>
Fields Calculator Script Commands 20-13

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Type: Array<string, string,...>


Array of strings containing the names of expression definitions to load from the file.
Example:
oModule.LoadNamedExpressions "C:\Ansoft\PersonalLib\smth.clc", "Fields", Array("smoothedtemp")

SaveNamedExpressions
Use:

Saves a named expression definition to a file.

Command:

In the Fields Calculator, click Save To... in the Library area.

Syntax:

SaveNamedExpressions <FileName>, <NamedExpressions>,


<BooleanFlag>

Return Value:

None

Parameters:

<FileName>
Type:<String>
Filename and full path to the file to hold the named expression definition.
<NamedExpressions>
Type: Array<string, string,...>
Array of strings containing the names of expression definitions to load from the file.
<BooleanFlag>
Type:<Boolean>
True: Overwrite the file.
False: Append to the file.

Example:
oModule.SaveNamedExpressions "C:\Ansoft\PersonalLib\smth.clc", Array("smoothedtemp"), true

20-14 Fields Calculator Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

21

Radiation Module Script


Commands

Radiation field commands should be executed by the "RadField" module.


Set oModule = oDesign.GetModule("RadField")
oModule.CommandName <args>
Note: HFSS-IE does not support Radiation module commands.
Conventions Used in this Chapter
<SetupName>
Type: <string>
Name of a radiation setup.
<FaceListName>
Type: <string>
Name of a qualifying face list. Used for specifying custom radiation surfaces. In order
to be valid for use in a radiation surface, the face list should not contain any faces on
PML objects and should contain only model faces.
<CSName>
Type: string
Name of a coordinate system.
General Commands Recognized by the Radiation Module
Script Commands for Creating and Modifying Radiation Setups
Script Commands for Modifying Antenna Array Setups
Radiation Module Script Commands 21-1
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Script Commands for Exporting Antenna Parameters and Max Field Parameters

General Commands Recognized by the Radiation Module


DeleteFarFieldSetup
DeleteNearFieldSetup
GetSetupNames
RenameSetup

DeleteFarFieldSetup
Use:

Deletes an existing far-field setup.

Command:

Delete command in the List dialog box. Click HFSS>List to access the List
dialog box.

Syntax:

DeleteFarFieldSetup <NameArray>

Return Value:

None

Parameters:

<NameArray>
Type: Array of strings.
An array of radiation setup names.

Example:
oModule.DeleteFarFieldSetup Array("Infinite Sphere1")

DeleteNearFieldSetup
Use:

Deletes an existing near-field setup (line and sphere).

Command:

Delete command in the List dialog box. Click HFSS>List to access the List
dialog box.

Syntax:

DeleteNearFieldSetup <NameArray>

Return Value:

None

Parameters:

<NameArray>
Type: Array of strings.
An array of radiation setup names.

Example:
oModule.DeleteNearFieldSetup Array("Line1", "Sphere1")

GetSetupNames
Use:

Gets the names of far field and near field radiation setups in a design.

Syntax:

GetSetupNames(<RadiationType>)

21-2 Radiation Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Return Value:

Array of setup names.

Parameters:

<RadiationType>
Type: <string>
For example: "Sphere"

Example:
Set setupnames = oModule.GetSetupNames("Infinite Sphere")
For Each setup in setupnames
Msgbox setup
Next

RenameSetup [Radiation]
Use:

Renames an existing radiation setup.

Command:

Right-click a radiation setup in the project tree, and then click Rename on
the shortcut menu.

Syntax:

RenameSetup <OldName>, <NewName>

Return Value:

None

Parameters:

<OldName>
Type: <string>
<NewName>
Type: <string>

Example:
oModule.RenameSetup "Sphere1", "MyNearSphere"

Radiation Module Script Commands 21-3


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Script Commands for Creating and Modifying Radiation Setups


EditFarFieldSphereSetup
EditNearFieldLineSetup
EditNearFieldSphereSetup
InsertFarFieldSphereSetup
InsertNearFieldLineSetup
InsertNearFieldSphereSetup

EditFarFieldSphereSetup
Use:

Modifies an existing far-field infinite sphere setup.

Command:

Double-click a radiation setup in the project tree to modify its settings.

Syntax:

EditFarFieldSphereSetup <InfSphereParams>

Return Value:

None

Example:
oModule.EditFarFieldSphereSetup Array("NAME:InfSphere",_
"UseCustomRadiationSurface:=", true, _
"CustomRadiationSurface:=", "FaceList1", _
"ThetaStart:=", "0deg", _
"ThetaStop:=", "180deg", _
"ThetaStep:=", "10deg", _
"PhiStart:=", "15deg", _
"PhiStop:=", "36deg", _
"PhiStep:=", "10deg", _
"UseLocalCS:=", false)

EditNearFieldLineSetup
Use:

Modifies an existing near-field line setup.

Command:

Double-click the radiation setup in the project tree to modify its settings.

Syntax:

EditNearFieldLineSetup <LineParams>

Return Value:

None

Example:
oModule.EditNearFieldLineSetup Array("NAME:MyLine", _
"UseCustomRadiationSurface:=", false, _
"Line:=", "Polyline2", _
21-4 Radiation Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"NumPts:=", "100")

EditNearFieldSphereSetup
Use:

Modifies an existing near-field sphere setup.

Command:

Double-click a radiation setup in the project tree to modify its settings.

Syntax:

EditNearFieldSphereSetup <SphereParams>

Return Value:

None

Example:
oModule.EditNearFieldSphereSetup Array("NAME:MySphere", _
"UseCustomRadiationSurface:=", true, _
"CustomRadiationSurface:=", "FaceList1", _
"Radius:=", "35mm", _
"ThetaStart:=", "0deg", "ThetaStop:=", "180deg", _
"ThetaStep:=", "10deg", "PhiStart:=", "15deg", _
"PhiStop:=", "36deg", "PhiStep:=", "10deg", _
"UseLocalCS:=", false)
Example:

Partial values can be specified, in which case default values will be used to
populate the rest of the fields:
oModule.EditNearFieldSphereSetup "NAME:MyInfSphere", _
Array("NAME:MySphere", _
"UseCustomRadiationSurface:=", true, _
"CustomRadiationSurface:=", "FaceList1", _
"Radius:=", "45mm")
This will cause default values to be used for the rest of the fields such as
ThetaStop, ThetaStart, ThetaStep, PhiStep, PhiStart, and
PhiStop;however, the value for the key CustomRadiationSurface has
to be specified if custom radiation surfaces are used.

InsertFarFieldSphereSetup
Use:

Creates/inserts a far-field infinite sphere radiation setup.

Command:

HFSS>Radiation>Insert Far Field Setup>Infinite Sphere

Syntax:

InsertFarFieldSphereSetup <InfSphereParams>

Return Value:

None

Parameters:

<InfSphereParams>
Radiation Module Script Commands 21-5

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array("NAME:<SetupName>",
"UseCustomRadiationSurface:=", <bool>,
"CustomRadiationSurface:=", <FaceListName>,
"ThetaStart:=", <value>,
"ThetaStop:=", <value>,
"ThetaStep:=", <value>,
"PhiStart:=", <value>,
"PhiStop:=", <value>,
"PhiStep:=", <value>,
"UseLocalCS:=", <bool>,
"CoordSystem:=", <CSName>)
UseCustomRadiationSurface
If true, provide CustomRadiationSurface parameter.
If false, radiation boundary/PML boundaries will be used as radiation surfaces.
UseLocalCS
If true, provide CoordSystem parameter.
If false, global coordinate system will be used.
Example:
oModule.InsertFarFieldSphereSetup
Array("NAME:InfiniteSphere1",_
"UseCustomRadiationSurface:=", false, _
"ThetaStart:=", "0deg",_
"ThetaStop:=", "180deg",_
"ThetaStep:=", "10deg",_
"PhiStart:=", "0deg",_
"PhiStop:=", "36deg",_
"PhiStep:=", "10deg",_
"UseLocalCS:=", true,_
"CoordSystem:=", "RelativeCS1")

InsertNearFieldLineSetup
Use:

Inserts a near-field line setup. Requires the presence of lines in the model.

Command:

HFSS>Radiation>Insert Near Field Setup>Sphere

21-6 Radiation Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Syntax:

InsertNearFieldLineSetup <LineParams>

Return Value:

None

Parameters:

<LineParams>
Array("NAME:<SetupName>",
"UseCustomRadiationSurface:=", <bool>,
"CustomRadiationSurface:=", <FaceListName>,
"Line:=", <PolyLineName>,
"NumPts:=", <int>)
<PolyLineName>
Type: String.
Name of the polyline as determined by name in the history tree.
UseCustomRadiationSurface
If true, provide CustomRadiationSurface parameter.
If false, radiation boundary/PML boundaries will be used as radiation surfaces.

Example:
oModule.InsertNearFieldLineSetup Array("NAME:MyLine", _
"UseCustomRadiationSurface:=", false, _
"Line:=", "Polyline1", _
"NumPts:=", "100")

InsertNearFieldSphereSetup
Use:

Creates/inserts a near-field sphere radiation setup.

Command:

HFSS>Radiation>Insert Near Field Setup>Sphere

Syntax:

InsertNearFieldSphereSetup <SphereParams>

Return Value:

None

Parameters:

<SphereParams>
Array("NAME:<SetupName>",
"UseCustomRadiationSurface:=", <bool>,
"CustomRadiationSurface:=", <FaceListName>,
"Radius:=", <value>,
"ThetaStart:=", <value>,
"ThetaStop:=", <value>,
"ThetaStep:=", <value>,
Radiation Module Script Commands 21-7

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"PhiStart:=", <value>,
"PhiStop:=", <value>,
"PhiStep:=", <value>,
"UseLocalCS:=", <bool>,
"CoordSystem:=", <CSName>)
UseCustomRadiationSurface
If true, provide CustomRadiationSurface parameter.
If false, radiation boundary/PML boundaries will be used as radiation surfaces.
UseLocalCS
If true, provide CoordSystem parameter.
If false, global coordinate system will be used.
Example:
oModule.InsertNearFieldSphereSetup _
Array("NAME:MySphere", _
"UseCustomRadiationSurface:=", true, _
"CustomRadiationSurface:=", "FaceList1", _
"ThetaStart:=", "0deg", "ThetaStop:=", "180deg", _
"ThetaStep:=", "10deg", "PhiStart:=", "0deg", _
"PhiStop:=", "360deg", "PhiStep:=", "10deg", _
"UseLocalCS:=", true, _
"CoordSystem:=", "FaceCS1")

Script Commands for Modifying Antenna Array Setups


EditAntennaArratSetup

EditAntennaArraySetup
Use:

Modifies the antenna array setup. There are 3 choices in the setup. The
default is set to No Array Setup. There are two (other) kinds of arrays that
the user can set: Regular Array Setup and Custom Array Setup.

Command:

HFSS>Radiation>Antenna Array Setup

Syntax:

EditAntennaArraySetup <AntennaArrayParams>

Return Value:

None

Parameters:

<AntennaArrayParams>
Array("NAME:ArraySetupInfo",

21-8 Radiation Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"UseOption:=", <ArrayOption>,
<RegularArrayParams>,
<CustomArrayParams>)
<ArrayOption>
Type: <string>
Can be one of three strings: "NoArray", or "RegularArray",
"CustomArray".
If "RegularArray" is specified, then <RegularArrayParams> must
be specified. If "CustomArray" is specified, <CustomArrayParams>
must be specified. You can also supply both the custom and regular
array specifications and switch between them by setting this flag to the
option you want to use.
<RegularArrayParams>
Array("NAME:RegularArray",
"NumUCells:=", <value>,
"NumVCells:=", <value>,
"CellUDist:=", <value>,
"CellVDist:=", <value>,
"UDirnX:=", <value>,
"UDirnY:=", <value>,
"UDirnZ:=", <value>,
"VDirnX:=", <value>,
"VDirnY:=", <value>,
"VDirnZ:=", <value>,
"FirstCellPosX:=", <value>,
"FirstCellPosY:=", <value>,
"FirstCellPosZ:=", <value>,
"UseScanAngle:=", <bool>,
"ScanAnglePhi:=", <value>,
"ScanAngleTheta:=", <value>,
"UDirnPhaseShift:=", <value>,
"VDirnPhaseShift:=", <value>)

Radiation Module Script Commands 21-9


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

UseScanAngle
If true, the values of the ScanAnglePhi and ScanAngleTheta
parameters will be used and need to be specified.
If false, the values of the UDirnPhaseShift and VDirnPhaseShift
parameters will be used and must be specified.
<CustomArrayParams>
Array("NAME:CustomArray",
"NumCells:=", <int>,
<CellsParamsArray
<CellsParamsArray>
Array("NAME:Cell",
<CellParams>, <CellParams>, ...)
<CellParams>
Array("Name:<CellName>",
"XCoord:=", <double>,
"YCoord:=", <double>,
"ZCoord:=", <double>,
"Amplitude:=", <double>,
"Phase:=", <double>)
The <double> values above should be in SI units.
<CellName>
Type: <string>
Format is: "Cell_n"
Replace n with the index number of the cell, for example: "Cell_1"
Example:

Using the "NoArray" option:


oModule.EditAntennaArraySetup _
Array("NAME:ArraySetupInfo", "UseOption:=", "NoArray")

Example:

Using the "RegularArray" option:


oModule.EditAntennaArraySetup _
Array("NAME:ArraySetupInfo",_
"UseOption:=", "RegularArray", _

21-10 Radiation Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array("NAME:RegularArray", _
"NumUCells:=", "10", "NumVCells:=", "10",_
"CellUDist:=", "10mm", "CellVDist:=", "10mm", _
"UDirnX:=", "1", "UDirnY:=", "0", "UDirnZ:=", _
"0", _
"VDirnX:=", "0", "VDirnY:=", "1", "VDirnZ:=",_
"0", _
"FirstCellPosX:=", "0mm", _
"FirstCellPosY:=", "0mm", _
"FirstCellPosZ:=", "0mm",
"UseScanAngle:=", true, _
"ScanAnglePhi:=","45deg", _
"ScanAngleTheta:=", "45deg"))
Example:

Using the "CustomArray" option:


oModule.EditAntennaArraySetup _
Array("NAME:ArraySetupInfo",
"UseOption:=", "CustomArray",_
Array("NAME:CustomArray", _
"NumCells:=", 3,_
Array("NAME:Cell", _
Array("NAME:Cell_1", _
"XCoord:=", 0, "YCoord:=", 0, "ZCoord:=",0,_
"Amplitude:=", 1, "Phase:=", 0), _
Array("NAME:Cell_2", _
"XCoord:=",0.06729,"YCoord:=","ZCoord:=",0,_
"Amplitude:=", 1, "Phase:=", 0), _
Array("NAME:Cell_3", _
"XCoord:=",0.13458,"YCoord:=",0,"ZCoord:=",0,_
"Amplitude:=", 1, "Phase:=", 0))))

Radiation Module Script Commands 21-11


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Script Commands for Exporting Antenna Parameters and Max Field


Parameters
ExportRadiationParametersToFile

ExportRadiationParametersToFile
Use:

Exports radiation parameters to a file. This command can be used to export


the max quantities of a near-field setup and, in the case of far fields, the
antenna parameters to the specified file.

Command:

HFSS>Radiation>Compute Max/Antenna Params

Syntax:

ExportRadiationParametersToFile <ExportToFileParams>

Return Value:

None

Parameters:

<ExportToFileParams>
Array("ExportFileName:=", <FilePath>
"SetupName:=", <SetupName>
"IntrinsicVariationKey:=", <string>,
"DesignVariationKey:=", <string>,
"SolutionName:=", <string>)
<FilePath>
Type: String.
Specifies the file to export to, for example: "C:\projects\exportantparams.txt".
IntrinsicVariationKey
Specifies the frequency at which to extract the parameters. Example:
"Freq='10GHz'"
DesignVariationKey
Specifies the design variations at which to extract the parameters. Example:
"width=5mm"

Example:
oModule.ExportRadiationParametersToFile _
Array("ExportFileName:=", _
"C:\projects\exportantparams.txt",_
"SetupName:=", "Infinite Sphere1", _
"IntrinsicVariationKey:=", "Freq='10GHz'", _
"DesignVariationKey:=", "",
21-12 Radiation Module Script Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

"SolutionName:=", "LastAdaptive")

Radiation Module Script Commands 21-13


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

21-14 Radiation Module Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

22

User Defined Solutions


Commands

User Defined Solution commands should be executed by the "UserDefinedSolutionModule" module.


Set oDesign = oProject.SetActiveDesign("TestDesign1")
Set oModule =
oDesign.GetModule("UserDefinedSolutionModule")
CreateUserDefinedSolution
DeleteUserDefinedSolutions
EditUserDefinedSolution

User Defined Solutions Commands 22-1


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

CreateUserDefinedSolution
Use:

Creates a new user defined solution.

Command:

Create User Defined Solution popup menu is available in the Result folder
context menu when applicable.

Syntax:

CreateUserDefinedSolution <SolutionName>,
<PluginFileLocation>, <PluginFileRelativePathName>,
<PropertyValuesArray>, <ProbeSelectionArray>,
<DynamicProbesArray>

Return Value:

The name of the user defined solution that was created. Note: if the
requested user defined solution name is not available because it is already
in use, the user defined solution will be created with a different name
which will be returned.

Parameters:

<SolutionName>
Type: String
Requested name of new user defined solution.
<PluginFileLocation>
Type: String
Indicates the library where the UDS plugin file is located. This parameter must be one
of the following values: "SysLib", "UserLib", "PersonalLib".
<PluginFileRelativePathName>
Type: String
The path of the UDS plugin file relative to the "UserDefinedOutputs"subdirectory of
the library specified by <PluginFileLocation>.
<PropertyValuesArray>
Type: Array of strings
Strings specify name-value pairs corresponding to the UDS properties specified in the
plugin file.
For example:

Array("multiply_factor:=", "2.0", "component_name:=", "resistor1")


<ProbeSelectionArray>
Type: Array of <ProbeSelection>'s (see below)
The probe specification array specifies how UDS probes are defined and mapped to
traces in the design.
<ProbeSelection>
22-2 User Defined Solutions Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Type: Array of strings representing how a single probe is defined by a trace. The
array contains the below items:
<ReportType>
Type: String
See the CreateReport command for more information.
<ProbeName>
Type: String
Name of the probe being specified. Note: this must match a probe name specified in
the UDS plugin file.
<SolutionName>
Type: String
See the CreateReport command for more information.
<SimulatedValueContexArray>
Type: Array of strings
See the CreateReport command for more information.
<PointSetDefinitionArray>
Type: Array of values with optional overriding values and optional
variable values.
See the CreateReport command for more information.
<TraceExpressionArray>
Type: Array of strings and values.
This is similar to the TracesExpressionsArray used in the CreateReport command, but
there will only be a single component expression named "Probe Component." See the
CreateReport command for more information.
<ExtendedTraceInformationArray>
Type: Array of strings and values
See the CreateReport command for more information.
<DynamicProbesArray>
Type: Array of <ProbeSelection>'s, representing the probes that are used by dynamicprobes.
Example:
oModule.CreateUserDefinedSolution "User Defined Solution 1", _
"SysLib", "Example",
Array("multiplication_factor:=", "1.2"),
Array(Array("Modal Solution Data",
"Probe 1", "Setup1 : LastAdaptive",
Array(),
User Defined Solutions Commands 22-3
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array("Freq:=", Array( "All")),


Array("Probe Component:=", Array("dB(S(1,1))")), Array()),
Array( "Modal Solution Data", "Probe 2",
"Setup1 : LastAdaptive", Array(),
Array("Freq:=", Array( "All")),
Array("Probe Component:=", Array("mag(S(1,1))")), Array())),
Array(Array( "Modal Solution Data",
"Dynamic Probe 1", "Setup1 : LastAdaptive", Array(),
Array("Freq:=", Array( "All")),
Array("Probe Component:=", Array("Freq")), Array()))

DeleteUserDefinedSolutions
Use:

Deletes one or more user defined solutions

Command:

'Delete' button from the "User Defined Solutions" dialog.

Syntax:

DeleteUserDefinedSolutions <UserDefinedSolutionNames>

Return Value:

None

Parameters:
<UserDefinedSolutionNames>
Type: Array of strings
Name of User Defined Solutions to be deleted.
Example:

Example:

oModule.DeleteUserDefinedSolutions Array("Solution1", "Solution2")

EditUserDefinedSolution
Use:

Updates an existing user defined solution

Command:

Command: 'Edit' button in the User Defined Solutions dialog

Syntax:

Syntax: EditUserDefinedSolution <ExistingSolutionName>,


<NewSolutionName>, <PluginFileLocation>,
<PluginFileRelativePathName>, <PropertyValuesArray>,
<ProbeSelectionArray>, <DynamicProbesArray>

Return Value:

Return Value: the name of the user defined solution after being updated.
Note: if the requested user defined solution name is not available because
it is already in use, the user defined solution will be created with a different
name which will be returned.

Parameters:
<ExistingSolutionName>
Type: String
Name of the existing user defined solution
<NewSolutionName>
22-4 User Defined Solutions Commands
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Type: String
Requested name for the updated user defined solution.
<PluginFileLocation>
See CreateUserDefinedSolution for more information.
<PluginFileRelativePathName>
See CreateUserDefinedSolution for more information.
<PropertyValuesArray>
See CreateUserDefinedSolution for more information.
<ProbeSelectionArray>
See CreateUserDefinedSolution for more information.
<DynamicProbesArray>
See CreateUserDefinedSolution for more information.
Example:
oModule.EditUserDefinedSolution "User Defined Solution 1",

"User Defined Solution 2",


"SysLib", "Example", Array("multiplication_factor:=", "1.2"),
Array(Array("Modal Solution Data", "Probe 1",
"Setup1 : LastAdaptive", Array(),
Array("Freq:=", Array("All")),
Array("Probe Component:=", Array("dB(S(1,1))")), Array()),
Array( "Modal Solution Data", "Probe 2",
"Setup1 : LastAdaptive", Array(),
Array("Freq:=", Array( "All")),
Array("Probe Component:=", Array("mag(S(1,1))")), Array())),
Array(Array("Modal Solution Data",
"Dynamic Probe 1",
"Setup1 : LastAdaptive", Array(),
Array("Freq:=", Array("All")),
Array("Probe Component:=", Array("Freq")), Array()))

User Defined Solutions Commands 22-5


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

22-6 User Defined Solutions Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

23

NdExplorer Script
Commands

The definition manager controls the use of NdExplorer for HFSS scripts.
Set oProject = oDesktop.SetActiveProject("Project1")
Set oDefinitionManager = oProject.GetDefinitionManager()
The topics for this section include:
NdExplorer Manager Script Commands

NdExplorer Manager Script Commands


The NdExplorer manager provides access to scripting for NdExplorer in HFSS. The manager
object is accessed via the definition manager.
Set oDefinitionManager = oProject.GetDefinitionManager()
Set oNdExplorerManager = oDefinitionManager.GetManager("NdExplorer")

ExportFullWaveSpice [NdExplorer]

NdeExportFullWaveSpice
Use:

Export FullWaveSpice data in a format of your choice.

Command:

File > Export MacroModel > Broadband (SYZ, FWS.)

Syntax:

ExportFullWaveSpice
"DesignName", // Design name. Can be left blank, if loading solution from a file.
true/false,

// true - solution loaded from file, false- loaded from design

"Name",

// If loading from design this is the solution name, else this is the
// full path of the file from which the solution is loaded
NdExplorer Script Commands -1

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

"variation",

// Pick a particular variation. Leave blank if no variation.

Array("NAME:Frequencies"), // Optional; if none defined all frequencies are used


Array("NAME:SpiceData",
"SpiceType:=", "SSS",
tre", "SSS",

// Spice export options object


// SpiceType can be "PSpice", "HSpice", "Spec-

// "Simplorer", "TouchStone1.0", "TouchStone2.0"


"EnforcePassivity:=", false,

// Enforce Passivity true/false

"EnforceCausality:=", false,

// Enforce Causality true/false

"UseCommonGround:=", false, // Use common ground true/false


"FittingError:=", 0.5,

// Fitting error

"MaxPoles:=", 400,

// Maximum Order

"PassivityType:=", "ConvexOptimization", // Passivity Type can be "ConvexOptimization",


// "PassivityByPerturbation", or "IteratedFittingOfPV"
"ColumnFittingType:=", "Column", // Column FittingType can be "Column",
"Entry", "Matrix"
"SSFittingType:=", "TWA", // SS Fitting Type can be "TWA", "IterativeRational"
"RelativeErrorToleranc:=", false,

// Relative error tolerance true/false

"TouchstoneFormat:=", "MA",

// Touchstone Format "MA", "RI", "DB"

"TouchstoneUnits:=", "Hz",
"MHz"

// Touchstone Units "Hz", "KHz", "MHz",

"TouchStonePrecision:=", 8,

// Touchstone precision

"ExportDirectory:=", "C:/Examples/LNA/",

// Directory to export to

"ExportSpiceFileName:=", "Linckt_HBTest_2.sss", // Spice export file


"FullwaveSpiceFileName:=", "Linckt_HBTest.sss", // FWS file
"CreateNPortModel:=", true // Create a model based on the exported file true/false
)

ExportNetworkData [NdExplorer]

NdeExportNetworkData
Use:

Export the solution in a format of your choice (Citifile, Spreadsheet, Matlab)

Command:

File > Export SYZ Data

Syntax:

ExportNetworkData
"DesignName", // Design name. Can be left blank, if loading solution from a file.
true/false,

// true - solution loaded from file, false- loaded from design

"Name",

// If loading from design this is the solution name, else this is the

-2 NdExplorer Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

// full path of the file from which the solution is loaded


"ExportFile",
"variation",

// full path of file to export to


// Pick a particular variation. Leave blank if no variation

Array("NAME:Frequencies"), // optional, if none defined all frequencies are used


Array("NAME:Options",

// Export options object

"DataTypes:=", Array("S"),

// DataTypes can be "S", "Y","Z", "G", and "Z0",


// for S , Y, Z matrix, Gamma and Z0 (zero)

"DisplayFormat:=", "MA",

// DisplayFormat "MA", "RI", "DB"

"FileType:=", "",

// Export File Type


// 2 - Spreadsheet(*.tab)
// 3 - Touchstone(*.sNp)
// 4 - Citifile(*.cit)
// 6 - Neutral format(*.nmf)
// 7 - Matlab format(*.m)

"Renormalize:=", false,

// Renormalize true/false

"RefImpedance:=",50,

// Reference Impedance

"Precision:=", 8,

// Number of digits Precision

"CreateNPortModel:=", true // Create a model based on the exported file true/false


)

ExportNMFData [NdExplorer]

NdeExportNMFData
Use:

Export the solution in NMF format.

Command:

File > Export SYZ Data

Syntax:

ExportNMFData
"DesignName", // Design name. Can be left blank, if loading solution from a file.
true/false,

// true - solution loaded from file, false- loaded from design

"Name",

// If loading from design this is the solution name, else this is the
// full path of the file from which the solution is loaded

"ExportFile",

// full path of file to export to

Array("NAME:Frequencies"), // optional, if none defined all frequencies are used


Array("NAME:NMFOptions",
"DataTypes:=", Array("S"),

// Export NMF options object


// DataTypes can be "S", "Y","Z", "G", and "Z0",

// for S , Y, Z matrix, Gamma and Z0 (zero)


"DisplayFormat:=", "MA",

// DisplayFormat "MA", "RI", "DB"


NdExplorer Script Commands -3

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

"FileType:=", "",

// Export File Type


// 2 - Spreadsheet(*.tab)
// 3 - Touchstone(*.sNp)
// 4 - Citifile(*.cit)
// 6 - Neutral format(*.nmf)
// 7 - Matlab format(*.m)

"Renormalize:=", false,

// Renormalize true/false

"RefImpedance:=",50,

// Reference Impedance

"Precision:=", 8,

// Number of digits Precision

"Variables:=", ARRAY("FF", "cap", "Rs") // Array of variables


"Variations:=", ARRAY("", "", "") // Array of variations to export solutions for
Array("NAME:ConstantVars")
empty

// Array of variables that are constant, can be

Array("NAME: DependentVars")
empty

// Array of variables that are dependent, can be

"MatrixSize:=", 2,

// Matrix size, optional (used in nmf file header)

"CreateNPortModel:=", true // Create a model based on the exported file true/false


)

-4 NdExplorer Script Commands


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

23

Example Scripts

Variable Helix Script


HFSS Data Export Script

Example Scripts 23-1


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Variable Helix Script


Following is a sample HFSS script that creates a tapered helix. Tapering helices is not supported
from the HFSS interface. The script includes comment lines, which are preceded by an apostrophe ( ), that offer explanations for each subsequent line or lines.
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp

= CreateObject("AnsoftHfss.HfssScriptInterface")

Set oDesktop = oAnsoftApp.GetAppDesktop()


Set oProject = oDesktop.GetActiveProject()
Set oDesign = oProject.GetActiveDesign()
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
Declare the arrays and variables needed for building the polyline.

Dim points(), segments()


Dim NumPoints, R(2), P(2), PointsPerTurn, Turns, Units

Establish the constant Pi.


Pi = 4*Atn(1)
Retrieve the variable helix parameters from the user.
Start with the input for unit selection.

Units = InputBox("Select the units:"&Chr(13)& _


"(cm,mm,um,in,mil)", "Variable Helix","mil",50,50)

Check to make sure it is a valid unit.

Select Case Units


Case "m"
Units = ""
Case "cm"
23-2 Example Scripts
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Case "mm"
Case "um"
Case "in"
Case "mil"
Case Else
MsgBox("Invalid Units - defaults to m")
Units = ""
End Select

Obtain the other user-defined parameters.

Turns = InputBox("Select the number of turns (must be


integer):","Variable Helix", 2,50,50)
PointsPerTurn = InputBox("Select the points per turn:", _
"Variable Helix",16,50,50)
R(0) = InputBox("Select the initial Radius: ", _
"Variable Helix",10,50,50)
R(1) = InputBox("Select the final Radius: ", _
"Variable Helix",10,50,50)
P(0) = InputBox("Select the initial Pitch: ", _
"Variable Helix", 4,50,50)
P(1) = InputBox("Select the final Pitch: ", _
"Variable Helix", 4,50,50)
NumPoints = Turns*PointsPerTurn

Initialize the points and segments arrays.

Redim points(NumPoints+1)
Redim segments(NumPoints)
points(0) = "NAME:PolylinePoints"
segments(0) = "NAME:PolylineSegments"

Build the Point and Segment Arrays needed in the HFSS polyline call.

For n = 1 To (NumPoints+1)
Example Scripts 23-3
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Angle = (n-1)*2*Pi/PointsPerTurn
Radius = R(0) + ((n-1)/NumPoints)*(R(1)-R(0))
Pitch = P(0) + ((n-1)/NumPoints)*(P(1)-P(0))
Rise = (n-1)*Pitch/PointsPerTurn
XValue = cstr(Radius*cos(Angle)) & Units
YValue = cstr(Radius*sin(Angle)) & Units
ZValue = cstr(Rise) & Units
points(n) = Array("NAME:PLPoint", "X:=", XValue, "Y:=", _
YValue, "Z:=", ZValue)

Create the line segments between each of the pairs of points.

If n<=NumPoints Then
segments(n) = Array("NAME:PLSegment", "SegmentType:=", _
"Line", "StartIndex:=", (n-1), "NoOfPoints:=", 2)
End If
Next

Create the polyline.

oEditor.CreatePolyline _
Array("NAME:PolylineParameters", "IsPolylineCovered:=", true, _
"IsPolylineClosed:=", false, points, segments), _
Array("NAME:Attributes", "Name:=", "Line_Helix","Flags:=", _
"", "Color:=", "(132 132 193)", "Transparency:=",0.4, _
"PartCoordinateSystem:=", "Global", "MaterialName:=", _
"vacuum", "SolveInside:=", true)

Create the helix cross-section.

oEditor.CreateCircle _
Array("NAME:CircleParameters", "IsCovered:=", true, "XCenter:=",_
cstr(R(0))&Units, "YCenter:=", 0, "ZCenter:=", 0, "Radius:=", _
"1"&Units, "WhichAxis:=", "Y"), _
23-4 Example Scripts
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Array("NAME:Attributes", "Name:=", "Circle_Helix", "Flags:=", _


"", "Color:=", "(132 132 193)", "Transparency:=", 0.4, _
"PartCoordinateSystem:=", "Global", "MaterialName:=", "vacuum", _
"SolveInside:=", true)

Sweep the cross-section along the path.

oEditor.SweepAlongPath _
Array("NAME:Selections", "Selections:=", _
"Circle_Helix,Line_Helix"),
Array("NAME:PathSweepParameters", "DraftAngle:=", "0deg", _
"DraftType:=", "Round", "TwistAngle:=", "0deg")

Example Scripts 23-5


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

HFSS Data Export Script


Following is a simple script that demonstrates how to export data from HFSS and save it to a
file. The output data in the example script is in 3 columns. The first column is freq in GHz, the
second is the Real part of S11, and the third is the Img part of S11. It uses a tab-delimited format. The HFSS output is done using output variables.
The frequency sweep data must be entered correctly. If it is incorrect, the script will request a
freq point that does not exist and execution will stop.
The script includes comment lines, which are preceded by an apostrophe ( ), that offer explanations for each subsequent line or lines.
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp

= CreateObject("AnsoftHfss.HfssScriptInterface")

Set oDesktop = oAnsoftApp.GetAppDesktop()


set oProject = oDesktop.GetActiveProject
set oDesign =

oProject.GetActiveDesign()

Dim oFS,ofile,x,y,z,path,range,
Dim arr2,del_f,freq,cfreq,val,temp,stn,stw,i,line

Input the desired file name.

path = inputbox("Input the file name" &chr(13) & _


"Note: If you do not specify a path the file will " & _
"be placed in the script directory", _
"File","C:\hfss_export.txt",50,50)

If the user clicks Cancel, the path will be blank, in which case the script should just exit.
If path <>"" then

Create the file, open it for data entry, and output the column labels.

Set oFS = CreateObject("Scripting.FileSystemObject")


23-6 Example Scripts
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

Set ofile = oFS.CreateTextFile (path)


line = "Freq" & chr(9) & "RE(S11)" & chr(9) & "IMG(S11)"
ofile.WriteLine line

Input the needed freq, solution, and sweep data and clean it up.

msgbox("For the following input make sure it matches " & _


"the frequencies defined in your sweep")
range = inputbox("Input the range of frequencies in GHz " & _
"and number of points",_
"Frequency","8,12,10",50,50)

The following 2 lines define the 2 output variables.

oDesign.CreateOutputVariable "re_S", "re(S(port1,port1))"


oDesign.CreateOutputVariable "im_S", "im(S(port1,port1))"
arr = split (range, ",")
arr(0) = Trim(arr(0))
arr(1) = Trim(arr(1))
arr(2) = Trim(arr(2))
if cint(arr(2)) <> 1 then
del_f = (arr(1)-arr(0))/(arr(2)-1)
else
del_f = 0
end if
temp = InputBox("Input the Setup and Sweep number to use:"_
& chr(13) & "(e.g. input 1,2 for Setup1 and Sweep2)", _
"Solution Data","1,1",50,50)
arr2 = split(temp,",")
stn = arr2(0)
swn = arr2(1)
stn = Trim(stn)
swn = Trim(swn)

Loop through the freq points.

Example Scripts 23-7


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Introduction to Scripting in HFSS

for i=1 to arr(2) step 1


freq = arr(0) + (cint(i)-1)*del_f
x=freq
cfreq="Freq='" & freq & "Ghz'"

Get the values of the output variables for the desired freq.

val

= oDesign.GetOutputVariableValue("re_S","Setup" & _

stn & " :Sweep" & swn,cfreq, "")


y = val
val

= oDesign.GetOutputVariableValue("im_S","Setup" & _

stn & " : Sweep" & swn,cfreq, "")


z = val

Create the line of text to send to the file and write it to the file.

line = x & chr(9) & y & chr(9) & z


ofile.WriteLine line
Next

Delete the 2 output variables before finishing.

oDesign.DeleteOutputVariable "re_S"
oDesign.DeleteOutputVariable "im_S"

Close the file.

ofile.close
End if

23-8 Example Scripts


ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Index

Numbers
3D Modeler editor commands
AssignMaterial 11-28
Chamfer 11-29
ChangeProperty 11-58
Connect 11-29
Copy 11-21
CoverLines 11-29
CoverSurfaces 11-30
CreateBondwire 11-3
CreateBox 11-4
CreateCircle 11-5
CreateCone 11-5
CreateCutplane 11-6
CreateCylinder 11-6
CreateEllipse 11-7
CreateEntityList 11-30
CreateEquationCurve 11-7
CreateEquationSurface 118
CreateFaceCS 11-30, 11-32
CreateHelix 11-9
CreateObjectFromdges 11-34
CreateObjectFromFaces 1135
CreatePoint 11-10

CreatePolyline 11-10
CreateRectangle 11-12
CreateRegion 11-13
CreateRegularPolygon 11-15
CreateRegularPolyhedron
11-15
CreateRelativeCS 11-36
CreateSphere 11-16
CreateSpiral 11-16
CreateTorus 11-17
Delete 11-59
DeleteLastOperation 11-36
DeletePolylinePoint 11-22
DetachFaces 11-37
DuplicateAlongLine 11-22
DuplicateAroundAxi 11-23
DuplicateMirror 11-24
EditEntityList 11-37
EditFaceCS 11-38
EditObjectCS 11-38
EditPolyline 11-18
EditRelativeCS 11-40
Export 11-40
ExportModelImagetoFile
11-41
Fillet 11-42
GenerateHistory 11-43
GetBodyNamesByPosition
Index-1

ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

11-59
GetEdgeByPosition 11-60
GetEdgeIDsfromFace 11-60
GetEdgeIDsfromObject 11-61
GetFaceArea 11-61
GetFaceByPosition 11-61
GetFaceCenter 11-61
GetFaceIDs 11-62
GetModelBoundingBox 11-62
Import 11-45
ImportDXF 11-46
ImportGDSII 11-47
InsertPolylineSegment 11-18
Intersect 11-49
Mirror 11-25
Move 11-25
MoveCSToEnd 11-49
MoveFaces 11-50
OffsetFaces 11-26
PageSetup 11-67
ProjectSheet 11-51
RenamePart 11-67
Rotate 11-26
Scale 11-27
Section 11-52
SeparateBody 11-52
SetModelUnits 11-53
SetWCS 11-53
Split 11-54
Subtract 11-54
SweepAlongPath 11-19
SweepAlongVector 11-20
SweepAroundAxis 11-21
SweepFacesAlongNormal 11-55
ThickenSheet 11-56
UncoverFaces 11-56
Unite 11-57

A
AddCartesianXMarker 13-3
AddDataset 8-2

AddDeltaMarker 13-3
AddMarker 13-4
AddMaterial 6-2, 6-3
AddNamedExpr 20-3
AddNamedExpression 20-3
AddNote 13-4
AddTraces 13-5, 13-7
Analysis module commands
Analyze 9-3
DeleteDrivenSweep 16-2
DeleteSetups 16-2
EditFrequencySweep 16-2, 16-4
EditSetup 16-3
GetSetupCount 16-4
GetSetups 16-5
GetSweepCount 16-5
GetSweeps 16-5
InsertFrequencySweep 16-6, 16-15
InsertSetup 16-8
InsertSetup HFSS-IE 16-12
InsertSetup Transient 16-13
RenameDrivenSweep 16-18
RenameSetup 16-18
RevertAllToInitial 16-19
RevertSetupToInitial 16-19
Analyze
Analysis module command 9-3
AnalyzeDistributed 9-4
Ansoft Application Object commands 3-1
Ansoft Application object commands
GetAppDesktop 3-2
SetDesiredRamMBLimit 3-5
ApplyMeshOps 9-3
arithmetic operators 1-5
array variables 1-4
AssignAperature 14-46
AssignArray 10-2
AssignCurrent 14-12
AssignDCThickness 9-4
AssignFiniteCond 14-13, 14-46
AssignFloquet 14-14
AssignIERegion 14-17
AssignImpedance 14-17, 14-47

Index-2
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

AssignIncidentWave 14-18
AssignLayeredImp 14-19
AssignLengthOp 15-4
AssignLumpedPort 14-21
AssignLumpedRLC 14-23
AssignMagneticBias 14-23
AssignMaster 14-24
AssignMaterial 11-28
AssignModelResolutionOp 15-5
AssignPerfectE 14-25
AssignPerfectH 14-25
AssignRadiation 14-26
AssignScreeningImpedance 14-27
AssignSkinDepthOp 15-5
AssignSlave 14-30
AssignSymmetry 14-31
AssignTerminal 14-31
AssignTrueSurfOp 15-6
AssignVoltage 14-32
AssignWavePort 14-32
AutoIdentifyPorts 14-3
AutoIdentifyTerminals 14-4

B
Boundary/Excitation module commands
AssignAperature 14-46
AssignCurrent 14-12
AssignFiniteCond 14-13, 14-46
AssignFloquet 14-14
AssignIERegion 14-17
AssignImpedance 14-17, 14-47
AssignIncidentWave 14-18
AssignLayeredImp 14-19
AssignLumpedPort 14-21
AssignLumpedRLC 14-23
AssignMagneticBias 14-23
AssignMaster 14-24
AssignPerfectE 14-25
AssignPerfectH 14-25
AssignRadiation 14-26
AssignScreeningImpedance 14-27

AssignSlave 14-30
AssignSymmetry 14-31
AssignTerminal 14-31
AssignVoltage 14-32
AssignWavePort 14-32
AutoIdentifyPorts 14-3
AutoIdentifyTerminals 14-4
ChangeImpedanceMult 14-4
CreatePML 14-49
DeleteAllBoundaries 14-4
DeleteAllExcitations 14-5
DeleteBoundaries 14-5
EditCurrent 14-35
EditFiniteCond 14-36
EditImpedance 14-37
EditIncidentWave 14-38
EditLayeredImpedance 14-39
EditLumpedPort 14-40
EditLumpedRLC 14-41
EditMagneticBias 14-41
EditMaster 14-39
EditPerfectE 14-39
EditPerfectH 14-39
EditRadiation 14-41
EditSlave 14-42
EditSymmetry 14-42
EditTerminal 14-43
EditVoltage 14-43
EditWavePort 14-43
GetBoundaries 14-5
GetBoundariesofType 14-6
GetBoundaryAssignment 14-5
GetDefaultBaseName 14-6
GetExcitations 14-6
GetExcitationsOfType 14-7
GetNumBoundaries 14-7
GetNumBoundariesofType 14-7
GetNumExcitations 14-7
GetNumExcitationsOfType 14-8
GetPortExcitationsCounts 14-8
ModifyPMLGroup 14-51
PMLGroupCreated 14-51
PMLGroupModified 14-52

Index-3
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

ReassignBoundaries 14-8
RecalculatePMLMaterials 14-52
RenameBoundary 14-9
ReprioritizeBoundary 14-9
SetDefaultBaseName 14-9
SetTerminalReferenceImpedances 1444
UnassignIERegions 14-44

C
CalcOp 20-3
CalcStack 20-4
CalculatorRead 20-4
CalculatorWrite 20-5
Chamfer 11-29
ChangeGeomSettings 20-5
ChangeImpedanceMult 14-4
ChangeProperty 7-4, 11-58
ClcEval 20-5
ClcMaterial 20-6
ClearAllMarkers 13-7
ClearAllNamedExpr 20-6
Close 5-2
CloseAllWindows 4-3
CloseProject 4-3
CloseProjectNoForce 4-3
comment lines 1-2
comparison operators 1-5
conditional statements
If...Then... Else 1-6
Select Case 1-6
types of 1-6
Connect 11-29
ConstructVariationString 9-5
conventions
command syntax 2-8
data types 2-8
script command 2-8
converting data types 1-7
Copy 11-21
CopyDesign 5-2

CopyNamedExprToStack 20-6
CopyReportData 13-8
CopyReportDefinition 13-8
copyright notices 1-9
CopySetup
Optimetrics module command 17-5
CopyTracesDefinitions 13-8
Count 4-4
CoverLines 11-29
CoverSurfaces 11-30
CreateBondwire 11-3
CreateBox 11-4
CreateCircle 11-5
CreateCone 11-5
CreateCutplane 11-6
CreateCylinder 11-6
CreateEllipse 11-7
CreateEntityList 11-30
CreateEquationCurve 11-7
CreateEquationSurface 11-8
CreateFaceCS 11-30, 11-32
CreateFieldPlot 19-2
CreateHelix 11-9
CreateObjectFromEdges 11-34
CreateObjectFromFaces 11-35
CreateOutputVariable 12-2
CreatePML 14-49
CreatePoint 11-10
CreatePolyline 11-10
CreateRectangle 11-12
CreateRegion 11-13
CreateRegularPolygon 11-15
CreateRegularPolyhedron 11-15
CreateRelativeCS 11-36
CreateReport 13-9
CreateReportFromTemplate 13-12
CreateSphere 11-16
CreateSpiral 11-16
CreateTorus 11-17
CreateUserDefinedSolution 22-2
CutDesign 5-2

Index-4
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

D
dataset commands
AddDataset 8-2
DeleteDataset 8-2
EditDataset 8-3
ImportDataset 8-3
Delete 11-59
DeleteAllBoundaries 14-4
DeleteAllExcitations 14-5
DeleteAllReports 13-12
DeleteArray 10-3
DeleteBoundaries 14-5
DeleteDataset 8-2
DeleteDesign 5-2
DeleteDrivenSweep 16-2
DeleteFarFieldSetup 21-2
DeleteFieldPlot 19-6
DeleteFullVariation 18-5
DeleteImportData 18-2
DeleteLastOperation 11-36
DeleteLinkedDataVariation 9-6
DeleteNamedExpr 20-7
DeleteNearFieldSetup 21-2
DeleteOp 15-2
DeleteOutputVariable 12-2
DeletePolylinePoint 11-22
DeleteReport 13-12
DeleteSetups
Analysis module command 16-2
Optimetrics module command 17-5
DeleteSolutionVariation 18-6
Deletetraces 13-13
DeleteUserDefinedSolution 22-4
DeleteVariation 18-7
Design object commands
13-16
AddCartesianXMarker 13-3
AddDeltaMarker 13-3
AddMarker 13-4
AddNote 13-4
AddTraces 13-5, 13-7

AnalyzeDistributed 9-4
ApplyMeshOps 9-3
AssignDCThickness 9-4
CalculatorRead 20-4, 20-5
ClearAllMarkers 13-7
CloseAllWindows 4-3
CopyReportData 13-8
CopyReportDefinition 13-8
CopyTracesData 13-8
CreateOutputVariable 12-2
CreateReport 13-9
CreateReportFromTemplate 13-12
DeleteAllReports 13-12
DeleteOutputVariable 12-2
DeleteReport 13-12
DeleteTraces 13-13
EditOutputVariable 12-3
ExportConvergence 9-6
ExportMeshStats 9-7
ExportPlotImageToFile 13-13
ExportProfile 9-7
ExportToFile 13-15
FFTOnReport 13-15
GetDesiredRamMBLimit 3-2
GetDisplayType 13-17
GetEditSourcesCount 9-8
GetHPCLicenseType 3-2
GetLibraryDirectory 4-6
GetMatchedObjectName 11-64
GetMaximumRamMBLimit 3-3
GetModelUnits 11-64
GetModule 9-9
GetMPIVendor 3-3
GetName 9-9
GetNominalVariation 9-9
GetNumberOfProcessors 3-4
GetNumObjects 11-65
GetObjectIDByName 11-63
GetObjectName 11-63, 11-64
GetObjectsInGroup 11-63
GetOutputVariables 12-4
GetOutputVariableValue 12-4
GetProjectDirectory 4-7

Index-5
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

GetSelections 11-65
GetSolutionType 9-10
GetSolveInsideThreshold 9-10
GetSourceContexts 9-10
GetTempDirectory 4-7
GetUseHPCforMP 3-4
GetUser Position 11-65
GetVariationVariableValue 9-10
GetVersion 4-7
GetVertexIDsFromEdge 11-66
GetVertexIDsFromFace 11-66
GetVertexIDsFromObject 11-67
ImportIntoReport 13-18
PasteReports 13-18
PasteTraces 13-19
Redo 9-11
RenameDesignInstance 9-11
RenameReport 13-19
RenameTraces 13-19
RunToolkit 9-14
SARSetup 9-11
SetActiveEditor 9-12
SetDesignSettings 9-12
SetHPCLicenseType 3-5
SetLibraryDirectory 4-12
SetMaximumRamMBLimit 3-6
SetMPIVendor 3-6
SetNumberOfProcessors 3-7
SetProjectDirectoryVBCommand> 4-12
SetSolutionType 9-13
SetSolveInsideThreshold 9-13
SetSourceContexts 9-14
SetTempDirectory 4-12
SetUseHPCforMP 3-7
ShowWindow 11-54
Solve 9-14, 9-16
UpdateAllReports 13-20
UpdateReports 13-20
UpdateTraces 13-21
UpdateTracesContextandSweeps 13-23
Desktop object commands
CloseProject 4-3
CloseProjectNoForce 4-3

Count 4-4
EnableAutosave 4-4
GetActiveProject 4-5
GetAutosaveEnabled 4-5
GetDesigns 4-5
GetDistributedAnalysisMachines 4-6
GetName 4-6
GetProjectList 4-7
GetProjects 4-6
NewProject 4-8
OpenMultipleProjects 4-8
OpenProject 4-8
PauseScript 4-9
Print 4-9
QuitApplication 4-9
RestoreWindow 4-9
RunProgram 4-10
RunScript 4-10
SetActiveProject 4-11
SetActiveProjectByPath 4-11
Sleep 4-13
DetachFaces 11-37
DistributedAnalyzeSetup
Optimetrics module command 17-6
DuplicateAlongLine 11-22
DuplicateAroundAxis 11-23
DuplicateMirror 11-24

E
EditAntennaArraySetup 21-8
EditArray 10-4
EditCurrent 14-35
EditDataset 8-3
EditEntityList 11-37
EditFaceCS 11-38
EditFarFieldSphereSetup 21-4
EditFiniteCond 14-36
EditFrequencySweep 16-2, 16-4
EditImpedance 14-37
EditIncidentWave 14-38
EditLayeredImpedance 14-39

Index-6
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

EditLengthOp 15-7
EditLumpedPort 14-40
EditLumpedRLC 14-41
EditMagneticBias 14-41
EditMaster 14-39
EditMaterial 6-4
EditModelResolutionOp 15-7
EditNearFieldLineSetup 21-4
EditNearFieldSphereSetup 21-5
EditObjectCS 11-38
EditOutputVariable 12-3
EditPerfectE 14-39
EditPerfectH 14-39
EditPolyline 11-18
EditRadiation 14-41
EditRelativeCS 11-40
EditSetup
Analysis module command 16-3
optimization command 17-15
parametric command 17-11
sensitivity command 17-19
statistical command 17-21
EditSkinOp 15-8
EditSlave 14-42
EditSources 18-2
EditSymmetry 14-42
EditTerminal 14-43
EditTrueSurfOp 15-8
EditUserDefinedSolution 22-4
EditVoltage 14-43
EditWavePort 14-43
EnableAutoSave 4-4
EnterComplex 20-7
EnterComplexVector 20-7
EnterLine 20-8
EnterPoint 20-8
EnterQty 20-9
EnterScalar 20-9
EnterScalarFunc 20-9
EnterSurf 20-10
EnterVector 20-10
EnterVectorFunc 20-10
EnterVol 20-11

Export 11-40
ExportConvergence 9-6
ExportDXConfigFile
Optimetrics module command 17-6
ExportEignemodes 18-9
ExportForHSpice 18-10
ExportForSpice 18-8
ExportFullWaveSpice 23-1
ExportMaterial 6-4
ExportMesh Stats 9-7
ExportModelImagetoFile 11-41
ExportNetworkData 23-2
ExportNetworkData 18-11
ExportNMFData 23-3
ExportNMFData 18-13
ExportOnGrid 20-11
ExportOptimetricsProfile
Optimetrics module command 17-6
ExportOptimetricsResults
Optimetrics module command 17-7
ExportParametricResults
Optimetrics module command 17-7
ExportPlotImageToFile 13-13
ExportProfile 9-7
ExportRadiationParametersToFile 21-12
ExportToFile 13-15, 20-12

F
FFTONReport 13-15
Field Overlay module commands
GetFieldPlotNames 19-6
Field Overlays module commands
AddNamedExpr 20-3
AddNamedExpression 20-3
CalcOp 20-3
CalcStack 20-4
ChangeGeomSettings 20-5
ClcEval 20-5
ClcMaterial 20-6
ClearAllNamedExpr 20-6
CopyNamedExprToStack 20-6

Index-7
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

CreateFieldPlot 19-2
DeleteFieldPlot 19-6
DeleteNamedExpr 20-7
EnterComplex 20-7
EnterComplexVector 20-7
EnterLine 20-8
EnterPoint 20-8
EnterQty 20-9
EnterScalar 20-9
EnterScalarFunc 20-9
EnterSurf 20-10
EnterVector 20-10
EnterVectorFunc 20-10
EnteVol 20-11
ExportOnGrid 20-11
ExportToFile 20-12
ModifyFieldPlot 19-7
RenameFieldPlot 19-8
RenamePlotFolder 19-9
SetFieldPlotSettings 19-9
SetPlotFolderSettings 19-10
Fields Calculator commands
AddNamedExpr 20-3, 20-6
CalcOp 20-3
CalcStack 20-4
ChangeGeomSettings 20-5
ClcEval 20-5
ClcMaterial 20-6
CopyNamedExprToStack 20-6
DeleteNamedExpr 20-7
EnterComplex 20-7
EnterComplexVector 20-7
EnterLine 20-8
EnterPoint 20-8
EnterQty 20-9
EnterScalar 20-9
EnterScalarFunc 20-9
EnterSurf 20-10
EnterVector 20-10
EnterVectorFunc 20-10
EnterVol 20-11
ExportOnGrid 20-11
ExportToFile 20-12

Fillet 11-42
For...Next loop 1-7

G
GenerateHistory 11-43
GenerateVariationData Parametric
parametric command 17-11
GetActiveDesign 5-3
GetActiveProject 4-5
GetAdaptiveFrq 18-14
GetAllReportNames 13-16
GetArrayVariables 7-10
GetAutoSaveEnabled 4-5
GetBodyNamesByPosition 11-59
GetBoundaries 14-5
GetBoundariesOfType 14-6
GetBoundaryAssignment 14-5
GetDefaultBaseName 14-6
GetDesign 5-3
GetDesigns 4-5
GetDesiredRamMBLimit 3-2
GetDisplayType 13-17
GetDistributedAnalysisMachines 4-6
GetEdgeByPosition 11-60
GetEdgeIDsFromFace 11-60
GetEdgeIDsFromObject 11-61
GetEditSourcesCount 9-8
GetExcitations 14-6
GetExcitationsOfType 14-7
GetFaceArea 11-61
GetFaceByPosition 11-61
GetFaceCenter 11-61
GetFaceIDs 11-62
GetFieldPlotNames
Field Overlay module command 19-6
GetHPCLicenseType 3-2
GetLibraryDirectory 4-6
GetMatchedObjectName 11-64
GetMaximumRamMBLimit 3-3
GetModelBoundingBox 11-62
GetModelUnits 11-64

Index-8
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

GetModule 9-9
GetMPVendor 3-3
GetName 4-6, 5-3, 9-9
GetNominalVariation 9-9
GetNumberOfProcessors 3-4
GetNumBoundaries 14-7
GetNumBoundariesOfType 14-7
GetNumExcitations 14-7
GetNumExcitationsOfType 14-8
GetNumObjects 11-65
GetObjectIDByName 11-63
GetObjectName 11-63, 11-64
GetObjectsIngroup 11-63
GetOperationNames
Mesh Operations module command 15-2
GetOutputVariable 12-4
GetOutputVariableValue 12-4
GetPath 5-3
GetPortExcitationsCounts 14-8
GetProjectDirectory 4-7
GetProjectList 4-7
GetProjects 4-6
GetProperties 7-9
GetPropertyValue 7-10
GetSelections 11-65
GetSetupCount
Analysis module command 16-4
GetSetupNames 21-2
GetSetupNames (Optimetrics)
Optimetrics module command 17-8
GetSetupNamesByType (Optimetrics)
Optimetrics module command 17-8
GetSetups
Analysis module command 16-5
GetSolutionType 9-10
GetSolutionVesrionID 18-14
GetSolveInsideThreshold 9-10
GetSolveRangeInfo 18-14
GetSourceContexts 9-10
GetSweepCount
Analysis module command 16-5
GetSweeps
Analysis module command 16-5

GetTempDirectory 4-7
GetTopDesignList 5-4
GetTopEntryValue 20-13
GetUseHPCforMP 3-4
GetUserPosition 11-65
GetValidISolutionList 18-15
GetVariables 7-10
GetVariableValue 7-11
GetVariationVariableValue 9-10
GetVersion 4-7
GetVertexIDsFromEdge 11-66
GetVertexIDsFromFace 11-66
GetVertexIDsFromObject 11-67

H
HasFields 18-15
AssignLumpedPort 14-48
Boundary/Excitation module commands
AssignLumpedPort 14-48
Analysis module commands
RenameSweep 16-19
RenameSweep 16-19
hierarchy of variables in HFSS 2-2

I
If...Then... Else statement 1-6
Import 11-45
ImportDataset 8-3
ImportDXF 11-46
ImportGDSII 11-47
ImportINtoReport 13-18
ImportSetup
Optimetrics module command 17-9
ImportSolution 18-16
ImportTable 18-17
InputBox function 1-7
InsertDesign 5-4
InsertFarFieldSphereSetup 21-5
InsertFrequencySweep 16-6, 16-15
InsertNearFieldLineSetup 21-6

Index-9
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

InsertNearFieldSphereSetup 21-7
InsertPolylineSegment 11-18
InsertSetup
Analysis module command 16-8
optimization command 17-15
parametric command 17-11
sensitivity command 17-19
statistical command 17-23
InsertSetup HFSS-IE
Analysis module command 16-12
InsertSetup Transient
Analysis module command 16-13
Intersect 11-49
IsFieldAvailableAt 18-18

J
JavaScript, script format 1-1

K
keywords, VBScript 1-2

L
ListMatchingVariations 18-19
ListValuesOfVariable 18-19
ListVariations 18-20
logical operators 1-6

M
material commands
AddMaterial 6-2, 6-3
EditMaterial 6-4
ExportMaterial 6-4
RemoveMaterial 6-4
Mesh Operations module commands
AssignLengthOp 15-4
AssignModelResolutionOp 15-5
AssignSkinDepthOp 15-5
AssignTrueSurfOp 15-6

DeleteOp 15-2
EditLengthOp 15-7
EditModelResolutionOp 15-7
EditSkinOp 15-8
EditTrueSurfOp 15-8
GetOperationNames 15-2
RenameOp 15-2
Microsoft
VBScript users guide 1-8
Visual Basic 1-1
Mirror 11-25
Model Setup commands
AssignArray 10-2
DeleteArray 10-3
EditArray 10-4
ModifyFieldPlot 19-7
modifying a script 2-7
ModifyPMLGroup 14-51
ModuleHasMatrixData 18-15
ModuleHasMesh 18-16
modules in HFSS scripting 2-4
Move 11-25
MoveCSToEnd 11-49
MoveFaces 11-50
MsgBox function 1-8

N
ndExplorer Manager Script Commands 23-1
NewProject 4-8

O
oAnsoftApp object 2-3
oDesign object 2-3
oDesktop object 2-3
oEditor object 2-4
OffsetFaces 11-26
oModule object 2-4
OpenMultipleProjects 4-8
OpenProject 4-8
operators

Index-10
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

arithmetic 1-5
categories in VBScript 1-4
comparison 1-5
logical 1-6
precedence of 1-5
oProject object 2-3
Optimetrics module commands
DeleteSetups 17-5
DistributeAnalyzeSetup 17-6
ExportDXConfigFile 17-6
ExportOptimetricsProfile 17-6
ExportOptimetricsResults 17-7
ExportParametricResults 17-7
GetSetupNames 17-8
GetSetupNamesByType 17-8
ImportSetup 17-9
RenameSetup 17-9
SolveSetup 17-5, 17-10
optimization commands
EditSetup 17-15
InsertSetup 17-15
output variable commands
CreateOutputVariable 12-2
DeleteOutputVariable 12-2
EditOutputVariable 12-3
GetOutputVariables 12-4
GetOutputVariableValue 12-4

P
PageSetup 11-67
parametric commands
EditSetup 17-11
GenerateVariationData
17-11
InsertSetup 17-11
Paste 5-4
PasteReports 13-18
PasteTraces 13-19
PauseScript 4-9
pausing a script 2-7
PMLGroupCreated 14-51

Parametric

PMLGroupModified 14-52
Print 4-9
Project object commands
AddDataset 8-2
AddMaterial 6-2, 6-3
ChangeProperty 7-4
Close 5-2
CopyDesign 5-2
CutDesign 5-2
DeleteDataset 8-2
DeleteDesign 5-2
EditDataset 8-3
EditMaterial 6-4
ExportMaterial 6-4
GetActiveDesign 5-3
GetArrayVariables 7-10
GetDesign 5-3
GetName 5-3
GetPath 5-3
GetProperties 7-9
GetPropertyValue 7-10
GetTopDesignList 5-4
GetTopEntryValue 20-13
GetVariables 7-10
GetVariableValue 7-11
InsertDesign 5-4
Paste 5-4
Redo 5-5
RemoveMaterial 6-4
Save 5-5
SaveAs 5-5
SetActiveDesign 5-6
SetPropertyValue 7-11
SetVariableValue 7-12
SimulateAll 5-6
Undo 5-6
ProjectSheet 11-51
property commands
ChangeProperty 7-4
GetArrayVariables 7-10
GetProperties 7-9
GetPropertyValue 7-10
GetTopEntryValue 20-13

Index-11
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

GetVariables 7-10
GetVariableValue 7-11
SetPropertyValue 7-11
SetVariableValue 7-12

Q
QuitApplication 4-9

R
Radiation module commands
DeleteFarFieldSetup 21-2
DeleteNearFieldSetup 21-2
EditAntennaArraySetup 21-8
EditFarFieldSphereSetup 21-4
EditNearFieldSphereSetup 21-5
EditNearLineSetup 21-4
ExportRadiationParametersToFile
21-12
GetSetupNames 21-2
InsertFarFieldSphereSetup 21-5
InsertNearFieldLineSetup 21-6
InsertNearFieldSphereSetup 21-7
RenameSetup 21-3
ReassignBoundaries 14-8
RecalculatePMLMaterials 14-52
recording a script 2-6
Redo
design-level command 9-11
project-level command 5-5
references, for VBScript 1-8
RemoveMaterial 6-4
RenameBoundary 14-9
RenameDesignInstance 9-11
RenameDrivenSweep 16-18
RenameFieldPlot 19-8
RenameOp 15-2
RenamePart 11-67
RenamePlotFolder 19-9
RenameReport 13-19
RenameSetup

Analysis module command 16-18


Optimetrics module command 17-9
Radiation module command 21-3
RenameTraces 13-19
Reporter editor commands
AddCartesianXMarker 13-3
AddDeltaMarker 13-3
AddMarker 13-4
AddNote 13-4
AddTraces 13-5, 13-7
ClearAllMarkers 13-7
CopyReportDefinition 13-8
CopyTracesData 13-8
CreateReport 13-9
CreateReportFromTemplate 13-12
DeleteAllReports 13-12
DeleteReport 13-12
DeleteTraces 13-13
ExportPlotImageToFile 13-13
ExportToFile 13-15, 13-18
FFTOnReport 13-15
GetAllReportNames 13-16
GetDisplayType 13-17
PasteReports 13-18
PasteTraces 13-19
RenameReport 13-19
RenameTraces 13-19
UpdateAllReports 13-20
UpdateReports 13-20
UpdateTraces 13-21
UpdateTracesContextandSweeps 13-23
ReprioritizeBoundary 14-9
RestoreWindow 4-9
resuming a script 2-7
RevertAllToInitial 16-19
RevertSetupToInitial 16-19
Rotate 11-26
running a script 2-6
RunProgram 4-10
RunScript 4-10
RunToolkit 9-14

Index-12
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

S
sample scripts
data export 24-6
simple HFSS 1-2
variable helix 24-2
SARSetup 9-11
Save 5-5
SaveAs 5-5
Scale 11-27
scripts
in JavaScript format 1-1
modifying for easier playback 2-7
pausing 2-7
recording 2-6
resuming 2-7
running 2-6
running from command prompt 1-1
stop recording 2-6
stopping execution of 2-7
Section 11-52
Select Case statement 1-6
sensitivity commands
EditSetup 17-19
InsertSetup 17-19
SeparateBody 11-52
SetActiveDesign 5-6
SetActiveEditor 9-12
SetActiveProject 4-11
SetActiveProjectByPath 4-11
SetDefaultBaseName 14-9
SetDesignSettings 9-12
SetDesiredRamMBLimit 3-5
SetFieldPlotSettings 19-9
SetHPCLicenseType 3-5
SetLibraryDirectory 4-12
SetMaximumRAMMBLimit 3-6
SetModelUnits 11-53
SetMPVendor 3-6
SetNumberOfProcessors 3-7
SetPlotFolderSettings 19-10
SetProjectDirectory 4-12

SetPropertyValue 7-11
SetSolutionType 9-13
SetSolveInsideThreshold 9-13
SetSourceContexts 9-14
SetTempDirectory 4-12
SetTerminalReferenceImpedances 14-44
SetUseHPCforMP 3-7
SetVariableValue 7-12
SetWCS 11-53
SGetAppDesktop 3-2
ShowlWindow 11-54
SimulateAll 5-6
Sleep 4-13
Solutions module commands
ConstructVariationString 9-5
DeleteFullVariation 18-5
DeleteImportData 18-2
DeleteLinkedDataVariation 9-6
DeleteSolutionVariation 18-6
DeleteVariation 18-7
EditSources 18-2
ExportEigenmodes 18-9
ExportForHSpice 18-10
ExportForSpice 18-8
ExportNetworkData 18-11
ExportNMF 18-13
GetAdaptiveFreq 18-14
GetSolutionVersionID 18-14
GetSolveRangeInfo 18-14
GetValidISolutionLIst 18-15
HasFields 18-15
ImportSolution 18-16
ImportTable 18-17
IsFieldAvailableAt 18-18
ListMatchingVariations 18-19
ListValuesOfVariable 18-19
ListVariations 18-20
ModuleHasMatrixData 18-15
ModuleHasMesh 18-16
Solve 9-14
SolveSetup
Optimetrics module command 17-10
Split 11-54

Index-13
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

statistical commands
EditSetup 17-21
InsertSetup 17-23
stopping a script 2-7
stopping script recording 2-6
Sub procedures 1-2
Subtract 11-54
SweepAlongPath 11-19
SweepAlongVector 11-20
SweepAroundAxis 11-21
SweepFacesAlongNormal 11-55

used as objects 1-2


used in HFSS scripts 2-2
.vbs file format 2-6
VBScript
Microsoft users guide 1-8
operators 1-4
overview 1-1
references 1-8
Sub procedures 1-2
.vbs file format 2-6

T
ThickenSheet 11-56
trademark notices 1-9

U
UnassignIERegions 14-44
UncoverFaces 11-56
underscore ( _ ) character 1-3
Undo
design-level command 9-16
project-level command 5-6
Unite 11-57
UpdateAllReports 13-20
UpdateReports 13-20
UpdateTraces 13-21
UpdateTracesContextandSweeps 13-23
UserDefinedSolutions module commands
CreateUserDefinedSolution 22-2
DeleteUserDefinedSolution 22-4
EditUserDefinedSolution 22-4

V
variables
array 1-4
assigning information 1-4
declaring 1-4
hierarchy in HFSS 2-2

Index-14
ANSYS Electromagnetics Suite 15.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

You might also like