0% found this document useful (0 votes)
459 views

HFSSScripting Guide

Uploaded by

Ap
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
459 views

HFSSScripting Guide

Uploaded by

Ap
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1144

HFSS Scripting Guide

  Release 2020 R2
ANSYS, Inc.   July 2020
Southpointe
2600 ANSYS Drive ANSYS, Inc. and
Canonsburg, PA 15317 ANSYS Europe,
[email protected] Ltd. are UL
https://www.ansys.com registered ISO
9001:2015 com-
(T) 724-746-3304 panies.
(F) 724-514-9494
HFSS Scripting Guide

Copyright and Trademark Information


© 1986-2020 ANSYS, Inc. Unauthorized use, distribution or duplication is prohibited.
ANSYS, ANSYS Workbench, AUTODYN, CFX, FLUENT 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 located in the United States or other countries. ICEM CFD is a
trademark used by ANSYS, Inc. under license. All other brand, product, service and feature names
or trademarks are the property of their respective owners. FLEXlm and FLEXnet are trademarks of
Flexera Software LLC.
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 doc-
umentation 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. and ANSYS Europe, Ltd. are UL registered ISO 9001: 2015 companies.
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 restric-
tions stated in the ANSYS, Inc. software license agreement and FAR 12.212 (for non-DOD
licenses).
Third-PartySoftware
See the legal information in the product help files for the complete Legal Notice for ANSYS pro-
prietary software and third-party software. If you are unable to access the Legal Notice, please con-
tact ANSYS, Inc.

2
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Table of Contents
Table of Contents Contents-1
1 - Introduction to Scripting 1-1
Introduction to VBScript 1-1
Simple and Composite Names 1-2
VBScript Variables 1-2
Declaring Variables 1-2
Declaring Variables in Python 1-3
Variable Naming Conventions 1-3
Scope and Lifetime of Variables 1-3
Array Variables 1-3
VBScript Operators 1-4
Operator Precedence 1-5
Arithmetic Operators 1-5
String Concatenation Operator 1-6
Comparison Operators 1-6
Logical Operators 1-6
Controlling Program Execution 1-7
Using If...Then...Else 1-7
Using Select Case 1-7
Looping Through Code 1-8
Using a For...Next Loop 1-8
Using a Do Loop 1-8
Repeating Statements While a Condition is True 1-8
Repeating a Statement Until a Condition Becomes True 1-8
VBScript Procedures 1-9
Function Procedures 1-9
Sub Procedures 1-9
Converting Between Data Types 1-9

Contents-1
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Including Scripts 1-10


Aborting Scripts 1-10
Interacting with a Script 1-10
Recommended VBScript References 1-11
Sample HFSS Script 1-11
Introduction to IronPython 1-13
Scope 1-13
Python compatibility 1-13
Advantages of IronPython 1-14
IronPython Mini-cookbook 1-15
Comments 1-15
Assigning/Creating Variables 1-15
Create Lists/Arrays 1-16
Create Dictionaries/Maps 1-16
Boolean Values 1-17
Converting Numbers to Strings and Vice Versa 1-17
String formatting/concatenation 1-17
Looping over lists 1-18
Looping over a range 1-18
A note about indentation 1-19
Sample Script 1 – Describing Python Indentation: 1-19
Obtaining more Information on Python 1-20
Discovering Methods 1-20
Help on a Method 1-21
Translating Script commands from VBScript to IronPython 1-22
Script Method Argument 1-22
Primitive Types 1-22
Named Array 1-22
Named Function 1-23
VBscript Method Call Types 1-23

Contents-2
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Converting VBScript Function calls to IronPython Syntax 1-24


Return Values 1-24
Primitive Method Arguments 1-25
Named Array Argument 1-25
Named Array Values with All Key Value Pairs 1-27
Named Arrays with Nested Named Arrays 1-28
Function Blocks 1-29
Scripting Using Iron Python: Putting it all Together 1-30
Translating a script in VBScript to IronPython 1-30
Writing an IronPython script from scratch 1-30
IronPython Script Execution Environment 1-30
Script Argument for IronPython 1-31
Script Objects for IronPython 1-32
Methods for IronPython 1-32
Methods for Manipulating Registry Values 1-34
Scripting using Embedded VBScript or JavaScript 1-35
Scripting with IronPython 1-38
Standalone IronPython 1-39
Running Standalone IronPython 1-39
Using a Recorded Script 1-39
Creating an External Script 1-39
Example Script 1-40
IronPython Samples 1-41
Change property 1-42
Create a Cone using IronPython 1-43
Creating User Defined Primitives and User Defined Models in Python Scripts 1-47
Advantages Compared to C++ 1-47
Changes compared to C 1-47
Structures 1-47
Constants 1-47

Contents-3
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Methods 1-47
Output Parameters 1-48
Comparison with C function: 1-48
'List Size' Parameters 1-49
Comparison with C function: 1-50
Added Parameters 1-50
Developing a UDM/UDP 1-51
Creation 1-51
Location 1-51
Organize 1-52
Edit/Reload 1-52
UDPExtension 1-52
Import 1-52
Main class: UDPExtension 1-52
IUDPExtension methods 1-53
Mandatory methods. 1-53
GetLengthParameterUnits() 1-53
GetPrimitiveTypeInfo() 1-53
GetPrimitiveParametersDefinition2() 1-53
AreParameterValuesValid2(errorMsg, udpParams) 1-53
CreatePrimitive2(funcLib, udpParams) 1-53
Optional methods 1-53
GetPrimitiveParameters() 1-53
GetRegisteredFaceNames() 1-54
GetRegisteredEdgeNames() 1-54
GetRegisteredVertexNames() 1-54
MapParametersDefinitionVersions2(oldVersion, oldUDPParams) 1-54
GetOldPrimitiveParametersDefinition2(version ) 1-54
Example UDP 1-54
UDPFunctionLibrary 1-55

Contents-4
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Functions list: 1-55


UDMExtension 1-58
Import 1-58
Main class: UDMExtension 1-58
IUDMExtension methods 1-59
Mandatory methods. 1-59
GetInfo() 1-59
IsAttachedToExternalEditor() 1-59
CreateInstance(funcLib) 1-59
GetUnits(instanceId) 1-59
ReleaseInstance(instanceId) 1-60
GetAttribNameForEntityId() 1-60
GetAttribNameForPartId() 1-60
Optional methods 1-60
GetInstanceSourceInfo(instanceId) 1-61
ShouldAttachDefinitionFilesToProject() 1-61
Example UDM 1-61
UDMFunctionLibrary 1-62
Functions list: 1-62
UDP/UDM Structures and constants 1-63
UDP/UDM Structures 1-63
List of structures 1-65
UDP/UDM Constants 1-70
Enum constants: 1-70
Logging and Desktop Messaging 1-72
Collecting EBU Logs 1-72
Collecting WB Logs 1-73
Example Scripts for Python UDP and UDM 1-73
ANSYS Electronics Desktop Scripting 1-75
Overview of ANSYS Electronics Desktop Script Variables 1-76

Contents-5
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Recording a Script 1-81


Working with Project Scripts 1-83
Stopping Script Recording 1-83
Running a Script 1-84
Pausing and Resuming a Script 1-85
Stopping a Script 1-86
Modifying a Script for Easier Playback 1-86
ANSYS Electronics Desktop Scripting Conventions 1-86
Syntax Conventions 1-87
Script Command Conventions 1-87
Named Arguments 1-89
Setting Numerical Values 1-90
ANSYS Electronics Desktop Layout Scripts and the Active Layer 1-90
Scripts and Locked Layers 1-91
Event Callback Scripting 1-91
Executing a Script from Within a Script 1-92
Editing Properties 1-93
2 - Application Object Script Commands 2-1
GetAppDesktop 2-1
3 - Desktop Object Script Commands 3-1
AddMessage 3-3
ClearMessages 3-4
CloseAllWindows 3-5
CloseProject 3-5
CloseProjectNoForce 3-6
Count 3-7
DeleteProject 3-8
DownloadJobResults 3-9
EnableAutoSave 3-10
ExportOptionsFiles 3-11

Contents-6
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetActiveProject 3-12
GetAutoSaveEnabled 3-13
GetBuildDateTimeString 3-14
GetDefaultUnit 3-15
GetDesigns 3-16
GetDistributedAnalysisMachines 3-17
GetDistributedAnalysisMachinesForDesignType 3-18
GetExeDir 3-19
GetGDIObjectCount 3-20
GetLibraryDirectory 3-20
GetLocalizationHelper 3-21
GetMessages 3-22
GetName [Desktop] 3-25
GetPersonalLibDirectory 3-26
GetProcessID 3-27
GetProjects 3-28
GetProjectDirectory 3-29
GetProjectList 3-30
GetScriptingToolsHelper 3-32
GetSysLibDirectory 3-32
GetTempDirectory 3-33
GetUserLibDirectory 3-34
GetVersion 3-36
ImportANF 3-37
ImportAutoCAD 3-38
ImportGDSII 3-38
ImportODB 3-40
LaunchJobMonitor 3-40
NewProject 3-41
OpenAndConvertProject 3-42

Contents-7
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

OpenMultipleProjects 3-43
OpenProject 3-43
OpenProjectWithConversion 3-44
Paste (Project Object) 3-44
Paste (Project Object) 3-46
PauseRecording 3-47
PauseScript 3-48
Print 3-49
QuitApplication 3-50
RefreshJobMonitor 3-51
RestoreProjectArchive 3-53
RestoreWindow 3-54
ResumeRecording 3-55
RunACTWizardScript 3-55
RunProgram 3-56
RunScript 3-56
RunScriptWithArguments 3-58
SelectScheduler 3-59
SetActiveProject 3-60
SetActiveProjectByPath 3-61
SetLibraryDirectory 3-62
SetProjectDirectory 3-63
SetTempDirectory 3-64
ShowDockingWindow 3-65
Sleep 3-65
SubmitJob 3-66
TileWindows 3-67
Desktop Commands For Registry Values 3-68
DoesRegistryValueExist 3-68
GetRegistryInt 3-69

Contents-8
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetRegistryString 3-69
SetRegistryFromFile 3-69
SetRegistryInt 3-70
SetRegistryString 3-70
4 - Running Instances Manager Script Commands 4-1
GetAllRunningInstances 4-1
GetRunningInstanceByProcessID 4-1
GetRunningInstanceByProject 4-2
5 - Project Object Script Commands 5-1
AnalyzeAll [project] 5-2
ClearMessages 5-2
Close 5-3
CopyDesign 5-3
CutDesign 5-4
DeleteDesign 5-4
DeleteToolObject 5-5
GetActiveDesign 5-5
GetChildNames [Project] 5-6
GetChildObject [Project] 5-7
GetChildTypes [Project] 5-8
GetConfigurableData (Project) 5-8
GetDefinitionManager 5-8
GetDependentFiles 5-9
GetDesign 5-10
GetEDBHandle 5-10
GetLegacyName 5-11
GetName [Project] 5-11
GetPath 5-11
GetTopDesignList 5-12
GetPropNames [Project] 5-13

Contents-9
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetPropValue [Project] 5-13


InsertDesign 5-14
InsertDesignWithWorkflow 5-16
InsertToolObject 5-17
Paste (Project Object) 5-18
Redo [Project Level] 5-19
Rename 5-20
RestoreProjectArchive 5-20
Save 5-21
SaveAs 5-22
SaveProjectArchive 5-24
SetActiveDefinitionEditor 5-25
SetActiveDesign 5-26
SetPropValue [Project] 5-27
SimulateAll 5-28
Undo [Project] 5-28
UpdateDefinitions 5-29
6 - Property Script Commands 6-1
Object Script Property Function Summary 6-2
Object Path 6-2
Property Object: 6-3
Project Object 6-4
Design Object 6-4
Variable Object 6-5
Optimetrics Module Object: 6-6
Optimetrics Setup Object 6-7
ReportSetup(Results) Module Object: 6-7
ReportSetup(Results) Module Child Objects: 6-8
Radiation Module Object: 6-8
Radiation Module Child Objects: 6-9

Contents-10
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Conventions Used in this Chapter 6-9


GetArrayVariables 6-14
GetProperties 6-14
GetPropertyValue 6-16
GetVariables 6-18
GetVariableValue 6-19
SetPropertyValue 6-19
SetVariableValue 6-21
Additional Property Scripting Example 6-22
Example Use of Record Script and Edit Properties 6-25
7 - Dataset Script Commands 7-1
AddDataset 7-1
DeleteDataset 7-2
EditDataset 7-3
ImportDataset 7-4
8 - Design Object Script Commands 8-1
AddDesignVariablesForDynamicLink 8-3
ApplyMeshOps 8-4
Analyze 8-5
AnalyzeDistributed 8-5
AssignDCThickness 8-6
ClearLinkedData (Design) 8-7
ConstructVariationString 8-8
DeleteFieldVariation 8-9
DeleteFullVariation 8-11
DeleteLinkedDataVariation 8-12
DeleteVariation 8-13
EditDesignSettings 8-13
HFSS-IE Design Settings 8-14
EditNotes 8-16

Contents-11
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ExportConvergence 8-17
ExportMatrixData 8-18
ExportNetworkData 8-21
ExportNMFData 8-25
ExportMeshStats 8-29
ExportProfile 8-30
Generate Mesh 8-30
GetChildNames [Design] 8-31
GetChildObject [Design] 8-31
GetChildTypes [Design] 8-32
GetConfigurableData 8-33
GetData 8-33
GetDesignType 8-33
GetDesignValidationInfo 8-34
GetEditSourcesCount 8-35
GetExcitationsModule 8-36
GetManagedFilesPath 8-37
GetModule 8-38
GetName 8-40
GetNominalVariation 8-40
GetNoteText 8-41
GetPostProcessingVariables 8-41
GetPropNames [Design] 8-42
GetPropValue [Design] 8-42
GetSelections 8-43
GetSolutionType 8-44
GetSolveInsideThreshold 8-45
GetSourceContexts 8-45
GetVariationVariableValue 8-46
GeometryCheckAndAutofix 8-46

Contents-12
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

PasteDesign (Design Object) 8-48


Redo [Design] 8-49
RenameDesignInstance 8-49
ResetToTimeZero 8-50
SARSetup 8-51
SetActiveEditor 8-52
SetBackgroundMaterial 8-52
SetDesignSettings 8-53
SetLengthSettings 8-55
SetObjectDeformation 8-56
SetObjectTemperature 8-56
SetPhaseCenterPerPort 8-57
SetPropValue [Design] 8-58
SetSinglePhaseCenter 8-59
SetSolutionType 8-59
SetSolveInsideThreshold 8-60
SetSourceContexts 8-61
Solve 8-61
RunToolkit 8-63
Undo [Design] 8-67
ValidateDesign 8-67
ValidateLink 8-68
9 - Model Setup Script Commands 9-1
Assign Array 9-1
DeleteArray 9-2
EditArray 9-3
10 - 3D Modeler Editor Script Commands 10-1
Draw Menu Commands 10-2
Create3D Component 10-3
CreateBondwire 10-5

Contents-13
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

CreateBox 10-5
CreateCircle 10-7
CreateCone 10-9
CreateCutplane 10-10
CreateCylinder 10-11
CreateEllipse 10-12
CreateEquationCurve 10-14
CreateEquationSurface 10-16
CreateHelix 10-20
CreatePoint 10-20
CreateUserDefinedPart 10-22
CreatePolyline 10-23
CreateRectangle 10-27
CreateRegion 10-29
CreateRegularPolyhedron 10-33
CreateRegularPolygon 10-33
CreateSphere 10-35
CreateSpiral 10-36
CreateTorus 10-37
CreateUserDefinedModel 10-39
CreateUserDefinedPart 10-41
Edit3DComponent 10-43
EditNativeComponentDefinition 10-44
EditPolyline 10-47
Get3DComponentParameters 10-47
Get3DComponentDefinitionNames 10-48
Get3DComponentInstanceNames 10-48
Get3DComponentMaterialNames 10-49
Get3DComponentMaterialProperties 10-49
Insert3DComponent 10-50

Contents-14
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

InsertNativeComponent 10-51
InsertPolylineSegment 10-53
SweepAlongPath 10-54
SweepAlongVector 10-56
SweepAroundAxis 10-57
SweepFacesAlongNormal 10-59
SweepFacesAlongNormalWithAttributes 10-60
UpdateComponentDefinition 10-62
Edit Menu Commands 10-62
Copy 10-63
DeletePolylinePoint 10-63
DuplicateAlongLine 10-63
DuplicateAroundAxis 10-65
DuplicateMirror 10-67
Mirror 10-69
Move 10-70
OffsetFaces 10-70
Paste (Model Editor) 10-71
Rotate 10-71
Scale 10-72
Modeler Menu Commands 10-72
AssignMaterial 10-74
Chamfer 10-75
Connect 10-76
CoverLines 10-76
CoverSurfaces 10-76
CreateEntityList 10-76
CreateFaceCS 10-80
CreateGroup 10-82
CreateObjectCS 10-83

Contents-15
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

CreateObjectFromEdges 10-86
CreateObjectFromFaces 10-88
CreateRelativeCS 10-89
DeleteEmptyGroups 10-90
DeleteLastOperation 10-91
DetachFaces 10-91
EditEntityList 10-92
EditFaceCS 10-93
EditObjectCS 10-93
EditRelativeCS 10-96
Export 10-97
ExportModelImageToFile 10-97
Fillet 10-100
FlattenGroup 10-101
GenerateHistory 10-102
HealObject 10-102
GetActiveCoordinateSystem 10-105
GetCoordinateSystems 10-106
Import 10-106
ImportDXF 10-109
ImportGDSII [Modeler Import] 10-111
Intersect 10-113
MoveCStoEnd 10-113
MoveEntityToGroup 10-114
MoveFaces 10-115
ProjectSheet 10-117
PurgeHistory 10-118
ReplaceWith3DComponent 10-119
Section 10-121
SeparateBody 10-122

Contents-16
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

SetModelUnits 10-122
SetWCS 10-123
ShowWindow 10-123
Split 10-124
Subtract 10-124
SweepFacesAlongNormal 10-125
ThickenSheet 10-127
UncoverFaces 10-128
Unite 10-129
Ungroup 10-130
WrapSheet 10-131
Other oEditor Commands 10-132
AddViewOrientation 10-133
BreakUDMConnection 10-136
ChangeProperty 10-137
Delete 10-139
FitAll 10-139
GetBodyNamesByPosition 10-140
GetChildNames [Modeler] 10-141
GetChildObject [Modeler] 10-142
GetChildTypes [Modeler] 10-144
GetEdgeByPosition 10-144
GetEdgeIDsFromFace 10-145
GetEdgeIDsFromObject 10-146
GetEntityListIDByName 10-146
GetFaceArea 10-147
GetFaceCenter 10-148
GetFaceByPosition 10-148
GetFaceIDs 10-149
GetGeometryModelerMode 10-150

Contents-17
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetMatchedObjectName 10-150
GetModelBoundingBox 10-151
GetModelUnits 10-151
GetPropNames [Modeler] 10-152
GetPropValue [Modeler] 10-152
GetNumObjects 10-153
GetObjectIDByName 10-154
GetObjectName 10-154
GetObjectNameByFaceID 10-155
GetObjectsByMaterial 10-155
GetObjectsInGroup 10-156
GetPropertyValue 10-156
GetSelections [Model Editor] 10-159
GetUserPosition 10-159
GetVertexIDsFromEdge 10-160
GetVertexIDsFromFace 10-161
GetVertexIDsFromObject 10-161
GetVertexPosition 10-161
OpenExternalEditor 10-162
PageSetup 10-162
RenamePart 10-163
SetPropValue [Modeler] 10-164
11 - Output Variable Script Commands 11-1
CreateOutputVariable 11-1
DeleteOutputVariable 11-4
DoesOutputVariableExist 11-5
EditOutputVariable 11-6
GetOutputVariableValue 11-8
SimValueContext 11-16
12 - Reporter Editor Script Commands 12-1

Contents-18
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

AddCartesianLimitLine 12-4
AddCartesianXMarker 12-5
AddCartesianYMarker 12-5
AddDeltaMarker 12-6
AddMarker 12-7
AddNote 12-7
AddTraceCharacteristics 12-9
AddTraces 12-11
ChangeProperty [ReportSetup] 12-15
ClearAllMarkers 12-16
ClearAllTraceCharacteristics 12-18
CopyTracesData 12-19
CopyReportData 12-19
CopyReportDefinitions 12-20
CopyTraceDefinitions 12-21
CreateReport 12-21
CreateReport [Designer] 12-26
CreateReportFromFile 12-31
CreateReportFromTemplate 12-31
CreateReportOfAllQuantities 12-33
DeleteMarker 12-34
DeleteAllReports 12-35
DeleteReports 12-35
DeleteTraces 12-36
ExportImageToFile [Reporter] 12-37
ExportPlotImageToFile [Reporter] 12-38
ExportReport 12-39
ExportToFile 12-40
ExportToFile [Reporter] 12-41
ExportMarkerTable 12-42

Contents-19
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

FFTOnReport 12-42
GetAllCategories 12-44
GetAllReportNames 12-45
GetAllQuantities 12-47
GetAvailableDisplayTypes 12-48
GetAvailableReportTypes 12-48
GetAvailableSolutions 12-49
GetChildNames [Report Setup] 12-49
GetChildObject [Report Setup] 12-50
GetChildTypes [ReportSetup] 12-51
GetDataExpressions 12-51
GetDataUnits 12-52
GetDesignVariableNames 12-52
GetDesignVariableUnits 12-53
GetDesignVariableValue 12-53
GetDesignVariationKey 12-54
GetDisplayType 12-54
GetImagDataValues 12-55
GetPerQuantityPrimarySweepValues 12-56
GetPropertyValue 12-57
GetPropNames [Reporter] 12-59
GetPropValue [Report Setup] 12-59
GetRealDataValues 12-60
GetReportTraceNames 12-61
GetSolutionContexts 12-62
GetSolutionDataPerVariation 12-62
GetSweepNames 12-64
GetSweepUnits 12-65
GetSweepValues 12-66
GroupPlotCurvesByGroupingStrategy 12-66

Contents-20
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ImportIntoReport 12-67
IsDataComplex 12-68
IsPerQuantityPrimarySweep 12-68
MovePlotCurvesToGroup 12-69
MovePlotCurvesToNewGroup 12-70
PasteReports 12-70
PasteTraces 12-71
Release Data 12-71
RenameReport 12-72
RenameTrace 12-72
ResetPlotSettings 12-73
SavePlotSettingsAsDefault 12-74
SetPropValue [Report Setup] 12-75
UpdateTraces 12-75
UpdateTracesContextandSweeps 12-82
UpdateAllReports 12-84
UpdateReports 12-84
UnGroupPlotCurvesInGroup 12-85
13 - Boundary and Excitation Module Script Commands 13-1
General Commands Recognized by the Boundary/Excitations Module 13-2
AddAssignmentToBoundary 13-3
AutoIdentifyNets 13-4
AutoIdentifyPorts 13-4
AutoIdentifyTerminals 13-5
ChangeImpedanceMult 13-5
ConvertNportCircuitElementsToPorts 13-6
CreateNportCircuitElements 13-6
DeleteAllBoundaries 13-8
DeleteAllExcitations 13-8
DeleteBoundaries 13-8

Contents-21
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetBoundaryAssignment 13-9
GetBoundaries 13-9
GetBoundariesOfType 13-9
GetDefaultBaseName 13-10
GetExcitations 13-10
GetExcitationsOfType 13-10
GetNumBoundaries GetNumBoundaries 13-11
GetNumBoundariesOfType 13-11
GetNumExcitations 13-11
GetNumExcitationsOfType 13-12
GetPortExcitationCounts 13-12
ReassignBoundary 13-12
RemoveAssignmentFromBoundary 13-14
RenameBoundary 13-14
ReprioritizeBoundaries 13-15
SetDefaultBaseName 13-15
Script Commands for Creating and Modifying Boundaries 13-16
AssignCircuitPort 13-17
AssignCurrent 13-19
AssignDielectricCavity 13-19
AssignFEBI 13-20
AssignFiniteCond 13-21
AssignFloquet 13-23
AssignHalfSpace 13-26
Assign Hybrid Region 13-27
AssignIERegion 13-28
AssignImpedance 13-28
AssignIncidentWave 13-29
AssignLayeredImp 13-30
AssignLinkedRegion 13-32

Contents-22
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

AssignLumpedPort 13-33
AssignLumpedRLC 13-35
AssignMagneticBias 13-37
AssignMaster 13-38
AssignPerfectE 13-39
AssignPerfectH 13-39
AssignRadiation 13-40
AssignScreeningImpedance 13-41
AssignSlave 13-44
AssignSymmetry 13-45
AssignTerminal 13-46
AssignVoltage 13-47
AssignWavePort 13-48
CircuitPortToLumpedPort 13-50
EditCircuitPort [HFSS] 13-51
EditCurrent 13-52
EditDiffPairs 13-52
EditFiniteCond 13-53
EditHalfSpace 13-54
EditHybridRegion 13-55
EditImpedance 13-55
EditIncidentWave 13-55
EditLayeredImpedance 13-57
EditMaster 13-57
EditPerfectE 13-57
EditPerfectH 13-57
EditLumpedPort 13-57
EditLumpedRLC 13-58
EditMagneticBias 13-59
EditRadiation 13-59

Contents-23
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

EditSlave 13-60
EditSymmetry 13-60
EditTerminal 13-60
EditVoltage 13-61
EditVoltageDrop 13-61
EditWavePort 13-61
LumpedPortToCircuitPort 13-62
SetHybridRegionCoupledGroup 13-62
SetTerminalReferenceImpedances 13-64
SetSBRSources 13-64
VBS Example Modal and Terminal Solution Type: 13-65
SetSBRWedgeSettings 13-66
VBS Example 13-67
SwapCircuitPortAssignment 13-68
UnassignIERegions 13-68
Script Commands for Creating and Modifying Boundaries in HFSS-IE 13-69
AssignAperture [HFSS-IE] 13-69
AssignFiniteCond [HFSS-IE] 13-70
AssignHalfSpace [HFSS-IE] 13-71
AssignImpedance [HFSS-IE] 13-72
AssignInfiniteGroundPlane [HFSS-IE] 13-72
AssignLumpedPort [HFSS-IE] 13-73
Script Commands for Creating and Modifying PMLs 13-73
CreatePML 13-74
ModifyPMLGroup 13-75
PMLGroupCreated 13-76
PMLGroupModified 13-76
RecalculatePMLMaterials 13-77
14 - Mesh Operations Module Script Commands 14-1
General Commands Recognized by the Mesh Operations Module 14-1

Contents-24
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

DeleteOp 14-2
GetOperationNames 14-2
RenameOp 14-2
Script Commands for Creating and Modifying Mesh Operations 14-3
AssignApplyCurvilinearElementsOp 14-3
AssignLengthOp 14-4
AssignModelResolutionOp 14-5
AssignCurvatureExtractionOp (Beta) 14-6
AssignSkinDepthLayerSetting 14-7
AssignSkinDepthOp 14-7
AssignTrueSurfOp 14-8
EditApplyCurvilinearElementsOp 14-9
EditLengthOp 14-10
EditModelResolutionOp 14-10
EditSBRCurvatureExtractionOp (Beta) 14-11
EditSkinDepthOp 14-12
EditTrueSurfOp 14-12
InitialMeshSettings 14-13
15 - Analysis Setup Module Script Commands 15-1
ClearLinkedData (Module) 15-2
CopySetup 15-2
CopySweep 15-3
DeleteDrivenSweep 15-3
DeleteSetups 15-4
DeleteSweep [HFSS-IE] 15-4
EditCircuitSettings 15-4
EditFrequencySweep 15-5
EditSetup 15-6
EditSweep [HFSS-IE] 15-8
ExportCircuit 15-9

Contents-25
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetSetupCount 15-12
GetSetups 15-13
GetSetupNames 15-13
GetSweepCount 15-13
GetSweeps 15-14
InsertFrequencySweep 15-14
InsertSetup 15-22
InsertSetup [HFSS-IE] 15-39
InsertSetup [Transient] 15-40
InsertSweep [HFSS-IE] 15-46
PasteSetup 15-50
PasteSweep 15-50
RenameDrivenSweep 15-50
RenameSetup 15-50
RenameSweep [HFSS-IE] 15-51
RevertAllToInitial 15-52
RevertSetupToInitial 15-52
SetMPIVendor 15-53
16 - Optimetrics Module Script Commands 16-1
General Commands Recognized by the Optimetrics Module 16-4
CopySetup 16-4
DeleteSetups [Optimetrics] 16-5
DistributedAnalyzeSetup 16-6
ExportDXConfigFile 16-6
ExportOptimetricsProfile 16-7
ExportOptimetricsResult 16-8
ExportParametricResults 16-8
GetChildNames [Optimetrics] 16-9
GetChildObject [Optimetrics] 16-10
GetChildTypes [Optimetrics] 16-10

Contents-26
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetPropNames [Optimetrics] 16-11


GetPropValue [Optimetrics] 16-11
GetSetupNames [Optimetrics] 16-12
GetSetupNamesByType [Optimetrics] 16-12
ImportSetup 16-13
PasteSetup [Optimetrics] 16-14
RenameSetup [Optimetrics] 16-14
SetPropValue [Optimetrics] 16-15
SolveAllSetup 16-16
SolveSetup [Optimetrics] 16-16
Parametric Script Commands 16-17
EditSetup [Parametric] 16-17
ExportParametricSetupTable 16-17
GenerateVariationData (Parametric) 16-18
InsertSetup [Parametric] 16-18
Optimization Script Commands 16-22
EditSetup [Optimization] 16-22
InsertSetup [Optimization] 16-26
Sensitivity Script Commands 16-34
EditSetup [Sensitivity] 16-34
InsertSetup [Sensitivity] 16-39
Statistical Script Commands 16-42
EditSetup [Statistical] 16-42
InsertSetup [Statistical] 16-45
17 - Solutions Module Script Commands 17-1
DeleteImportData 17-1
EditSources 17-2
DeleteSolutionVariation 17-5
DeleteVariation [HFSS] 17-6
ExportEigenmodes 17-6

Contents-27
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ExportForHSpice 17-7
ExportNetworkData 17-9
ExportNMFData [HFSS] 17-13
GetAdaptiveFreq 17-14
GetAvailableVariations 17-14
GetExcitationScaling 17-15
GetISolutionVersionID 17-15
GetSolveRangeInfo 17-16
GetValidISolutionList 17-16
HasFields 17-17
HasMatrixData 17-17
HasMesh 17-18
ImportSolution 17-18
ImportTable 17-19
IsFieldAvailableAt 17-21
ListMatchingVariations 17-21
ListValuesOfVariable 17-22
ListVariations 17-22
18 - Field Overlays Module Script Commands 18-1
AddAntennaOverlay 18-1
AddMarkerToPlot 18-3
CreateFieldPlot 18-3
DeleteFieldPlot 18-17
EditAntennaOverlay 18-17
GetFieldPlotNames 18-19
HideAntennaParametersOverlay 18-20
ModifyFieldPlot 18-21
RenameFieldPlot 18-22
RenamePlotFolder 18-23
SetFieldPlotSettings 18-23

Contents-28
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

SetPlotFolderSettings 18-24
ShowAntennaParameterOverlay 18-28
UpdateAllFieldsPlots 18-29
UpdateQuantityFieldsPlots 18-29
19 - Fields Calculator Script Commands 19-1
AddNamedExpression 19-2
AddNamedExpr 19-2
CalcOp 19-3
CalcRead(deprecated) 19-3
CalculatorRead 19-3
CalcStack 19-4
CalculatorWrite 19-5
ChangeGeomSettings 19-5
ClcEval 19-6
ClcMaterial 19-6
ClearAllNamedExpr 19-7
CopyNamedExprToStack 19-7
DeleteNamedExpr 19-7
EnterComplex 19-8
EnterComplexVector 19-8
EnterLine 19-9
EnterPoint 19-9
EnterQty 19-9
EnterScalar 19-10
EnterScalarFunc 19-10
EnterSurf 19-11
EnterVector 19-11
EnterVectorFunc 19-12
EnterVol 19-12
ExportOnGrid 19-12

Contents-29
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ExportToFile [Fields Calculator] 19-14


GetTopEntryValue 19-15
LoadNamedExpressions 19-15
SaveNamedExpressions 19-16
20 - Radiation Module Script Commands 20-1
General Commands Recognized by the Radiation Module 20-1
DeleteFarFieldSetup 20-2
DeleteNearFieldSetup 20-2
EditRadiatedPowerCalculationMethod 20-3
GetChildNames [Radiation] 20-3
GetChildObject [Radiation] 20-3
GetChildTypes [Radiation] 20-4
GetPropNames [Radiation] 20-4
GetPropValue [Radiation] 20-4
GetSetupNames 20-5
RenameSetup [Radiation] 20-5
SetPropValue [Radiation] 20-6
Script Commands for Creating and Modifying Radiation Setups 20-6
EditBoxSetup 20-7
EditInfiniteSphereSetup 20-8
EditNearFieldLineSetup 20-10
EditNearFieldRectangleSetup 20-11
EditNearFieldSphereSetup 20-12
InsertBoxSetup 20-13
InsertFarFieldSphereSetup 20-15
InsertNearFieldLineSetup 20-16
InsertNearFieldRectangleSetup 20-17
InsertNearFieldSphereSetup 20-18
Script Commands for Modifying Antenna Array Setups 20-20
EditAntennaArraySetup 20-20

Contents-30
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Script Commands for Exporting Antenna Parameters and Max Field Parameters 20-24
ExportRadiationParametersToFile 20-24
21 - User Defined Solutions Commands 21-1
CreateUserDefinedSolution 21-1
DeleteUserDefinedSolutions 21-3
EditUserDefinedSolution 21-4
22 - Network Data Explorer Script Commands 22-1
Network Data Explorer Manager Script Commands 22-1
ExportFullWaveSpice [Network Data Explorer] 22-1
ExportNetworkData [Network Data Explorer] 22-2
ExportNMFData [Network Data Explorer] 22-3
23 - Definition Manager Script Commands 23-1
AddMaterial 23-1
CloneMaterial 23-3
DoesMaterialExist 23-4
EditMaterial 23-5
ExportMaterial 23-7
RemoveMaterial 23-7
RemoveUnusedDefinitions 23-8
Component Manager Script Commands 23-9
Add [component manager] 23-10
AddDynamicNPortData [component manager] 23-23
AddNPortData [component manager] 23-25
AddSolverOnDemandModel 23-29
ClearSolutionCache [component manager] 23-29
Edit [component manager] 23-29
EditSolverOnDemandModel 23-48
EditWithComps [component manager] 23-48
Export [component manager] 23-56
GetData [component manager] 23-57

Contents-31
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetNames [component manager] 23-58


GetNPortData [component manager] 23-59
GetSolverOnDemandData 23-61
GetSolverOnDemandModelList 23-61
IsUsed [component manager] 23-61
Remove [component manager] 23-62
RemoveSolverOnDemandModel 23-63
RemoveUnused [component manager] 23-63
Update Dynamic Link [component manager] 23-64
Material Manager Script Commands 23-64
GetData [material manager] 23-64
GetNames [material manager] 23-65
GetProperties [material manager] 23-66
IsUsed [material manager] 23-67
RemoveUnused [material manager] 23-67
Model Manager Script Commands 23-68
Add [model manager] 23-68
ConvertToDynamic 23-75
ConvertToParametric 23-76
Edit [deprecated] 23-76
EditWithComps [model manager] 23-76
Export [model manager] 23-84
GetData [model manager] 23-85
GetNames [model manager] 23-86
IsUsed [model manager] 23-86
Remove [model manager] 23-87
RemoveUnused [model manager] 23-88
Symbol Manager Script Commands 23-88
Add [symbol manager] 23-89
BringToFront [symbol manager] 23-96

Contents-32
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Edit [deprecated] 23-96


EditWithComps [symbol manager] 23-97
Export [symbol manager] 23-105
GetData [symbol manager] 23-105
GetNames [symbol manager] 23-106
IsUsed [symbol manager] 23-106
Remove [symbol manager] 23-106
RemoveUnused [symbol manager] 23-107
Footprint Manager Script Commands 23-108
Add [footprint manager] 23-108
Edit [footprint manager] 23-124
EditWithComps [footprint manager] 23-124
Export [footprint manager] 23-136
GetData [footprint manager] 23-137
GetNames [footprint manager] 23-138
IsUsed [footprint manager] 23-138
Remove [footprint manager] 23-138
RemoveUnused [footprint manager] 23-139
Padstack Manager Script Commands 23-140
Add [padstack manager] 23-140
Edit [padstack manager] 23-145
EditWithComps [padstack manager] 23-150
Export [padstack manager] 23-156
GetData [padstack manager] 23-156
GetNames [padstack manager] 23-157
IsUsed [padstack manager] 23-157
Remove [padstack manager] 23-157
RemoveUnused [padstack manager] 23-158
Script and Library Scripts 23-159
AddScript 23-159

Contents-33
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

EditScript 23-160
ExportScript 23-161
RemoveScript 23-161
ModifyLibraries 23-162
24 - Example Scripts 24-1
VBScript Example Scripts 24-1
Data Export Script 24-1
Variable Helix Script 24-4
IronPython Example Scripts 24-8
BH Coordinates Python Script 24-8
Script Contents 24-9
Posco_BH_Curve.tab Contents 24-11
Equation Based Curve Python Script 24-13
HFSS Waveguide Array Python Script 24-16
Index Index-1

Contents-34
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

1 - Introduction to Scripting
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 in the order in which they appear.
ANSYS Electronics Desktop can record scripts in VBScript or IronPython, and can run external
scripts written in VBScript, IronPython, or JavaScript. Additionally, it contains an IronPython com-
mand shell for executing scripts.
When running ANSYS Electronics Desktop from the command line, scripts can be written in any
language that provides Microsoft COM methods.
The following topics contain more information about the VBScript and IronPython scripting lan-
guages, as well general advice for scripting using Electronics Desktop:
Introduction to VBScript
Introduction to IronPython
ANSYS Electronics Desktop Scripting

Introduction to VBScript
ANSYS Electronics Desktop can use Microsoft® Visual Basic® Scripting (VBScript) to record mac-
ros. VBScript is based on the Microsoft Visual Basic programming language.
This chapter provides an overview of key VBScript components.
Simple and Composite Names
VBScript Variables
VBScript Operators
Controlling Program Execution
Looping Through Code
VBScript Procedures
Converting Between Data Types
Including Scripts
Aborting Scripts
Interacting with a Script
Recommended VBScript References
Sample HFSS Script
Sample Circuit Script
Sample Q3D Script

Introduction to Scripting 1-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

For more details about VBScript, please see the Recommended VBScript References section at
the end of this chapter.
Simple and Composite Names
Components, symbols, footprints, models, and padstacks possess either "simple" names or "com-
posite" names. Composite names are used to distinguish items from libraries that may possess the
same simple name. A composite name is created by combining an item’s library name with its
simple name. Composite names for definitions are unique, but simple names are not.

l Composite names are used by definition manager script commands to uniquely identify
script definitions.
l Materials and scripts do not have composite names, so project definitions for these items
must possess a unique simple name.
l The format of a composite name is LibraryName:SimpleDefinitionName. For example, the
composite name for the component "CAP_ in" the system library Nexxim Circuit Ele-
ments\Capacitors is "Nexxim Circuit Elements\Capacitors:CAP_in."
l The format of a composite name in a project is OriginLibraryName:SimpleDefinitionName.
For example, the composite name for the project component "CAP_" that was originally
from the system library Nexxim Circuit Elements\Capacitors is "Nexxim Circuit Ele-
ments\Capacitors:CAP_".
l Not all definitions in a project have a library of origin. Newly added definitions do not have a
library of origin, and project definitions whose names are changed do not have a library of ori-
gin (even if they did before the name change). As a result, the composite name for items
without a library of origin is the item’s simple name itself. For example, the composite name
for the project component "CAP_" that came from a system library and was renamed to
"MyCAP_" is "MyCAP_".

To construct a composite name, select Tools > Edit Configured Libraries > Components to
open the Edit Libraries dialog box. The subnames used to construct a composite name can be
found in the Name and Origin columns that correspond to a particular component. The Origin
column contains the library portion of the composite name, while the Name column contains the
simple portion of the composite name.
VBScript Variables
A VBScript variable is a placeholder representing information that may change during the time your
script is running. Variables are useful because they let you assign a short and easy to remember
name to each piece of data you plan to use. Use a variable name in a script to view or modify its
value.
Declaring Variables
To declare variables explicitly in a script, use the Dim, Public, or Private statements. For example:
Dim box_xsize

Introduction to Scripting 1-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

After declaring a variable, you can assign information to it. For example:
box_xsize = "3mm"
You can declare multiple variables by separating each variable name with a comma. For example:
Dim Top, Bottom, Left, Right
You can also declare a variable implicitly by simply using its name in your script. Doing so is not gen-
erally a good practice because you could misspell the variable name in one or more places, causing
unexpected results when your script is run. For that reason, the Option Explicit statement is avail-
able to require explicit declaration of all variables. The Option Explicit statement should be the
first statement in your script.
Declaring Variables in Python

Python does not require you to declare variables before you assign a value to them.
You can directly assign information to it. For example:
box_xsize = "3mm"
Variable Naming Conventions
You should use names that are short but intuitive and easy to remember. Use the following con-
ventions for naming variables in VBScript:

l Begin with an alphabetic character.


l Cannot contain an embedded period.
l Must not exceed 255 characters.
l Must be unique in the scope in which it is declared.
l Do not use VBScript keywords.

Scope and Lifetime of Variables


Variables at the script level are available to all procedures within the script. At the procedure level,
variables are available only within the procedure. It has local scope and is a procedure-level vari-
able.
The lifetime of a variable depends on how long it exists. The script-level variables exist from declar-
ation until the end of the script. A procedure-level variable exists only as long as you are in the pro-
cedure and is destroyed when the procedure exits.
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)

Introduction to Scripting 1-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

All arrays in VBScript are zero-based, so the array above actually contains 3 elements. You assign
data to each of the array’s elements using an index into the array. Data can be assigned to the ele-
ments 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().

If you do not know the size of the array at declaration or the size changes during the time your script
is running, you can use dynamic arrays. They are declared without size or number of dimensions
inside the parentheses. For example:
Dim FirstArray()
ReDim SecondArray()
To use a dynamic array, you must subsequently use ReDim to determine the number of dimen-
sions and the size of each dimension. You can also use the Preserve keyword to preserve the con-
tents of the array as the resizing takes place.
ReDim FirstArray(25)
ReDim Preserve FirstArray(30)
VBScript Operators
VBScript provides operators, which are grouped into these categories: arithmetic operators, com-
parison operators, and logical operators.
Please see the online VBScript User’s Guide for more details.

Introduction to Scripting 1-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Operator Precedence
When several operations occur in an expression, each part is evaluated and resolved in a pre-
determined 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 par-
entheses, however, standard operator precedence is maintained.
When an expression contains operators from more than one category, they are evaluated in the fol-
lowing order:

1. Arithmetic Operators
2. String Concatenation Operator (&)
3. Comparison Operators
4. Logical Operators

Arithmetic operators within a single expression are evaluated in the following order of pre-
cedence:

1. Exponentiation (^)
2. Multiplication and Division (*,/): These two operators are of equal precedence and are eval-
uated in the left-to-right order in which they appear within the expression.
3. Integer Division (\)
4. Modulus Arithmetic (Mod)
5. Addition and Subtraction (+,-): These two operators are of equal precedence and are eval-
uated in the order in which they appear within the expression.

If the same arithmetic operator appears multiple times within a single expression, they are eval-
uated in the left-to-right order in which they appear.
Comparison operators all have equal precedence and are evaluated in the left-to-right order in
which they appear within the expression.
Logical operators all have equal precedence and are evaluated in the left-to-right order in which
they appear within the expression.
Arithmetic Operators
Following is a list of VBScript’s arithmetic operators:

Symbol Description
^ Exponentiation
- Unary negation
* Multiplication
/ Division

Introduction to Scripting 1-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

\ Integer division
Mod  Modulus arithmetic 
+ Addition
- Subtraction

Note:

For the order of precedence for these operators, see Operator Precedence.

String Concatenation Operator


The ampersand symbol (&) is used to perform string concatenation. This operator appends the
second string to the first string.
Example:
"Hello," & " isn't it a lovely day?"
produces the following resultant string:
"Hello, isn't it a lovely day?"
Comparison Operators
Following is a list of VBScript’s comparison operators:

Symbol Description
= Equality
<> Inequality
< Less than
> Greater than
<= Less than or equal to
>=  Greater than or equal to 
Is Object equivalence

Note:

All comparison operators have the same precedence. When multiple comparisons exist
in a single expression, evaluate them in the left-to-right order in which they appear.

Logical Operators
Following is a list of VBScript’s logical operators:

Introduction to Scripting 1-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Symbol Description
Not Logical negation
And Logical conjunction
Or Logical disjunction
Xor Logical exclusion
Eqv  Logical equivalence 
Imp Logical implication

Note:

All logical operators have the same precedence. When multiple logical operators exist in
a single expression, evaluate them in the left-to-right order in which they appear.

Controlling Program Execution


You can use conditional statements to control the flow of a script. There are two types of con-
ditional statements in VBScript:

l If...Then...Else
l 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:
Select Case primitive_name
Case "Box1"
<statements to execute>

Introduction to Scripting 1-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Case "Cylinder1"
<statements to execute>
Case Else
<statements to execute>
End Select
Looping Through Code
Looping allows you to run a group of statements repeatedly. There are two types of loops:

l For...Next: Uses a counter to run statements a specified number of times.


l Do...Loop: Loops while or until a condition is True.

When using conditional statements that test for zero voltage/current, it is important to note that a
real voltage or current should not be trusted to be exactly zero, even when it should be. Typically,
the voltage or current is often on the order of 'epsilon' (1e-16) or smaller; hence, it is nonzero in
value.
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.
Using a Do Loop
You can use Do...Loop statements to run a block of statements until (or while) a condition is true.
Repeating Statements While a Condition is True
Use the While keyword to check a condition in a Do...Loop statement. The syntax is as follows:
Do While condition
<statements to execute>
Loop
Repeating a Statement Until a Condition Becomes True
Following is the syntax:
Do Until condition
<statements to execute>

Introduction to Scripting 1-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Loop
You can exit early from a loop by using the Exit For statement.
VBScript Procedures
In VBScript, there are two kinds of procedures, Sub and Function. These procedures are called by
name, they can receive arguments, and each performs a specific task with a group of VBScript
statements. If there is no argument, then the Sub or Function statement must include an empty set
of parentheses.
Function Procedures
A Function returns a value by assigning a value to its name in one or more statements. Following is
the syntax of a Function:
Function FunctionName([arguments])
<Function statements>
End Function
Sub Procedures
A Sub procedure is like a function procedure, except that it does not return a value through its
name. Following is the syntax of a Sub:
Sub ProcedureName([arguments])
<Procedure statements>
End Sub
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 con-
vert the string "2.5" to the number 2.5.
CInt Syntax: CInt(variablename).
Converts variablename to an integer.

Introduction to Scripting 1-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Including Scripts
You can include one script within another using the following command:
#include "<scriptfilename>"
Where scriptfilename is the full path name to a file that contains script text, or is the name of a script
in the project library or script library (listed in the project window under the Definitions/Scripts dir-
ectory).
The command works for VBScript, JScript, and for the following:

l Scripts in the project library that are run by right-clicking the script icon in the project window
and choosing Run Script
l Scripts in files that are external are run by choosing Tools> Run Script
l Scripts that are specified as callbacks in the Property dialog box
l Scripts that are run to draw parameterized footprints in layout

An include command can be placed anywhere in a script, but for readability it is recommended that
commands be placed at the beginning of a file. The same script can be included multiple times
without error, and circular inclusions will be ignored.
Aborting Scripts
You can abort a script that is running in the desktop simply by pressing the ESC key. Terminating a
script in this manner works for each of the following:

l Scripts in the project library that are run by right-clicking the script icon in the project window
and choosing Run Script.
l Scripts in files that are external can be run by choosing Tools> Run Script.
l Scripts that are specified as callbacks in the Property dialog box.
l Scripts that are run to draw parameterized footprints in layout.

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.
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")

Introduction to Scripting 1-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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 User’s Guide.
Available http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/htm-
l/vbstutor.asp.
Childs, M., Lomax, P., and Petrusha, R. VBScript in a Nutshell: A Desktop Quick Reference.
May 2002. O’Reilly & Associates. ISBN: 1-56592-720-6.
Sample HFSS Script
Following is an example of an ANSYS Electronics Desktop script. It includes comment lines, which
are preceded by either an apostrophe ( ’) or the word REM, that offer explanations for each pre-
ceding 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,
REMPublic, or Private to declare variables. As VBScript has no built-in data types (like
REMinteger, string, etc.), all variables are treated as variants, which can store any type of
REMinformation. In this example, the three variables will be used as objects. When
REMrecording scripts in HFSS, variants that will be used as objects always begin with o.

Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")


’ 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

Introduction to Scripting 1-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

’ 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", ""
’ 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 box’s geometric parameters and the second array is for the box’s
’ 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

Introduction to Scripting 1-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

’ 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 ANSYS Electronics Desktop script examples, see Example Scripts.

Introduction to IronPython
IronPython is an implementation of the Python programming language targeting the .NET runtime.
What this means in practical terms is that IronPython uses the Python programming language syn-
tax and standard python libraries and can additionally use .NET classes and objects to give one the
best of both worlds. This usage of .NET classes is fairly seamless in that a class defined in a .NET
assembly can be used as a base class of a python class.

Scope
Functioning as a tutorial on Python or IronPython is way out of the scope of this document. There
are several excellent resources online that do a very good job in that regard. This document only
attempts to provide a limited introduction to IronPython as used to script ANSYS EM products.
This document is also not a tutorial on the scripting of ANSYS EM products. It complements the
existing scripting guide (available from a product's Help menu) and provides a pythonic inter-
pretation of that information. The reader might have to refer to either the scripting guide or recor-
ded samples of VBScript to follow some of the sections.

Python compatibility
The version of IronPython in use is 2.7 and built on the .NET framework version 4.0: this version tar-
gets Python 2.7 language compatibility. While most python files will execute under IronPython
with no changes, python libraries that make use of extensions written in the C programming lan-
guage (NumPy or SciPy for instance), are not expected to work under IronPython. In such cases, it
might be possible to locate .NET implementation of such libraries or explore the use of IronClad.
(http://code.google.com/p/ironclad/).

Introduction to Scripting 1-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Advantages of IronPython
The advantages that IronPython use provides are significant:

l Python has a large eco-system with plenty of supporting libraries, Visual IDEs and debug-
gers. It is actively developed and enhanced.
l IronPython, in addition, has access to the entire .NET eco system. This allows us, for
instance, to create a modern GUI using the System.Windows.Forms assembly from
IronPython code and call any other .NET assembly for that matter.
l The use of IronPython's technologies enables the ability to interactively script Desktop (fea-
ture in development). This allows better discovery of the scripting APIs as well as directly pro-
gramming to the scripting API in python, a language more tractable and platform
independent compared with VBScript.
l The Python syntax of dictionaries is somewhat easier to read and write when supplying argu-
ments to the scripting methods.

This document describes IronPython briefly and then goes on to describe the desktop provided
IronPython scripting console and scripting with IronPython. You can open an IronPython Com-
mand Window by clicking Tools> Open Command Window.

The document assumes that you know how desktop scripting works using VBScript or Javascript.
Introduction to IronPython
IronPython Mini-cookbook
Translating Script commands from VBScript to IronPython
Scripting Using Iron Python: Putting it all Together

Introduction to Scripting 1-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Standalone IronPython and Desktop IronPython


IronPython Samples
Creating User Defined Primitives and User Defined Models in Python Scripts
IronPython Mini-cookbook
While a tutorial on Python syntax is beyond the scope of this document, it will present simple coun-
terparts the VBScript constructs that users tend to regularly use.
Comments
Assigning/Creating variables
Create Lists/Arrays
Create Dictionaries/Maps
Boolean Values
Converting Numbers to Strings and Vice Versa
String Formatting/Concatenation
Looping over Lists
Looping over a Range
A Note About Indentation

Additional Sections:
Obtaining More Information
Discovering Methods
Help on a Method

Comments

VBScript IronPython
' Comments start with a single quote # Comments start with a sharp or hash
' like this line # symbol, like these lines

Assigning/Creating Variables

VBScript IronPython
' Declare with a Dim # No Set syntax. Simply create and assign
Dim oDesktop oDesktop = oApp.GetAppDesktop()

Introduction to Scripting 1-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

'Assignment needs a Set instruction


Set oDesktop = oApp.GetAppDesktop()

Create Lists/Arrays

VBScript IronPython
' Declare as array of String with 11 # Declare an empty array
' indices from 0 through 10 myEmptyArray = []
Dim myArray(0 to 10) as String
myArray(0) = "Hello" # declare an array and initialize it with 5 ints
myArray(1) = "bye" myInitedArray = [ 1, 2, 3, 4, 5]

' Declare n array with no size # Python lists can have items of any type
Dim array2() as String # and there is no pre-declaration
# declare an array and init with mixed types
' Re-Dimension the array once size is mixed = ["hello", 1 ,2 ["nested"]]
' known
ReDim array2(0 to 2) as String # append to an array
array2(0) = "this" mixed.append( 3.5 )
array2(1) = "also"

Create Dictionaries/Maps

VBScript IronPython
' No direct equivalent is available as # an IronPython dictionary is a collection of
' far as the author knows # name value pairs. Just like arrays, there is
# no restriction on the keys or the values.
# For purposes of ANSYS EM scripting however,
# all keys must be strings

# delimiters are curly braces


# use a ":" between the key and the value
# separate key value pairs with a ","

Introduction to Scripting 1-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

myDict = {
"a" : 1,
"b" : "hello there",
"c" : [ 1, 2, "abc"]
}

Boolean Values

VBScript IronPython
' Boolean literals are in lower case # The first letter is capitalized
true True
false False

Converting Numbers to Strings and Vice Versa

VBScript IronPython
' Use CInt, CDbl, CBool, CLng # use the integer() or float() or double()
' to convert the string representation # functions to cast a string CONTAINING the
' to the number representation. Use # string representation of whatever you are
' IsNumber to check before conversion # casting to.
Dim nStr = "100" strInt = "3"
Dim n = CInt(nStr) intVal = int(strVal)
floatVal = float(strVal)
' Use CStr to convert a number to
' its string representation # invoke the str() function with the int/float
Dim v, vStr # values as needed. You can alternately use
v = 100 # the string formatting method listed below
vStr = CStr(v) strVal = str(42)
strVal = str(42.345)

String formatting/concatenation

VBScript IronPython
' string concatenation uses the & # if you have two strings, you can always
' operator # concatenate then using the '+' operator
Dim allStr, str1 str1 = "hello"

Introduction to Scripting 1-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

str1 = " how are you" str2 = "world"


allStr = "Hello " & " There" & str1 str12 = str1 + " " + str2

' there seems to be no direct string # if you have different types though, string
' formatting function in VBScript # and int say, you must use the string
' using string concatenation or using # formatting commands. When formatting
' Replace are the two builtin options # multiple arguments, they must be entered
Dim fmt = "{1} climbs stalk {2}" # as a tuple ( item1, item2, )
Dim str = Replace(fmt, "{1}", "jack") num = 10
str = Replace(str, "{2"}, 10) str3 = "%s climbs stalk %d" % ("jack", num)
str4 = "%d stalks" % num

Looping over lists

VBScript IronPython
Dim myArray(0 to 2) as String vals = [1, 3, 3.456]
myArray(0) = "alpha"
myArray(1) = "bravo" def process(val):
myArray(2) = "charlie" return 2*val

For Each i in myArray # is of the form


Print i # for variable_name in array ':'
Next # < indent> statement1
# <indent> statement2
for i in vals:
print i
print " -> " process(i)

Looping over a range

VBScript IronPython
' Loop over a range, specify start, end # prints out values from 0 through 9
' and step for i in range(0, 10):
For i = 0 To 10 Step 1 print i

Introduction to Scripting 1-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Print i
Next

Related Topics
A Note About Indentation
Obtaining More Information
Discovering Methods
Help on a Method
Introduction to IronPython
Translating Script commands from VBScript to IronPython
Scripting Using Iron Python: Putting it all Together
IronPython Samples
A note about indentation
Python is one of the languages where whitespace (spaces, tabs etc) are syntactically significant.
You must understand the basics of indentation before scripting in python.
Any statement that introduces a block of code should be written such that every line of the block
has the same indent (leading spaces or tabs) and the indent should be at least one more than the
indent of the introducing statement.
Sample Script 1 – Describing Python Indentation:

# define a function that starts at 0 indentation.


def multInt(a,b):
# every line following the def multInt which is expected
# to be a part of the function, must have the indent
# used by the first line of the function (3 spaces)
# here we introduce one more block, the if condition
# each line that belongs to the body of this function should
# have an indent that is more than the indent used by the
# if statement
If a%2 == 0:
# I am using an indent 3 more than the parent,
# i.e. 6 spaces in total

Introduction to Scripting 1-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

return (a * b) + 100
else:
return (a * b) + 1000

Related Topics
Obtaining More Information
Discovering Methods
Help on a Method
Introduction to IronPython
Translating Script commands from VBScript to IronPython
Scripting Using Iron Python: Putting it all Together
IronPython Samples
Obtaining more Information on Python
Reading a book and searching online are two of the standard options. There are several very good
python tutorials online and the command window is also a great way to quickly execute code and
learn by doing.
Much of the official python documentation is embedded into each python distribution and the com-
mand window can also be used to get more help. You can open the IronPython Command Window
by clicking Tools> Open Command Window. You can also aces the command window execut-
able, Ipy.exe, from the IronPython directory under the ANSYS EM product installation directory.
You can use this window to interactively enter python commands (any of the pure python samples
in this document)

Related Topics
Discovering Methods
Help on a Method
Introduction to IronPython
Translating Script commands from VBScript to IronPython
Scripting Using Iron Python: Putting it all Together
IronPython Samples
Discovering Methods
For instance, if you want to list all methods available in the string module, you would type in "import
string" to import the module first and then type in "dir(string)". You will get a list of all the methods
available (as well as some __somename__ internal names that can be ignored)

Introduction to Scripting 1-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Related Topics
Obtaining More Information
Help on a Method
Introduction to IronPython
Translating Script commands from VBScript to IronPython
Scripting Using Iron Python: Putting it all Together
IronPython Samples
Help on a Method
Once you know a function name, you can get more help on it using the builtin help method. For
instance, executing help(string.split) in the IronPython Command Window displays the fol-
lowing:

Related Topics
Obtaining More Information
Discovering Methods

Introduction to Scripting 1-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Introduction to IronPython
Translating Script commands from VBScript to IronPython
Scripting Using Iron Python: Putting it all Together
IronPython Samples
Translating Script commands from VBScript to IronPython
This chapter briefly describes Desktop scripting methods and arguments via VBScript samples.
The distinctions made here are significant and come in use later when translating scripts written in
VBScript to IronPython.

Related Topics
Script Method Argument
VBscript Method Call Types
VBScript Sub-Routines
Converting VBScript Function calls to IronPython Syntax
Introduction to IronPython
IronPython Mini-cookbook
Scripting Using Iron Python: Putting it all Together
IronPython Samples
Script Method Argument
Script method calls in VBscript are described later in this document, they generally take the form:
objectName .methodName ( arg1, arg2, ..)
The function call syntax is a standard followed by several programming languages, however, the
argument types in VBScript objects, when used for product scripting, are restricted to the following
Primitive types
Named Array
Named Function
Primitive Types

Primitive types are the standard bool, int, float, double and string
Named Array

Named arrays are a special construct used very commonly and can be found in practically every
recorded script sample.

Introduction to Scripting 1-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

It starts with Array( "NAME:someName" and is followed by a collection of comma separated val-


ues which can be:

l A primitive value
l An array of primitive values
l Another named array
l A key, of the form "keyName:=" followed by
o A primitive value
o A function (described next)
Named Function

Named functions are arrays which start with Array( and do not have a leading "NAME:name" item.
They are always introduced by a key and can contain comma separated values of the following
type:

l A primitive value
l A key (of the form "keyName:=") followed by
o A primitive value
o Another function (nested function)

Related Topics
Translating Script commands from VBScript to IronPython
VBscript Method Call Types
VBScript method calls fall into two categories and the distinction between the two results in syntax
differences. These syntax differences are significant when converting VBScript to IronPython.
VBScript Functions
In VBScript terminology functions return values. The syntax for this is the one shared with prac-
tically all programming languages.
Set oDesktop = oAnsoftApp.GetAppDesktop()
Set oProject = oDesktop.NewProject
Sample Script 2: VBScript function call sample
Note that the significant item here is that the method name is always followed by an argument list
enclosed in parentheses if there are arguments. If the argument list is empty as shown above for
the NewProject call, the parentheses can be omitted.
VBScript Sub-Routines
VBScript Sub-Routines are those that do not have any return value. VBScript allows these to be
written without any parentheses even if they have a non-empty argument list.

Introduction to Scripting 1-23


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModule.CreateReport "XY Plot1", "Standard", "XY Plot", "optimtee :


optimtee", _
Array("Domain:=", "Sweep"), Array("Freq:=", Array("All"), "off-
set:=", _
Array("0uin")), Array("X Component:=", "Freq", "Y Component:=",
_
Array("dB20(S(1,1))", "dB20(S(1,2))", "dB20(S(1,3))", _
"dB20(S(2,1))", "dB20(S(2,2))", "dB20(S(2,3))", "dB20(S
(3,1))", _
"dB20(S(3,2))", "dB20(S(3,3))")), Array()
Sample Script 3: VBScript Sub-Routine sample

Related Topics
Translating Script commands from VBScript to IronPython
Converting VBScript Function calls to IronPython Syntax
When converting functions, the important point to remember is that IronPython function names,
when used for scripting, are always followed by parentheses. So:

l If you see a VBScript snippet that looks like a VBScript Sub-Routine, remember to add par-
entheses.
l If you see a VBScript function that has no arguments and no parenthesis, remember to add
them around an empty argument list.

The parentheses change is the only one to keep in mind when converting VBScript function calls
syntax to IronPython.

Related Topics
Return Values
Primitive Method Arguments
Named Array Argument
Named Array Values with All Key Value Pairs
Named Arrays with Nested Named Arrays
Function Blocks
Return Values

VBscript return values are sometimes assigned via the Set declaration. IronPython return values
are simple assignment (see the cookbook chapter)

Introduction to Scripting 1-24


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Related Topics
Converting VBScript Function calls to IronPython Syntax
Primitive Method Arguments

Replace each VBScript primitive with an equivalent IronPython primitive. Boolean values in
IronPython have their first letter capitalized.
True instead of true, and False instead of false
Converting VBScript Function calls to IronPython Syntax
Named Array Argument

The recommended approach here is to simply replace a VBScript array with a python array. The
mapping is quite simple:

l Change Array( to a left bracket: [ and close with a right bracket: ], instead of a right par-
enthesis ).
l Remove the line continuation symbols: _
l Capitalize the first letter of Boolean values.
l If individual elements of an array are presented on separate lines, the indentation level of
related items must be consistent. Also, array contents must be indented more than their con-
taining brackets.

oEditor.CreateCone Array("NAME:ConeParameters", "XCenter:=", "0mm",


_
"YCenter:=", "0mm", "ZCenter:=", "0mm", "WhichAxis:=", "Z",
"Height:=", "2mm", _
"BottomRadius:=", "1.56204993518133mm", "TopRadius:=", "0mm"),
_
Array("NAME:Attributes", "Name:=", "Cone1", "Flags:=", "", "Col-
or:=", _
"(132 132 193)", "Transparency:=", 0, "PartCoordinateSystem:=",
_
"Global", "UDMId:=", "", "MaterialValue:=", _
"" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=", true)
Sample Script 4: Create cone recorded snippet

For instance, method and named VBScript arrays in the snippet above are translated to the fol-
lowing:
oEditor.CreateCone(

Introduction to Scripting 1-25


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

[
"NAME: ConeParameters",
"XCenter:=" , "0mm",
"YCenter:=" , "0mm",
"ZCenter:=" , "0mm",
"WhichAxis:=" , "Z",
"Height:=" , "2mm",
"BottomRadius:=" , "1.56204993518133mm",
"TopRadius" , "0mm"
],
[
"NAME:Attributes",
"Name:=" , "Cone1",
"Flags:=" , "",
"Color:=" , "(132 132 193)",
"Transparency:=" , 0,
"PartCoordinateSystem:=" , "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"vacuum\"",
"SolveInside:=" , True
])
Sample Script 5: Create a cone in IronPython
Note that the formatting, which helps readability immensely is not really needed. All that had to be
done was:

l Add the parentheses, since the VBScript subroutine omits them.


l Replace the Array( ) label and delimiters with brackets: [ ].
l Remove the Char(34) function, which introduced a double quote, and replace it with the
escaped double quote literal: \".
l Replace true with True.
l Remove the line continuation symbols: _ and the line breaks.

Introduction to Scripting 1-26


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Related Topics
Converting VBScript Function calls to IronPython Syntax
Named Array Values with All Key Value Pairs

While it is generally not allowed to replace the arrays and nested arrays with python dictionaries, in
the case where the named array consists entirely of key value pairs (like the following sample), one
can use a dictionary and avoid typing the trailing ":=" symbols after the keys. This further aids read-
ability of the script.
If the array consists of all key value pairs:

l Remove the trailing ":=" after each key


l Replace the "," after the key with a ":"
l If the named array is the top level argument, ensure that "NAME:name" is present and is
split into "NAME" : "name" as a key value pair
l Enclose the converted array in a pair of braces { } to declare the dictionary.
oEditor.CreateCone(
{
"NAME" : "ConeParameters",
"XCenter" : "0mm",
"YCenter" : "0mm",
"ZCenter" : "0mm",
"WhichAxis" : "Z",
"Height" : "2mm",
"BottomRadius": "1.56204993518133mm",
"TopRadius" : "0mm"
},
{
"NAME" : "Attributes",
"Name" : "Cone1",
"Flags" : "",
"Color" : "(132 132 193)",
"Transparency" : 0,
"PartCoordinateSystem": "Global",

Introduction to Scripting 1-27


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"UDMId" : "",
"MaterialValue" : "\"vacuum\"",
"SolveInside" : True
}
Sample Script 6: CreateCone in IronPython using dictionary syntax

Related Topics
Converting VBScript Function calls to IronPython Syntax
Named Arrays with Nested Named Arrays

l Split the "NAME:name" field into a key value pair


l Translate array key value pair to a dictionary key value pair.
l Create a new key with the name of the nested array and keep the nested array (as an array
or as a dictionary) as its value. If the nested array is being retained as an array, the"NAME:-
name" field should be retained in the array. If the nested array is being converted to a dic-
tionary, the name is optional: if also retained in the nested array, it must match the outer key.

[ "NAME:name",
"key1:=" , 1,
"key2:=" , 2,
["NAME:name2", "R:=", 255]
]
Sample Script 7: Named array with nested named array in array syntax

The above named array with a nested named array (after conversion to IronPython as named
array) can be converted to a dictionary as well. The dictionary can take any of the following forms
{ "NAME" : "name",
"key1" : 1,
"key2" : 2,
"name2" : ["NAME:name2", "R:=", 255]
}
Sample Script 8: Named array with nested named array as mixed dictionary + array

Introduction to Scripting 1-28


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

{ "NAME" : "name",
"key1" : 1,
"key2" : 2,
"name2" : {"R" : 255}
}
Sample Script 9: Named array with nested named array in all dictionary syntax

{ "NAME" : "name",
"key1" : 1,
"key2" : 2,
"name2" : {
"NAME" : "name2",
"R" : 255
}
}
Sample Script 10: Nested named array with optional "NAME:" field

Related Topics
Converting VBScript Function calls to IronPython Syntax
Function Blocks
Function blocks in VBScript argument syntax are represented as arrays without the "NAME:.."
field. However, functions are always introduced by a key in a parent structure. Function blocks can
therefore never exist as a top-level argument. They are only found as the value pairs inside a
named array or inside another function block.

Note:

Function blocks and their items cannot be converted to dictionaries even though they
might be composed entirely of key value pairs.

The reason for this is the need to main the user-entered order. Every item in a function block is
expect to be transmitted to the script method in exactly the same order as typed out and this is
impossible to achieve when a dictionary is used (as the keys get reordered according to the dic-
tionary's internal tree/key sorting scheme).

Introduction to Scripting 1-29


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Note:

When you see a function block, simply replace the Array( ) delimiters with the python
array delimiters [ ].

Related Topics
Converting VBScript Function calls to IronPython Syntax
Scripting Using Iron Python: Putting it all Together
If you have existing VBScript/Javascript scripts use existing scripts them as much as possible by
either embedding the test into the IronPython script or invoking them via the Run methods
described later in this chapter.
Translating a script in VBScript to IronPython
Read the chapter on translation and study the samples in that chapter as well as those in the
appendix. For python syntax and the differences, the mini-cookbook chapter will also be useful.
Writing an IronPython script from scratch
Read through the scripting guide available from the product's help menu and translate the
VBScript methods described to IronPython using the information provided in the chapter on trans-
lation. Studying the samples in the document will also prove helpful.
For python syntax and the differences, the mini-cookbook chapter will also be useful.
IronPython Script Execution Environment
Methods for Manipulating Registry Values
Scripting using Embedded VBScript or JavaScript
Scripting with IronPython
Standalone IronPython and Desktop IronPython

Related Topics
Introduction to IronPython
IronPython Mini-cookbook
Translating Script commands from VBScript to IronPython
Appendix: IronPython Samples
IronPython Script Execution Environment
Scripts written in IronPython are executed by desktop in four different ways:

Introduction to Scripting 1-30


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

l Tools> Open Command Window, to open the IronPython Command Window:

l Tools> Run Script menu item, select "IronPython" from the file type drop-down list.
l Launch the product with a script argument.
o HFSS -runscript someScript.py to keep HFSS GUI open after completing script exe-
cution.
o HFSS -features=beta -ng -runscriptandexit someScript.py to run HFSS in a non-
graphical mode and exit after script completion. Note that this is a beta feature sup-
ported for the HFSS and 3D Layout design types.
l Register an IronPython script as an external tool using the Tools> External Tools menu
item.

When desktop executes a script, it does so in an execution environment setup with predefined vari-
ables and functions. These predefined variables and functions are how the script communicates
with the desktop, and they come in four flavors addressed in the following subtopics:
Script Argument for IronPython
Script Objects for IronPython
Methods for IronPython
Methods for Manipulating Registry Values
Script Argument for IronPython

When scripts are launched using the Tools > Run Script menu item, the dialog that pops up
allows the user to specify arguments.

Introduction to Scripting 1-31


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Figure 1: Run Script dialog and script arguments


Any argument specified here is communicated to the script being executed as the predefined vari-
able ScriptArgument.

Related Topics
IronPython Script Execution Environment
Script Objects for IronPython

The Desktop script objects are available to every IronPython script being run. The names used fol-
low the same convention as with VBScript.

l oAnsoftApplication is the script object representing the entire application.


l oDesktop is the script object representing the desktop. While this can be obtained from the
oAnsoftApplication using oAnsoftApplication.GetAppDesktop(), since this is a very com-
monly used script object, it is always made available.

The use of these objects is done as per the individual product scripting guides with some syntax
adjustments made for the parameters to account for the IronPython differences.

Related Topics
IronPython Script Execution Environment
Methods for IronPython

A collection of methods is made available to all python scripts to enable the use of existing scripts
written in VBScript or Javascript. Additional utility methods to add messages to the desktop mes-
sage window are also present.

l AddErrorMessage(str), AddWarningMessage(str), AddInfoMessage(str) and


AddFatalMessage(str) this family of methods allows a script to add messages to the
product's message window. All methods take a python string.
l RunScriptFile(filename, arguments) runs the contents of the supplied file as a script. The
type of the script (Javascript/VBScript) is deduced from the file extension. Script arguments

Introduction to Scripting 1-32


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

are passed as a single string with individual arguments separated by spaces. Each argu-
ment can optionally be enclosed by quotes to allow spaces within the argument.
l SetScriptingLanguageToJavascript(), SetScriptingLanguageToVBScript() allows
the script to change the syntax of the language being used in the Run*Command commands
listed below. Once set, the language choice remains for the rest of the script execution or till
it is changed. The default is VBScript.
l RunScriptCommand(CommandString) runs the supplied script text. The language of the
text is controlled by a previous call to SetScriptingLanguageToJavascript() or SetScript-
ingLanguageToVBScript()
l RunDesktopCOmmand(CommandString) runs the supplied script text. The text is expec-
ted to generally be a single line and be a method call on a oDesktop object. The oDesktop
object is initialized based on the supplied optional ProjectName Pparameter. If the Pro-
jectName parameter is not supplied, the active project is used.
l RunProjectCommand(CommandString,ProjectName=None, ProjectName=None)
runs the supplied script text. The oDesign object is initialized based on the supplied optional
parameters. If the ProjectName is not supplied, the active project is used to resolve the pro-
ject. If the DesignName is not supplied, the project’s active design or first design will be used
to resolve the oDesign object within the project.
l RunModuleCommand(CommandString,ModuleName, DesignName=None, Pro-
jectName=None) runs the supplied script text. The text is expected to be a single line and
be a method call on a oModule object. The design targeted is resolved using the supplied
optional DesignName and ProjectName parameters and the oModule object is initialized
using the supplied Module name on that resolved design.
l RunEditorCommand(CommandString, EditorName,DesignName=None, Pro-
jectName=None) runs the supplied script text. The text is expected to be a single line and
be a method call on a oEditor object. The design targeted is resolved using the supplied
optional DesignName and ProjectName parameters and the oEditor object is initialized
using the supplied Editor name on that resolved design.
l RunDefinitionManagerCommand(CommandString, ProjectName=None) runs the
supplies script text. The text is expected to be a single line and be a method call on a oDefin-
itionManager object. The oDefinitionManager object is created for the project specifie4d by
the optional ProjectName parameter.

Related Topics
IronPython Script Execution Environment

Introduction to Scripting 1-33


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Methods for Manipulating Registry Values

The ANSYS Registry is stored as an XML file format, file is located (by default) at C:\User-
s\<UserName>\Documents\Ansoft\<AnsysProductNameversion>\config\<PC_NAME>_user-
.XML. Most of the ANSYS product configuration information is stored in this XML file. So those six
methods allow a user to change the product configuration in VB-script or Python script.

l GetRegistryString("KeyPath") - returns the registry key string value, if successful.

Example:
value = oDesktop.GetRegistryString("Desktop/Act-
iveDSOConfigurations/HFSS")

l SetRegistryString (KeyPath", "string") - sets the registry key to the specified string
value.

Example:
oDesktop.SetRegistryString("Desktop/Act-
iveDSOConfigurations/HFSS", "Local")

l GetRegistryInt("KeyPath") - returns the registry key int value.

Example:
num = oDesktop.GetRegistryInt("Desktop/Set-
tings/ProjectOptions/HFSS/UpdateReportsDynamicallyOnEdits")

l SetRegistryInt("KeyPath", int) - Sets a registry key to a specified int value.

Example:
oDesktop.SetRegistryInt("Desktop/Set-
tings/ProjectOptions/HFSS/UpdateReportsDynamicallyOnEdits", 0)

l DoesRegistryValueExist("KeyPath") - returns a boolean true if a key exists, and false if


not.

Example:
bExist =oDesktop.DoesRegistryValueExist("Desktop/Act-
iveDSOConfigurations/HFSS")

l SetRegistryFromFile("FilePath") - full path to an Analysis Configuration File, which has


been exported from the HPC and Analysis Options panel.

Example:
oDesktop.SetRegistryFromFile("c:\\temp/test.acf")
Example for how to set the DSO & HPC analysis setup with Python script

Introduction to Scripting 1-34


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

1. In a PC start HFSS go to the DSO and HPC options dialog, create a setup name it as "test"
2. Export the setup to a file c:\tem\test.acf.
3. Copy the exported file to a target PC f:\temp\test.acf.
4. Run the following script.
#import the setup
oDesktop.SetRegistryFromFile("f:\\temp\\test.acf")
# Set Active Setup to "test"
oDesktop.SetRegistryString("Desktop/Act-
iveDSOConfigurations/HFSS", "test")
Scripting using Embedded VBScript or JavaScript
Since script recording is still done in VBScript and users are expected to have a significant col-
lection of VBScript or JavaScript assets, it is useful to continue to use existing script files and snip-
pets even when scripting in IronPython. The various Run<*>Command methods have been
designed for this purpose.
For instance: one can create a parameterized cone in HFSS by executing the following IronPython
script from the Tools>Run Script menu.
# assign the VBScript snippet obtained from a script recording from
HFSS to
# coneScript and replace the BottomRadius recorded value with botRa-
dius
coneScript = """Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject()
oProject.InsertDesign "HFSS", "HFSSPyTestDesign", "DrivenModal", ""
Set oDesign = oProject.SetActiveDesign("HFSSPyTestDesign")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")

Introduction to Scripting 1-35


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oEditor.CreateCone Array("NAME:ConeParameters", _
"XCenter:=", "0mm", "YCenter:=", "0mm", "ZCenter:=", "0mm",_
"WhichAxis:=", "Z", "Height:=", "2mm", _
"BottomRadius:=", "3mm", _
"TopRadius:=", "0mm"), Array("NAME:Attributes", "Name:=", _
"Cone1", "Flags:=", "", "Color:=", "(132 132 193)", "Trans-
parency:=", 0, _
"PartCoordinateSystem:=", "Global", "UDMId:=", "", "Mater-
ialValue:=", _
"" & Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=", _
true)
"""

SetScriptingLanguageToVBScript()
RunScriptCommand(coneScript)
Sample Script 11: Hybrid VBScript + IronPython scripting: parameterized Cone Creation
Even though recorded VBScript is used for scripting, the incremental functionality that is provided
using IronPython is the ability to write a GUI using IronPython/.NET, collect information from the
user and then modify or generate the VBScript commands to actually script the ANSYS EM
desktop. This GUI functionality is cross platform and a significant positive. The following example
demonstrates a contrived use of a .NET window form to display the argument supplied to the
IronPython script (via the ScriptArgument variable).

#import the CLR references


import clr
clr.AddReference("System.Windows.Forms")

from System.Windows.Forms import Application, Form, Label, Button,


DockStyle

# the GUI form to show some text


# the class below derives from From (System.Windows.Forms.Form)
# imported above from the .NET assembly.
class ShowPropertiesForm(Form):

Introduction to Scripting 1-36


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

def __init__(self, name, text):


self.Name = name
self._label = Label()
self._label.Text = text
self._label.Dock = DockStyle.Fill

_button = Button()
_button.Text = "Close"
_button.Dock = DockStyle.Bottom
_button.Click += self._buttonPressed

self.Controls.Add(self._label)
self.Controls.Add(_button)

def _buttonPressed(self,sender,args):
self.Close()

#----------------------------------------------------
# Main script code
#----------------------------------------------------
#display the ScriptArgument variable as the text label
# in the form.
gui = ShowPropertiesForm("Sample Form", ScriptArgument)

# This makes it a modal dialog.


gui.ShowDialog()

# the following will make it a non-modal dialog


#Application.Run(gui)
Sample Script 12: Demonstrates the use of a .NET form from IronPython

Introduction to Scripting 1-37


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

While creating cross platform user interfaces from scripts is one of the main motivations driving the
adoption of IronPython, any .NET assembly can be used with the caveat that Linux use requires
Mono compatibility of any used assemblies.
While this hybrid approach is useful when you have existing VBScript commands that you want to
reuse or when you want to quickly parameterize a recorded sample, the one significant limitation of
this approach is the inability to capture return values from VBScript or JavaScript calls that do
return something. Full two way communication with the product requires the use of pure
IronPython to directly invoke the script objects as described below.

Related Topics
IronPython Script Execution Environment
Scripting with IronPython
While this section talks about directly interacting with the script objects, note that you can execute
VBScript or Javascript at any point using any of the available Run*Command functions. using your
existing script assets in this fashion and mixing with IronPython code for new functionality as
needed is a viable and option.
Access to the application scripting objects is provided via the predefined oDesktop object (as listed
in Script Objects). Interacting with the script objects is very natural, method calls are made just like
in VBScript except that the argument syntax is somewhat simplified to follow natural Python syn-
tax. All primitive types (string, integer, double) map to the natural primitive types in python. The only
differences from the VBScript syntax are seen when specifying array type arguments. The dif-
ferences are described in earlier chapters.

Note:

The typical VBScript calls to obtain the registered COM scripting interface via CreateOb-
ject calls and then obtain the oDesktop object from it using the GetAppDesktop() is not
needed (or even supported on all platforms). Since all scripting occurs in the context of a
running workbench, the available Desktop object is always provided and expected to be
used directly.

Scripting using the IronPython scripting API is very much like scripting with VBScript except that

l Any argument is supplied via the built in ScriptArgument variable


l The oDesktop object is always available
l The scripting method names are identical to the ones used with VBScript
l Method calls, while the name is the same have to adhere to the rule of ensuring trailing par-
entheses irrespective of whether the function returns anything or has any arguments.
l Any compound/block arguments should be translated to the appropriate IronPython array or
dictionary syntax.

Introduction to Scripting 1-38


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

The samples section lists a collection of pure IronPython snippets: these, along with the various
script snippets listed in this document should serve as a guide and reference.

Related Topics
IronPython Script Execution Environment
Standalone IronPython and Desktop IronPython
Standalone IronPython
In general, it is easier to run a script directly from Electronics Desktop. Standalone IronPython does
not implement all the functionality available when a script is run from Electronics Desktop. It only
implements full support for COM functions.
Running Standalone IronPython

Standalone IronPython uses COM to get the handle to the AnsysEDT app. To run standalone
IronPython, you’ll need to call the IronPython interpreter ipy64.exe.
It is located in:
\\<AnsysEDTInstallationPath>\common\IronPython\ipy64.exe
For example, to run myScript.py, type the following in the command line:
"C:\Program Files\An-
sysEM\AnsysEM20.2\Win64\common\IronPython\ipy64.exe"
"<filePath>\myScript.py"
You can set the interpreter to be the default program when double-clicking the .py script. You can
use any recorded script as the basis for a standalone script and simply add an installation-internal
path to the python module search path (as shown below) and end the script with a new shutdown
call.
Using a Recorded Script

A python script recorded in AnsysEDT already has the required lines to be run as a standalone,
except for the first two lines (path settings) and the final Shutdown() call. See the example script
below.
Creating an External Script

When creating a script outside of Electronics Desktop, the following lines should be included at the
beginning of your script:
l import sys

# Imports the sys module containing system-specific functions native to IronPython.

Introduction to Scripting 1-39


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

l sys.path.append("<InstallationPath>")

# Adds the Electronics Desktop installation path to the list of directories Python searches for
modules and files.

l sys.path.append("<InstallationPath>/PythonFiles/DesktopPlugin")

# Adds the PythonFiles/DesktopPlugin subfolder to the list of directories Python searches


for modules and files.

l import ScriptEnv

# This imports ScriptEnv.py from the installation path specified above. ScriptEnv.py per-
forms an operating system check and defines functions used in Electronics Desktop scripts.
See the annotations in the ScriptEnv.py file for more information.

l ScriptEnv.Initialize("Ansoft.ElectronicsDesktop")

or ScriptEnv.InitializeNew(NonGraphical=True)

# Initialize and InitializeNew are functions within ScriptEnv.py. The first option
launches Electronics Desktop. The second allows you to run a script without launching
Electronics Desktop. See the annotations in the ScriptEnv.py file for more information.

You must end the script with:


l ScriptEnv.Shutdown()

# This stops ScriptEnv.py. If you are running multiple scripts, include this only at the end of
the last script.
Example Script

import sys
sys.path.append(r"C:\Program Files\AnsysEM\AnsysEM20.2\Win64")
sys.path.append(r"C:\Program Files\An-
sysEM\AnsysEM20.2\Win64\PythonFiles\DesktopPlugin")

import ScriptEnv
ScriptEnv.Initialize("Ansoft.ElectronicsDesktop")
oDesktop.RestoreWindow()
oProject = oDesktop.NewProject()
oProject.InsertDesign("HFSS", "HFSSDesign1", "DrivenModal", "")

Introduction to Scripting 1-40


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oDesign = oProject.SetActiveDesign("HFSSDesign1")
oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.CreateRectangle(
[
"NAME:RectangleParameters",
"IsCovered:= ", True,
"XStart:= ", "-0.2mm",
"YStart:= ", "-3mm",
"ZStart:= ", "0mm",
"Width:= ", "0.8mm",
"Height:= ", "1.2mm",
"WhichAxis:= ", "Z"
],
[
"NAME:Attributes",
"Name:= ", "Rectangle1",
"Flags:= ", "",
"Color:= ", "(132 132 193)",
"Transparency:= ", 0,
"PartCoordinateSystem:=", "Global",
"UDMId:= ", "",
"MaterialValue:= ", "\"vacuum\"",
"SolveInside:= ", True
])
oDesign.SetDesignSettings(['NAME:Design Settings Data', 'Allow Mater-
ial Override:=', True, 'Calculate Lossy Dielectrics:=', True])
oEditor.SetModelUnits(['NAME:Units Parameter', 'Units:=', 'mil',
'Rescale:=' , False ])
ScriptEnv.Shutdown()
IronPython Samples

Introduction to Scripting 1-41


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Change property

The following snippets show how a change property command (in this case, to change the color of
a cone) looks in VBScript and its two possible IronPython variants.
oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geo-
metry3DAttributeTab",_
Array("NAME:PropServers", "Cone1"), _
Array("NAME:ChangedProps", _
Array("NAME:Color", "R:=", 255, "G:=", 255, "B:=", 0))))
Sample Script 13: ChangeProperty command to change color of a cone in VBScript
oEditor.ChangeProperty(
["NAME:AllTabs",
["NAME:Geometry3DAttributeTab",
["NAME:PropServers", "Cone1"],
["NAME:ChangedProps",
["NAME:Color", "R:=", 0, "G:=", 0, "B:=", 64]
]
]
])
Sample Script 14: ChangeProperty command to change color of cone using Python
arrays
Any time there are named arrays composed purely of key-value pairs, they can always be rep-
resented using a Python dictionary, irrespective of the nesting of said named array.
oEditor.ChangeProperty(
["NAME:AllTabs",
["NAME:Geometry3DAttributeTab",
["NAME:PropServers", "Cone1"],
["NAME:ChangedProps",
{
"NAME":"Color",
"R" : 0,
"G" : 64,
"B" : 0

Introduction to Scripting 1-42


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

}]]
])
Sample Script 15: ChangeProperty command to change the color of a cone using
Python arrays and dictionaries

Create a Cone using IronPython

Most scripting tasks using IronPython are expected to be formatted as the following example. One
starts with the predefined oDesktop object and drills down to the design, editors, modules etc and
issues any required commands on the object while formatting the script command arguments in nat-
ural python syntax.
oProject = oDesktop.GetActiveProject()
oDesign = oProject.InsertDesign("HFSS","Random","DrivenModal","")
oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.CreateCone(
{
"NAME" : "ConeParameters",
"XCenter" : "0mm",
"YCenter" : "0mm",
"ZCenter" : "0mm",
"WhichAxis" : "Z",
"Height" : "2mm",
"BottomRadius" : "1.56204993518133mm",
"TopRadius" : "0mm"
},
{
"NAME" : "Attributes",
"Name" : "Cone1",
"Flags" : "",
"Color" : "(132 132 193)",
"Transparency" : 0,
"PartCoordinateSystem": "Global",
"UDMId" : "",

Introduction to Scripting 1-43


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"MaterialValue" : "\"vacuum\"",
"SolveInside" : True
}
)
Sample Script 16: IronPython script to create a cone
Create geometry and then create a grid from it using copy/paste/move
The following script demonstrates slightly more advanced use of scripting and the use of return val-
ues from script methods. It creates a 5x5 grid of cones and also demonstrates the adding of inform-
ation messages to the application's message window.
oProject = oDesktop.GetActiveProject()
oDesign = oProject.InsertDesign("HFSS","Hersheys Kis-
ses","DrivenModal","")
oEditor = oDesign.SetActiveEditor("3D Modeler")

# create the first cone


AddInfoMessage("Creating first cone")
firstConeName = "firstCone"
coneBotRad = "1.5mm"
oEditor.CreateCone(
{
"NAME" : "ConeParameters",
"XCenter" : "0mm",
"YCenter" : "0mm",
"ZCenter" : "0mm",
"WhichAxis" : "Z",
"Height" : "2mm",
"BottomRadius": coneBotRad,
"TopRadius" : "0mm"
},
{
"NAME" : "Attributes",

Introduction to Scripting 1-44


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Name" : firstConeName,
"Flags" : "",
"Color" : "(132 132 193)",
"Transparency" : 0,
"PartCoordinateSystem": "Global",
"UDMId" : "",
"MaterialValue" : "\"vacuum\"",
"SolveInside" : True
}
)

# Now replicate this a few times and create an array out of it


AddInfoMessage("Replicating it 24 times")
for x in range(5):
for y in range(5):
# leave the first one alone in it's created
# position
if x == 0 and y == 0:
continue

# all other grid positions, replicate from the


# first one

# copy first
oEditor.Copy(
{
"NAME" : "Selections",
"Selections" : firstConeName
}
)

Introduction to Scripting 1-45


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

# paste it and capture the pasted name


# the pasted names come in an array as we could
# be pasting a selection cmposed of multiple objects
pasteName = oEditor.Paste()[0]

# now move the pasted item to it's final position


oEditor.Move(
{
"NAME" : "Selections",
"Selections" : pasteName
},
{
"NAME" : "TransalateParameters",
"CoordinateSystemID" : -1,
"TranslateVectorX" : "%d * 3 * %s" % (x, coneBotRad),
"TranslateVectorY" : "%d * 3 * %s" % (y, coneBotRad),
"TranslateVectorZ" : "0mm"
}
)

# Now fit the display to the created grid


oEditor.FitAll()
Sample Script 17: Sample script to create a cone and then use copy/paste/move to rep-
licate it.

Related Topics
Introduction to IronPython
IronPython Mini-cookbook
Translating Script commands from VBScript to IronPython
Scripting Using Iron Python: Putting it all Together

Introduction to Scripting 1-46


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Creating User Defined Primitives and User Defined Models in Python


Scripts
You can create User Defined Primitives and User Defined Models in Python scripts (based on the
IronPython implementation).
Advantages Compared to C++

l No need to create and build project; all you need to do is create a Python script
l Python script is platform independent
l Scripts can inherit functionality from existing scripts
l Garbage collector - no need to free memory
l Easy debugging
Changes compared to C

Though methods, constants and structures are kept as close to the C implementation as possible,
some changes had to be made to make code Python-compatible.
Structures

l Structures have the same names as in C implementation.


l Structures fields names are capitalized.
l Arrays in structures become lists in Python (Technically a.NET IList container)
l Structure instances are created using the supplied constructors and members are accessed
using the provided access methods.

For a complete list of structures and examples please see UDP/UDM Structures.

Constants

Enumeration/Enum constants have almost the same names as in C but the enum must be qualified
by the type. Additionally, redundant "UDP", "UDM" or type prefixes have been removed. This
allows for better human-readability.
# Example of specifying the LengthUnit enum by qualifying it
# with the type of the enum: UnitType
unitType = UnitType.LengthUnit
For a complete list of enum constants please see UDP/UDM Constants.
Methods

Methods are described in IUDPExtension methods, IUDMExtension methods, UDPFunc-


tionLibrary and UDMFunctionLibrary listed further in this document.
The main differences in functions parameters (from C implementation):

Introduction to Scripting 1-47


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

l functions names in UDPFunctionLibrary and UDMFunctionLibrary are capitalized


l arrays become a python list of objects
l void * callback parameter is dropped from the parameter list
l output parameters (pointer types that are filled during the function call) usually become
return values
l 'list size' parameter usually will be omitted as redundant
Output Parameters

The rule for the output parameters is as follows:

l If the function has one output parameter variable and no return value, the variable will
become function's return value.The same will happen if the return value is a 'success/failure'
boolean ('None' will be returned on failure and parameter variable - on success).
l If the function has one output parameter and a return value, the function will return a Python
tuple where function return value will be the first one in the tuple.
l If there is more than one out variable, the function will return a Python tuple with all output
parameters in the specified order. If function has a return value, it must always be the first in
the tuple.
# one output parameter; return value is ignored
udmDefinition = udmFunctionLibrary.GetDefinition()

# one output parameter; return value must be preserved. return


# and output values are packed into the return tupe, in order
(lRet, partIdsList) = udpFunctionLibrary.DetachFaces(nPartIds,
faceIdsList)
# Two output parameter; return value must be preserved
# the return tuple is (returnVal, output1, output2)
(bRet, udpPositionLow, udpPositionHigh) = udmFunc-
tionLibrary.GetBoundingBox(partId,exact);
Comparison with C function:

C Python
bool getDefinition(UDMDefinition* udmDefinition = udmFunctionLibrary.GetDefinition()
udmDefinition,
void* callbackData );
(Note: callbackData is omitted in py interface)

Introduction to Scripting 1-48


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

C Python
where udmDefinition is an output
parameter

long detachlFaces( int (bRet, partIds) = udmFunctionLibrary.DetachlFaces


nFacesAndPartIds, (nFacesAndPartIds, faceIds)
long* faceIds,
long* partIds, (Note: callbackData is omitted in py interface)
void* callbackData);

where partIds is an output para-


meter

'List Size' Parameters

The rule for the 'list size' is as follows:

l If function has input 'List' parameter and input 'list size' parameter, 'list size' parameter will be
omitted.
l If function has output 'List' parameter and output 'list size' parameter, 'list size' parameter will
be omitted.
l If function has output 'List' parameter and input 'list size' parameter, 'list size' parameter
won't be omitted as it's needed for memory allocation in the corresponding C++ function
from the UDP/UDM function library.

Example:
# input list, input list size
lret = udpFunctionLibrary.Unite(objectIds)

# output list, output list size


faceIdList = udmFunctionLibrary.GetAllFaces(PartId)

# output list, input list size


(lret, partIdList) = udpFunctionLibrary.DetachFaces(listSize,
faceIdList)

Introduction to Scripting 1-49


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Comparison with C function:

C Python
bool getAllFaces(  long partId, faceIds = udmFunc-
tionLibrary.GetAllFaces(partId)
long* numFaces,
long** faceIds,
void* callbackData);
(ignore numFaces as redundant: folded
into faceIds,
where numFaces and faceIds are output parameters return value is omitted: folded into the
and numFaces is the size of faceId. faceIds is None check
callbackData is omitted)
long unite(  long numObjects, lret = udpFunctionLibrary.Unite
(objectIds)
long* objectIds,
void* callbackData);

(ignore numObjects as redundant: fol-


where numObjects and objectIds are input parameters ded into objectIds
and numObjects is the size of objectIds.
callbackData is omitted)
long detachFaces(  long nSize, (lret, partIdList) = udpFunc-
tionLibrary.DetachFaces(nSize,
long* faceIds, faceIds)
long* partIds,
void* callbackData);

(nSize is not ignored,


where partIds is and output list and nSize is an input callbackData is omitted)
parameters and nSize is the size of partIds.

Added Parameters

There is a special case in UDPFunctionLibrary: two functions - DuplicateAlongLine and Duplic-


ateAroundAxis - have new integer listSize parameter added to their signatures.
This parameter defines the size of the output List. This is done for compliance with C++ geometry
library as the size of the List must be predefined and this size is different from the existing para-
meter’s values.
Example:
(ret, cloneIDs) = funcLib.DuplicateAlongLine(partID, transVec,
numCubes, cloneIdsSize)

Introduction to Scripting 1-50


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

(ret, cloneIDs) = funcLib.DuplicateAroundAxis(partID, axis, angle,


nClones, cloneIdsSize)
Here cloneIdsSize is a new integer parameter.
Comparison with C function:

C Python
long duplicateAlongLine(  (lret, cloneIds) = udmFunctionLibrary.DuplicateAlongLine(partId,
long partId, transVec, nClones, cloneIdsSize)
UDPVector transVector,
int nClones,
long* nClones, (callbackData is omitted
void* callbackData); cloneIdsSize is a new parameter)
long duplicateAroundAxis(  (lret, cloneIds) = udmFunctionLibrary.DuplicateAroundAxis(partId,
axis, angle, nClones, cloneIdsSize)
long partId,
UDPCoordinateSystemAxis
axis,
double angle, (callbackData is omitted
int nClones, cloneIdsSize is a new parameter)
long* nClones,
void* callbackData);

Developing a UDM/UDP

Creation

To create a User Defined Primitive in Python you write a Python script that implements UDPEx-
tension class. To create a User Defined Model in Python you write a Python script that implements
UDMExtension class (see links for full description).

Location

The scripts are located the same way the C based UDM/UDP are. They are expected to be under
the UserDefinedParts or UserDefinedModels sub-directories of one of the library folders (SysLib,
UserLib or PersonalLib). They will then appear under the appropriate menu items: Draw>User
Defined Primitives for UDP or Draw>User Defined Model for UDM.
The sub-directories structure created in one of the specified directory will be displayed in the
UDP/UDM menu.

Introduction to Scripting 1-51


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Keep in mind that there is no difference between the menu display for C and Python imple-
mentations of UDM or UDP - only the file names without extensions are displayed

Organize

"Lib" sub-directory is a special directory. The contents of this directory is not shown in the menu. In
the "Lib" directory you can create Python scripts with base classes and utilities to be used in
UDP/UDM Python scripts. All the Lib directories upstream of a script (till the UserDefinedModels or
UserDefinedPrimitives) are included in the Python search path and this allows for easy import of
helper modules in such directories.
To use UDM data structures, constants, and/or classes in your Lib sub-directory scripts you have to
add import statement to the scripts:
For UDM:extension:
from UDM import *
For UDP:extension:
from UDP import *

Edit/Reload

Python is a scripting language, so if you have errors in your script, you will see them at the time you
try to run the script. The errors will be displayed in the Message Manager Window. If you need
more information, you might be able to get it from log files. See Logging section for more details.
You can always change your script, call Update Menu command from Draw>User Defined
Model> menu or Draw>User Defined Primitives> menu and run the script again. If you delete
script you might want to restart the application instead of calling Update Menu.
UDPExtension

Import

You do not have to add import statements for the predefined classes, structures, and constants - it
is done for you and all data types described in this document can be used in your Python script.
However you have to add import statements to your helper scripts in your Lib sub-directory.
from UDP import *

Main class: UDPExtension

You must write a class derived from IUDPExtension with a mandatory name UDPExtension:
class UDPExtension(IUDPExtension):
The class should implement IUDPextension methods described below.

Introduction to Scripting 1-52


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

IUDPExtension methods

All methods are same as the methods in the C UDP implementation. The changes to the methods
signatures are just to conform to the Python style.

Mandatory methods.

These methods must be implemented in the UDP Python script as methods of UDPExtension
class.

GetLengthParameterUnits()

l returns string.

GetPrimitiveTypeInfo()

l returns UDPPrimitiveTypeInfo.

GetPrimitiveParametersDefinition2()

l returns a list of UDPPrimitiveParameterDefinition2 or None on failure

AreParameterValuesValid2(errorMsg, udpParams)

l errorMsg is a c# list of strings


l udpParams is a c# list of UDPParam
l returns True if udpParams are valid, False otherwise.

CreatePrimitive2(funcLib, udpParams)

l funcLib is UDPFunction library


l udpParams is a c# list of UDPParam
l returns True on success, False on failure.

Optional methods

These methods, which have default implementations, can be implemented as methods of UDPEx-
tension class as needed. Default methods will return NULL or FALSE depending on the return
type.

GetPrimitiveParameters()

l returns Python list of strings or NULL

Introduction to Scripting 1-53


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetRegisteredFaceNames()

l returns Python list of strings or NULL

GetRegisteredEdgeNames()

l returns Python list of strings or NULL

GetRegisteredVertexNames()

l returns Python list of strings or NULL

ProjectParametersOnToValidPlane2(currentUDPParams, projectedUDPParams)

l currentUDPParams is a list of UDPParam


l projectedUDPParams is a list of UDPParam
l returns True on success, False on failure.

MapParametersDefinitionVersions2(oldVersion, oldUDPParams)

l oldVersion is a string
l oldUDPParamsis a list of UDPParam
l returns Python list of UDPParam or NULL

GetOldPrimitiveParametersDefinition2(version )

l version is a string
l returns a list of UDPPrimitiveParameterDefinition2 or None on failure.
Example UDP

import sys
class UDPExtension(IUDPExtension):

def GetLengthParameterUnits(self):
return "mm"

def GetPrimitiveTypeInfo(self)
typeInfo = UDPPrimitiveTypeInfo(
name = "SampleUDP",

Introduction to Scripting 1-54


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

purpose = "example",
company="ANSYS",
date="12.21.12",
version = "1.0")

return typeInfo
...
...
For the full example, see Example Scripts for Python UDP and UDM.
UDPFunctionLibrary

UDPFunctionLibrary implements IUDPFunctionLib interface: The IUDPFunctionLib object is


passed as a parameter to Python script in functions CreatePrimitive2. You can call any of the func-
tions from the functions list (shown below).
udpFunctionLib.AddMessage(MessageSeverity.WarningMessage ,"New warn-
ing");
Considering that out variables are returned as members of the return tuple, sample code that calls
DetachFaces in Python script can look like this:
intVal = 10
inList = [..., ...]
(lret, outList) = udpFunctionLibrary.DetachFaces(intVal, inList)
As you can see outList output parameter is defined in the call to DetachFaces function. Unlike in C,
there is no need to define it before the function call.

Functions list:

1. bool: bret = AddMessage(MessageSeverity: messageSeverity, string: message)


2. int: iret = NameAFace(UDPPosition: pointOnFace, string: faceName)
3. int: iret = NameAEdge(UDPPosition: pointOnEdge, string: edgeName)
4. int: iret = NameAVertex(UDPPosition: pointOnVertex, string: vertexName)
5. int: iret = GetFaceIDFromPosition(UDPPosition: pointOnFace)
6. int: iret = GetEdgeIDFromPosition(UDPPosition: pointOnEdge)
7. int: iret = CreatePolyline(UDPPolylineDefinition: polylineDefinition)
8. int: iret = CreateRectangle(CoordinateSystemPlane: whichPlane, UDPPosition:
centerPoint, List_of_double: widthAndHeight, int: isCovered)

Introduction to Scripting 1-55


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

9. int: iret = CreateArc(CoordinateSystemPlane: whichPlane, UDPPosition: centerPoint,


UDPPosition: startPoint, double: fAngle)
10. int: iret = CreateCircle(CoordinateSystemPlane: whichPlane, UDPPosition: center-
Point, double: fRadius, int: isCovered)
11. int: iret = CreateEllipse(CoordinateSystemPlane: whichPlane, UDPPosition: center-
Point, double: fMajorRadius, double: fRadiusRatio, int: isCovered)
12. int: iret = CreateRegularPolygon(CoordinateSystemPlane: whichPlane, UDPPos-
ition: centerPoint, UDPPosition: startPoint, int: numOfSides, int: isCovered)
13. int: iret = CreateEquationBasedCurve(UDPEquationBasedCurveDefinition:
curveDefinition)
14. int: iret = CreateEquationBasedSurface(UDPEquationBasedSurfaceDefinition: sur-
faceDefinition)
15. int: iret = CreateSpiral(UDPSpiralDefinition: spiralDefinition)
16. int: iret = CreateBox(UDPPosition: startPoint, List_of_double: boxXYZsize)
17. int: iret = CreateSphere(UDPPosition: centerPoint, double: fRadius)
18. int: iret = CreateCylinder(CoordinateSystemAxis: whichAxis, UDPPosition: center-
Point, double: fRadius, double: fHeight)
19. int: iret = CreateCone(CoordinateSystemAxis: whichAxis, UDPPosition: centerPoint,
double: fBottomRadius, double: fTopRadius, double: fHeight)
20. int: iret = CreateTorus(CoordinateSystemAxis: whichAxis, UDPPosition: centerPoint,
double: fMajorRadius, double: fMinorRadius)
21. int: iret = CreatePolyhedron(CoordinateSystemAxis: whichAxis, UDPPosition: center-
Point, UDPPosition: startPosition, int: numOfSides, double: fHeight)
22. int: iret = CreateHelix(UDPHelixDefinition: helixDefinition)
23. int: iret = Unite(List_of_int: pObjectIDArray)
24. int: iret = Subtract(List_of_int: pBlankObjectIDArray, List_of_int: pToolObjectIDArray)
25. int: iret = Intersect(List_of_int: pObjectIDArray)
26. int: iret = Imprint(List_of_int: pBlankObjectIDArray, List_of_int: pToolObjectIDArray)
27. int: iret = SweepAlongVector(int: profileID, UDPVector: sweepVector, UDPSweep-
Options: sweepOptions)
28. int: iret = SweepAroundAxis(int: profileID, CoordinateSystemAxis: whichAxis,
double: sweepAngle, UDPSweepOptions: sweepOptions)
29. int: iret = SweepAlongPath(int: profileID, int: pathID, UDPSweepOptions: sweep-
Options)

Introduction to Scripting 1-56


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

30. int: iret = Translate(int: partID, UDPVector: translateVector)


31. int: iret = Rotate(int: partID, CoordinateSystemAxis: whichAxis, double: rotateAngle)
32. int: iret = Mirror(int: partID, UDPPosition: mirrorPlaneBasePosition, UDPVector: mir-
rorPlaneNormalVector)
33. int: iret = Transform(int: partID, List_of_double: rotationMatrix, UDPVector: trans-
lateVector)
34. int: iret = Scale(int: partID, double: xScale, double: yScale, double: zScale)
35. (int: lret, List_of_double: cloneIDs) = DuplicateAlongLine(int: partID, UDPVector:
translateVector, int: numTotalObjs, int: cloneIDsListSize)
36. (int: lret, List_of_double: cloneIDs) = DuplicateAroundAxis(int: partID, Coordin-
ateSystemAxis: whichAxis, double: rotateAngle, int: numTotalObjs, int: cloneIDsListS-
ize)
37. int: iret = DuplicateAndMirror(int: partID, UDPPosition: mirrorPlaneBasePosition,
UDPVector: mirrorPlaneNormalVector)
38. int: iret = Connect(List_of_int: objectIDArray)
39. int: iret = Offset(int: partID, double: offsetDistance)
40. int: iret = Section(int: partID, CoordinateSystemPlane: sectionPlane)
41. (int: iret , int: newPartID) = Split(int: partID, CoordinateSystemPlane: splitPlane,
SplitWhichSideToKeep: whichSideToKeep, bool: bSplitCrossingObjectsOnly)
42. (int: iret , List_of_int: importedObjectIDs) = ImportNativeBody2(string:
fileNameWithFullPath)
43. (int: lret, List_of_int: importedObjectIDs) = ImportAnsoftGeometry(string:
fileNameWithFullPath, List_of_string: overridingParamsNameArray, List_of_
UDPParam: overridingParamsArray)
44. int: iret = Clone(int: partID)
45. int: iret = DeletePart(int: partID)
46. int: iret = CreateObjectFromFace(int: faceID)
47. int: iret = Fillet(UDPBLNDElements: entitiesToFillet, UDPBLNDFilletOptions: fil-
letOptions)
48. int: iret = Chamfer(UDPBLNDElements: entitiesToChamfer, UDPBLNDCham-
ferOptions: chamferOptions)
49. (int: iret , List_of_int: newPartIDArray) = DetachFaces(int: newPartIDArraySize, List_
of_int: faceIDArray)

Introduction to Scripting 1-57


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

50. (int: iret , List_of_int: newPartIDArray) = DetachEdges(int: newPartIDArraySize, List_


of_int: edgeIDArray)
51. int: iret = CreateObjectFromEdge(int: edgeID)
52. int: iret = SheetThicken(int: partID, double: fThickness, bool: bThickenBothSides)
53. (int: iret , List_of_int: newPartIDArray) = SweepFaceAlongNormal(int: newPartIDAr-
raySize, List_of_int: faceIDArray, double: sweepLength)
54. int: iret = CoverLine(int: partID)
55. int: iret = CoverSurface(int: partID)
56. int: iret = UncoverFaces(List_of_int: faceIDArray)
57. (int: iret , int: numPartsCreated, List_of_int>: faceIDArray) = SeparateBodies(int: partID,
int: numPartsCreated)
58. int: iret = MoveFaces(List_of_int: faceIDArray, bool: bMoveAlongNormal, double: fOff-
setDistance, UDPVector: moveVector)
59. int: iret = WrapSheet(int: sheetBodyID, int: targetBodyID)
60. int: iret = ImprintProjection(int: blankBodyID, List_of_int: toolBodyIDArray, bool:
bNormalProjection, UDPVector: projectDirection, double: projectDistance)
61. string: str = GetTempDirPath()
62. string: str = GetSysLibDirPath()
63. string: str = GetUserLibDirPath()
64. string: str = GetPersonalLibDirPath()
65. string: str = GetInstallDirPath()
66. string: str = GetProjectPath()
67. (bool: bret, bool: abort) = SetProgress(UDPProgress: progress)

UDMExtension
Import

You do not have to add import statements for the predefined classes and structures - it is done for
you, and all data types described in this document can be used in your Python script.
However you have to add import statements to your helper scripts in your Lib sun-directory.
from UDM import *
Main class: UDMExtension

You must write a class derived from IUDMExtension with a mandatory name UDMExtension:
class UDMExtension(IUDMExtension):
The class should implement IUDMExtension methods described below.

Introduction to Scripting 1-58


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

IUDMExtension methods

All methods are the same as the methods in the C UDM implementation. The changes to the meth-
ods signatures are just to conform to the Python style.

Mandatory methods.

These methods must be implemented in the UDM Python script as methods of UDMExtension
class.

GetInfo()

l returns UDMInfo object populated with appropriate UDM information.

IsAttachedToExternalEditor()

l returns True if UDM dll is attached to external editor.


l In case of python UDMs, this should typically return False

CreateInstance(funcLib)

l funcLib is UDMFunctionLibrary
l returns UDMParameters.

GetUnits(instanceId)

l instanceId is a long
l returns string containing units for the instance.

Refresh(funcLib, udmInParams, updatedParams, refreshModifiedPartsOnly,


nonEditedPartRefIds )
This Method is called every time a UDM is refreshed. Geometry creation/refresh should happen in
this method.

l funcLib is UDMFunctionLibrary
l udmInParams is a list of UDMParameters that comes from desktop
l updatedParams: UDM script can change the UDM parameters it receives. Updated para-
meters need to be sent back to desktop. If the UDM script is not going to change any of the
parameters that it received, it needs to copy udmInParams to updatedParams.
l refreshModifiedPartsOnly is a boolean

Supporting this flag is optional. For UDMs where the refresh performance is not an issue, it
is recommended to ignore this flag and update all parts every time.

Introduction to Scripting 1-59


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

This flag can be used to optimize performance of Refresh method when the model created
by UDM is large. If the UDM consists of multiple parts, and new parameters change only a
few parts amongst them, UDM script can only modify parts that are changed by the new
parameters.

l nonEditedPartRefIds: If RefreshModifiedPartsOnly is true and the UDM script supports par-


tial update, Refresh method needs to return ids of parts that are unchanged.

returns True on success, False on failure.

ReleaseInstance(instanceId)

l instanceId is a long
l This should release any resources assigned to this particular instance of UDM.
l returns True on success, False on failure.

GetAttribNameForEntityId()

l Returns string that acts as a the name of the attribute containing entity IDs.
l For example, it can return a unique string such as "ATTRIB_XACIS_ID"
l Python UDMs should implement this method.

GetAttribNameForPartId()

l Returns string that acts as a the name of the attribute containing entity IDs.
l For example, it can return a unique string such as "ATTRIB_XACIS_ID" (Can be same as
GetAttribNameForEntityId())
l Python UDMs should implement this method.

Optional methods

These methods have default implementations (default is to return NULL or FALSE depending on
the return type) but can be overridden by the user as needed as methods of UDMExtension class.
DialogForDefinitionOptionsAndParams(self, defData, optData, params):
Replaces the old UDMDialogForDefinitionAndOptions method, which is still supported, but users
are urged to use UDMDialogForDefinitionOptionsAndParams. If both methods are present, applic-
ation will use UDMDialogForDefinitionOptionsAndParams.

l UDM can pop up dialog for UDM definition, options, parameters in this method. Definition,
options, and parameters are set/modified by user and returned to application. Dll can also
just give default definition, options and parameters.
l Returns two booleans and a string

Introduction to Scripting 1-60


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

l First boolean returns whether the method was successful or not.


l Second boolean returns whether the application should popup a dialog. If it is True, applic-
ation will populate a dialog with definition, options, parameters that are returned.
l String returned contains length units for parameters.
DialogForDefinitionAndOptions(self, defData, optData) [Deprecated]
UDM can pop up dialog for UDM definition and options in this method. Definition, and options are
set/modified by user and returned to application. Dll can also just give default definition and options.

l Returns two booleans.


l First boolean provides whether the call to this method was successful or not.
l Second boolean determines whether the application should pop up a dialog. If this is true,
application will populate the dialog with the definitions and options that are returned. As no
parameters are returned, no parameters are shown in this dialog.
GetInstanceSourceInfo(instanceId)

l instanceId is a long
l returns string containing source information of UDM instance. It is used to create initial name
for UDM instance.
ShouldAttachDefinitionFilesToProject()

l returns true if any of definition files needs to be attached to project


l returns python list of string containing definition names of files or NULL
Example UDM

class UDMExtension(IUDMExtension):

def IsAttachedToExternalEditor(self):
return False

def GetInfo(self)
udmInfo = UDMInfo(
name = "SampleUDM",
purpose = "udm example",
company="ANSYS",
date="12.21.12",
version = "1.0")

Introduction to Scripting 1-61


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

return udmInfo
...
...
UDMFunctionLibrary
UDMFunctionLibrary implements IUDMFunctionLib interface. The IUDMFunctionLib object is
passed as a parameter to Python script in the following functions

l CreateInstance
l Refresh

You can call any of the functions from the functions list (shown below).
partRefId = udmFunctionLib.GetPartRefId(partId)
For example sample code that calls GetBoundingBox in Python script can look like this:
partId = 10
exact = True
udpPosition = UDPPosition(0,0,0)

(bret, udpPositionLow, udpPositionHigh) = udmFunc-


tionLibrary.GetBoundingBox(partId, exact);

if bret:
udpPosition.X = udpPositionLow.X
As you can see udpPositionLow and udpPositionHigh output parameters are defined in the call to
GetBoundingBox function. There is no need to define them before the function call.

Functions list:

1. List_of_UDMDefinition: udmDefinitionList = GetDefinition()


2. List_of_UDMOption: udmOptionList = GetOptions()
3. bool: bret = SetMaterialName(string: matName, int: partId)
4. bool: bret = SetMaterialName2(string: matName, string: partName)
5. bool: bret = SetPartName(string: partName, int: partId)
6. int: iret = GetInstanceId()
7. string: str = GetPartRefId(int: partId)

Introduction to Scripting 1-62


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

8. bool: bret = SetPartRefId(int: partId, string: refId)


9. List_of_int: faceIds = GetAllFaces(int: partId)
10. List_of_int: edgeIds = GetAllEdges(int: partId)
11. List_of_int: vertexIds = GetAllVertices(int: partId)
12. bool: bret = SetFaceAttribs(List_of_int: faceIds, List_of_string: attribs)
13. bool: bret = SetEdgeAttribs(List_of_int: edgeIds, List_of_string: attribs)
14. bool: bret = SetVertexAttribs(List_of_int: vertexIds, List_of_string: attribs)
15. string: str = GetModelerUnit()
16. string: str = GetCacheFileForUDMResume()
17. bool: bret = SetPartColor(int: partId, int: nColor)
18. bool: bret = SetPartFlags(int: partId, int: nFlags)
19. (bool: bret, UDPPosition: low, UDPPosition: high) = GetBoundingBox(int: partId,
bool: exact)
20. bool: bret = IsParametricUpdate()
21. bool: bret = SetMaterialNameByRefId(string: partRefID, string: matName)
22. bool: bret = SetPartNameByRefId(string: partRefId, string: partName)
23. bool: bret = SetPartColorByRefId(string: partRefId, int: nColor)
24. bool: bret = SetPartFlagsByRefId(string: partRefId, int: nFlags)

In addition to the above functions all functions defined in the UDPFunctionLib are available in the
IUDMFunctionLib and can be called directly exactly the same way as the IUDMFunctionLib func-
tions.
Example:
udmFunctionLib.CreateCircle(center,radius,ratio,isCovered)
UDP/UDM Structures and constants
The following sections describe:

l UDP/UDM Structures
l UDP/UDM Constants

UDP/UDM Structures

Differences compared to C API

l UDMDefinition
l UDMOptions

Introduction to Scripting 1-63


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

l UDMParameters

Instead of containing arrays of data, the structures contain single fields where each field cor-
responds to an item in a different array from the original C API. The structure objects thus con-
structed are added to the Python list. Alternately the Python list can be initialized using the structure
objects.
Example (creating UDMParameter list):
udmParamList = [UDMParameter("cubeSizeName", UnitType.LengthUnit,
UDPParam(ParamDataType.Double, cubeSize),
ParamPropType.Value,
ParamPropFlag.MustBeReal),
UDMParameter("cubeDistanceName", UnitType.LengthUnit,
UDPParam(ParamDataType.Double, cubeDistance),
ParamPropType.Value,
ParamPropFlag.MustBeReal),
UDMParameter("numCubesName", UnitType.LengthUnit,
UDPParam(ParamDataType.Int, numCubes),
ParamPropType.Number,
ParamPropFlag.MustBeInt)]

l UDPParam
l UDPParamData

Data field in UDPParam is now an object - the same for all types of data used - as Python can work
with any type of data.
UDPParamData is obsolete, thus not implemented. Be sure to set proper data type to UDPPara-
m.DataType when setting UDPParam.Data.
Example:
nCubesParam = UDPParam(ParamDataType.Int, numCubes)
nCubes = nCubesParam.Data

distanceParam = UDPParam()
distanceParam.setDouble(10.5)
doubleDistance = distanceParam.Data * 2

l UDP3x3Matrix

Introduction to Scripting 1-64


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

The structure is not implemented. Use size 9 Python List of doubles instead.
Example:
rotationMatrix =[0,0,1, 1,0,0, 0,0,1]
udpFunctionLib.Transform(partId, rotationMatrix, translationVector)

List of structures

You can use constructors to create a structure. You can also modify fields - directly or by provided
methods.
Example:
pos1 = UDPPosition(1,2,3)
pos2 = UDPPosition(x=1,y=10,z=0)
pos2.Z = pos1.Z

udpParam = UDPParam(ParamDataType.Double,1)
value = udpParam.Data

Structure Construction Members


UDPPrimitiveTypeInfo UDPPrimitiveTypeInfo( string Name
string name, string Purpose
string purpose, string Company
string company, string Date
string date, string Version
string version)
UDPPrim- UDPPrim- string Name
itiveParameterDefinition itiveParameterDefinition(
string Description
string name,
UnitType UnitType
string description,
double DefaultValue
UnitType unitType,
double defaultValue)
UDPParam UDPParam() ParamDataType DataType
object Data
UDPParam( object can be int, double ,
string, bool or UDPPosition
ParamDataType dataType,

Introduction to Scripting 1-65


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Structure Construction Members


object data)
object can be int, double, string,
bool or UDPPosition

methods:
setInt(int val)
setBool(bool val)
setString(string val)
setDouble(double val)
setPosition(UDPPosition val)

UDPPrim- UDPPrim- string Name


itiveParameterDefinition2 itiveParameterDefinition2(
string Description
string name,
UnitType UnitType
string description,
ParamPropType PropType
UnitType unitType,
ParamPropFlag PropFlag
ParamPropType propType,
UDPParam DefaultValue
ParamPropFlag propFlag,
UDPParam defaultValue)
UDPPosition UDPPosition( double X
double x, double Y
double y, double Z
double z)
UDPVector UDPVector( double X
double x, double Y
double y, double Z
double z)
UDPSweepOptions UDPSweepOptions( SweepDraftType
DraftType
SweepDraftType draftType,
double DraftAngle
double draftAngle,
double TwistAngle

Introduction to Scripting 1-66


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Structure Construction Members


double twistAngle)
UDPPolylineSegmentDefinition UDPPolylineSegmentDefinition( PolylineSegmentType Seg-
mentType
PolylineSegmentType seg-
mentType, int segmentStartIndex,
int segmentStartIndex, int numberOfPoints,
int numberOfPoints, double angle,
double angle, UDPPosition centerPoint,
UDPPosition centerPoint, CoordinateSystemPlane
arcPlane)
CoordinateSystemPlane
arcPlane)
UDPPolylineDefinition UDPPolylineDefinition() int IsClosed
int IsCovered
UDPPolylineDefinition(
List_of_UDPPosition
List_of_UDPPosition positions, ArrayOfPosition
List_of_UDPPolylineSeg- List_of_UDPPolylineSeg-
mentDefinition segDefs, mentDefinition ArrayOfSeg-
int closed, mentDefinition

int covered)
UDPEqua- UDPEqua- string FunctionXt
tionBasedCurveDefinition tionBasedCurveDefinition(
string FunctionYt
string functionXt,
string FunctionZt
string functionYt,
double TStart
string functionZt,
double TEnd
double tStart,
int NumOfPointsOnCurve
double tEnd,
int numOfPointsOnCurve)
UDPEqua- UDPEqua- string FunctionXuv
tionBasedSurfaceDefinition tionBasedSurfaceDefinition(
string FunctionYuv
string functionXuv,
string FunctionZuv
string functionYuv,
double UStart
string functionZuv,
double UEnd
double uStart,
double VStart

Introduction to Scripting 1-67


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Structure Construction Members


double uEnd, double VEnd
double vStart,
double vEnd)
UDPHelixDefinition UDPHelixDefinition( int ProfileID
int profileID, UDPPosition PtOnAxis
UDPPosition ptOnAxis, UDPPosition AxisDir
UDPPosition axisDir, double NoOfTurns
double noOfTurns, bool IsRightHanded
bool isRightHanded, double Radi-
usChangePerTurn
double radiusChangePerTurn,
double Pitch
double pitch)
UDPSpiralDefinition UDPSpiralDefinition( int ProfileID
int profileID, UDPPosition PtOnAxis
UDPPosition ptOnAxis, UDPPosition AxisDir
UDPPosition axisDir, double NoOfTurns
double noOfTurns, bool IsRightHanded
bool isRightHanded, double Radi-
usChangePerTurn
double radiusChangePerTurn)
UDPBLNDElements UDPBLNDElements( int PartID
int partID) List_of_int ListOfEdges
List_of_int ListOfFaces

UDPBLNDFilletOptions UDPBLNDFilletOptions( bool SupressFillet


bool supressFillet, BLNDFilletRadiusLaw Fil-
letRadiusLaw
BLNDFilletRadiusLaw fil-
letRadiusLaw, double FilletStartRadius
double filletStartRadius, double FilletEndRadius
double filletEndRadius, bool Fol-
lowSmoothEdgeSequence
bool fol-
lowSmoothEdgeSequence, BLNDFilletType FilletType

Introduction to Scripting 1-68


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Structure Construction Members


BLNDFilletType filletType, double SetbackDistance
double setbackDistance, double BulgeFactor
double bulgeFactor)
UDPBLNDChamferOptions UDPBLNDChamferOptions( bool SupressChamfer
bool supressChamfer, BLNDChamferRangeLaw
ChamferRangeLaw
BLNDChamferRangeLaw cham-
ferRangeLaw, double ChamferLeftRange
double chamferLeftRange, double Cham-
ferRightRange
double chamferRightRange)

UDPProgress UDPProgress( int Prog


int prog, int SubProg
int subProg, string Mesg
string mesg, string SubMesg
string subMesg)
UDMInfo UDMInfo( string Name
string name, string Purpose
string purpose, string Company
string company, string Date
string date, string Version
string version)
UDMDefinition UDMDefinition() string DefName
UDPParam DefValue
UDMDefinition( ParamPropType PropType
string name, ParamPropFlag PropFlag
UDParam value,
ParamPropType propType,
ParamPropFlag propFlag)
UDMOption UDMOption() string OptName
UDPParam OptValue
UDMOption( ParamPropType PropType

Introduction to Scripting 1-69


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Structure Construction Members


string name, ParamPropFlag PropFlag
UDParam value,
ParamPropType propType,
ParamPropFlag propFlag)
UDMParameter UDMParameter() string ParamName
UDPParam ParamValue
UDMParameter( UnitType UnitType
string name, ParamPropType PropType
UDParam value, ParamPropFlag PropFlag
UnitType unitType,
ParamPropType propType,
ParamPropFlag propFlag)

UDP/UDM Constants

Full names of enum constants must be used in scripts.


Example:
unitType = UnitType.LengthUnit
dataType = ParamDataType.Int
Enum constants:

enum Constant Parameters


UnitType NoUnit
LengthUnit
AngleUnit
ParamDataType Int
Double
String
Bool
Position
Unknown
ParamPropType Text

Introduction to Scripting 1-70


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

enum Constant Parameters


Menu
Number
Value
FileName
Checkbox
Position
Unknown
ParamPropFlag NoFlag
ReadOnly
MustBeInt
MustBeReal
Hidden
Unknown
CoordinateSystemAxis XAxis
YAxis
ZAxis
CoordinateSystemPlane XYPlane
YZPlane
ZXPlane
SweepDraftType ExtendedDraft
RoundDraft
NaturalDraft
MixedDraft
SplitWhichSideToKeep SplitKeepBoth
SplitKeepPositiveOnly
SplitKeepNegativeOnly
PolylineSegmentType LineSegment
ArcSegment
SplineSegment
AngularArcSegment

Introduction to Scripting 1-71


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

enum Constant Parameters


MessageSeverity WarningMessage
ErrorMessage
InfoMessage
IncompleteMessage
FatalMessage
BLNDFilletRadiusLaw BLNDConstantRadius
BLNDVariableRadius
BLNDFilletType BLNDRound
BLNDMitered
BLNDChamferRangeLaw BLNDConstantRange
BLNDVariableRange
PartPropertyFlags PropNonModel
PropDisplayWireFrame
PropReadOnly
PostprocessingGeometry
PropInvisible
PropShowDirection
PropDummy

Logging and Desktop Messaging


There is error logging and displaying script errors in Desktop Message Manager for UDP/UDM
Python scripts.
You can also add messages to Message Manager using the UDPFunctionLibrary AddMessage
method, but no logging is done in this case.

Collecting EBU Logs

The instructions below are for Windows, but they work similarly for Linux. On Linux, determine your
shell (execute echo $SHELL) and, based on that, use setenv or export to set the environment vari-
ables.

1. Create a directory that serves as a folder for the logs. Make sure that this directory is empty:
clean it out if it already has files. For this example, the name of the directory is c:\ans-
dir\ansdebug.

Introduction to Scripting 1-72


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

2. Start a new shell to set the environment. (You can set it permanently, but this is not recom-
mended.)
3. Set the following env variables in this shell:
l Set ANSOFT_DEBUG_MODE to 2. Set it to a higher number such as 4 or 5 if the
developer requests it.
l Set ANSOFT_DEBUG_LOG to a file in the previously created ansdebug directory: for
example, set ANSOFT_DEBUG_LOG=c:\ansdir\ansdebug\ansdebug.log.
l Set ANSOFT_DEBUG_LOG_SEPARATE to 1.
4. From the above shell, start the ANSYS Electromagnetics product and exercise the problem
scenario.
5. Zip all the log files in the c:\ansdir\ansdebug directory, and send them to the developer or sup-
port person requesting them.

Collecting WB Logs

1. Under WB, execute the Tools/Options menu option, and under the Journals And Logs sec-
tion, ensure the Write Workbench Log Files is checked.

Note the location of the log files. (On Windows this is typically %TEMP%\WorkbenchLogs.)
Navigate to that directory and remove all files.

2. Set up the EBU env vars if you need to collect those as well, following the instructions above.

3. Exercise the problem scenario.


4. Collect the WB log files and optionally the ANSYS Electromagnetics logs and, send them to
the developer or support person requesting them.

Example Scripts for Python UDP and UDM


The UDP example for Python creates a rectangular spiral.

1. Click Draw>User Defined Primitive>Examples>Rectangular Spiral (Python). The


User Defined Primitive Operation dialog box appears. You can set parameters such as
Xpos, Ypos, distance between turns, and Number of turns.

Introduction to Scripting 1-73


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

2. Click OK to create the spiral.

The UDM example for Python creates an on die spiral inductor.

1. Click Draw>User Defined Model>OnDieSpiralInductor. This opens a Properties dialog


box in which you can set parameters.

Introduction to Scripting 1-74


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

2. Set the parameters and click OK to create the UDM.

ANSYS Electronics Desktop Scripting


This chapter provides an overview of scripting in ANSYS Electronics Desktop.
Overview of ANSYS Electronics Desktop Script Variables
Recording a Script

Introduction to Scripting 1-75


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Stopping Script Recording


Running a Script
Pausing and Resuming a Script
Modifying a Script for Easier Playback
ANSYS Electronics Desktop Scripting Conventions
ANSYS Electronics Desktop Layout Scripts and the Active Layer
Scripts and Locked Layers
Event Callback Scripting
Executing a Script from Within a Script
Editing Properties
Overview of ANSYS Electronics Desktop Script Variables
When you record an ANSYS Electronics Desktop script, the beginning of the script has some
standard commands as shown in the following chart. The commands in the chart are meant to
define the variables used by ANSYS Electronics Desktop in the script and assign values to the vari-
ables. The variables are used in the following hierarchy.

Introduction to Scripting 1-76


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

First the commands are described followed by examples.


oAnsoftApp
The oAnsoftApp object provides a handle for VBScript to access the Ansoft.ElectronicsDesktop
product.
One example of accessing this object is:
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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 the chapter Desktop Object Script Commands, for details about script commands recognized
by the oDesktop object.

Introduction to Scripting 1-77


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oProject
The oProject object corresponds to one project open in the product. It is used to manipulate the pro-
ject 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:

l Project Object Script Commands


l Property Script Commands
l 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()
See the following chapters for details about the script commands recognized by the oDesign
object:

l Design Object Script Commands


l Output Variable Script Commands
l Reporter Editor Script Commands

oEditor
The oEditor object corresponds to an editor, such as the 3D Modeler, layout or schematic editors.
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")
A layout example of accessing this object is:
Set oEditor = oDesign.SetActiveEditor("Layout")
The Ansoft.ElectronicsDesktop product scripting supports the following editors:

Editor Name in Script


3D "3D Modeler"
Modeler
Editor

Introduction to Scripting 1-78


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Reporter There is no Reporter editor object in the script. Instead, Reporter editor commands
Editor are executed by the ANSYS Electronics Desktop design object oDesign.

See the chapter 3D Modeler Editor Script Commands, for details about the script commands recog-
nized by the oEditor object and the chapter 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")
The software scripting supports the following modules:

Module Name in Script Chapter Title


Boundary/Excitations/Nets Module "BoundarySetup" Boundary and Excit-
ation Module Script
Corresponds to the Boundaries,Excitations or Commands
Nets branches in the project tree.

Mesh Operations Module "MeshSetup" Mesh Operations Mod-


ule Script Commands
Corresponds to the Mesh Operations branch in the
project tree.

Analysis Module "AnalysisSetup" Analysis Module Script


Commands
Corresponds to the Analysis branch in the project
tree.

Optimetrics Module "Optimetrics" Optimetrics Script Com-


mands
Corresponds to the Optimetrics branch in the pro-
ject tree.

Solutions Module "Solutions" Solutions Module Script


Commands
Corresponds to the operations in the Solution Data
dialog box, which is accessed by clicking Results>
Solution Data.

Introduction to Scripting 1-79


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Field Overlays Module "FieldsReporter" Field Overlays Module


Script Commands
Corresponds to the Field Overlays branch in the pro-
ject tree.

Radiation Module "RadField" Radiation Module


Script Commands
Corresponds to the Radiation branch in the project
tree.

Reduce Matrix Module "ReduceMatrix" Reduce Matrices Mod-


ule Script Commands
Corresponds to the Reduce Matrix branch in the pro-
ject tree.

Examples of HFSS, Layout Editor, and Q3D Extractor scripts are described as follows.
Example: HFSS Script
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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")

Example: HFSS Layout Editor Script


Dim oAnsoftApp
Dim oDesktop

Introduction to Scripting 1-80


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project1")
oProject.InsertDesign "HFSS3D", "HFSS3D1", _
"C:\testinstall\HFSS\syslib\PCB - SingleSided.asty", ""
Set oDesign = oProject.SetActiveDesign("HFSS3D1")
Set oEditor = oDesign.SetActiveEditor("Layout")

Example: Q3D Extractor Script


Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
Set oProject = oDesktop.SetActiveProject("")
Set oDesign = oProject.SetActiveDesign("")
Set oModule = oDesign.GetModule("Solutions")
The lines above define the variables used by the script and assigns values to the variables.
Recording a Script
After you begin to record a script, each subsequent interface action you take is recorded and saved
to a text file or project folder you have specified — i.e., each interface command is made up of one
or more associated script commands, and each action is recorded and saved to a single script. The

Introduction to Scripting 1-81


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

recorded script is saved in the format you select, either IronPython Script format (.py, the
default) or VBScript format (.vbs).
To Record a Script to a File:

1. Click Tools> Record Script to File or select the Automation tab and click the Record
Script icon:

The Save As dialog box appears.

2. Use the file browser to locate and double-click the folder where you wish to save the script,
such as C:\Program Files\AnsysEM\<platform>\Scripts.
3. Type the name of the script in the File name text box and select the script type as
IronPython (*.py, the default) or or VBScript format (.vbs).
4. Click Save.
5. Perform the steps you want to record.
6. When you have finished recording the script, click Tools > Stop Script Recording.
The recorded script is then saved to filename.py or filename.vbs in the folder specified
folder.

To Record a Script to a Project:

1. Click Tools > Record Script to Project.

The Save Script to Project dialog box appears.

2. Type the name of the script in the text box, then click OK.

Perform the steps you want to record.

3. When you have finished, click Tools > Stop Script Recording.

The recorded script is then saved to scriptname.vbs in the Scripts library and can be
accessed by expanding the definitions/Scripts folder in the Project Manager.

Introduction to Scripting 1-82


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Working with Project Scripts

l You can edit scripts stored in a project by right-clicking the desired script in the Definitions >
Scripts folder in the Project Manager window; then selecting Edit Script from the context
menu. The script will open in theScript Editor.
l You can execute a project script, by right-clicking the desired script in the Definitions >
Scripts folder in the Project Manager window; then selecting Run Script from the context
menu.
l You can also access project scripts by selecting the Automation tab and using the menu
under the Run script icon:

Note:

Project scripts are stored in the project scripts library. Refer to Managing Library
Contents for information on working with libraries.

Stopping Script Recording


l ClickTools > Stop Script Recording or select the Automation ribbon tab and click the
Stop Recording icon:

ANSYS Electronics Desktop stops recording to the script.

Introduction to Scripting 1-83


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Running a Script
1. Click Tools> Run Script or click the Automation tab and click the Run Script icon:

The Open dialog box appears.

2. Use the file browser to locate the folder in which you saved the script, and then double-click
the folder’s name.
3. Type the name of the script in the File name text box, or click its name, specify the file type:

4. Click Open.

ANSYS Electronics Desktop executes the script.

To supply script arguments when running from Tools> Run Script, use the Edit field at the bot-
tom of the file selection dialog box. 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 ANSYS Electronics Desktop Help in the
Running ANSYS Electronics Desktop from a Command Line section), use:
-runscriptandexit or -runscript arguments to the ANSYS Electronics Desktop command
line syntax.
You can give -scriptargs parameter to the script and specify the arguments described in the
ANSYS Electronics Desktop help.

Introduction to Scripting 1-84


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

If you run the script from DOS prompt as a .vbs file (that is, you do not launch ANSYS Electronics
Desktop, but just 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, use the
following script:
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:

l Click Tools> Pause Script or select the Automation tab and click the Pause Script icon.

To resume a script after pausing it:

l Click Tools> Resume Script.

Introduction to Scripting 1-85


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Stopping a Script
l On the Tools menu, click Stop Script.

ANSYS Electronics Desktop stops executing the script that has been paused.

Modifying a Script for Easier Playback


In the sample scripts, 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.
The modified sample script is as follows:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
Set oProject = oDesktop.SetActiveProject()
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
Set oModule = oDesign.GetModule("BoundarySetup")
ANSYS Electronics Desktop Scripting Conventions
A number of conventions exist for ANSYS Electronics Desktop regarding syntax, arguments and
numerical values. These conventions are as follows:

l Syntax Conventions
l Script Command Conventions
l Named Arguments
l Setting Numerical Values
l ANSYS Electronics Desktop Layout Scripts and the Active Layer

Introduction to Scripting 1-86


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

l Scripts and Locked Layers


l Event Callback Scripting

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 1: "SolveIn-
side:=", true
Example 2: "PortSolver:=", 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 ANSYS
Electronics Desktop 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 ">". For example, HFSS>Excitations>Assign>Wave Port.
Syntax:Demonstrates the correct syntax for the command. 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.

Introduction to Scripting 1-87


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Example:Provides a working example of the script command, if


needed.
Passing Arguments to Scripts
There are two ways to pass arguments to scripts:

1. When running from command line using -runscriptandexit or -runscript, give -scriptargs
parameters and specify arguments.

All arguments following the -scriptargs flag are enclosed in double quotes. For example

C:\AnsysEM\AnsysEMn\Win64\hfss.exe -RunScriptAndExit _
C:\scripts\test.vbs -scriptsargs "arg1 arg2 arg3"

2. When running from Tools> Run script, there is an edit field at the bottom of the file selec-
tion dialog that you can use to enter script arguments.

You can access the script arguments using the AnsoftScriptHost.arguments collection from
vbscript. This is a standard COM collection.
If you run the script from DOS prompt as a .vbs file (that is, you do not open ANSYS Electronics
Desktop, but launch vbs directly, or use wscript.exe or cscript.exe), the arguments are in the
WSH.arguments collection, not the AnsoftScriptHost.arguments collection. To handle this,
write this script:
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

Introduction to Scripting 1-88


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Named Arguments
Many ANSYS Electronics Desktop script commands use named arguments. The names can
appear in three ways:

1. Named data, name precedes data.

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 ANSYS Elec-
tronics Desktop 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 ANSYS Electronics
Desktop which data is being given. The names must be included or the script will not play back cor-
rectly. 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 writ-
ing a script by hand, you can just add the data that changed and omit anything that you do not want
to change. ANSYS Electronics Desktop will use the names to determine which data you provided.
For example, when editing an impedance boundary, ANSYS Electronics Desktop 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")
Another example corresponding to ANSYS Electronics Desktop layout is described below:
When editing a port excitation, ANSYS Electronics Desktop records the ‘edit port’ command as fol-
lows:
oModule.Edit "Port1", Array("NAME:Port1",Array("NAME:Properties",
"PortSolver:=", "true", "Phase:=", "0deg", "Magnitude:=", "2mA",
"Impedance:=", "50Ohm", "Theta:=", "0deg", "Phi:=", "0deg",

Introduction to Scripting 1-89


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"PostProcess:=", "false", "Renormalize:=", "50Ohm + 0i Ohm",


"Deembed:=", "0mm", "RefToGround:=", "false"), "Type:=", "EdgePort",
"IsGapSource:=", true, "UpperProbe:=", false, "LayoutObject:=",
"Port1", "Pin:=", "", "ReferencePort:=", "")
If you only want to change the magnitude, you can leave out the other data arguments when you
are manually writing a script:
oModule.Edit "Port1", Array("NAME:Port1", Array ("Magnitude:=",
"1mA"))
Setting Numerical Values
For script arguments that expect a number, the following options are possible:

l Pass in the number directly. For example:

oModule.EditVoltage "Voltage1", Array("NAME:Voltage1", _

"Voltage:=", 3.5)

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

oModule.EditVoltage "Voltage1", Array("NAME:Voltage1", _

"Voltage:=", "3.5V" )

l Pass in a defined variable name. For example:

oModule.EditVoltage "Voltage1", Array("NAME:Voltage1", _

"Voltage:=", "$var1" )

l Pass in a VBScript variable. For example:

vb_var = "3.5V"

oModule.EditVoltage "Voltage1", Array("NAME:Voltage1", _

"Voltage:=", vb_var)

ANSYS Electronics Desktop Layout Scripts and the Active Layer


The active layer is the layer that is used for object creation and placement during adding operations
in the user interface. Adding operations include paste and placement of instances, as well as object
creation. Usually there will be an active layer, but it is not required and can not be assumed. Adding
operations are responsible for ensuring that the active layer exists and meets the particular require-
ments (such as layer type) for the operation. Adding operations may change the active layer to a dif-
ferent layer that meets requirements. The user is notified if the active layer is changed. If no layer is
available to be active, the operation is not done.

Introduction to Scripting 1-90


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

The active layer is not used during script adding operations. Script adding operations are respons-
ible for ensuring that the specified layer exists and meets the particular requirements (such as layer
type) for the operation. If there is a problem with using the specified layer, the operation is not done.
The active layer is always visible and selectable. These attributes are reset, if needed, when a layer
is made active. The current active layer is indicated by a combo box display in the toolbar. The list
for the combo box contains all layers that may be set active.
The active text style is related to the active layer. If there is no active layer, there is no active text
style. Objects on the active layer have priority during snapping.
Scripts and Locked Layers
The locked attribute of a layer is defined to mean that you may not edit, delete, or add objects on
the layer, either directly or with scripts (i.e., scripts run on layout or footprint definitions). This
includes not being able to change properties of objects on the layer. Note, however, that parameter
changes can alter objects on locked layers.
The locked attribute of a layer is configurable using script commands and is user-editable via the
Edit Layers Dialog in the Layout Editor.
Event Callback Scripting
Event Callback scripting allows you to define custom JavaScript and VBScript routines that will run
automatically after a triggering event is detected, events such as placing a component or running a
simulation. When you define an Event Callback script, you specify one or more scripts that will be
run after a particular event is detected. For more information see Event Callbacks in the help.
A callback script can only access functions and other scripts defined by its callback definition. For
example, a Simplorer callback script can call PropHost.GetValue — and all other PropHost func-
tions — but only from scripts defined in the Property Dialog callback. As a result, "PropHost" is a
Simplorer script item that is only visible in "Property" callback scripts. For more information, see
Callback Scripting Using PropHost Object and Callback Scripting Using CompInstance Object.
The following table lists allowable callback events, items that are visible from the associated call-
back script, and the set of accessible functions that can be called.

Scripts Vis-
Callback ible from the Functions Callable
Event Event Call- from the Visible Script
back Script
Place Com- CompInstance CompInstance.GetParentDesign() — Returns a oDesign item
ponent that can be used to call Design functions.

CompInstance.GetPropserverName() – Returns a Com-


pInstance identification name that can be used in oEditor property-
method scripts, such as GetPropertyValue(), SetPropertyValue(),
etc.

CompInstance.GetComponentName() — Returns the com-

Introduction to Scripting 1-91


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ponent name, e.g. "MS_TRL".


Simulate CompInstance CompInstance.GetDesign() — Returns the interface to the spe-
Component cified design simulation.

CompInstance.GetProgress() – Returns the completion per-


centage (from 0 to 100) of the specified design simulation.

CompInstance.GetRunStatus() — Returns the status number of


the specified design simulation.

CompInstance.Abort() — Aborts the specified design simulation.

The function, ExecuteAnsoftScript(<ScriptName>), searches the configured ANSYS Elec-


tronics Desktop script libraries by name for the script passed to it, and invokes the found
ScriptName. The invoked script will run with the same set of visible script items as the originally
called script. That is, CompInstance is visible from the invoked sub-script, ScriptName, and Com-
pInstance’s functions can be called from ScriptName.
Executing a Script from Within a Script
ANSYS Electronics Desktop 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, ANSYS Electronics Desktop searches for the specified
script in the following locations, in this order:

l 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.

l 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.

l System library directory.

Introduction to Scripting 1-92


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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 dia-
log box) under the Project Options tab.

l ANSYS Electronics Desktop installation directory.

Editing Properties
Any data that is shown in the dockable Properties window or in the pop-up Properties dialog box
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 the chapter, Property Script Commands, for an explan-
ation of how to manipulate properties in a script.

Introduction to Scripting 1-93


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

1-94
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

2 - Application Object Script Commands


The Application object commands permit you to get the AppDesktop. Application object commands
should be executed by the oAnsoftApp object.
oAnsoftApp.<CommandName> <args>
General Application Script Commands
The following are general script commands recognized by the oAnsoftApp object:

l GetAppDesktop

The following deprecated commands are no longer supported and produce an error if used.

l GetDesiredRamMBLimit (deprecated)
l GetHPCLicenseType (deprecated)
l GetMaximumRamMBLimit (deprecated)
l GetMPISpawnCmd(deprecated)
l GetMPIVendor (deprecated)
l GetNumberOfProcessors (deprecated)
l GetUseHPCForMP (deprecated)
l SetDesiredRamMBLimit (deprecated)
l SetHPCLicenseType (deprecated)
l SetMaximumRamMBLimit (deprecated)
l SetMPISpawnCmd (deprecated)
l SetMPIVendor (deprecated)
l SetNumberOfProcessors (deprecated)
l SetUseHPCForMP (deprecated)

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.

UI Access NA

Name Type Description


Parameters
None

Return Value Object

Application Object Script Commands 2-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- GetAppDesktop()


tax

Python oDesktop = oAnsoftApp.GetAppDesktop()


Example

VB Syntax GetAppDesktop()
VB Set oDesktop = oAnsoftApp.GetAppDesktop()
Example

Application Object Script Commands 2-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

3 - 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("Ansoft.ElectronicsDesktop")
oDesktop.CommandName <args>
AddMessage
ClearMessages
CloseAllWindows
CloseProject
CloseProjectNoForce
Count
DeleteProject
DownloadJobResults
EnableAutoSave
GetActiveProject
GetAutoSaveEnabled
GetBuildDateTime
GetDefaultUnit
GetDesigns
GetDistributedAnalysisMachines
GetDistributedAnalysisMachincesForDesignType
GetExeDir
GetGDIObjectCount
GetLibraryDirectory
GetLocalizationHelper
GetMessages
GetName
GetNoteText
GetPersonalLibDirectory

Desktop Object Script Commands 3-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetProcessID
GetProjects
GetProjectDirectory
GetProjectList
GetScriptingToolsHelper
GetSysLibDirectory
GetTempDirectory
GetUserLibDirectory
GetVersion
ImportANF
ImportAutoCAD
ImportGDSII
ImportODB
LaunchJobMonitor
NewProject
OpenAndConvertProject
OpenMultipleProjects
OpenProject
OpenProjectWithConversion
Paste
PauseRecording
PauseScript
Print
QuitApplication
RefreshJobMonitor
RestoreProjectArchive
RestoreWindow
ResumeRecording
RunACTWizardScript
RunProgram

Desktop Object Script Commands 3-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

RunScript
RunScriptWithArguments
SelectScheduler
SetActiveProject
SetActiveProjectByPath
SetLibraryDirectory
SetProjectDirectory
SetTempDirectory
ShowDockingWindow
Sleep
SubmitJob
Tile Windows
Also see:
Desktop Commands For Registry Values

AddMessage
Add a message with severity and context to message window.

UI Access NA

Name Type Description


<projectName> String Project name, an empty string adds the mes-
sage as the desktop global message
<designName> String Design name, is ignored if project name is
empty; an empty string adds the message to
project node in the message tree
<severity> integer One of "Error", "Warning" or "Info". Anything
other than the first two is treated as "Info" 0 =
Informational, 1 = Warning, 2 = Error, 3 =
Parameters Fatal
<msg> String The message for the message window
<category> String Optional. The category is created with the
message under the design tree node if the cat-
egory does not exist. If the category already
exists, the new message is added to the end
of the existing category. It is ignored if the pro-
ject or design is empty. If missing or empty,
the message is added to the Design node in
the message tree.

Desktop Object Script Commands 3-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Return Value None

Pytho- AddMessage( <projectName>, <designName>, <severity>, <msg>, <category>)


n Syn-
tax

Pytho- oDesktop.AddMessage ("Project1", "HFSS1", 0, "This is a test


n message", "")
Exam-
ple

VB  AddMessage <projectName>, <designName>, <severity>, <msg>, <category>


Syntax

VB oDesktop.AddMessage "Project1", "HFSS1", 0, "This is a test


Examp- message", ""
le

ClearMessages
Clears messages, optionally specifying severity and design.

In Message Manager, right-click the project name and click Clear messages
UI Access
for Project#

Name Type Description


project <string> project name, an empty string clears all pro-
ject messages.
design <string> design name; ignored if project name is
empty; an empty string clears messages in all
designs.
Parameters severity <int> 0 - clear all info messages
1 - clear all info and warning messages
2- clear all info, warning and error messages
3 - clear all messages included info, warning,
error, and fatal-error

Return Value None

Desktop Object Script Commands 3-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- ClearMessages(<project>, <design>, <severity>)


tax

Python oDesktop.ClearMessages("", "",3)


Example

VB Syn- ClearMessages <project>, <design>, <severity>


tax

Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")


VB
Set oDesktop = oAnsoftApp.GetAppDesktop()
Example
oDesktop.ClearMessages "", "", 3

CloseAllWindows
Closes all MDI child windows on the desktop.

UI Access From main menu, Window>CloseAll.

Name Type Description


Parameters
None

Return Value None

Python Syn- CloseAllWindows()


tax

Python oDesktop.CloseAllWindows()
Example

VB Syntax CloseAllWindows()
VB Example oDesktop.CloseAllWindows()

CloseProject
Closes a specified project. Changes to the project are not saved. Save the project using the Project
command Save or Save As before closing to save changes.

UI Access File>Close

Desktop Object Script Commands 3-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name Type Description


Parameters <ProjectName> String The name of the project already in the
Desktop that is to be closed, without path or
extension

Return Value None

Python Syn- CloseProject (<ProjectName>)


tax

Python oDesktop.CloseProject ("MyProject")


Example

VB Syntax CloseProject <ProjectName>


VB Example oDesktop.CloseProject "MyProject"

CloseProjectNoForce
Use: Close a named project currently open in the Desktop, unless a simulation is running. Changes
to the project will not be saved. Save the project using the Project command Save or Save As
before closing to save changes. To determine if the project has been closed, use GetPro-
jectList and see if the named project is present.

UI Access File>Close

Name Type Description


Parameters <ProjectName> String The name of the project already on the
Desktop that is to be closed, without path or
extension

Return Value None

Python Syn- CloseProjectNoForce (<ProjectName>)


tax

Python oDesktop.CloseProjectNoForce ("MyProject")


Example

VB Syntax CloseProjectNoForce <ProjectName>

Desktop Object Script Commands 3-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB oDesktop.CloseProjectNoForce "MyProject"
Example

VB Example:
------------------------------------
Example Script
------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.CloseProjectNoForce "Project9"

Count
Use: Gets the total number of queried projects or designs obtained by GetProjects() and
GetDesigns() commands. See the example query.
Syntax:
Return Value: Returns an integer value.
Parameters: None
Example: set projects = oDesktop.GetProjects()
numprojects = projects.

Example:
---------------------------------------------------------
Example Script: iterate through using integer index
---------------------------------------------------------
Dim oAnsoftApp

Desktop Object Script Commands 3-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
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 - 1
msgbox designs(j).GetName()
next
next

DeleteProject
Use: Deletes a project from disk.

UI Access Edit>Delete

Name Type Description


Parameters
<projectname> String Name of the project

Return Value None

Python Syn- DeleteProject (<ProjectName>)


tax

Python oDesktop.DeleteProject ("MyProject")


Example

Desktop Object Script Commands 3-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax DeleteProject <ProjectName>


VB Example oDesktop.DeleteProject "MyProject"

VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
oDesktop.DeleteProject "Project8"

DownloadJobResults
This command is for downloading results from ANSYS Cloud. Before using this script command,
the command SelectScheduler() must be used first to select “ansys cloud” scheduler. This makes
sure that current scheduler is ANSYS Cloud, and user is logged in. Then, either a valid .q file or .q.-
completed file must be in the project folder, or, a valid job ID and a “batchinfo” folder containing the
corresponding .jobid file are required in the project folder. When the download requirements are
met, the command downloads results from ANSYS Cloud using the specified filters to the given
folder.

UI Access Select Scheduler

Name Type Description


jobID string Provide the job ID of the target job. The job ID
must be able to be found in current .q (or .q.-
completed) file, or inside the “batchinfo” folder
Parameters
in projectPath. If the job ID is empty, the job ID
in current .q (or .q.completed) file will be used
projectPath string A string of path to locate the project folder.
The project file may be not necessary, but .q
(or .q.completed) file or “batchinfo” folder with
valid .jobid files are required

Desktop Object Script Commands 3-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

resultPath string A string giving the folder path for the down-
load to save to.
Filters (optional) string A string containing filters to download. The
delimiter of file types is “;”. If no filter specified,
the default filter “*” will be applied, which
requests all files for download.

Return Value A Boolean result about download complete or not

Python Syn- DownloadJobResults(jobID, projectPath, resultsPath, filters)


tax

boolDownloadCompleted = oDesktop. DownloadJobResults


Python
("012345678901234567890", "C:\\projects\\basic.aedt",
Example
“C:\\projects\\DownloadResults\\”, “*”)

VB Syntax DownloadJobResults(jobID, projectPath, resultsPath, filters)


boolDownloadCompleted = oDesktop. DownloadJobResults
VB Example ("012345678901234567890", "C:\\projects\\basic.aedt",
“C:\\projects\\DownloadResults\\”, “*”)

EnableAutoSave
Enable or disable autosave feature.

UI Access NA

Name Type Description


Parameters
<enable> Boolean True enables autosave and False disables it.

Return Value None

Python Syn-  EnableAutoSave(<Enable>)


tax

Python oDesktop.EnableAutoSave(True)
Example

VB Syntax  EnableAutoSave(<Enable>)

Desktop Object Script Commands 3-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Example oDesktop.EnableAutoSave(true)

--------------------------------------------------------------------
In this example message box returns 1 since autosave is enabled.
--------------------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject()
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
oDesktop.EnableAutoSave(true)
msgbox(oDesktop.GetAutoSaveEnabled())

ExportOptionsFiles
Copies the options config files to the DestinationDirectory.

UI Access Tools>Options>Export Options Files ...

Name Type Description


Parameters
<DestinationDirectory> String The path to the destination directory.

Return Value None

Python ExportOptionsFiles(  <
  DestinationDirectory>)
Syntax

Python oDesktop.ExportOptionsFiles("D:/test/export/")
Example

Desktop Object Script Commands 3-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax ExportOptionsFiles <DestinationDirectory>


VB oDesktop.ExportOptionsFiles"D:/test/export/"
Example

GetActiveProject
Obtain the object for the project that is currently active in the Desktop.

Note:

GetActiveProject returns normally if there are no active objects.

UI Access NA

Name Type Description


Parameters
None

Return Value Object, the project that is currently active in the desktop

Python Syn- GetActiveProject()


tax

Python oProject = oDesktop.GetActiveProject()


Example

VB Syntax GetActiveProject
VB Set oProject = oDesktop.GetActiveProject
Example

VB Example:
------------------------------------
Example Script
------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign

Desktop Object Script Commands 3-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject()

GetAutoSaveEnabled
Checks to see if the autosave feature is enabled.

UI Access NA

Name Type Description


Parameters
None

Boolean
Return Value
True if autosave is enabled

Python Syn- GetAutoSaveEnabled()


tax

Python Enabled = oDesktop.GetAutoSaveEnabled()


Example

VB Syntax GetAutoSaveEnabled
VB Enabled = oDesktop.GetAutoSaveEnabled()
Example

VB Example:
------------------------------------
Example Script
------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject

Desktop Object Script Commands 3-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject()
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
msgbox(oDesktop.GetAutoSaveEnabled())

GetBuildDateTimeString
Returns a string representing the build date and time of the product;

UI Access NA

Name Type Description


Parameters
None

String
Return Value The build date and time. Format: year-month-day hour:minute:second, e.g.,
2019-01-18 21:59:33

Python Syn- GetBuildDateTimeString()


tax

Python oDesktop.GetBuildDateTimeString()
Example

VB Syntax GetBuildDateTimeString
VB Example dnt = oDesktop.GetBuildDateTimeString

VB Example:
------------------------------------------------------
message box displays dat
------------------------------------------------------

Desktop Object Script Commands 3-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
msgbox(oDesktop.GetBuildDateTimeString())

GetDefaultUnit
Returns the default unit for a physical quantity.

UI Access You can view the default settings in Options > General > Default Units

Name Type Description


Parameters Type of option <string> an item in Default Units, such as Length or
Frequency

<unit>
Return Value
For example, for Length in the Default Units options, the return value is mm

Python GetDefaultUnit()
Syntax

oDesktop.GetDefaultUnit("length")
oDesktop.GetDefaultUnit("angularspeed")

Python oDesktop.GetDefaultUnit("magneticreluctance")
Example oDesktop.GetDefaultUnit("massflowrate")
oDesktop.GetDefaultUnit("pressurecoefficient")
oDesktop.GetDefaultUnit("flux")

Desktop Object Script Commands 3-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax GetDefaultUnit
VB Example oDesktop.GetDefaultUnit("length")

GetDesigns
Returns the designs in a given project.
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.

UI Access NA

Name Type Description


Parameters
None

Return Value  A collection containing objects for all designs in the project

Python Syn- GetDesigns()


tax

for dsn in oProject.GetDesigns():


Python
Example AddInfoMessage(dsn.GetName())

VB Syntax GetDesigns
For each dsn in oProject.GetDesigns
VB Example MsgBox dsn.GetName()
next

Example:
--------------------------------------------------------------------
Object in design(0) is edited. designs(0) is one of several designs
in this project. design(0) implies first design; design(1) implies
second design and so on.
--------------------------------------------------------------------
Dim oAnsoftApp

Desktop Object Script Commands 3-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project9")
set projects = oDesktop.GetProjects()
set designs = projects(0).GetDesigns()
Set oEditor = designs(0).SetActiveEditor("3D Modeler")
oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geo-
metry3DCmdTab", Array("NAME:PropServers", _
"Box1:CreateBox:1"), Array("NAME:ChangedProps", Array("NAME:ZSize",
"Value:=", "1mm"))))

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

UI Access NA

Name Type Description


Parameters
None

Return Value Returns a collection of names of machines used for distributed analysis

Python GetDistributedAnalysisMachines()
Syntax

for machine in oDesktop.GetDistributedAnalysisMachines():


Python
Example AddInfoMessage(str(machine))

Desktop Object Script Commands 3-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syn- GetDistributedAnalysisMachines()
tax

For each machine in oDesktop.GetDistributedAnalysisMachines


VB ()
Exampl-
msgbox machine
e
next

VB Example:
------------------------------------
Example Script
------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Dim omachine
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
for each machine in oDesktop.GetDistributedAnalysisMachines()
msgbox machine
next

GetDistributedAnalysisMachinesForDesignType
To obtain a list of the machines set up for analysis of the specified design type.

UI Access NA

Name Type Description


Parameters
<designTypeName> String The name of the type of design, such as
"Twin Builder", "HFSS", HFSS-IE", "Maxwell
3D" , "Maxwell 2D", "RMxprt", "EM Design",

Desktop Object Script Commands 3-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Circuit", "System", "Q3D Extractor", "2D


Extractor"

Return Value Object; returns a collection of machine names.

Python Syn- GetDistributedAnalysisMachinesForDesignType (<designTypeName>)


tax

machineNames =oDesktop.
Python GetDistributedAnalysisMachinesForDesignType
Example
("HFSS")

VB Syntax GetDistributedAnalysisMachinesForDesignType <designTypeName>


Set machineNames =oDesktop.
VB
GetDistributedAnalysisMachinesForDesignType
Example
("HFSS")

GetExeDir
Returns the path where the executable is located.

UI Access NA

Name Type Description


Parameters
None

String
Return Value path where executable is located, such as 'C:/Program Files/An-
sysEM/AnsysEM20.2/Win64/'

Python Syn- GetExeDir()


tax

Python oDesktop.GetExeDir()
Example

Desktop Object Script Commands 3-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax GetExeDir()
VB Example msgbox(oDesktop.GetExeDir())

GetGDIObjectCount

Note:
This command is for internal ANSYS use only.

Python Syn- GetGDIObjectCount()


tax

Python oDesktop.GetGDIObjectCount()
Example

GetLibraryDirectory
Get the path to the SysLib directory.

UI Access NA

Name Type Description


Parameters
None

String
Return Value
The path to the SysLib directory.

Python GetLibraryDirectory()
Syntax

Python AddInfoMessage(str(oDesktop.GetLibraryDirectory()))
Example

VB Syntax GetLibraryDirectory
VB Example MsgBox oDesktop.GetLibraryDirectory

VB Example:
------------------------------------------------------

Desktop Object Script Commands 3-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

message box returns the path in this example


------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
libdir = oDesktop.GetLibraryDirectory
msgbox(oDesktop.GetLibraryDirectory())

Python GetLibraryDirectory()
Syntax

Python AddInfoMessage(str(oDesktop.GetLibraryDirectory()))
Example

GetLocalizationHelper

Note:
This command is for internal ANSYS use only.

Returns the object for the localization helper.

UI Access NA

Name Type Description


Parameters
None

Object
Return Value
Localization helper object, such as "IDispatch(ILocalizationHelper)"

Python Syn- GetLocalizationHelper()


tax

Desktop Object Script Commands 3-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python oDesktop.GetLocalizationHelper()
Example

VB Syntax GetLocalizationHelper
VB Example oDesktop.GetLocalizationHelper()

GetMessages
Get the messages from a specified project and design.

UI Access NA

Name Type Description


< ProjectName> String Name of the project for which to collect mes-
sages. An incorrect project name results in no
messages (design is ignored). An empty pro-
ject name results in all messages (design is
ignored)
< DesignName> String Name of the design in the named project for
which to collect messages. An incorrect
design name results in no messages for the
Parameters named project. An empty design name results
in all messages for the named project
< Severity> Integer Severity is 0-3, and is tied in to info/warn-
ing/error/fatal types as follows:
0 is info and above
1 is warning and above
2 is error and fatal
3 is fatal only (rarely used)

Return Value  A simple array of strings.

Python Syn- GetMessages (<ProjectName>, <DesignName>, <Severity>)


tax

Messages = oDesktop.GetMessages
Python
Example ("MyProject","HFSS1,1)

Desktop Object Script Commands 3-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax GetMessages <ProjectName>, <DesignName>, <Severity>


Messages = oDesktop.GetMessages
VB Example
("MyProject","HFSS1,1)

VB Example:
------------------------------------------------------
For severity =1, the message box returns the first
warning message for Project9, HFSSDesign1
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Dim omachine
Dim oseverity
Dim var
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
var = oDesktop.GetMessages(Project9,HFSSDesign1,1)
msgbox var(0)

VB Example:
----------------------------------------------------------
For severity =2, the message box returns the
first error message for Project9, HFSSDesign1
----------------------------------------------------------

Desktop Object Script Commands 3-23


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Dim omachine
Dim oseverity
Dim var
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
var = oDesktop.GetMessages(Project9,HFSSDesign1,1)
msgbox var(0)

VB Example:
------------------------------------------------------
using for loop display all the messages for
Project9, HFSSDesign1
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Dim omachine
Dim var

Desktop Object Script Commands 3-24


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")


Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
for each var in oDesktop.GetMessages("Project9","HFSSDesign1",1)
msgbox var
next

GetName [Desktop]
Use: Gets names of queried projects or designs obtained by GetProjects() and GetDesigns() com-
mands. 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()
Example:
--------------------------------------------------------------
In this example, message box returns project name. projects(0) is
the first of the several projects. Similarly projects(1) displays
name of second project
----------------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow

Desktop Object Script Commands 3-25


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

set projects = oDesktop.GetProjects()


project_name = projects(0).GetName()
msgbox(project_name)
Example:
------------------------------------------------------
message box returns the names of the projects
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
for each prj in oDesktop.GetProjects()
msgbox prj.GetName()
next

GetPersonalLibDirectory
Get the path to the PersonalLib directory.

UI Access NA

Name Type Description


Parameters
None

String
Return Value
The path to the PersonalLib directory

Python GetPersonalLibDirectory()

Desktop Object Script Commands 3-26


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax

Python AddInfoMessage(str(oDesktop.GetPersonalLibDirectory()))
Example

VB Syntax GetPersonalLibDirectory
VB MsgBox oDesktop.GetPersonalLibDirectory
Example

VB Example:
------------------------------------------------------
message box returns the PersonalLib directory path
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
sys = oDesktop.GetPersonalLibDirectory()
msgbox(oDesktop.GetPersonalLibDirectory())

GetProcessID
Returns the process ID of ansysedt.exe.

UI Access NA

Name Type Description


Parameters
None

String
Return Value
returns the process ID of ansysedt.exe, such as 12716

Desktop Object Script Commands 3-27


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- GetProcessID ()


tax

Python oDesktop.GetProcessID()
Example

VB Syntax GetProcessID()
VB Example msgbox(oDesktop.GetProcessID())

GetProjects
 Return a list of all the projects that are currently open in the Desktop. Once you have the projects
you can iterate through them using standard VBScript methods. See the example query.

UI Access NA

Name Type Description


Parameters
None

Return Value Returns a collection containing objects for all open projects in the Desktop

Python Syn- GetProjects()


tax

for pjt in oDesktop.GetProjects():


Python
Example AddInfoMessage(str(pjt.GetName()))

VB Syntax GetProjects
For each pjt in oDesktop.GetProjects
MsgBox pjt.GetName()
VB Example

Next

VB Example:
---------------------------------------------------

Desktop Object Script Commands 3-28


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Example Script
----------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
for each prj in oDesktop.GetProjects()
msgbox prj.GetName()
for each design in prj.GetDesigns()
msgbox design.GetName()
next
next

GetProjectDirectory
Gets the path to the Project directory.

UI Access NA

Name Type Description


Parameters
None

String
Return Value
The path to the Project directory.

Python GetProjectDirectory()
Syntax

Python AddInfoMessage(str(oDesktop.GetProjectDirectory()))

Desktop Object Script Commands 3-29


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Example

VB Syntax GetProjectDirectory
VB Example MsgBox oDesktop.GetProjectDirectory

VB Example:
------------------------------------------------------
message box returns the project directory path
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
projdir = oDesktop.GetProjectDirectory()
msgbox(oDesktop.GetProjectDirectory())

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

UI Access NA

Name Type Description


Parameters
None

Return Value An array of strings, the names of all open projects in the Desktop.

Python Syn- GetProjectList()


tax

Desktop Object Script Commands 3-30


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python list_of_projects = oDesktop.GetProjectList()


Example

VB Syntax GetProjectList
VB list_of_projects = oDesktop.GetProjectList
Example

VB Example:
------------------------------------------------------
message box returns list of project names
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Dim omachine
Dim lpj
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
for each lpj in oDesktop.GetProjectList()
msgbox lpj
next

Python Syn- GetProjectList()


tax

Python list_of_projects = oDesktop.GetProjectList()


Example

Desktop Object Script Commands 3-31


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetScriptingToolsHelper

Note:
This command is for internal ANSYS use only.

Returns the object for the scripting tools helper.

UI Access NA

Name Type Description


Parameters
None

Object
Return Value
ScriptingTools helper object

Python Syn- GetScriptingToolsHelper()


tax

Python oDesktop.GetScriptingToolsHelper()
Example

VB Syntax GetScriptingToolsHelper
VB Example oDesktop.GetScriptingToolsHelper()

GetSysLibDirectory
Get the path to the SysLib directory.

UI Access NA

Name Type Description


Parameters
None

String
Return Value
The path to the SysLib directory.

Python GetSysLibDirectory()
Syntax

Desktop Object Script Commands 3-32


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python AddInfoMessage(str(oDesktop.GetSysLibDirectory))
Example

VB Syntax GetSysLibDirectory
VB Example MsgBox oDesktop.GetSysLibDirectory

VB Example:
------------------------------------------------------
message box returns system library directory path
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
sys = oDesktop.GetSysLibDirectory()
msgbox(oDesktop.GetSysLibDirectory())

Python GetSysLibDirectory()
Syntax

Python AddInfoMessage(str(oDesktop.GetSysLibDirectory))
Example

GetTempDirectory
Gets the path to the Temp directory.

UI Access NA

Name Type Description


Parameters
None

Desktop Object Script Commands 3-33


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

String
Return Value
The path to the Temp directory.

Python GetTempDirectory()
Syntax

Python AddInfoMessage(str(oDesktop.GetTempDirectory))
Example

VB Syntax GetTempDirectory
VB Example MsgBox oDesktop.GetTempDirectory

VB Example:
tempdir = oDesktop.GetTempDirectory
VB Example:
------------------------------------------------------
message box returns temp directory path
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
tempdir = oDesktop.GetTempDirectory()
msgbox(oDesktop.GetTempDirectory())

GetUserLibDirectory
Gets the path to the UserLib directory.

Desktop Object Script Commands 3-34


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access NA

Name Type Description


Parameters
None

String
Return Value
The path to the UserLib directory.

Python GetUserLibDirectory()
Syntax

Python AddInfoMesage(str(oDesktop.GetUserLibDirectory()))
Example

VB Syntax GetUserLibDirectory
VB Example MsgBox oDesktop.GetUserLibDirectory

VB Example:
------------------------------------------------------
message box returns userlib directory path
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
userlib = oDesktop.GetUserLibDirectory()
msgbox(oDesktop.GetUserLibDirectory())

Desktop Object Script Commands 3-35


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetVersion
Use: Returns a string representing the version.

UI Access NA

Name Type Description


Parameters
None

String
Return Value
The version string of the product.

Python Syn- GetVersion()


tax

Python AddInfoMessage(str(oDesktop.GetVersion()))
Example

VB Syntax GetVersion()
VB Example Msgbox oDesktop.GetVersion

VB Example:
------------------------------------------------------
message box displays version number
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow

Desktop Object Script Commands 3-36


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

msgbox(oDesktop.GetVersion())

ImportANF
Use:Import an ANF file into a new project.
Command:File > Import > ANF
Syntax:ImportANF<"ANF_filename">
Return Value:None
Parameters:<"ANF_filename">
Type: text
Example:
oDesktop.RestoreWindow()
Set oTool = oDesktop.GetTool("ImportExport")
oTool.ImportANF("C:/AnsTranslator/results/package 4.anf")
Example:
------------------------------------------------------
Example shows how to import an ANF file.
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Dim omachine
Dim oTool
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oTool = oDesktop.GetTool("ImportExport")

Desktop Object Script Commands 3-37


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oTool.ImportANF("C:\Program Files\An-
sysEM\AnsysEM18.0\Win64\Examples\Package\package_board.anf")

ImportAutoCAD
Use:Import an AutoCAD file into a new project.
Command:File >Import > AutoCAD
Syntax:ImportAutoCAD <"AutoCADfilename">, <"Controlfilename">
Return Value:None
Parameters:<"AutoCADfilename">
Type: text
Description: name of the AutoCAD file to import
<"OutputEDBfilename">
Type: text
Description: name of the EDB file to create during the import.
<"Controlfilename">
Type: text
Description: name of the xml control file to use to guide the import.
This string can be empty ("") if no control file is to be used.
VB Example:
Set oTool = oDesktop.GetTool("ImportExport")
oTool.ImportDXF"a4lines.dxf", "a4lines.aedb.edb" "a4lines.xml"

ImportGDSII
Use:Import a GDSII file into a new project.
Command:File > Import > GDSII
Syntax:ImportGDSII
<"GDSIIfilename">
<"OutputEDBfilename">,
<"Controlfilename">,
<"PropertyMappingfilename">
Return Value:None
Parameters:<"GDSIIfilename">

Desktop Object Script Commands 3-38


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type: text
Description: name of the GDSII file to import
<"OutputEDBfilename">
Type: text
Description: name of the EDB file to create during the import.
<"Controlfilename">
Type: text
Description: name of the xml control file to use to guide the import.
This string can be empty ("") if no control file is to be used.
<"PropertyMappingfilename">
Type: text
Description: name of the property mapping file to use to guide the import.
This string can be empty ("") if no control file is to be used.
VB Example:
Set oTool = oDesktop.GetTool("ImportExport")
oTool.ImportGDSII "test.gds", "test.aedb.edb", "test.xml",
"test.txt"

ImportGDSII ([
<"GDSIIfilename">
Python Syn- <"OutputEDBfilename">,
tax
<"Controlfilename">,
<"PropertyMappingfilename">
])
oTool.ImportGDSII
([
Python
Example "test.gds", "test.aedb.edb",
"test.xml", "test.txt"
])
,

Desktop Object Script Commands 3-39


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ImportODB
Use:Import an ODB++ file into a new project.
Command:File > Import > ODB++
Syntax:ImportODB++ <"ODB++filename">, <"OutputEDBfilename>, <"Controlfilename">
Return Value:None
Parameters:<"ODB++filename">
Type: text
Description: name of the ODB++ file to import
<"OutputEDBfilename">
Type: text
Description: name of the EDB file to create during the import.
<"Controlfilename">
Type: text
Description: name of the xml control file to use to guide the import.
This string can be empty ("") if no control file is to be used.
VB Example:
Set oTool = oDesktop.GetTool("ImportExport")
oTool.ImportODB "test.tgz", "test.aedb.edb", "test.xml"

LaunchJobMonitor
Use: For use in starting job monitoring. This brings up the Monitor Job dialog box.

UI Access Launch Job Monitor

Name Type Description


Parameters
projectPath: Path to the project file to be monitored

Return Value None

Python LaunchJobMonitor()
Syntax

Python oDesktop.LaunchJobMonitor("C:\\projects\\basic.aedt")
Example

Desktop Object Script Commands 3-40


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syn- LaunchJobMonitor()
tax

VB oDesktop.LaunchJobMonitor("C:\\projects\\basic.aedt")
Example

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

UI Access File>New

Name Type Description


Parameters
None

Return Value Object, the project that is added.

Python Syn- NewProject()


tax

Python oProject = oDesktop.NewProject()


Example

VB Syntax NewProject
VB Example Set oProject = oDesktop.NewProject

VB Example:
------------------------------------------------------
Example creates a new project.
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule

Desktop Object Script Commands 3-41


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oProjects
Dim omachine
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.NewProject

OpenAndConvertProject
Opens a legacy project and converts or copies it to .aedt format.

UI Access Click File>Open, and choose a legacy project

Name Type Description


itemPath <string> full project path of the legacy project
legacyChoice <integer> 0: show conversion dialog box, (same as
File>Open of a legacy file
Parameters 1. rename (changes extension to .aedt, the ori-
ginal file and results are renamed)
2. copy (creates new file with .aedt extension,
and the original file and results remain avail-
able)

Return Value An object reference to the newly opened project which has the .aedt extension

Warning: If project file / results with the same name and .aedt extension already exist in the same
directory, they will be overwritten.

Pytho- OpenAndConvertProject(filePath, legacyChoice)


n Syn-
tax

oProject = oDesktop.OpenAndConvertProject("c:\\-
files\\optimtee.hfss", 1)
Pytho-
n Note: optimtee.hfss is gone after this code executes
Examp- oProject = oDesktop.OpenAndConvertProject("c:\\-
le
files\\optimtee.hfss", 2)
Note: optimtee.hfss remains after this code executes

VB OpenAndConvertProject(filePath, legacyChoice)

Desktop Object Script Commands 3-42


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax

VB
Set oProject = oDesktop.OpenAndConvertProject("c:\-
Exam- files\optimtee.hfss", 1)
ple
Note: optimtee.hfss is gone after this code executes

OpenMultipleProjects
Use: Opens all files of a specified type in a specified directory.
Command: Click File>Multiple Open
Syntax: OpenMultipleProjects <Directory> <FileType>
Return Value: None
Parameters: <Directory>
Type: <string>
<FileType>
Type: <string>
VB Example:
oDesktop.OpenMultipleProjects "D:/Projects", "*.aedt"

OpenProject
Opens a specified project.

UI Access Click File>Open

Name Type Description


Parameters
<FileName> <string> Full path of the project to open

Return Value An object reference to the newly opened project.

Python OpenProject(<Filename>)
Syntax

Python oDesktop.OpenProject("C:/Projects/MyProject.aedt")
Example

VB Syntax OpenProject <FileName>

Desktop Object Script Commands 3-43


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB oDesktop.OpenProject "D:/Projects/Project1.aedt"
Example

VB Syn- OpenProject <FileName>


tax

Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor

VB Dim oModule
Example Dim oProjects
Dim omachine
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
oDesktop.OpenProject "E:/helical_antenna.aedt"

OpenProjectWithConversion

Note:
This command is for internal ANSYS use only.

Python Syn- OpenProjectWithConversion()


tax

Python oDesktop.OpenProjectWithConversion()
Example

Paste (Project Object)


Use:Pastes a design in the active project.

UI Access Edit>Paste

Desktop Object Script Commands 3-44


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name Type Description


Parameters
None

Return Value None

Python Syn- Paste()


tax

Python oProject.Paste()
Example

VB Syntax Paste
VB Example oProject.Paste

Example:
------------------------------------------------------
Example Script
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Dim omachine
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject()
oProject.CopyDesign "Differential"
oProject.Paste

Desktop Object Script Commands 3-45


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

For Q3D Extractor, the Paste command works as follows:


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 guaranteed to be
alphabetical.
Parameters: None
Example: arrayEntities = oEditor.Paste

Paste (Project Object)


Pastes a design in the active project.

UI Access Edit>Paste

Name Type Description


Parameters
None

Return Value None

Python Syn- Paste()


tax

Python oProject.Paste()
Example

VB Syntax Paste
VB Example oProject.Paste

VB Example:
------------------------------------------------------
Example Script
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject

Desktop Object Script Commands 3-46


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Dim omachine
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject()
oProject.CopyDesign "Differential"
oProject.Paste

For Q3D Extractor the Paste command works as follows:


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 guaranteed to be
alphabetical.
Parameters: None
VB Example: arrayEntities = oEditor.Paste

PauseRecording
Temporarily stop script recording.

UI Access NA

Name Type Description


Parameters
None

Return Value None

Python Syn- PauseRecording()


tax

Desktop Object Script Commands 3-47


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python oDesktop.PauseRecording()
Example

VB Syntax PauseRecording
VB Example oDesktop.PauseRecording

PauseScript
Pause the execution of the script and pop up a message to the user. The script execution will not
resume until the user chooses
Tools>Resume Script

UI Access Tools>Pause Script

Name Type Description


Parameters
<Message> String Any Text

Return Value None

Python PauseScript (<Message>)


Syntax

Python oDesktop.PauseScript("Text to display in pop-up dialog")


Example

VB Syn- PauseScript <Message>


tax

VB oDesktop.PauseScript "Text to display in pop-up dialog"


Example

VB Example:
------------------------------------------------------
Example pauses a script. Resume script to run it.
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject

Desktop Object Script Commands 3-48


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Dim omachine
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
oDesktop.PauseScript "Script is paused. Click OK to continue"
Set oProject = oDesktop.NewProject
oDesktop.OpenProject "E:/helical_antenna.aedt"

Print
Use: Prints the contents of the active view window.

UI Access File>Print

Name Type Description


Parameters
None

Return Value None

Python Syn- Print()


tax

Python oDesktop.Print()
Example

VB Syntax Print
VB Example oDesktop.Print

VB Example:
------------------------------------------------------
Example prints the contents of the active window.

Desktop Object Script Commands 3-49


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Dim omachine
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
oDesktop.Print

QuitApplication
Exits the desktop.

UI Access File>Exit

Name Type Description


Parameters
None

Return Value None

Python Syn- QuitApplication()


tax

Python oDesktop.QuitApplication()
Example

VB Syntax QuitApplication
VB Example oDesktop.QuitApplication

VB Example:
oDesktop.QuitApplication

Desktop Object Script Commands 3-50


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

------------------------------------------------------
Example : quit an application.
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Dim omachine
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
oDesktop.QuitApplication

RefreshJobMonitor
For use in monitoring a job.

UI Access Monitor Jobs

Name Type Description


Parameters
None

A string specifing the job state. The result could be one of the following strings:
"Monitor Not Visible"
"Queued"
"Running"
Return Value "Shutting Down"
"Unknown"
"Completed"
"Not Monitoring"
"Starting Monitoring"

Desktop Object Script Commands 3-51


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- RefreshJobMonitor()


tax

Python oDesktop.RefreshJobMonitor()
Example

VB Syntax RefreshJobMonitor()
VB Example oDesktop.RefreshJobMonitor()

VB Example:
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """C:\\Program Files\\An-
sysEM\\AnsysEM18.0\\Win64\\ansysedt.exe"" -ng -monitor -batchsolve
c:\\Projects\\basic.aedt"
'WshShell.Run "notepad"
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
oDesktop.LaunchJobMonitor "c:\\projects\\basic.aedt"
do
a = oDesktop.RefreshJobMonitor()
msg = "state is " + a
oDesktop.AddMessage "", "", 1, a
if a = "Monitor Not Visible" then
exit do

Desktop Object Script Commands 3-52


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

end if
loop
oDesktop.AddMessage "", "", 1, "Done monitoring"

RestoreProjectArchive
Restores a specified project archive to the specified file path.
Command: File>Restore Archive...
Syntax: RestoreProjectArchive <ArchiveFilePath>, <ProjectFilePath>, <OverwriteExistingFiles>,
<OpenProjectAfterRestore>;
Return Value: None
Parameters: <ArchiveFilePath>
Type: string
Archive file path.
<ProjectFilePath>,
Type: string
<OverwriteExitingFiles>,
Type: Boolean
Whether to overwriting any existing files during extraction.
<OpenProjectAfterRestore>,
Type Boolean
Whether to open the project in the desktop.
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()

Desktop Object Script Commands 3-53


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oDesktop.RestoreWindow
oDesktop.RestoreProjectArchive "C:\User-
s\kmchrist\Documents\OptimTee.aedtz", _
"C:\Documents\OptimTee.aedt", false, true

RestoreWindow
Restores a minimized Desktop window.

UI Access NA

Name Type Description


Parameters
None

Return Value None

Python Syn- RestoreWindow()


tax

Python oDesktop.RestoreWindow()
Example

VB Syntax RestoreWindow
VB Example oDesktop.RestoreWindow

oDesktop.RestoreWindow
------------------------------------------------------
Example : restores minimized Desktop window.
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects

Desktop Object Script Commands 3-54


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim omachine
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow

ResumeRecording
Resume recording a script.

UI Access NA

Name Type Description


Parameters
None

Return Value None

Python Syn- ResumeRecording()


tax

Python oDesktop.ResumeRecording()
Example

VB Syntax ResumeRecording
VB Example oDesktop.ResumeRecording

RunACTWizardScript

Note:
This command is for internal ANSYS use only.

Python Syn- RunACTWizardScript()


tax

Python oDesktop.RunACTWizardScript()
Example

Desktop Object Script Commands 3-55


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

RunProgram
Runs an external program.

UI Access NA

Name Type Description


<ProgName> String Name of the program to run.
<ProgPath> String Location of the program. Pass in an empty
Parameters string to use the system path.
<WorkPath> String Working directory in which program will start.
< ArgArray> Array of Arguments to pass to the program. If no argu-
Strings ments, pass in None

Return Value None

Python  RunProgram (<ProgName>, <ProgPath>, <WorkPath>, <ArgArray>)


Syntax

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

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


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

RunScript
Launches another script from within the script currently being executed.

UI Access Tools>Run Script

Name Type Description


<SCriptPath> String Name or full path of the script to execute.
Parameters If the full path to the script is not spe-
cified, Twin Builder searches for the spe-
cified script in the following locations, in
this order:

Desktop Object Script Commands 3-56


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

1. 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.

2. User library directory.

This is the userlib subdirectory in the library


directory. The library directory can be spec-
ified in the General Options dialog box (click
Tools>Options>General Options to open
this dialog box) under the Project Options
tab.

3. System library directory.

This is the syslib subdirectory in the library dir-


ectory. The library directory can be speci-fied in
the General Options dialog box (click
Tools>Options>General Options to open
this dialog box) under the Project Options
tab.

4. HFSS installation directory.

Long
Return Value
the return code for the script method.

Python Syn- RunScript (<ScriptPath>)


tax

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

VB Syntax RunScript <ScriptPath>


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

Desktop Object Script Commands 3-57


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

RunScriptWithArguments
Similar to RunScript, launch another script from within the currently executing script, but with argu-
ments.

UI Access NA

Name Type Description


< ScriptPath> String The name or full path of the script to
execute. If the full path to the script is not
specified, the software looks for the
script in the following locations:

l Personal library directory: "Per-


sonalLib". The PersonalLib directory
can be specified in Tools>Op-
tions>General Options on the 'Project
Options' tab.
Parameters l User library directory: directory "user-
lib". The UserLib directory can be spe-
cified in Tools>Options>General
Options on the 'Project Options' tab.
l System library directory: directory
"syslib". The SysLib directory can be
specified in Tools>Options>General
Options on the 'Project Options' tab.
l Software installation directory
<Arguments> String The arguments to supply to the specified
script.

Long
Return Value
the return code for the script method.

Python Syn- RunScriptWithArguments (<ScriptPath>, <Arguments>)


tax

Python oDesktop.RunScriptWithArguments
Example ("C:/Project/test2.py", "foo")

Desktop Object Script Commands 3-58


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax RunScriptWithArguments <ScriptPath>, <Arguments>


oDesktop.RunScriptWithArguments
VB Example
"C:/Project/test2.vbs", "foo"

SelectScheduler
Select the scheduler used for batch job submission. It tries non-graphical selection of the sched-
uler, attempting to get version information from the scheduler in order to check for successful selec-
tion, and if unable to get the information, it then displays the Select Scheduler window, waiting for
the user to complete the settings.

UI Access Select Scheduler

Name Type Description


option String One of the following options (not case sens-
itive):

l Empty string for remote RSM service


l "RSM" for local RSM
l "Windows HPC" for Windows HPC
l "LSF" for Load-Sharing Facility
l "SGE" for Grid Engine (GE, OGE,
SGE, UGE, etc.)
l "PBS" for Portable Batch Sched-
uler/System (PBSPro, Torque, Maui,
Parameters etc.)
l"ANSYS Cloud" for ANSYS Cloud
address (optional) String String specifying the IP address or hostname
of the head node or for the remote host run-
ning the RSM service.
username (optional) String Username string to use for remote RSM ser-
vice (or blank to use username stored in cur-
rent submission host user settings). If the
(non-blank) username doesn't match the user-
name stored in current submission host user
settings, then the Select Scheduler dialog is
displayed to allow for password entry prior to
job submission.
forcePasswordEntry String Boolean used to force display of the Select
(optional) Scheduler GUI to allow for password entry
prior to job submission.

Return Value The selected scheduler (if selection was successful, this string should match the

Desktop Object Script Commands 3-59


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

input option string, although it could differ in upper/lowercase).

Python Select Scheduler(option, address, username, forcePasswordEntry)


Syntax

Python result = oDesktop.SelectScheduler("Windows HPC",


Example "headnode.win.example.com")

VB Syntax Select Scheduler(option, address, username, forcePasswordEntry)

VB result = oDesktop.SelectScheduler("Windows HPC",


Example "headnode.win.example.com")

SetActiveProject
Specify the name of the project that should become active in the desktop. Return that project.

UI Access NA

Name Type Description


Parameters < ProjectName> String The name of the project already in the
Desktop that is to be activated.

Return Value Object, the project that is activated

Python SetActiveProject (<ProjectName>)


Syntax

Python oProject = oDesktop.SetActiveProject ("Project1")


Example

VB Syn- SetActiveProject <ProjectName>


tax

VB Set oProject = oDesktop.SetActiveProject ("Project1")


Example

Example:
------------------------------------------------------

Desktop Object Script Commands 3-60


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Example sets an existing project as active.


------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Dim omachine
Dim lpj
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject ("Project9")
msgbox "Active Project Set to " + oDesktop.GetActiveProject
().GetName()

SetActiveProjectByPath
Specify the name of the project that should become active in the desktop. Return that project. 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 pro-
ject.

UI Access NA

Name Type Description


Parameters <ProjectName> String The full pathname of the project already in the
Desktop that is to be activated.

Return Value Object, the project that is activated.

Python Syn- SetActiveProjectByPath(ProjectName)


tax

Desktop Object Script Commands 3-61


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oProject = oDesktop.SetActiveProjectByPath
Python
Example ("c:\Projects\MyProject.aedt")

VB Syntax SetActiveProjectByPath(ProjectName)
Set oProject = oDesktop.SetActiveProjectByPath
VB
Example
("c:\Projects\MyProject.aedt")

Example:
------------------------------------------------------
Example sets an existing project as active by path.
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Dim omachine
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProjectByPath("E:/helical_
antenna.aedt")
msgbox "Active Project Set to " + oDesktop.GetActiveProject
().GetName()

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

Desktop Object Script Commands 3-62


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access NA

Name Type Description


Parameters
<DirectoryPath> String The path to the SysLib Directory

Return Value None

Python Syn-  SetLibraryDirectory (<DirectoryPath>)


tax

Python oDesktop.SetLibraryDirectory("c:\libraries")
Example

VB Syntax  SetLibraryDirectory <DirectoryPath>


VB oDesktop.SetLibraryDirectory"c:\libraries"
Example

SetProjectDirectory
UI Access NA

Name Type Description


Parameters < DirectoryPath> String The path to the Project directory. This should
be writeable by the user.

Return Value None

Python Syn- SetProjectDirectory (<DirectoryPath>)


tax

Python oDesktop.SetProjectDirectory("c:\projects")
Example

VB Syntax SetProjectDirectory <DirectoryPath>


VB oDesktop.SetProjectDirectory "c:\projects"
Example

Desktop Object Script Commands 3-63


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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

UI Access NA

Name Type Description


Parameters < DirectoryPath> String The path to the Temp directory. This should
be writeable by the user.

Return Value None

Python Syn- SetTempDirectory (<DirectoryPath>)


tax

Python oDesktop.SetTempDirectory("c:\tmp")
Example

VB Syntax SetTempDirectory <DirectoryPath>


VB Example oDesktop.SetTempDirectory "c:\tmp"

Example:
------------------------------------------------------
Example sets Temp directory path.
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Dim omachine
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()

Desktop Object Script Commands 3-64


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oDesktop.RestoreWindow
oDesktop.SetTempDirectory("C:\temp")
msgbox "Temp Directory Set to " + oDesktop.GetTempDirectory()

ShowDockingWindow
Shows or hides a docking window.

UI Access Right click docking window > Show/Hide.

Name Type Description


< windowName> String The window name (for example, "Message
Parameters Manager", "Component Libraries", "Prop-
erties")
< show> Boolean True to show; False to hide.

Return Value None.

Python ShowDockingWindow (<windowName>, <show>)


Syntax

Python oDesktop.ShowDockingWindow('Message Manager',False)


Example

VB Syn- ShowDockingWindow <windowName> <show>


tax

VB oDesktop.ShowDockingWindow "Message Manager" False


Example

Sleep
Suspends execution of HFSS for the specified number of milliseconds, up to 60,000 milliseconds
(1 minute).

UI Access NA

Name Type Description


Parameters <TimeInMil- Integer The time that the execution should be sus-
liseconds> pended in milliseconds

Return Value None

Desktop Object Script Commands 3-65


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- Sleep (<TimeInMilliseconds>)


tax

Python oDesktop.Sleep(1000)
Example

VB Syntax Sleep <TimeInMilliseconds>


VB Example oDesktop.Sleep 1000

SubmitJob
To submit a batch job to a scheduler. When submitting the same project file multiple times, you
should have the script wait for each job (or jobs for multi-step) to finish, which can be done via the
monitoring functions LaunchJobMonitor() and RefreshJobMonitor(), checking the result of
RefreshJobMonitor() in a loop until it returns completed ("Monitor Not Visible") status.

UI Access Submit Job

Name Type Description


settingsPath: string Path to the settings file (exported from the
Submit Job GUI) to use for submission.
Parameters
projectPath: string Path to the project file to use in the batch job.
This could be an archive (.aedtz file) or an un-
archived project.
design (optional): string Name of the design to use for batch solve.
setup (optional): string Name of the specific setup to solve.

Return Value Array of job ID strings (empty if no jobs submitted).

Python SubmitJob(settingsPath, projectPath, design, setup)


Syntax

jobIDs = oDesktop.SubmitJob("C:\\hpc-settings\\Submit_
Job_Settings.areg", "C:\\projects\\basic.aedt"))
Python
moreIDs = oDesktop.SubmitJob("C:\\hpc-settings\\Submit_
Example
Job_Settings.areg", "C:\\projects\\basic.aedt",
"Design1", "Setup1")

Desktop Object Script Commands 3-66


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syn- SubmitJob(settingsPath, projectPath, design, setup)


tax

jobIDs = oDesktop.SubmitJob("C:\\hpc-settings\\Submit_
Job_Settings.areg", "C:\\projects\\basic.aedt"))
VB
moreIDs = oDesktop.SubmitJob("C:\\hpc-settings\\Submit_
Example
Job_Settings.areg", "C:\\projects\\basic.aedt",
"Design1", "Setup1")

TileWindows
Use: Arrange all open windows in a tiled format.
Command: From main menu, Window>Tile Horizontally or Window>Tile Vertically.
Syntax: TileWindows(<TilingFlag>)TileWindows(<)
Return Value: None
Parameters: <TilingFlag>
Type: <int>
Tile vertically when <TilingFlag> is 0 and horizontally when <TilingFlag> is 1
VB Example:
oDesktop.CloseAllWindows()
VB Example:
------------------------------------
Example Script
------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.TileWindows(0)

Desktop Object Script Commands 3-67


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- TileWindows()


tax

Python oDesktop.TileWindows(0)
Example

Desktop Commands For Registry Values


The ANSYS Registry is stored as XML format file. By default it is located at C:\User-
s\<UserName>\Documents\Ansoft\<AnsysProductNameversion>\config\<PC_NAME>_user-
.XML. Most of the ANSYS product configuration information is stored in this XML file. These
methods allow you to change the product configuration in VB-script or Python script.
For example, to set the DSO & HPC analysis setup for HFSS with Python script:

1. In a PC start HFSS go to the DSO and HPC options dialog, create a setup name it as "test"
2. Export the setup to a file c:\tem\test.acf.
3. Copy the exported file to a target PC f:\temp\test.acf.
4. Run the following script.

#import the setup


oDesktop.SetRegistryFromFile("f:\\temp\\test.acf")
# Set Active Setup to "test"
oDesktop.SetRegistryString("Desktop/ActiveDSOConfigurations/HFSS", "test")

DoesRegistryValueExist
GetRegistryInt
GetRegistryString
SetRegistryFromFile
SetRegistryInt
SetRegistryString
DoesRegistryValueExist
Use: Determine if a registry value exists.
Command: None
Syntax: DoesRegistryValueExist <KeyName>
Return Value: Boolean. True if key exists. False otherwise.

Desktop Object Script Commands 3-68


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters: <KeyName> - registry key name with the full path.


VB Example:
bExist = oDesktop.DoesRegistryValueExist("Desktop/Act-
iveDSOConfigurations/HFSS")
GetRegistryInt
Use: Obtain RegistryKey integer value.
Command: None
Syntax: GetRegistryIn(<KeyName>)
Return Value: Integer for success, if the integer value is found. Return as Bad-Argument-Value, if
Registry key does not exist or it is not an integer value.
Parameters: <KeyName>
Registry key name with the full path.
VB Example:
num = oDesktop.GetRegistryInt("Desktop/Set-
tings/ProjectOptions/HFSS/UpdateReportsDynamicallyOnEdits")
GetRegistryString
Use: Obtain RegistryKey string value.
Command: None.
Syntax: GetRegistryString <KeyName> <PVal>
Return Value: String for success. Bad argument if they key is not defined or has an integer value.
Parameters: <KeyName>
Registry key name with the full path.
VB Example:
activeDSO = oDesktop.GetRegistryString("Desktop/ActiveDSOConfigurations/HFSS")

SetRegistryFromFile
Configures a registry by specifying an Analysis Configuration file which must have been exported
from the HPC and Analysis panel.
Command: None.
Syntax: SetRegistryFromFile "<filePath>"

Desktop Object Script Commands 3-69


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Return Value: Success if Analysis configuration is imported. Bad argument value if the file is not
found or does not contain valid analysis configuration data.
Parameters: <filePath>
Full path to an Analysis Configuration file.
VB Example:
oDesktop.SetRegistryFromFile "c:/temp/test.acf"
SetRegistryInt
Sets a registry key with an integer value.
Command: None
Syntax: SetRegistryInt "<KeyName>", <int>
Return Value: Success if the key is defined as an integer. Bad argument value if a key is not
defined, or if the value is a text string.
Parameters: <KeyName>
Registry key name with full path.
<int>
New integer value.
VB Example:
oDesktop.SetRegistryInt "Desktop/Set-
tings/ProjectOptions/HFSS/UpdateReportsDynamicallyOnEdits", 0
SetRegistryString
Sets a string value for a specified registry key.
Command: None.
Syntax: SetRegistryString "<KeyPath>" "<val>"
Return Value: Success, if the key is defined as a text string. Bad argument value if the key is not
defined or requires an integer value.
Parameters: <KeyName>
Registry key name with full path.
<val>
New string value.
VB Example:

Desktop Object Script Commands 3-70


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oDesktop.SetRegistryString "Desktop/ActiveDSOConfigurations/HFSS",
"Local"

Desktop Object Script Commands 3-71


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

3-72
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

4 - Running Instances Manager Script Com-


mands
The Running Instances Manager is a scripting object that lets you identify and connect to all running
instances of Electronics Desktop. oDesktop objects that are returned provide full scripting func-
tionality. Running Instances Manager commands should be executed by the oDesktop object. For
example:
Set oRunningInstances = oDesktop.GetRunningInstancesMgr()
GetAllRunningInstances
GetRunningInstanceByProcessID
GetRunningInstanceByProject

GetAllRunningInstances
Returns a list of running instances of ANSYS Electronics Desktop.

UI Access NA
Parameters None.
Return Value Array containing list of ANSYS Electronics Desktop instances.

Python GetAllRunningInstances()
Syntax

Python obj = oRunningInstances.GetAllRunningInstances()


Example

VB Syn- GetAllRunningInstances
tax

VB set obj = oRunningInstances.GetAllRunningInstances()


Example

GetRunningInstanceByProcessID
Returns the instance of ANSYS Electronics Desktop that is running a specified process.

UI Access NA

Parameters Name Type Description

Running Instances Manager Script Commands 4-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<processID> Integer Process ID

Return Value String of the returned instance.

Python GetRunningInstanceByProcessID(<processID>)
Syntax

Python obj = oRunningInstances.GetRunningInstanceByProcessID


Exampl- (12345)
e

VB GetRunningInstanceByProcessID <processID>
Syntax

VB set obj = oRunningInstances.GetRunningInstanceByProcessID


Exampl- (12345)
e

GetRunningInstanceByProject
Returns the instance of ANSYS Electronics Desktop that contains a specified open project.

UI Access NA

Name Type Description


Parameters
<projectNameOrPath> String Project name or full file path.

Return Value String of the returned instance.

Python GetRunningInstanceByProject(<projectNameOrPath>)
Syntax

Python obj = oRunningInstances.GetRunningInstanceByProject('my_pro-


Exampl- ject')
e

VB GetRunningInstanceByProject <projectNameOrPath>
Syntax

VB set obj = oRunningInstances.GetRunningInstanceByProject("my_


Examp- project")
le

Running Instances Manager Script Commands 4-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

5 - Project Object Script Commands


Project commands should be executed by the oProject object. One example of accessing this
object is:
Set oProject = oDesktop.GetActiveProject()
AnalyzeAll
ClearMessages
Close
CopyDesign
CutDesign
DeleteDesign
DeleteToolObject
GetActiveDesign
GetChildNames [Project]
GetChildObject [Project]
GetChildTypes [Project]
GetConfigurableData
GetDefinitionManager
GetDependentFiles
GetDesign
GetEDBHandle
GetLegacyName
GetName [Project]
GetPath
GetPropNames [Project]
GetPropValue [Project]
GetTopDesignList
InsertDesign
InsertDesignWithWorkflow
InsertToolObject
Paste

Project Object Script Commands 5-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Redo
Rename
Save
SaveAs
SetActiveDefinitionEditor
SetActiveDesign
SetPropValue [Project]
SimulateAll
Undo
UpdateDefinitions
ValidateDesign

AnalyzeAll [project]
Runs the project-level script command from the script, which simulates all solution setups and Opti-
metrics setups for all design instances in the project. The UI waits until simulation is finished before
continuing with the script.

UI Access Project>Analyze All

Name Type Description


Parameters
None

Return Value None

Python Syn- AnalyzeAll()


tax

Python oProject.AnalyzeAll()
Example

VB Syntax AnalyzeAll
VB Example oProject.AnalyzeAll

ClearMessages
Clears the Message Window

Project Object Script Commands 5-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access NA

Name Type Description


Parameters
None

Return Value None

Python Syn- ClearMessages()


tax

Python oproject.ClearMessages()
Example

VB Syntax ClearMessages
VB Example oproject.ClearMessages

Close
Closes the active project. Unsaved changes will be lost.
Command: None
Syntax: Close
Return Value: None
Parameters: None
VB Example:
oProject.Close

CopyDesign
Copies a design

UI Access Edit>Copy

Name Type Description


Parameters
DesignName String Name of the design

Return Value Value

Python Syn- CopyDesign (<DesignName>)

Project Object Script Commands 5-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

tax

Python oProject.CopyDesign ("HFSSDesign1")


Example

VB Syntax CopyDesign <DesignName>


VB Example oProject.CopyDesign "HFSSDesign1"

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

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.

UI Access Edit>Cut

Name Type Description


Parameters
<DesignName> String Name of the design

Return Value None

Python Syn- CutDesign (<DesignName> )


tax

Python oProject.CutDesign("SimplorerDesign1")
Example

VB Syntax CutDesign <DesignName>


VB Example oProject.CutDesign "SimplorerDesign1"

DeleteDesign
Deletes a specified design in the project.

Project Object Script Commands 5-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access Edit>Delete

Name Type Description


Parameters
<DesignName> String The name of the design

Return Value None

Python Syn- DeleteDesign (<DesignName>)


tax

Python oProject.DeleteDesign ("SimplorerDesign2")


Example

VB Syntax DeleteDesign <DesignName>


VB oProject.DeleteDesign "SimplorerDesign2"
Example

DeleteToolObject

Note:
This command is for internal ANSYS use only.

Python Syn- DeleteToolObject()


tax

Python oProject = oDesktop.GetActiveProject()


Example oProject.DeleteToolObject()

GetActiveDesign
Returns the design in the active project

Note:

GetActiveDesign will return normally if there are no active objects.

Project Object Script Commands 5-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access NA

Name Type Description


Parameters
None

Return Value  The active design

Python Syn- GetActiveDesign()


tax

Python oDesign = oProject.GetActiveDesign()


Example

VB Syntax GetActiveDesign
VB Set oDesign = oProject.GetActiveDesign()
Example

GetChildNames [Project]
Use: Gets child names of the project object.
Syntax: GetChildNames(type)
Return Value: Returns names of children for the queried object.
Parameters: type - optional parameter, default to "Design"; should use values returned by
GetChildTypes().

Python Syn- GetChildNames (type)


tax

oProject=oDesktop.GetActiveProject()

Python arrDesignNames = oProject.GetChildNames()


Example oProject.GetChildNames("Variable")
["$VarName1", "$VarName2"]

VB Syntax GetChildNames(type)
set oProject=oDesktop.GetActiveProject()
VB Example
arrDesignNames = oProject.GetChildNames()

Project Object Script Commands 5-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

arrVarbleNames = oProject.GetChildNames("Variable")

GetChildObject [Project]
Returns the Child Object of the project.

Note:

GetChildObject will return normally if there are no active objects.

UI Access NA

Name Type Description


Parameters Object path String The path may include multiple generations. Like
("designObject/moduleObj/SetupObject"). See
Object Path discussion here.

Return a child object if object is found. Otherwise cause script error.


Value

Python Syn- GetChildObject()


tax

oProject = oDeskop.GetActiveProject()
oDesign = oProject.GetChildObject(“TeeModel”)
Python
Example oVariable = oProject.GetChildObject("VariableName")
oReport = oProject.GetChildObject("TeeModel/Results/S
Parameter Plot 1")

VB GetChildObject()
Syn-
tax

Set oProject = oDesktop.GetActiveproject()

VB
set oDesign = oProject.GetChildObject(“TeeModel”)
Exam- set oVariable = oProject.GetChildObject("VariableName")
ple
set oReport = oProject.GetChildObject("TeeModel/Results/S
Parameter Plot 1")

Project Object Script Commands 5-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetChildTypes [Project]
Use: Gets child types of the project object..
Syntax: GetChildTypes()
Return Value: Returns type of children for the queried object.

Python Syn- GetChildTypes ()


tax

oProject=oDesktop.GetActiveProject()
oprj.GetName()
Python
Example
'Project1'
oprj.GetChildTypes()
['Design', 'Variable']

GetConfigurableData (Project)

Note:
This command is for internal ANSYS use only.

Python Syn- GetConfigurableData()


tax

Python oProjectGetConfigurableData()
Example

GetDefinitionManager
Obtain the DefinitionManager object.

UI Access NA

Name Type Description


Parameters
None

Return Value Object for the DefinitionManager

Project Object Script Commands 5-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python GetDefinitionManager()
Syntax

Python oDefinitionManager = oProject.GetDefinitionManager()


Example

VB Syn- GetDefinitionManager
tax

VB Set oDefinitionManager = oProject.GetDefinitionManager


Example

GetDependentFiles
Provides a list of the external files referenced in the project, including characteristic (for example,
MDX) and coupled project files; does not include those in <libdir>/Data directories.

UI Access NA

Name Type Description


Parameters
None

Return Value The list of referenced files.

Python Syn- GetDependentFiles()


tax

Python files = oProject.GetDependentFiles()


Example

VB Syntax GetDependentFiles
VB Example files = oProject.GetDependentFiles

VB Example:
files = oProject.GetDependentFiles
for i = 0 to UBound(files)
msgbox files(i)
next

Project Object Script Commands 5-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetDesign
Returns the interface to a specific design in a given project.

UI Access NA

Name Type Description


Parameters
<designName> string Name of the design

Return Value Returns the interface to the specified design

Python Syn- GetDesign(<designName>)


tax

Python oProject.GetDesign("HFSSDesign1")
Example

VB Syntax GetDesign(<designName>)
VB Example oProject.GetDesign("HFSSDesign1")

GetEDBHandle
Returns the EDB handle for the project.

UI Access NA
Parameters NA
Return Value Numeric string indicating the EDB handle for the project

Python Syn- GetEDBHandle()


tax

Python oProject.GetEDBHandle()
Example

VB Syntax GetEDBHandle()
VB Example oProject.GetEDBHandle()

Project Object Script Commands 5-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetLegacyName

Note:
This command is for internal ANSYS use only.

Python Syn- GetLegacyName()


tax

Python oProject.GetLegacyName()
Example

GetName [Project]
Obtain the project name

UI Access NA

Name Type Description


Parameters
None

Return Value String, the project name not including the path or extension.

Python Syn- GetName()


tax

Python AddInfoMessage (str(oProject.GetName()))


Example

VB Syntax GetName
VB Example MsgBox oProject.GetName ()

GetPath
Returns the location of the project on disk.

UI Access NA

Project Object Script Commands 5-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name Type Description


Parameters
None

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

Python Syn- GetPath()


tax

Python AddInfoMessage(str(oProject.GetPath()))
Example

VB Syntax GetPath
VB Example MsgBox oProject.GetPath ()

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

UI Access NA

Name Type Description


Parameters
None

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

Python Syn- GetTopDesignList()


tax

name_list = oProject.GetTopDesignList()
Python for i in nameL
Example
AddInfoMessage(str(i))

VB Syntax GetTopDesignList
VB name_list = oProject.GetTopDesignList()
Example

Project Object Script Commands 5-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

for each i in
MsgBox i
Next

GetPropNames [Project]
Use: Always return empty; since the project object doesn't associated with any property.
Syntax: GetPropNames()
Return Value: Empty array.
Parameters: Implicit or specific name of Project object.

Python Syn- GetPropNames ()


tax

Python
Example

GetPropValue [Project]
Returns the property value for the active project object, or specified property values.

UI Access NA

Name Type Description


Parameters propPath string A child object's property path.
See property path discussion
here.

Return Value The property value of a child object.

Python Syn- GetPropValue(propPath)


tax

oProject.GetPropValue("TeeModel/offset") //get the off-


Python set variable value in the TeeModel Design
Example oProject.GetPropValue("TeeModel/Results/S Parameter
Plot 1/Display Type") // Get the report display type.

VB Syntax GetPropValue(propPath)
VB Example varVal = oProject.GetPropValue("TeeModel/offset")

Project Object Script Commands 5-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

dispType = oProject.GetPropValue("TeeModel/Results/S Parameter Plot 1/Dis-


play Type")

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".
VB Example:
Set oDesign = oProject.InsertDesign("HFSS", "HFSSDesign3",_
"DrivenModal", "")

For Insert HFSS Layout Design and Insert Circuit Netlist, the command details are as fol-
lows.
Use: Inserts a new design in the project. In Circuit scripts, the last argument will always be empty.
Command: Project>Insert Circuit Design
Syntax: InsertDesign <DesignType>, <DesignName>, <TechnologyFile>:<SubCircuitID>,""
Return Value: None.
Parameters:
<DesignType>
Type: <string>
Possible Values:
"Circuit", "Nexxim Circuit", "System" , "Nexxim Netlist", "HFSS3D"

Project Object Script Commands 5-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<DesignName>
Type: <string>
Name of the new design

<TechnologyFile>:<SubCircuitID>
Type: <string>
The path to the Circuit technology file to be used in this design. Use a pair of empty double quotes
("") for none. <SubCircuitID> is optional and must be preceded by a colon if included along with the
Technology File name. No colon is necessary when the subcircuit ID is omitted.

VB Example: oProject.InsertDesign "Nexxim Circuit","MyDesigner",


"C:\Program Files\AnsysEM\Designer\"
oProject.InsertDesign "Nexxim Circuit","MyDesigner:12", "C:\Program
Files\AnsysEM\Designer\

For Q3D Extractor the InsertDesign command details are as follows:


Use: Inserts a new design in the project. In Q3D scripts, the last argument will always be empty.
Command: Project>Insert Q3D Extractor Design
Syntax: InsertDesign "Q3D Extractor", <DesignName>, "", ""
Return Value: None
Parameters: <DesignName>
Type: <string>
Name of the new design.
VB Example:
oProject.InsertDesign "Q3D Extractor","Q3DDesign2", "",

For Maxwell the InsertDesign command details are as follows:


Use: Inserts a new design in the project. In Maxwell scripts, the last argument will always be empty.
Command: Project>Insert Maxwell Design
Syntax: InsertDesign <DesignType>, <DesignName>, <SolutionType>, ""
Return Value: None

Project Object Script Commands 5-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters: <DesignType>
Type: <string>
Type of design to insert. Can be "Maxwell 2D", "Maxwell 3D", or "RMxprt"
<DesignName>
Type: <string>
Name of the new design.
<SolutionType>
Type: <string>
Solution type of the new design where available types depend upon the DesignType
chosen.

DesignType Available SolutionType


Maxwell 3D "Magnetostatic", "EddyCurrent", "Transient", "Electrostatic", "DCConduction",
"ElectroDCConduction", "ElectricTransient"
Maxwell 2D "Magnetostatic", "EddyCurrent", "Transient", "Electrostatic", "ACConduction",
"DCConduction"
RMxprt "Three-Phase Induction Motor",
"Single-Phase Induction Motor",
"Three-Phase Synchronous Machine",
"Brushless Permanent-Magnet DC Motor",
"Adjust-Speed Synchronous Machine",
"Permanent-Magnet DC Motor",
"Switched Reluctance Motor",
"Line-Start Permanent-Magnet Synchronous Motor",
"Universal Motor",
"DC Machine",
"Claw-Pole Alternator",
"Three-Phase Non-Salient Synchronous Machine"
"Generic Rotating Machine"

InsertDesignWithWorkflow
Inserts a design with a named workflow and returns an IDispatch string.

NA, although Circuit Design has a Show workflow dialog on new design
UI Access
check box in Options.

Name Type Description


<type> string Type of design.
Parameters
<workflowName> string Name of the workflow.
<specName> string Name of the spec.

Project Object Script Commands 5-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<fileName> string Name of the file.


<libLoc> string Type of library, such as SysLib.
<stationaryPath> string Path

Return Value IDispatch string, such as 'IDispatch(IAltraSimScript)'

Pytho- InsertDesignWithWorkflow(<type>, <workflowName>, <specName>, <fileName>,


n Syn- <libLoc>, <stationeryPath>)
tax

oProject.InsertDesignWithWorkflow ("Circuit Design", "Serial


Design",
Pytho-
n "PCIe3 Stressed", "LongChannel", "SysLib",
Exam- "C:\Program Files\AnsysEM\AnsysEM20.2\Win64\syslib\MS - RT_
ple
duroid 6010 (Er=10.2)
0.010 inch, 0.5 oz copper.asty")

VB InsertDesignWithWorkflow (<type>, <workflowName>, <specName>, <fileName>,


Syn- <libLoc>, <stationeryPath>)
tax

oProject.InsertDesignWithWorkflow "Circuit Design", "Serial


Design", _
VB "PCIe3 Stressed", "LongChannel", "SysLib", _
Exam-
ple "C:\Program Files\AnsysEM\AnsysEM20.2\Win64\syslib\MS - RT_
duroid 6010 (Er=10.2" & _
") 0.010 inch, 0.5 oz copper.asty"

InsertToolObject

Note:
This command is for internal ANSYS use only.

Python Syn- InsertToolObject()


tax

Python oProject = oDesktop.GetActiveProject()


Example

Project Object Script Commands 5-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oProject.InsertToolObject()

Paste (Project Object)


Pastes a design in the active project.

UI Access Edit>Paste

Name Type Description


Parameters
None

Return Value None

Python Syn- Paste()


tax

Python oProject.Paste()
Example

VB Syntax Paste
VB Example oProject.Paste

VB Example:
------------------------------------------------------
Example Script
------------------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Dim oProjects
Dim omachine
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")

Project Object Script Commands 5-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oDesktop = oAnsoftApp.GetAppDesktop()


oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject()
oProject.CopyDesign "Differential"
oProject.Paste

For Q3D Extractor the Paste command works as follows:


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 guaranteed to be
alphabetical.
Parameters: None
VB Example: arrayEntities = oEditor.Paste

Redo [Project Level]


Reapplies the last project-level command.

UI Access Edit>Redo

Name Type Description


Parameters
None

Return Value None

Python Syn- Redo()


tax

Python oProject.Redo()
Example

VB Syntax Redo
VB Example oProject.Redo

Project Object Script Commands 5-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Rename
Renames the project and saves it. Similar to SaveAs, except SaveAs requires a path.

UI Access Edit>Rename

Name Type Description


<NewName> String The desired name of the project. The path is
Parameters optional.
<OverWriteOk> Boolean Whether to overwrite the same named file on
disk if it exists. True to overwrite.

Return Value None

Python Rename (<NewName>,<OverWriteOK>)


Syntax

Python oProject.Rename("c:\projects\MyProject.aedt", True)


Example

VB Syn- Rename <NewName>,<OverWriteOK>


tax

VB oProject.Rename "c:\projects\MyProject.aedt", true


Example

RestoreProjectArchive
Restores a specified project archive to the specified file path.
Command: File>Restore Archive...
Syntax: RestoreProjectArchive <ArchiveFilePath>, <ProjectFilePath>, <OverwriteExistingFiles>,
<OpenProjectAfterRestore>;
Return Value: None
Parameters: <ArchiveFilePath>
Type: string
Archive file path.
<ProjectFilePath>,
Type: string
<OverwriteExitingFiles>,

Project Object Script Commands 5-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type: Boolean
Whether to overwriting any existing files during extraction.
<OpenProjectAfterRestore>,
Type Boolean
Whether to open the project in the desktop.
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
oDesktop.RestoreProjectArchive "C:\User-
s\kmchrist\Documents\OptimTee.aedtz", _
"C:\Documents\OptimTee.aedt", false, true

Save
Saves the active project.

UI Access File>Save

Name Type Description


Parameters
None

Return Value None

Python Syn- Save()


tax

Python oProject.Save()
Example

Project Object Script Commands 5-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax Save
VB Example oProject.Save

SaveAs
Saves the project under a new name. Similar to Rename except SaveAs requires a path.

UI Access File>Save As

Name Type Description


< NewName> String The desired name of the project, with dir-
Parameters
ectory and extension.
< OverWriteOK> Boolean Whether to overwrite the same-named file on
disk, if it exists. True to overwrite, with initial
capital letter required.

Return Value None

Python SaveAs <NewName> <OverWriteOK>


Syntax

Python oProject.SaveAs("D:/projects/project1.aedt", True)


Example

VB Syntax SaveAs <NewName> <OverWriteOK>


VB oProject.SaveAs "D:/projects/project1.aedt", True
Example

For Schematic and Layout editor related projects SaveAs functions as follows.
Use: Saves the project under a new name.
Command: File > Save As
Syntax: SaveAs <FileName> <OverWrite> <DefaultAction> <OverrideActions>
Return Value: None
Parameters:
<FileName>
Type: <string>
New name for the file

Project Object Script Commands 5-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<OverWrite>
Type: <bool>
Set to True if an existing project by that name should be overwritten. "True" must begin
with a capital letter.
<DefaultAction>
Type: <string>
Set to one of the following action strings: ef_overwrite , ef_copy_no_overwrite, ef_
make_path_absolute or empty string

<OverrideActions>
Type: Array("Name: OverrideActions", <Files>, <Files>, ...)
<Files>
Type: Array("Name: <Action>", <FileName>, <FileName>, ...)

<DAction>
Type: <string>
Set to one of the following action strings: ef_overwrite , ef_copy_no_overwrite, ef_
make_path_absolute or empty string

VB Example:
oProject.SaveAs
"F:\Designer Projects\TA33097\HighSpeedChannel.aedt", true, "ef_over-
write", Array("NAME:OverrideActions",
Array("NAME:ef_copy_no_overwrite", Array("NAME:Files","$PROJECTDIR/-
circuit_models.inc")),
Array("NAME:ef_make_path_absolute", Array
("NAME:Files","$PROJECTDIR\SL_6s.sp")))

Project Object Script Commands 5-23


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Note:

The Action and DefaultAction strings correspond to the following actions:

• ef_overwrite — Copy File to New Project Directory and Overwrite

• ef_copy_no_overwrite — Copy File to New Project Directory and Don't Overwrite

• ef_make_path_absolute — Change Reference to Point to File in Old Project Directory

• empty string — Do Nothing

The DefaultAction is applied to all files that are NOT explicitly listed in the OverrideActions
array. Those in the OverrideActions array are separate arrays for actions that are dif-
ferent from the default action; those actions are applied to the files listed in the same
array:

• If OverrideActions are not specified, then DefaultAction is applied to ALL files in project
directory.

• If DefaultAction is not specified, then nothing is done (action is Do Nothing).

SaveProjectArchive
Saves the active project as an archive to the specified file path.

UI Access File>Archive

Name Type Description


<archiveFilePath> String Path to archived file
<IncludeExternalFiles> Boolean Whether to include external files asso-
ciated with the project, True or False
Parameters <IncludeResultsFiles> Boolean Whether to Iinclude simulation files asso-
ciated with the project, True or False
<AdditionalFiles> Array Whether to include additional specified
files
<ArchiveNotes> String A descriptive string about the archive

Return Value None

Pyth- SaveProjectArchive (<archivefilepath>, <IncludeExternalFiles>, <IncludeResultsFiles>,

Project Object Script Commands 5-24


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

on <AdditionalFiles>,<ArchiveNotes>)
Syn-
tax

Pyth- oProject.SaveProjectArchive("C:\\User-
on s\\Documents\\Ansoft\\Project27.aedtz", True, False, [], "")
Exa-
mpl-
e

VB oSaveProjectArchive (path>, <IncludeExternalFiles>, <IncludeResultsFiles>, <Addi-


Syntax tionalFiles>,<ArchiveNotes>)

VB
oProject.SaveProjectArchive "C:\Documents\OptimTee.aedtz",
Examp- true, _
le false, Array(), "My notes"

VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("OptimTee")
oProject.Save
oProject.SaveProjectArchive "C:\\Documents\OptimTee.aedtz", true, _
false, Array(), "My notes"

SetActiveDefinitionEditor
Obtain a particular definition editor.

Project Object Script Commands 5-25


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access NA

Name Type Description


< EditorName> String Name of the definition editor to set
active, one of:
Parameters "SymbolEditor"
"FootprintEditor"
< DefinitionName> String The combination name for the symbol or foot-
print, < libname>:< defname>

Return Value Object for the definition to be edited.

Python SetActiveDefinitionEditor (<EditorName>, <DefinitionName>)


Syntax

oSymbolEditor=oProject.SetActiveDefinitionEditor("Sym-
Python bolEditor",
Exampl- "Simplorer Elements\Basic Elements\Circuit\Passive Ele-
e
ments:R")

VB SetActiveDefinitionEditor <EditorName>, <DefinitionName>


Syntax

Set oSymbolEditor = oProject. SetActiveDefinitionEditor


VB ("SymbolEditor",_
Exam-
ple "Simplorer Elements\Basic Elements\Circuit\Passive Ele-
ments:R")

SetActiveDesign
Sets a new design to be the active design. Specify the name of the design that should become act-
ive and return that design.

UI Access NA

Name Type Description


Parameters <DesignName> String Name of the design to set as the active
design.

Return Value Object for the specified design .

Project Object Script Commands 5-26


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python SetActiveDesign (<DesignName>)


Syntax

Python oDesign = oProject.SetActiveDesign("SimplorerDesign2")


Example

VB Syn- SetActiveDesign <DesignName>


tax

VB Set oDesign = oProject.SetActiveDesign ("SimplorerDesign2")


Example

SetPropValue [Project]
Sets the property value for the active project object.

UI Access Edit Properties on ProjectTree objects

Name Type Description


Parameters
PropPath string a child object's property path. See property
path discussion here.
Value string new property value

Return Value True if the property is found and the new value is valid. Otherwise return False.

Python Syn- SetPropValue(propPath, newValue)


tax

oProject.SetPropValue("TeeModel/offset", "2mm") //Set


the offset variable value to "2mm" in the TeeModel
Design
Python
oProject.SetPropValue("TeeModel/Results/S Parameter
Example
Plot 1/Display Type", "Data Table") // Set the report
display type to data table.

VB Syntax SetPropValue(propPath, newValue)


oProject.SetPropValue("TeeModel/offset", "2mm")
VB Example oProject.SetPropValue("TeeModel/Results/S Parameter
Plot 1/Display Type", "Data Table")

Project Object Script Commands 5-27


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

SimulateAll
Runs the SimulateAll project-level script command from the script, which will simulate all solution
setups and Optimetrics setups for all design instances in the project. Script processing only con-
tinues when all analyses are finished.

UI Access NA

Name Type Description


Parameters
None

Return Value None

Python Syn- SimulateAll()


tax

Python oProject.SimulateAll()
Example

VB Syntax SimulateAll
VB Example oProject.SimulateAll

Undo [Project]
Cancels the last project-level command.

UI Access Edit>Undo

Name Type Description


Parameters
None

Return Value None

Python Syn- Undo()


tax

Python oProject.Undo()
Example

Project Object Script Commands 5-28


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax Undo
VB Example oProject.Undo

UpdateDefinitions
Updates all definitions. Warning messages are sent to the message window when definitions can't
be found, informational messages when definitions are updated.

The script method performs the same as if you ran Tools/Pro-


UI Access jectTools/Update Definitions (the dialog default is to list "newer" definitions),
then clicked Select All and then Update.

Name Type Description


Parameters
None

Return Value None

Python Syn- UpdateDefinitions()


tax

Python oProject.UpdateDefinitions()
Example

VB Syntax UpdateDefinitions
VB Example oProject.UpdateDefinitions

Project Object Script Commands 5-29


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

5-30
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

6 - Property Script Commands


Property script commands allow you to navigate through all objects and properties in an
ANSYS Electromagnetics project. You can get and set all properties for all objects in the Project
tree with simple data types.
Property Object is the base class defined for all script objects that support property Get & Set.
GetName()
Returns the name of the object.
GetChildTypes()
An object may have different type of children, for example a Design may has variables, Mod-
ules, and Editors.
Return array of text string, may be empty if the children are NOT divided to different types.
GetChildNames([type)
type -- Children type name, default will return all children names for all types.
return -- An array of immediate children names, belong to the type if specified.
GetChildObject(objPath)
objPath -- A child object path. The path may include multiple generations. Like (designOb-
ject/moduleObj/SetupObject).
return -- A child property object if the object found.
• GetPropNames(bIncludeReadOnly);
bIncludeReadOnly -- optional, default to true; True will include read-only properties, false will
exclude Read-Only properties.
Return -- An array of the object’s property names
GetPropValue(propertyPath)
propertyPath -- The path of the property. A property name or child object’s path appended
with a property name, like “TeeModel/Offset/SIValue”
return -- The property value if the property is found, otherwise cause script error.
• SetPropValue(propertyPath, data)
propertyPath -- The path of the property. A property name or child object’s path appended
with a property name, like “TeeModel/Offset/Value”
data -- new data, data type is depended on property type.
return -- True if property data is updated successfully. False if the new data is invalid.

Property Script Commands 6-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

For a detailed summary of how these new Property script commands are used in a range of con-
texts, including Variable objects, see Object Script Property Function Summary. Additional
examples for these commands are listed under Project Objects, Design Objects, 3D Modeler, Opti-
metrics, Radiation Module and Reporter.
Older property commands should be executed by the oProject object.
Set oProject = oDesktop.SetActiveProject("Project1")
oProject.CommandName <args>
Some of the topics covered in this chapter are as follows:
Conventions Used in this Chapter
ChangeProperty
GetProperties
GetPropertyValue
GetArrayVariables
GetVariables
SetPropertyValue
SetVariableValue
Additional Property Scripting Example
Example Use of Record Script and Edit Properties

Object Script Property Function Summary


Object Path
Object path can be used to navigate through objects and properties in an Ansys EM project.

l An Object path consisted of one or multiple Object-ID-Nodes separated by "/" . In the HFSS-
Optimtee example, the Optimization Max value of variable "offset" is represented by the path
"TeeModel/offset/Optimization/max" or "TeeModel/Variable[offset]/Optimization[max]"
l Object-ID-Node; may exist in the following forms:
l A simple object name or property name.
l Type[Name] for object; Tab[name] for property.
l Name[attr1="v1", attr2 = "v2", ...]. When more than one child object have the same
name, use attributes to specify the difference.
l ArrayName[index]. For example, the Optimetric setup may has multiple calculations,
"Calculation[0]" can be used to identify the first calculation.

Property Script Commands 6-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

l name beginning with '@' character denoted as a property name, when an object has
a child and property with the same name.

Property Object:
Property Object is the base class defined for all script object that support property Get & Set.

l GetName()
l Returns the name of the object.
l GetChildTypes()
l An object may have different type of children. For example, a design may have vari-
ables, modules, and editors.
l Returns array of text strings; may be empty if the children are NOT divided to dif-
ferent types.
l GetChildNames([type)
l type – Children type name; default returns all children names for all types.
l return – An array of immediate children names, belong to the type if specified.
l GetChildObject(objPath)
l objPath – A child object path. The path may include multiple generations, such as
(designObject/moduleObj/SetupObject).
l return – A child property object if the object found.
l GetPropNames(bIncludeReadOnly);
l bIncludeReadOnly – optional, default to true; True will include read-only properties,
False will exclude read-only properties.
l Return – An array of the object’s property names.
l GetPropValue(propertyPath)
l propertyPath – The path of the property. A property name or child object’s path
appended with a property name, like “TeeModel/Offset/SIValue”
l return -- The property value if the property is found, otherwise cause script error..
l SetPropValue([propertyPath, data)
l propertyPath – The path of the property. A property name or child object’s path appen-
ded with a property name, like “TeeModel/Offset/Value”
l data – new data, data type is depended on property type.
l return – True if property data is updated successfully; False if the new data is invalid.

Property Script Commands 6-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Project Object
Project Object inherited all functions defined in the Property Object. But it doesn't have property,
GetPropValue() & SetPropValue() function can be used to set its child object's property.

l GetChildTypes() always return [“Design”, “Variable”].


l GetChildNames(type)
GetChildNames() & GetChildName(“Design”) will return all Design names of the project.
GetChildNames(“Variable”) return all project variable names.
l GetChildObject(objPath)

oDesign = oProject("TeeModel")

oVariable = oProject.GetChildObject("VariableName")

oReport = oProject.GetChildObject("TeeModel/Results/S Parameter Plot 1")

l GetPropNames(bIncludeReadOnly) always return empty array since the project has no


property.
l GetPropValue(propertyPath)

oProject.GetPropValue("TeeModel/offset") //get the offset variable value in the TeeModel


Design
oProject.GetPropValue("TeeModel/Results/S Parameter Plot 1/Display Type") // Get the
report display type.

l SetPropValue(propertyPath, newValue)

oProject.SetPropValue("TeeModel/offset", "2mm") //Set the offset variable value to "2mm"


in the TeeModel Design
oProject.SetPropValue("TeeModel/Results/S Parameter Plot 1/Display Type", "Data
Table) // Set the report display type to data table.

Design Object
Design Object inherited all functions defined in the Property Object. But it doesn't have property,
GetPropValue() & SetPropValue() function can be used to set its child object's property..

l GetChildTypes() always return ['Module', 'Editor', 'Variable'].


l GetChildNames(type)
GetChildNames() will return modules & editor child names.
GetChildNames(“Variable”) will return all variable names
GetChildNames(“Module”) will return all module names that support property-object-script
like ['Optimetrics', 'RadField', 'Results']
GetChildNames(“Editor”) will return a 3D editor name for all 3D Designs

Property Script Commands 6-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

l GetChildObject()
oVariable = oDesign.GetChildObject("VariableName")
oReport = oDesign.GetChildObject("Results/S Parameter Plot 1")
oRptModule = oDesign.GetChildObject("ReportSetup")
l GetPropNames(bIncludeReadOnly) always return empty array since the design has no
property.
l GetPropValue()
oDesign GetPropValue("offset/SIValue") //get the offset variable SI value in the
DesignoDesign GetPropValue("offset/SIValue") //get the offset variable SI value in the
Design
oDesign.GetPropValue("Results/S Parameter Plot 1/Display Type") // Get the report display
type
l SetPropValue()
oDesign.SetPropValue("offset", "2mm") //Set the offset variable value to "2mm" in the
Design
oDesign.SetPropValue("Results/S Parameter Plot 1/Display Type", "Data Table) // Set the
report display type to data table.

Variable Object
Is a Property Object that has no child. It also provides quick function call to get/set it properties by
adding functions with property name appended to Get_ & Set_ prefix. To find what functions it
provided enter dir(oVar) the command window. It can accessed by the project or design object’s
GetChildObject(VariableName) function.
oProjVar = oProject.GetChildObject(“$VarName”)
oVar = oProject.GetChildObject(“DesignName/VarName”)
oVar = oDesign.GetChildObject(“variableName”)
oProject..GetChildNames(“Variable”) will return all project variable names.
oDesign.GetChildNames(Variable”) will return all Design Variable names.

l GetChildTypes() always return empty array.


l GetChildNames() always return empty array , since variable has no child.
l GetChildObject(objPath) it has no child.
l GetPropNames(bIncludeReadOnly) ['EvaluatedValue', 'SIValue'] are read-only properties
l Independent variable :['Value', 'EvaluatedValue', 'SIValue', 'Description', 'ReadOnly',
'Hidden', 'Sweep', 'Optimization/Included', 'Optimization/Min', 'Optimization/Max',
'Sensitivity/Included', 'Sensitivity/Min', 'Sensitivity/Max', 'Sensitivity/IDisp', 'Statistical',
'Statistical/Included', 'Tuning/Included', 'Tuning/Step', 'Tuning/Min', 'Tuning/Max'].

Property Script Commands 6-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

l Dependent variable ['Value', 'EvaluatedValue', 'SIValue', 'Description', 'ReadOnly',


'Hidden', 'Sweep']
l GetPropValue(propName)
oVar.GetPropValue() return the variable value as text string.
oVar.GetPropValue(“Value”) return the variable value as text string.
oVar.GetPropValue(“SIValue”) return the SI-value of variable as number.
oVar.Get_SIValue()also return the SI value.
l SetPropValue(propName, newValue)
oVar.SetPropValue(“Value", 888)
oVar.SetPropValue("Sensitivity'/Included", True)
oVar.SetPropValue("Sensitivity/Max”, '1.8pF'])
oVar.Set_Sensitivity_Max( '1.8pF') also works as last call.
oVar.SetPropValue("Sensitivity", ['Min:=', '0.8pF', 'Max:=', '1.8pF'])
//set multiple attributes at one call:
oVar.SetPropValue("@", ['Value:=',288, 'Sensitivity', ['Included', True,'Min', '0.0']])
oVar.SetPropValue("", ['Value:=',288, 'Sensitivity', ['Included', True,'Min', '0.0']])

Optimetrics Module Object:


Optimetrics Module Object inherited all functions defined in the Property Object. But it doesn't have
property, GetPropValue() & SetPropValue() function can be used to set its child object's property..

l GetChildTypes() there are six type of children, they are ['OptiParametric', 'OptiOptimization',
'OptiSensitivity', 'OptiStatistical', 'OptiDesignExplorer', 'OptiDXDOE']. But the return array
only included those that have setup defined, so it may be an empty array if no optimetrics
setup is defined. The GetChildNames(type) function also recognized the type name without
the prefix “Opti”.
l GetChildNames(type)
GetChildNames() will return all setup for all types.
GetChildNames(“OptiOptimization”) & GetChildNames(“Optimization”) will return all Optim-
ization setup.
l GetChildObject()
oParamSetup = oOptModule.GetChildObject('ParametricSetup1') get the
oOptSetup = oOptModule.GetChildObject('OptimizationSetup1')
l GetPropNames(bIncludeReadOnly) always return empty array since the it has no property.
l GetPropValue(propPath) may be used to get its child’s property value
oOptModule.GetPropValue("OptimizationSetup1\Optimizer") get the optimizer name for
OptimizationSetup1

Property Script Commands 6-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

l SetPropValue(propPath, newValue) may be used to set its child’s property value


oOptModule.SetPropValue(ParametricSetup1\Enabled", False) //disable Para-
metricSetup1

Optimetrics Setup Object


This is a new Object inherited all functions defined in the Property Object. But it doesn't have child.
It is accessible through its parents.
oOptSetup = oOptModule.GetChildObject('OptimizationSetup1')
oOptSetup = oDesign.GetChildObject('Optimetrics\OptimizationSetup1')
oOptSetup = oProject.GetChildObject('TeeModel\Optimetrics\OptimizationSetup1')

l GetChildTypes() always return empty array.


l GetChildNames(type) always return empty array
l GetChildObject()
l GetPropNames(bIncludeReadOnly) will return the property names listed in the property win-
dow when the setup is selected.
l GetPropValue(propName)
oOptSetup.GetPropValue("Optimizer") return the selected optimizer name.
oOptSetup.GetPropValue("Optimizer/Choices") return all optimizer names.
l SetPropValue(propName, newValue)
oOptSetup.SetPropValue("Optimizer", “NotAnOptimzerName”; will return false.
oOptSetup.SetPropValue("Optimizer", “Quasi Newton”; return true, since “Quasi Newton”
is one of the optimizer name returned as the Optimizer Choices.
l HasResult() return true if the setup is solved. Otherwise return false.
l Validate() return true if the setup is valid for analyze. Otherwise return false. Calling the
SetPropValue() function to change the property may invalid the setup.

ReportSetup(Results) Module Object:


ReportSetup module Object inherited all functions defined in the Property Object. But it doesn't
have property, GetPropValue() & SetPropValue() function can be used to get/set its child object's
property..

l GetChildTypes() always empty array.


l GetChildNames(type)
GetChildNames() return all report names
l •GetChildObject(objPath)
oRpt = oRptModule.GetChildObject("S Parameter Plot 1") return the report property object
oTrace = oRptModule.GetChildObject("S Parameter Plot 1/dB(S(Port1,Port1))") return the

Property Script Commands 6-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

trace property object


oAxisX = oRptModule.GetChildObject("S Parameter Plot 1/AxisX") return the axis X prop-
erty object
l GetPropNames(bIncludeReadOnly) always return empty array since the it \has no property.
l GetPropValue()
oRptModule.GetPropValue(“S Parameter Plot 1/Display Type”)
l SetPropValue()
oRptModule.SetPropValue(“S Parameter Plot 1/Display Type”, “DataTable”)

ReportSetup(Results) Module Child Objects:


These are Property Objects. Its first level of child object is report. Report has trace, axis, header,
Legend, and more children. Trace has curve as child etc.
Those child objects can be accessed by calling all levels of parent object’s GetChildObject(path)
function.
oRpt = oRptModule.GetChildObject(reportName)
oRpt = oDesign.GetChildObject(“Results/reportName”)
oTrace = oRpt.GetChildObject(traceName)
oTrace = oRptModule.GetChildObject(ReportName/TraceName)

l GetChildTypes() always return empty array.


l GetChildNames() get the object’s child names. What will be returned will depended on the
object instance.
l GetChildObject(objPath)
l GetPropNames(bIncludeReadOnly) will return the property names listed in the property win-
dow when the object is selected.
l GetPropValue(propName)
oRpt.GetPropValue("Display Type") return the report’s display type.
oOptSetup.GetPropValue("Display Type/Choices") return all optimizer names.
oTrace.GetPropValue(“X Component”)
l SetPropValue(propName, newValue)
oTrace.SetPropValue(“Primary sweep”, “Freq”)

Radiation Module Object:


This inherited all functions defined in the Property Object. But it doesn't have property,
GetPropValue() & SetPropValue() function can be used to set its child object's property.

Property Script Commands 6-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

l GetChildTypes() always return empty array, now its children


l GetChildNames(type)
GetChildNames() return all setup names.
l GetChildObject(setupName) return the setup object as Property object.
oOverlay= oRadModule.GetChildObject('Antenna Parameter Overlay1')
oSphere = oRadModule.GetChildObject('Infinite Sphere1')
l GetPropNames() return empty array; it has no property.
l GetPropValue()
oRadModule.GetPropValue('Line1/Num Points') //Get the the Line1 setups’ “Num Points”
property value.
l SetPropValue()
oRadModule.SetPropValue('Line1/Num Points', 100) ; Set the Line1 setups’ “Num Points”
property to 100.

Radiation Module Child Objects:


These are Property Objects. It also provides quick function call to get/set its properties by adding
functions with property name appended to Get_ & Set_ prefix. To find what functions it provides
enter dir(oVar) the command window.
Those child objects can be access by call all levels of parent object’s GetChildObject(path) function.
oRadSetup = oRadModule.GetChildObject(setupName)
oRadSetup = oDesign.GetChildObject(RadField/setupName)

l GetChildTypes() always return empty array.


l GetChildNames() always return empty array , since Radiation setup has no child.
l GetChildObject(objPath) it has no child.
l GetPropNames(bIncludeReadOnly) will return the property names listed in the property win-
dow when the setup is selected.
l GetPropValue(propName)
oRadSetup.GetPropValue(”Num Points") return the line setup’s “Num Points” property
value.
oRadSetup.Get_NumPoints() will also get the same value.
l SetPropValue(propName, newValue)
oRadSetup.SetPropValue('Num Points', 888)
oRadSetup.Set_NumPoints(888)

Conventions Used in this Chapter


l Property

Property Script Commands 6-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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

l <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.

l <PropTab>

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

l <PropName>

Name of a single property .

<PropServer> and <PropTab> Names


Project
Project Variables:
<PropServer>
"ProjectVariables"

<PropTab>
"ProjectVariableTab"

AnsoftHfss, Maxwell Design. Design, and Q3D Extractor Design


Local Variables:
<PropServer>
"LocalVariables"

<PropTab>
"LocalVariableTab"
Passed Parameters
<PropServer>
"Instance:<name of circuit instance>"

Property Script Commands 6-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<PropTab>
"PassedParameter Tab"
Definition Parameters
<PropServer>
"DefinitionParameters"
<PropTab>
"DefinitionParameters"
Modules and Editors
<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"
Circuit module: "CCircuitTab"
System module: "SystemTab"
HFSS 3D Layout module: "HFSS 3D LayoutTab"
Nexxim module: "NexximTab"
Layout elements: "BaseElementTab"
Schematic elements: "ComponentTab"
Optimetrics module: "OptimetricsTab"

Property Script Commands 6-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

3D Model Editor
Object in the module:
<PropServer>
Name of the object. For example: "Box1".

<PropTab>
"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 Box2’s 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:Com-
pany Name", "Value:=", "My Company"))))

Q3D Extractor Modules


<PropServer>

Property Script Commands 6-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Format is: <ModuleName>:<ItemName>, where <ItemName> is the solu-


tion setup name, etc., depending on which module is being edited.
<PropTab>
Boundary module: "Q3D ExtractorTab" or "2D ExtractorTab"
Mesh Operations module: "MeshSetupTab"
Analysis module: "Q3D ExtractorTab" or "2D ExtractorTab"
Optimetrics module: "OptimetricsTab"
Solutions module: Does not support properties.
Field Overlays module: "FieldsPostProcessorTab"
Maxwell Modules
<PropServer>
Format is: <ModuleName>:<ItemName>, where <ItemName> is the solu-
tion setup name, etc., depending on which module is being edited.

Example: <PropServer> for the boundary "PerfE1" is "Bound-


arySetup:PerfE1"

<PropTab>
Boundary module: "MaxwellTab"
Mesh Operations module: "MeshSetupTab"
Analysis module: "MaxwellTab"
Optimetrics module: "OptimetricsTab"
Solutions module: Does not support properties.
Field Overlays module: "FieldsPostProcessorTab"
Radiation module: "RadFieldSetupTab"

Note:

For scripted property changes in the various modules and editors, refer to the chapters
on the System, HFSS 3D Layout, and Nexxim tools, as well as the Layout and Schematic
editors.

Property Script Commands 6-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetArrayVariables
Use: Returns a list of array variables. To get a list of indexed Project variables, execute this com-
mand 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.
VB Example:
Dim var_array
project_var_array = oProject.GetArrayVariables()
local_var_array = oDesign.GetArrayVariables()

GetProperties
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.

UI Access NA

Name Type Description


<propTab> String One of the following, where tab titles
are shown in parentheses:
PassedParameterTab ("Parameter
Values")
DefinitionParameterTab (Para-
meter Defaults")
LocalVariableTab ("Variables" or
"Local Variables")
Parameters ProjectVariableTab ("Project vari-
ables")
ConstantsTab ("Constants")
BaseElementTab ("Symbol" or
"Footprint")
ComponentTab ("General")
Component("Component")
CustomTab ("Intrinsic Variables")
Quantities ("Quantities")

Property Script Commands 6-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Signals ("Signals")
<propServer> String An object identifier, generally returned from
another script method, such as Comp-
Inst@R;2;3

Return Value Array of strings, the names of the appropriate properties.

Python GetProperties( <propTab>, <propServer> )


Syntax

selectionArray = oEditor.GetSelections()
for k in selectionArray:
Python
Example props = oEditor.GetProperties("PassedParameterTab",k)
...

VB Syn- GetProperties( <propTab>, <propServer> )


tax

selectionArray = oEditor.GetSelections
for each k in selectionArray
VB
props = oEditor.GetProperties("PassedParameterTab",k)
Example
...
next

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

VB Example: Dim all_props


all_props = oDesign.GetProperties("BaseElementTab",_
"rect_1")

VB Example: Dim all_props

Property Script Commands 6-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

all_props = oDesign.GetProperties("Q3DTab",_
"BoundarySetup:Source1")

GetPropertyValue
Gets the value of a single property belonging to a specific serverName and PropTab. This function
is available with the Project, Design or Editor objects, including definition editors.
Use the script recording feature and edit a property, and then view the resulting script to
see the format for that property.

UI Access NA

Name Type Description


<propTab> String One of the following, where tab titles
are shown in parentheses:
PassedParameterTab ("Parameter
Values")
DefinitionParameterTab (Para-
meter Defaults")
LocalVariableTab ("Variables" or
"Local Variables")
ProjectVariableTab ("Project vari-
ables")

Parameters ConstantsTab ("Constants")


BaseElementTab ("Symbol" or
"Footprint")
ComponentTab ("General")
Component("Component")
CustomTab ("Intrinsic Variables")
Quantities ("Quantities")
Signals ("Signals")
<propServer> String An object identifier, generally returned from
another script method, such as Comp-
Inst@R;2;3
<propName> String Name of the property.

Return Value  String, the value of the property.

Property Script Commands 6-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python GetPropertyValue (<propTab>, <serverName>, <propName>)


Syntax

selectionArray = oEditor.GetSelections()
for k in selectionArray:
Python
Exampl- val = oEditor.GetPropertyValue("PassedParameterTab", k,
e "R")
...

VB GetPropertyValue (<propTab>, <serverName>, <propName>)


Syntax

selectionArray = oEd-
itor.GetSelections

for each k in selectionArray

VB
Examp-
val = oEditor.GetPropertyValue("PassedParameterTab", k,
le
"R")

...

next

Python Syn- GetPropertyValue ([ <array>])


tax

oModule = oDesign.GetModule("ReportSetup")
Python
Example oModule.GetPropertyValue("Trace", "S Parameter Plot
1:dB(S(1,1))","Y Axis")

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

Property Script Commands 6-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Example:value_string = _
oEditor.GetPropertyValue("BaseElementTab",_
"rect_1", "Name")

Example: (Query frequency and excitation)


freq = oDesign.GetPropertyValue("General", "AnalysisSetup:Setup1",
"Adaptive Freq")
sigType = oDesign.GetPropertyValue("Q3D", "BoundarySetup:via_1",
"Type")
sourceType = oDesign.GetPropertyValue("Q3D", "Bound-
arySetup:Source1", "Type")

Example: (Query Trace values in a specified report)


oModule = oDesign.GetModule("ReportSetup")
oModule.GetPropertyValue("Trace", "S Parameter Plot 1:dB(S(1,1))","Y
Axis")

GetVariables
Returns a list of all defined variables. To get a list of Project variables, execute this command using
oProject. To get a list of local variables, use oDesign.

UI Access NA

Name Type Description


Parameters
None

Return Value Variant array of strings – the names of the variables.

Python Syn- GetVariables ()


tax

project_var_array = oProject.GetVariables()
Python
Example local_var_array = oDesign.GetVariables()

Property Script Commands 6-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax GetVariables ()

VB project_var_array = oProject.GetVariables()
Example local_var_array = oDesign.GetVariables()

GetVariableValue
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.

UI Access NA

Name Type Description


Parameters
<VarName> String Name of the variable to access

String
Return Value
A string representing the value of the variable.

Python Syn- GetVariableValue(  <


  VarName> )
tax

Python oProject.GetVariableValue("var_name")
Example

VB Syntax GetVariableValue(  <
  VarName> )
VB Example oProject.GetVariableValue("var_name")

SetPropertyValue
Sets the value of a single propertybelonging to a specific PropServer and PropTab. This function is
available with the Project, Design or Editor objects, including definition editors.This is not sup-
ported for properties of the following types: ButtonProp, PointProp, V3DPointProp, and
VPointProp. Only the ChangeProperty command can be used to modify these properties.
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.

UI Access NA

Name Type Description


Parameters <propTab> String One of the following, where tab titles
are shown in parentheses:

Property Script Commands 6-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

PassedParameterTab ("Parameter
Values")
DefinitionParameterTab (Para-
meter Defaults")
LocalVariableTab ("Variables" or
"Local Variables")
ProjectVariableTab ("Project vari-
ables")
ConstantsTab ("Constants")
BaseElementTab ("Symbol" or
"Footprint")
ComponentTab ("General")
Component("Component")
CustomTab ("Intrinsic Variables")
Quantities ("Quantities")
Signals ("Signals")
<propServer> String An object identifier, generally returned from
another script method, such as Comp-
Inst@R;2;3
<propName> String Name of the property.
<propValue> String The value for the property

Return Value None

Python SetPropertyValue (<propTab>, <propServer>, <propName>, <propValue>)


Syntax

selectionArray=oEditor.GetSelections()
for k in selectionArray:
...#filter for resistors
Python
Example oEditor.SetPropertyValue("PassedParameterTab",
k, "R", "2200")
...

Property Script Commands 6-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syn- SetPropertyValue (<propTab>, <propServer>, <propName>, <propValue>)


tax

selectionArray=oEditor.GetSelections
for each k in selectionArray
...'filter for resistors
VB
oEditor.SetPropertyValue("PassedParameterTab",
Example
k, "R", "2200")
...
next

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

VB Example: oEditor.SetPropertyValue _
"BaseElementTab","rect_1",_
"LineWidth", "3mm"

SetVariableValue
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.

UI Access NA

Name Type Description


Parameters
<VarValue> Value New value for the variable.

Return Value None

Python Syn- SetVariableValue (<VarName>, <VarValue>)


tax

Python oProject.SetVariableValue ("$Var1", "3mm")


Example

Property Script Commands 6-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax SetVariableValue <VarName>, <VarValue>


VB oProject.SetVariableValue "$Var1", "3mm"
Example

Additional Property Scripting Example


Following is a sample script that uses the GetPropertyValue, SetPropertyValue, and GetProp-
erties 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.

VB 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 = _
oEditor.SetPropertyValue("Geometry3DCmdTab",_
"Box1:CreateBox:1", prop)
MsgBox("Now the value of '" + prop + "' is " + val)
End If
Next

Property Script Commands 6-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

The following is a sample script that creates a HFSS 3D Layout design, draws a rectangle in the lay-
out editor and uses the GetPropertyValue, SetPropertyValue and GetProperties functions. The
script gets all properties of the rectangle. It then loops through the properties and for each one,
shows the user the current value and asks if the value should be changed. Note that the last call to
GetPropertyValue in the script will fail if you change the name of the rectangle from the script.

VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
'
oDesktop.RestoreWindow
oDesktop.NewProject
Set oProject = oDesktop.GetActiveProject
'
' CREATE A RECTANGLE IN HFSS_3D_LAYOUT
'
oProject.InsertDesign "HFSS 3D Layout", "HFSS 3D Layout1", _
"C:\testinstall\Designer\syslib\PCB - SingleSided.asty", ""
Set oDesign = oProject.SetActiveDesign("HFSS 3D Layout1")
Set oEditor = oDesign.SetActiveEditor("Layout")
oEditor.CreateRectangle Array("NAME:Contents", _
"rectGeometry:=", Array("Name:=", _
"rect_1", "LayerName:=", "Top", "lw:=", _
"0mm", "Ax:=", "-22mm", "Ay:=", "20mm", "Bx:=", _
"29mm", "By:=", "-4mm", "ang:=", "0deg"))
'

Property Script Commands 6-23


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

' GET ALL PROPERTIES OF THE RECTANGLE


'
Dim all_props
Dim prop
Dim val
Dim new_val
'
all_props = oEditor.GetProperties("BaseElementTab","rect_1")
'
' LOOP OVER ALL PROPERTIES
'
For Each prop in all_props
val = oEditor.GetPropertyValue("BaseElementTab","rect_1",prop)
'
' DISPLAY VALUE TO THE USER
'
new_val = InputBox("New Value of "+prop+":",_
"Current Value of "+prop+" is "+val,val)
'
' CHANGE THE VALUE IF DESIRED
'
If new_val <> val Then
oEditor.SetPropertyValue _
"BaseElementTab","rect_1",prop,new_val
val = _
oEditor.GetPropertyValue("BaseElementTab","rect_1",prop)

MsgBox("Now the value of "+prop+" is "+val)


End If
'
Next

Property Script Commands 6-24


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

'

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 and then edit the property. Open the script file and look at the
o.Editor.ChangeProperty entry to see the string arguments.
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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:Geo-
metry3DAttributeTab", Array("NAME:PropServers", _
"Polyline1"), Array("NAME:ChangedProps", Array("NAME:Display Wire-
frame", "Value:=", true), _
Array("NAME:Display Wireframe", "Value:=", false), Array
("NAME:Transparent", "Value:=", 0.2))))

Property Script Commands 6-25


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

6-26
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

7 - Dataset Script Commands


Dataset commands should be executed by the oProject object:
Set oProject = oDesktop.SetActiveProject("Project1")
oProject.CommandName <args>

AddDataSet
DeleteDataSet
EditDataSet
ImportDataSet

AddDataset
Adds a dataset.

UI Access Add command in the Datasets dialog box. Project>Datasets>Add

Name Type Description


<DatasetDataArray> Array Array("NAME:<DatasetName>",
Array("NAME:Coordinates", <Coordin-
ateArray>,
Parameters
<CoordinateArray>, ...)
<DatasetName> String Name of the dataset
<CoordinateArray> Array Array("NAME:Coordinate", "X:=", <double>,
"Y:=",<double>)

Return Value None

Python Syn- AddDataset <DatasetDataArray>


tax

oProject.AddDataset(
Python
[
Example
"NAME:$ds1",

Dataset Script Commands 7-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

[
"NAME:Coordinates",
[
"NAME:Coordinate",
"X:=", 2,
"Y:=", 4
],
[
"NAME:Coordinate",
"X:=", 6,
"Y:=", 8
]
]
])

VB Syntax AddDataset <DatasetDataArray>


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

DeleteDataset
Deletes the specified dataset.

UI Access Remove command in the Datasets dialog box.

Parameters Name Type Description

Dataset Script Commands 7-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<DatasetName> String Name of the dataset found in the project

Return Value None

Python Syn- DeleteDataset (<DatasetName>)


tax

Python oProject.DeleteDataset("$ds1")
Example

VB Syntax DeleteDataset <DatasetName>


VB Example oProject.DeleteDataset "$ds1"

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

UI Access Edit command in the Datasets dialog box

Name Type Description


Parameters
<OriginalName> String Name of the dataset before editing.

Return Value None

Python EditDataset (<OriginalName> <DatasetDataArray>)


Syntax

oProject.EditDataset ("ds1" ["NAME:ds2",_


["NAME:Coordina
Python
Example "X:=", 1, "Y:="
"X:=", 3, "Y:=", 4]]])

VB Syn- EditDataset <OriginalName> <DatasetDataArray>


tax

VB oProject.EditDataset "ds1" Array("NAME:ds2",_


Example

Dataset Script Commands 7-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:Coor

"X:=", 1, "Y:=",
"X:=", 3, "Y:=", 4)))

ImportDataset
Imports a dataset from a named file.

UI Access Import command in the Datasets dialog box.

Name Type Description


Parameters <datasetFileFullPath> String The full path to the file containing the data-
set values.

Return Value None

Python Syn- ImportDataset (<datasetFileFullPath>)


tax

Python oProject.ImportDataset ("e:\tmp\dsdata.txt")


Example

VB Syntax ImportDataset <datasetFileFullPath>


VB oProject.ImportDataset ("e:\tmp\dsdata.txt")
Example

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

Where BSR_1_dk.tab contains a numbered list of tab separated data:

1 18.5
2 18.5
3 18.5
4 18.5

Dataset Script Commands 7-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

5 18.5
6 18.5
...
In the case of Q3D Extractor, the ImportDataset command details are as follows.
Imports a dataset.
Command: Project>Datasets>Import
Syntax: ImportDataset <DatasetFileFullPath>
Return Value: None
Parameters: <DatasetFileFullPath>
Type: <string>
The full path to the file containing the dataset values.
VB Example: oProject.ImportDataset ("e:\tmp\dsdata.txt")

Dataset Script Commands 7-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

7-6
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

8 - Design Object Script Commands


Design object commands should be executed by the oDesign object.
oDesign.CommandName <args>
Another example is as follows:
Set oDesign = oProject.SetActiveDesign("Q3DExtractorDesign1")
oDesign.CommandName <args>
Conventions Used in this Chapter
<ModuleName>
Name used to access one of the following modules:

l Boundary module: "BoundarySetup"


l Mesh Operations module: "MeshSetup"
l Analysis module: "AnalysisSetup"
l Optimetrics module: "Optimetrics"
l Solutions module: "Solutions"
l Field Overlays module: "FieldsReporter"
l Radiation module: "RadField"

AddDesignVariablesForDynamicLink
ApplyMeshOps
Analyze
AnalyzeDistributed
AssignDCThickness
ConstructVariationString
DeleteLinkedDataVariation
DeleteVariation
DeleteFieldVariation
DeleteFullVariation
DeleteLinkedDataVariation
EditDesignSettings
EditNotes

Design Object Script Commands 8-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ExportConvergence
ExportMatrixData
ExportMeshStats
ExportProfile
ExportNetworkData
ExportNMFData
GenerateMesh
GetChildNames [Design]
GetChildObject [Design]
GetChildTypes [Design]
GetConfigurableData
GetData
GetDesignType
GetDesignValidationInfo
GetEdit SourcesCount
GetExcitations
GetManagedFilesPath
GetModule
GetName
GetNominalVariation
GetNoteText
GetPostProcessingVariables
GetSelections
GetSolutionType
GetSolveInsideThreshold
GetSourceContexts
GetVariationVariableValue
GeometryCheckAndAutofix
PasteDesign
Redo

Design Object Script Commands 8-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

RenameDesignInstance
ResetToTimeZero
SARSetup
SetActiveEditor
SetDesignSettings
SetLengthSettings
SetObjectDeformation
SetObjectTemperature
SetPhaseCenterPerPort
SetPropValue [Design]
SetSinglePhaseCenter
SetSolutionType
SetSolveInsideThreshold
SetSourceContexts
Solve
RunToolkit
Undo
ValidateLink

AddDesignVariablesForDynamicLink
Creates design variables based on any in a Circuit, HFSS, 3D Layout, Q3D, or 2D extractor project
that is connected to a Circuit or 3D Layout design through a dynamic link.

l In the Schematic Editor or Layout Editor, right click the new instance
of the linked design and click Add Design Variables for Dynamic Link.
UI Access l In the Project Manager, right click on [Project Name] > [Design Name] >
[Dynamic Link Design] and click Add Design Variables for Dynamic
Link.

Name Type Description


Parameters InstanceID String Instance ID for the dynamic link
component

Return Value None

Design Object Script Commands 8-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python AddDesignVariablesForDynamicLink (<InstanceID>)


Syntax

Python oDesign = oProject.SetActiveDesign("Circuit1")


Example oDesign.AddDesignVariablesForDynamicLink ("6")

VB Syn- AddDesignVariablesForDynamicLink <InstanceID>


tax

VB Set oDesign = oProject.SetActiveDesign("Circuit1")


Example oDesign.AddDesignVariablesForDynamicLink "6"

ApplyMeshOps
Use: If any mesh operations were defined and not yet performed in the current variation for the spe-
cified 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.

Note:

This is a legacy script. Please use GenerateMesh.

Command: HFSS > Analysis Setup > Generate Mesh.


Syntax: ApplyMeshOps <SetupNameArray>
Return Value: <SetupNameArray>
Type: <int>
-1: completed with error
0: completed successfully
VB Example:
status = oDesign.ApplyMeshOps Array("Setup1","Setup2")

Python ApplyMeshOps (<SetupNameArray>)


Syntax

Python oDesign.ApplyMeshOps Array(["Setup1","Setup2"])


Example

Design Object Script Commands 8-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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

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

Name Type Description


Parameters
<setup> String Setup name

Integer
Return Value 0: successful completion
-1: simulation error

Python Syn- Analyze (<setup>)


tax

Python oDesign.Analyze("TR1")
Example

VB Syntax Analyze <setup>


VB Example oDesign.Analyze "TR1"

Set oProject = oDesktop.SetActiveProject("Tee")


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

Design Object Script Commands 8-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters: <SetupName>
VB Example: For frequency sweeps:
oDesign.AnalyzeDistributed "Setup1"

Python Syn- AnalyzeDistributed (<SetupName>)


tax

Python oDesign.AnalyzeDistributed (["Setup1"])


Example

AssignDCThickness
Assign DC Thickness to more accurately compute DC resistance of a thin conducting object for
which Solve Inside is not selected.
Command: HFSS>Boundaries>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 thick-
ness dialog. "DisableAuto" is equivalent to clearing that checkbox. Omitting the string
means leaves the checkbox unchanged.
Example:
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignDCThickness Array("Box2"), Array("1mm")

The following example includes the use of "Automatic" and "Infinite" settings.

Design Object Script Commands 8-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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) & "")

Python AssignDCThickness Array[<ObjectName>] Array [<ThicknessValue>] <string>


Syntax

oModule.AssignDCThickness Array["Arm_1", "Arm_2],


_
Python Array["" & Chr(34) & "<Effective>" & Chr(34) &
Example "", _
"" & Chr(34) & "<Infinite>" &
Chr(34) & ""]

ClearLinkedData (Design)
Clear the linked data of all the solution setups. Similar to the ClearLinkedData command for the
module level.
Right-click menu of the Analysis item

UI Access [Product] > Analysis Setup > Clear Linked Data

Design Object Script Commands 8-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name Type Description


Parameters
None

Return Value None

Python Syn- ClearLinkedData()


tax

Python oDesign.ClearLinkedData()
Example

VB Syntax ClearLinkedData()
VB Example oDesign.ClearLinkedData

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

UI Access None.

Name Type Description


< ArrayOfVariableNames> Array of Strings List of vari-
able
names.
< ArrayOfVariableValuesIncludingUnits> Array of Strings List of vari-
Parameters able values,
including
units, in the
same order
as the list of
names.

Returns variation string with the variables ordered to correspond to the order of
Return variables in design variations. The values for the variables are inserted into the vari-
Value ation string. For an example of how ConstructionVariationString can be used, see
the Python example.

Python ConstructVariationString(<ArrayOfVariableNames>, <ArrayOfVari-


Syntax ableValuesIncludingUnits>)
Python varStr = oDesign.ConstructVariationString(["xx", "yy"],
Examp- ["2mm", "1mm"])

Design Object Script Commands 8-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

le oDesign.ExportProfile("Setup1", varStr, "C:\profile.prof")

VB ConstructVariationString(<ArrayOfVariableNames>, <ArrayOfVari-
Syn- ableValuesIncludingUnits>)
tax

VB oDesign.ConstructVariationString(Array("x_size","y_size"),
Exam- Array("2mm", "1mm"))
ple

DeleteFieldVariation
Delete field variations, fields and meshes, or fields and meshes for all variations

[Solver]>Results>Clean Up Solutions>Fields Only (or Fields and Meshes


UI Access
depending on second argument)

Name Type Description


All Array deletes fields and meshes for all variations
Parameters
None Boolean deletes mesh data
None Boolean deletes linked data

Return Value None

Fields

Pyt- DeleteFieldVariation ([All | Array(<parameters>)], boolean, boolean, [boolean])


hon
Sy-
nta-
x

oProject = oDesktop.GetActiveProject()
Pyt-
oDesign = oProject.GetActiveDesign()
hon
Exa- Design.DeleteFieldVariation(["mm=\'2mm\' y_
mp- 1=\'0.838297677541429mm\' y_7=\'3.07582323679311mm\'"],
le False, False)

Fields and meshes

Pyt- DeleteFieldVariation ([All | Array(<parameters>)], boolean, boolean, [boolean])


hon
Sy-
nta-
x

Design Object Script Commands 8-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Pyt- oDesign.DeleteFieldVariation(["mm=\'2mm\' y_
hon 1=\'0.559511093478194mm\' y_7=\'1.86857203894162mm\'"], True,
Exa- False)
mp-
le

Fields and meshes for all variations

Python DeleteFieldVariation ([All | Array(<parameters>)], boolean, boolean, [boolean])


Syntax

Python oDesign.DeleteFieldVariation("All", True, False)


Example

VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("OptimTee")
Set oDesign = oProject.SetActiveDesign("TeeModel")
oDesign.DeleteFieldVariation "All", true, false
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")

Design Object Script Commands 8-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oDesktop = oAnsoftApp.GetAppDesktop()


oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("OptimTee")
Set oDesign = oProject.SetActiveDesign("TeeModel")
oDesign.DeleteFieldVariation Array("offset=" & Chr(39) &
"0.0947046688081817in" & Chr(39) & ""), _
true, false

DeleteFullVariation
Use: Use to selectively make deletions or delete all solution data.
Command: [solver]>Results>Clean Up Solutions...
Syntax: DeleteFullVariation Array(<parameters>), boolean
Parameters: All | <DataSpecifierArray>
If, All, all data of existing variations is deleted.
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:
Set oDesign = oProject.SetActiveDesign("MaxwellModel1")
oDesign.DeleteFullVariation Array(""), false
Example:
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")

Design Object Script Commands 8-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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("Ansoft.ElectronicsDesktop")
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

Python Syn- DeleteFullVariation Array(<parameters>, <boolean>)


tax

Python oDesign.DeleteFullVariation("All", False)


Example

DeleteLinkedDataVariation
Deletes the linked data of specified variations.

UI Access [product_name]>Results>Clean Up Solutions

Name Type Description


<DesignVariationKeys> Arrays of The keys of the variation whose linked
Parameters strings data are going to be deleted
Array(<DesignVariationKey>)
< DesignVariationKey> String Design variation string.

Return Value None

Design Object Script Commands 8-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Pytho- DeleteLinkedDataVariation(<DesignVariationKeys>)
n Syn-
tax

Pytho- oDesign.DeleteLinkedDataVariation(["current=\'0.9mA\'", "cur-


n rent=\'1.0mA\'"])
Exam-
ple

VB DeleteLinkedDataVariation(<DesignVariationKeys>)
Syn-
tax

VB oDesign.DeleteLinkedDataVariation(Array("current=\'0.9mA\'",
Exam- "current=\'1.0mA\'"))
ple

DeleteVariation
Use:Obsolete. Use DeleteFullVariation, DeleteFieldVariation, DeleteLinkedDataVariation.

EditDesignSettings
Use: To set the design settings.
Command: [product]>Design Settings
Syntax: EditDesignSettings <OverrideArray>
Return Value: None
Parameters: <OverrideArray>
Array("NAME:Design Settings Data",
"Use Advanced DC Extrapolation:= <Boolean>,
"Port Validation Settings=: ["Standard" | "Extended"]
"Calculate Lossy Dielectrics:=", <Boolean>)
"Use Power S:=", <Boolean>,
"Export After Simulation:=", <boolean>, "Export Dir:=", "<path>",
"Allow Material Override:=", <boolean>,
"Calculate Lossy Dielectrics:=", <boolean>,
"EnabledObjects:=", Array(),
"Model validation Settings:=", Array("NAME:Validation Options",
"EntityCheckLevel:=", "[strict | none | warningOnly | basic ]",

Design Object Script Commands 8-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"IgnoreUnclassifiedObjects:=", <boolean>,
"SkipIntersectionChecks:=", <boolean>),
"Design Validation Settings:=", "Perform full validations" )
HFSS Example
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project4")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
oDesign.EditDesignSettings Array("NAME:Design Settings Data", "Use
Advanced DC Extrapolation:=", _
false, "Use Power S:=", false, "Export After Simulation:=", false,
"Allow Material Override:=", _
true, "Calculate Lossy Dielectrics:=", true, "Perform Minimal val-
idation:=", _
false, "EnabledObjects:=", Array(), "Port Validation Settings:=",
"Standard"), Array("NAME:Model Validation Settings", "EntityCheck-
Level:=", _
"Strict", "IgnoreUnclassifiedObjects:=", true, "SkipIn-
tersectionChecks:=", _
false)

HFSS-IE Design Settings


Use: To set the design settings for materials override.
Command: HFSS-IE>Design Settings
Syntax: EdotDesignSettings <MaterialsOverrideArray>
Return Value: None

Design Object Script Commands 8-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters: <MaterialsOverrideArray>
Array("NAME:Design Settings Data",
"Allow Material Override:=", <boolean>,
"Calculate Lossy Dielectrics:=", <boolean>,
"Perform Minimal validation:=", <boolean>,
"PECThreshold:=", <real>, "CondThreshold:=", <int>),
Array("NAME:Model Validation Settings", "EntityCheckLevel:=", [strict | none | warningOnly | basic
]", "IgnoreUnclassifiedObjects:=", <boolean>,
"SkipIntersectionChecks:=", <boolean>)
HFSS-IE Example
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project38")
Set oDesign = oProject.SetActiveDesign("IEDesign1")
oDesign.EditDesignSettings Array("NAME:Design Settings Data", "Allow
Material Override:=", _
true, "Calculate Lossy Dielectrics:=", true, "Perform Minimal val-
idation:=", _
false, "PECThreshold:=", 1E+030, "CondThreshold:=", 10000), _
Array("NAME:Model Validation Settings", "EntityCheckLevel:=", _
"Strict", "IgnoreUnclassifiedObjects:=", false, "SkipIn-
tersectionChecks:=", _
true)

Python Syn- SeparateBody (<SelectionsArray>)


tax

Python oDesign.EditDesignSettings(
Example [

Design Object Script Commands 8-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"NAME:Design Settings Data",


"Use Advanced DC Extrapolation:=", True,
"Use Power S:=" , False,
"Export After Simulation:=", False,
"Allow Material Override:=", True,
"Calculate Lossy Dielectrics:=", True,
"Perform Minimal validation:=", False,
"EnabledObjects:=" , [],
"Port Validation Settings:=", "Standard"
],
[
"NAME:Model Validation Settings",
"EntityCheckLevel:=" , "Strict",
"IgnoreUnclassifiedObjects:=", False,
"SkipIntersectionChecks:=", False
])

EditNotes
Edits design notes.
Command: Click [design_type]>Edit Notes, or right-click a design instance in the project tree and
select Edit Notes.
Return Value: None
Parameters: <DesignNotes>
Type: string
VB Example: oDesign.EditNotes "Design for testing"

Python Syn- EditNotes(<DesignNotes>)


tax

Python
Example oDesign.EditNotes("Design for testing")

Design Object Script Commands 8-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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

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

For Q3D Extractor the ExportConvergence command details are as follows:


Use: Exports convergence data to file for the given variation.
Command: None
Syntax: ExportConvergence <SetupName>, <VariationString>, <SolnType>, <FilePath>
Return Value: None

Design Object Script Commands 8-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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

Python ExportConvergence (<SetupName>, <VariationString>, <FilePath> <over-


Syntax writeIfExists>)
oDesign.ExportConvergence
Python
"Setup1", "x_size = 2mm", "AC RL", "c:\convergence.conv"
Example
])

ExportMatrixData
Use:Exports matrix in Matlab or spreadsheet format.
Command:In the Matrix tab of the Solution dialog box, click Export>RLGC.

Design Object Script Commands 8-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax:ExportMatrixData <FileName>, <SolnType>, <DesignVariationKey>, <Solution>, <Mat-


rix>, <ResUnit>, <IndUnit>, <CapUnit>, <CondUnit>, <Frequency>, <MatrixType>, <PassNum-
ber>, <ACPlusDCResistance>
Return Value:none
Parameters:<FileName>
Type: <string>
The path and name of the file where the data will be exported. The
file extension determines the file format.
<SolnType>
Type: <string>
One of the following "C", "AC RL" and "DC RL"
<DesignVariationKey>
Type: <string>
Design variation string
Example: "radius = 3mm"
The empty variation string ("") is interpreted to mean the current
nominal variation.
<Solution>
<SolveSetup>:<Soln>
Parameters:
<SolveSetup>
Type: <string>
Name of the solve setup
<Soln>
Type: <string>
Name of the solution at a certain adaptive pass.
<Matrix>
Type: <string>
Either "Original" or one of the reduce matrix setup names
<ResUnit>
Type: <string>
Unit used for the resistance value

Design Object Script Commands 8-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<IndUnit>
Type: <string>
Unit used for the inductance value
<CapUnit>
Type: <string>
Unit used for the capacitance value
<CondUnit>
Type: <string>
Unit used for the conductance value
<Frequency>
Type: <double>
Frequency in hertz.
<MatrixType>
Type: <String>
Value: "Maxwell", "Spice", "Couple" , (one or all of these).
Matrix type to export.
<PassNumber>
Type: <integer>
Pass number.
<ACPlusDCResistance>
Type: <bool>
Default Value: false
Add DC and AC resistance and export the matrix.
VB Example:oDesign.ExportMatrixData "C:/temp/3DScripts/rlgc_
lvl.lvl", "C, DC RL, AC RL", "", _ "Setup1:LastAdaptive", "Ori-
ginal", "ohm", "nH", "pF", "mSie", 100000000, _ "Max-
well,Spice,Couple", 0

Pytho- ExportMatrixData ([FileName, SolnType, DesignVariationKey, Solution, Matrix,


n Syn- ResUnit, IndUnit, CapUnit, CondUnit, Frequency, MatrixType, PassNumber,
tax ACPlusDCResistance])

Design Object Script Commands 8-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oDesign.ExportMatrixData
Pytho- (["C:/temp/3DScripts/rlgc_lvl.lvl", "C, DC RL, AC RL", "", _
n "Setup1:LastAdaptive",
Exam- "Original", "ohm", "nH", "pF", "mSie", 100000000, _ "Max-
ple well,Spice,Couple",
0])

ExportNetworkData
Exports matrix solution data to a file. Available only for Driven solution types with ports.
Command: None
Syntax: ExportNetworkData
<DesignVariationKey>, <SolnSelectionArray>, <FileFormat>,
<OutFile>,<FreqsArray>, <useExportFreqs>, <DoRenorm>, <RenormImped>
<dataType> <pass> <complexFormat> <Touch-
stoneNumberofDigitsPrecision> <IncludeGammaAndImpedanceComments>
<SupportNon-standardTouchstoneExtensions>
Return Value: None
Parameters: <SolnSelectionArray>
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>

Design Object Script Commands 8-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type: <string>
Full path to the file to write out.

<FreqsArray>
Type: Array of doubles or "All".
The frequencies to export. The <FreqsArray> argument contains a vector (e.g. "1GHz",
"2GHz", ...) to use, or "all". To export all frequencies, use Array("all").
<useExportFreqs>
Type: <bool>
Optional, currently always ignored.
<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.
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.

Design Object Script Commands 8-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<TouchstoneNumberofDigitsPrecision>
Type: <int>
Default if not specified is 15.
<IncludeGammaAndImpedanceComments>
Type: <bool>
Specifies whether to include Gamma and Impedance comments.
<SupportNon-standardTouchstoneExtensions>
Type: <bool>
Specifies whether to support non-standard Touchstone extensions for mixed reference
impedances.

VB Example: Export all frequencies:


oModule.ExportNetworkData "width=’2in’", _
Array("Setup1:Sweep1"),2, "c:\mydir\out.tab", _
Array("all"), false, 0
VB 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
VB Example: Touchstone Outputs with Precision, Gamma and Impedance
Comments, and support for mixed reference impedances.
oModule.ExportNetworkData "offset=" & Chr(39) & "0in" & Chr(39) &
"", Array("Setup1:Sweep1"), 3, "C:/MyDocuments/Tee_TeeModel.s3p",
Array("All"), true, 50, "S", -1, 0, 15, true, true, false

ExportNetworkData( [

Pyth- "",
on
Syn-
# Empty string.
tax 1,
#The number 1.

Design Object Script Commands 8-23


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Name",
# This is the full path of the file from which the solution is loaded.
"ExportFile",
# full path of file to export to
"variation",
# Pick a particular variation. Leave blank if no variation
["NAME:Frequencies"],
# optional, if none defined all frequencies are used
["NAME:Options",
# Export options object
"DataTypes:=", ["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
])

Design Object Script Commands 8-24


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

import ScriptEnv
ScriptEnv.Initialize("Ansoft.ElectronicsDesktop")
oDesktop.RestoreWindow()
Pyth- oProject = oDesktop.SetActiveProject("package")
on
Exa- oDesign = oProject.SetActiveDesign("HFSSDesign1")
mple
oModule = oDesign.GetModule("Solutions")
oModule.ExportNetworkData("", ["Setup1:Sweep1"], 3, "C://Docu-
ments/package_HFSSDesign1.s4p", _
Array ('all'), True, 50, "S", -1, 0, 15, True, True, True)

ExportNMFData
Use:Exports s-parameters in neutral file format.
Command:In the matrix tab of the Solution dialog box, click Export->S-Parameter. Then select
the Neutral Model file format.
Syntax: ExportNetworkData <SolutionName> <FileName> <ReduceMatrix><Reference Imped-
ance> <FrequencyArray> <DesignVariation> <Format> <Length> <PassNumber>
Return Value:None
Parameters:SolutionName>
Type: <String>
Format: <SetupName>:<SolutionName>
Solution that is exported.
<FileName>
Type:<String>
The name of the file. The file extension will determine the
file format.
<ReduceMatrix>
Type: <string>
Either "Original" or one of the reduce matrix setup name
<Reference Impedance>
Type: <Double>
Reference impedance
<FrequencyArray>

Design Object Script Commands 8-25


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type: <Array of doubles>


Value: Array(<double>,<double>….)
Frequency points in the sweep that is exported.
<DesignVariation>
Type: <String>
Design variation at which the solution is exported.
<Format>
Type: <String>
Values: "MagPhase", "RealImag", "DbPhase".
The format in which the sparameters will be exported.
<Length>
Type:<String>
Length for exporting sparameters.
<PassNumber>
Type:<integer>
Pass number.
VB Example:
oDesign.ExportNMFData "Setup7 : LastAdaptive", "C:/temp/neu.nmf",
"Original", _ 50, Array(10000000, 20000000, 30000000, 40000000,
50000000, 60000000, 70000000, _ 80000000, 90000000, 100000000), "",
"MagPhase","7meter"

ExportNMFData( 
"",
# Empty string.
1,
Python Syn-
tax
#The number 1.
"Name",
# This is the full path of the file from which the solution is loaded
"ExportFile",
# full path of file to export to

Design Object Script Commands 8-26


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

["NAME:Frequencies"],
#optional, if none defined all frequencies are used
["NAME:NMFOptions",
#Export NMF options object
"DataTypes:=", ["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
"Variables:=", ["FF", "cap", "Rs"]
# Array of variables
"Variations:=", ["", "", ""]
# Array of variations to export solutions for
["NAME:ConstantVars"]
#Array of variables that are constant, can be empty
["NAME: DependentVars"]
#Array of variables that are dependent, can be empty

Design Object Script Commands 8-27


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"MatrixSize:=", 2,
#Matrix size, optional (used in nmf file header)
"CreateNPortModel:=", true
#Create a model based on the exported file true/false
])
oTool = oDesktop.GetTool("NdExplorer")
oTool.ExportNetworkData("", True,
"C:/.../100OHM.S2P", "$SYSLIB/Test.s2p", "",
[
"NAME:Frequencies",
500000000,
1000000000,
10000000000,
25000000000,
50000000000,
75000000000,

Python
Example 100000000000
],
[
"NAME:TSOptions",
"DataTypes:=" , ["S"],
"DisplayFormat:=" , "DB",
"FileType:=" , 3,
"Renormalize:=" , True,
"RefImpedance:=" , 50,
"Precision:=" , 6,
"UseMultipleCores:=" , False,
"NumberOfCores:=" , 1,

Design Object Script Commands 8-28


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Comments:=" , True,
"Noise:=" , False
])

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
VB Example:
oDesign.ExportMeshStats ("Setup1", "offset=" & Chr(39) & "0.09in" &
Chr(39) & "","C:\mydir\meshstats.ms" "tat")

Python N/A
Syntax

oDesign.ExportMeshStats (["Setup1", "offset="


Python
& Chr(39) & "0.09in" & Chr(39) & "","C:\mydir\meshstats.ms"
Example
"tat"])

Design Object Script Commands 8-29


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ExportProfile
Use: Exports a solution profile to file.
Syntax: ExportProfile <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:\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
VB Example:
oDesign.ExportProfile "Setup1", "", "c:\profile.prof"

Python ExportProfile <SetupName>, <VariationString>, <FilePath>, <overwriteIfExists>)


Syntax

Python oDesign.ExportProfile (["Setup1", "", "c:\profile.prof"])


Example

Generate Mesh
Use: If any mesh operations were defined and not yet performed in the current variation for the spe-
cified 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 > Generate Mesh.

Design Object Script Commands 8-30


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax: GenerateMesh <SetupNameArray>


Return Value: <SetupNameArray>
Type: <int>
-1: completed with error
0: completed successfully
VB Example:
status = oDesign.GenerateMesh Array("Setup1","Setup2")

Python GenerateMesh (<SetupNameArray>)


Syntax

Python oDesign.GenerateMesh Array(["Setup1","Setup2"])


Example

GetChildNames [Design]
Use: Gets child names of the Design object..
Syntax: GetChildNames(childType)
Return Value: Returns names of children for the Design object.
Parameters: childType-- optional parameter, default will return Module and Editor names; or use
value returned by GetChildTypes().

Python Syn- GetChildNames (childType)


tax

oDesign = oProject.GetActiveDesign()
arrModuleAndEditorNames = oDesign.GetChildNames()
Python
arrEditorNames = oDesign.GetChildNames("Editor")
Example
arrModuleNames = oDesign.GetChildNames("Editor")
arrVariableNames = oDesign.GetChildNames("Variable")

VB Syntax GetChildNames(childType)
VB Example

GetChildObject [Design]
Returns the Child Object of the Design object.

Design Object Script Commands 8-31


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access NA

Name Type Description


ObjectPath text string Module, Editor, Variable name; or a path with
Parameters multiple generations. Like ("Para-
metrics/OptimizationSetup1").
See Object Path discussion here.

Return a child object of the Design.


Value

Python Syn- GetChildObject(objectPath)


tax

oDesign = oProject.GetActiveDesign()
oOptimModule = oDesign.GetChildObject(“Optimetrcis”)
oEditor = oDesign.GetChildObject(“3D Model”)
Python
Example oBox = oDesign.GetChildObject(“3D Model/Box1”)
oRpt = oDesign.GetChildObject("Results/S Parameter Plot
1")
oVariable= oDesign.GetChildObject("Offset")

VB Syntax GetChildObject(objectPath)
set oDesign = oProject.GetActiveDesign()
set oOptimModule = oDesign.GetChildObject(“Opti-
metrcis”)
set oEditor = oDesign.GetChildObject(“3D Model”)
VB Example
set oBox = oDesign.GetChildObject(“3D Model/Box1”)
set oRpt = oDesign.GetChildObject("Results/S Parameter
Plot 1")
set oVariable= oDesign.GetChildObject("Offset")

GetChildTypes [Design]
Use: Gets child types of design object.
Syntax: GetChildTypes()

Design Object Script Commands 8-32


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Return Value: Returns ['Module', 'Editor', 'Variable'].

Python GetChildTypes ()
Syntax

oProject=oDesktop.GetActiveProject()
oDesign = oProject.GetChildObject("'HFSSDesign1'")
Python
oDesign .getChildTypes()
Example
['Module', 'Editor', 'Variable']

GetConfigurableData

Note:
This command is for internal ANSYS use only.

Python Syn- GetConfigurableData()


tax

Python oDesign.GetConfigurableData()
Example

GetData

Note:
This command is for internal ANSYS use only.

Python Syn- GetData()


tax

Python oDesign.GetData()
Example

GetDesignType
Returns the design type of the active design.

Design Object Script Commands 8-33


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access NA
Parameters NA

String indicating the design type of the active design ("Circuit Design", "Circuit
Netlist", "HFSS 3D Layout Design", "HFSS", "HFSS-IE", "Icepak", "Maxwell
Return Value
2D", "Maxwell 3D", "Q2D Extractor", "Q3D Extractor", "RMxprt", "Twin
Builder")

Python Syn- GetDesignType()


tax

Python oDesign = oProject.GetActiveDesign()


Example oDesign.GetDesignType()

VB Syntax GetDesignType()

VB Set oDesign = oProject.GetActiveDesign()


Example oDesign.GetDesignType()

GetDesignValidationInfo
Use: Returns the validation information. For example, for a non-graphical job so the cluster man-
ager can reject any job in a queue that does not have proper validation. For example, ansysedt.exe
-features=SF6694_Non_Graphical_Command_execution -ng -runscriptandexit "D:/MyPro-
jects/Validate.py" "E/MyProjects/Tee.aedt".
Command: none
Syntax: GetDesignValidationInfo(<ValidationResultfilePath>)
Return Value: 0 if Validation is not done or 1 if a validation result has been found. Writes the result
to a user specified location.
Type: <string>
Format is as follows:
<ValidationInfo>
<DesignValid>false</DesignValid>
<IgnoreUnclassifiedObjects>false</IgnoreUnclassifiedObjects>
<SkipIntersectionChecks>false</SkipIntersectionChecks>
<EntityCheckLevel>Strict</EntityCheckLevel>

Design Object Script Commands 8-34


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<ValidationLevel>Perform full validations with standard port


validations</ValidationLevel>
<Messages>
<Message>[warning] Warning - Boundary &apos;Rad1&apos; and
Boundary &apos;PerfE1&apos; overlap. </Message>
<Message>[error] Error - Port &apos;Port1&apos; and Port
&apos;1&apos; overlap. </Message>
</Messages>
</ValidationInfo>
VB Example:
BOOL ret = oDesign.GetDesignValidationInfo(E:/MyPro-
jects/Validation.xml)

Pytho- GetDesignValidationInfo(<filePath>)
n Syn-
tax

Pytho- BOOL ret = oDesign.GetDesignValidationInfo("E:/MyPro-


n jects/Validation.xml")
Exam-
ple

GetEditSourcesCount
Returns the number of sources that are listed in the Edit Sources panel.
Command: None
Syntax: GetEditSources
Return Value: <int>
Parameters: None
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor

Design Object Script Commands 8-35


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject
Set oDesign = oProject.GetActiveDesign
Set oModule = oDesign.GetModule("Solutions")
Dim count
count = oModule.GetEditSourcesCount
MsgBox(count)

Python Syn- GetEditSourcesCount


tax

Python oModule.GetEditSourcesCount
Example

GetExcitationsModule
Query source scalings (mag, phase etc.) from the Edit Source panel.
Command: None
Syntax: GetExcitationScaling( <port name>, <port index>)
Return Value: Scaling for excitation.
Parameters: <port name>
Port ID
<port index>
Port Index if present.
Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor

Design Object Script Commands 8-36


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project15")
Set oDesign = oProject.SetActiveDesign("HfssDesign1")
Set oModule = oDesign.GetExcitations("Solutions")

' --------- first terminal off of port "1" -------


' data = oModule.GetExcitationScaling( "1" )

' --------- excitations for modal "port1:2" -------


data = oModule.GetExcitationScaling( "port1", 2 )

' -- Second eigenmode (excitation name is irrelevant --


' data = oModule.GetExcitationScaling( "unused", 2 )

' ----------------------------------------------
' sample code to display results
' ----------------------------------------------

buffer = ""
for i = 0 to uBound(data)
buffer = buffer & data(i)
if i < uBound(data) then buffer = buffer + ", "
next
MsgBox( buffer )

GetManagedFilesPath
Get the path to the project's results folder.

Design Object Script Commands 8-37


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access NA

Name Type Description


Parameters
None

The path where the project results are located, such as C:/Users/[user-
Return Value
name]/Ansoft/Project31.aedtresults/mf_0/

Python Syn- oDesign.GetManagedFilesPath()


tax

Python oDesign.GetManagedFilesPath()
Example

VB Syntax oDesign.GetManagedFilesPath
VB Example oDesign.GetManagedFilesPath

GetModule
Use: Returns the IDispatch for the specified module.

UI Access NA

Name Type Description


Parameters <modulename> String Currently the only module name supported is
"SimSetup"

Return Value Module IDispatch

Python Syn- GetModule (<modulename>)


tax

Python oModule = oDesign.GetModule("SimSetup")


Example

VB Syntax GetModule <modulename>


VB set oModule = oDesign.GetModule("SimSetup")
Example

Parameters: Type: <string>

Design Object Script Commands 8-38


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name of the module. One of the following:


- Boundary module: "BoundarySetup"
- Mesh Operations module: "MeshSetup"
- Reduce Matrix module: "ReduceMatrix"
- Analysis module: "AnalysisSetup"
- Optimetrics module: "Optimetrics"
- Solutions module: "Solutions"
- Field Overlays module: "FieldsReporter"
- Radiation module: "RadField"
- Reporter module: "ReportSetup"

VB Example:
Set oModule = oDesign.GetModule "BoundarySetup"
For Q3D Extractor the GetModule command details are as follows.
Use: Returns the IDispatch for the specified module.
Command: none
Syntax: GetModule <ModuleName>
Return Value: Module object.
Parameters: Type: <string>
Name of the module. One of the following:
- Boundary module: "BoundarySetup"
- Mesh Operations module: "MeshSetup"
- Reduce Matrix module: "ReduceMatrix"
- Analysis module: "AnalysisSetup"
- Optimetrics module: "Optimetrics"
- Solutions module: "Solutions"
- Field Overlays module: "FieldsReporter"
- Reporter module: "ReportSetup"
VB Example: Set oModule = oDesign.GetModule "MeshSetup"
Example:

Design Object Script Commands 8-39


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModule = oDesign.GetModule("ReportSetup")
oModule.GetPropertyValue("Trace", "S Parameter Plot 1:dB(S(1,1))","Y
Axis")

GetName
Returns the name of the Design.

UI Access NA

Name Type Description


Parameters
None

 String, the hierarchical name of the design, with the following format:
<id0>;<name0>[/<id1>;<name1>]*, where the id and name for a
design at any level of hierarchy can be seen as the values of the ID and Rep-
resentation properties on the General tab when the design is selected in the pro-
Return Value ject window. The first set of id and name identifies the top level design, the next
set identifies the design at the next level of hierarchy, and the remaining sets
identify further levels of hierarchy. Note that two instances of the same design
will have different ID values, so that the hierarchical name is specific to the
actual design instance responding to the script method.

Python Syn- GetName()


tax

Python dname = oDesign.GetName()


Example

VB Syntax GetName
VB Example dname = oDesign.GetName

GetNominalVariation
Use: Gets the nominal variation string
Command: None
Syntax: GetNominalVariation()
Return Value: Returns a string representing the nominal variation

Design Object Script Commands 8-40


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters: None
VB Example:
var = oDesign.GetNominalVariation()

Python Syn- GetNominalVariation(<>)


tax

Python oDesign.GetNominalVariation([])
Example

GetNoteText
 Return the text of the note added to a design in the project tree.

UI Access NA

Name Type Description


Parameters
None

Return Value Returns text of the design note

Python Syn- GetNoteText()


tax

oProject = oDesktop.GetActiveProject()
Python oDesign = oProject.GetActiveDesign()
Example
oDesign.GetNoteText()

GetPostProcessingVariables
 Return the list of post processing variables.

UI Access NA

Name Type Description


Parameters
None

Return Value Returns list of variables

Design Object Script Commands 8-41


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- GetPostProcessingVariables()


tax

oProject = oDesktop.GetActiveProject()
Python oDesign = oProject.GetActiveDesign()
Example
oDesign.GetPostProcessingVariables()

GetPropNames [Design]
Use: Always return empty array since the design has no property.
Syntax: GetPropNames()
Return Value: Returns empty array.
Parameters: Implicit or specific name of Design object.

Python Syn- GetPropNames ()


tax

Python GetPropNames(bIncludeReadOnly)
Example

GetPropValue [Design]
Returns the property value for the active design object, or specified property values.

UI Access NA

Name Type Description


Parameters PropPath a child object's property path. See property
path discussion here.

Return Value the property value of a child object.

Python Syn- GetPropValue(propPath)


tax

oProject = oDeskop.GetActiveProject()
Python oDesign = oProject.GetChildObject(“TeeModel”)
Example
oDesign.GetPropValue(“offset”) // Get value of offset
variable as text string

Design Object Script Commands 8-42


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oDesign.GetPropValue(“offset/SIValue”) // Get SI-value


of offset variable as number.
oDesign.GetPropValue("Results/S Parameter Plot 1/Dis-
play Type") // Get the report display type as text
string
oDesign.GetPropValue("Results/S Parameter Plot 1/Dis-
play Type/Choices'") // Get the report display type
choice as array of text string

VB Syntax GetPropValue(propPath)
set oProject = oDeskop.GetActiveProject()
set oDesign = oProject.GetChildObject(“TeeModel”)
valStr = oDesign.GetPropValue(“offset”) // Get value of
offset variable as text string
val = oDesign.GetPropValue(“offset/SIValue”) // Get SI-
VB Example value of offset variable as number.
disp = oDesign.GetPropValue("Results/S Parameter Plot
1/Display Type") // Get the report display type as text
string
arr = oDesign.GetPropValue("Results/S Parameter Plot
1/Display Type/Choices'") // Get the report display
type choice as array of text string

GetSelections
Use:Informational.
Command:None
Syntax:GetSelections
Return Value:array of names. When called after a copy/paste operation, it returns a list of the pas-
ted objects.
Parameters:None
VB Example:Set oProject = oDesktop.SetActiveProject("Project6")
Set oDesign = oProject.SetActiveDesign("Q3DDesign1")
Set oEditor = oDesign.SetActiveEditor("Modeler")
Dim A
A = Array()

Design Object Script Commands 8-43


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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

Python Syn- GetSelections([])


tax

oEditor.GetSelections(
[
Dim B
B = Join(A,",")
'Debug.Write "The Selections are " &B
Python
Example MsgBox(B)
Dim C
C = Array("NAME:Selections", "Selections:=",
B)
oEditor.Delete C
])

GetSolutionType
Use: Returns the solution type for the design.
Command: none (The solution type may be viewed in the project tree at the design level.)
Syntax: GetSolutionType
Return Value: <SolutionType>
Type: <string>

Design Object Script Commands 8-44


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Examples of possible values are: "DrivenModal", "DrivenTerminal", "Eigenmode", "Tran-


sient" or "Transient Network".

Python Syn- GetSolutionType()


tax

oProject = oDesktop.GetActiveProject()
Python
oDesign = oProject.GetActiveDesign()
Example
oDesign.GetSolutionType()

VB Syntax GetSolutionType
VB 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.
VB 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
VB Example:
SetoModule = oDesign.GetModule("Solutions")
oModule.GetSourceContexts

Design Object Script Commands 8-45


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- GetSourceContexts(<>)


tax

Python oModule.GetSourceContexts([])
Example

GetVariationVariableValue
Use: Finds the value of a variable for a specific variation string.
Command: None
Syntax: GetVariationVariableValue(<VariationString>, <VariableName>)
Return Value: Returns a double precision value in SI units, interpreted to mean the value of the vari-
able contained in the variation string.
Parameters: <VariationString>
Type: string
<VariableName>
Type: string
VB Example:
Example: varval = _
oDesign.GetVariationVariableValue("x_size = 2mm y_size = 1mm",_ "y_
size")

GeometryCheckAndAutofix
Use: Runs Geometry Check and optionally applies autofixes.
Command: HFSS 3D Layout > Geometry Check
Syntax: GeometryCheckAndAutofix <ChecksArray>,
      minimum_area_meters_squared,
      <FixesArray>
Return Value: None
Parameters: <ChecksArray> - Array("NAME:checks", <check 1>, <check
2>, …, <check n>)
Specify the checks that should be included. Specifying fewer checks
may speed up execution but may also result in less problems reported

Design Object Script Commands 8-46


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

in the message manager (or the logfile) and consequently less prob-
lems that can be fixed by autofixes.
The following are valid checks that can be specified:
— "Self-Intersecting Polygons"
— "Disjoint Nets (Floating Nodes)"
— "DC-Short Errors"
— "Identical/Overlapping Vias"
— "Misaligments"
There may be no checks, all 5 of the checks, or anything in between.
The order that checks are specified in is not relevant.

minimum_area_meters_squared
Specify a decimal value for the minimum area (e.g. .000015) option-
ally in scientific notation (e.g. 2E-006). Cutouts smaller than this
minimum area may be ignored during validation check.

<FixesArray> - Array("NAME:fixes", <fix 1>, <fix 2>, …, <fix n>)


Specify the autofixes that should be applied if they are found by a
check.
The following are valid fixes that can be specified:
— "Self-Intersecting Polygons"
— "Disjoint Nets",
— "Identical/Overlapping Vias"
— "Traces-Inside-Traces Errors"
— "Misalignments (Planes/Traces/Vias)"
There may be no fixes specified, all 5 fixes specified, or anything
in between. The order that fixes are specified in is not relevant.
Example:
oEditor.GeometryCheckAndAutofix _
Array("NAME:checks", "Self-Intersecting Polygons", _
"Disjoint Nets (Floating Nodes)", "DC-Short Errors", _
"Identical/Overlapping Vias", "Misaligments"), _

Design Object Script Commands 8-47


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"minimum_area_meters_squared:=", 2E-006, _
Array("NAME:fixes", "Self-Intersecting Polygons", _
"Disjoint Nets", "Identical/Overlapping Vias", _
"Traces-Inside-Traces Errors", _
"Misalignments (Planes/Traces/Vias)")

PasteDesign (Design Object)


Use:Paste a design that has already been copied to the clipboard into another design to create a
subdesign.
Command:After copying a design from the project window, right-click Nexxim, HFSS 3D Layout
Design, or Simplorer Design, and then choose Paste. Or select one of those designs and choose
Edit>Paste menu or Ctrl-V shortcut. Or drag an appropriate design in the project window and drop
it on one of those designs.
Syntax:PasteDesign pasteOption
Return Value: None
Parameters:
pasteOption
Type: <Integer>
One of the following:

l 0 to link to the existing design that was copied

l 1 to create a new copy of the design that was copied but keep the original layers of the
design being copied

l 2 to create a new copy of the design and merge the layers of the design being copied into the
design receiving the copy
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")

Design Object Script Commands 8-48


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oDesktop = oAnsoftApp.GetAppDesktop()


oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("SimpleCircuitPaste")
oProject.CopyDesign "B"
Set oDesign = oProject.SetActiveDesign("A")
oDesign.PasteDesign 1

Redo [Design]
Reapplies the last design-level command.

UI Access Edit>Redo

Name Type Description


Parameters
None

Return Value None

Python Syn- Redo()


tax

Python oDesign.Redo()
Example

VB Syntax Redo
VB Example oDesign.Redo

RenameDesignInstance
Renames a design instance.

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

Name Type Description


<OldName> String The current name of the design, which must
Parameters be the design on which this command is
invoked.
<NewName> String The new name for the design.

Design Object Script Commands 8-49


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Return Value None

Python RenameDesignInstance (<OldName>, <NewName>)


Syntax

Python oDesign.RenameDesignInstance("Design1", "Design2")


Example

VB Syntax RenameDesignInstance <OldName>, <NewName>

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

ResetToTimeZero
To reset a simulation to time zero.
Command: CleanStop
Syntax: ResetToTimeZero( "<name of setup>" )
Return Value: None
Parameters: <Name of Setup>
VB Example:
import ScriptEnv
ScriptEnv.Initialize("Ansoft.ElectronicsDesktop")
oDesktop.RestoreWindow()
oProject = oDesktop.SetActiveProject("TermPorts")
oDesign = oProject.SetActiveDesign("TermPorts2Active")
oDesign.AnalyzeAll()
oModule = oDesign.GetModule("AnalysisSetup")
oModule.ResetToTimeZero("Setup1")

Python Syn- ResetToTimeZero("<name of setup>")


tax

Python oModule.ResetToTimeZero(["Setup1"])
Example

Design Object Script Commands 8-50


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

SARSetup
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>, <Tissue object List ID>, <voxel size>,
<Average SAR method>
Return Value: None
Parameters: <TissueMass>
Type: <double>
Double between 1 and 10 in grams.

<MaterialDensity>
Type: <double>
Positive double in gram/cm3.

<Tissue Object listID>


Type: <integer>
The ID of an object list which will be treated as tissues for SAR calculation.

<voxel size>
Type: <double>
The size of a voxel in millimeters.

<Average SAR method>


Type: <integer>
0: IEEE std 1528.
1: Gridless, i.e. classical Ansoft method.
VB Example:
oDesign.SARSetup 1, 1, 678, 1, 0

Design Object Script Commands 8-51


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

SetActiveEditor
Sets the active editor.
Command: None
Syntax: SetActiveEditor(<EditorName>)
Return Value: Editor object
Parameters: <EditorName>
Type: <string>
The only choice is "3D Modeler"
VB Example:
Set oEditor = oDesign.SetActiveEditor("3D Modeler")

Python SetActiveEditor (<editorName>)


Syntax

Python oEditor = oDesign.SetActiveEditor("SchematicEditor")


Example

SetBackgroundMaterial
Use:Sets the background material of the design.
Command:Right click on the design in the project tree and choose "Set Background Material".
Syntax:SetBackgroundMaterial <MatName>
Return Value:None
Parameters:<MatName>
Type: <string>
The name of the background material
VB Example:oDesign.SetBackgroundMaterial "vacuum"

Design Object Script Commands 8-52


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Note:

For a 2D project, you can run this command only if the following conditions are met:

• there is no surface ground in the design, and

• problem type is "open".

SetDesignSettings
Use: To set the design settings.
Command: HFSS>Design Settings
Syntax: SetDesignSettings <OverrideArray>
Return Value: None
Parameters: <OverrideArray>
Array("NAME:Design Settings Data",
"Use Advanced DC Extrapolation:= <Boolean>,
"Port Validation Settings=: ["Standard" | "Extended"]
"Calculate Lossy Dielectrics:=", <Boolean>)
"Use Power S:=", <Boolean>,
"Export After Simulation:=", <boolean>, "Export Dir:=", "<path>",
"Allow Material Override:=", <boolean>,
"Calculate Lossy Dielectrics:=", <boolean>,
"EnabledObjects:=", Array(),
"Maximum Number of Frequencies for Broadband Adapt:=", <int>
],
[
"Model validation Settings:=", Array("NAME:Validation Options",
"EntityCheckLevel:=", "[strict | none | warningOnly | basic ]",
"IgnoreUnclassifiedObjects:=", <boolean>,
"SkipIntersectionChecks:=", <boolean>),
"Design Validation Settings:=", "Perform full validations" )

Design Object Script Commands 8-53


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

HFSS Example
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project38")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
oDesign.SetDesignSettings Array("NAME:Design Settings Data", "Use
Advanced DC Extrapolation:=", _
false, "Use Power S:=", false, "Export After Simulation:=", false,
"Allow Material Override:=", _
false, "Calculate Lossy Dielectrics:=", false, "Perform Minimal val-
idation:=", _
false, "EnabledObjects:=", Array(), "Port Validation Settings:=",
"Extended"), Array("NAME:Model Validation Settings", "EntityCheck-
Level:=", _
"WarningOnly", "IgnoreUnclassifiedObjects:=", false, "SkipIn-
tersectionChecks:=", _
true)

Python Syn- SeparateBody (<SelectionsArray>)


tax

oDesign.SetDesignSettings(
[

Python "NAME:Design Settings Data",


Example "Use Advanced DC Extrapolation:=", True,
"Use Power S:=" , False,
"Export After Simulation:=", False,

Design Object Script Commands 8-54


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Allow Material Override:=", True,


"Calculate Lossy Dielectrics:=", True,
"Perform Minimal validation:=", False,
"EnabledObjects:=" , [],
"Port Validation Settings:=", "Standard"
"Maximum Number of Frequencies for Broadband
Adapt:=", 5
],
[
"NAME:Model Validation Settings",
"EntityCheckLevel:=" , "Strict",
"IgnoreUnclassifiedObjects:=", False,
"SkipIntersectionChecks:=", False
])

SetLengthSettings
Use:Sets the distributed and lumped length of the design.
Syntax:SetLengthSettings
Return Value:None
Parameters: <DistributedUnits>
Type:<String>
Value: Length units
Length Units used for post processing in the design.
<LumpedLength>
Type:<String>
Value: Length (double) with units.
Length of design used in post processing.
<RiseTime>
Type: <String>
Value: Time with units.
Rise time used in post processing steps.

Design Object Script Commands 8-55


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oDesign.SetLengthSettings "mm", "7meter", "1s"

SetObjectDeformation
Sets the deformation of objects when calling ANSYS Electronics Desktop from ANSYS Work-
bench

UI Access [product] > Deformation of Objects

Name Type Description


Parameters
<ObjectArray> Object Array

Return The array of objects


Value

Pyth- SetObjectDeformation()
on
Syn-
tax

system1.SendAnsoftCommand(PyCom-
Pyth- mand="""oDesktop.SetActiveProject(\"MaxwellProject\")
on
.SetActiveDesign(\"Maxwell3DDesign1\")
Exam-
ple .SetObjectDeformation([ \"EnabledObjects:=\" , [\"Cylin-
der1\"]])""")

VB Syntax SetObjectDeformation
VB Example oDesign.SetObjectDeformation

SetObjectTemperature
Sets the temperature of objects.

UI Access [product] > Set Object Temperature

Name Type Description


<Temperature Settings>
<IncludeTem- Boolean True to include tem-
Parameters peratureDependence> perature depend-
Boolean ence. False to not
<EnableFeedback> include.
Array of
<Temperatures> Strings

Design Object Script Commands 8-56


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

True to enable feed-


back. False to not
enable feedback.
Objects and tem-
peratures

Return None
Value

Pytho- oDesign.SetObjectTemperature()
n Syn-
tax

oDesign.SetObjectTemperature(
[
"NAME:TemperatureSettings",
Pytho-
n "IncludeTemperatureDependence:=", True,
Exam-
ple EnableFeedback:=" , False,
Temperatures:=" , ["Regu-
larPolyhedron1","22cel","Polygon1","22cel"
])

VB oDesign.SetObjectTemperature
Syn-
tax

oDesign.SetObjectTemperature Array("NAME:Tem-
VB peratureSettings", "IncludeTemperatureDependence:=", _
Exa-
true, "EnableFeedback:=", true, "Temperatures:=", Array
mpl-
e
("RegularPolyhedron1", _
"22cel", "Polygon1", "22cel"))

SetPhaseCenterPerPort
Use: Sets phase center per port for an HFSS Modal antenna in preparation for link to a target
SBR+ design.
Command: Set Far-Field Phase Center...

Design Object Script Commands 8-57


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax: SetPhaseCenterPerPort (["NAME:1","Coordinate System:=, <"CSName">], ["NAME:2",


Coordinate System:'", <"CSName">]])
Return Value: None.
Parameters: <CSName>
Type: <string>
Name of the coordinate system to set as the phase center.
VB Example:
Set oDesign = oProject.SetSinglePhaseCenter ("RelativeCS1")

Python SetPhaseCenterPerPort ([ ["NAME:1","Coordinate System:=,<CSName>),


Syntax ["NAME:2", Coordinate System:'", <"CSName">]])
oDesign = oProject.SetPhaseCenterPerPort([

Python ["NAME:1","Coordinate System:=,"RelativeCS1"],


Example ["NAME:2","Coordinate System:=,"RealtiveCS1"]
])

SetPropValue [Design]
Sets the property value for the active property object.

UI Access Edit Properties on ProjectTree objects

Name Type Description


Parameters
propPath string a child object's property path. See property
path discussion here.
Value string new property value

Return Value True if the property is found and the new value is valid. Otherwise return False.

Python Syn- SetPropValue(propPath)


tax

oDesign = oProject.GetChildObject(“TeeModel”)
Python oDesign.SetPropValue(“offset”, "12mm")
Example
oDesign.SetPropValue("Results/S Parameter Plot 1/Dis-
play Type", "Rectangular Plot")

Design Object Script Commands 8-58


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax SetPropValue(propPath)
set oDesign = oProject.GetChildObject(“TeeModel”)
oDesign.SetPropValue(“offset”, "0.1in")
VB Example
oDesign.SetPropValue("Results/S Parameter Plot 1/Dis-
play Type", "Rectangular Plot")

SetSinglePhaseCenter
Use: Sets a single phase center for an HFSS Modal antenna in preparation for link to a target
SBR+ design.
Command: Set Far-Field Phase Center...
Syntax: SetSinglePhaseCenter <"CSName">
Return Value: None.
Parameters: <CSName>
Type: <string>
Name of the coordinate system to set as the phase center.
VB Example:
Set oDesign = oProject.SetSinglePhaseCenter ("RelativeCS1")

Python SetSinglePhaseCenter (<CSName>)


Syntax

Python oDesign = oProject.SetSinglePhaseCenter("RelativeCS1")


Example

SetSolutionType
Sets the solution type for the design. This command does not apply to HFSS-IE.
Command: HFSS>Solution Type
Syntax: SetSolutionType <SolutionType>, <AutoOpenMode>,<Model_Exterior_as_IE>
Return Value: None
Parameters: <SolutionType>
Type: <string>
Possible values are: "DrivenModal", "DrivenTerminal", "Transient", "Transient Network",
or "Eigenmode"
<AutoOpenMode>
Type: <Boolean>

Design Object Script Commands 8-59


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Only applies for Driven Solution Type. Possible values are: True, False
<Model_Exterior_as_IE>
Type: <Boolean>
Only Applies for Driven Solution Type. Possible values are: True, False.

VB Example:
oDesign.SetSolutionType "DrivenModal", true, true

For Q3D Extractor the command details are as follows:


Sets the solution type for the design.
Command: 2D Extractor>Solution Type
Syntax: SetSolutionType <SolutionType>
Return Value: None
Parameters: <SolutionType>
Type: <string>
Possible values are: "Open", or "Closed"
VB Example: oDesign.SetSolutionType ("Open")

Python Syn- SetSolutionType (<SolutionType>)


tax

Python oDesign.SetSolutionType
Example (["Open"])

SetSolveInsideThreshold
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>

Design Object Script Commands 8-60


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type: <double>
Siemens/m
VB Example:
oDesign.SetSolveInsideThreshold(100000)

SetSourceContexts
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>
VB Example:
SetoModule = oDesign.GetModule("Solutions")
oModule.SetSourceContexts Array("Box1_T1", "Box1_T2", "Box1_T3",
"Current1", "IncPWave1")

Python Syn- SetSourceContexts Array(<"<sourceID>",...>)


tax

oModule.SetSourceContexts Array([
Python "Box1_T1",
Example "Box1_T2", "Box1_T3", "Current1", "IncPWave1"
])

Solve
Performs a blocking simulation. The next script command will not be executed until the simulation is
complete.
Command: [product]>Analyze
Syntax: Solve <SetupNameArray>
Return Value: Type: <int>
-1: simulation error
0: normal completion

Design Object Script Commands 8-61


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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


<SetupName>
Type: <string>
Name of the solution setup to solve.
VB Example:
return_status = oDesign.Solve Array("Setup1", "Setup2")

For Q3D Extractor Solve command details are as follows:

Performs a blocking simulation. The next script command will not be executed until the simulation is
complete.
Command: Q3D Extractor or 2D Extractor>Analyze. Or right-click the Analysis option in the
project tree and choose "Analyze".
Syntax: Solve <SetupNameArray>
Return Value: Type: <int>
-1: command execution error
1: simulation error
0: normal completion
Parameters: <SetupNameArray>: Array(<SetupName>, <SetupName>, ...)
<SetupName>
Type: <string>
Name of the solution setup to solve.
VB Example: return_status = oDesign.Solve Array("Setup1", "Setup2")

Python Syn- Solve (<SetupNameArray>)


tax

oDesign.Solve Array([
Python
"Setup1", "Setup2"
Example
])

Design Object Script Commands 8-62


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

RunToolkit
Use: Run a Python toolkit script, applying it to the Active Project. The script itself may have pre-
requisites, such as sweeps defined, or specific model characteristics, such as port definitions.
Command: [product]>Toolkit><IronPythonScript>
Syntax: RunToolkit "<LibName>", "<IronPythonScriptName>", Array()
Return Value: User Defined Solutions and user Defined Outputs.
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.
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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")

Design Object Script Commands 8-63


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModule.InsertFrequencySweep "Setup1", Array("NAME:Sweep", "IsEn-


abled:=", true, "SetupType:=", _
"LinearStep", "StartValue:=", "1GHz", "StopValue:=", "10GHz", "StepS-
ize:=", _
"0.1GHz", "Type:=", "Interpolating", "SaveFields:=", false,
"SaveRadFields:=", _
false, "InterpTolerance:=", 0.5, "InterpMaxSolns:=", 250, "Inter-
pMinSolns:=", _
0, "InterpMinSubranges:=", 1, "ExtrapToDC:=", false, "InterpUseS:=",
true, "InterpUsePortImped:=", _
false, "InterpUsePropConst:=", true, "UseDerivativeConvergence:=",
false, "InterpDerivTolerance:=", _
0.2, "UseFullBasis:=", true, "EnforcePassivity:=", true, "Passiv-
ityErrorTolerance:=", _
0.0001)

For Q3D Extractor the RunToolkit command details are as follows:


Use: Run a Python toolkit script, applying it to the Active Project.
Command: Q3D Extractor or 2D Extractor>Toolkit
Syntax: RunToolkit "<LibName>", "<IronPythonScriptName>", Array()
Return Value: User Defined Solutions and user Defined Outputs.
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 thescript.

Design Object Script Commands 8-64


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Full scripting for cable modeling is not supported and no arguments are allowed in the script. The
RunToolkit command will not automatically create a cable bundle, but will simply open the Cable
Modeling dialog box. You will have to manually input your parameters.
Currently, the script to launch the cable modeling dialog boxes is:
oDesign.RunToolkit "SysLib", "CableModeling/AutomotiveCableBundle",
Array()
oDesign.RunToolkit "SysLib", "CableModeling/Oil-GasCableBundle",
Array()

VB Example: Dim oAnsoftApp


Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")

Set oDesktop = oAnsoftApp.GetAppDesktop()


oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project1")
oProject.InsertDesign "Q3D Extractor", "Q3DDesign1", "", ""
oProject.SaveAs "E:\project_directories'3d\v13\user_stories_
R15\US53001_cable_modeling\auto_script.q3dx", true
Set oDesign = oProject.SetActiveDesign("Q3DDesign1")

oDesign.RunToolkit "SysLib", "CableModeling/AutomotiveCableBundle",


Array()
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AutoIdentifyNets

Set oModule = oDesign.GetModule("AnalysisSetup")

Design Object Script Commands 8-65


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModule.InsertSetup "Matrix", Array("NAME:Setup1", "AdaptiveFreq:=",


"1GHz", "SaveFields:=", _
true, "Enabled:=", true, Array("NAME:Cap", "MaxPass:=", 10,
"MinPass:=", 1, "MinConvPass:=", _
1, "PerError:=", 1, "PerRefine:=", 30, "AutoIn-
creaseSolutionOrder:=", true, "SolutionOrder:=", _
"Normal"), Array("NAME:DC", "Residual:=", 1E-005, "SolveResOnly:=",
false, Array("NAME:Cond", "MaxPass:=", _
10, "MinPass:=", 1, "MinConvPass:=", 1, "PerError:=", 1, "Per-
Refine:=", 30), Array("NAME:Mult", "MaxPass:=", _
1, "MinPass:=", 1, "MinConvPass:=", 1, "PerError:=", 1, "Per-
Refine:=", 30)), Array("NAME:AC", "MaxPass:=", _
10, "MinPass:=", 1, "MinConvPass:=", 1, "PerError:=", 1, "Per-
Refine:=", 30))
oProject.Save

Python RunToolkit ("<LibName>", "<IronPythonScriptName>", Array[] )


Syntax

oModule = oDesign.GetModule("AnalysisSetup")
oModule.InsertSetup "Matrix", Array("NAME:Setup1",
"AdaptiveFreq:=", "1GHz", "SaveFields:=", _
true, "Enabled:=", true, Array("NAME:Cap",
"MaxPass:=", 10, "MinPass:=", 1, "MinConvPass:=", _
1, "PerError:=", 1, "PerRefine:=", 30,
"AutoIncreaseSolutionOrder:=", true, "SolutionOrder:=", _
"Normal"), Array("NAME:DC", "Residual:=",
Python 1E-005, "SolveResOnly:=", false, Array("NAME:Cond",
Examp- "MaxPass:=", _
le
10, "MinPass:=", 1, "MinConvPass:=", 1,
"PerError:=", 1, "PerRefine:=", 30), Array("NAME:Mult",
"MaxPass:=",
_
1, "MinPass:=", 1, "MinConvPass:=", 1,
"PerError:=", 1, "PerRefine:=", 30)), Array("NAME:AC",
"MaxPass:=",
_
10, "MinPass:=", 1, "MinConvPass:=", 1,

Design Object Script Commands 8-66


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"PerError:=", 1, "PerRefine:=", 30))

Undo [Design]
Cancels the last design-level command.

UI Access Edit>Undo

Name Type Description


Parameters
None

Return Value None

Python Syn- Undo()


tax

Python oDesign.Undo()
Example

VB Syntax Undo
VB Example oDesign.Undo

ValidateDesign
Use: Returns the validation information to a named file.
Command: Validation Check, which validates the active design in the project.
Syntax: ValidateDesign(r"filePath", <Whether to clear the file, True or False>)
Return Value: 0 means the validation failed. 1 means passed.
Type: <string>

Python ValidateDesign(r"<filePath>", True)


Syntax

oProject = oDesktop.GetActiveProject()
Python
oDesign = oProject.GetActiveDesign()
Exampl-
e oDesign.ValidateDesign(r"C:/Users/agao/Desktop/f1.tmp",
True)

Design Object Script Commands 8-67


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ValidateLink

Note:
This command is for internal ANSYS use only.

Python Syn- ValidateLink()


tax

Python oDesign.ValidateLink()
Example

Design Object Script Commands 8-68


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

9 - Model Setup Script Commands


Model Setup Script Commands should be executed by:
Set oModule = oDesign.GetModule("ModelSetup")
These commands are as follows:
AssignArray
DeleteArray
EditArray

Assign Array
Use:Create an array based on a unit cell model.
Command:HFSS>Model>Create Array
Syntax:AssignArray <arrayParameters>
Return Value:None
Parameters:Array(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:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign

Model Setup Script Commands 9-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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",
"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:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign

Model Setup Script Commands 9-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("forcreatearraycube")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("ModelSetup")
oModule.DeleteArray

EditArray
To edit properties of an existing array.
Command: Properties
Syntax: EditArray <arrayParameters>
Return Value: None
Parameters: Array(NAME:<string>",
"NAME:A",
"Name:=", "<string>",
"UseAirObjects:=", <boolean>,
"RowMasterBnd:=", "Master<n>",
"ColumnMasterBnd:=", "Master<n>",
"RowDimension:=", <value>,
"ColumnDimension:=", <value>,
"PostProcessRow:=", <value>,
"PostProcessCol:=", <value>,
"Active:=", "All" | [<arraycoords>] |"None" )
Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject

Model Setup Script Commands 9-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("PatchHexLattice")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
Set oModule = oDesign.GetModule("ModelSetup")
oModule.EditArray Array("NAME:A", "Name:=", "A", "UseAirObjects:=",
true, _
"RowMasterBnd:=", "PhasedArray1_1_Master1", "ColumnMasterBnd:=",
"PhasedArray1_1_Master2", _
"RowDimension:=", 4, "ColumnDimension:=", 3, _
"Visible:=", true, "RenderType:=", 0, "Padding:=", 0,
Array("NAME:Cells", _
"PhasedArray1_1:=", Array("[1,1], [1,2], [1,3], [3,2]")), _
Array("NAME:Rotation"), "Active:=", "[1,1], [1,2], [1,3], [3,2]", _
Array("NAME:PostProcessingCells", "PhasedArray1_1:=", Array("3",
"2")), _
"Colors:=", Array("PhasedArray1_1", "(128 128 255)"))

Model Setup Script Commands 9-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

10 - 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:

l NonModel
l Wireframe

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


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>

3D Modeler Editor Script Commands 10-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:Selections",
"Selections:=", <string>)
Selections
Comma-separated list of parts on which to perform the operation.
Example: "Selections:=", "Rect1, Rect2"
The topics for this section include:
Draw Menu Commands
Edit Menu Commands
Modeler Menu Commands
Other oEditor Commands

Draw Menu Commands


Create3D Component
CreateBondWire
CreateBox
CreateCircle
CreateCone
CreateCutplane
CreateCylinder
CreateEllipse
CreateEquationCurve
CreateEquationSurface
CreateHelix
CreatePoint
CreatePolyline
CreateRectangle
CreateRegion
CreateRegularPolyhedron
CreateRegularPolygon
CreateSphere
CreateSpiral

3D Modeler Editor Script Commands 10-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

CreateTorus
CreateUserDefinedModel
CreateUserDefinedPart
Edit3DComponent
EditNativeComponentDefinition
EditPolyline
Get3DComponentParameters
Get3DComponentDefinitionNames
Get3DComponentInstanceNames
Get3DComponentMaterialNames
Get3DComponentMaterialProperties
Insert3DComponent
InsertNativeComponent
InsertPolylineSegment
SweepAlongPath
SweepAlongVector
SweepAroundAxis
SweepFacesAlongNormal
SweepFacesAlongNormalWithAttributes
UpdateComponentDefinition
Create3D Component
Use: Create a 3D component
Command: None
Syntax: Create3DComponent <Geometry Data>, <Design Data>, <File Name>, <Image File>
Return Value: None
Parameters: < Geometry Data>
Geometry data
< Design Data>
Design data
< File Name>

3D Modeler Editor Script Commands 10-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

File name of 3D component


< Image File>
File name of 3D component image
VB Example:
oEditor.Create3DComponent Array("NAME:GeometryData",
"ComponentName:=", "Connector",
"Owner:=", "", "Email:=", "", "Company:=", "",
"Version:=", "1.0", "Date:=", "11:41:01 AM Aug 28, 2014",
"Notes:=", "", "HasLabel:=", false,
"IncludedParts:=", Array( "Box1", "Cylinder1", "Cone1"),
"IncludedCS:=", Array("RelativeCS1"),
"ReferenceCS:=", "Global",
"IncludedParameters:=", Array("htcone", "lr", "htcyl", "zs",
"radcyl", "xs", "$rp", "$con"),
"ParameterDescription:=", Array()),
Array("NAME:DesignData", "Boundaries:=",
Array( "PerfE1", "FiniteCond1"),
"Excitations:=", Array("1"),
"MeshOperations:=", Array()),
"C:/tmp/Connector.a3dcomp",
Array("NAME:ImageFile", "ImageFile:=", "")

Python Create3DComponent (<Geometry Data>, <Design Data>, <File Name>, <Image


Syntax File>)
oEditor.Create3DComponent Array(["NAME:GeometryData",

"ComponentName:=", "Connector",
"Owner:=", "", "Email:=", "", "Company:=", "",
"Version:=", "1.0", "Date:=", "11:41:01 AM Aug 28, 2014",
"Notes:=", "", "HasLabel:=", false,
"IncludedParts:=", Array( "Box1", "Cylinder1", "Cone1"),
"IncludedCS:=", Array("RelativeCS1"),
Python "ReferenceCS:=", "Global",
Exampl- "IncludedParameters:=", Array("htcone", "lr", "htcyl",
e "zs",
"radcyl", "xs", "$rp", "$con"),
"ParameterDescription:=", Array()),
Array("NAME:DesignData", "Boundaries:=",
Array( "PerfE1", "FiniteCond1"),
"Excitations:=", Array("1"),
"MeshOperations:=", Array()),
"C:/tmp/Connector.a3dcomp",
Array("NAME:ImageFile", "ImageFile:=", "" ])

3D Modeler Editor Script Commands 10-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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
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.

3D Modeler Editor Script Commands 10-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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>)
VB 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, _
"XComponent:=", "1mm", "YComponent:=", "1mm", "ZComponent:=", _
"0mm", "NumClones:=", "2"), _
Array("NAME:Options", "DuplicateBoundaries:=", true)

Python Syn- CreateBox (  [ <BoxParameters>], [<BoxAttributes>])

3D Modeler Editor Script Commands 10-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

tax

oEditor.CreateBox(
[
"NAME:BoxParameters",
"XPosition:=" , "0.4mm",
"YPosition:=" , "-1.4mm",
"ZPosition:=" , "0mm",
"XSize:=" , "0.4mm",
"YSize:=" , "0.4mm",
"ZSize:=" , "0.4mm"
],
[

Python "NAME:Attributes",
Example "Name:=" , "Box2",
"Flags:=" , "",
"Color:=" , "(143 175 143)",
"Transparency:=" , 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"vacuum\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , True,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False
])

CreateCircle
Use: Creates a circle primitive.
Command: Draw>Circle
Syntax: CreateCircle <CircleParametersArray>, <AttributesArray>
Return Value: The name of the newly created object.

3D Modeler Editor Script Commands 10-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.

Python Syn- CreateCircle (<CircleParameters>, <CircleAttributes>)


tax

oEditor.CreateCircle(
[
"NAME:CircleParameters",
"IsCovered:=" , True,
"XCenter:=" , "0mm",
"YCenter:=" , "0mm",

Python "ZCenter:=" , "0mm",


Example "Radius:=" , "0.565685424949238mm",
"WhichAxis:=" , "Z",
"NumSegments:=" , "0"
],
[
"NAME:Attributes",
"Name:=" , "Circle1",

3D Modeler Editor Script Commands 10-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Flags:=" , "",
"Color:=" , "(143 175 143)",
"Transparency:=" , 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"copper\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , False,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False
])

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>,
"BottomRadius:=", <value>,
"TopRadius:=", <value>)
WhichAxis
Axis of the cone. Possible values are: "X", "Y", "Z"
Example: "WhichAxis:=", "Z"

3D Modeler Editor Script Commands 10-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python CreateCone (<ConeParameters>], [<ConeAttributes>)


Syntax

oEditor.CreateCone(
[
"NAME:ConeParameters",
"XCenter:=" , "0mm",
"YCenter:=" , "0mm",
"ZCenter:=" , "0mm",
"WhichAxis:=" , "Z",
"Height:=" , "1mm",
"BottomRadius:=" , "0.282842712474619mm",
"TopRadius:=" , "0.565685424949238mm"
],
[
Python
"NAME:Attributes",
Example
"Name:=" , "Cone1",
"Flags:=" , "",
"Color:=" , "(143 175 143)",
"Transparency:=" , 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"copper\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , False,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False
])

CreateCutplane
Use: Creates a cutplane. Only the name and color attributes from <AttributesArray> are sup-
ported.
Command: Draw>Plane

3D Modeler Editor Script Commands 10-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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>,
<AttributesArray>
Return Value: The name of the newly created object.
Parameters: <CylinderParametersArray>
Array("NAME:CylinderParameters",
"XCenter:=", <value>,
"YCenter:=", <value>,
"ZCenter:=", <value>,
"Radius:=", <value>,
"Height:=", <value>,
"WhichAxis:=", <string>
"NumSides:=", "<integer>")
WhichAxis
Axis of the cylinder. Possible values are: "X", "Y", "Z"
Example: "WhichAxis:=", "Z"

3D Modeler Editor Script Commands 10-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- CreateCylinder (<CylinderParameters>, <CylinderAttributes>)


tax

oEditor.CreateCylinder(
[
"NAME:CylinderParameters",
"XCenter:=" , "0mm",
"YCenter:=" , "-0.2mm",
"ZCenter:=" , "0mm",
"Radius:=" , "0.14142135623731mm",
"Height:=" , "0.3mm",
"WhichAxis:=" , "Z",
"NumSides:=" , "0"
],
[
Python
"NAME:Attributes",
Example
"Name:=" , "Cylinder1",
"Flags:=" , "",
"Color:=" , "(143 175 143)",
"Transparency:=" , 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"copper\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , False,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False
])

CreateEllipse
Use: Creates an ellipse primitive.
Command: Draw>Ellipse

3D Modeler Editor Script Commands 10-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.

Python Syn- CreateEllipse (<EllipseParameters>, <EllipseAttributes>])


tax

oEditor.CreateEllipse(
[
"NAME:EllipseParameters",
"IsCovered:=" , True,
"XCenter:=" , "0mm",
"YCenter:=" , "0mm",

Python "ZCenter:=" , "0mm",


Example "MajRadius:=" , "0.2mm",
"Ratio:=" , "2",
"WhichAxis:=" , "Z",
"NumSegments:=" , "0"
],
[
"NAME:Attributes",

3D Modeler Editor Script Commands 10-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Name:=" , "Ellipse1",
"Flags:=" , "",
"Color:=" , "(143 175 143)",
"Transparency:=" , 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"copper\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , False,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False
])

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",
"XtFunction:=", "<value>",
"YtFunction:=", "<value>",
"ZtFunction:=", "<value>",
"tStart:=", "<value>",
"tEnd:=", "<value>",
"NumOfPointsOnCurve:=", "<value>",
"Version:=", <ID>),
Array("NAME:Attributes",
"Name:=", "<textn>",
"Flags:=", "",
"Color:=", "(<int> <int> <int>)",

3D Modeler Editor Script Commands 10-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Transparency:=", <value>,
"PartCoordinateSystem:=", "<id>",
"UDMId:=", "",
"MaterialValue:=", "" & Chr(34)
& "vacuum"
& Chr(34) & "",
"SolveInside:=", <boolean>)

Python Syn- CreatEquationCurve (<parameters>, <attributes> )


tax

oEditor.CreateEquationCurve(
[
"NAME:EquationBasedCurveParameters",
"XtFunction:=" , "sin(_t)",
"YtFunction:=" , "_t",
"ZtFunction:=" , "_t",
"tStart:=" , "0",
"tEnd:=" , "6",
"NumOfPointsOnCurve:=" , "10",

Python "Version:=" , 1,
Example [
"NAME:PolylineXSection",
"XSectionType:=" , "None",
"XSectionOrient:=" , "Auto",
"XSectionWidth:=" , "0",
"XSectionTopWidth:=" , "0",
"XSectionHeight:=" , "0",
"XSectionNumSegments:=" , "0",
"XSectionBendType:=" , "Corner"]
],

3D Modeler Editor Script Commands 10-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

[
"NAME:Attributes",
"Name:=" , "EquationCurve1",
"Flags:=" , "",
"Color:=" , "(143 175 143)",
"Transparency:=" , 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"copper\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , False,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False
])

CreateEquationSurface
Use: Create an equation based surface. For descriptions of the parameters, see the online help for
the Draw>Equation Based Surface command. The parameters here correspond to the fields in
the dialog.

3D Modeler Editor Script Commands 10-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

The attributes correspond to the object attributes in the Properties dialog.

Command: Draw>Create Equation Based Surface


Syntax: CreateEquationSurface Array <parameters> Array <attributes>
Return Value:
Parameters:
Array("NAME:EquationBasedSurfaceParameters",
"XuvFunction:=", "<equation containing Function, Operators and/or
quantities _u, _v, or PI>",
"YuvFunction:=", "<equation containing Function, Operators and/or
quantities _u, _v, or PI>",
"ZuvFunction:=", "<equation containing Function, Operators and/or
quantities _u, _v, or PI>",
"uStart:=", "<start value for _u>",
"uEnd:=", "<end value for _u",
"vStart:=", "<start value for _u>",
"vEnd:=", "<end value for _v",
"Version:=", 1),
Array("NAME:Attributes", "Name:=", "EquationSurface1",
"Flags:=", "",
"Color:=", "(132 132 193)",
"Transparency:=", 0,
"PartCoordinateSystem:=", "Global",

3D Modeler Editor Script Commands 10-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"UDMId:=", "",
"MaterialValue:=", ""
& Chr(34)
& "vacuum"
& Chr(34)
& "", "SolveInside:=", true)
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project74")
Set oDesign = oProject.SetActiveDesign("HFSS1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.CreateEquationSurface Array("NAME:Equa-
tionBasedSurfaceParameters", "XuvFunction:=", _
"_u", "YuvFunction:=", "_v", "ZuvFunction:=", "sin(_u)+cos(_v)",
"uStart:=", "1", "uEnd:=", _
"10", "vStart:=", "1", "vEnd:=", "10", "Version:=", 1), Array
("NAME:Attributes", "Name:=", _
"EquationSurface1", "Flags:=", "", "Color:=", "(143 175 143)",
"Transparency:=", _
0, "PartCoordinateSystem:=", "Global", "UDMId:=", "", "Mater-
ialValue:=", _
"" & Chr(34) & "vacuum" & Chr(34) & "", "SurfaceMaterialValue:=", ""
& Chr(34) & "" & Chr(34) & "", "SolveInside:=", _

3D Modeler Editor Script Commands 10-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

true, "IsMaterialEditable:=", true, "UseMaterialAppearance:=",


false, "IsLightweight:=", _
false)

Python Syn- CreateEquationSurface (<parameters>, <attributes> )


tax

oEditor.CreateEquationSurface(
[
"NAME:EquationBasedSurfaceParameters",
"XuvFunction:=" , "_u",
"YuvFunction:=" , "_v",
"ZuvFunction:=" , "sin(_u)+cos(_v)",
"uStart:=" , "1",
"uEnd:=" , "10",
"vStart:=" , "1",
"vEnd:=" , "10",
"Version:=" , 1
],
Python
[
Example
"NAME:Attributes",
"Name:=" , "EquationSurface1",
"Flags:=" , "",
"Color:=" , "(143 175 143)",
"Transparency:=" , 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"copper\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , False,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False

3D Modeler Editor Script Commands 10-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

])

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>,
"Thread:=", <value>,
"NumThread:=", <value>,
"RightHand:=", <bool>)
CreatePoint
Creates a point. Only the name and color attributes from <AttributesArray> are supported.

UI Access Draw > Point

Name Type Description


PointParametersArray Array Array("NAME:PointPara-
Parameters meters",
"PointX:=", <value>,

3D Modeler Editor Script Commands 10-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"PointY:=", <value>,
"PointZ:=", <value>)
AttributesArray Array Array("NAME:At-
tributes",
"Name:=", <value>,
"Color:=", <R G B>)

Return None
Value

Python Syn- CreatePoint(<PointParametersArray>, <AttributesArray>)


tax

oEditor.CreatePoint(
[
"NAME:PointParameters",
"PointX:=" , "0.2mm",
"PointY:=" , "-0.2mm",
Python "PointZ:=" , "0mm"
Example ],
[
"NAME:Attributes",
"Name:=" , "Point1",
"Color:=" , "(143 175 143)"
])

VB Syntax CreatePoint <PointParametersArray>, <AttributesArray>


oEditor.CreatePoint
Array("NAME:PointParameters",
"PointX:=" , "0.2mm",
"PointY:=" , "-0.2mm",
VB Example
"PointZ:=" , "0mm") ,
Array("NAME:Attributes",
"Name:=" , "Point1",
"Color:=" , "(143 175 143)")

3D Modeler Editor Script Commands 10-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

CreateUserDefinedPart
Use: Create User defined part.
Command: Draw>UserDefinedPrimitive
Syntax: CreateUserDefinedPart <UserDefinedParametersArray>, <AttributesArray>
Return Value: None
Parameters: <UserDefinedParametersArray>
Array("NAME:UserDefinedPrimitiveParameters",
"CoordinateSystemID:=", <value>,
"DllName:=", <string>,
"Library:=", <string>,
Array("NAME:ParamVector",
Array("NAME:Pair", "Name:=", <string>, "Value:=", <value>)…)

Python CreateUserDefinedPart ([ <UserDefinedParametersArray>, <AttributesArray>])


Syntax

oEditor.CreateUserDefinedPart [
(
Array("NAME:UserDefinedPrimitiveParameters",
"CoordinateSystemID:=", -1,
"DllName:=", "Examples/RectangularSpiral",
"NoOfParameters:=", 6, "Library:=", "syslib",

Array("NAME:ParamVector",

Array("NAME:Pair", "Name:=", "Xpos", "Value:=", "0mm"),

Python Array("NAME:Pair","Name:=", "Ypos", "Value:=", "0mm"),


Example
Array("NAME:Pair", "Name:=", "TurnSep", "Value:=", "5mm"),

Array("NAME:Pair", "Name:=", "Turns", "Value:=", "2"),

Array("NAME:Pair", "Name:=", "Width", "Value:=", "2mm"),

Array("NAME:Pair", "Name:=", "Height", "Value:=", "2mm"))),

Array("NAME:Attributes", "Name:=",
"RectangularSpiral1",
"Flags:=", "",

3D Modeler Editor Script Commands 10-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Color:=", "(132 132 193)",


"Transparency:=", 0,
"PartCoordinateSystem:=", "Global",
"MaterialName:=", "copper",
"SolveInside:=", _
False)
)]

CreatePolyline
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",
"X:=", <value>,
"Y:=", <value>,
"Z:=", <value>))

<PolylineSegmentsArray>

3D Modeler Editor Script Commands 10-23


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:PolylineSegments",
<OneSegmentArray>, <OneSegmentArray>, ...)

<OneSegmentArray>
Array("NAME:PLSegment",
"SegmentType:=", <string>,
"StartIndex:=", <value>,
"NoOfPoints:=", <value>)

SegmentType
Can be "Line", "Arc", "Spline", or "AngularArc"

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

oEditor.CreatePolyline Array("NAME:PolylineParameters",
"IsPolylineCovered:=", true,
"IsPolylineClosed:=", false,
Array("NAME:PolylinePoints",

3D Modeler Editor Script Commands 10-24


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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:=", "", "Col-
or:=", "(132 132 193)",
"Transparency:=", 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=", "", "MaterialValue:=", ""
& Chr(34) & "vacuum" & Chr(34) & "", "SolveInside:=", true)

Python Syn- CreatePolyline (<PolylineParameters>, <PolylineAttributes>)


tax

oEditor.CreatePolyline(
Python
[
Example
"NAME:PolylineParameters",

3D Modeler Editor Script Commands 10-25


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"IsPolylineCovered:=" , True,
"IsPolylineClosed:=" , False,
[
"NAME:PolylinePoints",
[
"NAME:PLPoint",
"X:=" , "0.4mm",
"Y:=" , "-0.6mm",
"Z:=" , "0mm"
],
[
"NAME:PLPoint",
"X:=" , "0mm",
"Y:=" , "-0.4mm",
"Z:=" , "0mm"
]
],
[
"NAME:PolylineSegments",
[
"NAME:PLSegment",
"SegmentType:=" , "Line",
"StartIndex:=" , 0,
"NoOfPoints:=" , 2
]
],
[
"NAME:PolylineXSection",
"XSectionType:=" , "None",
"XSectionOrient:=" , "Auto",

3D Modeler Editor Script Commands 10-26


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"XSectionWidth:=" , "0mm",
"XSectionTopWidth:=" , "0mm",
"XSectionHeight:=" , "0mm",
"XSectionNumSegments:=" , "0",
"XSectionBendType:=" , "Corner"
]
],
[
"NAME:Attributes",
"Name:=" , "Polyline1",
"Flags:=" , "",
"Color:=" , "(143 175 143)",
"Transparency:=" , 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"copper\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , False,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False
])

CreateRectangle
Use: Creates a rectangle primitive.
Command: Draw>Rectangle
Syntax: CreateRectangle <RectangleParametersArray>,
<AttributesArray>
Return Value: The name of the newly created object.
Parameters: <RectangleParametersArray>
Array("NAME:RectangleParameters",
"XStart:=", <value>,

3D Modeler Editor Script Commands 10-27


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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.

Python Syn- CreateRectangle (<RectangleParameters>, <RectangleAttributes>)


tax

oEditor.CreateRectangle(
[
"NAME:RectangleParameters",
"IsCovered:=" , True,
"XStart:=" , "-0.2mm",
"YStart:=" , "-0.4mm",
"ZStart:=" , "0mm",
"Width:=" , "0.6mm",

Python "Height:=" , "0.6mm",


Example "WhichAxis:=" , "Z"
],
[
"NAME:Attributes",
"Name:=" , "Rectangle1",
"Flags:=" , "",
"Color:=" , "(143 175 143)",
"Transparency:=" , 0,
"PartCoordinateSystem:=", "Global",

3D Modeler Editor Script Commands 10-28


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"UDMId:=" , "",
"MaterialValue:=" , "\"copper\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , False,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False
])

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
Can be one of:
"Percentage Offset",

3D Modeler Editor Script Commands 10-29


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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>)

VB 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, _

3D Modeler Editor Script Commands 10-30


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"PartCoordinateSystem:=", "Global", _
"MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", _
"SolveInside:=", true)

For Q3D Extractor the CreateRegion command details are as follows:


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", _
"CoordinateSystemID:=", <ID_number>_
"+XPadding:=", "<X_value>", _
"-XPadding:=", "<-X_value>", _
"+YPadding:=", "<Y_value>",
"-YPadding:=", "<-Y_value>", _
"+ZPadding:=", "<Z_value>", _
"-ZPadding:=", "<-Z_value>")
<RegionAttributes>
Array("NAME:Attributes",
"Name:=", "Region", _
"Flags:=", "Wireframe<# or >", _
"Color:=", "(<red_int> <green_int> <blue_int>)", _
"Transparency:=", <real>, _
"PartCoordinateSystem:=", "<ID>", _
"MaterialName:=", "<MaterialName>", _
"SolveInside:=", <Boolean>)
Set oEditor = oDesign.SetActiveEditor("3D Modeler") oEd-
itor.CreateRegion Array("NAME:RegionParameters", _

3D Modeler Editor Script Commands 10-31


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"CoordinateSystemID:=", -1, _ "+XPadding:=", "0", "-XPadding:=",


"0", _ "+YPadding:=", "0", "-YPadding:=", "0", _ "+ZPadding:=", "0",
"-ZPadding:=", "0"), _ Array("NAME:Attributes", "Name:=", "Region",
_ "Flags:=", "Wireframe#", _ "Color:=", "(255 0 0)", _ "Trans-
parency:=", 0.400000005960464, _ "PartCoordinateSystem:=", "Global",
_ "MaterialName:=", "vacuum", _ "SolveInside:=", true)

Python CreateRegion ([ <RegionParameters>, <RegionAttributes> ])


Syntax

oEditor.CreateRegion(
[
("NAME:RegionParameters",
"+XPaddingType:=", "Absolute Offset",
"+XPadding:=", "1um",
"-XPaddingType:=", "Absolute Offset",
"-XPadding:=", "1um",
"+YPaddingType:=", "Absolute Offset",
"+YPadding:=", "1um",
"-YPaddingType:=", "Absolute Offset",
"-YPadding:=", "1um",
Python
Example "+ZPaddingType:=", "Absolute Offset",
"+ZPadding:=", "1um",
"-ZPaddingType:=", "Absolute Offset",
"-ZPadding:=", "1um"),

("NAME:Attributes", "Name:=",
"Region", "Flags:=", "Wireframe#",
"Color:=", "(255 0 0)",
"Transparency:=", 0,
"PartCoordinateSystem:=", "Global",
"MaterialValue:=", "" & Chr(34) & "vacuum"
& Chr(34) & "",

3D Modeler Editor Script Commands 10-32


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"SolveInside:=", True)
)]

CreateRegularPolyhedron
Use: Creates a regular polyhedron primitive.
Command: Draw>Regular Polyhedron
Syntax: CreateRegularPolyhedron <PolyhedronParametersArray>,
<AttributesArray>
Return Value: The name of the newly created object.
Parameters: <PolyhedronParametersArray>
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

3D Modeler Editor Script Commands 10-33


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax: CreateRegularPolygon <PolygonParametersArray>,


<AttributesArray>
Return Value: The name of the newly created object.
Parameters: <PolygonParametersArray>
Array("NAME:RegularPolygonParameters",
"XCenter:=",<value>,
"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.

Python Syn- CreateRegularPolygon (<PolygonParameters>, <PolygonAttributes>)


tax

oEditor.CreateRegularPolygon(
[
"NAME:RegularPolygonParameters",

Python "IsCovered:=" , True,


Example "XCenter:=" , "0.6mm",
"YCenter:=" , "0.2mm",
"ZCenter:=" , "0mm",
"XStart:=" , "0.4mm",

3D Modeler Editor Script Commands 10-34


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"YStart:=" , "0.8mm",
"ZStart:=" , "0mm",
"NumSides:=" , "12",
"WhichAxis:=" , "Z"
],
[
"NAME:Attributes",
"Name:=" , "Polygon1",
"Flags:=" , "",
"Color:=" , "(143 175 143)",
"Transparency:=" , 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"copper\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , False,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False
])

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>)

3D Modeler Editor Script Commands 10-35


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- CreateSphere (<SphereParameters>, <SphereAttributes>)


tax

oEditor.CreateSphere(
[
"NAME:SphereParameters",
"XCenter:=" , "-0.1mm",
"YCenter:=" , "-0.4mm",
"ZCenter:=" , "0mm",
"Radius:=" , "0.223606797749979mm"
],
[
"NAME:Attributes",

Python "Name:=" , "Sphere1",


Example "Flags:=" , "",
"Color:=" , "(143 175 143)",
"Transparency:=" , 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"copper\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , False,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False
])

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>

3D Modeler Editor Script Commands 10-36


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:Selections",
"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

3D Modeler Editor Script Commands 10-37


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Axis of the torus. Possible values are: "X", "Y", "Z"


Example: "WhichAxis:=", "Z"

Python Syn- CreateTorus (<TorusParameters>, <TorusAttributes>)


tax

oEditor.CreateTorus(
[
"NAME:TorusParameters",
"XCenter:=" , "0mm",
"YCenter:=" , "-0.4mm",
"ZCenter:=" , "0mm",
"MajorRadius:=" , "0.182514076993644mm",
"MinorRadius:=" , "0.0410927207563347mm",
"WhichAxis:=" , "Z"
],
[

Python "NAME:Attributes",
Example "Name:=" , "Torus1",
"Flags:=" , "",
"Color:=" , "(143 175 143)",
"Transparency:=" , 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"copper\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , False,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False
])

3D Modeler Editor Script Commands 10-38


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

CreateUserDefinedModel
Command: Creates a SpaceClaimLink. Spaceclaim file path has to be included as "Geo-
metryFilePath" definition. Another definition named "IsSpaceClaimLinkUDM" needs to be there
with value equal to 1.
Syntax: UserDefinedModel <UserDefinedModelParameters>
Return Value: None
Parameters: <UserDefinedModelParameters>
Array("NAME:UserDefinedModelParameters
"DllName:=", "<modelName>", "Version:=", "2.0",
"ConnectionID:=", "", "Library:=", "<installLib>",
Array("NAME:Definition", Array("NAME:UDMParam",
"Name:=", "GeometryFilePath", "Value:=", "" & Chr(34) &
"<SpaceClaimFilePath>" & Chr(34) & "" & "",
"DataType:=", "String", "PropType2:=", 0,
"PropFlag2:=", 1),
Array("NAME:UDMParam", "Name:=", "IsSpaceClaimLinkUDM",
"Value:=", "1", "DataType:=", "Int", "PropType2:=", 5,
"PropFlag2:=", 8))
VB Example:
oEditor.CreateUserDefinedModel Array("NAME:User-
DefinedModelParameters",
"DllName:=", "SCIntegUDM", "Version:=", "2.0",
"ConnectionID:=", "", "Library:=", "installLib",
Array("NAME:Definition", Array("NAME:UDMParam",
"Name:=", "GeometryFilePath", "Value:=", "" & Chr(34) &
"G:\box.scdoc" & Chr(34) & "" & "",
"DataType:=", "String", "PropType2:=", 0, "PropFlag2:=", 1), Array
("NAME:UDMParam", "Name:=", "IsSpaceClaimLinkUDM",
"Value:=", "1", "DataType:=", "Int", "PropType2:=", 5,
"PropFlag2:=", 8)),
Array("NAME:Options", Array("NAME:UDMParam",
"Name:=", "Solid Bodies", "Value:=", "1",
"DataType:=", "Int", "PropType2:=", 5, "PropFlag2:=", 0), Array
("NAME:UDMParam", "Name:=", "Surface Bodies", "Value:=", "1",
"DataType:=", "Int", "PropType2:=", 5, "PropFlag2:=", 0), Array
("NAME:UDMParam", "Name:=", "Line Bodies", "Value:=", "1",
"DataType:=", "Int", "PropType2:=", 5, "PropFlag2:=", 8), Array
("NAME:UDMParam", "Name:=", "Parameters", "Value:=", "1",
"DataType:=", "Int", "PropType2:=", 5, "PropFlag2:=", 0), Array

3D Modeler Editor Script Commands 10-39


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

("NAME:UDMParam", "Name:=", "Parameter Key",


"Value:=", "" & Chr(34) & "" & Chr(34) & "", "DataType:=", "String",
"PropType2:=", 0, "PropFlag2:=", 0),
Array("NAME:UDMParam", "Name:=", "Named Selections", "Value:=", "1",
"DataType:=", "Int", "PropType2:=", 5, "PropFlag2:=", 8),
Array("NAME:UDMParam", "Name:=", "Rendering Attributes",
"Value:=", "1", "DataType:=", "Int", "PropType2:=", 5,
"PropFlag2:=", 0),
Array("NAME:UDMParam", "Name:=", "Material Assignment",
"Value:=", "1", "DataType:=", "Int", "PropType2:=", 5,
"PropFlag2:=", 0),
Array("NAME:UDMParam", "Name:=", "Explode Multi-Body Parts",
"Value:=", "1", "DataType:=", "Int", "PropType2:=", 5,
"PropFlag2:=", 8),
Array("NAME:UDMParam", "Name:=", "Smart CAD Update", "Value:=", "1",
"DataType:=", "Int", "PropType2:=", 5, "PropFlag2:=", 8)), Array
("NAME:GeometryParams"), Array("NAME:MaterialParams"), Array
("NAME:DesignParams"))

Pytho- UserDefinedModel ([ <UserDefinedModelParameters> ])


n Syn-
tax

oEditor.CreateUserDefinedModel [(
{Array("NAME:UserDefinedModelParameters",

"DllName:=", "SCIntegUDM", "Version:=", "2.0",


"ConnectionID:=", "", "Library:=", "installLib",
Array("NAME:Definition", Array("NAME:UDMParam",
"Name:=", "GeometryFilePath", "Value:=", "" & Chr(34) &
"G:\box.scdoc" & Chr(34) & "" & "",
Pytho-
"DataType:=", "String", "PropType2:=", 0, "PropFlag2:=", 1),
n Array("NAME:UDMParam",
Exam- "Name:=", "IsSpaceClaimLinkUDM",
ple
"Value:=", "1", "DataType:=", "Int", "PropType2:=", 5,
"PropFlag2:=", 8)),
Array("NAME:Options", Array("NAME:UDMParam",
"Name:=", "Solid Bodies", "Value:=", "1",
"DataType:=", "Int", "PropType2:=", 5, "PropFlag2:=", 0),
Array("NAME:UDMParam",
"Name:=", "Surface Bodies", "Value:=", "1", "DataType:=",
"Int", "PropType2:=",
5, "PropFlag2:=", 0),

3D Modeler Editor Script Commands 10-40


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:UDMParam", "Name:=", "Line Bodies",


"Value:=", "1", "DataType:=", "Int", "PropType2:=", 5,
"PropFlag2:=",
8),
Array("NAME:UDMParam", "Name:=", "Parameters", "Value:=",
"1",
"DataType:=", "Int", "PropType2:=", 5, "PropFlag2:=", 0),
Array("NAME:UDMParam",
"Name:=", "Parameter Key",
"Value:=", "" & Chr(34) & "" & Chr(34) & "", "DataType:=",
"String", "PropType2:=", 0, "PropFlag2:=", 0),
Array("NAME:UDMParam", "Name:=", "Named Selections",
"Value:=", "1",
"DataType:=", "Int", "PropType2:=", 5, "PropFlag2:=", 8),
Array("NAME:UDMParam", "Name:=", "Rendering Attributes",
"Value:=", "1", "DataType:=", "Int", "PropType2:=", 5,
"PropFlag2:=", 0),
Array("NAME:UDMParam", "Name:=", "Material Assignment",
"Value:=", "1", "DataType:=", "Int", "PropType2:=", 5,
"PropFlag2:=", 0),
Array("NAME:UDMParam", "Name:=", "Explode Multi-Body Parts",
"Value:=",
"1", "DataType:=", "Int", "PropType2:=", 5,
"PropFlag2:=", 8),
Array("NAME:UDMParam", "Name:=", "Smart CAD Update",
"Value:=", "1",
"DataType:=", "Int", "PropType2:=", 5, "PropFlag2:=", 8)),
Array("NAME:GeometryParams"),
Array("NAME:MaterialParams"), Array("NAME:DesignParams")
])

CreateUserDefinedPart
Use: Create User defined part.
Command: Draw>UserDefinedPrimitive
Syntax: CreateUserDefinedPart <UserDefinedParametersArray>, <AttributesArray>
Return Value: None
Parameters: <UserDefinedParametersArray>
Array("NAME:UserDefinedPrimitiveParameters",

3D Modeler Editor Script Commands 10-41


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"CoordinateSystemID:=", <value>,
"DllName:=", <string>,
"Library:=", <string>,
Array("NAME:ParamVector",
Array("NAME:Pair", "Name:=", <string>, "Value:=", <value>)…)

Python CreateUserDefinedPart ([ <UserDefinedParametersArray>, <AttributesArray>])


Syntax

oEditor.CreateUserDefinedPart [
(
Array("NAME:UserDefinedPrimitiveParameters",
"CoordinateSystemID:=", -1,
"DllName:=", "Examples/RectangularSpiral",
"NoOfParameters:=", 6, "Library:=", "syslib",

Array("NAME:ParamVector",

Array("NAME:Pair", "Name:=", "Xpos", "Value:=", "0mm"),

Array("NAME:Pair","Name:=", "Ypos", "Value:=", "0mm"),

Array("NAME:Pair", "Name:=", "TurnSep", "Value:=", "5mm"),

Array("NAME:Pair", "Name:=", "Turns", "Value:=", "2"),


Python
Example Array("NAME:Pair", "Name:=", "Width", "Value:=", "2mm"),

Array("NAME:Pair", "Name:=", "Height", "Value:=", "2mm"))),

Array("NAME:Attributes", "Name:=",
"RectangularSpiral1",
"Flags:=", "",
"Color:=", "(132 132 193)",
"Transparency:=", 0,
"PartCoordinateSystem:=", "Global",
"MaterialName:=", "copper",
"SolveInside:=", _
False)
)]

3D Modeler Editor Script Commands 10-42


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Edit3DComponent
Use:Edit 3D Component
Command:None
Syntax:Edit3DComponent <Component Name>
Return Value:None
Parameters:<Component Name>
Name of the 3D component
<Data>
Data of the 3D component
VB Example:
oEditor.Edit3DComponent "Connector1",
Array("NAME:EditComponentParametersData",
"NewComponentName:=", " Connector2",
"GeometryParameters:=", "",
"MaterialParameters:=", "",
"DesignParameters:=", "",
Array("NAME:Component Meshing", "MeshAssembly:=", false), Array("NAME:Ex-
citations", "Suppressed:=", Array()))

Python Syn- Edit3DComponent (<Component Name>)


tax

oEditor.Edit3DComponent(
[
"Connector1",
("NAME:EditComponentParametersData",

"NewComponentName:=",
Python
Example " Connector2",
"GeometryParameters:=", "",

"MaterialParameters:=", "",

"DesignParameters:=", "",
("NAME:Component Meshing",

3D Modeler Editor Script Commands 10-43


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"MeshAssembly:=", false),
("NAME:Excitations",
"Suppressed:=", Array()))
])

EditNativeComponentDefinition
Edit Link from HFSS Modal antenna design to SBR+ design as a component.
Command: Edit Definition
Syntax: EditNativeComponentDefinition <LinkParameters>
Return Value: None
Parameters: <LinkParametersData>
Data of the 3D component
VB Example:
oEditor.EditNativeComponentDefinition Array("NAME:EditNat-
iveComponentData",
"TargetCS:=", "Global",
"UniqueDefinitionIdentifier:=", "cf3021fd-fca4-4428-a045-fed-
c60b9d040",
"OriginFilePath:=", "",
"IsLocal:=", false,
"ChecksumString:=", "",
"ChecksumHistory:=", Array(),
"VersionHistory:=", Array(),
Array("NAME:NativeComponentDefinitionProvider", "Type:=", "Linked
Antenna", _
"Unit:=", "mm", "Project:=", "HornElliptical_ATK1.aedt",
"Product:=", "HFSS", "Design:=", "HornElliptical_ATK",
"Soln:=", "ATK_Solution : FF_Sweep",
Array("NAME:Params", "Horn_length:=", "2.36in", _
"Horn_radius:=", "1.65in", "Ratio:=", "0.6",
"WG_Wall_Thickness:=", "0.024in", "WG_length:=", "1.18in", "WG_radi-
us:=", "0.59in"),
"ForceSourceToSolve:=", false, "PreservePartnerSoln:=", false,
"PathRelativeTo:=", "TargetProject", "FieldType:=", "farfield"),

3D Modeler Editor Script Commands 10-44


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:SourceBlockageStructure", "ModelObject:=", Array


("Cap"),
"NonModelObject:=", Array("Circle2", "Perfect Conductor"))),
"SubmodelDefinitionName:=", "Antenna1", Array("NAME:Com-
ponentPriorityLists"),
Array("NAME:BasicComponentInfo",
"ComponentName:=", "Antenna1",
"Company:=", "",
"Company URL:=", "",
"Model Number:=", "", "Help URL:=", _
"", "Version:=", "1.0", "Notes:=", "", "IconType:=", "Linked
Antenna"))

Python Syn- EditNativeComponentDefinitionData [(<Data>])


tax

oEditor.EditNativeComponentDefinitionData(
[
"NAME:EditNativeComponentData",
"TargetCS:=" , "Global",
"UniqueDefinitionIdentifier:=", "c05a4b88-aaef-4e97-
a746-ecf27ab5adf1",
"OriginFilePath:=" , "",
"IsLocal:=" , False,
"ChecksumString:=" , "",
Python "ChecksumHistory:=" , [],
Example
"VersionHistory:=" , [],
[
"NAME:NativeComponentDefinitionProvider",
"Type:=" , "Linked Antenna",
"Unit:=" , "mm",
"Project:=" , "This Project*",
"Product:=" , "HFSS",
"Design:=" , "Source1",
"Soln:=" , "fc : LastAdaptive",

3D Modeler Editor Script Commands 10-45


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

[
"NAME:Params",
"imp:=" , "60ohm"
],
"ForceSourceToSolve:=" , False,
"PreservePartnerSoln:=" , False,
"PathRelativeTo:=" , "TargetProject",
"FieldType:=" , "farfield",
[
"NAME:SourceBlockageStructure",
"ModelObject:=" , ["bowtie"],
"NonModelObject:=" , ["Cylinder1","Perfect Con-
ductor"]
]
],
"SubmodelDefinitionName:=", "Antenna2",
[
"NAME:ComponentPriorityLists"
],
[
"NAME:BasicComponentInfo",
"ComponentName:=" , "Antenna2",
"Company:=" , "",
"Company URL:=" , "",
"Model Number:=" , "",
"Help URL:=" , "",
"Version:=" , "1.0",
"Notes:=" , "",
"IconType:=" , "Linked Antenna"
]

3D Modeler Editor Script Commands 10-46


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

])

EditPolyline
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: The name of the newly created object
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"
Get3DComponentParameters
Use:Get parameters of 3D components
Command:none
Syntax:Get3DComponentParameters <Component Name>
Return Value:An array of component parameters.

3D Modeler Editor Script Commands 10-47


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters:<Component Name>
Name of the 3D component
VB Example:
Dim paras
paras = oEditor.Get3DComponentParameters("Connector")

Python Syn- Get3DComponentParameters (<Component Name>)


tax

Python oEditor.Get3DComponentParameters("Connector")
Example

Get3DComponentDefinitionNames
Use:Get names of 3D component definitions
Command:None
Syntax:Get3DComponentDefinitionNames
Return Value:An array of component definition names.
Parameters:
VB Example:
Dim defNames
defNames = oEditor.Get3DComponentDefinitionNames()

Python Syn- Get3DComponentDefinitionNames ("")


tax

Python oEditor.Get3DComponentDefinitionNames("")
Example

Get3DComponentInstanceNames
Use:Get instance names of 3D component definitions.
Command:None
Syntax:An array of 3D component instance names.
Return Value:An array of 3D component instance names.
Parameters:<Definition Name>
Name of the 3D component definition
VB Example:

3D Modeler Editor Script Commands 10-48


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim instNames
instNames = oEditor.Get3DComponentInstanceNames("Connector")

Python Get3DComponentInstanceNames(<"Connector">)
Syntax

Python oEditor.Get3DComponentInstanceNames("Connector")
Example

Get3DComponentMaterialNames
Use:Get material names of 3D component.
Command:None.
Syntax:Get3DComponentMaterialNames <Component Instance Name>
Return Value:An array of material names.
Parameters:<Component Instance Name>
Name of the component
VB Example:
Dim materialNames
materialNames = oEditor.Get3DComponentMaterialNames("Connector1")

Python Get3DComponentMaterialNames(<"Connector1">)
Syntax

Python oEditor.Get3DComponentMaterialNames("Connector1")
Example

Get3DComponentMaterialProperties
Use:Get material properties of 3D component material.
Command:None
Syntax:Get3DComponentMaterialProperties <Complete Material Name>
Return Value:An array of material properties.
Parameters:<Complete Material Name>
Name of the material with a complete format

3D Modeler Editor Script Commands 10-49


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Example:
Dim materialProperties
materialProperties = oEditor.Get3DComponentMaterialProperties("Con-
nector1:Material01")

Python Get3DComponentMaterialProperties(<"Connector1:Material01">)
Syntax

Python oEditor.Get3DComponentMaterialProperties("Con-
Exampl- nector1:Material01")
e

Insert3DComponent
Insert a 3D Component
Command: none
Syntax: Insert3DComponent <Data>
Return Value: None
Parameters: <Data>
Data of the 3D component
VB Example:
oEditor.Insert3DComponent Array("NAME:InsertComponentData",
"Parameters:=", "",
"TargetCS:=", "Global",
"ComponentFile:=", "C:\tmp\Connector.a3dcomp")

Python Insert3DComponent [(<Data>])


Syntax

oEditor.Insert3DComponent [
(
Array("NAME:InsertComponentData",
Python
Example "Parameters:=", "",
"TargetCS:=", "Global",
"ComponentFile:=", "C:\tmp\Connector.a3dcomp")
])

3D Modeler Editor Script Commands 10-50


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

InsertNativeComponent
Link from HFSS Modal antenna design to SBR+ design as a component.
Command: Create Antenna>Link to Source Design...
Syntax: InsertNativeComponentData <LinkParameters>
Return Value: None
Parameters: <LinkParametersData>
Data of the 3D component
VB Example:
oEditor.InsertNativeComponent Array("NAME:In-
sertNativeComponentData", "TargetCS:=", "Radar_CS",
"UniqueDefinitionIdentifier:=", "cc9025bd-6de1-4291-8740-
0e38f796e83d",
"OriginFilePath:=", "", "IsLocal:=", false,
"ChecksumString:=", "", "ChecksumHistory:=", Array(), "Ver-
sionHistory:=", Array(),
Array("NAME:NativeComponentDefinitionProvider", "Type:=", "Linked
Antenna", "Unit:=", "meter", "Project:=", "Dipole_twoplates.aedt",
"Product:=", "HFSS", "Design:=", "SBR_Dipole_PEC3", "Soln:=",
"Setup1 : LastAdaptive",
Array("NAME:Params", "gap:=", "0.1mm", "lambda2Ghz:=", "0.074948-
meter"),
"ForceSourceToSolve:=", false,
"PreservePartnerSoln:=", false,
"PathRelativeTo:=", "TargetProject",
"FieldType:=", "nearfield",
Array("NAME:SourceBlockageStructure", "NonModelObject:=", Array()),
"UseGlobalCurrentSrcOption:=", _false,
"Current Source Conformance:=", "Enable", "Thin Sources:=", true,
"Power Fraction:=", "0.95"),
"SubmodelDefinitionName:=", "Antenna2", Array("NAME:Com-
ponentPriorityLists"),

3D Modeler Editor Script Commands 10-51


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:BasicComponentInfo", "ComponentName:=", "Antenna2", "Com-


pany:=", "", "Company URL:=", "",
"Model Number:=", "", "Help URL:=", "", "Version:=", "1.0",
"Notes:=", "", "IconType:=", "Linked Antenna"))

Python Syn- InsertNativeComponent [(<Data>])


tax

oEditor.InsertNativeComponent(
[
"NAME:InsertNativeComponentData", "TargetCS:=" ,
"Radar_CS",
"UniqueDefinitionIdentifier:=", "e7557a6b-d552-46e9-
b085-ffd1a6a38a31",
"OriginFilePath:=" , "",
"IsLocal:=" , False, "ChecksumString:=" , "",
"ChecksumHistory:=" , [],
"VersionHistory:=" , [],
[ "NAME:NativeComponentDefinitionProvider",
"Type:=" , "Linked Antenna",
Python
"Unit:=" , "meter",
Example
"Project:=" , "Dipole_twoplates.aedt",
"Product:=" , "HFSS",
"Design:=" , "SBR_Dipole_PEC3",
"Soln:=" , "Setup1 : LastAdaptive", [ "NAME:Params",
"gap:=" , "0.1mm", "lambda2Ghz:=" , "0.074948meter" ],
"ForceSourceToSolve:=" , False,
"PreservePartnerSoln:=" , False,
"PathRelativeTo:=" , "TargetProject",
"FieldType:=" , "nearfield", [ "NAME:SourceB-
lockageStructure", "NonModelObject:=" , [] ],
"UseGlobalCurrentSrcOption:=", False,
"Current Source Conformance:=", "Enable",

3D Modeler Editor Script Commands 10-52


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Thin Sources:=" , True, "Power Fraction:=" , "0.95"


],
"SubmodelDefinitionName:=", "Antenna2", [ "NAME:Com-
ponentPriorityLists" ],
[ "NAME:BasicComponentInfo", "ComponentName:=" ,
"Antenna2", "Company:=" , "",
"Company URL:=" , "", "Model Number:=" , "",
"Help URL:=" , "", "Version:=" , "1.0", "Notes:=" ,
"", "IconType:=" , "Linked Antenna"
] ])

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
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>)

3D Modeler Editor Script Commands 10-53


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<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
Sweeps the specified 1D or 2D parts along a path. The last 1D object specified is the path for the
sweep.

UI Access Draw > Sweep > Along Path.

Name Type Description


PathSweepParametersArray Array Array("NAME:PathSweep-
Parameters",
"DraftAngle:=", <value>,
"DraftType:=", <string>,
Parameters "Check-
FaceFaceIntersection:=",
<bool>,
"TwistAngle:=", <value>)
Possible values for DraftType are "Exten-
ded", "Round", and "Natural"

3D Modeler Editor Script Commands 10-54


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Return None
Value

Python Syn- SweepAlongPath([<SelectionsArray>], [<PathSweepParametersArray>])


tax

oEditor.SweepAlongPath(
[
"NAME:Selections",
"Selections:=" , "Rectangle1,Polyline1",
"NewPartsModelFlag:=" , "Model"
],
Python
[
Example
"NAME:PathSweepParameters",
"DraftAngle:=" , "0deg",
"DraftType:=" , "Round",
"CheckFaceFaceIntersection:=", False,
"TwistAngle:=" , "0deg"
])

VB Syntax SweepAlongPath <SelectionsArray>, <PathSweepParametersArray>


oEditor.SweepAlongPath
Array("NAME:Selections", "Selections:=",
"Polygon1,Polyline1"),_

VB Array("NAME:PathSweepParameters", _
Example "DraftAngle:=", "0deg",_
"DraftType:=", "Round",_
"CheckFaceFaceIntersection:=", False,_
"TwistAngle:=", "30deg")

3D Modeler Editor Script Commands 10-55


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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

UI Access Draw > Sweep > Along Vector.

Name Type Description


VecSweepParametersArray Array Array("NAME:Vect-
orSweepParameters",
"DraftAngle:=", <value>,
"DraftType:=", <string>,
"Check-
Parameters FaceFaceIntersection:=",
<bool>,
"SweepVectorX:=", <value>
"SweepVectorY:=", <value>
"SweepVectorZ:=", <value>)
Possible values for DraftType are "Exten-
ded", "Round", and "Natural"

Return None
Value

Python Syn- SweepAlongVector([<SelectionsArray>], [<VecSweepParametersArray>])


tax

oEditor.SweepAlongVector(
[
"NAME:Selections",
"Selections:=" , "Rectangle1",

Python "NewPartsModelFlag:=" , "Model"


Example ],
[
"NAME:VectorSweepParameters",
"DraftAngle:=" , "0deg",
"DraftType:=" , "Round",

3D Modeler Editor Script Commands 10-56


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"CheckFaceFaceIntersection:=", False,
"SweepVectorX:=" , "0mm"
"SweepVectorY:=" , "0mm"
"SweepVectorX:=" , "12mm"
])

VB Syntax SweepAlongVector <SelectionsArray>, <VecSweepParametersArray>


oEditor.SweepAlongPath
Array("NAME:Selections",_
"Selections:=", "Rectangle1",_
"NewPartsModelFlag:=" , "Model")
Array("NAME:VectorSweepParameters", _
VB
"DraftAngle:=", "0deg",_
Example
"DraftType:=", "Round",_
"CheckFaceFaceIntersection:=", False,_
"SweepVectorX:=" , "0mm",_
"SweepVectorY:=" , "0mm",_
"SweepVectorZ:=" , "12mm")

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

UI Access Draw > Sweep > Around Axis.

Name Type Description


AxisSweepParametersArray Array Array("NAME:Ax-
isSweepParameters",
"DraftAngle:=", <value>,
Parameters "DraftType:=", <string>,
"Check-
FaceFaceIntersection:=",
<bool>,
"SweepAxis:=", <value>

3D Modeler Editor Script Commands 10-57


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"SweepAngle:=", <value>
"NumOfSegments:=", <value>)
Possible values for DraftType are "Exten-
ded", "Round", and "Natural"
Possible values for SweepAxis are "X", "Y",
and "Z"

Return None
Value

Python Syn- SweepAroundAxis([<SelectionsArray>], [<AxisSweepParametersArray>])


tax

oEditor.SweepAroundAxis(
[
"NAME:Selections",
"Selections:=" , "Rectangle1",
"NewPartsModelFlag:=" , "Model"
],
[
Python
"NAME:AxisSweepParameters",
Example
"DraftAngle:=" , "0deg",
"DraftType:=" , "Round",
"CheckFaceFaceIntersection:=", False,
"SweepAxis:=" , "X"
"SweepAngle:=" , "360deg"
"NumOfSegments:=" , "12"
])

VB Syntax SweepAroundAxis <SelectionsArray>, <AxisSweepParametersArray>

VB oEditor.SweepAroundAxis
Example Array("NAME:Selections",_

3D Modeler Editor Script Commands 10-58


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Selections:=", "Rectangle1",_
"NewPartsModelFlag:=" , "Model")
Array("NAME:AxisSweepParameters", _
"DraftAngle:=", "0deg",_
"DraftType:=", "Round",_
"CheckFaceFaceIntersection:=", False,_
"SweepAxis:=" , "X",_
"SweepAngle:=" , "360deg",_
"NumOfSegments:=" , "12")

SweepFacesAlongNormal
Sweep a face along normal.

UI Acce- Modeler > Surface > Sweep Faces Along Normal


ss

Name Type Description


selections Array Array("NAME:Selections",
"Selections:=", "<faceID>",
"NewPartsModelFlag:=", ["Model" |
"NonModel"]),
Para- parameters Array Array("NAME:Parameters",
meters
"NAME:Sweep-
FaceAlongNormalToParameters",
"FacesToDetach:=", <faceIDarray>,
"LengthOfSweep:=",
"<value><units>")

Return None
Value

Python Syn- SweepFacesAlongNormal(<selections> <parameters>)


tax

oEditor.SweepFacesAlongNormal(
Python
[
Example
"NAME:Selections",

3D Modeler Editor Script Commands 10-59


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Selections:=" , "Rectangle1",
"NewPartsModelFlag:=" , "Model"
],
[
"NAME:Parameters",
[
"NAME:SweepFaceAlongNormalToParameters",
"FacesToDetach:=" , [183],
"LengthOfSweep:=" , "0.1mm"
]
])

VB Syntax SweepFacesAlongNormal <selections> <parameters>


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

SweepFacesAlongNormalWithAttributes
Use: Sweep selected faces along normal to create new object, user can specify the attributes of
the new object
Command: Recorded during PML creation
Syntax: SweepFacesAlongNormalWidthAttributes <SelectionsArray>, <ParametersArray>,
<AttributeArray>
Return Value: None
Parameters: <ParametersArray>

3D Modeler Editor Script Commands 10-60


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:SweepFaceAlongNormalToParameters",
"FacesToDetach:=", Array(12),
"LengthOfSweep:=", "0.1mm"))
VB Example:
oEditor.SweepFacesAlongNormalWithAttributes Array("NAME:Selections",
"Selections:=","Box1",
"NewPartsModelFlag:=", "Model"),
Array("NAME:Parameters",
Array("NAME:SweepFaceAlongNormalToParameters", "FacesToDetach:=", Array(7),
"LengthOfSweep:=", "0.424865556413828mm")),
Array("NAME:Attributes", "Name:=", "PML_Box1_1", "Flags:=", "",
"Color:=", "(132 132 193)",
"Transparency:=", 0.899999976158142,
"PartCoordinateSystem:=", "FaceCS1",
"UDMId:=", "",
"MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "",
"SolveInside:=", true)

Pytho- SweepFacesAlongNormalWidthAttributes (<SelectionsArray>, <ParametersArray>,


n Syn- <AttributeArray>)
tax

oEditor.SweepFacesAlongNormalWithAttributes ([
Array("NAME:Selections","Selections:=","Box1",
"NewPartsModelFlag:=", "Model"),

Array("NAME:Parameters",

Array("NAME:SweepFaceAlongNormalToParameters",
"FacesToDetach:=", Array(7),
Pytho- "LengthOfSweep:=", "0.424865556413828mm")),
n
Exam-
ple Array("NAME:Attributes", "Name:=", "PML_Box1_1", "Flags:=",
"",
"Color:=", "(132 132 193)",
"Transparency:=", 0.899999976158142,
"PartCoordinateSystem:=", "FaceCS1",
"UDMId:=", "",
"MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) &
"",
"SolveInside:=", True)
])

3D Modeler Editor Script Commands 10-61


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UpdateComponentDefinition
Use:Update component definition
Command:None
Syntax:UpdateComponentDefinition <Data>
Return Value:none
Parameters:<Data> Component data
VB Example:
oEditor.UpdateComponentDefinition
Array("NAME:UpdateDefinitionData",
"DefinitionNames:=", " Connector, Magic_Tee",
"Passwords:=", Array("", ""))

Python Syn- UpdateComponentDefinition (<Data>)


tax

oEditor.UpdateComponentDefinition
([
Array("NAME:UpdateDefinitionData",
Python "DefinitionNames:=", " Connector, Magic_Tee",
Example "Passwords:=",
Array("", ""))
])

Edit Menu Commands


Copy
DeletePolyLinePoint
DuplicateAlongLine
DuplicateAroundAxis
DuplicateMirror
Mirror
Move
OffsetFaces
Paste (Model Editor)
Rotate

3D Modeler Editor Script Commands 10-62


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Scale
Copy
Use: Copies specified parts
Command: Edit>Copy
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
Duplicates specified parts along line.

UI Access Edit > Duplicate > Along Line

Name Type Description


<DupLineParametersArray> <Array>
Parameters DuplicateToAlongLineParameters <Array>
XComponent <value>
YComponent <value>

3D Modeler Editor Script Commands 10-63


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ZComponent <value>
NumClones <value> Specify a number greater than
1.
Options <Array>
<DupBoundaries> <Array>
DuplicateBoundaries <bool> True or False

Return Value List with names of newly created objects

Python DuplicateAlongLine (<SelectionsArray>, <DupLineParametersArray>


Syntax <DupBoundariesArray>)
oEditor.DuplicateAlongLine(
[
"NAME:Selections",
"Selections:=" , "Rectangle1",
"NewPartsModelFlag:=" , "Model"
],
[
"NAME:DuplicateToAlongLineParameters",
"CreateNewObjects:=" , True,
"XComponent:=" , "0mm",
Python
"YComponent:=" , "-1.9mm",
Example
"ZComponent:=" , "0mm",
"NumClones:=" , "2"
],
[
"NAME:Options",
"DuplicateAssignments:=", False
],
[
"CreateGroupsForNewObjects:=", False
])

3D Modeler Editor Script Commands 10-64


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syn- DuplicateAlongLine (<SelectionsArray>, <DupLineParametersArray> <DupBound-


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

DuplicateAroundAxis
Duplicates specified parts around an axis.

UI Access Edit > Duplicate > Around Axis

Name Type Description


DupAxisParametersArray <Array>
DuplicateAroundAxisParameters <Array>
WhichAxis <string> Axis to duplicate around. Poss-
ible values are: "X", "Y", "Z"
Parameters Example: "WhichAxis:=", "Z"
AngleStr: <value>
NumClones <value> Specify a number greater than 1.
DupBoundariesArray <Array>
Options <Array>
DuplicateBoundaries <bool> True or False

Return Value None

Python Syn- DuplicateAroundAxis (<SelectionsArray>, <DupAxisParametersArray>


tax <DupBoundariesArray>)
Python oEditor.DuplicateAroundAxis(

3D Modeler Editor Script Commands 10-65


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

[
"NAME:Selections",
"Selections:=" , "Rectangle1",
"NewPartsModelFlag:=" , "Model"
],
[
"NAME:DuplicateAroundAxisParameters",
"CreateNewObjects:=" , False,
"WhichAxis:=" , "Z",
Example "AngleStr:=" , "90deg",
"NumClones:=" , "2"
],
[
"NAME:Options",
"DuplicateAssignments:=", False
],
[
"CreateGroupsForNewObjects:=", False
])

VB Syn- DuplicateAroundAxis <SelectionsArray>, <DupAxisParametersArray>,


tax <DupBoundariesArray>
oEditor.DuplicateAroundAxis Array("NAME:Selections",_
"Selections:=", "Box1", _
"NewPartsModelFlag:=", "Model"), _

VB Array("NAME:DuplicateAroundAxisParameters", _
Example "CreateNewObjects:=", false, _
"WhichAxis:=", "Z", _
(For Maxwell 2D XY Designs, "Whichaxis:=" should be set to "Z".)
(For Maxwell 2D RZ Designs, "Whichaxis:=" should be set to "Y".)

3D Modeler Editor Script Commands 10-66


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"AngleStr:=", "90deg", _
"NumClones:=", "2"), _
Array("NAME:Options", "DuplicateBoundaries:=", false)

DuplicateMirror
Duplicate specified parts according to a mirror plane.

UI Access Edit > Duplicate > Mirror

Name Type Description


DupMirrorParametersArray <Array>
DuplicateToMirrorParameters <Array> Mirror to duplicate to.
DuplicateMirrorBaseX <string>
DuplicateMirrorBaseY <value> (For Maxwell 2D RZ Designs, Y para-
meters should be set to "0".)
DuplicateMirrorBaseZ <value> (For Maxwell 2D XY Designs, Z para-
meters should be set to "0".)
Parameters
DuplicateMirrorNormalX <value>
DuplicateMirrorNormalY <value> (For Maxwell 2D RZ Designs, Y para-
meters should be set to "0".)
DuplicateMirrorNormalZ <value> (For Maxwell 2D XY Designs, Z para-
meters should be set to "0".)
DupBoundariesArray <Array>
Options <Array>
DuplicateBoundaries <bool> True or False

Return Value None

Python DuplicateMirror (<SelectionsArray>, <DupMirrorParametersArray>)


Syntax

oEditor.DuplicateMirror(
[
"NAME:Selections",

Python "Selections:=" , "Rectangle1",


Example "NewPartsModelFlag:=" , "Model"
],
[
"NAME:DuplicateToMirrorParameters",

3D Modeler Editor Script Commands 10-67


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"DuplicateMirrorBaseX:=", "0mm",
"DuplicateMirrorBaseY:=", "0.7mm",
"DuplicateMirrorBaseZ:=", "0mm",
"DuplicateMirrorNormalX:=", "1mm",
"DuplicateMirrorNormalY:=", "0mm",
"DuplicateMirrorNormalZ:=", "0mm"
],
[
"NAME:Options",
"DuplicateAssignments:=", False
],
[
"CreateGroupsForNewObjects:=", False
])

VB Syn- DuplicateMirror (<SelectionsArray>, <DupMirrorParametersArray>)


tax

oEditor.DuplicateMirror Array("NAME:Selections", _
"Selections:=", "Box1", _
"NewPartsModelFlag:=", "Model"), _
Array("NAME:DuplicateToMirrorParameters", _
"DuplicateMirrorBaseX:=", "0mm", _
"DuplicateMirrorBaseY:=", "0mm", _
VB
Exampl- "DuplicateMirrorBaseZ:=", "0mm", _
e
"DuplicateMirrorNormalX:=", "0mm", _
"DuplicateMirrorNormalY:=", "-1mm", _
"DuplicateMirrorNormalZ:=", "0mm"), _
Array("NAME:Options", "DuplicateBoundaries:=", false)
(For Maxwell 2D XY Designs, Z parameters should be set to "0".)
(For Maxwell 2D RZ Designs, Y parameters should be set to "0".)

3D Modeler Editor Script Commands 10-68


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<DupBoundariesArray>
Array("NAME:Options", "DuplicateBoundaries:=",
<bool>)

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>)
VB 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")

Python Mirror (<SelectionsArray>, <MirrorParametersArray>)


Syntax

3D Modeler Editor Script Commands 10-69


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oEditor.Mirror(
[
("NAME:Selections",
"Selections:=","Box1",
"NewPartsModelFlag:=", "Model"),

Python ("NAME:MirrorParameters",
Example "MirrorBaseX:=", "-0.8mm",
"MirrorBaseY:=", "-1mm",
"MirrorBaseZ:=", "0mm",
"MirrorNormalX:=", "0.948683298050514mm",
"MirrorNormalY:=", "-0.316227766016838mm",
"MirrorNormalZ:=", "0mm")
])

Move
Use: Moves specified parts.
Command: Click Edit>Arrange>Move
Syntax: Move <SelectionsArray>, <MoveParametersArray>
Return Value: None
Parameters: <MoveParametersArray>
Array("NAME:TranslateParameters",
"TranslateVectorX:=", <value>,
"TranslateVectorY:=", <value>,
"TranslateVectorZ:=", <value>)
(For Maxwell 2D XY Designs, "TranslateVectorZ:=" should be set to "0".)
(For Maxwell 2D RZ Designs, "TranslateVectorY:=" should be set to "0".)
OffsetFaces
Use: Offsets faces of specified parts.
Command: Edit>Arrange>Offset
Syntax: OffsetFaces <SelectionsArray>, <OffsetParametersArray>

3D Modeler Editor Script Commands 10-70


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Return Value: None


Parameters: <OffsetParametersArray>
Array("NAME:OffsetParameters",
"OffsetDistance:=", <value>)
Paste (Model Editor)
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 guaranteed to be
alphabetical.
Parameters: None.
VB 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",
"RotateAxis:=", <string>
"RotateAngle:=", <value>)
RotateAxis
Possible values are: "X", "Y", "Z"
(For Maxwell 2D XY Designs, "RotateAxis:=" should be set to "Z".)
(For Maxwell 2D RZ Designs, "Whichaxis:=" should be set to "Y".)

Python Syn- Rotate()


tax

Python oEditor.Rotate (
Example

3D Modeler Editor Script Commands 10-71


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

[
"NAME:Selections",
"Selections:=",
["CompInst@R;2;4", "CompInst@C;1;1"
]
],
["NAME:RotateParameters",
"Degrees:=", 90,
"Disconnect:=", false,
"Rubberband:=", false
])

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>)
(For Maxwell 2D XY Designs, "ScaleZ:=" should be set to "0".)
(For Maxwell 2D RZ Designs, "ScaleY:=" should be set to "0".)

Modeler Menu Commands


AssignMaterial
Chamfer
Connect
CoverLines
CoverSurfaces
CreateEntityList

3D Modeler Editor Script Commands 10-72


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

CreateFaceCS
CreateGroup
CreateObjectCS
CreateObjectFromEdges
CreateObjectFromFaces
CreateRelativeCS
DeleteEmptyGroups
DeleteLastOperation
DetachFaces
EditEntityList
EditFaceCS
EditObjectCS
EditRelativeCS
Export
Fillet
FlattenGroup
Generate History
GetActiveCoordinateSystem
GetCoordinateSystems
Import
ImportDXF
ImportGDSII [Modeler]
Intersect
MoveCStoEnd
MoveEntityToGroup
MoveFaces
ProjectSheet
PurgeHistory
ReplaceWith3DComponent
Section

3D Modeler Editor Script Commands 10-73


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

SeparateBody
SetModelUnits
SetWCS
ShowWindow
Split
Subtract
SweepFacesAlongNormal
ThickenSheet
UncoverFaces
Unite
Ungroup
Wrap Sheet
AssignMaterial
Use: Assigns a material to the specified objects. Only the MaterialName and SolveInside para-
meters of <AttributesArray> are supported.
Command: Modeler>Assign Material
Syntax: AssignMaterial <SelectionsArray>, <AttributesArray>
Return Value: None
VB Example:
oEditor.AssignMaterial _
Array("NAME:Selections", "Selections:=", "Polygon1"),
Array("NAME:Attributes", _
"MaterialName:=", "tungsten",_
"SolveInside:=", false)

Python AssignMaterial (<SelectionsArray>, <AttributesArray>)


Syntax

oEditor.AssignMaterial
Python
([
Example
Array("NAME:Selections", "Selections:=", "Polygon1"),

3D Modeler Editor Script Commands 10-74


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:Attributes", _
"MaterialName:=", "tungsten",_
"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>))

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

Pyt- Chamfer ([ <ObjectName>, <ChamferParameters> ])


hon
Syn-

3D Modeler Editor Script Commands 10-75


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

tax

oEditor.Chamfer
([
Pyt-
hon
Array("Name:Selections", "Selections:=", "Box1"),
Exa- Array("NAME:Parameters",
mpl-
e 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
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>

3D Modeler Editor Script Commands 10-76


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Return Value: Name of list.


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

VBS Example: This example first creates a box and cylinder, and then
displays Entity lists.
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.NewProject
oProject.InsertDesign "HFSS", "HFSSDesign1", "DrivenTerminal", ""
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.CreateBox Array("NAME:BoxParameters", "XPosition:=", "-
1.1mm", "YPosition:=", _
"-0.8mm", "ZPosition:=", "0mm", "XSize:=", "0.3mm", "YSize:=",
"0.5mm", "ZSize:=", _
"0.4mm"), Array("NAME:Attributes", "Name:=", "Box1", "Flags:=", "",
"Color:=", _
"(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=",
"Global", "UDMId:=", _
"", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "Sur-
faceMaterialValue:=", _

3D Modeler Editor Script Commands 10-77


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"" & Chr(34) & "" & Chr(34) & "", "SolveInside:=", true, "IsMa-
terialEditable:=", _
true, "UseMaterialAppearance:=", false, "IsLightweight:=", false)
oEditor.CreateCylinder Array("NAME:CylinderParameters", "XCenter:=",
"0.4mm", "YCenter:=", _
"0.7mm", "ZCenter:=", "0mm", "Radius:=", "0.282842712474619mm",
"Height:=", _
"0.6mm", "WhichAxis:=", "Z", "NumSides:=", "0"), Array("NAME:At-
tributes", "Name:=", _
"Cylinder1", "Flags:=", "", "Color:=", "(143 175 143)", "Trans-
parency:=", 0, "PartCoordinateSystem:=", _
"Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum"
& Chr(34) & "", "SurfaceMaterialValue:=", _
"" & Chr(34) & "" & Chr(34) & "", "SolveInside:=", true, "IsMa-
terialEditable:=", _
true, "UseMaterialAppearance:=", false, "IsLightweight:=", false)
Dim oObjectList
oObjectList = oEditor.CreateEntityList(Array("NAME:Geo-
metryEntityListParameters", "EntityType:=", _
"Object", "EntityList:=", "Box1, Cylinder1"), Array("NAME:At-
tributes", "Name:=", _
"Objectlist1"))
MsgBox(oObjectList)
Dim oObjectID
oObjectID = oEditor.GetEntityListIDByName(oObjectList)
MsgBox(oObjectID)
Dim oFaceList
oFaceList = oEditor.CreateEntityList(Array("NAME:Geo-
metryEntityListParameters", "EntityType:=", _
"Face", "EntityList:=", Array(12, 35)), Array("NAME:Attributes",
"Name:=", _
"Facelist1"))
MsgBox(oFaceList)
Dim oFaceID

3D Modeler Editor Script Commands 10-78


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oFaceID = oEditor.GetEntityListIDByName(oFaceList)
MsgBox(oFaceID)

Python Syn- CreateEntityList(<EntityListParametersArray>)


tax

oProject = oDesktop.GetActiveProject()
oDesign = oProject.GetActiveDesign()
oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.CreateBox(
[
"NAME:BoxParameters",
"XPosition:=" , "-0.5mm",
"YPosition:=" , "-0.8mm",
"ZPosition:=" , "0mm",
"XSize:=" , "1.6mm",
"YSize:=" , "2mm",
"ZSize:=" , "2.3mm"

Python ],
Example [
"NAME:Attributes",
"Name:=" , "Box1",
"Flags:=" , "",
"Color:=" , "(143 175 143)",
"Transparency:=" , 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"vacuum\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , True,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False,

3D Modeler Editor Script Commands 10-79


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"IsLightweight:=" , False
])
list_name = oEditor.CreateEntityList(
[
"NAME:GeometryEntityListParameters",
"EntityType:=" , "Face",
"EntityList:=" , [int(id) for id in oEd-
itor.GetFaceIDs("Box1")]
],
[
"NAME:Attributes",
"Name:=" , "Facelist1"
])

print(list_name)

CreateFaceCS
Use: Creates a face coordinate system. Only the Name attribute of the <AttributesArray> para-
meter is supported.
Command: Modeler>Coordinate System>Create>Face CS
Syntax: CreateFaceCS <FaceCSParametersArray>, <AttributesArray>
Return Value: None
Parameters: <FaceCSParametersArray>
Array("NAME:FaceCSParameters",
"FaceID:=", <int>,
"PartID:=", <int>,
Array("NAME:OriginPosn",
"IsAttachedToEntity:=", <bool>,
"EntityID:=", <value>,
"PositionType:=", <string>,
"UParam:=", <value>,
"VParam:=", <value>,

3D Modeler Editor Script Commands 10-80


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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
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

3D Modeler Editor Script Commands 10-81


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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"
CreateGroup
Creates a group from specified objects in the history tree.

UI Access Modeler > Group > Create.

Name Type Description


< group> Structured Array "NAME:GroupParameter", "Par-
entGroupID:=", "Model",
Para- "Parts:=", "<objID>,<ob-
meters jID>,<objID><...>", "Sub-
modelInstances:=",
"<submodelID>", "Groups:=",
"<subgroupID>"

Return None.
Value

Pytho- CreateGroup (<group>)


n Syn-
tax

oEditor.CreateGroup(
Pytho- ["NAME:GroupParameter", "ParentGroupID:=", "Model",
n
Examp- "Parts:=", "Box1,Box2,Box3", "SubmodelInstances:=", "",
le "Groups:=", ""]
)

VB CreateGroup <group>
Syn-
tax

VB Dim oAnsoftApp

3D Modeler Editor Script Commands 10-82


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
Exam-
ple oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project44")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.CreateGroup Array("NAME:GroupParameter", "Par-
entGroupID:=", "Model", _
"Parts:=", "Box1,Box2,Box3", "SubmodelInstances:=", "",
"Groups:=", "")

CreateObjectCS
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>,

3D Modeler Editor Script Commands 10-83


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"XPosition:=", "<Integer>",
"YPosition:=", "<Integer>",
"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

3D Modeler Editor Script Commands 10-84


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")


Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("coax_bend")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
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")

Python Syn- CreateObjectCS (<ParameterArrays>)


tax

Python oEditor.CreateObjectCS

3D Modeler Editor Script Commands 10-85


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

([
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",
Example "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
Creates a polyline from the specified object edge.

UI Access Modeler > Edge > Create Object From Edge

Name Type Description


<Selections> Array of Names of selected
Parameters Strings edges
<NewPartsModelFlag>
Model or Non Model
<Parameters>

3D Modeler Editor Script Commands 10-86


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<BodyFromEdgeToParameters> Array of
Integers
<Edges> Identifying numbers
for selected edges
<CreateGroupsForNewObjects> Boolean True to create groups
for new objects. False
to not create groups
for new objects.

Return None
Value

CreateObjectFromEdges ([
Python Syn- <SelectionsArray>,
tax
<ObjFromEdgeParametersArray>
])
oEditor.CreateObjectFromEdges(
[
"NAME:Selections",
"Selections:=" , "Rectangle1",
"NewPartsModelFlag:=" , "Model"
],
[

Python "NAME:Parameters",
Example [
"NAME:BodyFromEdgeToParameters",
"Edges:=" , [72]
]
],
[
"CreateGroupsForNewObjects:=", False
])

3D Modeler Editor Script Commands 10-87


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syn- CreateObjectFromEdges <SelectionsArray>,


tax <ObjFromEdgeParametersArray>

oEditor.CreateEdgeFromEdges _
Array("NAME:Selections", "Selections:=", "Box1"),_

VB Array("NAME:Parameters", _
Example Array("NAME:BodyFromEdgeToParameters", _
"CoordinateSystemID:=", -1, _
"Edges:=", Array(13)))

CreateObjectFromFaces
Creates 2D objects from the specified faces.

UI Access Modeler > Surface > Create Object From Face

Name Type Description


<Selections> Array of Names of selected faces
Strings

<NewPartsModelFlag> Model or Non Model


<Parameters>
Parameters <BodyFromFaceToParameters> Array of
Integers
<FacesToDetach> Identifying numbers for
selected faces
<CreateGroupsForNewObjects> Boolean True to create groups for
new objects. False to not
create groups for new
objects.

Return None
Value

CreateObjectFromFaces ([
Python Syn- <SelectionsArray>,
tax
<ObjFromFaceParametersArray>
])

Python oEditor.CreateObjectFromFaces (
Example [

3D Modeler Editor Script Commands 10-88


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"NAME:Selections",
"Selections:=" , "Rectangle1",
"NewPartsModelFlag:=" , "Model"
],
[
"NAME:Parameters",
[
"NAME:BodyFromFaceToParameters",
"FacesToDetach:=" , [78]
]
],
[
"CreateGroupsForNewObjects:=", False
])

Array of integers – the IDs of the faces to use to create objects.

VB Syn- CreateObjectFromFaces <SelectionsArray>,


tax <ObjFromFaceParametersArray>

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

CreateRelativeCS
Use: Creates a relative coordinate system. Only the Name attribute of the <AttributesArray> para-
meter 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>,

3D Modeler Editor Script Commands 10-89


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<AttributesArray>
Return Value: None
Parameters: <RelativeCSParametersArray>
Array("NAME:RelativeCSParameters",
"OriginX:=", <value>,
"OriginY:=", <value>,
"OriginZ:=", <value>,
"XAxisXvec:=", <value>,
"XAxisYvec:=", <value>,
"XAxisZvec:=", <value>,
"YAxisXvec:=", <value>,
"YAxisYvec:=", <value>,
"YAxisZvec:=", <value>)
DeleteEmptyGroups
Use: Removes a specified history tree group.
Command: Modeler>Group>Delete Empty
Syntax: DeleteEmptyGroups Array("Groups:=", Array("<GroupID>"))
Return Value: None
Parameters: <GroupID>,
The ID for the history tree groups to delete.
Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow

3D Modeler Editor Script Commands 10-90


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oProject = oDesktop.SetActiveProject("Project44")


Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.DeleteEmptyGroups Array("Groups:=", Array("Group1"))

Python Syn- DeleteEmptyGroups ([ Array("Groups:=", Array("<GroupID>") ])


tax

oEditor.DeleteEmptyGroups

Python ([
Example Array("Groups:=", Array("Group1")
)])

DeleteLastOperation
Use: Deletes the last operation for specified objects.
Command: Modeler>Delete Last Operation
Syntax: DeleteLastOperation <SelectionsArray>
Return Value: None
DetachFaces
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>)

3D Modeler Editor Script Commands 10-91


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

FacesToDetach
An array of integers – the face IDs of the faces to detach.
VB 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)))

DetachFaces ([
Python Syn- <SelectionsArray>,
tax
<DetachFacesParametersArray>
])
oEditor.DetachFaces
([
Array("NAME:Selections", "Selections:=",_
"Box5,Box4"),_

Python Array("NAME:Parameters", _
Example Array("NAME:DetachFacesToParameters", _
"FacesToDetach:=", Array(123, 122)),
Array("NAME:DetachFacesToParameters", _
"FacesToDetach:=", Array(94)))
])

EditEntityList
Modifies an entity list.
Command: Modeler>List>Reassign

3D Modeler Editor Script Commands 10-92


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax: EditEntityList <SelectionsArray>,


<EntityListParametersArray>
Return Value: None
EditFaceCS
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: Click 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",

3D Modeler Editor Script Commands 10-93


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project53")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")

3D Modeler Editor Script Commands 10-94


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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,
"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")

Python EditObjectCS (<Array>)


Syntax

oEditor.EditObjectCS

Python
([
Example Array("NAME:ObjectCSParameters",
"PartID:=", 6,

3D Modeler Editor Script Commands 10-95


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"ReverseXAxis:=", false,
"ReverseYAxis:=", false,
Array("NAME:Origin", "IsAttachedToEntity:=", false,
"EntityID:=", -1,
"PositionType:=", "AbsolutePosition",
"UParam:=", 0, "VParam:=", 0,
"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
Modifies a relative coordinate system. Use <AttributesArray> to indicate the name of the coordin-
ate system to modify.
Command: Modeler>Coordinate System>Edit
Syntax: EditRelativeCS <RelativeCSParametersArray>,
<AttributesArray>
Return Value: None
Parameters: <ParametersArray>
Array("NAME:RelativeCSParameters",
"OriginX:=", <value>,
"OriginY:=", <value>,

3D Modeler Editor Script Commands 10-96


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"OriginZ:=", <value>,
"XAxisXvec:=", <value>,
"XAxisYvec:=", <value>,
"XAxisZvec:=", <value>,
"YAxisXvec:=", <value>,
"YAxisYvec:=", <value>,
"YAxisZvec:=", <value>)
Export
Exports the model to a file.
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. For high resolution images, you can set environment
variables to specify pixel width and height. You can also specify an orientation, either a default ori-
entation name, or a custom orientation that you have defined in the desktop.
Command: Modeler>Export...
Syntax: ExportModelImageToFile "<path>/<imageName>.<formatsuffix>" 0,0, Array
(<SaveImageParams>)
Return Value: None
Parameters: <path>

3D Modeler Editor Script Commands 10-97


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<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.

<width>,<height>,
For the default, use 0, 0. For higher resolution, set desired <width> and <height>, for
example for 8k export as: 7680, 4320.
Array("NAME:SaveImageParams",
"ShowAxis:=","<Boolean>",
Whether to show the Axis in the image.
"ShowGrid:=", "<Boolean>",
Whether to show the Grid in the image.
"ShowRuler:=", "<Boolean>"
Whether to show the Ruler in the image.
"ShowRegions:=", "<Default>",
Whether to show regions in the image.
"Selections:=" ,""
Selected object names.
"Orientation:=", "<OrientationName>")
The name of the Orientation to use. One of top, bottom, right, left, front, back trimetric,
dimetric, isometric, or a custom orientation that you added to the Orientation List using
View>Modify Attributes>Add Orientation... command in the ANSYS Electronics
Desktop.
Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor

3D Modeler Editor Script Commands 10-98


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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" , "Ori-
entation:=", "Trimetric")

Python Syn- ExportModelImageToFile (["<path>/<imageName>.<formatsuffix>" 0,0,


tax [(<SaveImageParams>)])
oEditor.ExportModelImageToFile
("C:/MyPath/Downloads/dra_example.jpg", 0, 0,
[
"NAME:SaveImageParams",
"ShowAxis:=" , "True",
Python "ShowGrid:=" , "True",
Example
"ShowRuler:=" , "True",
"ShowRegion:=" , "Default",
"Selections:=" , ""
"Orientation:=" , "Trimetric"
])

oEditor.ExportModelImageToFile
Python ("C:/Users/MyName/Documents/highresexample_image.jpg",
Example 7680, 4320,
using High [
Resolution "NAME:SaveImageParams",
settings. "ShowAxis:=" , "True",
"ShowGrid:=" , "True",

3D Modeler Editor Script Commands 10-99


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"ShowRuler:=" , "True",
"ShowRegion:=" ,
"Default",
"Selections:=" , ""
"Orientation:=" , "Trimetric"
])

Fillet
Creates a fillet.
Command: Modeler>Fillet
Syntax: Fillet(<ObjectName> <FilletParameters>)
Return Value: None
Parameters: <ObjectName>
Array("NAME:Selections", _
"Selections:=", <string>),
<FilletParameters>
Array("NAME:Parameters", _
Array("NAME:FilletParameters", _
"CoordinateSystemID:=", <value>,
"Edges:=", <ArrayOfEdgeIDs>,
"Radius:=", <value>,
"Setback:=", <value>))

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

Python Fillet ([ <ObjectName> <FilletParameters> ])


Syntax

Python oEditor.Fillet
Exampl-

3D Modeler Editor Script Commands 10-100


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

([
Array("Name:Selections", "Selections:=",
_
"Box1"), Array("NAME:Parameters", Array("NAME:Fil-
letParameters",
e _
"CoordinateSystemID:=", -1, "Edges:=", Array(13),
"Radius:=", _
"1mm", "Setback:=", "0mm"))
])

FlattenGroup
Use: Flattens a specified history tree group.
Command: Modeler>Group>Flatten
Syntax: FlattenGroup Array("Groups:=", Array("<GroupID>"))
Return Value: None
Parameters: <GroupID>,
The ID for the history tree groups to flatten.

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project44")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")

3D Modeler Editor Script Commands 10-101


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oEditor.Ungroup Array("Groups:=", Array("Group1"))


GenerateHistory
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: Click Modeler>Model Healing>Heal
Syntax:HealObject <parameters>
Return Value:None
Parameters:Array("NAME:Selections",
"Selections:=", "<objectID>",
"NewPartsModelFlag:=", ["Model" | "NonModel"]),
Array("NAME:ObjectHealingParameters",
"Version:=", 1,
"AutoHeal:=", <boolean>,
"TolerantStitch:=", <boolean>,
"SimplifyGeom:=", <boolean>,
"TightenGaps:=", <boolean>,
"StopAfterFirstStitchError:=", <boolean>,
"MaxStitchTol:=", <smallvalue>,
"ExplodeAndStitch:=", <boolean>,
"GeomSimplificationTol:=", <value>,
"MaximumGeneratedRadiusForSimplification:=", <value>,
"SimplifyType:=", 2,
"TightenGapsWidth:=", <value>,
"RemoveSliverFaces:=", <boolean>,
"RemoveSmallEdges:=", <boolean>,
"RemoveSmallFaces:=", <boolean>,

3D Modeler Editor Script Commands 10-102


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"SliverFaceTol:=", <value>,
"SmallEdgeTol:=", <value>,
"SmallFaceAreaTol:=", <value>,
"BoundingBoxScaleFactor:=", <value>,
"RemoveHoles:=", <boolean>,
"RemoveChamfers:=", <boolean>,
"RemoveBlends:=", <boolean>,
"HoleRadiusTol:=", <value>,
"ChamferWidthTol:=", <value>,
"BlendRadiusTol:=", <value>,
"AllowableSurfaceAreaChange:=", <value>,
"AllowableVolumeChange:=", <value>)

VB 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,
"SimplifyType:=", 2,
"TightenGapsWidth:=", 1E-006,

3D Modeler Editor Script Commands 10-103


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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)

Python HealObject (<parameters>)


Syntax

oEditor.HealObject
([
Array("NAME:Selections",
"Selections:=", "Box1",
"NewPartsModelFlag:=", "Model"),

Python Array("NAME:ObjectHealingParameters",
Example "Version:=", 1,
"AutoHeal:=", false,
"TolerantStitch:=", true,
"SimplifyGeom:=", true,
"TightenGaps:=", true,
"StopAfterFirstStitchError:=", false,

3D Modeler Editor Script Commands 10-104


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"MaxStitchTol:=", 0.001,
"ExplodeAndStitch:=", true,
"GeomSimplificationTol:=", -1,
"MaximumGeneratedRadiusForSimplification:=", -1,
"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)
])

GetActiveCoordinateSystem
Get active coordinate system.
Command: None.
Syntax: GetActiveCoordinateSystem
Return Value: Active coordinate name.
Parameters: None.
VB Example:
Dim csName

3D Modeler Editor Script Commands 10-105


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

csName = oEditor.GetActiveCoordinateSystem

Python Syn- GetActiveCoordinateSystem([])


tax

Python oEditor.GetActiveCoordinateSystem([])
Example

GetCoordinateSystems
Get coordinate system names.
Command: None
Syntax: GetCoordinateSystems
Return Value: An array of coordinate system names
Parameters: None
VB Example:
Dim csNames
csNames = oEditor.GetCoordinateSystems ()

Import
Imports a 3D model file.
Command: Modeler>Import
Syntax: Import <ImportParametersArray>
Return Value: None
Parameters: <ImportParametersArray>
Array("NAME:NativeBodyParameters",
"CoordinateSystemID:=", <ID>,
"HealOption:=", <integer>,
"HealSTL":=, <integer>,
"CheckModel:=", <boolean>,
"Options:=", "",
"FileType:=", "UnRecognized",

3D Modeler Editor Script Commands 10-106


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"MaxStitchTol:=", <value>,
"SourceFile:=", "string")

For Q3D Extractor the Import command details are as follows:


Imports a 3D model file.
Command: Modeler>Import
Syntax: Import <ImportParametersArray>
Return Value: None
Parameters: <ImportParametersArray>
Array("NAME:NativeBodyParameters",
"AutoHeal:=", <bool>,
"Options:=", <string>,
VB Example: oDesign.Import("SourceFile:=", <string>)

Example STL to HFSS


Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project7")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.Import Array("NAME:NativeBodyParameters", "HealOption:=", 0,
"Options:=", "-1", "FileType:=", "UnRecognized", "MaxStitchTol:=", -
1,

3D Modeler Editor Script Commands 10-107


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"ImportFreeSurfaces:=", false, "GroupByAssembly:=", false,


"CreateGroup:=", true, "STLFileUnit:=", _
"Auto", "MergeFacesAngle:=", 0.02, "HealSTL:=", true,
"PointCoincidenceTol:=", 1E-06, "CreateLightweightPart:=", false,
"ImportMaterialNames:=", false,_
"SeparateDisjointLumps:=", false, _
"SourceFile:=", _
"D:\ANSYS Electronics Desktop Projects\TeeModelforSpaceClaim.stl")

Python Syn- Import (<ImportParametersArray>)


tax

oEditor = oDesign.SetActiveEditor("3D Modeler")


oEditor.Import(
[
"NAME:NativeBodyParameters",
"HealOption:=" , 0,
"Options:=" , "-1",
"FileType:=" , "UnRecognized",
"MaxStitchTol:=" , -1,
"ImportFreeSurfaces:=" , False,
Python "GroupByAssembly:=" , False,
Example
"CreateGroup:=" , True,
"STLFileUnit:=" , "Auto",
"MergeFacesAngle:=" , 0.02,
"HealSTL:=" , True,
"PointCoincidenceTol:=" , 1E-06,
"CreateLightweightPart:=", False,
"ImportMaterialNames:=" , False,
"SeparateDisjointLumps:=", False,
"SourceFile:=" , "D:\\ANSYS Electronics Desktop Pro-
jects\\TeeModelforSpaceClaim.stl"

3D Modeler Editor Script Commands 10-108


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

])

ImportDXF
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>",

3D Modeler Editor Script Commands 10-109


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"paint:=", <boolean>),
Array("NAME:TechFileLayers", "layer:=",
Array("name:=", "ground",
"color:=", "purple",
"elev:=", 0,
"thick:=", 0.0001),
)))
oEditor.Import Array("NAME:NativeBodyParameters",
"CoordinateSystemID:=", -1,
"HealOption:=", <integer>,
"CheckModel:=", <boolean>,
"Options:=", "",
"FileType:=", "UnRecognized",
"MaxStitchTol:=", <real>,
"SourceFile:=", "<path>" & ".sm3")

VB 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,

3D Modeler Editor Script Commands 10-110


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"CheckModel:=", true,
"Options:=", "",
"FileType:=", "UnRecognized",
"MaxStitchTol:=", 0.001,
"SourceFile:=", "C:design." & ".sm3")

Python Syn- ImportDXF (<ImportParametersArray>)


tax

oEditor.ImportDXF ([
Array("NAME:options", "FileName:=",
_
"C:/mymodel.dxf", ...
Array("NAME:TechFileLayers", ...
Python "layer:=", Array("name:=", "BOTTOMLAYER",
Example
"color:=", "purple",
"elev:=", 0,
"thick:=", 200),
)))
])

ImportGDSII [Modeler Import]


Imports a GDSII 3D model file.
Command: Modeler>Import
Syntax: ImportGDSII <ImportParametersArray>
Return Value: None
Parameters:
"FileName:=", "<string>",
"NodeConversionType:=", "<string>",
"MaxLayerNumber:=", <integer>,
"ApproxPolyToCircle:=", <boolean>,

3D Modeler Editor Script Commands 10-111


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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"))))

3D Modeler Editor Script Commands 10-112


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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

VB 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
Moves the named ObjectCS to the end of the History tree.

UI Access Modeler > Coordinate System > Move CS to End.

Name Type Description


Parameters < objectCSname> Structured Array The Object Coordinate System
name.

Return Value None.

3D Modeler Editor Script Commands 10-113


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python MoveCStoEnd (<objectCSname>)


Syntax

Python oEditor.MoveCSToEnd(['NAME:Selections', 'Selections:=',


Examp- 'ObjectCS1'])
le

VB MoveCStoEnd <objectCSname>
Syntax

Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
VB
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Exam-
ple 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")

MoveEntityToGroup
Use: Moves a specified entity to an existing history tree group.
Command: None.
Syntax: MoveEntityToGroup Array("Groups:=", Array("<entityID>")),
Array("ParentGroup:=", "<target_GroupID>")
Return Value: None
Parameters: <entityID>,
The ID for the models or groups to become part of the parent history tree group.
<target_GroupID>"
The parent history tree ID.

3D Modeler Editor Script Commands 10-114


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Groups:=, " "

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project44")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.MoveEntityToGroup Array("Groups:=", Array("Box_Group1")), _
Array("ParentGroup:=", "Box_Group")
MoveFaces
Moves the specified faces along normal or along a vector.

Modeler > Surface > Move Faces > Along Normal or


UI Access
Modeler > Surface > Move Faces > Along Vector

Name Type Description


MoveFacesParametersArray Array ("NAME:Parameters",
<FacesOfOneObjToMove>,
<FacesOfOneObjToMove>, ...)

Para- Contents of FacesOfOneObjToMove


meters are described below.
FacesOfOneObjToMove Array Array("Name:MoveFacesPara-
meters",

"MoveAlongNormalFlag:=",
<bool>,

3D Modeler Editor Script Commands 10-115


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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 is an array of integers
(the IDs of the faces to move)

Return None
Value

Python MoveFaces (<SelectionsArray>, <MoveFacesParametersArray>)


Syntax

oEditor.MoveFaces(
[
"NAME:Selections",
"Selections:=" , "Rectangle1",
"NewPartsModelFlag:=" , "Model"
],
[
"NAME:Parameters",
Python [
Example "NAME:MoveFacesParameters",
"MoveAlongNormalFlag:=" , True,
"OffsetDistance:=" , "1mm",
"MoveVectorX:=" , "0mm",
"MoveVectorY:=" , "0mm",
"MoveVectorZ:=" , "0mm",
"FacesToMove:=" , [183]
]
])

3D Modeler Editor Script Commands 10-116


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax MoveFaces <SelectionsArray>, <MoveFacesParametersArray>


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

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

UI Acce- Click Modeler > Surface > Project Sheet.


ss

Name Type Description


< argSelec- Struc- 'NAME:Selec-
tions> tured tions','Selections:=','<Obj1>,<Obj2>,<Obj2>'
Para-
meters Array
< argPara- Struc- 'NAME:ProjectSheetParameters'
meters> tured
Array

Return None.
Value

Python ProjectSheet (<argSelections>, <argParameters>)

3D Modeler Editor Script Commands 10-117


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax

oEditor.ProjectSheet(

Python ['NAME:Selections','Selections:=','Box1,Box2,Polyline1'],
Example ['NAME:ProjectSheetParameters']
)

VB Syn- ProjectSheet <argSelections> <argParameters>


tax

Set oDesign = oProject.SetActiveDesign("HFSSDesign1")


Set oEditor = oDesign.SetActiveEditor("3D Modeler")
VB
Exampl- oEditor.ProjectSheet Array("NAME:Selections", "Selec-
e tions:=",
"Box1,Box2,Polyline1"),
array("NAME:ProjectSheetParameters")

PurgeHistory
Use:Purges the construction history of the selected object. For complex objects this simplifies the
object and can improve modeler speed.
Command:Click Modeler>Purge History
Syntax:PurgeHistory <PurgeHistoryArray>
Return Value:None
Parameters:<PurgeHistoryArray>
Array("Name:Selections",
"Selections:=", <string>,
"NewPartsModelFlag:=", ["Model" | "NonModel"])
Selections
Name of the object to purge.
NewPartsModelFlag
Flag to indicate model properties, Model or NonModel.
VB Example:
oEditor.PurgeHistory Array("NAME:Selections", _
"Selections:=", "Polygon1", "NewPartsModelFlag:=", "Model")

3D Modeler Editor Script Commands 10-118


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python PurgeHistory (<PurgeHistoryArray>)


Syntax

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

ReplaceWith3DComponent
Use: Replace selection with a 3D component
Command: Replace with 3D Component
Syntax: ReplaceWith3DComponent <Geometry Data>, <Design Data>, <File Name>, <Image
File>
Return Value: None
Parameters: < Geometry Data>
Geometry data
< Design Data>
Design data
< File Name>
File name of 3D component
< Image File>
File name of 3D component image
VB Example:
oEditor.ReplaceWith3DComponent Array("NAME:CreateData", "Com-
ponentName:=", _
"ConnectorOnly_wBCs", "Company:=", "", "Company URL:=", "", "Model
Number:=", "", "Help URL:=", _
"", "Version:=", "1.0", "Notes:=", "", "IconType:=", "", "Own-
er:=", _

3D Modeler Editor Script Commands 10-119


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"MyName", "Email:=", "[email protected]", "Date:=", "3:07:37 PM Jun 25,


2019", _
"HasLabel:=", false, "IsEncrypted:=", false, "AllowEdit:=",
false,_
"SecurityMessage:=", "", "Password:=", "", "EditPassword:=", "", _
"PasswordType:=", "UnknownPassword", "HideContents:=", true,
"ReplaceNames:=", true, _
"ComponentOutline:=", "None", "IncludedParts:=", _
Array("pin", "solderl", "ConnectorDielectric", _
"ConnectorOuter", "pcap", "solderr"), "HiddenParts:=", Array(), _
"IncludedCS:=", Array(), "ReferenceCS:=", _
"Global", "IncludedParameters:=", Array("lcon", "lpin", "rpin"), _
"ParameterDescription:=", Array("lcon:=", "", "lpin:=", "",
"rpin:=", ""), "IsLicensed:=", false, _
"LicensingDllName:=", "", "VendorComponentIdentifier:=", _
"", "PublicKeyFile:=", ""), Array("NAME:DesignData", "Bound-
aries:=", Array( _
"PinSurface", "Connect"), "Excitations:=", Array("1", "2"),
"MeshOperations:=", Array( _
"Length1", "SkinDepth1")), "", Array("NAME:ImageFile",
"ImageFile:=", "")

Python Syn- ReplaceWith3DComponent (<Geometry Data>, <Design Data>, <File Name>,


tax <Image File>)
oEditor.ReplaceWith3DComponent(
[
"NAME:ReplaceData",
"ComponentName:=" , "CoaxBend",
Python
"Company:=" , "",
Example
"Company URL:=" , "",
"Model Number:=" , "",
"Help URL:=" , "",
"Version:=" , "1.0",

3D Modeler Editor Script Commands 10-120


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Notes:=" , "",
"IconType:=" , "",
"Owner:=" , "Emily",
"Email:=" , "[email protected]",
"Date:=" , "3:46:31 PM Dec 26, 2018",
"HasLabel:=" , False,
"IncludedParts:=" , ["out-
er","teflon","inner","teflon_1"],
"HiddenParts:=" , [],
"IncludedCS:=" , [],
"ReferenceCS:=" , "Global",
"IncludedParameters:=" , ["bend_angle"],
"ParameterDescription:=", [ "bend_angle:=" , ""]
],
[
"NAME:DesignData",
"Excitations:=" , ["1","2"]
],
[
"NAME:ImageFile",
"ImageFile:=" , ""
])

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>)

3D Modeler Editor Script Commands 10-121


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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
Parameters: <SelectionsArray>
Selections:=",<objectNames>"
"NewPartsModelFlag:=", ["Model" | "NonModel"]
Indicates the type of model properties in the geometry - Model or Non Model.
VB Example:
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.SeparateBody Array("NAME:Selections",
"Selections:=", "Rectangle1,Circle1",
"NewPartsModelFlag:=", "Model")

Python Syn- SeparateBody (<SelectionsArray>)


tax

oEditor.SeparateBody
([
Python Array("NAME:Selections",
Example "Selections:=", "Rectangle1,Circle1",
"NewPartsModelFlag:=", "Model")
])

SetModelUnits
Use: Sets the model units.
Command: Modeler>Units
Syntax: SetModelUnits <ModelUnitsParametersArray>

3D Modeler Editor Script Commands 10-122


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.
ShowWindow
Opens the selected 3D model editor window.
Syntax: ShowWindow
Return Value: None
Parameters: None
VB Example:
Set oDesign = oProject.GetActiveDesign
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.ShowWindow

Python Syn- ShowWindow()


tax

Python oEditor.ShowWindow()

3D Modeler Editor Script Commands 10-123


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Example

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"
Possible values for 2D XY Designs are "YZ", "ZX".
Possible values for 2D RZ Designs are "XY", "YZ".
WhichSide
Side to keep. Possible values are "Both", "PositiveOnly", "NegativeOnly"
Subtract
Use: Subtracts specified objects.
Command: Modeler->Boolean->Subtract
Syntax: Subtract <SubtractSelectionsArray>,
<SubtractParametersArray>
Return Value: None
Parameters: <SubtractSelectionsArray>
Array("NAME:Selections",
"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"

3D Modeler Editor Script Commands 10-124


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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>)
VB Example:
oEditor.Subtract _
Array("NAME:Selections", _
"Blank Parts:=", "Polygon1",_
"Tool Parts:=", "Box1"),_
Array("NAME:SubtractParameters", _
"KeepOriginals:=", false)

Python Syn- Subtract(<SubtractSelectionsArray>, <SubtractParametersArray>)


tax

oEditor.Subtract(
[
("NAME:Selections",
"Blank Parts:=", "Polygon1",
Python
"Tool Parts:=", "Box1"),
Example

("NAME:SubtractParameters",
"KeepOriginals:=", false)
])

SweepFacesAlongNormal
Sweep a face along normal.

UI Acce- Modeler > Surface > Sweep Faces Along Normal


ss

3D Modeler Editor Script Commands 10-125


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name Type Description


selections Array Array("NAME:Selections",
"Selections:=", "<faceID>",
"NewPartsModelFlag:=", ["Model" |
"NonModel"]),
Para- parameters Array Array("NAME:Parameters",
meters
"NAME:Sweep-
FaceAlongNormalToParameters",
"FacesToDetach:=", <faceIDarray>,
"LengthOfSweep:=",
"<value><units>")

Return None
Value

Python Syn- SweepFacesAlongNormal(<selections> <parameters>)


tax

oEditor.SweepFacesAlongNormal(
[
"NAME:Selections",
"Selections:=" , "Rectangle1",
"NewPartsModelFlag:=" , "Model"
],

Python [
Example "NAME:Parameters",
[
"NAME:SweepFaceAlongNormalToParameters",
"FacesToDetach:=" , [183],
"LengthOfSweep:=" , "0.1mm"
]
])

3D Modeler Editor Script Commands 10-126


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax SweepFacesAlongNormal <selections> <parameters>


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

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

UI Access Modeler > Surface > Thicken Sheet

Name Type Description


Selections <Array> ID of the object
NewPartsModelFlag <value> Model or Nonmodel
Parameters
SheetThickenParameters> Array
Thickness> <value><units> Value and units
BothSides> Boolean True or False

Return Value None.

Python Syn- Thicken Sheet (<SelectionParameters> <SheetThickenParameters>)


tax

oEditor.ThickenSheet(
[

Python "NAME:Selections",
Example
"Selections:=" , "Box1_ObjectFromFace1",
"NewPartsModelFlag:=" , "Model"
],

3D Modeler Editor Script Commands 10-127


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

[
"NAME:SheetThickenParameters",
"Thickness:=" , "0.01mm",
"BothSides:=" , True
])

VB Syntax Thicken Sheet <SelectionParameters> <SheetThickenParameters>


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

UncoverFaces
Uncovers specified faces.
Command: Modeler>Surface>Uncover Faces
Syntax: UncoverFaces <SelectionsArray>, <UncoverParametersArray>
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.

3D Modeler Editor Script Commands 10-128


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- UncoverFaces (<SelectionsArray>, <UncoverParametersArray>)


tax

oEditor.UncoverFaces(
[
"NAME:Selections",
"Selections:=" , "Box1_ObjectFromFace1",
"NewPartsModelFlag:=" , "Model"
],
Python
Example
[
"NAME:Parameters",
[
"NAME:UncoverFacesParameters",
"FacesToUncover:=" , [39]
]
])

VB Syntax UncoverFaces <SelectionsArray>, <UncoverParametersArray>


oEditor.UncoverFaces _
Array("NAME:Selections", "Selections:=", _
"Box3,Box2"),_

VB Array("NAME:Parameters", _
Example 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

3D Modeler Editor Script Commands 10-129


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters: <UniteParametersArray>
Array("NAME:UniteParameters",
"KeepOriginals:=", <bool>)
Ungroup
Ungroups a specified history tree group.

UI Access Modeler > Group > Ungroup

Name Type Description


Parameters < Groups> Structured The name of the group or groups to ungroup.
Array

Return Value None

Python Ungroup()
Syntax

oEditor.Ungroup(

Python [
Example
"Groups:=" , ["armature_Group","Group1"]
])

VB Syn- Ungroup
tax

Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
VB
Dim oEditor
Example
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow

3D Modeler Editor Script Commands 10-130


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oProject = oDesktop.SetActiveProject("Project44")


Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.Ungroup Array("Groups:=", Array("Group1"))

WrapSheet
Wraps a sheet object to another object.

UI Access None.

Name Type Description


< argSelections> Structured Array "NAME:Selections", "Selections:=",
Parameters "< SheetID>,< ObjectID>"
< argParameters> Structured Array "NAME:WrapSheetParameters",
"Imprinted:=", < Boolean>

Return None.
Value

Python WrapSheet (<argSelections>, <argParameters>)


Syntax

oEditor.WrapSheet(

Python ["NAME:Selections", "Selections:=","Rectangle1,Box1"],


Example ["NAME:WrapSheetParameters", "Imprinted:=", True]
])

VB WrapSheet <argSelections> <argParameters>


Syntax

Dim oAnsoftApp
Dim oDesktop
VB Dim oProject
Examp-
le Dim oDesign
Dim oEditor
Dim oModule

3D Modeler Editor Script Commands 10-131


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")


Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project3")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.WrapSheet Array("NAME:Selections", "Selections:=",
"Rectangle1,Box1"), Array("NAME:WrapSheetParameters",
"Imprinted:=",
_
true)

Other oEditor Commands


AddViewOrientation
BreakUDMConnection
ChangeProperty
Delete
FitAll
GetBodyNamesByPosition
GetChildNames [Modeler]
GetChildOjbect [Modeler]
GetChildTypes [Modeler]
GetEdgeByPosition
GetEdgeIDsFromObject
GetEdgeIDsFromFace
GetEntityListIDByName
GetFaceArea
GetFaceByPosition
GetFaceCenter
GetFaceIDs
GetModelBoundingBox

3D Modeler Editor Script Commands 10-132


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetObjectIDByName
GetObjectName
GetObjectNameByFaceID
GetObjectsByMaterial
GetObjectsInGroup
GetMatchedObjectName
GetModelUnits
GetNumObjects
GetPropNames [Modeler]
GetSelections
GetVertexIDsFromEdge
GetVertexIDsFromFace
GetVertexIDsFromObject
GetVertexPosition
GetUserPosition
OpenExternalEditor
PageSetup
RenamePart
SetPropValue [Modeler]
AddViewOrientation
Creates a new orientation using a script. The command you to use predefined view names or cre-
ate a user defined View Orientation that supports the Orientation parameter for the
ExportModelImageToFile script command. Parameters can be in either Vector or Input angle
format, as shown in the Update View Orientation dialog accessed by the View>Modify Attrib-
utes>Orientation List... command.

3D Modeler Editor Script Commands 10-133


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access View > Modify Attributes > Orientation List

OrientationName Type Description


Parameters Top, Bottom, Right, Left, Front, Back, String Orientation name.
Trimetic, Dimetric, Isometric, <user-
Defined>

Return Value None.

3D Modeler Editor Script Commands 10-134


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Py- AddViewOrientation(<orientationName>, <isGlobal>, <orientationParams>, [pro-


th- jectionParams])
on
Sy-
nt-
ax

oEditor.AddViewOrientation(orientationName, isGlobal, ori-


entationParams, [optional]projectionParams)
# orientationParams can be specified either using angles:
[
"NAME:OrientationAngles",
"Psi:=" , 30,
"Theta:=" , 60,
"Phi:=" , 90
])
# Or vectors:

Py- [
th- "NAME:VectorComponents",
on
Ex- [
a-
m- "NAME:Direction",
pl-
e -0.726043283939362,
-0.214442044496536,
-0.653357207775116
],
[
"NAME:Up",
-0.620335400104523,
-0.205735266208649,
0.75687313079834
]
]

3D Modeler Editor Script Commands 10-135


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

# projectionParams can be specified using "Scaling", "Trans-


lation", "ProjectionType" and "ProjectionLimits" in which all
are optional:
[
"NAME:ProjectionParams",
[
"NAME:Scaling",
61539101600647,
61539089679718,
615390717983246
],
[
"NAME:Translation",
140740811824799,
198991596698761,
-6.16659688949585
],
"ProjectionType:=" , "Orthographic",
[
"NAME:ProjectionLimits",
-0.89195191860199,
295922607183456,
-0.104839414358139,
601647555828094,
-1.50278854370117,
9826126098633
]
]

BreakUDMConnection
Break a current UDM connection to SpaceClaim.

3D Modeler Editor Script Commands 10-136


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access Break Connection

Name Type Description


Parameters
Array Selections

Return Value

Python Syn- BreakUDMConnection (<Array>)


tax

oEditor.BreakUDMConnection(
[
Python
"NAME:Selections",
Example
"Selections:=" , "SpaceClaim1"
])

VB Syn- BreakUDMConnection <Array>


tax

VB oEditor.BreakUDMConnection Array("NAME:Selections",
Example "Selections:=", "")

ChangeProperty
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:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor

3D Modeler Editor Script Commands 10-137


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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:Geo-
metry3DCmdTab",
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:Geo-
metry3DCmdTab", Array("NAME:PropServers",
"Polyline2:CreatePolyline:1"),
Array("NAME:ChangedProps",
Array("NAME:Bend Type", "Value:=", "Corner"))))

ChangeProperty([<NAME:AllTabs>, [<NAME:Geometry3DCmdTab>,
Python Syn-
tax
[<NAME:PropServers>, <ObjectName:CommandName>],
[<NAME:ChangedProps>, [<NAME:BendType>, <Value>]]]])
oEditor.ChangeProperty(
[
"NAME:AllTabs",

Python [
Example
"NAME:Geometry3DCmdTab",
[
"NAME:PropServers",
"Polyline2:CreatePolyline:1"

3D Modeler Editor Script Commands 10-138


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

],
[
"NAME:ChangedProps",
[
"NAME:Bend Type",
"Value:=", "Corner"
]
]
]
])

Delete
Use: Deletes specified objects, coordinate systems, points, planes, etc.
Command: None
Syntax: Delete <SelectionsArray>
Return Value: None
FitAll
Fits the design to the modeling area.

UI Access View > Fit All > All Views

Name Type Description


Parameters
None.

Return Value None.

Python Syn- FitAll()


tax

Python oEditor.FitAll()
Example

VB Syn- FitAll()
tax

3D Modeler Editor Script Commands 10-139


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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


Example oEditor.FitAll()

GetBodyNamesByPosition
Gets the object names that contact the given point.

UI Access NA

Name Type Description


<positionParameters> Array Name of the object
Parameters Xposition:= <value> value of the X position
Yposition:= <value> value of the Y position
Zposition:= <value> value of the Z position

Return Value The list of object names

Python GetBodyNamesByPosition ()
Syntax

oProject = oDesktop.GetActiveProject()
oDesign = oProject.GetActiveDesign()
oEditor = oDesign.SetActiveEditor("3D Modeler")
list_of_bodies = oEditor.GetBodyNamesByPosition(
[
Python "NAME:Parameters",
Example
"XPosition:=","0mm",
"YPosition:=","15mm",
"ZPosition:=","0mm"
])
print(list_of_bodies)

VB Syn- GetBodyNamesByPosition(<positionParameters>)
tax

3D Modeler Editor Script Commands 10-140


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oEditor.GetBodyNamesByPosition(Array("NAME:Parameters", _

VB "XPosition:=", "a", _
Example "YPosition:=", "0mm", _
"ZPosition:=", "0mm"))

GetChildNames [Modeler]
Use: Gets child names of queried model objects.
Syntax: GetChildNames()
Return Value: Returns names of children for the queried object History tree.
Parameters: Implicit or specific name of Project object or object category.

Python Syn- GetChildNames ()


tax

oProject = oDeskTop.GetActiveProject()
oDesign = oProject.GetActiveDesign()
oModel = oDesign.GetChildObject(“3D Modeler”)
oModel.GetChildTypes()
Returns an array containing the different types of child objects.
['ModelParts', 'AllParts', 'NonModelParts', 'Coordin-
ateSystems', 'Points', 'Planes', 'SubmodelDefinitions',
'Groups', 'Lists']
oModel.GetChildNames('ModelParts')
Returns Model Parts
Python
Example ['WG_Interior', 'WG', 'MT_Interior', 'MT', 'Box2',
'Cylinder1', 'RegularPolyhedron1', 'Polyline1',
'Polyline2', 'RegularPolyhedron1_Detach1', 'Polyline2_
Detach1', 'Polyline2_ObjectFromEdge1']
oModel.GetChildNames('NonModelParts')
Returns NonModel parts, if any.
oModel.GetChildNames("AllParts")
Returns all parts.
['WG_Interior', 'WG', 'MT_Interior', 'MT', 'Box2',
'Cylinder1', 'RegularPolyhedron1', 'Polyline1',
'Polyline2', 'RegularPolyhedron1_Detach1', 'Polyline2_
Detach1', 'Polyline2_ObjectFromEdge1']

3D Modeler Editor Script Commands 10-141


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModel.GetChildNames(“CoordinateSystems”)
Returns Coordinate Systems
oModel.GetChildNames(“Points”)
Returns all the points
[‘Point1’]
oModel.GetChildNames(‘Planes’)
Returns all the planes in the model
['Global:XY', 'Global:YZ', 'Global:XZ', 'EndCS:XY',
'EndCS:YZ', 'EndCS:XZ', 'aEndCS:XY', 'aEndCS:YZ',
'aEndCS:XZ', 'bEndCS:XY', 'bEndCS:YZ', 'bEndCS:XZ',
'cEndCS:XY', 'cEndCS:YZ', 'cEndCS:XZ', 'FaceCS1:XY',
'FaceCS1:YZ', 'FaceCS1:XZ', 'Plane1', 'ObjectCS1:XY',
'ObjectCS1:YZ', 'ObjectCS1:XZ']
oModel.GetChildNames(‘SubModelDefinitions”)
Returns all the subModel definitions in the model
['Straight', 'MagicTee']
oModel.GetChildNames(“Groups”)
Returns all the groups in the model
['Group1', 'Group2', 'Group3']
oModel.GetChildNames(“Lists”)
Returns all the Lists
['AllObjects', 'Objectlist1', 'Facelist1']

GetChildObject [Modeler]
Returns the ChildObject in the active model, or specified object values.

Note:

GetChildObject will return normally if there are no active objects.

UI Access NA

Name Type Description


Parameters
"3D Modeler"

3D Modeler Editor Script Commands 10-142


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Returns the object of the 3D Modeler to a specified variable, for example,


Return Value
oModel

Python Syn- GetChildObject()


tax

oDesign = oProject.GetActiveDesign()
oModel = oDesign.GetChildObject(“3D Modeler”)
oModel.GetChildTypes()
Returns:
['ModelParts', 'AllParts', 'NonModelParts', 'Coordin-
ateSystems', 'Points', 'Planes', 'SubmodelDefinitions',
'Groups', 'Lists']

oModel.GetChildNames(“ModelParts”)
Returns:
['WG_Interior', 'WG', 'MT_Interior', 'MT', 'Box2',
Python 'Cylinder1', 'RegularPolyhedron1', 'Polyline1',
Example 'Polyline2', 'RegularPolyhedron1_Detach1', 'Polyline2_
Detach1', 'Polyline2_ObjectFromEdge1']
oWGi = oModel.GetChildObject(“WG_Interior”)
Returns object of WG_Interior to variable WGi
oWGi.GetPropNames()
Returns property names from ChildObject assigned to WGi
['Name', 'Material', 'Material/SIValue', 'Mater-
ial/EvaluatedValue', 'Solve Inside', 'Orientation',
'Orientation/Choices', 'Model', 'Display Wireframe',
'Material Appearance', 'Color', 'Color/Red', 'Col-
or/Green', 'Color/Blue', 'Transparent']

VB Syntax GetChildObject
VB Set oDesign = oProject.GetActiveDesign()

3D Modeler Editor Script Commands 10-143


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Example Model = oDesign.GetChildObject(“3D Modeler”)

GetChildTypes [Modeler]
Use: Gets child types of queried designs or editors obtained by GetActiveProjects() and GetAct-
iveDesigns() commands.
Syntax: GetChildTypes()
Return Value: Returns type of children for the queried object.

Python Syn- GetChildTypes ()


tax

oprj=oDesktopGetActiveProject()
oprj.GetName()
'Project1'
oprj.GetChildNames()
['HFSSDesign1']
oprj.GetChildTypes()

Python ['Design', 'Variable']


Example

odes=GetActiveDesign()
odes=Get.ChildNames()
['Optimetrics', 'Radfield', 'Results', '3D Modeler']
odes.getChildTypes()
['Module', 'Editor', 'Variable']

GetEdgeByPosition
Gets the edge ID corresponding to position input.
Syntax: GetEdgeByPosition(<PositionParameters>)
Return Value: Returns an integer edge ID.
Parameters: <PositionParameters>
Array("NAME:EdgeParameters", _
"BodyName:=", <string>,
"Xposition:=", <value>,

3D Modeler Editor Script Commands 10-144


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"YPosition:=", <value>,
"ZPosition:=", <value>)
For 2D XY Designs, ZPosition should be set to "0".
For 2D RZ Designs, YPosition should be set to "0".
VB Example:
oEditor.GetEdgeByPosition(Array("NAME:EdgeParameters", _
"BodyName:=", "Box1", "XPosition:=", "3.4mm", _
"YPosition:=", "2.8mm", "ZPosition:=", "0.4mm"))

Pyt- GetEdgeByPosition ([<PositionParameters>])


ho-
n
Sy-
nta-
x

Pyt- oEditor.GetEdgeByPosition
ho-
n (["NAME:EdgeParameters", "BodyName:=", "Box1", "XPosition:=",
Ex- "3.4mm", "YPosition:=", "2.8mm", "ZPosition:=", "0.4mm"
am-
ple
])

GetEdgeIDsFromFace
Get the edge IDs for a given face ID.
Command: None
Syntax: GetEdgeIDsFromFace <Face ID>
Return Value: An array of edge IDs
Parameters: <FaceID>
ID of the face
VB Example:
Dim oEdgeIDs
oEdgeIDs = Array()
oEdgeIDs = oEditor.GetEdgeIDsFromFace(10)

3D Modeler Editor Script Commands 10-145


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- GetEdgeIDsFromFace (<Face ID>)


tax

Python oEditor.GetEdgeIDsFromFace("10")
Example

GetEdgeIDsFromObject
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
VB Example: Example:
Dim oEdgeIDs
oEdgeIDs = Array()
oEdgeIDs = oEditor.GetEdgeIDsFromObject("Box1")

Python Syn- GetEdgeIDsFromObject (<Object Name>)


tax

Python oEditor.GetEdgeIDsFromObject("Box1")
Example

GetEntityListIDByName
Where oObjectList is the name of the entity list (can be object or face), GetEntityListIDByName
(oObjectList) returns a list of IDs in that list
Command: None
Syntax: GetEntityListIDByName( <ObjectList>
Return Value: A list of IDs.
Parameters: <ObjectList>
Names of the objects
VB Example: Example:
Dim oObjectList

3D Modeler Editor Script Commands 10-146


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oObjectList = oEditor.CreateEntityList(Array("NAME:Geo-
metryEntityListParameters", "EntityType:=", _
"Object", "EntityList:=", "Box1, Cylinder1"), Array("NAME:At-
tributes", "Name:=", _
"Objectlist1"))
MsgBox(oObjectList)
Dim oObjectID
oObjectID = oEditor.GetEntityListIDByName(oObjectList)
MsgBox(oObjectID)
Dim oFaceList
oFaceList = oEditor.CreateEntityList(Array("NAME:Geo-
metryEntityListParameters", "EntityType:=", _
"Face", "EntityList:=", Array(12, 35)), Array("NAME:Attributes",
"Name:=", _
"Facelist1"))
MsgBox(oFaceList)
Dim oFaceID
oFaceID = oEditor.GetEntityListIDByName(oFaceList)
MsgBox(oFaceID)

Python Syn- GetEntityListIDByName (<Object List>)


tax

Python oEditor.GetEntityListIDByName(oObjectList)
Example

GetFaceArea
Get area of given face ID.
Command: None.
Syntax: GetFaceArea <face ID>
Return Value: Double value for face area.
Parameters: <FaceID>
Face ID
VB Example:

3D Modeler Editor Script Commands 10-147


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oArea
oArea = oEditor.GetFaceArea(10)

Python Syn- GetFaceArea (<face ID>)


tax

Python oEditor.GetFaceArea("10")
Example

GetFaceCenter
Given a planar face ID, return the center position.
Command: none
Syntax: GetFaceCenter <FaceID>
Return Value: An array containing planar face center position
Parameters: <PlanarFaceID>
VB Example:
Dim oFaceCenter
oFaceCenter = oEditor.GetFaceCenter(oFaceID)

Python Syn- GetFaceCenter (<PlanarFace ID>)


tax

Python oEditor.GetFaceCenter(oFaceID)
Example

GetFaceByPosition
Gets the face id corresponding to position input.
Syntax: GetFaceByPosition(<FaceByPositionParametersArray>)
Return Value: Returns an integer face id
Parameters: (<FaceByPositionParametersArray>)
Array("NAME:FaceParameters",
"BodyName:=", <string>,
"XPosition:=", <value>,
"YPosition:=", <value>,
"ZPosition:=", <value>)

3D Modeler Editor Script Commands 10-148


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

For 2D XY Designs, ZPosition should be set to "0".


For 2D RZ Designs, YPosition should be set to "0".
BodyName
Name of the body on which the point lies.
The point should be on exactly one face, not at a vertex or edge where two or more faces
join. And the coordinates must be on the face.
VB Example:
Dim faceid
faceid = oEditor.GetFaceByPosition(Array("NAME:FaceParameters", _
"BodyName:=" "Box1", "XPosition:=", "3.4mm", "YPosition:=, _
"2.8mm", "ZPosition:=", "0.4mm"))

Python Syn- GetFaceByPosition ([(<FaceByPositionParametersArray>)])


tax

top_face_id = oEditor.GetFaceByPosition(["NAME:FacePara-
meters",
"BodyName:=", "Box",
Python
Example "XPosition:=", "0mm",
"YPosition:=", "0mm",
"ZPosition:=", "100mm"])

GetFaceIDs
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
VB Example:
Dim oFaceIDs
oFaceIDs = Array()
oFaceIDs = oEditor.GetFaceIDs("Box1")

3D Modeler Editor Script Commands 10-149


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- GetFaceIDs (<Object Name>)


tax

Python oEditor.GetFaceIDs("Box1")
Example

GetGeometryModelerMode
Returns the modeler mode (3D or XY) for the current design. This lets you know whether the cur-
rent model is 2D or 3D.

UI Access NA
Parameters None.
Return Value String containing the modeling mode.

Python Syn- GetGeometryModelerMode()


tax

Python oEditor.GetGeometryModelerMode()
Example

VB Syntax GetGeometryModelerMode()
oEditor.GetGeometryModelerMode()
VB Example

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.
VB Example:
objectnames = oEditor.GetMatchedObjectName("Box*")

3D Modeler Editor Script Commands 10-150


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- GetMatchedObjectName(<ObjectNameWildcardText>)


tax

Python oEditor.GetMatchedObjectName("Box*")
Example

GetModelBoundingBox
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
VB Example:
Dim oBoundingBox
oBoundingBox = oEditor.GetModelBoundingBox()

Python Syn- GetModelBoundingBox ([ ])


tax

Python oEditor.GetModelBoundingBox([])
Example

GetModelUnits
Use: Get the model units.
Command: None.
Syntax: GetModelUnits
Return Value: A string contains current model units.
Parameters: None.
VB Example:
Dim oUnit
oUnit = oEditor.GetModelUnits()

Python Syn- GetModelUnits([])


tax

Python oEditor.GetModelUnits([])
Example

3D Modeler Editor Script Commands 10-151


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetPropNames [Modeler]
Returns the property names for the active model object, or specified property values.

UI Access NA

Name Type Description


Parameters
Model Object String

Returns the property names of the current 3D Model object. If you specify
Return Value
"False" returns all property names that can be changed.

Python Syn- GetPropNames()


tax

oRh1 = oModel.GetChildObject("Box1")
oRh1.GetPropNames()
Returns:
Python
Example ['Name', 'Material', 'Material/SIValue', 'Mater-
ial/EvaluatedValue', 'Solve Inside', 'Orientation',
'Orientation/Choices', 'Model', 'Group', 'Display Wire-
frame', 'Material Appearance', 'Color', 'Color/Red',
'Color/Green', 'Color/Blue', 'Transparent']

VB Syntax GetPropNames()
Rh1 = oDesign.GetChildObject(“Box1”)
GetPropName("Rh1")
Returns
VB Example
['Name', 'Material', 'Material/SIValue', 'Mater-
ial/EvaluatedValue', 'Solve Inside', 'Orientation',
'Orientation/Choices', 'Model', 'Group', 'Display Wire-
frame', 'Material Appearance', 'Color', 'Color/Red',
'Color/Green', 'Color/Blue', 'Transparent']

GetPropValue [Modeler]
Returns the property value for the active model object, or specified property values.

3D Modeler Editor Script Commands 10-152


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access NA

Name Type Description


Parameters propPath a child object's property path. See property
path discussion here.

Return Value The property value of a child object

Python Syn- GetPropValue(propPath)


tax

oRh1 = oModel.GetChildObject("Box1")
oRh1.GetPropNames()
Returns:
['Name', 'Material', 'Material/SIValue', 'Mater-
ial/EvaluatedValue', 'Solve Inside', 'Orientation',
Python
'Orientation/Choices', 'Model', 'Group', 'Display Wire-
Example
frame', 'Material Appearance', 'Color', 'Color/Red',
'Color/Green', 'Color/Blue', 'Transparent']
oBox2.GetPropValue("Orientation")
Returns the specified Property Value:
'Global'

VB Syntax GetPropValue()
Rh1 = oDesign.GetChildObject(“Box1”)
VB Example
GetPropValue("Orientation")

GetNumObjects
Gets the number of objects in a design.

UI Access NA

Name Type Description


Parameters
None

Return Value the number of objects

3D Modeler Editor Script Commands 10-153


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- GetNumObjects()


tax

Python oEditor.GetNumObjects()
Example

VB Syntax GetNumObjects()
VB Example totalobjects = oEditor.GetNumObjects()

GetObjectIDByName
Use: Get Object IDs to provide for CreateEntityList.
Syntax: GetObjectIDByName("<objectName>")
Return Value: <Object ID>
Parameters: <objectName>
Type: <string>
VB Example:
oObjectID = oEditor.GetObjectIDByName("Box2")

Python Syn- GetObjectIDByName("<objectName>")


tax

Python oEditor.GetObjectIDByName("Box2")
Example

GetObjectName
Use: Gets an object name corresponding to the 0 base index of the creation order.
Syntax: GetObjectName(<Index>)
Return Value: Returns the object name of the corresponding object.
Parameters: <Index>
Type: <string>
The 0 base index of the creation order
VB Example:
objectname = oEditor.GetObjectName(3)

3D Modeler Editor Script Commands 10-154


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- GetObjectName(<Index>)


tax

Python oEditor.GetObjectName("3")
Example

GetObjectNameByFaceID
Gets an object name corresponding to the input face id.

UI Access NA

Name Type Description


Parameters
<FaceID> integer value ID of the face

Return Value the name of the corresponding object.

Python Syn- GetObjectNameByFaceID ()


tax

Python oEditor.GetObjectNameByFaceID(88)
Example

VB Syntax GetObjectNameByFaceID (<FaceID>)


VB objectname = oEditor.GetObjectNameByFaceID(10)
Example

GetObjectsByMaterial
Use:Get objects by material name.
Command:None.
Syntax:GetObjectsByMaterial <Material Name>
Return Value:An array of object names.
Parameters:<Material Name>
Type: <string>
Material name/
VB Example:
Dim objNames
objNames = oEditor.GetObjectsByMaterial("vacuum")

3D Modeler Editor Script Commands 10-155


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- GetObjectsByMaterial (<Material Name>)


tax

Python oEditor.GetObjectsByMaterial("vacuum")
Example

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"
VB Example:
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
Dim oObject
Dim oObjects
Set oObjects = oEditor.GetObjectsInGroup( "Sheets" )
For Each oObject in oObjects
MsgBox oObject
Next

Python Syn- GetObjectsInGroup (<GroupName>)


tax

Python oEditor.GetObjectsInGroup("Sheets")
Example

GetPropertyValue
Gets the value of a single property belonging to a specific serverName and PropTab. This function
is available with the Project, Design or Editor objects, including definition editors.
Use the script recording feature and edit a property, and then view the resulting script to
see the format for that property.

3D Modeler Editor Script Commands 10-156


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access NA

Name Type Description


<propTab> String One of the following, where tab titles
are shown in parentheses:
PassedParameterTab ("Parameter
Values")
DefinitionParameterTab (Para-
meter Defaults")
LocalVariableTab ("Variables" or
"Local Variables")
ProjectVariableTab ("Project vari-
ables")

Parameters ConstantsTab ("Constants")


BaseElementTab ("Symbol" or
"Footprint")
ComponentTab ("General")
Component("Component")
CustomTab ("Intrinsic Variables")
Quantities ("Quantities")
Signals ("Signals")
<propServer> String An object identifier, generally returned from
another script method, such as Comp-
Inst@R;2;3
<propName> String Name of the property.

Return Value  String, the value of the property.

Python GetPropertyValue (<propTab>, <serverName>, <propName>)


Syntax

selectionArray = oEditor.GetSelections()
for k in selectionArray:
Python
Exampl- val = oEditor.GetPropertyValue("PassedParameterTab", k,
e "R")
...

3D Modeler Editor Script Commands 10-157


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB GetPropertyValue (<propTab>, <serverName>, <propName>)


Syntax

selectionArray = oEd-
itor.GetSelections

for each k in selectionArray

VB
Examp-
val = oEditor.GetPropertyValue("PassedParameterTab", k,
le
"R")

...

next

Python Syn- GetPropertyValue ([ <array>])


tax

oModule = oDesign.GetModule("ReportSetup")
Python
Example oModule.GetPropertyValue("Trace", "S Parameter Plot
1:dB(S(1,1))","Y Axis")

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

VB Example:value_string = _
oEditor.GetPropertyValue("BaseElementTab",_
"rect_1", "Name")

Example: (Query frequency and excitation)


freq = oDesign.GetPropertyValue("General", "AnalysisSetup:Setup1",
"Adaptive Freq")

3D Modeler Editor Script Commands 10-158


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

sigType = oDesign.GetPropertyValue("Q3D", "BoundarySetup:via_1",


"Type")
sourceType = oDesign.GetPropertyValue("Q3D", "Bound-
arySetup:Source1", "Type")

Example: (Query Trace values in a specified report)


oModule = oDesign.GetModule("ReportSetup")
oModule.GetPropertyValue("Trace", "S Parameter Plot 1:dB(S(1,1))","Y
Axis")
GetSelections [Model Editor]
Use: Informational.
Syntax: GetSelections
Return Value: Array of IDs.
Parameters: None
VB 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.

3D Modeler Editor Script Commands 10-159


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax: GetUserPosition(<PositionInputPrompt>)
Return Value: Array of coordinates
Parameters: <PositionInputPrompt>
Type: <string>
VB Example:
Dim position
Dim coord
position = oEditor.GetUserPosition("Enter a point")
For Each coord in position
Msgbox(coord)
Next

Python Syn- GetUserPosition(<PositionInputPrompt>)


tax

Python oEditor.GetUserPosition("Enter
Example a point")

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.
VB Example:
Dim oVertexIDs
oVertexIDs = Array()
oVertexIDs = oEditor.GetVertexIDsFromEdge(10)

3D Modeler Editor Script Commands 10-160


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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
VB Example:
Dim oVertexIDs
oVertexIDs = Array()
oVertexIDs = oEditor.GetVertexIDsFromFace(10)

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
VB Example:
Dim oVertexIDs
oVertexIDs = Array()
oVertexIDs = oEditor.GetVertexIDsFromObject("Box1")

GetVertexPosition
Use: Returns a vector of vertex coordinates.
Syntax: GetVertexPosition(<VertexID>)
Return Value: Vector of coordinates
Parameters: <VertexID>
Type: <vector>

3D Modeler Editor Script Commands 10-161


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Example:
position = oEditor.GetVertexPosition(VertexIDs(0))

OpenExternalEditor
Launch a SpaceClaim session.

Model >SpaceClaim Geometry Object> Launch SpaceClaim in the history


UI Access
tree.

Name Type Description


Parameters
Array Selections

Return Value

Python Syn- OpenExternalEditor (<Array>)


tax

oEditor.OpenExternalEditor(
[
Python
"NAME:Selections",
Example
"Selections:=" , "SpaceClaim1"
])

VB Syn- OpenExternalEditor <Array>


tax

VB oEditor.OpenExternalEditor Array("NAME:Selections",
Example "Selections:=", "")

PageSetup
Use: Specifies the page settings for printing.
Command: File>Page Setup
Syntax: PageSetup <PageSetupParametersArray>
Return Value: None
Parameters: <PageSetupParametersArray>
Array("NAME:PageSetupData",

3D Modeler Editor Script Commands 10-162


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"margins:=",
Array("left:=", <value>,
"right:=", <value>,
"top:=", <value>,
"bottom:=", <value>))
RenamePart
Renames an object.

UI Access Enter new name in Name field.

Name Type Description


renameParametersArray Structured Array "NAME:Rename Data", "Old
Parameters Name:=", <oldNameString>,
"New Name:=",
<newNameString>

Return None.
Value

Python Syn- oEditor.RenamePart()


tax

oEditor.RenamePart(
[
'NAME:Rename Data',
Python
'Old Name:=', 'partname',
Example
'New Name:=', 'newpartname',
]
)

VB Syn- oEditor.RenamePart()
tax

Dim oEditor
VB
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
Example
oEditor.RenamePart Array("NAME:Rename Data",

3D Modeler Editor Script Commands 10-163


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Old Name:=", "partname",


"New Name:=", "newpartname",
)

SetPropValue [Modeler]
Sets the property value for the active model property.

UI Access Edit Properties on History Tree objects

Name Type Description


propPath a child object's property path. See property
Parameters path discussion here.
Model Property new property value
Value

Return Value True if the property is found and the new value is valid. Otherwise return False.

Python Syn- SetPropValue(propPath)


tax

oRh1 = oModel.GetChildObject("Box1")
oRh1.GetPropNames()
Returns:
['Name', 'Material', 'Material/SIValue', 'Mater-
ial/EvaluatedValue', 'Solve Inside', 'Orientation',
'Orientation/Choices', 'Model', 'Group', 'Display Wire-
frame', 'Material Appearance', 'Color', 'Color/Red',
'Color/Green', 'Color/Blue', 'Transparent']
oPt1.GetPropNames(False)
Python
Example Returns all Prop names that can be set.
['Name', 'Color', 'Color/R', 'Color/G', 'Color/B', 'Pos-
ition', 'Position/X', 'Position/Y', 'Position/Z']

oBox1.GetPropValue("Color/R")
Returns the specified Property Value:
143
oBox1.SetPropValue(“Color/r”,111)

3D Modeler Editor Script Commands 10-164


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax GetPropValue()
VB Example SetPropValue(“Color/r”,111)

3D Modeler Editor Script Commands 10-165


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

10-166
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

11 - 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 output variable commands.
Set oModule = oDesign.GetModule("OutputVariable")
oModule.CommandName <args>
List of commands are as follows:
CreateOutputVariable
DeleteOutputVariable
DoesOutputVariableExist
EditOutputVariable
GetOutputVariableValue
SimValueContext

CreateOutputVariable
Different forms of this command are documented for HFSS, Q3D Extractor and Schematic and
Layout Editors.

UI Access [product]>Results>Output Variables

Name Type Description


<OutputVarName> String Name of the output variable
<Expression> Value Value to assign to the variable
<SolutionName> String The name of the solution as seen in the output
Parameters variable UI.
<reportTypeName String The name of the report type as seen in the out-
> put variable UI.
<simValueCtxt> Variant Context for which the output variable expres-
sion is being evaluated.

Return Value None

Python CreateOutputVariable (<OutputVarName>, <Expression>, <Solution Name>,


Syntax <reportTypeName>, <simValueCtxt>)

Python
oModule = oDesign.GetModule("OutputVariable")
Exampl- oModule.CreateOutputVariable ("test", "normalize(R1_0.V)",
e _

Output Variable Script Commands 11-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"TR", "Standard", ["NAME:Context", "SimValueContext:=", _


[ 1, 0, 2, 0, false, false, -1, 1, 0, 1, 1, "", 0, 0]])

VB CreateOutputVariable <OutputVarName>, <Expression>, <Solution Name>,


Syntax <reportTypeName>, <simValueCtxt>
Set oModule = oDesign.GetModule("OutputVariable")
oModule.CreateOutputVariable "test", "normalize(R1_0.V)", _
VB
Exampl- "TR", "Standard", Array("NAME:Context", "SimValueCon-
e text:=", _
Array( 1, 0, 2, 0, false, false, -1, 1, 0, 1, 1, "", 0, 0))

Command details for HFSS are as follows:


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 or other
operators in it. The definitions cannot 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 >

Output Variable Script Commands 11-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.
VB Example:
Set oModule = oDesign.GetModule("OutputVariable")
oModule.CreateOutputVariable "test","mag(S(WavePort1,WavePort1))", _
"Setup1 : LastAdaptive", "Modal Solution Data", _
Array("Domain:=", "Sweep")

For Layout Editor the CreateOutputVariable syntax and other details are as follows:

Syntax: CreateOutputVariable "<varName>", <Expression>, <SolutionName>, <SolutionType>,


<Domain>
Return Value: None
Parameters: <VarName>
Type: <string>
Name of the output variable.

<Expression>
Type: <value>
Value to assign to the variable.

<SolutionName>
Type: <string>
Name of the solution as listed in the output variable UI.
For example: "Setup1 : Last Adaptive"

<ReportTypeName>

Output Variable Script Commands 11-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type: <string>
The name of the report type as seen in the output variable UI.

<SimValueContext>
Type: <variant>
Context for which the output variable expression is being evaluated. For more inform-
ation see SimValueContext.

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


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

oModule.CreateOutputVariable "Var_" & OutputQuantity,_


OutputQuantity, Solution, "Far Fields", _
Array("Context:=", InfiniteSphere, "Domain:=", "Sweep")

For Q3D Extractor or a 2D Extractor the command and example are as follows:
Command: Q3D Extractor or 2D Extractor>Results>Output Variables
VB Example: Set oModule = oDesign.GetModule("OutputVariable") oMod-
ule.CreateOutputVariable "char_Z", _ "sqrt(ACL(via:via_source,vi-
a:via_source)/C(via,GroundPlane))", _ "Setup1 : LastAdaptive",
"Matrix", Array("Context:=", "Original")

DeleteOutputVariable
Deletes an existing output variable. The variable can only be deleted if it is not in use by any traces.

UI Access [product]>Results>Output Variables, dialog Delete Button

Name Type Description


Parameters
<OutputVarName> String Name of the output variable

Return Value None

Output Variable Script Commands 11-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn-  DeleteOutputVariable (<OutputVarName>)


tax

Python
oModule = oDesign.GetModule("OutputVariable")
Example oModule.DeleteOutputVariable ("testNew")

VB Syntax  DeleteOutputVariable <OutputVarName>

VB
Set oModule = oDesign.GetModule("OutputVariable")
Example oModule.DeleteOutputVariable "testNew"

For Q3D Extractor, the DeleteOutputVariable command details are as follows.


Deletes an existing output variable. The variable can only be deleted if it is not in use by any traces.
Command: Delete command in the Output Variables dialog box. Click Q3D Extractor or 2D
Extractor>Results>Output Variables to open the Output Variables dialog box.
Syntax: DeleteOutputVariable <VarName>
Return Value: None
Parameters: <VarName>
Type: <string>
Name of the output variable.
VB Example: Set oModule = oDesign.GetModule("OutputVariable")
oModule.DeleteOutputVariable "Var_" & OutputQuantity

DoesOutputVariableExist
Verify that a named output variable exists.

UI Access NA

Name Type Description


Parameters
<outputVariableName> String Text string of the output variable name

Boolean
Return Value
True if the variable exists. False otherwise.

Python Syn- DoesOutputVariableExist(<outputVariableName>)


tax

Output Variable Script Commands 11-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oProject = oDesktop.GetActiveProject()
oDesign = oProject.GetActiveDesign()
Python
Example oModule = oDesign.GetModule("OutputVariable")
oModule.DoesOutputVariableExist("MyTestVar")

VB Syntax DoesOutputVariableExist(<outputVariableName>)
Set oProject = oDesktop.GetActiveProject()
Set oDesign = oProject.GetActiveDesign()
VB
Example Set oModule = oDesign.GetModule("OutputVariable")
Set oModule.DoesOutputVariableExist("MyTestVar")

EditOutputVariable
Changes the name or expression of an existing output variable.

UI Access NA

Name Type Description


<OrigVarName> String Name of the original output variable.
<NewExpression> String New value to assign to the variable.
<NewVarName> String New name of the variable if any, else pass
empty string.
<SolutionName> String Name of the solution as seen in
the output variable UI.
Parameters
For example: "Setup1 : Last
Adaptive"
<ReportTypeName> String The name of the report type as seen in the
output variable UI
<ContextArray> Variant Context for which the output vari-
able expression is being evaluated
Array("Context:=", <Context>)

Return Value None

Python EditOutputVariable (<OrigVarName>, <NewExpression>, <NewVarName>,


Syntax <SolutionName>, <reportTypeName>, <ContextArray>)

Output Variable Script Commands 11-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModule = oDesign.GetModule("OutputVariable")
Python
oModule.EditOutputVariable ("test",
Example
"normalize(R1_0.V)", "testNew", "TR", "Standard", [])

VB Syn- EditOutputVariable <OrigVarName>, <NewExpression>, <NewVarName>, <Solu-


tax tionName>, <reportTypeName>, <ContextArray>
Set oModule = oDesign.GetModule("OutputVariable")
VB
oModule.EditOutputVariable "test",
Example
"normalize(R1_0.V)", "testNew", "TR", "Standard", Array()

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

For Q3D Extractor, the EditOutputVariable command details are as follows.


Changes the name or expression of an existing output variable.
Syntax: EditOutputVariable <OrigVarName> <NewExpression> <NewVarName> <Soult-
ionName> <SolutionType> <ContextArray>
Provide empty quotes "" as the NewVarName or NewExpression if it should not be
changed.
Return Value: None
Parameters: <OrigVarName>
Type: <string>
Original name of the variable.
<NewExpression>
Type: <value>
New value to assign to the variable.
<NewVarName>
Type: <string>
New name of the variable if any, or else pass an empty string.

Output Variable Script Commands 11-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<SolutionName>
Type: <string>
Name of the solution as seen in the output variable UI.
For example: "Setup1 : Last Adaptive"
<SolutionType>
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.
VB Example: oModule.EditOutputVariable "char_Z", _ "sqrt(ACL
(via:via_source,via:via_source)/C(via,via))", "char_Z", _ "Setup1 :
LastAdaptive", "Matrix", Array("Context:=", "Original")

GetOutputVariableValue
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.
Different forms of this command are documented for HFSS, Q3D Extractor as well Schematic and
Layout Editors.

UI Access NA

Name Type Description


<OutputVarName> String Name of the output variable.
<IntrinsicVariation> String A set of intrinsic variable value
pairs to use when evaluating the
output expression.
Example: "Freq='20GHz' Theta-
='20deg' Phi='30deg' in HFSS
Parameters
"" in Q3D Extractor
<SolutionName> String Name of the solution as listed in the output
variable UI.
<ReportTypeName> String The name of the report type as seen in the
output variable UI.
<ContextArray> Array Context for which the output vari-
able expression is being eval-
uated. This can be empty if there is

Output Variable Script Commands 11-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

no context.

Return Value Double value of the output variable .

Pytho- GetOutputVariableValue(<OutputVarName>, <IntrinsicVariation>, <SolutionName>,


n Syn- <ReportTypeName>, <ContextArray>
tax

Pytho- Val = oModule.GetOutputVariableValue("test","Freq = '20Ghz'


n Theta='20deg'
Exam- Phi='30deg'", "TR", "Standard", [])
ple

GetOutputVariableValue(<OutputVarName>, <IntrinsicVariation>, <Solu-


VB Syntax
tionName>, <ReportTypeName>, <ContextArray>)
Val = oModule.GetOutputVariableValue
VB
("test","Freq = '20Ghz' Theta='20deg'
Example
Phi='30deg'", "TR", "Standard", Array())

For HFSS, the command details are as follows:


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>
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>

Output Variable Script Commands 11-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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 HFSS 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"
<ContextArray>
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 special-sweep value is
outside the range the Reporter does not do extrapolation. Rather it issues an error mes-
sage indicating values outside the available range for a primary sweep.
Example:
Array("Context:=","Infinite Sphere1")
or Array("Context:=","Polyline1")
or Array()
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule

Output Variable Script Commands 11-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim var1
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project1")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("OutputVariable")
var1 = oModule.GetOutputVariableValue("p", "freq='1GHz'", _
"Setup1 : LastAdaptive", "Modal Solution Data", Array())
msgbox (var1)

VB Example:
' -----------------------------------------------------------
' Sample script to get output variable values
' -----------------------------------------------------------
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("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
Set projects = oDesktop.GetProjects()
Set oProject = projects(0)
Set oDesign = oProject.GetDesign ("HfssDesign1")

Output Variable Script Commands 11-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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", _
"Setup1 : LastAdaptive", _
"Freq='1GHz'",_
"Modal Solution Data", _
Array())

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

Output Variable Script Commands 11-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Distance='1mm'
"Setup1 : LastAdaptive", _
Freq='1GHz'", _
"Fields", _
Array("Context:=", "Polyline1", "PointCount:=", 3 ) _
)
MsgBox( "2 val " & FormatNumber(val) )

For HFSS Layout and Schematic Editor the command details are as follows:
Syntax: GetOutputVariableValue(<OutputVarName>, <VariationKey>, <SolutionName>,
<ReportType>, <ContextArray>)
Return Value: Double value of the output variable .
Parameters: <OutputVarName>
Type: <string>
Name of the output variable.

<VariationKey>
Type: <string>
Example: " ’F=’20GHz’ x_size=’1.0in’ "

<SolutionName>
Type: <string>
Name of the solution as listed in the output variable UI.
For example: "Setup1 : Last Adaptive"

<ReportType>
Type: <string>
Possible values are:
"Standard" - For most plot types.
"Load Pull" - For load pull plots.

Output Variable Script Commands 11-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Constellation" - For constellation plots.


"Data table" - For data tables.
"Eye Diagram" - For eye diagrams.
"Statistical" - For statistical plots.

<ContextArray>
Type: Array
Context for the output variable. For more information see SimValueContext.

VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("MyTransientProject")
Set oDesign = oProject.SetActiveDesign("Nexxim1")
Set oModule = oDesign.GetModule("OutputVariable")
val1=oModule.GetOutputVariableValue("vout", "MyTransientSetup",
"time='3.9462ns'", "Standard", _
Array("NAME:Context", "SimValueContext:=", Array(1, 0, 2, 0, false,
false, -1, 1, 0, 1, 1, "", 0, 0)))
MsgBox val1

VB Example:
Dim oAnsoftApp
Dim oDesktop

Output Variable Script Commands 11-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("MyLNAExample")
Set oDesign = oProject.SetActiveDesign("Nexxim1")
Set oModule = oDesign.GetModule("OutputVariable")
val1=oModule.GetOutputVariableValue("magS", _
"LinearFrequency", "F='1GHz'", "Standard", _
Array("NAME:Context", "SimValueContext:=", _
Array(3, 0, 2, 0, false, false, -1, 1, 0, 1, 1, "", 0, 0)))
MsgBox val1

For Q3D Extractor, the GetOutputVariableValue command details are as follows:


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>, <VariationKey>, <SolutionName>,
<ReportType>, <ContextArray>)
Return Value: Double value of the output variable .
Parameters: <OutputVarName>
Type: <string>
Name of the output variable.
<VariationKey>
Type: <string>
Example: "Freq=’20GHz’ x_size=’1.0in’"
<SolutionName>
Type: <string>

Output Variable Script Commands 11-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name of the solution as listed in the output variable UI.


For example: "Setup1 : Last Adaptive"
<ReportType>
Type: <string>
Possible values are:
"Matrix"
"C Fields Report"
"DC R/L Fields Report"
"AC R/L Fields Report"
<ContextArray>
Type: Array
Context for which the output variable expression is being evaluated. This can be empty if
there is no context.
Example:
Array("Context:=","Original")
or Array("Context:=","Polyline1")
or Array()
VB Example:
Set oModule = oDesign.GetModule("OutputVariable")
Dim Val
Val=oModule.GetOutputVariableValue("OutVarTest",_ Freq=’500MHz’
"Setup1 : LastAdaptive", "Matrix", _
Array ("Context:= ",Original" ))

SimValueContext
SimValueContext holds context information for a trace, and describes how data for a trace should
be extracted from the simulation. SimValueContext contains a list of 14 required initial values:

SimValueContext (
Domain ID, Calculation Type, Number of Cycles, Rise Time,
Step, Impulse, Context ID, Window Width,
Window Type, TDR Kaiser Parameter, Hold Time, DeviceName,
TDR Step Time, DR Maximum Time )

Output Variable Script Commands 11-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

For example, the following indicates a trace in the Time Domain, Standard Calculation with the
number of cycles being 2:
"SimValueContext:=", Array(1, 0, 2, 0, false, false, -1, 1, 0, 1, 1,
"", 0, 0)
Additional, context-specific values may follow the required values, as described in subsection 15
below.
1. Domain ID

No Domain 0
Time Domain 1
Spectrum Domain 2
Sweep Domain 3
Device Domain 4
SinglePt Domain 5
LoadPull Domain 6
Transient Domain 7
Budget Domain 8
NetworkFunction Domain 9
Oscillator Domain 55802
Noise Domain 55803
Transfer Function Domain 55807
Time Frequency Domain 55808
Transient Time Domain 55809
Periodic AC Domain 55818
UI Domain 55819
Eye Measurement Domain 55823
Initial Response Domain 55824
Peak Distortion Domain 55825

2. Calculation Type

Standard Calculation 0
Device2_DCIV 1
Device3_DCIV_Output 2

Output Variable Script Commands 11-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Device3_DCIV_Input 3
Device3_DCIV_Transfer 4
Device3_DCIV_Reverse 5
Device2_ACLoad 6
Device3_ACLoad_Output 7
Device3_ACLoad_Input 8
Device3_ACLoad_Transfer 9
Device3_ACLoad_Reverse 10
Constellation 11
EyeDiagram 12
FreeX ( Statistic Report ) 13

3. Number of Cycles — Used in Time Domain in HarmonicBalance analysis.


4. Rise Time — Not used by Designer/Nexxim.
5. Step — Not used by Designer/Nexxim.
6. Impulse — Not used by Designer/Nexxim.
7. Context ID — Not used by Designer/Nexxim.
8. Window Width — Not used by Designer/Nexxim.
9. Window Type — Not used by Designer/Nexxim.
10. TDR Kaiser Parameter — Not used by Designer/Nexxim.
11. Hold Time — Not used by Designer/Nexxim.
12. DeviceName — Not used by Designer/Nexxim.
13. TDR Step Time — Not used by Designer/Nexxim.
14. TDR Maximum Time — Not used by Designer/Nexxim.
15. Context-specific values — Used in Time Domain in HarmonicBalance analysis.

Context-specific values are entered in the format "key, true/false, keyvalue", where:
— "key" is the name of the key being set.
— "true/false" indicates whether the key is a string value.
— "keyvalue" is the value of the key.
— The order of the context keys is not significant.
— Context keys have software defaults that will be used if not provided in the script.

Output Variable Script Commands 11-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Example:
"SimValueContext:=", Array(1, 0, 2, 0, false, false, -1, 1, 0, 1, 1,
"", 0, 0,
"DE", false, "0",
"DP", false, "20000000",
"DT", false, "0.001",
"WE", false, "10ns",
"WM", false, "10ns",
"WN", false, "0ns",
"WS", false, "0ns"))

a. Plotting Range for Time domain in Transient and QuickEye analysis:

Description Key Name Is a string? Key Value


Start Time WS False 0ns
Stop Time WE False 10ns
Minimum Time WM False 0ns
Maximum Time WN False 10ns
Is Thinning Enabled? DE False 0
Dy/dx Tolerance DT False 0.001
Number of points DP False 20000000

b.Transient report context for Spectral domain in Transient analysis:

Description Key Name Is a string? Key Value


Start Time TS False 0ns
Stop Time TE False 10ns
Max Harmonics MH False 100
Window type WT False 0
Width Percentage WW False 100
Kaiser Parameter KP False 0
Adjust Coherent Gain CG False 0

Output Variable Script Commands 11-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Window Type ID
Rectangular 0
Bartlett 1
Blackman 2
Hamming 3
Hanning 4
Kaiser 5
Welch 6
Weber 7
Lanzcos 8

c. Eyeprobe index context for UI domain, Time domain, Eye Measuremant domain in Veri-
fEye and QuickEye analysis:

Description Key Name Is a string? Key Value


Eyeprobe compinst ID PCID False 0

d. Eyesource index context for Initial Response domain and Peak Distortion domain in
VerifEye and QuickEye analysis:

Description Key Name Is a string? Key Value


Eyesource compinst ID SCID False 0

e. UI domain context in VerifEye and QuickEye analysis:

Description Key Name Is a string? Key Value


Use midpoint? MIDPOINT False 0 - Don't use midpoint.
1 - Use midpoint of amplitude.
2 - Use midpoint of UI.
Minimum latch overdrive MLO False 0

Output Variable Script Commands 11-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

f. Distribution Context for UI Domain in VerifEye and QuickEye analysis:

Description Key Name Is a string? Key Value


Use distribution? USE_DIST False 0 - No
1 - Yes
Distribution type DIST False 0 - Receiver Jitter
1 - Receiver Noise
2 - User Defined

Receiver Jitter Parameters

Description Key Name Is a string? Key Value


DLL standard deviation DSD False 0
Distribution type DIST False 0
DLL taps DMN False 0
Static Offset SOFF False 0
Number of Gaussian data sets NUMG False 0
Gaussian std deviation GS0,GS1... False 0
Offset mean GM1,GM1... False 0
Number of Uniform data sets NUMU False 0
Uniform width UW0,UW1... False 0
Uniform mean UM1,UM1... False 0

Receiver Noise Parameters

Description Key Name Is a string? Key Value


Number of Gaussian data sets NUMG False 0
Gaussian std deviation GS0,GS1... False 0
Number of Uniform data sets NUMU False 0
Uniform width UW0,UW1... False 0

Output Variable Script Commands 11-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

User Defined Parameters

Description Key Name Is a string? Key Value


Number of XY data pairs NUMG False 0
X data X0,X1,X2... False 0
Y data Y0,Y1,Y2... False 0
Cutoff probability CP False 0

Output Variable Script Commands 11-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

12 - 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")

Another example of accessing this object in Q3D Extractor is:


Set oDesign = Project.SetActiveDesign("Q3DDesign1")
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:

When you execute Tools>Record Script, operations performed in the Reporter are
automatically recorded.

The list of commands is as follows:


AddCartesianLimitLine
AddCartesianXMarker
AddCartesianYMarker
AddDeltaMarker
AddMarker
AddNote
AddTraces
ClearAllMarkers
ClearAllTraceCharacteristics
CopyTracesData
CopyReportData
CopyReportDefinitions

Reporter Editor Script Commands 12-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

CopyTraceDefinitions
CreateReport
CreateReportFromFile
CreateReportFromTemplate
CreateReportOfAllQuantities
DeleteMarker
DeleteAllReports
DeleteReports
DeleteTraces
FFTOnReport
ExportImageToFile
ExportPlotImageToFile
ExportToFile
ExportMarkerTable
GetAllCategories
GetAllQuantities
GetAllReportNames
GetAvailableDisplayTypes
GetAvailableReportTypes
GetAvailableSolutions
GetChildObject [Reporter]
GetChildNames [Reporter]
GetChildTypes [Reporter]
GetDataExpressions
GetDataUnits
GetDesignVariableNames
GetDesignVariableUnits
GetDesignVariableValue
GetDesignVariationKey
GetDisplayType

Reporter Editor Script Commands 12-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetImagDataValues
GetPerQuantityPrimarySweepValues
GetPropertyValue
GetPropNames [Reporter]
GetRealDataValues
GetSolutionContexts
GetSolutionDataPerVariation
GetSweepNames
GetSweepUnits
GetSweepValues
GroupPlotCurvesByGroupingStrategy
ImportIntoReport
IsDataComplex
IsPerQuantityPrimarySweep
MovePlotCurvesToGroup
MovePlotCurvesToNew
PasteReport
PasteTraces
ReleaseData
RenameReport
RenameTrace
ResetPlotSettings
SavePlotSettingsAsDefault
SetPropValue [Reporter]
UpdateAllFieldsPlots
UpdateAllReports
UpdateQuantityFieldsPlots
UpdateReports
UpdateTrace
UpdateTracesContextandSweeps

Reporter Editor Script Commands 12-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UnGroupPlotCurvesInGroup

AddCartesianLimitLine
Adds a limit line to a report on the X axis.

UI Access Report2D>Add Limit Line

Name Type Description


<ReportName> String Name of Report
<XValues> Real Array of X coordinate values
Parameters
<XUnits> String Unit of measure for X values
<YValues> Real Array of Y coordinate values
<YUnits> String Unit of measure for Y values
<YAxisName> Real Name of the Y axis associated with the limit
line

Return Value None

AddCartesianLimitLine <ReportName>, [("NAME:CartesianLimitLine",


Python
Syntax
[("NAME:XValues",<XValues>)], "XUnits:=", "<XUnits>", [("NAME:YValues",
<YValues>)], "YUnits:=", "<YUnits>", "YAxis:=", "<YAxisName>"])
oModule.AddCartesianLimitLine("Project Outputs",
["NAME:CartesianLimitLine",

Python ["NAME:XValues",0, 2, 5, 7, 10, 15]


Example "XUnits:=", "s"
["NAME:YValues",0.05, 0.3, 0.65, 0.825, 0.95, 1],
"YUnits:=", "mV", "YAxis:=", "Y1"])

   AddCartesianLimitLine <ReportName>, Array("NAME:CartesianLimitLine",


VB Syn-
Array("NAME:XValues",<XValues>), "XUnits:=", "<XUnits>", Array("NAME:YVal-
tax
ues", <YValues>), "YUnits:=", "<YUnits>", "YAxis:=", "<YAxisName>")
oModule.AddCartesianLimitLine
"Project Output
VB
Example
Array("NAME:CartesianLimitLine",
Array("NAME:XValues", 0, 2, 5, 7, 10,

Reporter Editor Script Commands 12-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

15), "XUnits:="
0.05, 0.3, 0.65, 0.825, 0.95,
1), "YUnits:=", "mV", "

AddCartesianXMarker
Adds a marker to a report on the X axis.

UI Access Report2D>Marker>Add X Marker

Name Type Description


Parameters
<ReportName> String Name of Report

Return Value None

Python AddCartesianXMarker ("<ReportName>", "<MXn>", <Xcoord>)


Syntax

Python oModule.AddCartesianXMarker ("XY Plot 1", "MX1", 0)


Example

VB Syntax AddCartesianXMarker "<ReportName>", "<MXn>", <Xcoord>


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

AddCartesianYMarker
Adds a marker to a report on the Y axis.
Command: Report2D>Marker>Add Y Marker
Syntax: AddCartesianYMarker <ReportName>, <MarkerID>, <Ycoord>
Return Value: None
Parameters: <ReportName>
Type: <string>
Name of Report.
<MarkerID>
Type: <string>
ID of the marker, for example: "Y1".

Reporter Editor Script Commands 12-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<YCoord>
Type: <real>
Y location for the marker.
VB Example:
oModule.AddCartesianYMarker "XY Plot1", "Y1", 0

Python AddCartesianYMarker ("<ReportName>", "<Yn>", <Ycoord>)


Syntax

Python oModule.AddCartesianYMarker ("XY Plot 1", "Y1", 0)


Example

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

UI Access Report2D>Marker>Add Delta Marker

Name Type Description


<ReportName> String Name of Report
Parameters
<MXn> String Name and n for the x marker
<XCoord> Real X location for the marker

Return Value None

Python AddDeltaMarker(  "  <ReportName>", "<mn>", "<traceID"> "<xcoord>" "<mn>",


Syntax "<traceID"> "<xcoord>"
oModule.AddDeltaMarker("XY Plot 1",
"m3", "GS1.VAL :
Python
Example TR4 : Cartesian", "1826000000ns",
"m4","GS1.VAL : TR4 : Cartesian", "2096000000ns")

AddDeltaMarker "<ReportName>", "<mn>", "<traceID"> "<xcoord>" "<mn>",


VB Syntax
"<traceID"> "<xcoord>"

VB
oModule.AddDeltaMarker "XY Plot 1",
Example "m3", "dB(S(LumpPort1 LumpPort1)):

Reporter Editor Script Commands 12-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Setup1 : Sweep1 : Cartesian", _ "3.22GHz", _


"m4", "dB(S(LumpPort1 LumpPort1)):
Setup1 : Sweep1 : Cartesian",_ "3.93GHz"

AddMarker
Adds a marker to a trace on a report.

UI Access Report2D>Marker>Add Marker

Name Type Description


<ReportName> String Name of Report
Parameters
<MXn> String Name and n for the x marker.
<XCoord> Real X location for the marker

Return Value None

Python AddMarker(  "  <ReportName>", "<mn>", "<traceID"> "<xcoord>")


Syntax

oModule.AddMarker("XY Plot 1", "m5",


Python
Example "GS1.VAL : TR4 : Cartesian", "3.61599999999997s")

VB Syntax AddMarker "<ReportName>", "<mn>", "<traceID"> "<xcoord>"


Set oModule = oDesign.GetModule("ReportSetup")
oModule.AddMarker "XY Plot1","m1", _
VB
Example "mag(S(Port1 Port1)) : Setup1:
LastAdaptive : Cartesian", "0.3in"

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

UI Access Right-click on the plot and select Add Note

Name Type Description


Parameters <ReportName> String Name of report
<NoteDataArray> Array Array("NAME:<NoteDataName>", <NoteAr-

Reporter Editor Script Commands 12-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ray>)
<NoteDataName> String
<NoteArray> Array Array
("NAME:<NoteDataSourceName>",
"SourceName:=", <SourceName>,
"HaveDefaultPos:=", <boolean>,
"DefaultXPos:=", <XPos>,
"DefaultYPos:=", <YPos>,
"String:=", <Note>))

Return None
Value

Python AddNote (<ReportName> <NoteDataArray>)


Syntax

oModule = oDesign.GetModule("ReportSetup")
oModule.AddNote ("XY Plot1", ["NAME:NoteDataSource",

Python ["NAME:Note-
DataSource", "SourceName:=", "Note1",
Exampl-
e "HaveDefaultPos:=", true, "DefaultXPos:=",
1996, "DefaultYPos:=", _ 3177, "String:=", "This is a
note"]]

VB Syn- AddNote <ReportName> <NoteDataArray>


tax

Set oModule = oDesign.GetModule("ReportSetup")


oModule.AddNote "XY Plot1", Array("NAME:NoteDataSource",
VB
Array("NAME:Note-
DataSource", "SourceName:=", "Note1",
Exampl-
e "HaveDefaultPos:=", true, "DefaultXPos:=",
1996, "DefaultYPos:=", _ 3177, "String:=", "This is a
note"))

Reporter Editor Script Commands 12-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

AddTraceCharacteristics
Adds a trace characteristics field to the legend on a report.
Command: Report2D>Trace Characteristics>All... for Add Trace Characteristics dialog.
Syntax: AddTraceCharacteristics <ReportName>, <TraceCharID>, Array("<sub-quantity for spe-
cific trace characteristic>"), Array(<Range>)
Return Value: None
Parameters: <ReportName>
Type: <string>
Name of Report.
<TraceCharID>
Type: <string>
ID for the trace characteristic. These are listed in the Add Trace Characteristics dialog
and the online help.

<Subquantity for some trace characteristic>


Type: <string>
Some Trace Characteristics require or more associated quantities, such as such as "fre-
quency" for "distortion". These sub-quantities are listed in the Add Trace Char-
acteristics dialog when you select a quantity that requires one. For example the

Reporter Editor Script Commands 12-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

deadtime trace characteristic requires a Tolerance quantity in addition to a Range:

<Range>
Either "Full" for the full sweep range, or "Specified", and "<start>", and "<end>" values
and units.

VB Example:
Set oModule = oDesign.GetModule("ReportSetup")
oModule.AddTraceCharacteristics "Rept2DRectFreq2", "min", Array(),
Array("Full")
VB Example:
Set oModule = oDesign.GetModule("ReportSetup")
oModule.AddTraceCharacteristics "Rept2DRectFreq", "distortion",
Array("0"), Array( "Specified", "19.5GHz", "20.4GHz")
oModule.AddTraceCharacteristics "Rept2DRectFreq2", "deadtime", Array
("0.1"), Array( "Full")

Pyth- AddTraceCharacteristics( "<ReportName>", "<CharacteristicID>", Array(),


on
Syn-
tax

Reporter Editor Script Commands 12-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Pyth-
oModule.AddTraceCharacteristics("Differential S-parameters",
on "pk2pk", [], ["Full"])
Exa- oModule.AddTraceCharacteristics("Differential S-parameters",
mple
"prms", ["0", "0"], ["Full"])

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

UI Access Modify Report>Add Trace

Name Type Description


<ReportName> String Name of Report
<SolutionName> String Name of the solution as listed in the Modify
Report dialog box.
< ContextArray> Array of Context for which the expression is
Strings being evaluated. This can be an
empty string if there is no context.
Array("Domain:=", <DomainType>)
<DomainType>
ex. "Sweep" or "Time"
Array("Context:=", <Geo-
metryType>)
<GeometryType>
ex. "Infinite Spheren", "Spheren", "Polylinen"
Parameters <FamiliesArray> Array of Contains sweep definitions for the
Strings report.
Array("<VariableName>:= ",
<ValueArray>)

<ValueArray>
Array("All") or Array("Value1", "Value2",
..."Valuen")
examples of <VariableName>
"Freq", "Theta", "Distance"
<ReportDataArray> Array of This array contains the report quant-
Strings ity and X, Y, and (Z) axis definitions.
Array("X Component:=", <Vari-
ableName>, "Y Component:=",

Reporter Editor Script Commands 12-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<VariableName> | <ReportQuant-
ityArray>)

<ReportQuantityArray>
ex. Array("dB(S(Port1, Port1))")

Return Value None

Python Add Traces (<ReportName>, <SolutionName> ,<ContextArray >,<FamiliesArray>,


Syntax <ReportDataArray>)
oModule.AddTraces ("XY Plot1", "Setup1 : Sweep1", _
["Domain:=", "Time", "HoldTime:=", 1, "RiseTime:=", 0, _
"StepTime:=", 6.24999373748E-012, "Step:=", false, _
"WindowWidth:=", 1, _
Python
"WindowType:=", 0, "KaiserParameter:=", 1, _
Exampl-
e "MaximumTime:=", 6.2437437437444E-009], _
["Time:=", ["All"], "OverridingValues:=", ["0s", _
"6.24999373748188e-012s", ... ]], ["X Component:=",
"Time",_
"Y Component:=", ["TDRZ(WavePort1)"]], [])

VB Add Traces <ReportName> <SolutionName> <ContextArray> <FamiliesArray>


Syntax <ReportDataArray>
oModule.AddTraces "XY Plot1", "Setup1 : Sweep1", _
Array("Domain:=", "Time", "HoldTime:=", 1, "RiseTime:=", 0,
_

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


Exampl-
"WindowWidth:=", 1, _
e
"WindowType:=", 0, "KaiserParameter:=", 1, _
"MaximumTime:=", 6.2437437437444E-009), _
Array("Time:=", Array("All"), "OverridingValues:=", Array

Reporter Editor Script Commands 12-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

("0s", _
"6.24999373748188e-012s", ... )), Array("X Component:=",
"Time",_
"Y Component:=", Array("TDRZ(WavePort1)")), Array()

An example for Q3D Extractor is as follows:


VB Example: oModule.AddTraces "XY Plot 1", "Setup1 : AdaptivePass",
Array("Context:=", _ "Original"), Array("Pass:=", Array("All"), "Fre-
q:=", Array("0.5GHz"), "viarad:=", Array( _ "Nominal"), "padrad:=",
Array("Nominal")), Array("X Component:=", "Pass", "Y Component:=",
Array( _"DCL(via:via_source,via:via_source)")), Array()

For Circuit, the AddTraces command has the following details.


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.
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>)

Reporter Editor Script Commands 12-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<DomainType>
ex. "Sweep" or "Time"

Array("Context:=", <SimValueContext>)
Context for the trace. For more information see SimValueContext.

<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))")
VB Example:
oModule.AddTraces "XY Plot1", "Setup1 : Sweep1", _
Array("Domain:=", "Time", "HoldTime:=", 1, "RiseTime:=", 0, _
"StepTime:=", 6.24999373748E-012, "Step:=", false, _
"WindowWidth:=", 1, _
"WindowType:=", 0, "KaiserParameter:=", 1, _

Reporter Editor Script Commands 12-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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

ChangeProperty [ReportSetup]
Change the properties for a Report.
Command: Select a Report and change properties.
Syntax: ChangeProperty <array>
Return Value: None
Parameters: Varies, depending on the properties associated with the select object command.
Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("bp_filter")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("ReportSetup")
oModule.ChangeProperty Array("NAME:AllTabs", Array("NAME:Cartesian",
Array("NAME:PropServers", _
"XY Plot 1:CartesianDisplayTypeProperty"), Array
("NAME:ChangedProps", Array("NAME:Show X Scrollbar", "Value:=", _

Reporter Editor Script Commands 12-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

true))))
oModule.ChangeProperty Array("NAME:AllTabs", Array("NAME:General",
Array("NAME:PropServers", _
"XY Plot 1:General"), Array("NAME:ChangedProps", Array("NAME:Use
Scientific Notation", "Value:=", _
true))))

Python Syn- ChangeProperty ([ <array>])


tax

oModule = oDesign.GetModule("ReportSetup")
oModule.ChangeProperty(
[
"NAME:AllTabs",
[
"NAME:General",
[
"NAME:PropServers",
"XY Plot 1:General"
Python
],
Example
[
"NAME:ChangedProps",
[
"NAME:Use Scientific Notation",
"Value:=" , True
]
]
]
])

ClearAllMarkers
Clears all markers from a report.

Reporter Editor Script Commands 12-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access Report2d>Markers>ClearAllMarkers

Name Type Description


Parameters
 <ReportName> String Name of Report

Return Value None

Python Syn- ClearAllMarkers ("<ReportName>")


tax

Python oModule.ClearAllMarkers ("XY Plot 1")


Example

VB Syntax ClearAllMarkers "<ReportName>"


VB Example oModule.ClearAllMarkers "XY Plot 1"

For Q3D Extractor the ClearAllMarkers command has the following details.
Clears all markers.
Command: Q3DExtractor>Fields>Fields>Marker>Clear All
Syntax: ClearAllMarkers
Return Value: none
Parameters: none
VB Example: Dim oAnsoftApp
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Solenoid")

Reporter Editor Script Commands 12-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oDesign = oProject.SetActiveDesign("Solenoid")


Set oModule = oDesign.GetModule("FieldsReporter")
oModule.ClearAllMarkers

ClearAllMarkers (2D Extractor)


Clears all markers from a report.
Command: Report2d>Markers>ClearAllMarkers
Syntax: ClearAllMarkers "<ReportName>"
Return Value: None
Parameters: <ReportName>
Type: <string>
Name of Report.
VB Example:
Set oProject = oDesktop.SetActiveProject("dra_antenna")
Set oDesign = oProject.SetActiveDesign("Q3DDesign1")
Set oModule = oDesign.GetModule("ReportSetup")
oModule.ClearAllMarkers "XY Plot 1"

ClearAllTraceCharacteristics
Clears all trace characteristics from the legend in a report.

UI Access Report_Type>Trace Characteristics>Clear All

Name Type Description


Parameters
<plot name> String Name of the plot

Return Value None

Python ClearAllTraceCharacteristics (<plot name>)


Syntax

Python oModule.ClearAllTraceCharacteristics("XY Plot 1")


Example

Reporter Editor Script Commands 12-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax ClearAllTraceCharacteristics <plot name>


VB oModule.ClearAllTraceCharacteristics "XY Plot 1"
Example

CopyTracesData
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.
VB Example:
oModule.CopyTracesData "Transmission", Array("mag(S(Port1,Port2))")
An example related to Q3D Extractor is as follows:
VB Example: oModule.CopyTracesData "C11", Array("C (Box1,Box1))")

Python Syn- CopyTracesData( <ReportName> <TracesArray>)


tax

Python
oModule.CopyTracesData ("Transmission",
Example ["mag(S(Port1,Port2))"])

CopyReportData
Copy all data corresponding to the specified reports.

UI Access Select a report in the Project tree, right-click and select Copy Data

Name Type Description


Parameters
<ReportsArray> Array of Names of reports from which to copy data

Reporter Editor Script Commands 12-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

strings

Return Value None

Python CopyReportData (<ReportsArray>)


Syntax

Python oModule.CopyReportData (["Transmission","Reflection"])


Example

VB Syntax CopyReportData <ReportsArray>


oModule.CopyReportData
VB Example
Array("Transmission","Reflection")

CopyReportDefinitions
Copy the definition of a report for paste operations.

UI Access Select a report in the Project tree, right-click and select Copy Definition

Name Type Description


Parameters <ReportsArray> Array of Names of reports from which to copy the defin-
strings itions

Return Value None

Python CopyReportDefinitions (<ReportsArray>)


Syntax

Python oModule.CopyReportDefinitions(["Transmission", "Reflec-


Exampl- tion"])
e

VB Syntax CopyReportDefinitions <ReportsArray>


oModule.CopyReportDefinitions
VB Example
Array("Transmission", "Reflection")

Reporter Editor Script Commands 12-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

CopyTraceDefinitions
Copy trace definitions for a paste operation.

UI Access Select a trace in the Project tree, right-click and select Copy Definition

Name Type Description


Parameters
<ReportName> String Name of Report
<TracesArray> Array of Trace definitions to copy
Strings

Return Value None

Python Syn- CopyTraceDefinitions( <ReportName>, <TracesArray>)


tax

Python
oModule.CopyTraceDefinitions ("Transmission",
Example ["mag(S(Port1,Port2))"])

VB Syntax CopyTraceDefinitions <ReportName> <TracesArray>

VB
oModule.CopyTraceDefinitions "Transmission",
Example Array("mag(S(Port1,Port2))")

The following example is applicable for Q3D Extractor.


VB Example: oModule.CopyTraceDefinitions "R11",
Array("R(via:source1, via:source1)")

CreateReport
Creates a new report with a single trace and adds it to the Results branch in the project tree.
Command: [product]>Results>Create <type> Report
Syntax: CreateReport <ReportName> <ReportType> <DisplayType> <SolutionName> <Con-
textArray> <FamiliesArray> <ReportDataArray>
Return Value: None
Parameters: <ReportName>
Type: <string>

Reporter Editor Script Commands 12-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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 Para-
meters", then set to 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 set to one of the following:


"Rectangular Plot", "Polar Plot", "Radiation Pattern", "Rect-
angular Contour Plot", "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", "Rectangular Contour
Plot" "Data Table",
"3D Rectangular Plot", or "3D Polar Plot"

If <ReportType> is "Emission Test", then set to one of the fol-


lowing:
"Rectangular Plot" or "Data Table"
<SolutionName>

Reporter Editor Script Commands 12-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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"

<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>)

Reporter Editor Script Commands 12-23


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<ReportQuantityArray>
ex. Array("dB(S(Port1, Port1))")
VB 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()
VB 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()

VB Example:
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))")), _

Reporter Editor Script Commands 12-24


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array()

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("dra_diel")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("ReportSetup")
oModule.CreateReport "Rectangular Contour Plot 2", "Far Fields", _
"Rectangular Contour Plot", "Setup1 : LastAdaptive", Array("Con-
text:=", _
"Infinite Sphere1"), Array("_u:=", Array("All"), "_v:=", Array
("All"), "Freq:=", Array( _
"5GHz")), Array("X Component:=", "_u", "Y Component:=", "_v", "Z Com-
ponent:=", Array( _
"rETotal")), Array()

Python CreateReport (<ReportName>, <ReportType>, <DisplayType>, <SolutionName>,


Syntax <ContextArray>, <FamiliesArray>, <ReportDataArray>, <ExtendedInfo>)
Three examples are given below:(nominal, Optimetrics, spec-
tral)
Python Nominal Example:
Example
oModule.CreateReport( "XY Plot 2", "Standard",_
"Rectangular Plot", "TR", ["NAME:Context",_

Reporter Editor Script Commands 12-25


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"SimValueContext:=", [] 1, 0, 2, 0, false,_
false, -1, 1, 0, 1, 1, "", 0, 0]], ["Time:=",_
["All"], "aaa:=", ["Nominal"]]_
["X Component:=", "Time", "Y Component:=",_
["E1.I"]][])

Optimetrics Example:
oModule.CreateReport ("XY Plot 3", "Standard",_
"Rectangular Plot", "TR", ["NAME:Context",_
"OptiSetup:=", "ParametricSetup1", "SimValueContext:=",_
[1, 0, 2, 0, false, false, 0, 1, _
0, 1, 1, "", 0, 0]], ["Time:=", ["All"],_
"aaa:=", ["Nominal"]], ["X Component:=",_
"Time", "Y Component:=", ["E1.I"]], [])

Spectral Example:
oModule.CreateReport ("XY Plot 4", "Standard",_
"Rectangular Plot", "TR", ["NAME:Context",_
"SimValueContext:=", [ 2, 0, 2, 0, false, false, _
-1, 1, 0, 1, 1, "", 0, 0, "CG", false, "0", "KP", _
false, "0", "MH", false, "100", "TE", false, "40ms", _
"TH", false, "40", "TS", false, "0ns", "UF", false, _
"0", "WT", false, "0", "WW", false, "100"]],_
["Spectrum:=", ["All"], "aaa:=",_
["Nominal"]], ["X Component:=","Spectrum", _
"Y Component:=", ["mag(E1.I)"]], [])

CreateReport [Designer]
Use:Creates a new report with a single trace and adds it to the Results branch in the project tree.
Command:Product Menu>Results>Create <type> Report

Reporter Editor Script Commands 12-26


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax:CreateReport <ReportName> <ReportType> <DisplayType> <SolutionName> <Con-


textArray> <FamilesArray> <ReportDataArray>
Return Value:None
Parameters:<ReportName>
Type: <string>
Name of Report.

<ReportType>
Type: <string>
Possible values are:
"Standard" - For most plot types.
"Load Pull" - For load pull plots.
"Constellation" - For constellation plots.
"Data table" - For data tables.
"Eye Diagram" - For eye diagrams.
"Statistical" - For statistical plots.

<DisplayType>
Type: <string>
Possible values are:
"Rectangular Plot", "Polar Plot", "Radiation Pattern", "Smith Chart", "Data Table", "3D
Rectangular Plot", "3D Polar Plot", or "Rectangular Stacked Plot".

<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

Reporter Editor Script Commands 12-27


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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:=", <SimValueContext>)
Context for the trace. For more information see SimValueContext.

<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))")

VB Example:

Reporter Editor Script Commands 12-28


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModule.CreateReport "XY Stacked Plot 1", "Standard", "Rectangular


Stacked Plot", _
"LinearFrequency", Array("NAME:Context", "SimValueContext:=", Array
(3, 0, 2, 0, _
false, false, -1, 1, 0, 1, 1, "", 0, 0)), Array("F:=", Array
("All")), Array("X Component:=", _
"F", "Y Component:=", Array("dB(S(Port1,Port1))", "dB(S
(Port1,Port2))", _
"dB(S(Port2,Port1))", "dB(S(Port2,Port2))")), Array()

VB Example:
oModule.CreateReport "Data Table 1", "Standard", "Data Table", "Lin-
earFrequency",_
Array("NAME:Context", "SimValueContext:=", Array( _
3, 0, 2, 0, false, false, -1, 1, 0, 1, 1, "", 0, 0)), Array("F:=",
Array("All")), Array("X Component:=", _
"F", "Y Component:=", Array("dB(S(Port1,Port1))")), Array()

VB Example:
oModule.CreateReport "3D Rectangular Plot 1", "Standard", "3D Rect-
angular Plot", _
"LinearFrequency", Array("NAME:Context", "SimValueContext:=", Array
(3, 0, 2, 0, _
false, false, -1, 1, 0, 1, 1, "", 0, 0)), Array("F:=", Array
("All")), Array("X Component:=", _
"F", "Y Component:=", "F", "Z Component:=", Array("dB(S
(Port1,Port1))")), Array()

VB Example:
oModule.CreateReport "3D Rectangular Plot 2", "Standard", "3D Rect-
angular Plot", _
"LinearFrequency", Array("NAME:Context", "SimValueContext:=", Array
(3, 0, 2, 0, _
false, false, -1, 1, 0, 1, 1, "", 0, 0)), Array("F:=", Array
("All")), Array("X Component:=", _

Reporter Editor Script Commands 12-29


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"F", "Y Component:=", "F", "Z Component:=", Array("dB(S


(Port1,Port1))")), Array()

Python CreateReport(<data_block>)
Syntax

oModule = oDesign.GetModule("ReportSetup")
oModule.CreateReport("QuickEye Voltage Plot 1", "Eye Dia-
gram", "Rectangular Plot", "QuickEyeAnalysis",
[
"NAME:Context",
"SimValueContext:=" , [1,0,2,0,False,False,
-1,1,0,1,1,"",0,0,"DE",False,"0","DP",False,
"20000000","DT",False,"0.001","NUMLEVELS",False,"1","PCI-
D",
False,"3","PID",False,"0",
"WE",False,"49.99995us","WM",False,"49.99995us","WN",Fal-
se,
"0ps","WS",False,"0ps"]
],
Python
Example [
"Time:=" , ["All"]
],
[
"Component:=" , ["aeyeprobe3"]
],
[
"Unit Interval:=" , "1e-009s",
"Offset:=" , "0",
"Auto Delay:=" , True,
"Manual Delay:=" , "0ps",
"AutoCompCrossAmplitude:=", True,
"CrossingAmplitude:=" , "0mV",

Reporter Editor Script Commands 12-30


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"AutoCompEyeMeasurementPoint:=", True,
"EyeMeasurementPoint:=" , "5e-010s"
])

CreateReportFromFile
Creates a new report from an .rdat file.
Command: [product]>Results>CreateReportFromFile
Syntax: CreateReportFromFile "<FilePathName>"
Return Value: None
Parameters: <FilePathName>
Type: <string>
Path to .rdat file.
VB Example:
Set oModule = oDesign.GetModule("ReportSetup")
oModule.CreateReportFromFile "C:/Users/MyDir/Documents/Return_
Loss.rdat"

Python Syn- CreateReportFromFile "<FilePathName>"


tax

oModule = oDesign.GetModule("ReportSetup")
Python
Example oModule.CreateReportFromFile("C:/User-
s/MyDir/Documents/Return_Loss.rdat")

CreateReportFromTemplate
Create a report from a saved template.

[product]>Results>Report Templates>
UI Access
PersonalLib><TemplateName>

Name Type Description


Parameters
<TemplatePath> String Path to report template

Return Value None

Reporter Editor Script Commands 12-31


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python CreateReportFromTemplate(  "  <TemplatePath>")


Syntax

oProject = oDesktop.SetActiveProject("3PhaseRectifier")
oDesign = oProject.SetActiveDesign("3PhaseRectifier")

Python oModule = oDesign.GetModule("ReportSetup")


Examp-
le oModule.CreateReportFromTemplate ("C:\MyHFSSPro-
jects\PersonalLib\" _
& "ReportTemplates\TestTemplate.rpt")

VB CreateReportFromTemplate "<TemplatePath>"
Syntax

Set oProject = oDesktop.SetActiveProject("3PhaseRectifier")


Set oDesign = oProject.SetActiveDesign("3PhaseRectifier")
VB
Set oModule = oDesign.GetModule("ReportSetup")
Examp-
le oModule.CreateReportFromTemplate "C:\MyHFSSPro-
jects\PersonalLib\" _
& "ReportTemplates\TestTemplate.rpt"

For Q3D Extractor, the command CreateReportFromTemplate details are as follows:


Create a report from a saved template.
Command: Q3D Extractor>Results>PersonalLib><TemplateName>
Syntax: CreateReportFromTemplate "<TemplatePath>"
Return Value: A new report.
Parameters: <TemplatePath>
Type: <string>
Path to report template.
VB Example: Set oProject = oDesktop.SetActiveProject("connector")
Set oDesign = oProject.SetActiveDesign("connector")
Set oModule = oDesign.GetModule("ReportSetup")
oModule.CreateReportFromTemplate _
"C:\MyQ3DProjects\PersonalLib\" & _

Reporter Editor Script Commands 12-32


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"ReportTemplates\TestTemplate.rpt"

CreateReportOfAllQuantities
Create a report including all quantities in a category. Cannot create a report with expressions.

UI Access NA

Name Type Description


reportTypeArg Report type name as input para-
meter
displayTypeArg Display type name as input
parameter
solutionNameArg Solution name as input para-
meter
Parameters simValueCtxtArg a context name, or array of
string that encoded the context
(I).
categoryNameArg a category name as
input parameter
pointSetArg Array of strings(II)
commonComponentsOfTracesArg Array of strings(III)
extTraceInfoArg Array of strings(IV)

Return Value  Report of all quantities in a category

CreateReportOfAllQuantities(reportNameArg, reportTypeArg, displayTypeArg, solu-


Python
Syntax
tionNameArg, simValueCtxtArg, categoryNameArg, pointSetArg, com-
monComponentsOfTracesArg, extTraceInfoArg)
solutions= oModule.CreateReportOfAllQuantities("Smith Chart
all",

Python Modal Solution Data", "Smith Chart", "Setup1 : LastAd-


Exampl- aptive",
e [],"S Parameter",["Freq:=", ["All"], "offset:=",
["All"],"a:=",
["Nominal"],"b:=", ["Nominal"]],[],[])

CreateReportOfAllQuantities(reportNameArg, reportTypeArg, displayTypeArg, solu-


VB
tionNameArg, simValueCtxtArg, categoryNameArg, pointSetArg, com-
Syntax
monComponentsOfTracesArg, extTraceInfoArg);

Reporter Editor Script Commands 12-33


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

solutions= oModule.CreateReportOfAllQuantities("Smith Chart


all",

VB
"Modal Solution Data", "Smith Chart", "Setup1 : LastAd-
Exampl- aptive",
e [],"S Parameter",["Freq:=", ["All"], "offset:=",
["All"],"a:=",
["Nominal"],"b:=", ["Nominal"]],[],[])

DeleteMarker
Use:Deletes the specified marker.
Command:[product]>Fields>Fields>Marker>Delete Marker
Syntax:DeleteMarker <MarkerName>
Return Value:None
Parameters:<MarkerName>
Type: <string>
Name of the marker.
VB Example:Dim oAnsoftApp
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Solenoid")
Set oDesign = oProject.SetActiveDesign("Solenoid")
Set oModule = oDesign.GetModule("FieldsReporter")
oModule.DeleteMarker "m1"

Reporter Editor Script Commands 12-34


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

DeleteAllReports
Deletes all existing reports.

Right-click the report to delete in the project tree, and then click Delete All
UI Access
Reports on the shortcut menu.

Name Type Description


Parameters
None

Return Value None

Python Syn- DeleteAllReports()


tax

Python oModule.DeleteAllReports()
Example

VB Syntax DeleteAllReports

VB Example oModule.DeleteAllReports

DeleteReports
Deletes an existing report or reports.

Right-click the report to delete in the project tree, and then click Delete on the
UI Access
shortcut menu

Name Type Description


Parameters <ReportNameArray> Array of Array of all the report names that are to be
Strings deleted

Return Value None

Python Syn- DeleteReports(<ReportNameArray>)


tax

Python oModule.DeleteReports (["Rept2DRectFreq"])


Example

Reporter Editor Script Commands 12-35


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax DeleteReports(<ReportNameArray>)
VB oModule.DeleteReports Array("Rept2DRectFreq")
Example

DeleteTraces
Deletes an existing traces or traces.

Right-click the Trace to delete in the project tree, and then click Delete on the
UI Access
shortcut menu

Name Type Description


<TraceSelectionArray> Array of Array("<ReportName>:=", <TracesAr-
Strings ray>, <TracesArray>,... )
<ReportName> String Name of Report
Parameters <TracesArray> Array of Contains the traces to delete within a
Strings report
Array(<Trace>, <Trace>, ...)
<Trace> String A specific trace that the user wishes to
delete

Return Value None

Python Syn- DeleteTraces(<TraceSelectionArray>)


tax

oModule.DeleteTraces (["XY Plot 1:=",


Python
Example ["dB(S(LumpPort1,Lump-
Port1))"],
"XY Plot 2:=", ["Mag_E"]])

VB Syntax DeleteTraces(<TraceSelectionArray>)
oModule.DeleteTraces Array("XY Plot 1:=",
VB
Array("dB(S(LumpPort1,Lump-
Port1))"),
Example
"XY Plot 2:=", Array("Mag_E"))

An example applicable for Q3D Extractor is as follows.


VB Example:

Reporter Editor Script Commands 12-36


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModule.DeleteTraces Array("XY Plot 1:=", Array("R(via:source1, via:-


source1)"), "XY Plot 2:=", Array("char_imped"))

ExportImageToFile [Reporter]
Export an image in a specified format.
Command: None.
Syntax: ExportImageToFile(<ReportName>,<exportFileName>, <width>, <height>)
Parameters: <ReportName>
Type: <string>
Name of the image file.
<ExportFileName>
Type: <String>
Full path of the exported image file name; with extension of jpg, gif, tiff, tif, bmp, or wrl.
<width>
Type: <int>
Image width in pixels; if width or height is less or equal to zero, use the report window
width, or 500 pixels if report window is closed.
<height>
Type: <int>
Image height in pixels; if width or height is less or equal to zero, use the report window
height, or 500 pixels report window is closed.
For the default, use 0, 0. For higher resolution, set the desired <width> and <height>, for
example for 8k export as 7680, 4320:
VB Example:
Set oProject = oDesktop.SetActiveProject("OptimTee")
Set oDesign = oProject.SetActiveDesign("TeeModel")
Set oModule = oDesign.GetModule("ReportSetup")
oModule.ExportImageToFile "Rectangular Contour Plot 1", "D:/-
work/2015/UV-Export/pp1.gif", 0, 0

Python Syn- ExportModelImageToFile (["<path>/<imageName>.<formatsuffix>" 0,0,


tax [(<SaveImageParams>)])

Python oModule.ExportImageToFile(" Plot 1", "C:/Users/kmchrist/Documents/Plot


Example 1.jpg", 0, 0)

Reporter Editor Script Commands 12-37


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python oModule.ExportImageToFile(" Plot 1", "C:/Users/kmchrist/Documents/Plot


Example, 1.jpg", 7680, 4320)
High Res-
olution

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.
Syntax: ExportPlotImageToFile(<FileName>, "", <plotItemName>, <setViewTopDownDir-
ectionByRelativeCS>)
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

Reporter Editor Script Commands 12-38


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")


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"

ExportReport

Note:

The ExportReport script command has been replaced by the script command
ExportToFile. ExportReport remains in order to retain backward compatibility for existing
scripts, but it is strongly recommended that you now use ExportToFile.

Export a report to a data file.


Command: None
Syntax: ExportReport <ReportName>, <FileName>, <FileExtension>
Return Value: None
Parameters: <ReportName>
Type: string
<Filename>
Type: string
<FileExtension>
Type: string
VB Example:

Reporter Editor Script Commands 12-39


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule

Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")


Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow

Set oProject = oDesktop.SetActiveProject("BJTinverter")


Set oDesign = oProject.SetActiveDesign("Nexxim1")
oDesign.ExportReport "Data Table 1", "table_test", "csv"

Python Syn- ExportReport(  <


  ReportName>, <FileName>)
tax

Python oDesign.ExportReport(
Example "Plot1", "c:\report1.dat")

ExportToFile

Note:

The ExportToFile script command has replaced the script command ExportReport.
ExportReport remains in order to retain backward compatibility for existing scripts, but it
is strongly recommended that you now use ExportToFile.

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

Reporter Editor Script Commands 12-40


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters: <ReportName>
Type: string

<Filename>
Type: string

.txt Post processor format file


.csv Comma-delimited data file
.tab Tab-separated file
.dat ANSYS plot data file

VB Example: Set oModule = oDesign.GetModule(’ReportSetup’)


oModule.ExportToFile(‘Plot 1’,’c:\report1.dat’)

ExportToFile [Reporter]
 From a data table or plot, generates text format, comma delimited, tab delimited, .dat, or .rdat type
output files.

UI Access Right-click on report name in the Project tree and select Export.

Name Type Description


<ReportName> String Name of the report
<FileName> String Path and File Name
Supported formats

Parameters .txt Post processor format file


.csv Comma-delimited data file
.tab Tab-separated file
.dat ANSYS plot data file
.rdat ANSYS report data file

Return Value None

Python Syn- ExportToFile (<ReportName>, <FileName>)


tax

Python oModule.ExportToFile(
Example

Reporter Editor Script Commands 12-41


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Plot1", "c:\report1.dat")

VB Syntax ExportToFile <ReportName>, <FileName>


oModule.ExportToFile
VB Example
"Plot1", "c:\report1.dat"

ExportMarkerTable
The documented command is applicable for Q3D Extractor.
Use:Exports the marker table to a .csv or .tab file.
Command:[product]>Fields>Fields>Marker>ExportMarkerTable
Syntax:ExportMarkerTable <pathandfilename>
Return Value:none
Parameters:<pathandfilename>
Example:Dim oAnsoftApp
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Solenoid")
Set oDesign = oProject.SetActiveDesign("Solenoid")
Set oModule = oDesign.GetModule("FieldsReporter")
oModule.ExportMarkerTable("C:/work/FieldMarkerTable.csv")

FFTOnReport
Use: Perform an FFT on a selected report.
Command: [product]>Results>Perform FFT on Report

Reporter Editor Script Commands 12-42


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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, dB20nor-
malize, dBc, im, mag, normalize, re.

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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"

For Q3D Extractor the details for FFTOnReports are as follows:


Use: Perform an FFT on a selected report.
Command: Q3D Extractor or 2D Extractor>Results>Perform FFT on Report

Reporter Editor Script Commands 12-43


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax: "<plotName>", <FFTWindowType>, "<function>"


Return Value: Creates a plot named FFT "Plot Name".
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, dB20nor-
malize, dBc, im, mag, normalize, re.
Example: Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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"

GetAllCategories
Get all available category names (not including variable and output-variables) in a solution for a
report type and display type, returned as an array of text strings.

UI Access NA

Reporter Editor Script Commands 12-44


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name Type Description


 <reportTypeArg> Report type name as input parameter
<displayTypeArg> Display type name as input parameter
Parameters <solutionNameArg> Solution name as input parameter
<simValueCtxtArg> A context name, or array of strings that
encode the contexts(I)
categoryName_ Output parameter for returning category
array names

Return Value Array of text strings

Python GetAllCategories(reportTypeArg,displayTypeArg, solutionNameArg, simValueCtx-


Syntax tArg, categoryName_array)
categories= oModule.GetAllCategories("Far Fields",
Python "Rectangular Plot", "Setup1 :
Example
LastAdaptive", "Infinit

GetAllCategories(reportTypeArg,displayTypeArg, solutionNameArg,
VB Syntax
simValueCtxtArg, categoryName_array)
categories= oModule.GetAllCategories
VB
("Far Fields", "Rectangular Plot", "Setup1 :
Example
LastAdaptive", "Infini

GetAllReportNames
Gets the names of existing reports in a design

UI Access NA

Name Type Description


Parameters
None

Return Value Array of report names

Python GetAllReportNames()
Syntax

Reporter Editor Script Commands 12-45


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oReportModule = oDesign.GetModule("ReportSetup")
names = oReportModule.GetAllReportNames()
Python
Example for name in names:
AddInfoMessage(str(name))

VB Syntax GetAllReportNames()
Dim names
names = oReportModule.GetAllReportNames

VB For index = 0 to UBound(names)


Example
MsgBox(names(index))

Next

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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)

Reporter Editor Script Commands 12-46


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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

GetAllQuantities
Gets all available quantity names in category, returned as an array of text strings.

UI Access NA

Name Type Description


<reportTypeArg> Report type name as input parameter
<displayTypeArg> Display type name as input parameter
<solutionNameArg> Solution name as input parameter
<simValueCtxtArg> A context name, or array of string that
Parameters encoded the contexts(I).
<categoryNameArg> A category name as input parameter. a cat-
egory name returned in GetAllCategories()
or "Vari-ables", or "Output Variables"
<quantityName_ Output parameter for returning quantity
array> names found in a category.

Return Value Array of text strings

Python Syn- GetAllQuantities(reportTypeArg, displayTypeArg, solutionNameArg,


tax
simValueCtxtArg, categoryNameArg, quantityName_array)
quantities= oModule.GetAllQuantities
Python ("Far Fields", "Rectangular Plot", "Setup1 :
Example
LastAdaptive", "Infinite Sphere1", "Gain")

GetAllQuantities(reportTypeArg, displayTypeArg, solutionNameArg,


VB Syntax
simValueCtxtArg, categoryNameArg, quantityName_array)

Reporter Editor Script Commands 12-47


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

quantities= oModule.GetAllQuantities
VB
("Far Fields", "Rectangular Plot", "Setup1 :
Example
LastAdaptive", "Infinite Sphere1", "Gain")

GetAvailableDisplayTypes
All supported display types in report type as an array of text strings.

UI Access NA

Name Type Description


Parameters
< reportTypeArg > Report type name as input parameter
<displayType_ Output parameter for returning display types
array>

Return Value Array of text strings

Python GetAvailableDisplayTypes(reportTypeArg,displayType_array)
Syntax

Python displayTypes = oModule .GetAvailableDisplayTypes("Far


Exampl- Fields")
e

VB Syn- GetAvailableDisplayTypes(reportTypeArg,displayType_array)
tax

VB displayTypes = oModule .GetAvailableDisplayTypes("Far


Exampl- Fields")
e

GetAvailableReportTypes
Get all available report types in the current Design as an array of text string.

UI Access NA

Name Type Description


Parameters
reportType_array Array Output parameter for returning report types

Return Value Array of text strings

Reporter Editor Script Commands 12-48


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python GetAvailableReportTypes([out, retval] VARIANT* reportType_array)


Syntax

Python reportTypes = oModule.GetAvailableReportTypes()


Example

VB Syntax GetAvailableReportTypes([out, retval] VARIANT* reportType_array)


VB reportTypes = oModule.GetAvailableReportTypes()
Example

GetAvailableSolutions
Get all available solutions in report type as an array of text strings.

UI Access NA

Name Type Description


Parameters
<reportTypeArg> Report type name as input parameter.
solution_array Output parameter for returning solution
names.

Return Value Array of text strings

Python GetAvailableSolutions(reportTypeArg,solution_array)
Syntax

Python solutions=oModule.GetAvailableSolutions("Far Fields")


Example

VB Syn- GetAvailableSolutions(reportTypeArg,solution_array)
tax

VB solutions= oModule.GetAvailableSolutions("Far Fields")


Example

GetChildNames [Report Setup]


Gets a list of report names.

UI Access NA

Parameters Name Type Description

Reporter Editor Script Commands 12-49


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type Text string Optional. This parameter is ignored.

Return Value All report names.

Python Syn- GetChildNames()


tax

Python oRptModule = oDesign.GetChildObject("ReportSetup")


Example oRptModule.GetChildNames()

GetChildObject [Report Setup]


Get a report object or report child object; the module’s first level of child object is report. Report has
trace, axis, header, Legend, and more children. Trace has curve as child etc. Those child objects
can be accessed by calling all levels of parent object’s GetChildObject(path) function.

UI Access NA

Name Type Description


Parameters Object path Text string Report Name or an object path beginning
with a report name.

A ReportSetup(Results) Module Child Object, [ReportSetup(Results) Module


Return Value
Child Objects ]

Pyt- GetChildObject(objectPath)
hon
Syn-
tax

oRpt = oRptModule.GetChildObject("S Parameter Plot 1") //re-


turn the report property object
Pyt-
hon oTrace = oRptModule.GetChildObject("S Parameter Plot 1/dB(S
Exa- (Port1,Port1))") //return the trace property object
mpl-
e oAxisX = oRptModule.GetChildObject("S Parameter Plot 1/AxisX")
return the axis X property object

VB GetChildObject(objectPath)

Reporter Editor Script Commands 12-50


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syn-
tax

set oRpt = oRptModule.GetChildObject("S Parameter Plot 1")


VB set oTrace = oRptModule.GetChildObject("S Parameter Plot
Exam- 1/dB(S(Port1,Port1))")
ple
set oAxisX = oRptModule.GetChildObject("S Parameter Plot
1/AxisX")

GetChildTypes [ReportSetup]
Use: Gets child types of queried Report module object.
Syntax: GetChildTypes()
Return Value: Always empty array.

Python Syn- GetChildTypes ()


tax

Python oRptModule = oDesign.GetChildObject(“ReportSetup”)


Example oRptModule.GetChildTypes()

GetDataExpressions
Returns data expressions.

UI Access NA
Parameters NA
Return Value Array of text strings

Python Syn- GetDataExpressions()


tax

Python expressions = oModule.GetDataExpressions()


Example

VB Syntax GetDataExpressions()

VB dim expressions
Example expressions = oModule.GetDataExpressions()

Reporter Editor Script Commands 12-51


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetDataUnits
Returns text string containing units.

UI Access NA

Name Type Description


Parameters <expressionString> String Can be returned from GetDataEx-
pressions()

Return Value Text string of units; empty if no units

Python Syn- GetDataUnits(<expressionString>)


tax

Python oModule.GetDataUnits(expressions)
Example

VB Syntax GetDataUnits(<expressionString>)
VB Example oModule.GetDataUnits(expressions)

GetDesignVariableNames
Returns array of strings containing design variable names.

UI Access NA
Parameters NA
Return Value Array of strings

Python Syn- GetDesignVariableNames()


tax

Python names = oModule.GetDesignVariableNames()


Example

VB Syntax GetDesignVariableNames()
VB dim names

Reporter Editor Script Commands 12-52


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Example names = oModule.GetDesignVariableNames()

GetDesignVariableUnits
Returns array of strings containing design variable units.

UI Access NA

Name Type Description


Parameters <varName> String Can be returned from GetDesignVari-
ableNames()

Return Text string of units; empty if no units.


Value

Python GetDesignVariableUnits(<varName>)
Syntax

Python units = oModule.GetDesignVariableUnits('Variable Name')


Example

VB Syn- GetDesignVariableUnits(<varName>)
tax

VB dim units
Example units = oModule.GetDesignVariableUnits("Variable Name")

GetDesignVariableValue
Returns a design variable's value.

UI Access NA

Name Type Description


<varName> String Can be returned from GetDesignVari-
Parameters ableNames()
<siValue> Boolean True to return SI-value; False to return
by GetDesignVariableUnits()

Return Double value


Value

Reporter Editor Script Commands 12-53


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python GetDesignVariableValue(<varName>, <siValue>)


Syntax

Python value = oModule.GetDesignVariableValue('varName',1)


Example

VB Syn- GetDesignVariableValue(<varName>, <siValue>)


tax

VB dim value
Example value = oModule.GetDesignVariableValue("varName", True)

GetDesignVariationKey
Returns a design's Variation Key.

UI Access NA
Parameters NA
Return Value String containing Variation Key

Python Syn- GetDesignVariationKey()


tax

Python key = GetDesignVariationKey()


Example

VB Syntax GetDesignVariationKey()
dim key
VB Example
key = oModule.GetDesignVariationKey()

GetDisplayType
Get the display type of a report.

UI Access NA

Name Type Description


Parameters
<ReportName> String Report name

Reporter Editor Script Commands 12-54


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Report <displaytype> of a report.


<DisplayType>

Type: <string>

Return Value If ReportType is "Standard", then returns one of the following:


"Rectangular Plot", "Polar Plot", "Radiation Pattern",
"Data Table", "3D Rectangular Plot", or "3D Polar
Plot", "Rectan-
gular Stacked Plot", "Bode Plot", "Rect-
angular Nyquist Plot", "Nyquist Plot", "Digital Plot".

Python Syn-  GetDisplayType ("<reportName>")


tax

Python GetDisplayType("Standard")
Example

VB Syntax  GetDisplayType "<reportName>"


VB Example GetDisplayType("Standard")

GetImagDataValues
Returns array of imaginary data values.

UI Access NA

Name Type Description


<expressionString> String Can be returned from GetDataEx-
pressions()
Parameters
<siValue> Boolean True to return SI-value; False to return
with units returned in GetSweepUnits
().

Return Value Array of doubles

Python GetImagDataValues(<expressionString>,<siValue>)
Syntax

Python imaginaryvalues = oModule.GetImagDataValues('expression',1)


Example

Reporter Editor Script Commands 12-55


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syn- GetImagDataValues(<expressionString>,<siValue>)
tax

VB
dim imaginaryvalues
Exampl- imaginaryvalues = oModule.GetImagDataValues("expres-
e sion",True)

GetPerQuantityPrimarySweepValues
Returns per quantity primary sweep values.

UI Access NA

Name Type Description


<expressionString> String Can be returned from GetDataEx-
Parameters pressions().
<siValue> Boolean True to return SI-value; False to return
by GetSweepUnits().

Array of doubles if IsPerQuantityPrimarySweep() returned True; error if returned


Return Value
False

Pytho- GetPerQuantitySweepValues(<expressionString>, <siValue>)


n Syn-
tax

Pytho- sweepvalues = oModule.GetPerQuantitySweepValues


n ('0.111,0.201,0.345,0.231', 1)
Exam-
ple

VB GetPerQuantitySweepValues(<expressionString>, <siValue>)
Syn-
tax

VB
dim sweepvalues
Exam- sweepvalues = oModule.GetPerQuantitySweepValues
ple ("0.111,0.201,0.345,0.231", True)

Reporter Editor Script Commands 12-56


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetPropertyValue
Gets the value of a single property belonging to a specific serverName and PropTab. This function
is available with the Project, Design or Editor objects, including definition editors.
Use the script recording feature and edit a property, and then view the resulting script to
see the format for that property.

UI Access NA

Name Type Description


<propTab> String One of the following, where tab titles
are shown in parentheses:
PassedParameterTab ("Parameter
Values")
DefinitionParameterTab (Para-
meter Defaults")
LocalVariableTab ("Variables" or
"Local Variables")
ProjectVariableTab ("Project vari-
ables")

Parameters ConstantsTab ("Constants")


BaseElementTab ("Symbol" or
"Footprint")
ComponentTab ("General")
Component("Component")
CustomTab ("Intrinsic Variables")
Quantities ("Quantities")
Signals ("Signals")
<propServer> String An object identifier, generally returned from
another script method, such as Comp-
Inst@R;2;3
<propName> String Name of the property.

Return Value  String, the value of the property.

Python GetPropertyValue (<propTab>, <serverName>, <propName>)


Syntax

Python selectionArray = oEditor.GetSelections()

Reporter Editor Script Commands 12-57


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

for k in selectionArray:

Exampl- val = oEditor.GetPropertyValue("PassedParameterTab", k,


e "R")
...

VB GetPropertyValue (<propTab>, <serverName>, <propName>)


Syntax

selectionArray = oEd-
itor.GetSelections

for each k in selectionArray

VB
Examp-
val = oEditor.GetPropertyValue("PassedParameterTab", k,
le
"R")

...

next

Python Syn- GetPropertyValue ([ <array>])


tax

oModule = oDesign.GetModule("ReportSetup")
Python
Example oModule.GetPropertyValue("Trace", "S Parameter Plot
1:dB(S(1,1))","Y Axis")

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

VB Example:value_string = _
oEditor.GetPropertyValue("BaseElementTab",_

Reporter Editor Script Commands 12-58


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"rect_1", "Name")

Example: (Query frequency and excitation)


freq = oDesign.GetPropertyValue("General", "AnalysisSetup:Setup1",
"Adaptive Freq")
sigType = oDesign.GetPropertyValue("Q3D", "BoundarySetup:via_1",
"Type")
sourceType = oDesign.GetPropertyValue("Q3D", "Bound-
arySetup:Source1", "Type")

Example: (Query Trace values in a specified report)


oModule = oDesign.GetModule("ReportSetup")
oModule.GetPropertyValue("Trace", "S Parameter Plot 1:dB(S(1,1))","Y
Axis")

GetPropNames [Reporter]
Use: Report setup module does not have its own property, this function always returns empty
array.
Syntax: GetPropNames(bIncludeReadOnly)
Return Value: Returns empty set.
Parameters: bIncludeReadOnly—optional, default to True.

Python Syn- GetPropNames (bIncludeReadOnly)


tax

oOptModule.GetPropNames()
Python
oOptModule.GetPropNames(True)
Example
oOptModule.GetPropNames(False)

GetPropValue [Report Setup]


Get the property value for a Report, or reports’ child object property values..

UI Access NA

Name Type Description


Parameters propPath text string a child object's property path. See property
path discussion here.

Reporter Editor Script Commands 12-59


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Return Value The property value.

Python Syn- GetPropValue(propPath)


tax

dispType = oRptModule.GetPropValue(“S Parameter Plot


Python 1/Display Type”)
Example XComponent = oRptModule.GetPropValue(“S Parameter Plot
1/db(S(port1,port2)/X Component”)

VB Syntax GetPropValue(propPath)
GetPropValue("Display Type"0)
VB Example
'Rectangular Plot'

GetRealDataValues
Returns array of real data values.

UI Access NA

Name Type Description


<expressionString> String Can be returned from GetDataEx-
pressions()
Parameters
<siValue> Boolean True to return SI-value; False to return
with units returned in GetSweepUnits
().

Return Value Array of doubles

Python GetRealDataValues(<expressionString>,<siValue>)
Syntax

Python realvalues = oModule.GetRealDataValues('expression',1)


Example

VB Syn- GetRealDataValues(<expressionString>,<siValue>)
tax

VB dim realvalues

Reporter Editor Script Commands 12-60


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Example realvalues = oModule.GetRealDataValues("expression",True)

GetReportTraceNames
Use: Gets the names of existing trace names in a plot.
Syntax: GetReportTraceNames("<plot name>")
Return Value: Array of trace names for a named plot.
Parameters: <PlotName>
Type: <string>
Name of plot.
Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject
Set oDesign = oProject.GetActiveDesign
Set oReportModule = oDesign.GetModule("ReportSetup")
Dim names
names = oReportModule.GetReportTraceNames("Sparameter Plot 1")
MsgBox(names(index))

Python GetReportTraceNames()
Syntax

Python
oReportModule = oDesign.GetModule("ReportSetup")
Exampl- names = oReportModule.GetReportTraceNames("SParameter Plot
e 1")

Reporter Editor Script Commands 12-61


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

for name in names:


AddInfoMessage(str(name))

GetSolutionContexts
Get all available solution context names in a solution as an array of text strings.

UI Access NA

Name Type Description


<reportTypeArg> Report type name as input parameter.
Parameters
<displayTypeArg> Display type name as input parameter.
<solutionNameArg> Solution name as input parameter.
<contextName_ Output parameter for returning context
array> names.

Return Value Array of text strings

Python Syn- GetSolutionContexts(reportTypeArg,displayTypeArg, solutionNameArg, con-


tax textName_array)
contexts= oModule.GetSolutionContexts
Python ("Far Fields", "Rectangular Plot", "Setup1:
Example
LastAdaptive")

GetSolutionContexts(reportTypeArg,displayTypeArg, solutionNameArg, con-


VB Syntax
textName_array);
contexts= oModule.GetSolutionContexts
VB
("Far Fields", "Rectangular Plot", "Setup1:
Example
LastAdaptive")

GetSolutionDataPerVariation
Obtains solution data for a given report type and solution. You must have already run a simulation.

UI Access N/A

Name Type Description


Parameters
<reportTypeArg> String Report type name as input para-

Reporter Editor Script Commands 12-62


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

meter.
<solutionNameArg> String Solution name as input para-
meter.
<simValueCtxtArg> Structured Array Same as ContextArray values cre-
ated in the relevant CreateReport
script.
<familiesArg> Array of Strings Same as FamiliesArray values
created in the relevant CreateRe-
port script.
<expressionArg> String or Array of Text string or array of text strings;
Strings valid expression, may validate it
as the data-table Y-component.

ARRAY of ISolutionDataResultComInterface objects, containing:

l GetSweepNames()
l GetSweepUnits()
l GetSweepValues()
l IsPerQuantityPrimarySweep()
l GetDataExpressions() – should be the same as <expressionArg>
l GetPerQuantityPrimarySweepValues()
l IsDataComplex()
Return Value
l GetDataUnits()
l GetRealDataValues()
l GetImagDataValues()
l ReleaseData()
l GetDesignVariableNames()
l GetDesignVariableUnits() 
l GetDesignVariableValue()
l GetDesignVariationKey()

Reporter Editor Script Commands 12-63


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Note:

l This command is not recordable from the UI, but its parameters are similar to
CreateReport, so you may record a CreateReport script to get the parameter val-
ues.
l For the returned ISolutionDataResultComInterface object, some of its functions
have an optional boolean parameter: SIValue. SIValue defaults to True. When the
pass in value is True, return data values will be in Standard International values;
when False, return data values will be in the current units.

Example: Freq Sweep with [1GHz, 2GHz,3GHz], GetSweepUnits(“Freq”) return


“GHz”; GetSweepValues(“Freq”, True) return [1000000,2000000,3000000];
GetSweepValues(“Freq”, False) return [1,2,3].

Python Syn- GetSolutionDataPerVariation(reportTypeArg, solutionNameArg, simValueCtx-


tax tArg, familiesArg, expressionArg)
oModule = oDesign.GetModule("ReportSetup")

Python arr = oModule.GetSolutionDataPerVariation('Modal Solu-


Example tion Data', 'Setup1 : Sweep', ['Domain:=', 'Sweep'],
[['Freq:=', ['All'], 'offset:=', ['All']], ['S
(Port1,Port1)', 'dB(S(Port1,Port3))'])

GetSolutionDataPerVariation(reportTypeArg, solutionNameArg,
VB Syntax
simValueCtxtArg, familiesArg, expressionArg)
set solutionData = oMod-
ule.GetSolutionDataPerVariation(
"Modal Solution Data",
"Setup1 : Sweep",
VB Example Array("Domain:=", "Sweep"),
Array("Freq:=", Array("All"), "offset:=", Array
("All")),
Array("S(Port1,Port1)", "dB(S(Port1,Port3))")
)

GetSweepNames
Returns array of text strings containing primary sweep name(s).

Reporter Editor Script Commands 12-64


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access NA
Parameters NA
Return Value Array of text strings

Python Syn- GetSweepNames()


tax

Python sweepnames = oModule.GetSweepNames()


Example

VB Syntax GetSweepNames()
dim sweepnames
VB Example
sweepnames = oModule.GetSweepNames()

GetSweepUnits
Returns text string containing units.

UI Access NA

Name Type Description


Parameters
<sweepName> String Primary sweep name

Return Value Text string containing units

Python Syn- GetSweepUnits(<sweepName>)


tax

Python sweepunits = oModule.GetSweepUnits('Sweep 1')


Example

VB Syntax GetSweepUnits(<sweepName>)

VB dim sweepunits
Example sweepunits = oModule.GetSweepUnits("Sweep 1")

Reporter Editor Script Commands 12-65


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetSweepValues
Returns sweep values.

UI Access NA

Name Type Description


Parameters
<sweepName> String Primary sweep name
<siValue> Boolean True to return SI-value; False to
return by GetSweepUnits().

Return Value Array of doubles

Python GetSweepValues(<sweepName>, <siValue>)


Syntax

Python sweepvalues = oModule.GetSweepValues('Sweep 1', True)


Example

VB Syn- GetSweepValues(<sweepName>, <siValue>)


tax

VB dim sweepvalues
Example sweepvalues = oModule.GetSweepValues("Sweep 1", True)

GroupPlotCurvesByGroupingStrategy
Groups curves in a Stacked Plot automatically based on a curve grouping strategy.
Command: Group Curves By...
Syntax: GroupPlotCurvesByGroupingStrategy "<reportName>", "<curve_grouping_strategy>")
Return Value: None
Parameters: <ReportName>
Type: <string>
Report name.
<curve_grouping_strategy>
Type: <string>
Single, By Trace, By Units
VB Example:

Reporter Editor Script Commands 12-66


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("CoaxBend14_1")
Set oDesign = oProject.SetActiveDesign("Transient")
Set oModule = oDesign.GetModule("ReportSetup")
oModule.GroupPlotCurvesByGroupingStrategy "Transient Plot 1", "By Units"

Pytho- GroupPlotCurvesByGroupingStrategy "<reportName>", "<curve_grouping_


n Syn- strategy>")
tax

Pytho- oModule.GroupPlotCurvesByGroupingStrategy("Transient Plot


n 1", "By Trace")
Exam-
ple

ImportIntoReport
Imports .tab, .csv, and .dat format files into a report.

UI Access Right-click on report name in the Project tree and select Export Data.

Name Type Description


<ReportName> String Name of the Report
<FileName> String Path and File Name
Parameters
.csv Comma-delimited data file
.tab Tab-separated file
.dat ANSYS plot data file

Return Value None

Reporter Editor Script Commands 12-67


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python  ImportIntoReport (<ReportName>, <FileName>)


Syntax

Python oDesign.ImportIntoReport ("Plot1", "c:\report1.dat")


Example

VB Syn-  ImportIntoReport <ReportName>, <FileName>


tax

VB oDesign.ImportIntoReport "Plot1", "c:\report1.dat"


Example

IsDataComplex
Returns whether an expression is complex.

UI Access NA

Name Type Description


Parameters <expressionString> String Can be returned from GetDataEx-
pressions().

Return Value Boolean (True if expression is Complex data; False if not)

Python Syn- IsDataComplex(<expressionString>)


tax

Python oModule.IsDataComplex('.001,.234,.455,.434')
Example

VB Syntax IsDataComplex(<expressionString>)
VB oModule.IsDataComplex('.001,.234,.455,.434')
Example

IsPerQuantityPrimarySweep
Returns whether data expressions have different primary sweep values.

UI Access NA

Reporter Editor Script Commands 12-68


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters NA
Return Value Boolean (True if data expressions have different primary sweep values)

Python Syn- IsPerQuantityPrimarySweep()


tax

Python oModule.IsPerQuantityPrimarySweep()
Example

VB Syntax IsPerQuantityPrimarySweep()
VB Example oModule.IsPerQuantityPrimarySweep()

MovePlotCurvesToGroup
In a Stacked Plot move curve(s) from its stack(s) to an existing stack. Here term ‘group’ is syn-
onymous to ‘stack’ in the context of cartesian stacked plot.
Command: Move Plot Curves to Group
Syntax: MovePlotCurvesToGroup("<reportName>",["<curve1-name>", "<curve2-name>",...],
"<stack-name>")
Return Value: None
Parameters: <ReportName>
Type: <string>
Report name.
<curveN_name>
Type: <string>
Trace name.
<"stack-name">
Type: <string>
Stack name.

Pyth- oModule.MovePlotCurvesToGroup("<report-name>", ["<curve1-name>", "<curve2-


on name>",...], "<stack-name>")
Syn-
tax

Reporter Editor Script Commands 12-69


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Pyth- oModule.MovePlotCurvesToGroup("XY Stacked Plot 1", ["R2.V :


on TR", "R2.I : TR"], "Stack 2")
Exa-
mple

MovePlotCurvesToNewGroup
In a Stacked Plot move curve(s) from its stack(s) to anew stack. Here term ‘group’ is synonymous
to ‘stack’ in the context of Cartesian stacked plot.
Command: Move Plot Curves to New Group
Syntax: MovePlotCurvestoNewGroup("<reportName>",["<curve1-name>", "<curve2-name>",...],
"<stack-name>")
Return Value: None
Parameters: <ReportName>
Type: <string>
Report name.
<curveN_name>
Type: <string>
Trace name.
<"stack-name">
Type: <string>
Stack name.

Pyth- oModule.MovePlotCurvesToNewGroup("<report-name>", ["<curve1-name>",


on "<curve2-name>",...], "<stack-name>")
Syn-
tax

Pyth- oModule.MovePlotCurvesToNewGroup("XY Stacked Plot 1", ["R2.V


on : TR", "R2.I : TR"], "Stack 2")
Exa-
mple

PasteReports
Paste copied reports to results in the current project.

UI Access Edit>Paste

Reporter Editor Script Commands 12-70


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name Type Description


Parameters
None

Return Value None

Python Syn- PasteReports ()


tax

Python oModule.PasteReports()
Example

VB Syntax PasteReports
VB Example oModule.PasteReports

PasteTraces
To paste copied traces to a named plot.

UI Access Paste

Name Type Description


Parameters
<plotName> String Name of plot

Return Value None

Python Syn- PasteTraces ("<plotName>")


tax

Python oModule.PasteTraces ("XY Plot1")


Example

VB Syntax PasteTraces "<plotName>"


VB Example oModule.PasteTraces "XY Plot1"

Release Data
Releases all cached data. After this function is called, all subsequent function calls to the object will
fail.

Reporter Editor Script Commands 12-71


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access NA
Parameters NA
Return Value NA

Python Syn- ReleaseData()


tax

Python oModule.ReleaseData()
Example

VB Syntax ReleaseData()
VB Example oModule.ReleaseData()

RenameReport
Renames an existing report.

UI Access Select a report on the Project tree, right-click and select Rename

Name Type Description


Parameters <OldReportName> String Old Report Name
<NewReportName> String New Report Name

Return Value None

Python RenameReport (<OldReportName>, <NewReportName>)


Syntax

Python oModule.RenameReport ("XY Plot1", "Reflection")


Example

VB Syntax RenameReport <OldReportName>, <NewReportName>


VB oModule.RenameReport "XY Plot1", "Reflection"
Example

RenameTrace
To rename a trace in a plot

Reporter Editor Script Commands 12-72


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access NA

Name Type Description


<plotName> String Name of plot.
Parameters
<traceID> String Name of Trace
<newName> String New trace name.

Return Value None

Python Syn- RenameTrace ("<plotName>" "<traceID>" "<newName>")


tax

Python
oModule.RenameTrace ("XY Plot1",
Example "dB(S(WavePort1,WavePort1))1",_ "Port1dbS")

VB Syntax RenameTrace "<plotName>" "<traceID>" "<newName>"

VB
oModule.RenameTrace "XY Plot1",
Example "dB(S(WavePort1,WavePort1))1",_ "Port1dbS"

An example related to Q3D Extractor is as follows:


VB Example: oModule.RenameTrace "XY Plot1", "ACR(trace:src1, trace:src1)", "TraceRes"

ResetPlotSettings
Resets plot settings to defaults.
Command: Right-click on plot Edit>Reset Plot Settings
Syntax: ResetPlotSettings("PlotName")
Return Value: None
Parameters: <PlotName>
Type: <string>
Name of plot.
VB Example:
Set oModule = oDesign.GetModule("ReportSetup")
oModule.ResetPlotSettings "Differential S-parameters"

Reporter Editor Script Commands 12-73


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- ResetPlotSettings( "<PlotName>")


tax

Python oModule = oDesign.GetModule("ReportSetup")


Example oModule.ResetPlotSettings("Differential S-parameters")

SavePlotSettingsAsDefault
Saves report plot settings as default.

UI Access Report Templates>Save Settings as Default

Name Type Description


Parameters
<Plot Name> String Name of plot to use for plot defaults.

Return Value A new report

Python SavePlotSettingsAsDefault ("<PlotName>")


Syntax

Python oModule.SavePlotSettingsAsDefault ("XY Plot1")


Example

VB Syntax SavePlotSettingsAsDefault "<PlotName>"


VB oModule.SavePlotSettingsAsDefault "XY Plot 1"
Example

VB Example:

Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow

Reporter Editor Script Commands 12-74


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oProject = oDesktop.SetActiveProject("OptimTee")


Set oDesign = oProject.SetActiveDesign("TeeModel")
Set oModule = oDesign.GetModule("ReportSetup")
oModule.SavePlotSettingsAsDefault "XY Plot 1"

SetPropValue [Report Setup]


Sets the property value for report module child object.

UI Access Edit Properties on Report objects

Name Type Description


proPath text string a child object's property path. See property
path discussion here.
Parameters
new Value Text String, New value data type is depending on the prop-
Number, or erty type,
Boolean

Return Value True if the property is found and the new value is valid. Otherwise return False.

Python Syn- SetPropValue(propPath, newValue)


tax

oRptModule.SetPropValue(“S Parameter Plot 1/Display


Python Type”, “DataTable”)
Example oRptModule.SetPropValue(“S Parameter Plot 1/db(S(port1,-
port2)/Primary sweep”, “Freq”)

UpdateTraces
Update the traces in a report for which traces are not automatically updated by the Report Traces
dialog, Update Report, Real Time selection.

UI Access Report dialog, Apply Traces button

Name Type Description


<ReportName> String Name of Report.
<SolutionName> String Name of the solution as lis-
Parameters ted in the Modify Report
dialog box.
For example: "Setup1
: Last Adaptive"

Reporter Editor Script Commands 12-75


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<ContextArray> Array of Context for which the expression is


Strings being evaluated. This can be an
empty string if there is no context.
<Domain> Array Array("Domain:=",
<DomainType>)
<DomainType>
ex. "Sweep" or "Time"
<Context> Array Array("Context:=", <Geo-
metryType>)
<GeometryType>
ex. "Infinite Spheren", "Spheren",
"Polylinen"
<FamiliesArray> Array of Contains sweep defin-
strings itions for the report.
Array("<Vari-
ableName>:= ", <ValueAr-
ray>)
<ValueArray> Array Array("All") or Array
("Value1", "Value2",
..."Valuen")
examples of <Vari-
ableName>
"Freq", "Theta",
"Distance"
<ReportDataArray> Array of This array contains the
Strings report quantity and X, Y,
and (Z) axis definitions.
Array("X Component:=",
<VariableName>, "Y
Component:=", <Vari-
ableName> |
<ReportQuantityArray>)
<ReportQuant- Array ex. Array("dB(S(Port1, Port1))")
ityArray>
Array() Empty Denotes the end of the
Array UpdateTraces Command

Return None
Value

Reporter Editor Script Commands 12-76


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python UpdateTraces ("<plotName>" ["<TraceDef>"] [])


Syntax

oModule.UpdateTraces("XY Plot 1", ["NEG1.VAL"], "TR4",


[
"NAME:Context",
"SimValueContext:=", [2,0,2,0,False,False,_
-
1,1,0,1,1,"",0,0,"CG",False,"0","KP",False,"0","MH",False,_
"100","TE",False,"100s","TH",False,"40",
"TS",False,"0ns","UF",False,_
Python "0","WT",False,"0","WW",False,"100"]
Exampl-
e ],
[
"Spectrum:=", ["All"]
],
[
"X Component:=", "Spectrum",
"Y Component:=", ["mag(NEG1.VAL)"]
], [])

oModule.UpdateTraces "XY Plot1", Array("dB(S


(WavePort1,WavePort1))"), _
"Setup1 : Sweep1", Array("Domain:=", "Time", "HoldTime:=",
1, _

VB "RiseTime:=", 0, "StepTime:=", 0, "Step:=", false, _


Examp-
"WindowWidth:=", 1, "WindowType:=", 0, "Kaiser-
le
Parameter:=",1, _
"MaximumTime:=", 0), Array("Time:=", Array("All")),_
Array("X Component:=", "Time",_
"Y Component:=", Array("dB(S(WavePort1,WavePort1))")),_

Reporter Editor Script Commands 12-77


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array()

For Circuit, the Update command details are as follows:

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 dialog, Apply Traces button
Syntax: UpdateTraces "<plotName>" Array("<TraceDef>") Array()
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.
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:=", <SimValueContext>)
Context for the trace. For more information see SimValueContext.

<FamiliesArray>
Type: Array of strings

Reporter Editor Script Commands 12-78


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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))")
Array()
Type: Empty array.
Denotes the end of the UpdateTraces command.

VB 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()

Reporter Editor Script Commands 12-79


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB 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()

For Q3D Extractor, the command details are as follows:


Update the traces in a report for which traces are not automatically updated by the Report Traces
dialog box, Update Report, Real Time selection.
Command: Report dialog, 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.

Reporter Editor Script Commands 12-80


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("Context:=", <DomainType>)
<DomainType>
ex. "Original" or "RM1"
Array("Context:=", <GeometryType>)
<GeometryType>
ex. "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"
<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("ACR(trace:src1, trace:src1)")
Array()
Type: Empty array.
Denotes the end of the UpdateTraces command.
VB Example: Set oModule = oDesign.GetModule("ReportSetup")
oModule.UpdateTraces "XY Plot1", _ Array("ACR(trace:src1,
trace:src1)"), _ "Setup1 : Sweep1", _
Array("Context:=", "Original"), _
Array("Freq:=", Array("All")), _
Array("X Component:=", "Freq", _
"Y Component:=", Array("ACR(trace:src1, trace:src1)"), _

Reporter Editor Script Commands 12-81


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array()

UpdateTracesContextandSweeps
Use this command to edit sweeps and context of multiple traces without affecting their component
expressions.

UI Access Modify Report with multiple traces selected.

Name Type Description


<ReportName> String Name of Report.
Array(<traceIDs>) String Name of Trace
<traceID>
<SolutionName> String Name of the solution as listed in the
Modify Report dialog box.
Parameters For example: "Setup1 : Last
Adaptive"
< ContextArray> 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> String Point set for the selected traces, for example,
X and Y values for the plot.

Return Value None

Python UpdateTracesContextandSweeps()
Syntax

oModule.UpdateTracesContextAndSweeps_
("Active S Parameter Quick Report",_
["dB(ActiveS(Port1:1))", "dB(ActiveS(Port2:1))"],_
"Setup1 : Sweep1", [], _
Python
["Freq:=", _
Example
["9GHz", "9.05GHz", "9.1GHz",
"9.15GHz", "9.2GHz", _
"9.25GHz", "9.3GHz", "9.35GHz", _
"9.4GHz", "9.45GHz", "9.5GHz",

Reporter Editor Script Commands 12-82


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"9.55GHz", _
"9.6GHz", "9.65GHz", "9.7GHz",_
"9.75GHz", "9.8GHz", "9.85GHz",
"9.9GHz", "9.95GHz", "10GHz"],_
"off-
set:=",["All"]])

VB Syntax UpdateTracesContextandSweeps
oModule.UpdateTracesContextAndSweeps_
"Active S Parameter Quick Report",_
Array( _
"dB(ActiveS(Port1:1))", "dB(ActiveS(Port2:1))"),_
"Setup1 : Sweep1", Array(), _
Array("Freq:=", _
Array( _
"9GHz", "9.05GHz", "9.1GHz",
VB
Example "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"),_

"off-
set:=", Array("All"))

An example related to Q3D Extractor is as follows:


VB Example: Set oProject = oDesktop.SetActiveProject("Via")
Set oDesign = oProject.SetActiveDesign("ViaModel")

Reporter Editor Script Commands 12-83


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oModule = oDesign.GetModule("ReportSetup")


oModule.UpdateTracesContextAndSweeps _
"C Matrix Quick Report", _
Array( _
"C(trace, trace)", "C(gnd, gnd)"), _
"Setup1 : Sweep1", Array ("Context:=", "Original")
Array("Freq:=", _
Array("All"))

UpdateAllReports
Updates all reports in the Results branch in the project tree.

UI Access Twin Builder>Results>Update All Reports

Name Type Description


Parameters
None

Return Value None

Python Syn- UpdateAllReports ()


tax

Python
oModule = oDesign.GetModule("ReportSetup")
Example oModule.UpdateAllReports()

VB Syntax UpdateAllReports ()

VB
Set oModule = oDesign.GetModule("ReportSetup")
Example oModule.UpdateAllReports

UpdateReports
Updates the specified reports in the Results branch in the project tree.
Update Report

UI Access NA

Reporter Editor Script Commands 12-84


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name Type Description


Parameters
<plotname> String Name of plot

Return Value None

Python UpdateReports(["<plotname>"])
Syntax

Python oModule.UpdateReports (["XY Plot 1", "XY Plot 4"])


Example

VB Syn- UpdateReports Array("<plotname>")


tax

VB oModule.UpdateReports Array("XY Plot 1", "XY Plot 4")


Example

UnGroupPlotCurvesInGroup
From a Stacked Plot ungroup curves in a stack, that is, curves in that stack are ungrouped and are
shown in their own stacks.
Command: UnGroup Plot Curves in ...
Syntax: oModule.UngroupPlotCurvesInGroup("<report-name>", "<stack-name>")
Return Value: None
Parameters: <ReportName>
Type: <string>
Report name.
<"stack-name">
Type: <string>
Stack name.
Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor

Reporter Editor Script Commands 12-85


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("CoaxBend14_1")
Set oDesign = oProject.SetActiveDesign("Transient")
Set oModule = oDesign.GetModule("ReportSetup")
oModule.GroupPlotCurvesByGroupingStrategy "Transient Plot 1", "Single"

Python oModule.MovePlotCurvesToGroup("<report-name>", ["<curve1-name>", "<curve2-


Syntax name>",...], "<stack-name>")
Python oModule.UngroupPlotCurvesInGroup("S Parameter Plot 3",
Exampl- "Stack 1"))
e

Reporter Editor Script Commands 12-86


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

13 - 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>)

Legal Names for Boundaries in HFSS Scripts

Anisotropic Impedance Master


Aperature Perfect E
Finite Conductivity Perfect H
Half Space Radiation
Impedance Slave
Layered Impedance Symmetry
Linked Impedance Fresnel SBR+
Lumped RLC

Boundary and Excitation Module Script Commands 13-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Legal Names for Excitations in HFSS Scripts

Circuit Port Cable Network


Floquet Port Plane Incident Wave
Lumped Port Hertizian-Dipole Incident Wave
Terminal Cylindrical Incident Wave
Wave Port Gaussian Beam
Voltage Linear Antenna Incident Wave
Current Far Field
Magnetic Bias Near Field

The topics for this section include:


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
Script Commands for Creating and Modifying Boundaries in 2D Extractor
Script Commands for Creating and Modifying Boundaries in Q3D Extractor

General Commands Recognized by the Bound-


ary/Excitations Module
AddAssignmentToBoundary
AutoIdentifyNets
AutoIdentifyPorts
AutoIdentifyTerminals
ChangeImpedanceMult
ConvertNPortCircuitElementToPorts
CreateNPortCircuitElement
DeleteAllBoundaries
DeleteAllExcitations
DeleteBoundaries
GetBoundaryAssignment
GetBoundaries
GetBoundariesOfType

Boundary and Excitation Module Script Commands 13-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetDefaultBaseName
GetExcitations
GetExcitationsOfType
GetNumBoundaries
GetNumBoundariesOfType
GetNumExcitations
GetNumExcitationsOfType
GetPortExcitationsCount
ReassignBoundary
RemoveAssignmentFromBoundary
RenameBoundary
ReprioritizeBoundaries
SetDefaultBaseName
AddAssignmentToBoundary
Use: Adds a new geometry assignment to a boundary.
Command: Click Boundaries>Reassign or Excitations>Reassign
Syntax: AddAssignmentToBoundary Array("Name:<BoundName>",
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)
Return Value: None
VB Example:
oModule.AddAssignmentTOBoundary Array("NAME:PerfE1",_
"Objects:=", Array("Box2", "Box3"),_
"Faces:=", Array(12, 11))
oModule.AddAssignmentToBoundary([ "NAME:SBR1", "Objects:=" , ["Fusel-
age"] ])

Python Syn- AddAssignmentToBoundary("NAME:<BoundaryName>", "Faces:=" ,


tax [<FaceID>]])

Python oModule.AddAssignmentToBoundary ((
Example [

Boundary and Excitation Module Script Commands 13-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"NAME:PerfE1",
"Faces:=" , [12]
])

AutoIdentifyNets
Use: Automatically identifies nets.
Command: Q3D Extractor>Nets>Auto Identify Nets
Syntax: AutoIdentifyNets
Return Value: None
Command: oModule.AutoIdentifyNets
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

VB Example:

Boundary and Excitation Module Script Commands 13-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oModule = oDesign.GetModule("BoundarySetup"


oModule.AutoIdentifyPorts Array("NAME:Faces", 52), true, _ Array
("NAME:ReferenceConductors", "Conductor1") true

AutoIdentifyTerminals
Use: Automatically identify the terminals within the given ports.
Command: HFSS>Excitations>Assign>Auto Assign Terminals
Syntax: AutoIdentifyTerminals <ReferenceConductorsArray>, <PortNames> <UseCon-
ductorNamesAsBaseNameforTerminals>
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
VB Example:
Set oModule = oDesign.GetModule("BoundarySetup"
oModule.AutoIdentifyTerminals Array("NAME:ReferenceConductors", "Con-
ductor1"), "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.
VB Example:

Boundary and Excitation Module Script Commands 13-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModule.ChangeImpedanceMult 0.5

ConvertNportCircuitElementsToPorts
Use: Converts one or more HFSS Circuit Element to one or more ports.
Command: Right-click on element and select Convert to HFSS Ports
Syntax: ConvertNportCircuitElementToHFSSPorts Array("<name> ")
Return Value: None
VB Example:
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.ConvertNportCircuitElementToPorts Array("Nport1")
oModule.ConvertNportCircuitElementToPorts Array("Nport2")

Python Syn- ConvertNportCircuitElementToPorts(<NportID>)


tax

oModule = oDesign.GetModule("BoundarySetup")
Python
oModule.ConvertNportCircuitElementToPorts(["Nport1"])
Example
oModule.ConvertNportCircuitElementToPorts(["Nport2"])

CreateNportCircuitElements
Use: Creates an HFSS Circuit Element from one or more ports..
Command: Right-click Circuit Elements>Create Single Port Model... or
Circuit Elements>Create Multi-Terminal Model...
Syntax: CreateNportCircuitElement("NAME:<Nportn>", "Definition:=" , "Model", [ "NAME:Assign-
ments", ["NAME: <ID>", Assign:=" , <ID>,] [...] ]
Return Value: None
VB Example:
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.CreateNportCircuitElement Array("NAME:Nport1", "Defin-
ition:=", "Model", Array("NAME:Assignments", Array("NAME:Model",
"Assign:=", "1")))
oModule.CreateNportCircuitElement Array("NAME:Nport2", "Defin-
ition:=", "Model2", Array("NAME:Assignments", Array("NAME:P01__
NET179__T1", "Assign:=", _

Boundary and Excitation Module Script Commands 13-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"2"), Array("NAME:P02__NET178__T1", "Assign:=", "3"), Array


("NAME:P03__NET178__T1", "Assign:=", _
"4"), Array("NAME:P04__NET179__T1", "Assign:=", "5")))

Python Syn- ReassignBoundary("NAME:<BoundaryName>", "Faces:=" ,[<FaceID>]])


tax

oModule.CreateNportCircuitElement(
[
"NAME:Nport1",
"Definition:=" , "Model",
[
"NAME:Assignments",
[
"NAME:Model",
"Assign:=" , "1"
]
]
])
Python
oModule.CreateNportCircuitElement(
Example
[
"NAME:Nport2",
"Definition:=" , "Model2",
[
"NAME:Assignments",
[
"NAME:P01__NET179__T1",
"Assign:=" , "2"
],
[
"NAME:P02__NET178__T1",
"Assign:=" , "3"

Boundary and Excitation Module Script Commands 13-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

],
[
"NAME:P03__NET178__T1",
"Assign:=" , "4"
],
[
"NAME:P04__NET179__T1",
"Assign:=" , "5"
]
]
])

DeleteAllBoundaries
Use: Deletes all boundaries.
Command: [product]>Boundaries>Delete All
Syntax: DeleteAllBoundaries
Return Value: None
VB Example: oModule.DeleteAllBoundaries

DeleteAllExcitations
Use: Deletes all excitations.
Command: [product]>Excitations>Delete All
Syntax: DeleteAllExcitations
Return Value: None
VB Example:
oModule.DeleteAllExcitations

DeleteBoundaries
Use: Deletes the specified boundaries and excitations.
Command: Delete command in the List dialog box. Click [product]>List to open the List dialog
box.

Boundary and Excitation Module Script Commands 13-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax: DeleteBoundaries <NameArray>


Return Value: None
Parameters: <NameArray>
Type: Array of strings
An array of boundary names.
VB 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.
VB Example:
list = oModule.GetBoundaryAssignment("Rad1")

GetBoundaries
Use: Gets boundary names for a project.
Syntax: GetBoundaries()
Return Value: Array of boundary names.
Parameters: None
VB 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>

Boundary and Excitation Module Script Commands 13-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type:<string>
Name of legal boundary type.
For example: "Radiation".
VB 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".
VB Example:
bnddefault_BaseName = oModule.GetDefaultBaseName "Radiation"

GetExcitations
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
VB Example:
excite_name_array = oModule.GetExcitations()

GetExcitationsOfType
Gets excitation names of the given type.
Syntax: GetExcitationsOfType(<ExcitationType>)
Return Value: Array of excitation names of the given type.

Boundary and Excitation Module Script Commands 13-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters: <ExcitationType>
Type: <string>
Name of legal excitation type.
For example: "Plane Incident Wave.
VB Example:
excite_name_array = _
oModule.GetExcitationsOfType("Wave Port")

GetNumBoundaries GetNumBoundaries
Gets the number of boundaries in a design.
Syntax: GetNumBoundaries()
Return Value: Integer count
Parameters: None
VB Example:
numbound = oModule.GetNumBoundaries()

GetNumBoundariesOfType
Gets the number of boundaries of the given type.
Syntax: GetNumBoundariesOfType(<BoundaryType>)
Return Value: Integer count
Parameters: <BoundaryType>
Type: <string>
VB Example:
numbound = oModule.GetNumBoundariesOfType("Perfect E")

GetNumExcitations
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 13-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Example:
numexcite = oModule.GetNumExcitations()

GetNumExcitationsOfType
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>
VB Example:
numexcite = oModule.GetNumExcitationsOfType("Voltage")
GetPortExcitationCounts
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
VB Example:
portinfo = oModule.GetPortExcitationCounts()

ReassignBoundary
Use: Specifies a new geometry assignment for a boundary.
Command: Click Boundaries>Reassign or Excitations>Reassign
Syntax: ReassignBoundary Array("Name:<BoundName>",
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)
Return Value: None
VB Example:
oModule.ReassignBoundary Array("NAME:PerfE1",_
"Objects:=", Array("Box2", "Box3"),_

Boundary and Excitation Module Script Commands 13-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Faces:=", Array(12, 11))


oModule.ReassignBoundary([ "NAME:SBR1", "Objects:=" , ["Fuselage"]
])
For Q3D Extractor, the command details are as follows:
Use: Specifies a new geometry assignment for a net/terminal.
Command: Q3D Extractor>Nets>Reassign>Net
Syntax: ReassignBoundary Array("Name:<BoundName>",
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)
Return Value: None
VB Example: oModule.ReassignBoundary Array("NAME:Net1",_
"Objects:=", Array("Box2", "Box3"),_
"Objects:=", Array("Box3", "Box4"))

For 2D Extractor, the command details are as follows:


Use: Specifies a new geometry assignment for a net/terminal.
Command: 2D Extractor>Conductor>Reassign
Syntax: ReassignBoundary Array("Name:<BoundName>",
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)
Return Value: None
VB Example: oModule.ReassignBoundary Array("NAME:Rectangle2",
"Objects:=", Array("Rectangle3"))

Python Syn- ReassignBoundary("NAME:<BoundaryName>", "Faces:=" ,[<FaceID>]])


tax

oModule.ReassignBoundary ((
[
Python
"NAME:PerfE1",
Example
"Faces:=" , [12]
])

Boundary and Excitation Module Script Commands 13-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

RemoveAssignmentFromBoundary
Use: Removes a geometry assignment from a boundary.
Command: Click Boundaries>Reassign or Excitations>Reassign
Syntax: RemoveAssignmentFromBoundary Array("Name:<BoundName>",
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)
Return Value: None
VB Example:
oModule.RemoveAssignmentFromBoundary Array("NAME:PerfE1",_
"Objects:=", Array("Box2", "Box3"),_
"Faces:=", Array(12, 11))
oModule.RemoveAssignmentFromBoundary([ "NAME:SBR1", "Objects:=" ,
["Fuselage"] ])

Python Syn- RemoveAssignmentFromBoundary("NAME:<BoundaryName>", "Faces:=" ,


tax [<FaceID>]])
oModule.RemoveAssignmentFromBoundary ((
[
Python
"NAME:PerfE1",
Example
"Faces:=" , [12]
])

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>

Boundary and Excitation Module Script Commands 13-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type: <string>
VB 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 bound-
aries and excitations appear in the list. All ports must be listed before any other boundary type.
Command: [product]>Boundaries>Reprioritize
Syntax: ReprioritizeBoundaries <NewOrderArray>
Return Value: None
Parameters: <NewOrderArray>
Array("NAME:NewOrder", <BoundName>, <BoundName>, ...)
VB 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.
For example: "Radiation".
<NewName>
Type: <string>
VB Example:
bnddefault_BaseName = oModule.SetDefaultBaseName "Radiation",_
"RadBnd"

Boundary and Excitation Module Script Commands 13-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.
AssignCircuitPort [HFSS]
AssignCurrent
AssignDielectricCavity
AssignFiniteCond
AssignFloquet
AssignHalfSpace
AssignHybridRegion
AssignIERegion
AssignImpedance
AssignIncidentWave
AssignLayeredImp
AssignLinkedRegion
AssignLumpedPort
AssignLumpedRLC
AssignMagneticBias
AssignMaster
AssignPerfectE
AssignPerfectH
AssignRadiation
AssignRadiation
AssignScreeningImpedance
AssignSymmetry
AssignTerminal
AssignVoltage
AssignWavePort
CircuitPortToLumpedPort
EditCircuitPort [HFSS]

Boundary and Excitation Module Script Commands 13-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

EditCurrent
EditDiffPairs
EditFiniteCond
EditHalfSpace
EditHybridRegion
EditImpedance
EditIncidentWave
EditLayeredImpedance
EditMaster
EditPerfectE
EditPerfectH
EditLumpedPort
EditLumpedRLC
EditMagneticBias
EditNPortCircuitElement
EditRadiation
EditSlave
EditSymmetry
EditTerminal
EditVoltage
EditWavePort
LumpedPortToCircuitPort
SetHybridRegionCoupledGroup
SetSBRSources
SetSBRWedgeSettings
SetTerminalReferenceImpedances
SwapCircuitPortAssignment
UnassignIERegions
AssignCircuitPort
Use: Assigns a circuit port for a driven terminal or driven modal design in HFSS.

Boundary and Excitation Module Script Commands 13-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Command: HFSS>Excitations>Assign>Circuit Port...


Syntax: AssignCircuitPort <parameters>
Return Value: None
Parameters: <CircuitPortArray>
Array("NAME:<PortName>",
"Edges:=", [n1, n2],
"Impedance:=", "valueohm",
DoDeembed:=", <boolean>
"RenormalizeAllTerminals:=", <boolean>
"TerminalIDLit:=", Array()
)

VB Example:
oModule.AssignCircuitPort Array("NAME:1",
"Edges:=", Array(50, 56), _
"Impedance:=", "50ohm", _
"DoDeembed:=", true, _
"RenormalizeAllTerminals:=", true,_
"TerminalIDList:=", Array())

Python Syn- AssignCircuitPort (<parameters>)


tax

oModule.AssignCircuitPort(
[
"NAME:1",

Python "Edges:=" , [50,56],


Example "Impedance:=" , "50ohm",
"DoDeembed:=" , False,
"RenormalizeAllTerminals:=", True,
"TerminalIDList:=" , []

Boundary and Excitation Module Script Commands 13-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

])

AssignCurrent
Use: Creates a current source.
Command: [product]>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))
AssignDielectricCavity
Use: Assign a Hybrid Region as a Dielectric Cavity.
Command: HFSS>Hybrid>Assign Hybrid>Dielectric Cavity
Syntax: AssignDielectricCavity Array(<name><"geometryName">)
Return Value: None
Parameters: <GeometryName>

Boundary and Excitation Module Script Commands 13-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type: String
Name of the FEBI Hybrid Region.
<GeometryName>
Type: String
Name of the geometry assigned as Dielectric Cavity Region.
<"geometryName">
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project17")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oModule.AssignDielectricCavity Array("NAME:Cavity1", "Objects:=",
Array("Cylinder1"))
AssignFEBI
Assign a Hybrid Region as a FEBI.
Command: HFSS>Hybrid>Assign Hybrid>FEBI
Syntax: AssignFEBI Array(<name><"geometryName">)
Return Value: None
Parameters: <name>
Type: String
Name of the FEBI Hybrid Region.
<name>

Boundary and Excitation Module Script Commands 13-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type: String
Name of the geometry assigned as FEBI Hybrid Region.
<"geometryName">
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project17")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignFEBI Array("NAME:FE-BI1", "Objects:=", Array("Regu-
larPolyhedron1"))

AssignFiniteCond
Use: Assign a single finite conductivity boundary on selected edges.
Command: 2D Extractor>Boundary>Assign>Finite Conductivity
Syntax: AssignFiniteCond Array("NAME:<Name>", "Edges:=", Array(<edge ids>), <Fin-
iteCondParameters>)
Return Value: none
Parameters: <Name>
Type:<String>
Name of the boundary
<edge ids>
Type:<integer list>
List of edge ids, separated by comma.
<FiniteCondParameters>

Boundary and Excitation Module Script Commands 13-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters:
"Roughness:=", "<Roughness>", "UseCoating:=", <UseCoating>, "Lay-
erThickness:=", "<Thickness>", "UseMaterial:=", <UseMaterial>,
"Material:=", "<MaterialName>"
<Roughness>
Type: <String>
Value: double with units of length
<UseCoating>
Type: <Boolean>
Value: true or false
<Thickness>
Type: String
Value: double with units of length
<UseMaterial>
Type:<Boolean>
Value: true or false
<MaterialName>
Type: String
Value: specify material name for coating.
<Radius>
Type: String
Value: double with units of length.
<Ratio>
Type: String
Value: double.

VB Example: This example is for the Hammerstad-Jensen surface rough-


ness model.

oModule.AssignFiniteCond Array("NAME:FiniteCond1", "Edges:=", Array


(7, 9), "Roughness:=", _ "2um", "UseCoating:=", true, "Lay-
erThickness:=", "1.2um", "UseMaterial:=", _ true, "Material:=", "Cop-
per")

Boundary and Excitation Module Script Commands 13-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Example: This example is for the Hurray surface roughness model.

oModule.AssignFiniteCond Array("NAME:FiniteCond1", "Edges:=", Array


(7), "UseCoating:=", _ false, "Radius:=", "0.5um", "Ratio:=", "2.9")

AssignFloquet
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",

Boundary and Excitation Module Script Commands 13-23


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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",
"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>)))

Boundary and Excitation Module Script Commands 13-24


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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,

Boundary and Excitation Module Script Commands 13-25


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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,
"PolarizationState:=", "TM", "AffectsRefinement:=", false)))

AssignHalfSpace
Use: Assign a Half Space boundary, dividing the background material at a specified Z axis point.
You also assign a material, typically to the lower half.
Command: Assign Half Space
Syntax: AssignHalfSpace Array("NAME:HalfSpacen", "ZLocation:=", "<intUnits>", "Material:=",
"<string>")
Return Value: None
Parameters: "NAME:<stringN>"
String
ZLocation
Z value and Units
Materials
<string> defining the material.
VB Example:
oModule.AssignHalfSpace Array("NAME:HalfSpace1", "ZLocation:=",
"2mm", "Material:=", "water_sea")

Boundary and Excitation Module Script Commands 13-26


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Assign Hybrid Region


Assign a Hybrid Region to a conductor, one of IE, PO, or SBR.
Command: Assign Hybrid Region
Syntax: AssignHybridRegion Array("Name:<Hybridn>", "Objects:=", Array("<geometryName>"),
"Type:=, "<HybridRegionType>", "IsLinkedRegion:=" <boolean>)
Return Value: None
Parameters: <Name>
Type: String
Name of the Hybrid Region.
<GeometryName>
Type: String
Name of the geometry assigned as Hybrid Region.
<HybridRegionType>
Type: String
One of "IE", "PO" or "SBR"
<boolean>
true, or false (default)
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project17")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")

Boundary and Excitation Module Script Commands 13-27


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModule.AssignHybridRegion Array("NAME:Hybrid1", "Objects:=", Array


("RegularPolyhedron1"), "Type:=", "IE", _
"IsLinkedRegion:=", false)
AssignIERegion
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:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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: [product]>Boundaries>Assign>Impedance
Syntax: AssignImpedance <ImpedanceArray>

Boundary and Excitation Module Script Commands 13-28


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Return Value: None


Parameters: <ImpedanceArray>
Array("NAME:<BoundName>",
"Resistance:=", <value>,
"Reactance:=", <value>,
"InfGroundPlane:=", <bool>,
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)
VB 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>,

Boundary and Excitation Module Script Commands 13-29


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"PhiStop:=", <value>,
"PhiPoints:=", <int>,
"ThetaStart:=", <value>,
"ThetaStop:=", <value>,
"ThetaPoints:=", <int>,
"EoPhi:=", <value>,
"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.
VB Example:
oModule.AssignIncidentWave Array("NAME:IncWave1",_
"IsCartesian:=", true,_
"EoX:=", "1", "EoY:=", "0", "EoZ:=", "0",_
"kX:=", "0", "kY:=", "0", "kZ:=", "1")
VB 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.

Boundary and Excitation Module Script Commands 13-30


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Command: HFSS>Boundaries>Assign>Layered Impedance


Syntax: AssignLayeredImp <LayeredImpArray>
Return Value: None
Parameters: <LayeredImpArray>
Array("NAME:<BoundName>",
"Frequency:=", <value>,
"Roughness:=", <value>,
"IsInternal:=", <bool>,
"IsTwoSided:=", <bool>,
"IsShellElement:=", <bool>,
<LayersArray>,
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)

<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"

Boundary and Excitation Module Script Commands 13-31


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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 Lay-
erType is "PerfectE" or "PerfectH".
InfGroundPlane <boolean>
For HFSS designs, you can specify whether one layer is an infinite ground plane.
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("tune_coax_fed_patch")
Set oDesign = oProject.SetActiveDesign("HFSSDesign2")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignLayeredImp Array("NAME:Layered1",
"Objects:=", Array("Rectangle1"),
"Frequency:=", "0GHz",
"Roughness:=", "0um",
"IsTwoSided:=", true,
"IsShellElement:=", true,
Array("NAME:Layers", Array("NAME:Layer1",
"Thickness:=", "1um", "Material:=", "vacuum")),
"InfGroundPlane:=", false)

AssignLinkedRegion
Use: Assign a Hybrid Region as a Linked Region.
Command: HFSS>Hybrid>Assign Hybrid>Linked Region

Boundary and Excitation Module Script Commands 13-32


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax: AssignLinkedRegion Array(<name><"geometryName">, Type:=, "IE", IsLinkedRegion:="


true))
Return Value: None
Parameters: <name>
Type: String
Name of the Linked Region.
<name>
Type: String
Name of the geometry assigned as a Linked Region.
<"geometryName">

VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project17")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignLinkedRegion Array("NAME:Linked1", "Objects:=", Array(
_
"RegularPolyhedron1"), "Type:=", "IE", "IsLinkedRegion:=", true)
AssignLumpedPort
Creates a lumped port.
Command: HFSS>Excitations>Assign>Lumped Port
Syntax: AssignLumpedPort <LumpedPortArray>

Boundary and Excitation Module Script Commands 13-33


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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),_
"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:
Dim oAnsoftApp

Boundary and Excitation Module Script Commands 13-34


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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")

AssignLumpedRLC
Use: Creates a lumped RLC boundary.
Command: HFSS>Boundaries>Assign>Lumped RLC
Syntax: AssignLumpedRLC <LumpedRLCArray>
Return Value: None
Parameters: <LumpedRLCArray>
Array("NAME:<BoundName>",
"RLC Type:=" , <"Parallel" | "Serial" >,
"UseResist:=",<bool>,
"Resistance:=", <value>,

Boundary and Excitation Module Script Commands 13-35


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"UseInduct:=", <bool>,
"Inductance:=", <value>,
"UseCap:=", <bool>,
"Capacitance:=", <value>,
<CurrentLineArray>,
"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)

<CurrentLineArray>
Array("NAME:CurrentLine", _
"Start:=", <LineEndPoint>,
"End:=", <LineEndPoint>)
VB Example:
oModule.AssignLumpedRLC Array("NAME:LumpRLC1",_
"RLC Type:=" ," Parallel" ,
"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))

Python Syn- AssignLumpedRLC (<Parameters>)


tax

oModule.AssignLumpedRLC(
Python
[
Example
"NAME:LumpRLC1",

Boundary and Excitation Module Script Commands 13-36


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Objects:=" , ["Box1"],
[
"NAME:CurrentLine",
"Start:=" , ["0.15mm","-0.2mm","0mm"],
"End:=" , ["0.15mm","0.6mm","0mm"]
],
"RLC Type:=" , "Parallel",
"UseResist:=" , True,
"Resistance:=" , "100ohm",
"UseInduct:=" , True,
"Inductance:=" , "10nH",
"UseCap:=" , True,
"Capacitance:=" , "10pF"
])

AssignMagneticBias
Use: Creates a magnetic bias source.
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.

Boundary and Excitation Module Script Commands 13-37


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

If false, supply the Project parameter.


VB Example:
oModule.AssignMagneticBias Array("NAME:MagBias1",_
"IsUniformBias:=", true,_
"Bias:=", "1",_
"XAngle:=", "10deg",_
"YAngle:=", "10deg",_
"ZAngle:=", "10deg",_
"Objects:=", Array("Box2"))
VB 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
Parameters:<MasterArray>
Array("NAME:<BoundName>",
<CoordSysArray>,
"ReverseV:=", <bool>,
"Faces:=", <AssignmentFaces>)

<CoordSysArray>
Array("NAME:CoordSysVector",
"Origin:=", <CoordSysPoint>,
"UPos:=", <LineEndPoint>)

Boundary and Excitation Module Script Commands 13-38


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB 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>)
VB Example:
oModule.AssignPerfectE Array("NAME:PerfE1",_
"InfGroundPlane:=", false,_
"Faces:=", Array(12))

AssignPerfectH
Creates a perfect H boundary.
Command:HFSS>Boundaries>Assign>PerfectH
Syntax: AssignPerfectH <PerfectHArray>
Return Value: None
Parameters: <PerfectHArray>
Array("Name:<BoundName>",

Boundary and Excitation Module Script Commands 13-39


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Objects:=", <AssignmentObjects>,
"Faces:=", <AssignmentFaces>)
VB Example:
oModule.AssignPerfectH Array("NAME:PerfH1",_
"Faces:=", Array(12))

AssignRadiation
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:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")

Boundary and Excitation Module Script Commands 13-40


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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
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>"

Boundary and Excitation Module Script Commands 13-41


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

If true, then specify the external link array with the project and solution to use. Also see
the second example.
Array("NAME:XLink",
"Project:=", "<projectName>.aedt",
"Design:=", "<DesignName>",
"Soln:=", "Setup1 : LastAdaptive",
Array("NAME:Params", "<variable>:=", "<value>"),
"ForceSourceToSolve:=", <Boolean>,
"PreservePartnerSoln:=", <Boolean>,
"PathRelativeTo:=", "TargetProject"),
Array("NAME:YLink",
"Project:=", "<projectName>.aedt",
"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("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project53")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")

Boundary and Excitation Module Script Commands 13-42


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oModule = oDesign.GetModule("BoundarySetup")


oModule.AssignScreeningImpedance Array("NAME:Screening1",
"Faces:=", Array(12),
"IsAnisotropic:=", false,
"HasExternalLink:=", false,
"XResistance:=", "377", "XReactance:=", "0")

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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", "Object-
s:=", Array( "Rectangle1"),
"IsAnisotropic:=", true,
"CoordSystem:=", 1,
"HasExternalLink:=", true,
Array("NAME:XLink",
"Project:=", "mydesign.aedt",
"Design:=", "HFSSDesign1",
"Soln:=", "Setup1 : LastAdaptive",
Array("NAME:Params", "bend_angle:=", "50deg"),
"ForceSourceToSolve:=", false,
"PreservePartnerSoln:=", false,
"PathRelativeTo:=", "TargetProject"),
Array("NAME:YLink", "Project:=", "mydesign.aedt",
"Design:=", "HFSSDesign1",
"Soln:=", "Setup1 : LastAdaptive",
Array("NAME:Params", "bend_angle:=", "50deg"),
"ForceSourceToSolve:=", true,

Boundary and Excitation Module Script Commands 13-43


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"PreservePartnerSoln:=", true,
"PathRelativeTo:=", "TargetProject"))

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.
VB Example:
oModule.AssignSlave Array("NAME:Slave1",_
Array("NAME:CoordSysVector", _
"Origin:=", Array(-1, 0, 0.2),_
"UPos:=", Array(-1, 0, 0)),_
"ReverseV:=", false,_
"Master:=", "Master1",_

Boundary and Excitation Module Script Commands 13-44


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"UseScanAngles:=", true,_
"Phi:=", "10deg",_
"Theta:=", "0deg",_
"Faces:=", Array(12))
VB Example:
oModule.AssignSlave Array("NAME:Slave2",_
Array("NAME:CoordSysVector",_
"Origin:=", Array(-1, 0, 0.2),_
"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>)
VB Example:
oModule.AssignSymmetry Array("NAME:Sym1",_
"IsPerfectE:=", true,_
"Faces:=", Array(12))

Boundary and Excitation Module Script Commands 13-45


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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
Name of Port.
<value>
Type: string
Value and units for the resistance.
VB Example:
oModule.AssignTerminal Array("NAME:Rectangle1_T1", _
"Edges:=", Array(36), "ParentBndID:=", _
"WavePort1", "TerminalResistance:=", "50ohm")

For Q3D Extractor the command details are as follows:


Use: Assigns 1D and 2D terminals.
Command: Q3D Extractor>Nets>AssignTerminals
Syntax: AssignTerminals <TerminalArray>
<TerminalArray>
Array("NAME:AssignTerminals",

Boundary and Excitation Module Script Commands 13-46


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("Name:SourceList", Array("Name:<SourceName>", "Net:=",


<NetObject>, "Objects:=", <Assignment 2D/1D>)),
Array("Name:SinkList", Array("Name:<SinkName>", "Net:=", <NetOb-
ject>, "Objects:=", <Assignment 2D/1D>)),
"Name:DeleteList", <Name Array>)
Return Value: None
VB Example: Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignTerminals Array("NAME:AssignTerminals", Array
("NAME:SourceList", Array("NAME:Polyline2", "Objects:=", Array(
"Polyline2"), "ParentBndID:=", "Box1", "Net:=", "Box1"), Array
("NAME:Rectangle1", "Objects:=", Array( "Rectangle1"), "Par-
entBndID:=", "Box1", "Net:=", "Box1")), Array("NAME:SinkList"),
"DeleteList:=", _ "")

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>)
VB Example:
oModule.AssignVoltage Array("NAME:Voltage1",_
"Voltage:=", "1000mV",_

Boundary and Excitation Module Script Commands 13-47


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.
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>, ...)

Boundary and Excitation Module Script Commands 13-48


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<OneModeArray>
Array("NAME:<ModeName>",
"ModeNum:=", <int>,
"UseIntLine:=", <bool>,
<IntLineArray>)

<ModeName>
Type: <string>
Name of the mode. Format is "Mode<int>". For example "Mode1".

<IntLineArray>
Array("NAME:IntLine",
"Start:=", <LineEndPoint>,
"End:=", <LineEndPoint>,
"CharImp:=", <string>)
CharImp
Characteristic impedance of the mode. Possible values are "Zpi", "Zpv", or "Zvi"
VB 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,_

Boundary and Excitation Module Script Commands 13-49


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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))
VB Example: Terminal problem:
oModule.AssignWavePort Array("NAME:WavePort1",_
"Faces:=", Array(11)
"NumModes:=", 2,_
"PolarizeEField:=", false,_
"DoDeembed:=", false,
"TeminalIDList:=", Array()
)

CircuitPortToLumpedPort
Use: Converts a circuit port to a lumped port for a driven terminal or driven modal design in HFSS.
Command: Convert to Lumped Port
Syntax: CIrcuitPortToLumpedPort ("<PortName>")
Return Value: None
Parameters: <PortName>

VB Example:
oModule.CircuitPortToLumpedPort("1")

Python Syn- CircuitPortToLumpedPort (<PortName>)


tax

Python CircuitPortToLumpedPort("1")

Boundary and Excitation Module Script Commands 13-50


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Example

EditCircuitPort [HFSS]
Use: Edits a circuit port for a driven terminal or driven modal design in HFSS.
Command: Properties
Syntax: EditCircuitPort <parameters>
Return Value: None
Parameters: <CircuitPortArray>
Array("NAME:<PortName>",
"Impedance:=", "valueohm",
DoDeembed:=", <boolean>
"RenormalizeAllTerminals:=", <boolean>
"TerminalIDLit:=", Array()
)

VB Example:
oModule.EditCircuitPort Array("NAME:1",
"Impedance:=", "50ohm", _
"DoDeembed:=", true, _
"RenormalizeAllTerminals:=", true,_
"TerminalIDList:=", Array())

Python Syn- EditCircuitPort (<parameters>)


tax

oModule.EditCircuitPort(
[
"NAME:1",
Python
"Impedance:=" , "50ohm",
Example
"DoDeembed:=" , False,
"RenormalizeAllTerminals:=", True,
"TerminalIDList:=" , []

Boundary and Excitation Module Script Commands 13-51


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

])

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

Boundary and Excitation Module Script Commands 13-52


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name of the terminal to use as the negative terminal.

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.
VB 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: Edit parameters of single finite conductivity boundary.
Command: Double-click finite conductivity boundary in project tree.
Syntax: EditFiniteCond <BoundaryName>, Array("NAME:<Name>", <FiniteCondParameters>)
Return Value: none
Parameters: <BoundaryName>
Type: <String>
Name of the boundary to edit.
<Name>
Type:<String>

Boundary and Excitation Module Script Commands 13-53


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name of the boundary


<FiniteCondParameters>
Parameters:
"Roughness:=", "<Roughness>", "UseCoating:=", <UseCoating>, "Lay-
erThickness:=", "<Thickness>", "UseMaterial:=", <UseMaterial>,
"Material:=", "<MaterialName>"
<Roughness>
Type: <String>
Value: double with units of length
<UseCoating>
Type: <Boolean>
Value: true or false
<Thickness>
Type: String
Value: double with units of length
<UseMaterial>
Type:<Boolean>
Value: true or false
<MaterialName>
Type: String
Value: specify material name for coating.
VB Example: oModule.EditFiniteCond "FiniteCond1", Array("NAME:Fin-
iteCond1", "Roughness:=", "2um", "UseCoating:=", _ false)
EditHalfSpace
Use: Edit a Half Space boundary name, Z location, and or materials.
Command: Edit Properties
Syntax: EditHalfSpace Array("NAME:HalfSpacen", "ZLocation:=", "<intUnits>", "Material:=",
"<string>")
Return Value: None
Parameters: "NAME:<stringN>"
String
ZLocation

Boundary and Excitation Module Script Commands 13-54


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Z value and Units


Materials
<string> defining the material.
VB Example:
oModule.EditHalfSpace "HalfSpace1", Array("NAME:HalfSpace1", "ZLoca-
tion:=", "3mm", "Material:=", "tungsten")
EditHybridRegion
Use:Edit a Hybrid Region boundary name.
Command: Edit Properties
Syntax:EditHybridRegion Array("<Name>", "NAME:<newName>",)
Return Value: None
Parameters: "NAME:<stringN>"
VB Example:
oModule.EditHybridRegion "SBR11", Array("NAME:SBR2")
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
EditIncidentWave
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

Boundary and Excitation Module Script Commands 13-55


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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",
"MinFreq:=", "100MHz",
"MaxFreq:=", "1GHz",
"Delay:=", "0.2s",
"NumFreqsExtracted:=", 401,
"SweepMinFreq:=", "100MHz",
"SweepMaxFreq:=", "1GHz",
"IsPropagating:=", true,

Boundary and Excitation Module Script Commands 13-56


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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
EditLumpedPort
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"

Boundary and Excitation Module Script Commands 13-57


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<ModesArray>,
"TerminalIDList:=", <TerminalsArray>,
"FullResistance:=", <value>,
"FullReactance:=", <value>,
)
Return Value: None
Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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:=", _
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

Boundary and Excitation Module Script Commands 13-58


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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
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>))
Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")

Boundary and Excitation Module Script Commands 13-59


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.
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>

Boundary and Excitation Module Script Commands 13-60


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME: <TerminalName>", "ParentBndID:=", "<PortName>", "Ter-


minalResistance:=," <value>")
<TerminalName>
Type:String
<PortName>
Type: String
<value>
Type: <string>
Value and units of resistance.
VB 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
EditVoltageDrop
Use: Edits a voltage drop excitation.
Command: Double-click the excitation in the project tree to edit it.
Syntax:EditVoltageDrop <BoundName> <VoltageDropArray>
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
VB Example:

Boundary and Excitation Module Script Commands 13-61


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

LumpedPortToCircuitPort
Use: Converts a lumped port to a circuit port for a driven terminal or driven modal design in HFSS.
Command: Convert to Circuit Port
Syntax: LumpedPortToCircuitPort ("<PortName>")
Return Value: None
Parameters: <PortName>

VB Example:
oModule.LumpedPortToCircuitPort("1")

Python Syn- LumpedPortToCircuitPort (<PortName>)


tax

Python LumpedPortToCircuitPort("1")
Example

SetHybridRegionCoupledGroup
Use: To set coupling for hybrid regions.
Command: HFSS>HybridRegions>Set Coupling
Syntax: SetHybridRegionCoupledGroup <value>
Return Value: None
Parameters: <value>
Type: <string>
"OneWayCoupled" or "TwoWayCoupled" for all regions or "Advanced", Array("One
Way:= <hybridregionname>, Array(Two Way:=", Array("<hybridregionname>" , )))
VB Example:
Setting All Hybrid Regions to One Way Coupled
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule

Boundary and Excitation Module Script Commands 13-62


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")


Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project35")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.SetHybridRegionCoupledGroup "OneWayCoupled"
Setting All Hybrid Regions to Two Way Coupled
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project35")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.SetHybridRegionCoupledGroup "TwoWayCoupled"
Setting Hybrid Region Groupings
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()

Boundary and Excitation Module Script Commands 13-63


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project35")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.SetHybridRegionCoupledGroup "Advanced", Array("One Way:=",
Array("Two Way:=", Array( _
"Hybrid1", "Hybrid2")))
SetTerminalReferenceImpedances
Use: To set the reference impedance for all terminals within a specified port.
Command: HFSS>Excitations>Set Terminal Reference Impedances or HFSS-IE>Ex-
citations>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.
VB Example:
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.SetTerminalReferenceImpedances "75ohm", "WavePort1"

SetSBRSources
Designs containing SBR+ regions will always be set to All One-Way and the Set Coupling menu is
replaced by the Set SBR+ Source Regions command. Non-SBR+ regions will serve as sources,
and interact with each other through the SBR+ regions. All source regions interact as one-way
links to SBR+ and coupling between the source regions are handled by SBR+ using reciprocity the-
ory. If Global Setting is selected, Current Source Conformance, Thin Sources, and Power Fraction
are not recorded.
Command: SetSBR+ Source Regions
Syntax: SetSBRSources (<parameters>)

Boundary and Excitation Module Script Commands 13-64


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters: "Name:Two Way", "Regions:=", [<Region Names>], "Use Glob-


al:=" <boolean>, "Far Field Source CS:=" "<string>", "Current Source
Conformance:=", "Auto" | "Enable" | "Disable", "Thin Sources:=",
<boolean>, "Power Fraction:=", "decimal less than 1 and greater than
0.1"
Return Value: None

VBS Example Modal and Terminal Solution Type:


oModule.SetSBRSources Array(Array
("NAME:Two Way",
"Regions:=", Array("FE-BI3", "Hybrid2")
"Use Global:= True
),
(Name: Two Way",
"Regions:=", Array("FE-BI1", "FE-BI2")
"Far Field Source CS:=", "Global"
),
("NAME:Hybrid3",
"Use Global:= False,
"Use Current Source Conformance:=", "Auto",
"Thin Sources:=", False
),
("NAME:Hybrid4",
"Use Global:= False,
"Use Current Source Conformance:=", "Enable",
"Thin Sources:=", True
"Power Fraction:=", 0.42
),
)

Python Syn- SetSBRSources (<parameters>)


tax

Boundary and Excitation Module Script Commands 13-65


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModule.SetSBRSources(
[
["NAME:Two Way",
"Regions:=", ["FE-BI3", "Hybrid2"],
"Use Global:= True
],
[
Name: Two Way",
"Regions:=", ["FE-BI1", "FE-BI2"],
"Far Field Source CS:=", "Global"
],
[
Python
"NAME:Hybrid3",
Example
"Use Global:= False,
"Use Current Source Conformance:=", "Auto",
"Thin Sources:=", False
],
[
"NAME:Hybrid4",
"Use Global:= False,
"Use Current Source Conformance:=", "Enable",
"Thin Sources:=", True,
"Power Fraction:=", 0.42
[,
])

SetSBRWedgeSettings
For designs with an SBR+ Region, set SBR wedge settings.
Command: Set SBR WedgeSettings
Syntax: SetSBRWedgeSettings Array("Name:SBRWedgeSettings", <parameters>)

Boundary and Excitation Module Script Commands 13-66


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters:"MaxWedgeAngle:=" <"ndeg">
"IncludeSheetEdges:=" <bool>
"ApplySourceDistFilter:="<bool>
"SourceX:=" <x coord>, "SourceY:=" <Y coord>, and "SourceZ:=" <Z
coord>,
"CS:=" "<CS Name>,
"DistFromSource:=", "n<units>",
"ApplyBoxFilter:=", <bool>
If false, no additional parameters. If True:
"Box:=" <BoxID>
Return Value: None

VBS Example
oModule.SetSBRWedgeSettings Array("NAME:SBRWedgeSettings",
"MaxWedgeAngle:=", _
"135deg", "IncludeSheetEdges:=", true, "ApplySourceDistFilter:=",
true, "SourceX:=", _
0, "SourceY:=", 0, "SourceZ:=", 0, "CS:=", "Global",
"DistFromSource:=", _
"1000mm", "ApplyBoxFilter:=", false)

Python Syn- SetSRBWedgeSettings (<parameters>)


tax

oModule.SetSBRWedgeSettings(
[
"NAME:SBRWedgeSettings",
"MaxWedgeAngle:=" , "135deg",
Python
Example
"IncludeSheetEdges:=" , True,
"ApplySourceDistFilter:=", True,
"SourceX:=" , 0,
"SourceY:=" , 0,
"SourceZ:=" , 0,

Boundary and Excitation Module Script Commands 13-67


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"CS:=" , "Global",
"DistFromSource:=" , "1000mm",
"ApplyBoxFilter:=" , True
"Box:=" , "Box1"
])

SwapCircuitPortAssignment
Use: Swaps the terminal and reference assignments on a circuit port.
Command: Swap Direction
Syntax: SwapCircuitPortAssignment ("<PortName>")
Return Value: None
Parameters: <PortName>

VB Example:
oModule.SwapCircuitPortAssignment("1")

Python Syn- SwapCircuitPortAssignment (<PortName>)


tax

Python SwapCircuitPortAssignment("1")
Example

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:

Dim oAnsoftApp

Boundary and Excitation Module Script Commands 13-68


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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")

Script Commands for Creating and Modifying Boundaries


in HFSS-IE
AssignAperture [HFSS-IE]
AssignFiniteCond [HFSS-IE]
AssignHalfSpace [HFSS-IE]
AssignImpedance [HFSS-IE]
AssignInfiniteGroundPlane [HFSS-IE]
AssignLumpedPort [HFSS-IE]
AssignAperture [HFSS-IE]
Use: Creates an aperature boundary on a sheet in an HFIE design.
Command: HFSS-IE>Boundary>Assign>Aperture...
Syntax: AssignAperture Array("NAME:<boundName>", "Objects:=", Array("<sheetName>"))
Parameters: <boundName>
Type: <string>
Boundary name.
<sheetName>
Type: <string>

Boundary and Excitation Module Script Commands 13-69


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name of the sheet object to which you assign the boundary


Return Value: None
VB 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>,
"Conductivity:=", <value>,
"Permeability:=", <value>,
"InfGroundPlane:=", <bool>,
"Faces:=", <AssignmentFaces>)

UseMaterial
If True, provide Material parameter.
If False, provide Conductivity and Permeability parameters.
VB Example:
oModule.AssignFiniteCond Array("NAME:FiniteCond1",_
"Objects:=", Array("Rectangle2"), _
"UseMaterial:=", false, _

Boundary and Excitation Module Script Commands 13-70


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Conductivity:=", "58000000", _
"Permeability:=", "1", _
"Roughness:=", "0um", _
"UseThickness:=", false)
AssignHalfSpace [HFSS-IE]
Use: Creates a Half Space boundary for an HFSS-IE design.
Command: HFSS-IE>Boundaries>Assign>Half Space
Syntax: AssignHalfSpace Array("NAME:HalfSpacen", "ZLocation:=, <Value><Units>", "Mater-
ial:=", <string>")
Return Value: None
Parameters: Zlocation
Z Coordinate and units for the definition of the half space boundary.
Material
String identifying the material for the lower half of the space.
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project2")
Set oDesign = oProject.SetActiveDesign("IEDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignHalfSpace Array("NAME:HalfSpace1", "ZLocation:=",
"0mm", "Material:=", "water_sea")

Boundary and Excitation Module Script Commands 13-71


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

AssignImpedance [HFSS-IE]
Use: Creates an impedance boundary for an HFSS-IE 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>)
VB 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
Syntax:AssignInfGndPlane <Array>
Return Value:None
Parameters:<Array>
"NAME:"<InfGndPlaneName>
"ZLocation:=", <value>
"Roughness:=", <value>
"Material:=", "<name>"
VB Example:
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignInfGndPlane Array("NAME:InfGndPlane1", _
"ZLocation:=", "0mm", _

Boundary and Excitation Module Script Commands 13-72


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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

VB Example:
Set oDesign = oProject.SetActiveDesign("HFSSIEDesign1")
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AutoIdentifyPorts Array("NAME:Faces", 12), _
Array("NAME:ReferenceConductors", "Box1"), _
"LumpPort1", true

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 wiz-
ard. 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 recor-
ded 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

Boundary and Excitation Module Script Commands 13-73


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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>,
"RadDist:=", <value>,
"UseFreq:=", <bool>,
"MinFreq:=", <value>,
"MinBeta:=", <double>)
"RadIncidentField:=", <bool>
"RadFssReference:=", <bool>

Return Value: None

Boundary and Excitation Module Script Commands 13-74


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.

VB Example:
oModule.CreatePML Array("UserDrawnGroup:=", false,_
"PMLFaces:=", Array(120), "CreateJoiningObjs:=",_ true,_
"Thickness:=", "0.33mm", "RadDist:=", "1.6mm",_
"UseFreq:=", true, "MinFreq:=", "1GHz")
VB Example:
oModule.CreatePML Array("UserDrawnGroup:=", true,_
"PMLObj:=", "Box1", "BaseObj:=", "Box2", _
"Thickness:=", "0.3mm", "Orientation:=", "ZAxis", _
"RadDist:=", "1.6mm", "UseFreq:=", false, _
"MinBeta:=", "2")
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>",

Boundary and Excitation Module Script Commands 13-75


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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.
VB 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
PMLGroupModified
Use: Command added by HFSS after a PML’s parameters are modified. This updates the PML
Setup wizard’s 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

Boundary and Excitation Module Script Commands 13-76


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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
VB Example:
oModule.RecalculatePMLMaterials

Boundary and Excitation Module Script Commands 13-77


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

13-78
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

14 - Mesh Operations Module Script Com-


mands
Commands for mesh setup and operations 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 3DModeler>Measure>Area command. The face ID is given in the Measure
Information dialog box.

The topics for this section include:


General Commands Recognized by the Mesh Operations Module
Script Commands for Creating and Modifying Mesh Operations

General Commands Recognized by the Mesh Operations


Module
General commands recognized by the Mesh Operations Module:
DeleteOp
GetOperationName
RenameOp

Mesh Operations Module Script Commands 14-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

DeleteOp
Deletes the specified mesh operations.
Command: Delete command in the List dialog box. Click HFSS or Q3D Extractor or 2D
Extractor or Maxwell 3D or Maxwell 2D>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.
VB 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"
VB 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 short-
cut menu.
Syntax: RenameOp <OldName>, <NewName>

Mesh Operations Module Script Commands 14-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Return Value: None


Parameters: <OldName>
Type: <string>
Old name for the mesh operation.

<NewName>
Type: <string>
New name for the mesh operation.
VB Example:
oModule.RenameOp "SkinDepth1", "NewName"

Script Commands for Creating and Modifying Mesh Oper-


ations
Script commands for creating and modifying mesh operations are as follows:
AssignApplyCurvilinearElementsOp
AssignCurvatureExtrationOp
AssignLengthOp
AssignModelResolutionOp
"AssignSkinDepthLayerSetting " on page 14-7
AssignSBRCurvatureExtractionOp
AssignSkinDepthOp
AssignTrueSurfOp
EditLengthOp
EditModelResolutionOp
EditSBRCurvatureExtractionOp
EditSkinDepthOp
EditTrueSurfOp
"InitialMeshSettings " on page 14-13
AssignApplyCurvilinearElementsOp
Applies a curvilinear elements mesh operation to the selection.

Mesh Operations Module Script Commands 14-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Command: HFSS or 2D Extractor or Maxwell 3D or Maxwell 2D > Mesh > Assign


Mesh Operation > On Selection > Apply Curvlinear Meshing...
Syntax: AssignApplyCurvilinarElementsOp <CurvilinearElementsOpParams>
Return Value: None
Parameters: <CurvilinearnElementsOpParams>
Array("NAME:<OpName>",
"Faces:=", <AssignmentFaces>, | "Objects:=", Array("objectID")
"Apply:=", <bool>,
RestrictElem
If true, NumMaxElem should be specified.
VB Example:
oModule.AssignApplyCurvlinearElementsOp Array("NAME:ApplyCurvilinear1", "Objects:=",
Array( "Sphere1"), "Apply:=", true)

Python Syn- AssignApplyCurvilinarElementsOp (<OpName>, <FaceID> | <ObjectID>,


tax <boolean>)
oModule.AssignApplyCurvlinearElementsOp("ApplyCur-
vilinear1",
[
Python
Example "NAME:ApplyCurvilinear1",
"Apply:=" , False
])

AssignLengthOp
Assigns length-based operations to the selection.
Command: HFSS or Maxwell 3D or Maxwell 2D > Mesh > Assign Mesh Operation > On
Selection or HFSS or Maxwell 3D or Maxwell 2D > Mesh > Assign Mesh Operation >
Inside Selection > Length Based.
Syntax: AssignLengthOp <LengthOpParams>
Return Value: None
Parameters: <LengthOpParams>
Array("NAME:<OpName>",
"RefineInside:=", <bool>,
"Objects:=", <AssignmentObjects>,

Mesh Operations Module Script Commands 14-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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
If true, MaxLength should be specified.
VB Example: Assigning length-based operations to the inside tet-
rahedra 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: HFSS or Q3D Extractor or 2D Extractor or Maxwell 3D > Mesh > Assign Mesh
Operation > Model Resolution
Syntax: AssignModelResolutionOp Array(<ModelResParams>)
Return Value: None
Parameters: Array("NAME:<string>",
"Objects:=", Array( "<modelname>"), _

Mesh Operations Module Script Commands 14-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"UseAutoLength:=", <Boolean>, _
"DefeatureLength:=", "<value><units>")
VB 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")

AssignCurvatureExtractionOp (Beta)
Assigns a curvature extraction operation to the selection for a faceted SBR+ object or face.
Command: HFSS > Mesh > Assign Mesh Operation > SBR+ Curvature Extraction for
Faceted Surfaces...
Syntax: AssignCurvatureExtractionOp <CurvilinearElementsOpParams>
Return Value: None
Parameters: <CurvilinearnElementsOpParams>
Array("NAME:<OpName>",
"Faces:=", <AssignmentFaces>, | "Objects:=", Array("objectID")
"Apply:=", <bool>)
VB Example:
oModule.AssignCurvatureExtractionOp Array("NAME:SBRCurvExtr1",
"Objects:=", Array( "RegularPolyhedron1"), "Dis-
ableForFacetedSurfaces:=", true)

Python AssignCurvatureExtractionOp (<OpName>, <FaceID> | <ObjectID>, <boolean>)


Syntax

oModule.AssignCurvatureExtractionOp("SBRCurvExtr1",

Python [
Example "NAME:SBRCurvExtr1",
"DisableForFacetedSurfaces:=", True

Mesh Operations Module Script Commands 14-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

])

AssignSkinDepthLayerSetting
Use: Assigns a skin-depth layer settings to the selected edges.
Command: Click Mesh > Assign Mesh Operation > On Selection > Skin Depth Based
Syntax: AssignSkinDepthLayerSetting Array("NAME:<LayerSettingName>", "Enabled:=", <Set-
tingEnabled>, "Edges:=", Array(<EdgeIDArray>), "SkinDepth:=", "<SkinDepthValue>", "NumLay-
ers:=", "<LayerNumber>")
Return Value: None
Parameters: <LayerSettingName>
The name of the skin depth layer setting.
<SettingEnabled>
Boolean: "Enabled:=", true
<EdgeIDArray>
Array of edge IDs. "Edges:=", Array(10, 12, 13)
<SkinDepthValue>
Skin depth value with unit. "SkinDepth:=", "1mm"
<LayerNumber>
Integer, the number of layers. "NumLayers:=", "2"
Example: oModule.AssignSkinDepthLayerSetting Array("NAME:Sk-
inDepthLayer1",
"Enabled:=", true
"Edges:=", Array(10, 12, 13),
"SkinDepth:=", "1mm",
"NumLayers:=", 2)
AssignSkinDepthOp
Assigns a skin-depth based operations to the selection.
Command: HFSS or 2D Extractor or Maxwell 3D or Maxwell 2D > Mesh > Assign
Mesh Operation > On Selection > Skin Depth Based
Syntax: AssignSkinDepthOp <SkinDepthOpParams>
Return Value: None
Parameters: <SkinDepthOpParams>

Mesh Operations Module Script Commands 14-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:<OpName>",
"Faces:=", <AssignmentFaces>,
"RestrictElem:=", <bool>,
"NumMaxElem:=", <int>,
"SkinDepth:=", <value>,
"SurfTriMaxLength:=", <value>,
"NumLayers:=", <int>)

RestrictElem
If true, NumMaxElem should be specified.
VB Example:
oModule.AssignSkinDepthOp Array("NAME:SkinDepth1", _
"Faces:=", Array(7), _
"RestrictElem:=", true, _
"NumMaxElem:=", 1000, _
"SkinDepth:=", "1mm", _
"SurfTriMaxLength:=", "1mm", _
"NumLayers:=", 2)

AssignTrueSurfOp
Assigns a true surface-based mesh operation on the selection.
Command: HFSS or Q3D Extractor or 2D Extractor or Maxwell 3D or Maxwell 2D > Mesh
> Assign Mesh Operation > Surface Approximation
Syntax: AssignTrueSurfOp <TrueSurfOpParams>
Return Value: None
Parameters: <TrueSurfOpParams>
Array("NAME:<OpName>",
"Faces:=", <AssignmentFaces>,
"SurfDevChoice:=", <RadioOption>,
"SurfDev:=", <value>,

Mesh Operations Module Script Commands 14-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"NormalDevChoice:=", <RadioOption>,
"NormalDev:=", <value>,
"AspectRatioChoice:=", <RadioOption>,
"AspectRatio:=", <double>)

<RadioOption>
Type: <int>
0: Ignore
1: Use defaults
2: Specify the value
VB Example:
oModule.AssignTrueSurfOp Array("NAME:TrueSurf1",
"Faces:=", Array(9), _
"SurfDevChoice:=", 2, _
"SurfDev:=", "0.04123105626mm", _
"NormalDevChoice:=", 2, _
"NormalDev:=", "15deg", _
"AspectRatioChoice:=", 1)

EditApplyCurvilinearElementsOp
Edits a curvilinear elements mesh operation to the selection.
Command: Edit>Properties.
Syntax: EditApplyCurvilinarElementsOp <CurvilinearElementsOpParams>
Return Value: None
Parameters: <CurvilinearnElementsOpParams>
Array("NAME:<OpName>",
"Faces:=", <AssignmentFaces>, | "Objects:=", Array("objectID")
"Apply:=", <bool>,
RestrictElem
If true, NumMaxElem should be specified.

Mesh Operations Module Script Commands 14-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Example:
oModule.EditApplyCurvlinearElementsOp Array("NAME:ApplyCurvilinear1", "Objects:=", Array( 
"Sphere1"), "Apply:=", true)

Python Syn- EditApplyCurvilinarElementsOp (<OpName>, <FaceID> | <ObjectID>,


tax <boolean>)
oModule.EditApplyCurvlinearElementsOp("ApplyCur-
vilinear1",
[
Python
Example "NAME:ApplyCurvilinear1",
"Apply:=" , False
])

EditLengthOp
Use: Edits an existing length-based operation. This cannot 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
VB Example:
oModule.EditLengthOpK "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>",

Mesh Operations Module Script Commands 14-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Objects:=", Array( "<modelname>"), _


"UseAutoLength:=", <Boolean>, _
"DefeatureLength:=", "<value><units>")
VB Example:
Set oDesign = oProject.SetActiveDesign("wg_combiner")
Set oModule = oDesign.GetModule("MeshSetup")
oModule.EditModelResolutionOp "ModelResolution1", _ Array
("NAME:ModelResolution1", "UseAutoLength:=", false, _
"DefeatureLength:=", "71.5891053163818mil")

EditSBRCurvatureExtractionOp (Beta)
Edits a curvature extraction operation to the selection for an SBR+ object or face.
Command: Edit Propeties
Syntax: EditSBRCurvatureExtractionOp <CurvilinearElementsOpParams>
Return Value: None
Parameters: <CurvilinearnElementsOpParams>
Array("NAME:<OpName>",
"Faces:=", <AssignmentFaces>, | "Objects:=", Array("objectID")
"Apply:=", <bool>)
VB Example:
oModule.EditSBRApplyCurvlinearElementsOp Array("NAME:ApplyCurvilinear1", "Objects:=",
Array( "Sphere1"), "Apply:=", true)

Python EditSBRCurvatureExtractionOp (<OpName>, <FaceID> | <ObjectID>,


Syntax <boolean>)
oModule.EditSBRCurvatureExtractionOp("SBRCurvExtr1",
[
Python
"NAME:SBRCurvExtr1",
Example
"DisableForFacetedSurfaces:=", True
])

Mesh Operations Module Script Commands 14-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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
VB 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
VB Example:
oModule.EditTrueSurfOp "TrueSurf2",
Array("NAME:trusurf", _
"SurfDevChoice:=", 2, _
"SurfDev:=","0.03mm", _
"NormalDevChoice:=", 1, _
"AspectRatioChoice:=", 2, _
"AspectRatio:=", 10)

Mesh Operations Module Script Commands 14-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

InitialMeshSettings
Use: Assigns a true surface-based mesh operation to the selection.
Command: Maxwell3D or Maxwell2D > Mesh > Initial Mesh Settings
Syntax: InitialMeshSettings <InitialMeshSettingsParams>
Return Value: None
Parameters: <InitialMeshSettingsParams>
Array("NAME:<MeshSettings>",
"CurvedSurfaceApproxChoice:=", "UseSlider" or "Manual Settings">
"UseLegacyFaceterForTauVolumeMesh:=", false, _
"UseFlexMeshingForTAUvolumeMesh:=", true)

VBS Example:Using Slider
oModule.InitialMeshSettings Array("NAME:MeshSettings", Array("NAME:G-
lobalSurfApproximation", _
"CurvedSurfaceApproxChoice:=", "UseSlider", "Slider-
MeshSettings:=", 5), _
Array("NAME:GlobalCurvilinear", "Apply:=", false), _
Array("NAME:GlobalModelRes", "UseAutoLength:=", true), "MeshMeth-
od:=", "Auto", _
"UseLegacyFaceterForTauVolumeMesh:=", false, _
"UseFlexMeshingForTAUvolumeMesh:=", true)

VBS Example: Manual Settings


oModule.InitialMeshSettings Array("NAME:MeshSettings", _
Array("NAME:GlobalSurfApproximation", _
"CurvedSurfaceApproxChoice:=", _
"ManualSettings", _
"SurfDevChoice:=", 2, _
"SurfDev:=", "0.01mm", _
"NormalDevChoice:=", 2, _
"NormalDev:=", "22.5deg", _

Mesh Operations Module Script Commands 14-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"AspectRatioChoice:=", 2, "AspectRatio:=", "10"), _


Array("NAME:GlobalCurvilinear", "Apply:=", false), _
Array("NAME:GlobalModelRes", "UseAutoLength:=", true), "MeshMeth-
od:=", "Auto", _
"UseLegacyFaceterForTauVolumeMesh:=", false, _
"UseFlexMeshingForTAUvolumeMesh:=", false)

Python Syn- InitialMeshSettings (<MeshSettings>)


tax

oModule.InitialMeshSettings(
[
"NAME:MeshSettings", [ "NAME:G-
lobalSurfApproximation", _
"CurvedSurfaceApproxChoice:=", "UseSlider", "Slider-
MeshSettings:=" , 5 ], _
Python [ "NAME:GlobalCurvilinear", "Apply:=" , False ], _
Example
[ "NAME:GlobalModelRes", "UseAutoLength:=" , True ],
_
"MeshMethod:=" , "Auto", _
"UseLegacyFaceterForTauVolumeMesh:=", False, _
"UseFlexMeshingForTAUvolumeMesh:=", False _
])

Mesh Operations Module Script Commands 14-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

15 - Analysis Setup Module Script Com-


mands
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")
ClearLinkedData
CopySetup
DeleteDrivenSweep
DeleteSetups
DeleteSweep [HFSS-IE]
EditCircuitSettings
EditFrequencySweep
EditSetup
EditSweep [HFSS-IE]
ExportCircuit
GetSetupCount
GetSetups
GetSweepCount
GetSweeps
InsertFrequencySweep
InsertSweep [HFSS-IE]
InsertSetup
InsertSetup [HFSS-IE]
InsertSetup [Transient]
PasteSetup
PasteSweep
RenameDrivenSweep
RenameSetup
RenameSweep [HFSS-IE]

Analysis Setup Module Script Commands 15-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

RevertAllToInitial
RevertSetupToInitial

ClearLinkedData (Module)
Clear the linked data of all the solution setups. Similar to the ClearLinkedData command for the
design level.
Right-click menu of individual setups under the Analysis item.

Project Manager > Design name > Analysis > right-click Setup name >
UI Access
Clear Linked Data

Name Type Description


Parameters <SetupNameArray> Array of Specify the name of the setups whose
string linked data are to be cleaned

Return Value None

Python Syn- ClearLinkedData(<SetupNameArray>)


tax

oProject = oDesktop.GetActiveProject()

Python oDesign = oProject.GetActiveDesign()


Example oDesign.GetModule("AnalysisSetup")
oModule.ClearLinkedData(["setup1"])

VB Syntax ClearLinkedData(<SetupNameArray>)
VB oModule.ClearLinkedData(Array("setup1"))
Example

CopySetup
Copy the specified Optimetrics setup.

UI Access NA

Name Type Description


Parameters
<SetupName> String Name of the setup

Return Value None

Analysis Setup Module Script Commands 15-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- CopySetup (<SetupName>)


tax

Python oModule.CopySetup ("OptimizationSetup1")


Example

VB Syntax CopySetup <SetupName>


VB Example oModule.CopySetup "OptimizationSetup1"

CopySweep
The documented command is applicable for Q3D Extractor.
Use: Copy a sweep.
Syntax: CopySweep <SetupName>, <SweepName>
Return Value: None
Parameters: <SetupName>
Type: <String>
Name of solve setup to which the sweep belongs.
<SweepName>
Type:<String>
Name of sweep copied.
oModule.CopySweep "Setup6", "Sweep1"

DeleteDrivenSweep
Use: Deletes a frequency sweep. For HFSS-IE use DeleteSweep.
Command: Right-click a frequency sweep in the Project Manager, and then click Rename on the
shortcut menu.
Syntax: DeleteDrivenSweep <SetupName>, <SweepName>
Return Value: None

Analysis Setup Module Script Commands 15-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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>, ...)
VB Example:
oModule.DeleteSetups Array("Setup1", "Setup2")

DeleteSweep [HFSS-IE]
Use: Deletes a frequency sweep.
Command: Right-click a frequency sweep in the Project Manager, and then click Rename on the
shortcut menu.
Syntax: DeleteSweep <SetupName>, <SweepName>
Return Value: None
For Q3D Extractor, the command details are as follows:
Use: Deletes a sweep.
Syntax: DeleteSweep <SetupName>, <SweepName>
Return Value: None
Parameters: <SetupName>
Type: <String>
Name of solve setup.
<SweepName>
Type: <String>
Name of sweep to be deleted.
oModule.DeleteSweep "Setup6", "Sweep1"

EditCircuitSettings
Use: Exports equivalent circuit data.

Analysis Setup Module Script Commands 15-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Command: Right-click the Analysis folder, and then choose Edit Circuit Settings.
Syntax: EditCircuitSettings <ExportSettings>
Return Value: None
Parameters: <ExportSettings>
See ExportCircuit for details.
VB Example: oModule.EditCircuitSettings Array("NAME:CircuitData",
"MatrixName:=", "Original", _
"NumberOfCells:=", "1", "UserHasChangedSettings:=", true,
"IncludeCap:=", true, "IncludeCond:=", _
true, Array("NAME:CouplingLimits", "CouplingLimitType:=", "By Frac-
tion", "CapFraction:=", 0.01, _
"IndFraction:=", 0.01, "ResFraction:=", 0.01, "CondFraction:=",
0.01), "IncludeDCR:=", false, _
"IncudeDCL:=", false, "IncludeACR:=", false, "IncludeACL:=", false,
"ADDResistance:=", true)

VB Example: oModule.EditCircuitSettings Array("NAME:CircuitData",


"MatrixName:=", "Original", _
"1", "UserHasChangedSettings:=", true, "IncludeCap:=", true,
"IncludeCond:=", true, Array _
("NAME:CouplingLimits", "CouplingLimitType:=", "By Fraction",
"CapFraction:=",0.01, _
"IndFraction:=", 0.01, "ResFraction:=", 0.01, "CondFraction:=",
0.01), "IncludeR:=", false, _
"IncludeL:=", false, "ExportDistributed:=", true, "LumpedLength:=",
"7meter", "RiseTime:=", "1s")

EditFrequencySweep
Use: Modifies an existing frequency sweep. For HFSS-IE use EditSweep [HFSS-IE]
Command: Double-click a frequency sweep in the Project Manager to modify its settings.
Syntax: EditFrequencySweep <SetupName>, <SweepName>, <AttributesArray>
Return Value: None
Parameters: <SetupName>
Type: <string>
Name of the solution setup containing the sweep to be edited.

<SweepName>

Analysis Setup Module Script Commands 15-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.

Analysis Setup Module Script Commands 15-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<AttributesArray>
Array("NAME:<NewSetupName>", <NamedParameters>)
See the InsertSetup command for details and examples.
For Q3D Extractor, the EditSetup command has the following details.
Use: Edit an existing solution setup.
Command: Double-click a setup in the Project Manager to edit it.
Syntax: EditSetup <SetupName>, Array("NAME:<NewSetupName>, "Enabled:=",
<Enabled>,"AdaptiveFreq:=",<AdaptFreq>,<SolverParam>)
Return Value: None
Parameters: <SetupName>
Type: <string>
Name of the solve setup being edited.
<NewSetupName>
Type: <string>
New name of the solve setup being edited
<SaveFields>
Type: <string>
Flag to indicate whether the fields are saved for last adaptive
solution. (True or False).
<Enabled>
Type: <bool>
Flag to indicate whether the setup is enabled.
<AdaptFreq>
Type: <String>
Frequency with units.
<SolverParam>
See InsertSetup for details.
oModule.EditSetup "Setup1", Array("NAME:Setup1", "AdaptiveFreq:=",
"1GHz", "EnableDistribProbTypeOption:=", _ false, "SaveFields:=",
"true", "Enabled:=", true, Array("NAME:Cap", "MaxPass:=", 10,
"MinPass:=", 1, "MinConvPass:=", _ 2, "PerError:=", 1, "Per-
Refine:=", 30, "AutoIncreaseSolutionOrder:=", false,

Analysis Setup Module Script Commands 15-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"SolutionOrder:=", _ "Normal"), Array("NAME:DC", "Residual:=", 1E-


005, "SolveResOnly:=", _ false, Array("NAME:Cond", "MaxPass:=", 10,
"MinPass:=", 1, "MinConvPass:=", 1, "PerError:=", _ 1, "Per-
Refine:=", 30), Array("NAME:Mult", "MaxPass:=", 1, "MinPass:=", 1,
"MinConvPass:=", _ 1, "PerError:=", 1, "PerRefine:=", 30)), Array
("NAME:AC", "MaxPass:=", 10, "MinPass:=", _ 1, "MinConvPass:=", 2,
"PerError:=", 1, "PerRefine:=", 30))

EditSweep [HFSS-IE]
Use: Modifies an existing sweep in HFSS-IE.
Command: Double-click a frequency sweep in the Project Manager 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>)
<additionalRanges>
Array( "SetupType:=", "<SetupType>",
"StartValue:=", "<ValueUnits>",
"StopValue:=", "<ValueUnits", "Count:=", <value>, ...)

Analysis Setup Module Script Commands 15-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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)

ExportCircuit
Use:Export equivalent circuit data.
Command:Right-click a setup in the project tree or the Analysis folder and choose Export
Circuit.
Syntax:ExportCircuit <Solution>, <Variation>, <FileName>, <ExportSettings>, <ModelName>,
<Freq>
Return Value: none
Parameters: <Solution>
<SetupName>:<SolutionName>
<SetupName>
Type: <string>
Name of the setup where circuit is being exported
<SolutionName>
Type: <String>
Name of the solution.
<Variation>
Type: <string>
The variation where circuit is being exported
<FileName>

Analysis Setup Module Script Commands 15-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type: <string>
The name of the file where circuit is being exported
<ModelName>
Type: <String>
Model name or name of the sub circuit (Optional). If not specified
then <FileName> is considered as model name.
<Freq>
Type: <double>
Sweep frequecny in hz.
<ExportSettings>
Array("NAME:CircuitData", "MatrixName:=", _
<ReduceMatrix>, "NumberOfCells:=", <NumCell>, "User-
HasChangedSettings:=", <UserChangedSettings>, "IncludeCap:=",
<IncludeCap>, "IncludeCond:=", <IncludeCond>, Array("NAME:Coup-
lingLimits", <CouplingLimitsArray>, "IncludeDCR:=", <IncludeDCR>,
"IncludeDCL:=", <IncludeDCL>, "IncludeACR:=", <IncludeACR>,
"IncludeACL:=", <IncludeACL>, "ADDResistance:=", <AddResistance>)
Parameters:
<ReduceMatrix>
Type: <string>
One of the reduced matrix setup or "Original"
<NumCell>
Type: <string>
Number of cells in export. Can be a variable.
<UserChangedSettings>
Type: <bool>
Whether user changed settings or use default settings.
<IncludeCap>
Type: <bool>
Flag indicates whether to export Capacitance matrix.
<IncludeCond>
Type: <bool>

Analysis Setup Module Script Commands 15-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Flag indicates whether to export Conductance matrix.


<IncludeDCR>
Type: <bool>
Flag indicates whether to export DC resistance matrix.
<IncludeDCL>
Type: <bool>
Flag indicates whether to export DC Inductance matrix.
<IncludeACR>
Type: <bool>
Flag indicates whether to export AC resistance matrix.
<IncludeACL>
Type: <bool>
Flag indicates whether to export AC inductance matrix.
<AddResistance>
Type: <bool>
Adds the DC and AC resistance.

Note:

You cannot export both AC and DC matrices unless AddResistance is selected.

<CouplingLimitsArray>
Array("NAME:CouplingLimits", "CouplingLimitType:=", <Coup-
lingLimitType>, _
<CouplingLimitsParameters>, 0.01, "CondFraction:=", 0.01)
<CouplingLimitType> = "None"
Argument not needed
<CouplingLimitType> = "ByFraction"
<CouplingLimitsParameters>
"CapFraction:=", <Fraction>, "IndFraction:=", <Fraction>,
"ResFraction:=", <Fraction>,"CondFraction:=",<Fraction>,
Parameters:

Analysis Setup Module Script Commands 15-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<Fraction>
Type: <double>
Fraction of the self term
<CouplingLimitType> = "ByValue"
<CouplingLimitsParameters>
"CapLimit:=", <Limit>, "IndLimit:=", <Limit>, "ResLimit:=",
<Limit>,
"CondLimit:=", <Limit>,
Parameters:
<Limit>
Type: <string>
Value of the limit.
VB Example:
oModule.ExportCircuit
"Setup1 : LastAdaptive", "", "C:/Project/Q3D/FourNets.cir", Array
("NAME:CircuitData", _
"MatrixName:=", "Original", "NumberOfCells:=", "1", "User-
HasChangedSettings:=", true, _
"IncludeCap:=", true, "IncludeCond:=", true, Array("NAME:Coup-
lingLimits", "CouplingLimitType:=", _
"By Fraction", "CapFraction:=", 0.01, "IndFraction:=", 0.01,
"ResFraction:=", 0.01, _
"CondFraction:=", 0.01), "IncludeDCR:=", false, IncudeDCL:=", false,
"IncludeACR:=", false, _
"IncludeACL:=", false, "ADDResistance:=", true), "", 2000000000000

GetSetupCount
Gets the number of analysis setups in a design.
Syntax: GetSetups()
Return Value: Number of setups.
Parameters: None
VB Example:
setupcount = oModule.GetSetupCount()

Analysis Setup Module Script Commands 15-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetSetups
Gets the names of analysis setups in a design.
Syntax: GetSetups()
Return Value: Array of analysis setup names.
Parameters: None
VB Example:
setupnames = oModule.GetSetups()

GetSetupNames
Use: Gets the names of far field and near field radiation setups in a design.
Syntax: GetSetupNames(<RadiationType>)
Return Value: Array of setup names.
Parameters: <RadiationType>
Type: <string>
For example: "Sphere"
VB Example:
Set setupnames = oModule.GetSetupNames("Infinite Sphere")
For Each setup in setupnames
Msgbox setup
Next

GetSweepCount
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.
VB Example:
sweepcount = oModule.GetSweepCount("Setup1")

Analysis Setup Module Script Commands 15-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetSweeps
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.
VB Example:
sweepnames = oModule.GetSweeps("Setup1")

InsertFrequencySweep
Adds a frequency sweep to a Driven solution-type setup.
Command: HFSS>Analysis Setup>Add Sweep
Syntax: InsertFrequencySweep <SetupName>, <AttributesArray> [<additionalRanges>]
Return Value: None
Parameters: <SetupName>
Type: <string>
Name of the solution setup into which the sweep will be inserted.
<Attributes Array>
Array("NAME:Sweep",
"IsEnabled:=", <boolean>
"RangeType:=", <"LinearStep" | "LinearCount" | "LogScale">,
<LinearStepArray>
"RangeStart:=", "<real>GHz",
"RangeEnd:=", "<real>GHz",
"RangeStep:=", "<real>GHz",
<LinearCountArray>
"RangeStart:=", "<real>GHz",
"RangeEnd:=", "<real>GHz",
"RangeCount:=", <int>,
<LogScaleArray>

Analysis Setup Module Script Commands 15-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

RangeStart:=", "<real>GHz",
"RangeEnd:=", "<real>GHz",
"RangeCount:=", <int>,
"RangeSamples:=", <int>,
<SweepTypeArray>
"Type:=", <"Interpolating" |"Fast" | "Discrete">,
<InterpolatingParametersArray>
"SaveFields:=", <boolean>,
"SaveRadFields:=", <boolean>,
"InterpTolerance:=", <real>,
"InterpMaxSolns:=", <int>,
"InterpMinSolns:=", <int>,
"InterpMinSubranges:=", <int>,
"ExtrapToDC:=", <boolean>,
"InterpUseS:=", <boolean>,
"InterpUsePortImped:=", <boolean>,
"InterpUsePropConst:=", <boolean>,
"UseDerivativeConvergence:=", true,
"InterpDerivTolerance:=", <real>,
"UseFullBasis:=", <boolean>,
"EnforcePassivity:=", <boolean>,
"PassivityErrorTolerance:=", <real>)
"EnforceCausality:=", <boolean>

<FastParametersArray>
"SaveFields:=", <boolean>,
"SaveRadFields:=", <boolean>,
"GenerateFieldsForAllFreqs:=", <boolean>,
"ExtrapToDC:=", <boolean>)

<DiscreteParametersArray>
"SaveFields:=", <boolean>,
"SaveRadFields:=", <boolean>,
"ExtrapToDC:=", <boolean>)

VB Example: Discrete Sweep

oModule.InsertFrequencySweep "Setup1", Array("NAME:Sweep",


"IsEnabled:=", true,
"RangeType:=", "LinearStep",

Analysis Setup Module Script Commands 15-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"RangeStart:=", "1GHz",
"RangeEnd:=", "10GHz",
"RangeStep:=", "0.1GHz",
"Type:=", "Discrete",
"SaveFields:=", false,
"SaveRadFields:=", false,
"ExtrapToDC:=", false)

VB Example: Fast Sweep

oModule.InsertFrequencySweep "Setup1",
Array("NAME:Sweep2", "IsEnabled:=", false,
"RangeType:=", "LinearStep",
"RangeStart:=", "1GHz",
"RangeEnd:=", "10GHz",
"RangeStep:=", "0.1GHz",
"Type:=", "Fast",
"SaveFields:=", true,
"SaveRadFields:=", false,
"GenerateFieldsForAllFreqs:=", false,
"ExtrapToDC:=", false)

VB Example: Interpolating Sweep with additional setups

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, _

Analysis Setup Module Script Commands 15-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"InterpUsePropConst:=", true, "UseFullBasis:=", true) _


Array( "SetupType:=", "LogScale", "StartValue:=", "11GHz",
"StopValue:=", _
"12GHz", "Count:=", 91, _
"SetupType:=", "LinearCount", "StartValue:=", "13GHz", _
"StopValue:=", "100GHz", "Count:=", 91)

VB 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)

VB 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)

For Q3D Extractor the command details are as follows:


Inserts a sweep in the selected solve setup.

Analysis Setup Module Script Commands 15-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax: InsertSweep
Return Value: None
Parameters: oModule.InsertSweep <SetupName>, <SweepDataArray>
<SetupName>
Type: <String>
Name of the solve setup in which the sweep is added.
<SweepDataArray>
Array("NAME:<SweepName>", "IsEnabled:=", <EnableFlag>,
"SetupType:=", _
<SetupType>", <SetupTypeParameters>, "Type:=", <SweepType>, _
"SaveFields:=", <SaveFields>, <InterpSweepParameters>) _
Array("NAME:<SweepName>", "IsEnabled:=", <EnableFlag>,
"SetupType:=", _
<SetupType>", <SetupTypeParameters>, "Type:=", <SweepType>, _
"SaveFieldsList:=", <SaveFieldsListParameters>, <Inter-
pSweepParameter>)
VB Example:
Array("NAME:Sweep1", "IsEnabled:=", true, "SetupType:=", _
"LinearStep", "StartValue:=", "1GHz", "StopValue:=", "10GHz", "StepS-
ize:=", _
"1GHz", "Type:=", "Discrete", "SaveFields:=", true)
VB Example:
Array("NAME:Sweep1", "IsEnabled:=", true, "SetupType:=", _
"LinearCount", "StartValue:=", "1GHz", "StopValue:=", "100GHz",
"Count:=", 100, "Type:=", _
"Discrete", "SaveFields:=", true)
VB Example:
Array("NAME:Sweep1", "IsEnabled:=", true, "SetupType:=", _
"LinearCount", "StartValue:=", "1GHz", "StopValue:=", "100GHz",
"Count:=", 100, "Type:=", _
"Discrete", "SaveFields:=", true)
VB Example:
Array("NAME:Sweep1", "IsEnabled:=", true, "SetupType:=", _
"SinglePoints", "ValueList:=", Array("1GHz", "2GHz", "5GHz"),

Analysis Setup Module Script Commands 15-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Type:=", _
"Discrete", "SaveFieldsList:=", Array(false, false, false)
VB Example:
Array("NAME:Sweep2", "IsEnabled:=", true, "SetupType:=", _
"LinearStep", "StartValue:=", "1GHz", "StopValue:=", "10GHz", "StepS-
ize:=", _
"1GHz", "Type:=", "Interpolating", "SaveFields:=", false, "Inter-
pTolerance:=", _
0.01, "InterpMaxSolns:=", 9, "InterpMinSolns:=", 4)

Parameters:
<SweepName>
Type: <String>
Sweep name
<EnableFlag>
Type:<bool>
Flag to tell whether sweep is enabled.
<SetupType>
Type:String>
Values: "LinearStep", "LinearCount", "LogScale", "SinglePoints"
<SetupTypeParameters>
Base on the value of setup type, setup type parameters varies.
<LinearStepParameters>
StartValue:=", <StartValue>, "StopValue:=", <StopValue>, "StepSize:=", <StepSize>
<StartValue>
Type:<String>
Start frequency.
<StopValue>
Type: <String>
Stop Frequency
<StepSize>
Type:<String>

Analysis Setup Module Script Commands 15-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Step frequency.
<LinearCountParameters>
StartValue:=", <StartValue>, "StopValue:=", <StopValue>, "Count:=", <Count>
<StartValue>
Type: <String>
Start frequency.
<StopValue>
Type: <String>
Stop Frequency
<Count>
Type: <integer>
Number of frequency points in the given range.
<LogScaleParameters>
"StartValue:=", <StartValue>,"StopValue:=",<StopValue>, "SamplesPerDecade:=", <Samples>
<StartValue>
Type: <String>
Start frequency.
<StopValue>
Type: <String>
Stop Frequency
<Samples>
Type: <integer>
Number of samples per decade.
<SinglePointsParameters>
"ValueList:=", Array(<FrequencyPoint>,<FrequencyPoint> ..),
<FrequencyPoint>
Type: <String>
Single frequency point.
<SweepType>
Type: <String>

Analysis Setup Module Script Commands 15-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Values: "Discrete", "Interpolating"


Type of sweep.
<SaveFields>
Type: <bool>
Flag, whether to save fields for the frequency points.
<SaveFieldsListParameters>
"SaveFieldsList:=", Array(<SaveFields>,<SaveFields>,…)
Type: Array of flags.
<InterpSweepParameter>

Note:

This parameter applies only to interpolating sweeps.

"InterpTolerance:=", <Tolerance>, "Inter-


pMaxSolns:=",<MaxSolutions>, "InterpMinSolns:=",<MinSolutions>,
<Tolerance>
Type: <double>
Tolerance for interpolating sweep.
<MaxSolutions>
Type: <Integer>
Maximum basis points for interpolating sweep.
<MinSolutions>
Type: <Integer>
Minimum basis points for interpolating sweep.
<InterpSweepParameter> (For 2D Extractor)
"InterpTolerance:=", <Tolerance>, "Inter-
pMaxSolns:=",<MaxSolutions>, "InterpMinSolns:=",<MinSolutions>,
"InterpMinSubranges:=", <InterpMinSubRanges>
<Tolerance>
Type: <double>
Tolerance for interpolating sweep.
<MaxSolutions>

Analysis Setup Module Script Commands 15-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type: <Integer>
Maximum basis points for interpolating sweep.
<MinSolutions>
Type: <Integer>
Minimum basis points for interpolating sweep.
<InterpMinSubRanges>
Type: <Integer>
Minimum number of subranges in the interpolator.
VB Example:
oModule.InsertSweep "Setup4", Array("NAME:Sweep2", "IsEnabled:=",
true, "SetupType:=", _
"LinearStep", "StartValue:=", "1GHz", "StopValue:=", "10GHz", "StepS-
ize:=", _
"1GHz", "Type:=", "Interpolating", "SaveFields:=", false, "Inter-
pTolerance:=", _
0.01, "InterpMaxSolns:=", 9, "InterpMinSolns:=", 4, Inter-
pMinSubranges:=", 2
VB Example: oModule.InsertSweep "Setup4", Array("NAME:Sweep1", "IsEn-
abled:=", true, "SetupType:=", _
"LinearStep", "StartValue:=", "1GHz", "StopValue:=", "10GHz", "StepS-
ize:=", _
"1GHz", "Type:=", "Discrete", "SaveFields:=", true)
VB Example: oModule.InsertSweep "Setup4", Array("NAME:Sweep2", "IsEn-
abled:=", true, "SetupType:=", _
"LinearStep", "StartValue:=", "1GHz", "StopValue:=", "10GHz", "StepS-
ize:=", _
"1GHz", "Type:=", "Interpolating", "SaveFields:=", false, "Inter-
pTolerance:=", _
0.01, "InterpMaxSolns:=", 9, "InterpMinSolns:=", 4)

InsertSetup
Use: Adds a new solution setup.
Command: [product]>Analysis Setup>Add Solution Setup
Syntax: InsertSetup <SetupType>, <AttributesArray>
Return Value: None

Analysis Setup Module Script Commands 15-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters: <SetupType>
Type: <string>
"HfssDriven" or "HfssDrivenAuto" 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 and the selections made.
The parameters correspond to fields in the Setup dialog box. For example, here is
default dialog for an HFSS driven setup with one excitation assigned.

Some of the attributes Array correspond to these fields on the General tab of the Setup.
Array("NAME:Setup1", "AdaptMultipleFreqs:=", false, _
"Frequency:=", "5GHz", _
"MaxDeltaS:=", 0.02, _
"PortsOnly:=", false, _
"UseMatrixConv:=", false, _
"MaximumPasses:=", 6,_
Others correspond to fields on the Options tab.

Analysis Setup Module Script Commands 15-23


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

The script parameters corresponding to these Options tab fields are as follows:
"MinimumPasses:=", 1, _
"MinimumConvergedPasses:=", 1, _
"PercentRefinement:=", 30, _
"IsEnabled:=", true, _
"BasisOrder:=", 1, _
"DoLambdaRefine:=", true, _
"DoMaterialLambda:=", true, _
"SetLambdaTarget:=", false, _
"Target:=", 0.3333,
Still other parameters correspond to fields on the Advanced tab.

Analysis Setup Module Script Commands 15-24


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"PortAccuracy:=", 2,_
SaveRadFieldsOnly:=", false, _
"SaveAnyFields:=", true,
"ListsForFields:=", ["Facelist1", "Facelist2"],
Still others parameters correspond to the Hybrid tab.

Analysis Setup Module Script Commands 15-25


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"IESolverType:=", "Auto",_
"LambdaTargetForIESolver:=", 0.15, _
"UseDefaultLambdaTgtForIESolver:=", true
The choices made for solver, solution type, Ports Only, Single Frequency, Multi-Fre-
quencies, Broadband, Mesh Linking, and whether Expression Cash, or Derivatives, and
HPC are used will all affect the parameters array for a particular setup.
To see the required parameters for a specific Setup and their format, use the record
script function, and view the resulting script in a text editor. For descriptions of the para-
meters, see the Online help for the setup. See the examples below.
VB Example: An HFSS Driven project solution with Auto Solution.

Analysis Setup Module Script Commands 15-26


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oModule = oDesign.GetModule("AnalysisSetup")_

Analysis Setup Module Script Commands 15-27


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModule.InsertSetup "HfssDrivenAuto", Array("NAME:Setup1", "IsEn-


abled:=", true, _
"AutoSolverSetting:=", "Balanced", _
Array("NAME:Sweeps", Array("NAME:Sweep", "RangeType:=", "Lin-
earCount", _
"RangeStart:=", "1GHz", "RangeEnd:=", "10GHz", "RangeCount:=",
"451")), _
"SaveRadFieldsOnly:=", false, "SaveAnyFields:=", false, "Type:=",
"Interpolating")

VB 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.aedt",
"Design:=", "TeeModel",
"Soln:=", "Setup1 : LastAdaptive",
Array("NAME:Params", "offset:=", "0in"),
"ForceSourceToSolve:=", false,
"PreservePartnerSoln:=", false,
"PathRelativeTo:=", "SourceProduct",
"ApplyMeshOp:=", true),
"BasisOrder:=", 1,

Analysis Setup Module Script Commands 15-28


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"UseIterativeSolver:=", false,
"DoLambdaRefine:=", false,
"DoMaterialLambda:=", true,
"SetLambdaTarget:=", false,
"Target:=", 0.3333,
"UseMaxTetIncrease:=", false,
"MaxTetIncrease:=", 1000000,
"EnableSolverDomains:=", false,
"ThermalFeedback:=", false,
"UsingConstantDelta:=", 0,
"ConstantDelta:=", "0s",
"NumberSolveSteps:=", 1)

VB 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,

Analysis Setup Module Script Commands 15-29


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"DoMaterialLambda:=", false,
"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)
VB 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,

Analysis Setup Module Script Commands 15-30


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"DoLambdaRefine:=", true,
"DoMaterialLambda:=", true,
"SetLambdaTarget:=", false,
"Target:=", 0.2,
"UseMaxTetIncrease:=", false,
"MaxTetIncrease:=", 1000000,
"UsingConstantDelta:=", 0,
"ConstantDelta:=", "0s",
"NumberSolveSteps:=", 1)

VB Example:
A Driven solution type with ports and matrix convergence:
Set oDesign = oProject.SetActiveDesign("packagehfss")
Set oModule = oDesign.GetModule("AnalysisSetup")
oModule.InsertSetup "HfssDriven",
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,

Analysis Setup Module Script Commands 15-31


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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)
VB Example:
An HFSS setup with an Hybrid Boundary type SBR.
oModule.EditSetup("SBRsetup1",
[
"NAME:SBRsetup1",
"AdaptBroadband:=" , False,
"Frequency:=" , "1GHz",
"MaxDeltaE:=" , 0.1,
"MaximumPasses:=" , 10,
"MinimumPasses:=" , 1,
"MinimumConvergedPasses:=", 1,
"PercentRefinement:=" , 30,
"IsEnabled:=" , True,
"BasisOrder:=" , 1,
"DoLambdaRefine:=" , True,

Analysis Setup Module Script Commands 15-32


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"DoMaterialLambda:=" , True,
"SetLambdaTarget:=" , False,
"Target:=" , 0.3333,
"UseMaxTetIncrease:=" , False,
"UseDomains:=" , True,
"UseIterativeSolver:=" , False,
"IterativeResidual:=" , 1E-
006,
"DDMSolverResidual:=" , 0.0001,
"SaveRadFieldsOnly:=" , False,
"SaveAnyFields:=" , True,
"IESolverType:=" , "Auto",
"LambdaTargetForIESolver:=", 0.15,
"UseDefaultLambdaTgtForIESolver:=", True
"SkipIERegionsSolveDuringAdaptivePasses:=", True
"RayDensityPerWavelength:=", 4,
"MaxNumberOfBounces:=" , 5,
"InfiniteSphereSetup:=" , "Infinite Sphere1",
"SkipSBRSolveDuringAdaptivePasses:=", True,
"PTDUTDSimulationSettings:=", "PTD Correction + UTD Rays",
"PTDEdgeDensity:=" , 20
])
VB Example:
A Driven solution type with Multi-Frequencies specified.
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")

Analysis Setup Module Script Commands 15-33


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oDesktop = oAnsoftApp.GetAppDesktop()


oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project20")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("AnalysisSetup")
oModule.InsertSetup "HfssDriven", Array("NAME:Setup2", "AdaptMul-
tipleFreqs:=", true, _
Array("NAME:MultipleAdaptiveFreqsSetup", "1.1GHz:=", Array( _
0.02), "10GHz:=", Array(0.02), "11GHz:=", Array(0.02), "12.5GHz:=",
Array(0.02), "15GHz:=", Array( _
0.02), "20GHz:=", Array(0.02)), "MaximumPasses:=", 6, "Min-
imumPasses:=", 1, "MinimumConvergedPasses:=", _
1, "PercentRefinement:=", 30, "IsEnabled:=", true, "BasisOrder:=",
1, "DoLambdaRefine:=", _
true, "DoMaterialLambda:=", true, "SetLambdaTarget:=", false, "Tar-
get:=", _
0.3333, "UseMaxTetIncrease:=", false, "PortAccuracy:=", 2,
"UseABCOnPort:=", _
false, "SetPortMinMaxTri:=", false, "UseDomains:=", false, "UseIter-
ativeSolver:=", _
false, "SaveRadFieldsOnly:=", false, "SaveAnyFields:=", true,
"IESolverType:=", _
"Auto", "LambdaTargetForIESolver:=", 0.15, "UseDe-
faultLambdaTgtForIESolver:=", _
true, "RayDensityPerWavelength:=", 4, "MaxNumberOfBounces:=", 5)

VB Example:
An Driven Solution type with Broadband specified.
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule

Analysis Setup Module Script Commands 15-34


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")


Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project20")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("AnalysisSetup")
oModule.InsertSetup "HfssDriven", Array("NAME:Setup1", "AdaptMul-
tipleFreqs:=", true, _
Array("NAME:MultipleAdaptiveFreqsSetup", Array("NAME:Broadband",
"Low:=", _
"2GHz", "High:=", "20GHz")), "MaximumPasses:=", 6, "Min-
imumPasses:=", 1, "MinimumConvergedPasses:=", _
1, "PercentRefinement:=", 30, "IsEnabled:=", true, "BasisOrder:=",
1, "DoLambdaRefine:=", _
true, "DoMaterialLambda:=", true, "SetLambdaTarget:=", false, "Tar-
get:=", _
0.3333, "UseMaxTetIncrease:=", false, "PortAccuracy:=", 2,
"UseABCOnPort:=", _
false, "SetPortMinMaxTri:=", false, "UseDomains:=", false, "UseIter-
ativeSolver:=", _
false, "SaveRadFieldsOnly:=", false, "SaveAnyFields:=", true,
"IESolverType:=", _
"Auto", "LambdaTargetForIESolver:=", 0.15, "UseDe-
faultLambdaTgtForIESolver:=", _
true, "RayDensityPerWavelength:=", 4, "MaxNumberOfBounces:=", 5)
oModule.InsertFrequencySweep "Setup1", Array("NAME:Sweep", "IsEn-
abled:=", true, "RangeType:=", _
"LinearCount", "RangeStart:=", "2GHz", "RangeEnd:=", "20GHz",
"RangeCount:=", _
451, "Type:=", "Interpolating", "SaveFields:=", false, "SaveRadField-
s:=", _
false, "InterpTolerance:=", 0.5, "InterpMaxSolns:=", 250, "Inter-
pMinSolns:=", _
0, "InterpMinSubranges:=", 1, "ExtrapToDC:=", false, "InterpUseS:=",
true, "InterpUsePortImped:=", _

Analysis Setup Module Script Commands 15-35


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

false, "InterpUsePropConst:=", true, "UseDerivativeConvergence:=",


false, "InterpDerivTolerance:=", _
0.2, "UseFullBasis:=", true, "EnforcePassivity:=", true, "Passiv-
ityErrorTolerance:=", _
0.0001)

Python Syn- InsertSetup("HfssDrivenAuto", [<parameters>])


tax

oModule.InsertSetup("HfssDrivenAuto",
[
"NAME:Setup1",
"IsEnabled:=" , True,
"AutoSolverSetting:=" , "Balanced",
[
"NAME:Sweeps",
[
"NAME:Sweep",
Python
"RangeType:=" , "LinearStep",
Example
"RangeStart:=" , "1GHz",
"RangeEnd:=" , "10GHz",
"RangeStep:=" , "1GHz"
]
],
"SaveRadFieldsOnly:=" , False,
"SaveAnyFields:=" , True,
"Type:=" , "Discrete"
])

Python Syn- InsertSetup("HfssDriven", [<parameters>])


tax

Python oModule.InsertSetup("HfssDriven",
Example

Analysis Setup Module Script Commands 15-36


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

[ "NAME:Setup2",
"AdaptMultipleFreqs:=" , False,
"Frequency:=" , "5GHz",
"MaxDeltaS:=" , 0.02,
"PortsOnly:=" , False,
"UseMatrixConv:=" , False,
"MaximumPasses:=" , 6, "MinimumPasses:=" , 1, "Min-
imumConvergedPasses:=", 1,
"PercentRefinement:=" , 30,
"IsEnabled:=" , True,
"BasisOrder:=" , 1,
"DoLambdaRefine:=" , True, "DoMaterialLambda:=" , True,
"SetLambdaTarget:=" , False, "Target:=" , 0.3333,
"UseMaxTetIncrease:=" , False,
"PortAccuracy:=" , 2, "UseABCOnPort:=" , False,
"SetPortMinMaxTri:=" , False,
"UseDomains:=" , True,
"UseIterativeSolver:=" , False, "IterativeResidual:=" ,
1E-06,
"DDMSolverResidual:=" , 0.0001,
"SaveRadFieldsOnly:=" , False, "SaveAnyFields:=" ,
True,
"IESolverType:=" , "Auto",
"LambdaTargetForIESolver:=", 0.15,
"UseDefaultLambdaTgtForIESolver:=", True,
"SkipIERegionSolveDuringAdaptivePasses:=", True
"RayDensityPerWavelength:=", 4,
"MaxNumberOfBounces:=" , 5,
"InfiniteSphereSetup:=" , "Infinite Sphere1",
"SkipSBRSolveDuringAdaptivePasses:=", True,
"PTDUTDSimulationSettings:=", "PTD Correction + UTD
Rays",
"PTDEdgeDensity:=" , 20 ])

For Q3D Extractor, the command details are as follows:


Use: Adds a new solution setup.
Command: Q3D Extractor>Analysis Setup>Add Solution Setup
Syntax: InsertSetup "Matrix", Array ("NAME:<SetupName>", "Enabled:=", <Enabled>, "Adapt-
iveFreq:=", <AdaptFreq>, <SolveParam>)
Return Value: None
Parameters: <SetupName>
Type: <string>
Name of the setup.
<SaveFields>

Analysis Setup Module Script Commands 15-37


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type: <string>
Flag to indicate whether the fields are saved for last adaptive
solution. (True or False).
<Enabled>
Type: <bool>
Flag to indicate whether the setup is enabled.
<AdaptFreq>
Type: <String>
Frequency with units.
<SolverParam>
Array("NAME:Cap", "Residual:=", <Residual>, <AdaptParam>),
Array("NAME:DC", "Residual:=", <Residual>, "SolveResOnly:=",
<SolveResOnly>, Array("NAME:Cond", <AdaptParam>), Array("NAME:Mult",
<AdaptParam>)),
Array("NAME:AC", "Residual:=", 1E-005, Array("NAME:Cond",
<AdaptParam>), Array("NAME:Mult", <AdaptParam>))
Parameters:
<ACFreq>
Type: <string>
Frequency of the AC solution.
<Residual>
Type: <double>
Solver residual.
<SolveResOnly>
Type: <bool>
Solve resistance only for a DC solution.
<AdaptParam>
"MaxPass:=", <MaxPass>, "PerError:=", <PerError>,
"PerRefine:=", <PerRefine>
Parameters:
<MaxPass>
Type: <int>

Analysis Setup Module Script Commands 15-38


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Maximum pass for a solution


<PerError>
Type: <double>
Percentage error as stopping criteria.
<PerRefine>
Type: <double>
Mesh refinement at each pass in percentage.
VB Example:
oModule.InsertSetup "Matrix", Array("NAME:Setup1", "AdaptiveFreq:=",
"1GHz", _
"EnableDistribProbTypeOption:=", false, "SaveFields:=", "true",
"Enabled:=", _
true, Array("NAME:Cap", "MaxPass:=", 10, "MinPass:=", 1, "MinCon-
vPass:=", 1, _
"PerError:=", 1, "PerRefine:=", 30, "AutoIncreaseSolutionOrder:=",
false, _
"SolutionOrder:=", "Normal"), Array("NAME:DC", "Residual:=", 1E-005,
_
"SolveResOnly:=", false, Array("NAME:Cond", "MaxPass:=", 10,
"MinPass:=", _
1, "MinConvPass:=", 1, "PerError:=", 1, "PerRefine:=", 30), Array
("NAME:Mult", _
"MaxPass:=", 1, "MinPass:=", 1, "MinConvPass:=", 1, "PerError:=", 1,
_
"PerRefine:=", 30)), Array("NAME:AC", "MaxPass:=", 10, "MinPass:=",
1, _
"MinConvPass:=", 1, "PerError:=", 1, "PerRefine:=", 30))

InsertSetup [HFSS-IE]
Adds a new HFSS-IE solution setup.
Command: HFSS>Analysis Setup>Add Solution Setup
Syntax: InsertSetup <SetupType>, <AttributesArray> [<AdditionalSetups>]
Return Value: None
Parameters: <SetupType>
Type: <string>
"HFIESetup". Must match the HFSS solution type.

Analysis Setup Module Script Commands 15-39


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<AttributesArray>
Array("NAME:<SetupName>", <Named Parameters>)

<Named Parameters>
The named parameters will vary according to the solution type. To see the required para-
meters 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.
<additionalRanges>
Array( "SetupType:=", "<SetupType>",
"StartValue:=", "<ValueUnits>",
"StopValue:=", "<ValueUnits", "Count:=", <value>, ...)

VB Example:
oModule.InsertSetup "HFIESetup", Array("NAME:Setup3", "Max-
imumPasses:=", 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]
Add a new solution setup to a Transient design
Command: HFSS>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 15-40


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<AttributesArray>
Array("NAME:<SetupName>", <Named Parameters>)

<Named Parameters>
The parameters correspond to fields in the Setup dialog. For example, here is default
dialog for an HFSS Transient driven Composite Excitation setup with one excitation
assigned. 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 editor.

The first part of a vbs script corresponds to the fields and selections on the General tab:
Set oModule = oDesign.GetModule("AnalysisSetup")
oModule.InsertSetup "HfssTransient", Array("NAME:Setup1", "Fre-
quency:=", "5GHz", "MaxDeltaE:=", 0.1, _"MaximumPasses:=", 6, "UseIm-
plicitSolver:=", true, "IsEnabled:=", true,
The next parameters correspond to fields and selections on the Saved Fields tab:

Analysis Setup Module Script Commands 15-41


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:Transient", "ListsForFields:=", Array("integ-


rationloops", "groundplane"), _
"UseSaveCount:=", 1, "SaveCount:=", 256, _
"UseSaveStart:=", 1, "SaveStart:=", "0s", _
"UseSaveDelta:=", 1, "SaveDelta:=", "10ps", _
"SaveRadFields:=", 0, "SaveFDRadFields:=", 0, _
You must create one or more face lists and select them to enable the ability to Save
fields at specified intervals.
The next part corresponds to fields on the Duration tab.

Analysis Setup Module Script Commands 15-42


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"UseAutoTermination:=", 1, "SteadyStateCriteria:=", 0.01, _


"UseMinimumDuration:=", 0, "TerminateOnMaximum:=", 0))
The choices made for solver, Transient solution type as Network Analysis or Composite
Excitation, Mesh Linking, and whether you use Expression Cash, Derivatives, and HPC
will all affect the parameters array for a particular setup. The Network Analysis solution
type includes the Input Signal tab.

Analysis Setup Module Script Commands 15-43


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

The vbs script for this setup includes parameters for this information.
Array("NAME:Transient", "TimeProfile:=", "Broadband Pulse", "HfssFre-
quency:=", "5GHz", _
"MinFreq:=", "100MHz", "MaxFreq:=", "1GHz", _
"NumFreqsExtracted:=", 401, _
"SweepMinFreq:=", "100MHz", "SweepMaxFreq:=", "1GHz",
To see the parameters for a specific Setup and their format, use the record script func-
tion, and view the resulting script in a text editor. For descriptions of the parameters, see
the Online help for the setup. See the examples below.
VB 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"))

VB Example:Transient Network Solution Type


Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign

Analysis Setup Module Script Commands 15-44


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("transient")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("AnalysisSetup")
oModule.InsertSetup "HfssTransient", Array("NAME:Setup1", "Fre-
quency:=", "5GHz", "MaxDeltaS:=", _
0.02, "MaximumPasses:=", 20, "UseImplicitSolver:=", true, "IsEn-
abled:=", true, "BasisOrder:=", _
-1, Array("NAME:Transient", "TimeProfile:=", "Broadband Pulse",
"HfssFrequency:=", _
"5GHz", "MinFreq:=", "100MHz", "MaxFreq:=", "1GHz", "NumFre-
qsExtracted:=", 401, "SweepMinFreq:=", _
"100MHz", "SweepMaxFreq:=", "1GHz", "ListsForFields:=", Array("Facel-
ist1"), "UseSaveCount:=", _
1, "SaveCount:=", 256, "UseSaveStart:=", 1, "SaveStart:=", "0s",
"UseSaveDelta:=", _
1, "SaveDelta:=", "10ps", "SaveRadFields:=", 0, "SaveFDRadFields:=",
0, "UseAutoTermination:=", _
1, "SteadyStateCriteria:=", 0.01, "UseMinimumDuration:=", 0, "Ter-
minateOnMaximum:=", _
1, "UseMaxTime:=", 1, "MaxTime:=", "20ns"))

Python Syn- InsertSetup("HfssTransient", [<parameters>])


tax

oModule.InsertSetup("HfssTransient",
[
"NAME:Setup2",
"Frequency:=" , "5GHz",
Python "MaxDeltaS:=" , 0.02,
Example "MaximumPasses:=" , 20,
"UseImplicitSolver:=" , True,
"IsEnabled:=" , True,

Analysis Setup Module Script Commands 15-45


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"BasisOrder:=" , -1,
[
"NAME:Transient",
"TimeProfile:=" , "Broadband Pulse",
"HfssFrequency:=" , "5GHz",
"MinFreq:=" , "100MHz",
"MaxFreq:=" , "1GHz",
"NumFreqsExtracted:=" , 401,
"SweepMinFreq:=" , "100MHz",
"SweepMaxFreq:=" , "1GHz",
"ListsForFields:=" , ["Facelist1"],
"UseSaveCount:=" , 1,
"SaveCount:=" , 256,
"UseSaveStart:=" , 1,
"SaveStart:=" , "0s",
"UseSaveDelta:=" , 1,
"SaveDelta:=" , "10ps",
"SaveRadFields:=" , 0,
"SaveFDRadFields:=" , 0,
"UseAutoTermination:=" , 1,
"SteadyStateCriteria:=" , 0.01,
"UseMinimumDuration:=" , 0,
"TerminateOnMaximum:=" , 0
]
])

InsertSweep [HFSS-IE]
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>,

Analysis Setup Module Script Commands 15-46


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<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.
<additionalRanges>
Array( "SetupType:=", "<SetupType>",
"StartValue:=", "<ValueUnits>",
"StopValue:=", "<ValueUnits", "Count:=", <value>, ...)

VB Example:Discrete Sweep

oModule.InsertSweep "Setup1", Array("NAME:Sweep2", _


"IsEnabled:=", true,
"SetupType:=", "LinearStep", _
"StartValue:=", "19.5GHz", _
"StopValue:=", "20.4GHz", _

Analysis Setup Module Script Commands 15-47


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"StepSize:=", "0.1GHz", _
"Type:=", "Discrete", _
"SaveFields:=", false, "ExtrapToDC:=", false)

VB 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")

VB Example: Interpolating Sweep

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, _

Analysis Setup Module Script Commands 15-48


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"InterpUsePropConst:=", true, "UseFullBasis:=", true)

VB 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)

VB Example: A Fast sweep, specified using the starting and stopping


frequencies and the step count:
oModule.InsertSweep "Setup1", Array("NAME:Sweep4", _
"IsEnabled:=", true, "SetupType:=", "LinearCount", _
"StartValue:=", "1GHz", _
"StopValue:=", "10GHz", _
"Count:=", 3, _
"Type:=", "Fast", _
"SaveFields:=", true, "ExtrapToDC:=", false)

Analysis Setup Module Script Commands 15-49


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

PasteSetup
Use: Paste a solve setup.
Syntax: PasteSetup
Return Value: None
VB Example: oModule.PasteSetup

PasteSweep
Use: Paste a sweep.
Syntax: PasteSweep <SetupName>
Return Value: None
Parameters: <SetupName>
Type: <String>
Name of solve setup where the copied sweep is pasted.
VB Example: oModule.PasteSweep "Setup6"

RenameDrivenSweep
Use: Renames an existing frequency sweep in HFSS. For HFSS-IE use RenameSweep.
Command: Right-click a frequency sweep in the Project Manager and then click Rename on the
shortcut menu.
Syntax: RenameDrivenSweep <SetupName>, <OldSweepName>,
<NewSweepName>
Return Value: None
VB Example:
oModule.RenameDrivenSweep "Setup1", "Sweep1", "MySweep"

RenameSetup
Use: Renames an existing solution setup.

Analysis Setup Module Script Commands 15-50


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Command: Right-click a solution setup in the Project Manager and then click Rename on the short-
cut 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.
VB Example: oModule.RenameSetup "Setup1", "Setup2"

RenameSweep [HFSS-IE]
Use: Renames an existing frequency sweep in HFSS-IE.
Command: Right-click a frequency sweep in the Project Manager and then click Rename on the
shortcut menu.
Syntax: RenameSweep <SetupName>, <OldSweepName>,
<NewSweepName>
Return Value: None
VB Example:
oModule.RenameSweep "Setup1", "Sweep1", "MySweep"

For Q3D Extractor, the command details are as follows:


Use: Rename an existing sweep.
Command: Right-click a sweep in the Project Manager and then click Rename on the shortcut
menu.
Syntax: RenameSweep <SetupName>, <OldSweepName>, <NewSweepName>
Return Value: None
Parameters: <SetupName>
Type: <string>

Analysis Setup Module Script Commands 15-51


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name of the setup.


<OldSweepName>
Type: <String>
Name of sweep to be renamed.
<NewSweepName>
Type: <string>
New name for the sweep.
VB Example: oModule.RenameSweep "Setup6", "Sweep3", "NewSweep"

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: [product]>Analysis Setup>Revert to Initial Mesh
Syntax: RevertAllToInitial
Return Value: None
For Q3D Extractor and 2D Extractor, the command details are as follows:
Use: Marks the current mesh for all solution setups as invalid. This will force the next simulation to
begin with the initial mesh.
Command: Q3D Extractor or 2D Extractor>Analysis Setup>Revert to Initial Mesh
Syntax: RevertAllToInitial
Return Value: None
VB Example: oModule.RevertAllToInitial

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
Parameters: <SetupName>
The name of the solution setup you want to revert to.

Analysis Setup Module Script Commands 15-52


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Example: oModule.RevertSetupToInitial "Setup1"

SetMPIVendor
The documented command is applicable for Q3D Extractor.
Use: Specify vendor name.
Syntax: SetMPIVendor <vendorname>, <product name>
Return Value: None
Parameters: <vendorname>
Type: <String>
Name of MPI vendor. Possible values are "Intel", "Plat-
formComputing"
<product name>
Type: <String>
Valid value is "Q3D Extractor". It is optional input, if not spe-
cified the default value is "Q3D Extractor"
oAnsoftApp.SetMPIVendor "Intel", "Q3D Extractor"

Analysis Setup Module Script Commands 15-53


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

15-54
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

16 - Optimetrics Module Script Commands


Optimetrics script commands should be executed by the "Optimetrics" module.
Set oModule = oDesign.GetModule("Optimetrics")
oModule.CommandName <args>

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.
<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>:=",

Optimetrics Module Script Commands 16-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<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>
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>, "rel:=", <Cond>, "rhs:=", <Rhs>), ...
"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>

Optimetrics Module Script Commands 16-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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:=",
<StopV>))
<Soln>
Type: <string>
Name of the solution.
<Calc>
Type: <string>
An expression that is composed of a basic solution quantity and an
output variable.
<ContextName>
Type: <string>
Name of context needed in the evaluation of <Calc>.
<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.
if "s", start values specify the single value for the variable.

Optimetrics Module Script Commands 16-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

The topics for this section include:


General Commands Recognized by the Optimetrics Module
Parametric Script Commands
Optimization Script Commands
Sensitivity Script Commands
Statistical Script Commands

General Commands Recognized by the Optimetrics Module


Following are general script commands recognized by the Optimetricsmodule:
CopySetup
DeleteSetups (Optimetrics)
DistrbutedAnalyzeSetup
ExportDXConfigFile
ExportOptimetricsProfile
ExportOptimetricsResult
ExportParametricResults
GetChildNames (Optimetrics)
GetChildObject (Optimetrics)
GetChildType (Optimetrics)
GetPropNames (Optimetrics)
GetPropValue (Optimetrics)
GetSetupNames (Optimetrics)
GetSetupNamesByType (Optimetrics)
ImportSetup
PasteSetup
RenameSetup (Optimetrics)
SetPropValue [Optimetrics]
SolveSetup (Optimetrics)
SolveAllSetup
CopySetup
Copy the specified Optimetrics setup.

Optimetrics Module Script Commands 16-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access NA

Name Type Description


Parameters
<SetupName> String Name of the setup

Return Value None

Python Syn- CopySetup (<SetupName>)


tax

Python oModule.CopySetup ("OptimizationSetup1")


Example

VB Syntax CopySetup <SetupName>


VB Example oModule.CopySetup "OptimizationSetup1"

DeleteSetups [Optimetrics]
Deletes the specified Optimetrics setups.

Right-click the setup in the project tree, and then click Delete on the shortcut
UI Access
menu

Name Type Description


Parameters <NameArray> Array of An Array of Setup Names
Strings

Return Value None

Python Syn- DeleteSetups (<NameArray>)


tax

Python oModule.DeleteSetups (["OptimizationSetup1"])


Example

VB Syntax DeleteSetups <NameArray>


VB oModule.DeleteSetups Array("OptimizationSetup1")
Example

Optimetrics Module Script Commands 16-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

DistributedAnalyzeSetup
Distributes all variable value instances within a parametric sweep to different machines already spe-
cified from within the user interface

Right-click the parametric setup name in the project tree and select Distribute
UI Access
Analysis.

Name Type Description


Parameters
 <ParametricSetupName> String Name of the Setup

Return Value None

Python DistributedAnalyzeSetup (<ParametricSetupName>)


Syntax

Python oModule.DistributedAnalyzeSetup("ParametricSetup1")
Example

VB Syn- DistributedAnalyzeSetup <ParametricSetupName>


tax

VB oModule.DistributedAnalyzeSetup "ParametricSetup1"
Example

ExportDXConfigFile
Create an xml file with the setup information for Design Xplorer

Right click on the Design Xplorer setup in the project tree and choose Export
UI Access
External Connector Addin Configuration…

Name Type Description


Parameters
<SetupName> String Must be one of existing DesignExplorer setup
names
<FileName> String Must be a valid file path and name

Return Value None

Python ExportDXConfigFile (<SetupName>, <FileName>)


Syntax

Python oModule.ExportDXConfigFile ("DesignXplorerSetup1",


Example

Optimetrics Module Script Commands 16-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"c:/exportdir/DXSetup1.xml")

VB Syn- ExportDXConfigFile <SetupName>, <FileName>


tax

VB
oModule.ExportDXConfigFile ("DesignXplorerSetup1",
Example "c:/exportdir/DXSetup1.xml")

ExportOptimetricsProfile
Export Optimetrics profile data

Right click on the Optimetrics setup in the project tree and choose View Ana-
UI Access lysis Result… On the Post Analysis Display dialog, click the Profile tab and
click on the Export button.

Name Type Description


<SetupName> String Must be one of the existing Parametric, Optim-
ization, Sensitivity, Statistical or
DesignXplorer setup names
Parameters <FileName> String Must be a valid file path and name with exten-
sion of csv, tab, dat, or txt
[profileNum] String Must be a numeric string. Optional: defaulted
to last profile number. It should be a zero
indexed profile number.

Return Value None

Python ExportOptimetricsProfile (<SetupName>, <FileName>, [profileNum]


Syntax

oModule.ExportOptimetricsProfile
Python
Example ("StatisticalSetup1", "

VB Syntax ExportOptimetricsProfile <SetupName>, <FileName>, [profileNum]

VB oModule.ExportOptimetricsProfile
Example "StatisticalSetup1", "c:/exportdir/test.csv"

Optimetrics Module Script Commands 16-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ExportOptimetricsResult
 Export an existing Optimization, Sensitivity, Statistical or DesignXplorer result. (Does not export
Parametric results.)

Right click on the desired Optimetrics setup in the project tree and choose View
UI Access Analysis Result… On the Post Analysis Display dialog, click the Result tab,
then select Table view, and click on the Export button

Name Type Description


<SetupName> String Must be one of the existing Optimization,
Sensitivity, Statistical, or DesignXplorer
setup names
Parameters <FileName> String Must be a valid file path and name with
extension of csv, tab, dat, or txt..
[useFullOutputName] Boolean Optional: defaulted to false. If set to true val-
ues will be printed with units. This parameter
is ignored for Optimization and Statistical res-
ults.

Return Value None

Python ExportOptimetricsResult (<SetupName>, <FileName>, [useFullOutputName])


Syntax

Python oModule.ExportOptimetricsResult (
Example "StatisticalSetup1", "c:/exportdir/test.csv",false)

VB ExportOptimetricsResult <SetupName>, <FileName>, [useFullOutputName]


Syn-
tax

VB oModule.ExportOptimetricsResult "StatisticalSetup1", "c:/-


Exam- exportdir/test.csv",
ple false

ExportParametricResults
Export existing Parametric results.

Right click on the desired Parametric setup in the project tree and choose View
UI Access Analysis Result… On the Post Analysis Display dialog, click the Result tab,
then select Table view, and click on the Export button.

Parameters Name Type Description

Optimetrics Module Script Commands 16-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<SetupName> String Must be one of the existing Parametric setup


names
<FileName> String Must be a valid file path and name with exten-
sion of csv, tab, dat or txt
<bOutputUnits> Boolean If set to true, values will be printed with units

Return Value None

Python ExportParametricResults (<SetupName>, <FileName>, <bOutputUnits>)


Syntax

Python oModule.ExportParametricResults (
Example "ParametricSetup1", "c:/exportdir/test.csv", False)

VB Syntax ExportParametricResults <SetupName>, <FileName>, <bOutputUnits>

VB oModule.ExportParametricResults
Example "ParametricSetup1", "c:/exportdir/test.csv",false

GetChildNames [Optimetrics]
If used without a specific optimization setup name, gets a list of all setups for all types. If a with a
specific setup name, returns names for that optimization setup.

UI Access NA

Name Type Description


typeName text string Optional, default to get all types of setup
Parameters names. Or one of type name return in
GetChildTypes(). Also, the type name can be
used without the prefix “Opti”.

Return Value Array of setup names.

Python Syn- GetChildNames()


tax

oOptimModule = oDesign.GetChildObject(“Optimetrics”)
Python
arrAllSetup = oOptimModule.GetChildNames()
Example
arrParmSetup = oOptimModule.GetChildNames(“'OptiPara-

Optimetrics Module Script Commands 16-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

metric'”)
arrOptimizeSetup = oOptimModule.GetChildNames(“'Optim-
ization'”)

GetChildObject [Optimetrics]
Gets a Setup Object of the Optimetrics module

UI Access NA

Name Type Description


Parameters Setup Name text string A optimetrics setup name, names returned by
the GetChildNames().

A script object for the setup See discussion of Optimetrics Setup Objects in
Return Value Object Script Property Function Summary.

Python Syn- GetChildObject()


tax

oParamSetup = oOptModule.GetChildObject('Para-
Python metricSetup1')
Example oOptSetup = oOptModule.GetChildObject('Optim-
izationSetup1')

GetChildTypes [Optimetrics]
Use: Gets child types of queried Optimetrics module.
Syntax: GetChildTypes()
Return Value: Array of text string, it can be an empty array if there is no setup is defined. There are
six types of setup, they are ['OptiParametric', 'OptiOptimization', 'OptiSensitivity', 'OptiStatistical',
'OptiDesignExplorer', 'OptiDXDOE'].

Python Syn- GetChildTypes ()


tax

Python oOptimModule = oDesign.GetChildObject(“Optimetrics”)


Example arrSetupTypes = oOptimModule.GetChildTypes()

Optimetrics Module Script Commands 16-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetPropNames [Optimetrics]
Use: Always returns the empty set for Optimetrics objects since they do not have properties.
Syntax: GetPropNames(bIncludeReadOnly)
Return Value: Returns empty set.
Parameters: bIncludeReadOnly—optional, default to True.

Python Syn- GetPropNames ()


tax

oOptModule.GetPropNames()
Python
oOptModule.GetPropNames(True)
Example
oOptModule.GetPropNames(False)

GetPropValue [Optimetrics]
Returns the property value for a setup property.

UI Access NA

Name Type Description


Parameters property-path a child object's property path. See property
path discussion here.

Return Value Returns the value of an setup property.

Python Syn- GetPropValue(propPath)


tax

oOptModule.GetPropValue("OptimizationSetup1\Optimizer")
//get the optimizer name for OptimizationSetup1
Python
Example oOptModule.GetPropValue("Optim-
izationSetup1\Optimizer\Choices") //Get the menu prop-
erty’s menu items. In this case all Optimizer names.

VB Syn- GetPropValue()
tax

VB GetPropValue(“Optimetrics/OptimizationSetup1/Enabled”)
Example
Returns True if Enabled, or False if disabled.

Optimetrics Module Script Commands 16-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetSetupNames [Optimetrics]
Gets a list of Optimetrics setup names

UI Access NA

Name Type Description


Parameters
None

Return Value IAnsoftCollectionObj – a collection of Optimetrics setup names

Python Syn- GetSetupNames()


tax

oModule = oDesign.GetModule("Optimetrics")
Python
Example setupNames = oModule.GetSetupNames()

VB Syn- GetSetupNames()
tax

Set oModule_opt = oDesign.GetModule("Optimetrics")


VB
Set opt_setup_list = oModule.GetSetupNames()
Example
numsetups = setupnames.Count

GetSetupNamesByType [Optimetrics]
Gets a list of Optimetrics setup names by type.

UI Access NA

Name Type Description


Parameters <Optimetrics type> String Examples: parametric, optimization, stat-
istical, sensitivity

Return Value  Array of Optimetrics setup names of the given type.

Python GetSetupNamesByType (<Optimetrics type>)


Syntax

Python for name in oModule.GetSetupNamesByType("optimization")


Example

Optimetrics Module Script Commands 16-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

AddInfoMessage(str(name))

VB Syn- GetSetupNamesByType <Optimetrics type>


tax

For each name in oModule.GetSetupNamesByType("optim-


VB ization")
Exampl-
Msgbox name
e
Next

ImportSetup
Import an Optimetric setup from a file.

UI Access NA

Name Type Description


<SetupTypeName> String Must be one of "OptiParametric" , "OptiOp-
timization", "OptiSensitivity", "OptiStatistical",
or "OptiDesignExplorer".
<SetupInfo> Array Array("NAME:<SetupName>", "FilePath")
<SetupName>
Parameters Type: <string>
Name of the setup.
<FilePath>
Type : <string: file path>
Must be a valid file path and
name.

Return Value None

Python Syn- ImportSetup (<SetupTypeName>, <SetupInfo>)


tax

Optimetrics Module Script Commands 16-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModule.ImportSetup ("OptiStatistical",
Python ["NAME:StatisticalSetup1",
Example
"c:/importdir/mySetupInfoFile"])

VB Syntax ImportSetup <SetupTypeName>, <SetupInfo>


oModule.ImportSetup "OptiStatistical",
VB Array("NAME:StatisticalSetup1",
Example

"c:/importdir/mySetupInfoFile")

PasteSetup [Optimetrics]
Pastes the specified Optimetrics setup.

UI Access NA

Name Type Description


Parameters
<SetupName> String Name of the Setup

Return Value None

Python Syn- PasteSetup (<SetupName>)


tax

Python oModule.PasteSetup ("OptimizationSetup1")


Example

VB Syntax PasteSetup <SetupName>


VB oModule.PasteSetup "OptimizationSetup1"
Example

RenameSetup [Optimetrics]
Renames the specified Optimetrics setup.

Right-click the setup in the project tree, and then click Rename on the
UI Access
shortcut menu.

Optimetrics Module Script Commands 16-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name Type Description


Parameters <OldName> String The name that needs to be replaced
<NewName> String Replacement name

Return Value None

Python RenameSetup (<OldName> <NewName>)


Syntax

Python oModule.RenameSetup ("OptimizationSetup1" "MyOptimization")


Example

VB Syn- RenameSetup <OldName> <NewName>


tax

VB oModule.RenameSetup "OptimizationSetup1" "MyOptimization"


Example

SetPropValue [Optimetrics]
Sets the property value for the active Optimetrics setup.

UI Access Set Property value on Optimetrics objects

Name Type Description


Property path text string Setup property path. See discussion of Prop-
erty Path
Parameters
new Value Text String, New value data type is depending on the prop-
Number, or erty type,
Boolean

Return Value True if the property is found and the new value is valid. Otherwise return False.

Python Syn- SetPropValue(propPath, newValue)


tax

oOptModule.SetPropValue("ParametricSetup1\Enabled",
Python False) //disable ParametricSetup1
Example oOptModule.SetPropValue("Optim-
izationSetup1/Optimizer","Quasi Newton")

Optimetrics Module Script Commands 16-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax SetPropValue(propPath, newValue)


VB SetPropValue("ParametricSetup1\Enabled", False)
Example

SolveAllSetup
Solves all Optimetrics setups

 Right-click on Optimetrics in Project Manager and select Analyze>All from


UI Access
context menu

Name Type Description


Parameters
None

Return Value None

Python Syn- SolveAllSetup()


tax

Python oModule.SolveAllSetup()
Example

VB Syntax SolveAllSetup
VB Example oModule.SolveAllSetup

SolveSetup [Optimetrics]
 Solves the specified Optimetrics setup.

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

Name Type Description


Parameters
<SetupName> String Name of the setup to be solved

Return Value None

Python Syn- SolveSetup (<SetupName>)


tax

Python oModule.SolveSetup ("OptimizationSetup1")


Example

Optimetrics Module Script Commands 16-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax SolveSetup <SetupName>


VB oModule.SolveSetup "OptimizationSetup1"
Example

Parametric Script Commands


EditSetup [Parametric]
ExportParametricSetupTable
GenerateVariationData [Parametric]
InsertSetup [Parametric]
EditSetup [Parametric]
Modifies an existing parametric setup

Right-click the setup in the project tree, and then click Properties on the short-
UI Access
cut menu.

Name Type Description


Parameters <SetupName> String Name of the Setup

Return Value None

Python Syn- EditSetup (<SetupName>, <ParametricParams>)


tax

Python See EditSetup [Optimization]


Example

VB Syntax EditSetup <SetupName>, <ParametricParams>


VB Example See EditSetup [Optimization]

ExportParametricSetupTable
Exports the parametric setup table as a CSV file.

UI Access Double-click parametric setup. Select Table tab. Click Export.

Optimetrics Module Script Commands 16-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name Type Description


Parameters <SetupName> String Name of the setup.
<filePath> String Full path for file export.

Return Value None

Pyth- ExportParametricSetupTable (<SetupName>, <filePath>)


on
Syn-
tax

Pyth- oModule.ExportParametricSetupTable('ParametricSetup1',
on 'E:/Files/ParametricSetup1_Table.csv')
Exa-
mple

VB ExportParametricSetupTable <SetupName>, <filePath>


Syn-
tax

VB obj.ExportParametricSetupTable "ParametricSetup1",
Exa- "E:/Files/ParametricSetup1_Table.csv"
mple

GenerateVariationData (Parametric)
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 the setup.
VB Example:
oModule.GenerateVariationData "ParametricSetup1"
InsertSetup [Parametric]
Inserts a new parametric setup.

Right-click the Optimetrics folder in the project tree, and then click Add> Para-
UI Access
metric on the shortcut menu.

Optimetrics Module Script Commands 16-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name Type Description


<Parametric Array Array("NAME:<SetupName>", "SaveField-
Params> s:=",
<SaveField>, <StartingPoint>, "Sim.
Setups:=",
<SimSetups>,
<SweepDefs>, <SweepOps>,
Array("NAME:Goals", Array("NAME:Goal",
<OptiGoalSpec>), ... Array("NAME:Goal",
<OptiGoalSpec>))
<SetupName> String Name of the parametric setup.
<SimSetups> Array of An array of Twin Builder solution setup
Strings names.
<SweepDefs> Array Array("NAME:Sweeps",
Array("NAME:SweepDefinition", "Variable:=",

Parameters
<VarName>, "Data:=", <SweepData>,
"Synchronize:=", <SyncNum>), ...
Array("NAME:SweepDefinition", "Variable:=",

<VarName>, "Data:=", <SweepData>,


"Synchronize:=", <SyncNum>))
<SweepData> String "<SweepType>, <StartV>, <StopV>,
<StepV>"
<SweepType> String The type of sweep data.
<SyncNum> Integer SweepDatas with the same value are syn-
chronized.
<SweepOps> Array("NAME:Sweep Operations",
"<OpType>:=,
Array(<VarValue>, …, <VarValue>), ...
<OpType>:=, Array(<VarValue>, …,
<VarValue>))
<OpType> String The sweep operation type.

Return Value None

Python Syn- InsertSetup ("OptiParametric", <ParametricParams>)

Optimetrics Module Script Commands 16-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

tax

oModule.InsertSetup(
"OptiParametric",
["NAME:ParametricSetup1", _
"SaveFields:=", true, _
["NAME:StartingPoint"], _
"Sim. Setups:=", ["Setup1"],_
["NAME:Sweeps", _
["NAME:SweepDefinition", _
"Variable:=", "$width", _
"Data:=", "LIN 12mm 17mm 2.5mm", _
"OffsetF1:=", false, _
"Synchronize:=", 0],
["NAME:SweepDefinition", _
"Variable:=", "$length", _
Python
Example "Data:=", "LIN 8mm 12mm 2mm", _
"OffsetF1:=", false, _
"Synchronize:=", 0]],
["NAME:Sweep Operations"], _
["NAME:Goals", _
["NAME:Goal", _
"Solution:=", "Setup1 : LastAdaptive", _
"Calculation:=", "returnloss", _
"Context:=", "",_
["NAME:Ranges", _
"Range:=", ["Var:=", "Freq", "Type:=","s", _
"Start:=", "8GHz", "Stop:=", "8GHz"]], _
["NAME:Goal", _
"Solution:=", "Setup1 : LastAdaptive",_

Optimetrics Module Script Commands 16-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Calculation:=", "reflect", _
"Context:=", "", _
["NAME:Ranges", _
"Range:=", ["Var:=", "Freq", "Type:=","s", _
"Start:=", "8GHz", "Stop:=", "8GHz"]]]]]])

VB Syntax InsertSetup "OptiParametric", <ParametricParams>


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", _
VB
"OffsetF1:=", false, _
Example
"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", _

Optimetrics Module Script Commands 16-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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", _
"Range:=", Array("Var:=", "Freq", "Type:=","s", _
"Start:=", "8GHz", "Stop:=", "8GHz")))))

Optimization Script Commands


EditSetup [Optimization]
InsertSetup [Optimization]
EditSetup [Optimization]
Modifies an existing optimization setup.

Right-click the setup in the project tree, and then click Properties on the shortcut
UI Access
menu

Name Type Description


Parameters <SetupName> String Name of the Setup

Return Value None

Python EditSetup (<SetupName>, <OptimizationParams>)


Syntax

oModule.EditSetup("OptimizationSetup1",
Python
[
Example
"NAME:OptimizationSetup1",

Optimetrics Module Script Commands 16-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"UseFastCalculationUpdateAlgo:=", False,
"FastCalcOptCtrledByUser:=", False,
"IsEnabled:=", True,
"SaveSolutions:=", False,
[
"NAME:StartingPoint"
],
"Optimizer:=", "Quasi Newton",
[
"NAME:AnalysisStopOptions",
"StopForNumIteration:=" , True,
"StopForElapsTime:=", False,
"StopForSlowImprovement:=", False,
"StopForGrdTolerance:=", False,
"MaxNumIteration:=",1000,
"MaxSolTimeInSec:=",3600,
"RelGradientTolerance:=", 0,
"MinNumIteration:=", 10
],
"CostFuncNormType:=", "L2",
"PriorPSetup:=", "",
"PreSolvePSetup:=", True,
[
"NAME:Variables"
],
[
"NAME:LCS"
],
[

Optimetrics Module Script Commands 16-23


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"NAME:Goals",
[
"NAME:Goal",
"ReportType:=", "Standard",
"Solution:=", "TR",
[
"NAME:SimValueContext",
"SimValueContext:=", [1,0,2,0,False,False,-1,1,0,1,1,"",0,0
]
],
"Calculation:=", "acosh(Time)",
"Name:=", "Time",
[
"NAME:Ranges",
"Range:=", ["Var:=", "Time","Type:=", "a"]
],
"Condition:=", "==",
[
"NAME:GoalValue",
"GoalValueType:=", "Independent",
"Format:=", "Real/Imag",
"bG:=", ["v:=", "[1;]"]
],
"Weight:=", "[1;]"
]
],
"Acceptable_Cost:=" , 0,
"Noise:=", 0.0001,
"UpdateDesign:=", False,

Optimetrics Module Script Commands 16-24


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"UpdateIteration:=", 5,
"KeepReportAxis:=", True,
"UpdateDesignWhenDone:=", True
])

VB EditSetup <SetupName>, <OptimizationParams>


Syn-
tax

oModule.EditSetup "OptimizationSetup1",
Array("NAME:OptimizationSetup1", "UseFastCal-
culationUpdateAlgo:=", _
false, "FastCalcOptCtrledByUser:=", false,
"IsEnabled:=", true, "SaveSolutions:=", _
false, Array("NAME:StartingPoint"), "Optimizer:=",
"Quasi Newton", Array("NAME:AnalysisStopOptions",
"StopForNumIteration:=", _
true, "StopForElapsTime:=", false,
"StopForSlowImprovement:=", false, "StopForGrdTolerance:=",
_
VB false, "MaxNumIteration:=", 1000, "MaxSolTimeInSec:=",
Exam-
ple 3600, "RelGradientTolerance:=", _
0, "MinNumIteration:=", 10), "CostFuncNormType:=",
"L2", "PriorPSetup:=", "", "PreSolvePSetup:=", _
true, Array("NAME:Variables"), Array("NAME:LCS"),
Array("NAME:Goals", Array("NAME:Goal", "ReportType:=", _
"Standard", "Solution:=", "TR", Array("NAME:SimValueCon-
text",
"SimValueContext:=", Array( _
1, 0, 2, 0, false, false, -1, 1, 0, 1, 1, "", 0, 0)),
"Calculation:=", "Time", "Name:=", _
"Time", Array("NAME:Ranges", "Range:=",

Optimetrics Module Script Commands 16-25


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("Var:=", "Time", "Type:=", "a")), "Condition:=", _


"==", Array("NAME:GoalValue", "GoalValueType:=",
"Independent", "Format:=", _
"Real/Imag", "bG:=", Array("v:=", "[1;]")),
"Weight:=", "[1;]")), "Acceptable_Cost:=", _
0, "Noise:=", 0.0001, "UpdateDesign:=", false,
"UpdateIteration:=", 5, "KeepReportAxis:=", _
true, "UpdateDesignWhenDone:=", true)

InsertSetup [Optimization]
Use: Inserts a new optimization setup.

Right-click the Optimetrics folder in the project tree, and then click Add>Op-
UI Access
timization on the shortcut menu.

Name Type Description


<OptimizationParams> Array Array("NAME:<SetupName>",
"SaveFields:=",
<SaveField>, <StartingPoint>, "Optim-
izer:=",
<Optimizer>,
"MaxIterations:=", <MaxIter>, "Pri-
orPSetup:=",
<PriorSetup>, "PreSolvePSetup:=",
<Preceed>,

Parameters <OptimizationVars>, <Constraint>,


Array("NAME:Goals", Array
("NAME:Goal",
<OptiGoalSpec>, <Optim-
izationGoalSpec>), ...
Array("NAME:Goal", <OptiGoalSpec>,
<OptimizationGoalSpec>)),
"Acceptable_Cost:=", <Accept-
ableCost>, "Noise:=",
<Noise>, "UpdateDesignWhenDone:=",
<UpdateDesign"

Optimetrics Module Script Commands 16-26


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<OptimizationVars> Array Array("NAME:Variables",


"VarName:=", Array("i:=",
<IncludeVar>, "Min:=",
<MinV>, "Max:=", <MaxV>,
"MinStep:=", <MinStepV>,
"MaxStep:=", <MaxStepV>),
………………. "VarName:=", Array
("i:=", <IncludeVar>,
"Min:=", <MinV>, "Max:=",
<MaxV>,
"MinStep:=", <MinStepV>,
"MaxStep:=", <MaxStepV>))
<MinStepV> VarValue The minimum step of the variable.
<MaxStepV> VarValue The maximum step of the variable.
<AcceptableCost> Double The acceptable cost value for the optim-
izer to stop.
<Noise> Double The noise of the design.
<UpdateDesign> Boolean Specifies whether or not to apply the
optimal variation to the design after the
optimization is done.
<OptimizationGoalSpec> Array "Condition:=", <Optim-
izationCond>,
Array("NAME:GoalValue",
"GoalValeType:=",
<GoalValueType>,
"Format:=",
<GoalValueFormat>, "bG:=",
Array("v:=", <GoalValue>)),
"Weight:=", <Weight>)
<OptimizationCond> String Either "<=", "==", or ">="
<GoalValueType> String Either "Independent" or "Depend-
ent"
<GoalValueFormat> String Either "Real/Imag" or "Mag/Ang".
<GoalValue> String Value in string. Value can be a real num-
ber, complex number, or expression.

Return None
Value

Command: Right-click the Optimetrics folder in the project tree, and then click Add>Op-
timization on the shortcut menu.
Syntax: InsertSetup "OptiOptimization", <OptimizationParams>

Optimetrics Module Script Commands 16-27


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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>),
………………. "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.

Optimetrics Module Script Commands 16-28


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<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 ">="

<GoalValueType>
Type: <string>
Either "Independent" or "Dependent"

<GoalValueFormat>

Optimetrics Module Script Commands 16-29


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type:<string>
Either "Real/Imag" or "Mag/Ang".

<GoalValue>
Type: <string>
Value in string. Value can be a real number, complex number, or expression.
VB 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 16-30


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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)

Python Syn- InsertSetup ("OptiOptimization", <OptimizationParams>)


tax

oModule.InsertSetup(
"OptiOptimization",_
["NAME:OptimizationSetup1", _
"SaveFields:=", false, _
["NAME:StartingPoint", "$length:=", "8mm",_
Python
Example "$width:=", "14.5mm"], _
"Optimizer:=", "Quasi Newton", _
"MaxIterations:=", 100, _
"PriorPSetup:=", "ParametricSetup1", _
"PreSolvePSetup:=", true, _

Optimetrics Module Script Commands 16-31


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

["NAME:Variables", _
"$length:=", ["i:=", true, "Min:=", "6mm",_
"Max:=", "18mm", _
"MinStep:=", "0.001mm", "MaxStep:=", _
"1.2mm"], _
"$width:=", ["i:=", true, "Min:=", _
"6.5mm", "Max:=", "19.5mm", _
"MinStep:=", "0.001mm", "MaxStep:=", _
"1.3mm"]], _
["NAME:LCS"], _
["NAME:Goals", _
["NAME:Goal", _
"Solution:=", "Setup1 : LastAdaptive", _
"Calculation:=", "reflect", _
"Context:=", "", _
["NAME:Ranges", _
"Range:=", ["Var:=", "Freq", _
"Type:=", "s", _
"Start:=", "8GHz", "Stop:=", "8GHz"]], _
"Condition:=", "&lt;=", _
["NAME:GoalValue", _
"GoalValueType:=", "Independent", _
"Format:=", "Real/Imag", _
"bG:=", ["v:=", "[0.0001]"]], _
"Weight:=", "[1]"]],
"Acceptable_Cost:=", 0.0002, _
"Noise:=", 0.0001, _
"UpdateDesign:=", true, _
"UpdateIteration:=", 5, _

Optimetrics Module Script Commands 16-32


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"KeepReportAxis:=", true, _
"UpdateDesignWhenDone:=", true)

VB Syntax InsertSetup "OptiOptimization", <OptimizationParams>


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",_
VB
Example "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 16-33


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Context:=", "", _
Array("NAME:Ranges", _
"Range:=", Array("Var:=", "Freq", _
"Type:=", "s", _
"Start:=", "8GHz", "Stop:=", "8GHz")), _
"Condition:=", "&lt;=", _
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)

Sensitivity Script Commands


EditSetup [Sensitivity]
InsertSetup [Sensitivity]
EditSetup [Sensitivity]
Modifies an existing sensitivity setup.

Right-click the setup in the project tree, and then click Properties on the shortcut
UI Access
menu

Name Type Description


Parameters <SetupName> String Name of the Setup

Return Value None

Optimetrics Module Script Commands 16-34


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python EditSetup (<SetupName>, <SensitivityParams>)


Syntax

oModule.EditSetup("OptimizationSetup1",
[
"NAME:OptimizationSetup1",
"UseFastCalculationUpdateAlgo:=", False,
"FastCalcOptCtrledByUser:=", False,
"IsEnabled:=", True,
"SaveSolutions:=", False,
[
"NAME:StartingPoint"
],
"Optimizer:=", "Quasi Newton",
[
"NAME:AnalysisStopOptions",
Python
Exampl- "StopForNumIteration:=", True,
e
"StopForElapsTime:=", False,
"StopForSlowImprovement:=", False,
"StopForGrdTolerance:=" , False,
"MaxNumIteration:=", 1001,
"MaxSolTimeInSec:=", 3600,
"RelGradientTolerance:=", 0,
"MinNumIteration:=", 10
],
"CostFuncNormType:=", "L2",
"PriorPSetup:=", "",
"PreSolvePSetup:=", True,
[
"NAME:Variables"

Optimetrics Module Script Commands 16-35


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

],
[
"NAME:LCS"
],
[
"NAME:Goals",
[
"NAME:Goal",
"ReportType:=", "Standard",
"Solution:=", "TR3",
[
"NAME:SimValueContext",
"SimValueContext:=", [1,0,2,0,False,False,-
1,1,0,1,1,"",0,0]
],
"Calculation:=", "mag(DIFF1.VAL)",
"Name:=", "DIFF1.VAL",
[
"NAME:Ranges",
"Range:=", [
"Var:=", "Time","Type:=", "a"]
],
"Condition:=", "==",
[
"NAME:GoalValue",
"GoalValueType:=", "Independent",
"Format:=", "Real/Imag",
"bG:=", ["v:=", "[1;]"]
],

Optimetrics Module Script Commands 16-36


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Weight:=", "[1;]"
]
],
"Acceptable_Cost:=", 0,
"Noise:=", 0.0001,
"UpdateDesign:=", False,
"UpdateIteration:=", 5,
"KeepReportAxis:=", True,
"UpdateDesignWhenDone:=", True
])

VB Syntax EditSetup <SetupName>, <SensitivityParams>


oModule.EditSetup("OptimizationSetup1",
Array(
"NAME:OptimizationSetup1",
"UseFastCalculationUpdateAlgo:=", False,
"FastCalcOptCtrledByUser:=", False,
"IsEnabled:=", True,
"SaveSolutions:=", False,
Array(
VB "NAME:StartingPoint"
Example
),
"Optimizer:=", "Quasi Newton",
Array(
"NAME:AnalysisStopOptions",
"StopForNumIteration:=" , True,
"StopForElapsTime:=", False,
"StopForSlowImprovement:=", False,
"StopForGrdTolerance:=", False,

Optimetrics Module Script Commands 16-37


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"MaxNumIteration:=", 1001,
"MaxSolTimeInSec:=", 3600,
"RelGradientTolerance:=", 0,
"MinNumIteration:=" , 10
),
"CostFuncNormType:=", "L2",
"PriorPSetup:=", "",
"PreSolvePSetup:=", True,
Array(
"NAME:Variables"
),
Array(
"NAME:LCS"
),
Array(
"NAME:Goals",
Array(
"NAME:Goal",
"ReportType:=", "Standard",
"Solution:=", "TR3",
Array(
"NAME:SimValueContext",
"SimValueContext:=",
Array(1,0,2,0,False,False,-1,1,0,1,1,"",0,0)
),
"Calculation:=", "mag(DIFF1.VAL)",
"Name:=", "DIFF1.VAL",
Array(
"NAME:Ranges",

Optimetrics Module Script Commands 16-38


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Range:=", Array("Var:=", "Time","Type:=", "a")


),
"Condition:=", "==",
Array(
"NAME:GoalValue",
"GoalValueType:=", "Independent",
"Format:=", "Real/Imag",
"bG:=", Array("v:=", "Array(1;]")
),
"Weight:=", "Array(1;]"
)
),
"Acceptable_Cost:=", 0,
"Noise:=", 0.0001,
"UpdateDesign:=", False,
"UpdateIteration:=", 5,
"KeepReportAxis:=", True,
"UpdateDesignWhenDone:=", True
))

InsertSetup [Sensitivity]
Inserts a new sensitivity setup.

Right-click Optimetrics in the project tree, and then click Add>Sensitivity on


UI Access
the shortcut menu.

Name Type Description


<SensitivityParams> Array Array("NAME:<SetupName>", "SaveField-
s:=",

Parameters <SaveField>, <StartingPoint>, "MaxIter-


ations:=",
<MaxIter>, "PriorPSetup:=", <PriorSetup>,
"PreSolvePSetup:=", <Preceed>, <Sens-

Optimetrics Module Script Commands 16-39


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

itivityVars>,
<Constraint>,
Array("NAME:Goals", Array("NAME:Goal",
<OptiGoalSpec>), ..., Array("NAME:Goal",
<OptiGoalSpec>)), "Master Goal:=". <Master-
GoalID>,
"MasterError:=", <MasterError>)
<SensitivityVars> Array Array("NAME:Variables",
"VarName:=", Array("i:=", <IncludeVar>,
"Min:=", <MinV>, "Max:=", <MaxV>,
"IDisp:=", <InitialDisp>),...
"VarName:=", Array("i:=", <IncludeVar>,
"Min:=", <MinV>, "Max:=", <MaxV>,
"IDisp:=", <InitialDisp>))
<InitialDisp> VarValue Index of the master goal. Index starts from
zero.
<MasterError> Double Error associated with the master goal.

Return Value None

Python Syn- InsertSetup ("OptiSensitivity", <SensitivityParams>)


tax

oModule.InsertSetup(
"OptiSensitivity", _
["NAME:SensitivitySetup1",_
"SaveFields:=", true,_
["NAME:StartingPoint"], _
Python
Example "MaxIterations:=", 20,_
"PriorPSetup:=", "",_
"PreSolvePSetup:=", true, _
["NAME:Variables"], _
["NAME:LCS"],_

Optimetrics Module Script Commands 16-40


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"NAME:Goals",_
["NAME:Goal", _
"Solution:=", "Setup1 : LastAdaptive",_
"Calculation:=", "returnloss",_
"Context:=", "",_
["NAME:Ranges",_
"Range:=", ["Var:=", "Freq", "_
Type:=", "s",_
"Start:=", "8GHz", "Stop:=", "8GHz"]]],_
["NAME:Goal",_
"Solution:=", "Setup1 : LastAdaptive",_
"Calculation:=", "reflect",_
"Context:=", "",_
["NAME:Ranges",_
"Range:=", ["Var:=","Freq",_
"Type:=", "s",_
"Start:=", "8GHz", "Stop:=", "8GHz"]]]],_
"Master Goal:=", 1,_
"MasterError:=", 0.001])

VB Syntax InsertSetup "OptiSensitivity", <SensitivityParams>


oModule.InsertSetup
"OptiSensitivity", _
Array("NAME:SensitivitySetup1",_
VB
"SaveFields:=", true,_
Example
Array("NAME:StartingPoint"), _
"MaxIterations:=", 20,_
"PriorPSetup:=", "",_

Optimetrics Module Script Commands 16-41


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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"))),_
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]
Modifies an existing statistical setup.

Right-click the setup in the project tree, and clickProperties on the shortcut
UI Access
menu.

Optimetrics Module Script Commands 16-42


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name Type Description


Parameters <SetupName> String Name of the Setup

Return Value None

Python Syn- EditSetup (<SetupName>, <StatisticalParams>)


tax

Python See EditSetup [Optimization]


Example

VB Syntax EditSetup <SetupName>, <StatisticalParams>


VB Example See EditSetup [Optimization]

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("optiguides")
Set oDesign = oProject.SetActiveDesign("HFSSModel1")
Set oModule = oDesign.GetModule("Optimetrics")
oModule.EditSetup "StatisticalSetup1", Array("NAME:S-
tatisticalSetup1",
Array("NAME:ProdOptiSetupData",
"SaveFields:=", true, "CopyMesh:=", false),
Array("NAME:StartingPoint", "$length:=", "7.824547736mm",
"$width:=", "14.8570192mm"),

Optimetrics Module Script Commands 16-43


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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",
"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",

Optimetrics Module Script Commands 16-44


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Type:=", "s",
"Start:=", "8.2GHz", "Stop:=", "0")))))
InsertSetup [Statistical]
Inserts a new statistical setup.

UI Access
Right-click Optimetrics in the project tree, and then click Add>Statistical on
the shortcut menu.

Name Type Description


<StatisticalParams> Array Array("NAME:<SetupName>",
"SaveFields:=",
<SaveField>, <StartingPoint>,
"MaxIterations:=",
<MaxIter>, "PriorPSetup:=", <Pri-
orSetup>,
"PreSolvePSetup:=", <Preceed>,
<StatisticalVars>,
Array("NAME:Goals", Array
("NAME:Goal",
<OptiGoalSpec>), …, Array
("NAME:Goal",
<OptiGoalSpec>)))
<StatisticalVars> Array Array("NAME:Variables",
Parameters
"VarName:=", Array("i:=",
<IncludeVar>, "Dist:=",
<DistType>, "Tol:=", <Tol-
erance>,
"StdD:=", <StdD>, "Min:=",
<MinCutoff>, "Max:=",
<MaxCutoff>, ...
"VarName:=", Array("i:=",
<IncludeVar>, "Dist:=",
<DistType>, "Tol:=", <Tol-
erance>, "StdD:=",
<StdD>, "Min:=", <MinCutoff>,
"Max:=",
<MaxCutoff>))
<DistType> String Distrbution can be "Gaussian" or "Uni-

Optimetrics Module Script Commands 16-45


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

form".
<Tolerance> VarValue The tolerance for the variable when dis-
tribution is Uniform
<StdD> VarValue The standard deviation for the variable when
distribution is Gaussian.
<MinCutoff> Double The minimum cut-off for the variable when dis-
tribution is Gaussian.
<MaxCutoff> Double The maximum cut-off for the variable when dis-
tribution is Gaussian.

Return Value None

Python Syn- InsertSetup ("OptiStatistical", <StatisticalParams>)


tax

oModule.InsertSetup(
"OptiStatistical", _
["NAME:StatisticalSetup1", _
"SaveFields:=", true, _
["NAME:StartingPoint"],_
"MaxIterations:=", 50,_
"PriorPSetup:=", "", _
["NAME:Variables"], _
["NAME:Goals", _
Python
["NAME:Goal", _
Example
"Solution:=", "Setup1 : LastAdaptive", _
"Calculation:=", "returnloss", _
"Context:=", "", _
["NAME:Ranges", _
"Range:=", ["Var:=", "Freq", _
"Type:=", "s",_
"Start:=", "8GHz", "Stop:=", "8GHz"]]],_
["NAME:Goal",_
"Solution:=", "Setup1 : LastAdaptive",_

Optimetrics Module Script Commands 16-46


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Calculation:=", "reflect",_
"Context:=", "", _
["NAME:Ranges",_
"Range:=", ["Var:=", "Freq", "Type:=",_
"s", "Start:=", "8GHz", "Stop:=", "8GHz"]]]])

VB Syntax InsertSetup "OptiStatistical", <StatisticalParams>


oModule.InsertSetup
"OptiStatistical", _
Array("NAME:StatisticalSetup1", _
"SaveFields:=", true, _
Array("NAME:StartingPoint"),_
"MaxIterations:=", 50,_
"PriorPSetup:=", "", _
Array("NAME:Variables"), _
Array("NAME:Goals", _
Array("NAME:Goal", _
VB
"Solution:=", "Setup1 : LastAdaptive", _
Example
"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:=", "", _

Optimetrics Module Script Commands 16-47


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:Ranges",_
"Range:=", Array("Var:=", "Freq", "Type:=",_
"s", "Start:=", "8GHz", "Stop:=", "8GHz"))))

Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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:S-
tatisticalSetup1",
Array("NAME:ProdOptiSetupData",
"SaveFields:=", false, "CopyMesh:=", false),
Array("NAME:StartingPoint", "offset:=", "0in"),
"MaxIterations:=", 50, "PriorPSetup:=", "",
Array("NAME:Variables",
"offset:=", Array("i:=", true,
"int:=", false,
"Dist:=", "Gaussian",
"Tol:=", "10%",

Optimetrics Module Script Commands 16-48


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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:SimValueCon-
text"),
"Calculation:=", "Power11",
"Name:=", "Power11",
Array("NAME:Ranges",
"Range:=", Array("Var:=", "Freq", "Type:=", "d",
"DiscreteValues:=", "10GHz")))))

For Q3D Extractor and Circuit the command details are as follows:
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>

Optimetrics Module Script Commands 16-49


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:Variables",
"VarName:=", Array("i:=", <IncludeVar>, "Dist:=",
<DistType>, "Tol:=", <Tolerance>,
"StdD:=", <StdD>, "Min:=", <MinCutoff>, "Max:=",
<MaxCutoff>, ...
"VarName:=", Array("i:=", <IncludeVar>, "Dist:=",
<DistType>, "Tol:=", <Tolerance>, "StdD:=",
<StdD>, "Min:=", <MinCutoff>, "Max:=",
<MaxCutoff>))
Parameters:
<DistType>
Type : <string>
Distrbution can be "Gaussian" or "Uniform".
<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>
The minimum cut-off for the variable when distribution is Gaus-
sian.
<MaxCutoff>
Type: <double>
The maximum cut-off for the variable when distribution is Gaus-
sian.
Example: oModule.InsertSetup "OptiStatistical", _
Array("NAME:StatisticalSetup1", _
"SaveFields:=", true, _

Optimetrics Module Script Commands 16-50


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:StartingPoint"),_
"MaxIterations:=", 50,_
"PriorPSetup:=", "", _
Array("NAME:Variables"), _
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",_
"Range:=", Array("Var:=", "Freq", "Type:=", _
"s", "Start:=", "8GHz", "Stop:=", "8GHz"))))

Optimetrics Module Script Commands 16-51


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

16-52
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

17 - Solutions Module Script Commands


Solutions commands should be executed by the "Solutions" module.
Set oModule = oDesign.GetModule("Solutions")
oModule.CommandName <args>
DeleteImportData
EditSources
DeleteSolutionVariation
ExportForSpice
ExportEigenmodes
ExportForHSpice
ExportNetworkData
ExportNMFData
GetAdaptiveFreq
GetAvailableVariations
GetExcitationScaling
GetISolutionVersionID
GetSolveRangeInfo
GetValidISolutionList
HasFields
HasMatrixData
HasMesh
ImportSolution
ImportTable
IsFieldAvailableAt
ListMatchingVariations
ListValuesOfVariables
ListVariations

DeleteImportData
Deletes imported solution or table data in HFSS. Not in HFSS-IE

Solutions Module Script Commands 17-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Command: HFSS>Results>Import Solutions


Syntax: DeleteImportData <ImportSpecArray>
Return Value: None
Parameters: <ImportSpecArray>
Array(<ImportSpec>, ...)

<ImportSpec>
Type: <string>
Format of string is "importname:solnnameORtablename".
VB Example:
oModule.DeleteImportData _
Array("Import1:Adaptive_1", "Import2:DataTable")

EditSources
For HFSS, the command details are as follows. Note that the syntax has changed for AEDT
18.2.
Indicates which source excitations should be used for fields post processing.
Command: HFSS or HFSS-IE>Fields>Edit Sources
Syntax: EditSources([["Name:=", "<portName>" , <keyword>, <value>, ...]...]
Return Value: None
Parameters:
Each inner block describes the values to be assigned to an individual excitation. The valid
keywords are:
Name ​- Required. This identifies the excitation and uses the same syntax as the edit source
dialog. As opposed to the old command, names can be specified in any order. Unspecified
excitations will not be affected, so users can edit one or more excitations without needing to
edit them all.
Magnitude ​- a unit quantity ("1W", "2mV", …)
Phase ​- a unit quantity ("1W", "2mV", …)
For Driven Terminal designs, a terminal may be terminated
Terminated ​- boolean ("true", "false"). If terminated, Magnitude and Phase are super-
seded with:
Resistance ​- a unit quantity ("50ohm", …)

Solutions Module Script Commands 17-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Reactance ​- a unit quantity ("50ohm", …)


For Transient problems, the spectral fields use Magnitude and Phase. The transient fields are con-
trolled by:
Delay- ​a unit quantity ("3.5ps", …)
TransientMagnitude ​- a unit quantity ("1W", …)
For CMA problems, the special excitation "Modes" specifies the modal excitations. These are then
set with the keywords:
Magnitudes - integer vector [ "0", "0", "1", "2.5" ]. The size of the vector will determine
how many modes are visible in the dialog.
Phases ​- unit quantity vector [ "30deg", ... ]. The size of the vector must match the size
of the magnitude vector.
For Eigen problems the special excitation "Modes" specifies the modal excitations. These are then
set with the keywords:
Magnitudes - integer vector [ "0", "0", "1", "2.5" ]. The size of the vector must match the
design,
Phases​- unit quantity vector [ "30deg", ... ]. The size of the vector must match the
design. :Phases is not needed for Stored Energy fields.
Optional settings that apply to all sources
Incident Power​- unit quantity ("2.5W"). Use in system gain calculations
SpecifySystemPower - boolean. If set, the above power is used. Otherwise, the max-
imum power is calculated.
FieldType - string. One of
ScatteredFields
TotalFields
IncidentFields
NoIncidentWave
EigenPeakElecticField
EigenStoredEnergy
IncludePortPostProcessing - boolean
For Driven Terminal designs, a terminal may be terminated
UseIncidentVoltage - boolean - otherwise use total voltage
For CMA problems:

Solutions Module Script Commands 17-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ExciteModes - boolean. If true use modal excitations, otherwise use terminals. Terminal
excitations are specified by their name, magnitude, and phase
For Eigen problems:
The special excitation "Modes" specifies the modal excitations. These are then set with the
keywords
For all unit quantities, expressions ( "3 * my_var", "pwl( freq, ds1 )") are permitted as well.
For Q3D Extractor, the documented command details are as follows:
Indicates which source excitations should be used for fields post processing.
Command: Q3D Extractor or 2D Extractor>Fields>Edit Sources
Syntax: EditSources <FieldType>, <SourceArray>,
<MultiplicityArray>, <MagnitudeArray>,
<PhaseArray>, <TerminatedArray>, <ImpedanceArray>
Return Value: None
Parameters: <SourceSettings>
"Value Type:=", <UnitType>, <SourceArray>, <ValueArray>
Parameters:
<UnitType>
Type: <string>
In Q3D Extractor, possible types for DC and AC are "A" and "V".
The only type for Cap is "V".
In 2D Extractor, the CG solution uses only "V" and the RL solu-
tion uses only "A".
<SourceArray>
Array("NAME:SourceNames", <SourceName>, <SourceName>, …)
Parameters:
<SourceName>
Type: <string>
Net name for capacitance. Source name for AC and DC
<ValueArray>
Array("NAME:Source Values", <SourceValue>, <SourceValue>, …)

Parameters:

Solutions Module Script Commands 17-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<SourceValue>
Type: <double>
The value associated with a source in
<SourceArray>.
oModule.EditSources Array("NAME:AC", "Value Type:=", "A", Array
("NAME:Source Names", _ "TheVia:Source1"), Array("NAME:Source Val-
ues", 1)),
Array("NAME:Cap", "Value Type:=", "N", _ Array("NAME:Source Names",
"GroundPlane", "TheVia"), Array("NAME:Source Values", 0, 1)), _
Array("NAME:DC", "Value Type:=", "V", Array("NAME:Source Names",
"TheVia:Source1"),
Array("NAME:Source Values", 1))

DeleteSolutionVariation
Deletes all solution data for specific solutions and design variations. This is obsolete and is sup-
ported only for backward compatibility. You should use DeleteFullVariation, DeleteFieldVariation,
and DeleteLinked Variation.
Command: [product]>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.

<SolnName>
Type: <string>
Name of the solutions within the solution setup.

Solutions Module Script Commands 17-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Example:
oModule.DeleteSolutionVariation Array( _
Array("width=’2in’", "Setup1", "Adaptive_1") _
Array("width=’2in’", "Setup1", "Sweep1") )

For Q3D Extractor, the command details are as follows:


Deletes matrix solution data for specific solutions and design variations.
Command: Q3D Extractor or 2D Extractor>Results>Clean Up Solutions
Syntax: DeleteSolutionVariation Array(<DataSpecifierArray>, …)
Return Value: None
Parameters: <DataSpecifierArray>
Array(<DesignVariationKey>, <SetupName>, <SolnName>)
Parameters:
<DesignVariationKey>
Type: <string>
Design variation string.

<SetupName>
Type: <string>
Name of the solve setup.
<SolnName>
Type: <string>
Name of the solutions within the solve setup.
VB Example: oModule.DeleteSolutionVariation Array(Array("width-
='2in'", "Setup1", "Adaptive_1") _
Array("width='2in'", "Setup1", "LastAdaptive") )

DeleteVariation [HFSS]
Obsolete. Replaced by DeleteFullVariation, DeleteFieldVariation, and DeleteLinked Variation.

ExportEigenmodes
Exports a tab delimited table of Eigenmodes in HFSS. Not in HFSS-IE.

Solutions Module Script Commands 17-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.
VB Example:
Set oModule = oDesign.GetModule("Solutions")
oModule.ExportEigenmodes "Setup1 : LastAdaptive", "", _
"C:\mydir\myeigenmode" & _
".eig"

ExportForHSpice
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 non-empty file names provided.
Command: None
Syntax: ExportForHSpice
<DesignVariationKey>, <SolnSelectionArray>, <SpiceType>,
<BandWidth>, <FWSFile>, <LumpedElementFile>,
<PoleZeroSpiceFile>, <PoleZeroMatlabFile>,
<PartialFractionFile>,

Solutions Module Script Commands 17-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<FittingErrorInPercent>, <MaximumOrder>, <MinimumOrder>, <Enfor-


cePassivity>
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>
Type: <string>

<PoleZeroMatlabFile>
Type: <string>

<PartialFractionFile>
Type: <string>

<FittingErrorInPercent>
Type: <float>

Solutions Module Script Commands 17-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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
VB Example:
oModule.ExportForHSpice "width=’2in’", _
Array("Setup1:Sweep1"), 1, 0, _
"c:\mydir\Sweep1.fws", "", "", "", "", _
.005, 20, 200

ExportNetworkData
Exports matrix solution data to a file. Available only for Driven solution types with ports.
Command: None
Syntax: ExportNetworkData
<DesignVariationKey>, <SolnSelectionArray>, <FileFormat>,
<OutFile>,<FreqsArray>, <useExportFreqs>, <DoRenorm>, <RenormImped>
<dataType> <pass> <complexFormat> <Touch-
stoneNumberofDigitsPrecision> <IncludeGammaAndImpedanceComments>
<SupportNon-standardTouchstoneExtensions>
Return Value: None
Parameters: <SolnSelectionArray>
Array(<SolnSelector>, <SolnSelector>, ...)
If more than one array entry, this indicates a combined Interpolating sweep.

Solutions Module Script Commands 17-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<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 or "All".
The frequencies to export. The <FreqsArray> argument contains a vector (e.g. "1GHz",
"2GHz", ...) to use, or "all". To export all frequencies, use Array("all").
<useExportFreqs>
Type: <bool>
Optional, currently always ignored.
<DoRenorm>
Type: <bool>
Specifies whether to renormalize the data before export.

<RenormImped>
Type: <double>
Real impedance value in ohms, for renormalization. Required in syntax,

Solutions Module Script Commands 17-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

but ignored if DoRenorm is false.


<DataType>
Type: "S", "Y", or "Z"
The matrix to export.
<Pass>
Type: string, from 1 to N.
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.
<TouchstoneNumberofDigitsPrecision>
Type: <int>
Default if not specified is 15.
<IncludeGammaAndImpedanceComments>
Type: <bool>
Specifies whether to include Gamma and Impedance comments.
<SupportNon-standardTouchstoneExtensions>
Type: <bool>
Specifies whether to support non-standard Touchstone extensions for mixed reference
impedances.

VB Example: Export all frequencies:


oModule.ExportNetworkData "width=’2in’", _
Array("Setup1:Sweep1"),2, "c:\mydir\out.tab", _
Array("all"), false, 0
VB Example: Export specific frequencies:
oModule.ExportNetworkData "width=’2in’", _

Solutions Module Script Commands 17-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("Setup1:Sweep1", "Setup1:Sweep2"), 3, _
"c:\mydir\out.s2p", Array(1.0e9, 1.5e9, 2.0e9), _
true, 50.0
VB Example: Touchstone Outputs with Precision, Gamma and Impedance
Comments, and support for mixed reference impedances.
oModule.ExportNetworkData "offset=" & Chr(39) & "0in" & Chr(39) &
"", Array("Setup1:Sweep1"), 3, "C:/MyDocuments/Tee_TeeModel.s3p",
Array("All"), true, 50, "S", -1, 0, 15, true, true, false

ExportNetworkData( [
"",
# Empty string.
1,
#The number 1.
"Name",
# This is the full path of the file from which the solution is loaded.
"ExportFile",
# full path of file to export to
"variation",
Pyth-
on # Pick a particular variation. Leave blank if no variation
Syn-
["NAME:Frequencies"],
tax
# optional, if none defined all frequencies are used
["NAME:Options",
# Export options object
"DataTypes:=", ["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)

Solutions Module Script Commands 17-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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
])
import ScriptEnv
ScriptEnv.Initialize("Ansoft.ElectronicsDesktop")
oDesktop.RestoreWindow()
Pyth- oProject = oDesktop.SetActiveProject("package")
on
Exa- oDesign = oProject.SetActiveDesign("HFSSDesign1")
mple
oModule = oDesign.GetModule("Solutions")
oModule.ExportNetworkData("", ["Setup1:Sweep1"], 3, "C://Docu-
ments/package_HFSSDesign1.s4p", _
Array ('all'), True, 50, "S", -1, 0, 15, True, True, True)

ExportNMFData [HFSS]
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>

Solutions Module Script Commands 17-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Return Value: None


VB Example:
oModule.ExportNMFData Array("Setup1:Sweep1"), _
"c:\mydir\out.nmf", Array("all"), "", FALSE, 0

GetAdaptiveFreq
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>
VB Example:
set oModule = oDesign.GetModule("Solutions")
adaptfreq = oModule.GetAdaptiveFreq("Setup1")

GetAvailableVariations
The documented command is applicable for Q3D Extractor.
Returns the available variation for a solution.
Command: None
Syntax: GetAvailableVariations("<SetupName>:<SolnName>)
Return Value: An array of string object.
Parameters: <SetupName>
Type: <string>
The solve setup name.
<>
Type: <string>
The solution name ("Adaptive_1", … "Adaptive_N", "LastAdaptive").

Solutions Module Script Commands 17-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Example: Dim oVarArray


oVarArray = oModule.GetAvailableVariations
("Setup1 : LastAdaptive")

GetExcitationScaling
Use: Get source scaling parameters.
Syntax: GetExcitationScaling("<port name>", <mode/terminal/eigenmode index>)
Return Value: Returns a vector of strings representing source scaling parameters
Parameters: <portName>
Type: <string>
<mode/terminal/eigenmode index>
Type: <Int>
VB Example:
First terminal scaling from port "1":
data = oModule.GetExcitationScaling("1")
or data = oModule.GetExcitationScaling("1", 1)

First mode scaling from port "1":


data = oModule.GetExcitationScaling("1", 1)

Second eigenmode scaling (name is irrelevant):


data = oModule.GetExcitationScaling("unused", 2)

GetISolutionVersionID
Use: To obtain the solution ID to help track solution validity.
Syntax: GetISolutionVersionID(BSTR fullSolutionName)
Return Value: Returns a solution ID.
Parameters: None
VB Example:
versionID = oModule.GetISolutionVersionID(BSTR fullSolutionName)

Solutions Module Script Commands 17-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetSolveRangeInfo
Use: To determine the frequency range of a particular simulation setup. For fast sweeps and inter-
polating 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>
VB Example:
set oModule = oDesign.GetModule("Solutions")
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.
VB Example:
solution = oModule.GetValidISolutionList(True)

For Q3D Extractor, the command details are as follows:


Use: Returns a list of valid solutions for a design.
Command: None
Syntax: GetValidISolutionList
Return Value: An array of string object in the <SetupName>:<SolnName> format.
VB Example: Dim oVarArray
oVarArray = oModule. GetValidISolutionList

Solutions Module Script Commands 17-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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"
VB 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>, <matrixType> )
Return Value: Returns 1 or 0 ( 1= true, 0 = false)
Type: Boolean
Parameters: <SolutionName>
Type: <string>
Example: "Setup1:LastAdpative"
<DesignVariation>
Type: <string>
Example: "radius = 4in"
Type: <string>
Example: "C, CD RL"
<matrixType>

Solutions Module Script Commands 17-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Type: <string>
Example: "C, DCR, DCL, ACR, ACL"
VB Example:
set oModule = oDesign.GetModule("Solutions")
matrixExistACRL = oModule.HasMatrixData("Setup1:LastAdaptive",_
"thick = -7mm", "ACR, ACL")
MsgBox matrixExistACRL

HasMesh
To determine if a current mesh exists for a particular simulation setup, not including the initial mesh.
Syntax:HasMesh(<SetupName>, <DesignVariation>, <matTypeArg>)
Return Value: Returns 1 or 0 ( 1= true, 0 = false)
Type: Boolean
Parameters: <SetupName>
Type: <string>
<DesignVariation>
Type: <string>
<matTypeArg>
Type: <string>; should be one of the strings: "Cap", "DC", "AC".
VB Example:
set oModule = oDesign.GetModule("Solutions")
meshexist = oModule.HasMesh("Setup1","padrad=\'0.6mm\' viarad-
d=\'0.2mm\'", "Cap")

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

Solutions Module Script Commands 17-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters: <FileName>
Type: <string>
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 sup-
porting multiple solutions in one file is HFSS8.x format.
VB 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 com-
plex 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>

Solutions Module Script Commands 17-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Location of the source data.

<ImportName>
Type: <string>
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.
VB Example:
oModule.ImportTable "c:\mydir\mytable.tab", _

Solutions Module Script Commands 17-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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>)
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>
VB 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>, <ArrayOfMatch-
ingVariableValueStringsIncludingUits>)
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

Solutions Module Script Commands 17-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<ArrayOfMatchingVariableNames>
Type: String
<ArrayOfMatchingVariableValueStringsIncludingUnits>
Type: String
VB 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.
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
VB 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
VB Example:
list = oModule.ListVariations("Setup1 : LastAdaptive")

Solutions Module Script Commands 17-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

18 - Field Overlays Module Script Com-


mands
Field overlay commands should be executed by the Field Overlays module, which is called "Field-
sReporter" in scripts.
Set oModule = oDesign.GetModule("FieldsReporter")
oModule.CommandName <args>
AddAntennaOverlay
AddMarkerToPlot
CreateFieldPlot
DeleteFieldPlot
EditAntennaOverlay
GetFieldPlotName
HideAntennaParametersOverlay
ModifyFieldPlot
RenameFieldPlot
RenamePlotFolder
SetFieldPlotSettings
SetPlotFolderSettings
ShowAntennaParameterOverlay
UpdateAllFieldsPlots
UpdateQuantityFieldsPlots

AddAntennaOverlay
To save a table of antenna parameters for use an overlay on far field plots.
Command: Antenna Parameter Overlay
Syntax: AddAntennaOverlay Array("NAME:<OverlayName>",
Setup :="<SetupName>", Solution :="<SolutionName>", ["<array>"],> <"Intrinsic Variation[s]">,
"<AntennaParameters>",)
Return Value: None
Parameters: <OverlayName>
Text string with the overlay name

Field Overlays Module Script Commands 18-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<SetupName>
Text string for the Far Field Radiation setup name, for example "Infinite Sphere1"
<SolutionName>
Text string for the Solution Setup and Pass, for example, "Setup1 : LastAdaptive"
<array>
Text string if an array has been defined.
<Intrinsic Variation[s]>
Text string for variation definition, in the form"IntrinsicVariation:=", "<vari-
able>=<value>",
<Use Nominal Design>
Boolean, in the format "UseNominalDesign:=", [true | false],
<AntennaParameters>,
A list of each antenna parameter to display, in the form "Calculations:=" <antenna para-
meter>,
Antenna parameters can be MaxU, Peak Directivity, Peak Gain, Peak Realized Gain,
Radiated Power, Accepted Power, Incident Power, Radiation Efficiency, Front to Back
Ratio, and Decay Factor.
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("tune_coax_fed_patch")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("RadField")
oModule.AddAntennaOverlay Array("NAME:Antenna Parameter Overlay1",
"Setup:=", "Infinite Sphere1", "Solution:=", "Setup1 :

Field Overlays Module Script Commands 18-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

LastAdaptive", "IntrinsicVariation:=", "Freq=1.8GHz", "UseNom-


inalDesign:=", true, "Calculations:=", "Max U,Peak Directivity,Peak
Gain,Radiation
Efficiency,Front To Back Ratio")
Set oModule = oDesign.GetModule("FieldsReporter")
oModule.ShowAntennaParameterOverlay "Antenna Parameter Overlay3"

AddMarkerToPlot
Use: Adds a marker to a trace on a named field plot.
Command: None.
Syntax: AddMarkerToPlot , <location>, <fieldPlotName>
Return Value: None
Parameters: <Location>
Type: <Coord>
X.Y, and Z coordinates for the marker.
<FieldPlotName>
Type: <string>
Name of the field plot.
VB Example:
Set oModule = oDesign.GetModule("FieldsReporter")
oModule.AddMarkerToPlot(["0.290455877780914in", "-
0.616900205612183in", "1.77635683940025e-015in"], "Mag_E1")
oModule.AddMarkerToPlot(["-0.317279517650604in",
"1.22481322288513in", "0in"], "Mag_E1")
oModule.AddMarkerToPlot(["0.290455877780914in", "-
0.616900205612183in", "1.77635683940025e-015in"], "Mag_H1")
oModule.AddMarkerToPlot(["-0.317279517650604in",
"1.22481322288513in", "0in"], "Mag_H1")

CreateFieldPlot
Use: Creates a field/mesh plot "Field" or a visual ray trace ("VRT") plot.
Command: HFSS>Fields>Plot Fields><field_quantity>
Command: Maxwell3D or Maxwell2D>Fields>Fields><field_quantity>

Field Overlays Module Script Commands 18-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax: CreateFieldPlot <PlotParameterArray> ["Field" | "VRT"]


Return Value: None
Parameters: <PlotParameterArray> "Field"
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 and Maxwell require 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 include :
Mesh plots: "Mesh"
Field plots (HFSS) include: "Mag_E", "Mag_H", "Mag_Jvol", "Mag_Jsurf",

Field Overlays Module Script Commands 18-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"ComplexMag_E", "ComplexMag_H", "ComplexMag_Jvol",


"ComplexMag_Jsurf", "Vector_E", "Vector_H",
"Vector_Jvol", "Vector_Jsurf", "Vector_RealPoynting",
"Local_SAR", "Average_SAR"
Field plots (Maxwell) include: "Mag_E", "Mag_H", "E_Vector", "H_Vector",
"Mag_J", "J_Vector", "energy", "coEnergy", "appEnergy",
"Ohmic_Loss", "Total_Loss", "Hysteresis_Loss", "Dielectric_Loss",
"Temperature", "Volume_Force_Density", "Surface_Force_Density", "Demag_Coef"

PlotFolder
Name of the folder to which the plot should be added. Possible values
include: "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>,

Field Overlays Module Script Commands 18-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<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>
<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.

Field Overlays Module Script Commands 18-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<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>,
"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>,

Field Overlays Module Script Commands 18-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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>)
Example Field Plot:
oModule.CreateFieldPlot Array("NAME:Mag_E1", _
"SolutionName:=", "Setup1 : LastAdaptive", _
"QuantityName:=", "Mag_E", _
"PlotFolder:=", "E Field1", _
"UserSpecifyName:=", 0, _
"UserSpecifyFolder:=", 0, _

Field Overlays Module Script Commands 18-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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)))

Example Demag_Coef Field Plot:


oModule.CreateFieldPlot Array("NAME:Demag_Coef2", "Solu-
tionName:=", _
"Setup1 : Transient", "UserSpecifyName:=", 0, "User-
SpecifyFolder:=", 0, "QuantityName:=", _
"Demag_Coef", "PlotFolder:=", "Demag-Coef", "StreamlinePlot:=",
false, "AdjacentSidePlot:=", _
false, "FullModelPlot:=", false, "IntrinsicVar:=", "Time=" &
Chr(39) & "0s" & Chr(39) & "", "PlotGeomInfo:=", Array( _
1, "Volume", "ObjList", 1, "Mag2_0"), "FilterBoxes:=", Array(1,
"Mag1_0"), Array("NAME:PlotOnVolumeSettings", "PlotIsoSurface:=", _
true, "PointSize:=", 1, "Refinement:=", 0, "CloudSpacing:=",
0.5, "CloudMinSpacing:=", _
-1, "CloudMaxSpacing:=", -1, Array("NAME:Ar-
row3DSpacingSettings", "ArrowUniform:=", _
true, "ArrowSpacing:=", 0, "MinArrowSpacing:=", 0, "MaxAr-
rowSpacing:=", 0)), "EnableGaussianSmoothing:=", _
false), "Field"

Field Overlays Module Script Commands 18-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters: <PlotParameterArray> "VRT"


Array("NAME:<PlotName>",
"SolutionName:=", <string>,
"QuantityName:=", <string>,
"PlotFolder:=", <string>,
"UserSpecifyName:=", <int>,
"UserSpecifyFolder:=", <int>,
"IntrinsicVar:=", <string>,
"MaxFrequency:=", "<Number><FreqUnits>", _
"LaunchFrom:=", ["Launch from custom", |
"LaunchFromPointID:=",] _
18007, "RayDensity:=", <int>, _
"NumberBounces:=", <int>, _
"Multi-Bounce Ray Density Control:=", <Boolean>, _
"MBRD Max sub divisions:=", <int>, _
"ShootFilterType:=", ["All Rays" | _
"Rays by index", "start index:=", <int>, "stop index:=", <int>,
"index step:=", <int> |_
"Rays in box", "FilterBoxID:=", <objID> | _
"Single ray", "Ray elevation:=", "<real>deg", "Ray azimuth:=",
"<real>deg"
"),
"VRT"

Example VRT Plot:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule

Field Overlays Module Script Commands 18-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")


Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("abrams_1p5")
Set oDesign = oProject.SetActiveDesign("UseSbr")
Set oModule = oDesign.GetModule("FieldsReporter")
oModule.CreateFieldPlot Array("NAME:VRT_Plot1", _
"SolutionName:=", "Setup1 : LastAdaptive", _
"QuantityName:=", "QuantityName_SBR", _
"PlotFolder:=", "Visual Ray Trace SBR", "UserSpecifyName:=", 0,
"UserSpecifyFolder:=", 0, _
"IntrinsicVar:=", "", "MaxFrequency:=", "1GHz", "LaunchFrom:=",
"Launch from custom", _
"LaunchFromPointID:=", 18007, "RayDensity:=", 2, "NumberBounces:=",
5, _
"Multi-Bounce Ray Density Control:=", false, "MBRD Max sub divi-
sions:=", 2, "ShootFilterType:=", "All Rays"), "VRT"

VB 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, _

Field Overlays Module Script Commands 18-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"MapTransparency:=", true, _
"Transparency:=", 0, _
"ArrowUniform:=", true, _
"ArrowSpacing:=", 0.100000001490116, _
"GridColor:=", Array(255, 255, 255))), "Field"

Example Mesh Plot


Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("abrams_1p5")
Set oDesign = oProject.SetActiveDesign("UseSbr")
Set oModule = oDesign.GetModule("FieldsReporter")
oModule.CreateFieldPlot Array("NAME:Mesh1", "SolutionName:=",
"Setup1 : LastAdaptive", "QuantityName:=", _
"Mesh", "PlotFolder:=", "MeshPlots", "FieldType:=", "Fields", "User-
SpecifyName:=", _
0, "UserSpecifyFolder:=", 0, "StreamlinePlot:=", false, "Intrins-
icVar:=", _
"Freq=" & Chr(39) & "2GHz" & Chr(39) & " Phase=" & Chr(39) & "0deg"
& Chr(39) & "" & _
"", "PlotGeomInfo:=", Array(1, "Surface", "FacesList", 1, "10568"),
"FilterBoxes:=", Array( _
0), "Real time mode:=", true, Array("NAME:MeshSettings", "Scale
factor:=", 100, "Transparency:=", _

Field Overlays Module Script Commands 18-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

0, "Mesh type:=", "Shaded", "Surface only:=", true, "Add grid:=",


true, "Refinement:=", _
0, "Use geometry color:=", true, "Mesh line color:=", Array(0, 0,
255), "Filled color:=", Array( _
255, 255, 255))), "Field"

For Q3D Extractor and 2D Extractor, the command details are as follows:

Use: Creates a field/mesh plot.


Command: Q3D Extractor or 2D Extractor>Fields
Syntax: CreateFieldPlot <PlotParameterArray>
Return Value: None
Parameters: <PlotParameterArray>
Array("NAME:<PlotName>",
"SolutionName:=", <string>,
"QuantityName:=", <string>,
"PlotFolder:=", <string>,
"UserSpecifyName:=", <int>,
"UserSpecifyFolder:=", <int>,
"IntrinsicVar:=", <string>,
"PlotGeomInfo:=", <PlotGeomArray>,
"FilterBoxes:=", <FilterBoxArray>,
<PlotOnPointSettings>, <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"

Field Overlays Module Script Commands 18-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

HFSS requires a space on both sides of the ‘:’ character. Other-


wise, the plot is not be created.
QuantityName
Type of plot to create. Possible values are:
Mesh plots: "Mesh"
Q3D Field Plots:

Field type Plot quantity names


AC R/L Fields "SurfaceJac", "Mag_SurfaceJac"
DC R/L PEC Fields "SurfaceJdc", "Mag_SurfaceJdc"
DC R/L Fields "VolumeJdc", "Mag_VolumeJdc", "Phidc"
C Fields "SmoothQ", "ABS_Q"

2D Extractor Field Plots:

Field Plot quantity names


type
CG "Mag_Phi", "PhiAtPhase", "Mag_E", "VectorE", "Mag_Jcg", "VectorJcg" and "energyCG"
Fields
RL "Flux Lines", "VectorA", "Mag_B", "VectorB", "Mag_H", "VectorH", "Jrl", "VectorJrl",
Fields "energyRL", "coenergy", "appenergy" and "emloss"

PlotFolder
Name of the folder to which the plot should be added. Possible
values are: "Q", "ABS_Q", "JDC Vol", "Phi", "JDC Surf", and "JAC".
UserSpecifyName
0 if default name for plot is used, 1 otherwise.
This parameter is not essential. <PlotName> is respected regard-
less of whether this flag is set.
UserSpecifyFolder
0 if the default folder for plot is used, 1 otherwise.
This parameter is not essential. The specified PlotFolder is
respected regardless of whether this flag is set.
IntrinsicVar

Field Overlays Module Script Commands 18-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Formatted string that specifies the frequency and phase at which


to create 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 at the same time.
<GeomTypeData>
<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 GeomType values "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 object names used to restrict the plot range.
Array(<NumFilters>, <ObjName>, <ObjName>, ...)

Field Overlays Module Script Commands 18-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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>,
"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:=", <double>,
"ArrowUniform:=", <bool>
"ArrowSpacing:=", <double>
"GridColor:=", Array(<int>, <int>, <int>)

Field Overlays Module Script Commands 18-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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>)

DeleteFieldPlot
Use: Deletes one or more plots.
Command: HFSS>Fields>Delete Plot
Command: Maxwell3D or Maxwell2D>Fields>Delete Plot
Command: Q3D Extractor or 2D Extractor>Fields>Delete Plot
Syntax: DeleteFieldPlot <NameArray>
Return Value: None
Parameters: <NameArray>
Array of strings – the names of the plots to delete.
VB Example:
oModule.DeleteFieldPlot Array("Mag_E1", "Vector_E1")

EditAntennaOverlay
Use:Edit the properties in an existing antenna parameters overlay.
Command:None
Command:Antenna Parameter Overlay

Field Overlays Module Script Commands 18-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax:EditAntennaOverlay Array("NAME:<OverlayName>",
Setup :="<SetupName>", Solution :="<SolutionName>", ["<array>"],> <"Intrinsic Variation[s]">,
"<AntennaParameters>",)
Return Value:None
Parameters:<OverlayName>
Text string with the overlay name
<SetupName>
Text string for the Far Field Radiation setup name, for example "Infinite Sphere1"
<SolutionName>
Text string for the Solution Setup and Pass, for example, "Setup1 : LastAdaptive"
<array>
Text string if an array has been defined.
<Intrinsic Variation[s]>
Text string for variation definition, in the form "IntrinsicVariation:=", "<vari-
able>=<value>",
<Use Nominal Design>
Boolean, in the format "UseNominalDesign:=", [true | false],
<AntennaParameters>,
A list of each antenna parameter to display, in the form "Calculations:=" <antenna para-
meter>,
Antenna parameters can be MaxU, Peak Directivity, Peak Gain, Peak Realized Gain,
Radiated Power, Accepted Power, Incident Power, Radiation Efficiency, Front to Back
Ratio, and Decay Factor.
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()

Field Overlays Module Script Commands 18-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("tune_coax_fed_patch")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("RadField")
oModule.EditAntennaOverlay "Antenna Parameter Overlay2", Array
("NAME:Antenna Parameter Overlay2",
"Setup:=", "Infinite Sphere1", "Solution:=", "Setup1 : LastAd-
aptive", "IntrinsicVariation:=", "Freq=1.8GHz ", "UseNom-
inalDesign:=", false, "DesignVariation:=", "feed_pos=" & Chr(39) &
"10.8mm" & Chr(39) & "", "Calculations:=", "Max U,Peak Dir-
ectivity,Peak Gain,Peak Realized Gain,Accepted Power,Radiation Effi-
ciency,Front To Back Ratio")

GetFieldPlotNames
Gets the names of field overlay plots defined in a design.
Syntax: GetFieldPlotNames()
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("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject
Set oDesign = oProject.GetActiveDesign
Set oReportModule = oDesign.GetModule("ReportSetup")
Dim names

Field Overlays Module Script Commands 18-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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

For Q3D Extractor, the command details are as follows:

Gets the names of field overlay plots defined in a design.


Syntax: GetFieldPlotNames()
Return Value: Array of field plot names.
Parameters: None
Example: Set plotnames = oModule.GetFieldPlotNames()
For Each name in plotnames
Msgbox name
Next

HideAntennaParametersOverlay
Use:To hide a currently visible antenna parameters overlay.
Command:HFSS or HFSS-IE>Fields>Plot Fields>Radiation Field
Syntax:HideAntennaParameterOverlay
Return Value:None
Parameters:<name>
The name of the antenna parameters overlay.
VB Example:
Dim oAnsoftApp

Field Overlays Module Script Commands 18-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("tune_coax_fed_patch")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("FieldsReporter")
oModule.HideAntennaParameterOverlay "Antenna Parameter Overlay3"

ModifyFieldPlot
Use: Modifies a plot definition.
Command: HFSS>Fields>Modify Plot
Command: Maxwell3D or Maxwell2D>Fields>Modify Plot
Command: Q3D Extractor or 2D Extractor>Fields>Modify Plot
Syntax: ModifyFieldPlot <OriginalName> <PlotParameterArray>
Return Value: None
VB Example:
oModule.ModifyFieldPlot "Vector_E1",_
Array("NAME:Vector_E2", _
"SolutionName:=", "Setup1 : LastAdaptive", _
"QuantityName:=", "Vector_E", _
"PlotFolder:=", "E Field1", _
"UserSpecifyName:=", 0, _
"UserSpecifyFolder:=", 0, _
"IntrinsicVar:=","Freq='1GHz' Phase='30deg'", _

Field Overlays Module Script Commands 18-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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.
VB Example:
oModule.RenameFieldPlot "Vector_E1", "Vector_E2"

Field Overlays Module Script Commands 18-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.
VB Example:
oModule.RenamePlotFolder "E Field", "Surface Plots"

SetFieldPlotSettings
Sets plot attributes.
Command: HFSS>Fields>Modify Plot Attributes, under the Plots tab.
Command: Maxwell3D or Maxwell2D>Fields>Modify Plot Attributes, under the Plots tab.
Command: Q3D Extractor or 2D Extractor>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",

Field Overlays Module Script Commands 18-23


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<PlotOnPointsSettings>,
<PlotOnLineSettings>,
<PlotOnSurfaceSettings>,
<PlotOnVolumeSettings>)
See description of CreateFieldPlot command for details.
VB Example:
oModule.SetFieldPlotSettings "Mag_E2", _
Array("NAME:FieldsPlotItemSettings", _
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
Sets the attributes of all plots in the specified folder.
Command: HFSS>Fields>Modify Plot Attributes
Command: Maxwell3D or Maxwell2D>Fields>Modify Plot Attributes

Field Overlays Module Script Commands 18-24


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Command: Q3D Extractor or 2D Extractor>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>)

<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

Field Overlays Module Script Commands 18-25


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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>)

MarkerType
9: Sphere
10: Box
11: Tetrahedron
12: Octahedron
default: Sphere

<Arrow3DSettings>
Array("NAME:Arrow3DSettings",
"ArrowType:=", <int>,

Field Overlays Module Script Commands 18-26


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"ArrowMapSize:=", <bool>,
"ArrowMapColor:=", <bool>,
"ShowArrowTail:=", <bool>,
"ArrowSize:=", <double>)

ArrowType
0: Line
1: Cylinder
2: Umbrella
default: Line
VB 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, _
"IntrinsicMin:=", 9.34379863739014, _
"IntrinsicMax:=", 13683.755859375), _
Array("NAME:Marker3DSettings", _
"MarkerType:=", 0, _
"MarkerMapSize:=", true, _

Field Overlays Module Script Commands 18-27


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"MarkerMapColor:=", false, _
"MarkerSize:=", 0.25), _
Array("NAME:Arrow3DSettings", _
"ArrowType:=", 1, _
"ArrowMapSize:=", true, _
"ArrowMapColor:=", true, _
"ShowArrowTail:=", true, _
"ArrowSize:=", 0.25))

ShowAntennaParameterOverlay
Use: To display an existing antenna parameters overlay as a table on a far field plot.
Command: HFSS or HFSS-IE>Fields>Plot>Radiation FIelds
Syntax: ShowAntennaParamedterOverlay <name>
Return Value: None
Parameters: <name>
The name of the antenna parameters overlay.
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("tune_coax_fed_patch")
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oModule = oDesign.GetModule("RadField")

Field Overlays Module Script Commands 18-28


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModule.AddAntennaOverlay Array("NAME:Antenna Parameter Overlay1",


"Setup:=", "Infinite Sphere1", "Solution:=", "Setup1 : LastAd-
aptive", "IntrinsicVariation:=", "Freq=1.8GHz ", "UseNom-
inalDesign:=", true, "Calculations:=", "Max U,Peak Directivity,Peak
Gain,Radiation
Efficiency,Front To Back Ratio")
Set oModule = oDesign.GetModule("FieldsReporter")
oModule.ShowAntennaParameterOverlay "Antenna Parameter Overlay3"

UpdateAllFieldsPlots
Updates the All Fields Plots.
Command: None.
Syntax: UpdateAllFieldsPlots ()
Return Value: None
Parameters: None
VB Example:
Set oModule = oDesign.GetModule("FieldsReporter")
oModule.UpdateAllFieldsPlots()

UpdateQuantityFieldsPlots
Use: Updates the Quantity Fields Plots.
Command: None.
Syntax: UpdateQuantityFieldsPlots (<quantity_folder_name>)
Return Value: None
Parameters: <quantity_folder_name>
Type: <string>
Folder containing the plotted quantities
VB Example:
Set oModule = oDesign.GetModule("FieldsReporter")
oModule.UpdateQuantityFieldsPlots("fldplt")

Field Overlays Module Script Commands 18-29


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

18-30
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

19 - 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
EnterQty
EnterScalar
EnterScalarFunc
EnterSurf
EnterVector
EnterVectorFunc
EnterVol

Fields Calculator Script Commands 19-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ExportOnGrid
ExportToFile
GetTopEntryValue
LoadNamedExpressions
SaveNamedExpressions

AddNamedExpression
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>
VB Example:
oModule.AddNamedExpression "Mag_JxE", "Fields"

AddNamedExpr
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>
VB Example:

Fields Calculator Script Commands 19-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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, +

CalcRead(deprecated)
Use:Reads a file that is written out by the CalcWrite command, and puts the result into a calculator
numeric.
Syntax:CalcRead <FileName> <SolutionName> <VariablesArray>
Return Value:None
Parameters:<FileName>
Type: <string>
<SolutionName>
Type: <string>
<VariablesArray>
Array of variable name and value pairs.
oModule.CalcRead _
"c:\example.reg" "Setup1: LastAdaptive",_
Array ("Freq:=", "10GHz", "Phase:=", "0deg")

CalculatorRead
Use: Gets a register file and applies it to the calculator stack.
Command: Click Read
Syntax: CalculatorRead <InputFilePath>, <SolutionName>, <FieldType>, <VariablesArray>

Fields Calculator Script Commands 19-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.
VB Example:
oModule.CalculatorRead "c:\test.reg", _
"Setup1 : LastAdaptive", "Fields", _
Array("Freq:=", "1GHz", "Phase:=", "0deg")
For Q3D Extractor, the command example is as follows:
VB Example: oModule.CalculatorRead "C:\Ansoft\smoothedtemper.fld",
"Setup1 : LastAdaptive", "Fields", Array("$conductivity:=",
"50000000")

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.
VB Example:
oModule.CalcStack "push"

Fields Calculator Script Commands 19-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.
VB Example:
oModule.CalculatorWrite "c:\test.reg", _
Array("Solution:=", "Setup1 : LastAdaptive"), _
Array("Freq:=", "1GHz", "Phase:=", "0deg")

For Q3D Extractor, the command example is as follows:


VB Example: oModule.CalculatorWrite "C:\Ansoft\smoothedTemp.fld",
Array("Solution:=", "Setup1 : LastAdaptive"), Array("$con-
ductivity:=", "50000000")

ChangeGeomSettings
Use: Changes the line discretization setting.
Command: Geom Settings
Syntax: ChangeGeomSettings <int>
Return Value: None
Parameters: The line discretization setting.

Fields Calculator Script Commands 19-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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>

<VariablesArray>
Array of variable name, value pairs.
VB 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".
VB Example:
oModule.ClcMaterial "Permeability (mu)" "mult"

Fields Calculator Script Commands 19-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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
Parameters: <Name>
Type: <string>
The name of the expression to be copied to the top of the stack.
VB 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.
VB Example:
oModule.DeleteNamedExpr "Mag_JxE"

Fields Calculator Script Commands 19-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.
VB Example:
oModule.EnterComplex "1 + 2 j"

EnterComplexVector
Use: Enters a complex vector onto the stack.
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.

Fields Calculator Script Commands 19-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB 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.
VB 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.
VB Example:
oModule.EnterPoint "Point1"

EnterQty
Use: Enters a field quantity.

Fields Calculator Script Commands 19-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.
VB 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.
VB Example:
oModule.EnterScalarFunc "Phase"

Fields Calculator Script Commands 19-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.
VB 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.
VB Example:
oModule.EnterVector Array (1.0, 1.0, 1.0)

Fields Calculator Script Commands 19-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

EnterVectorFunc
Use: Enters a vector function.
Command: Click Function and then select Vector.
Syntax: EnterVectorFunc Array(<XVarName>, <YVarName>,
<ZVarName>)
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 func-
tion on the stack.
VB 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.
VB 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.

Fields Calculator Script Commands 19-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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>
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.
VB Example:
oModule.ExportOnGrid "J:\TestSuite\EdgeLossDensity\aaa.fld", Array(
"0mm", "0deg", "-25mm"),
Array("20mm", "90deg", "125mm"),
Array("10mm", "45deg", "50mm"),
"Setup1 : LastAdaptive",

Fields Calculator Script Commands 19-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("Freq:=", "10000Hz", "Phase:=", "0deg"),


true, "Cylindrical",
Array("0mm", "0mm", "0mm")

For Q3D Extractor the command details are as follows:


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>
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 X, Y, and Z components of the grid.
VB Example: oModule.ExportOnGrid
"C:`3D Extractor6OutputFiles\GridExport.reg",_
Array("1", "1", "1"),_
Array("4", "4", "4"),_
Array("2", "2", "2")

ExportToFile [Fields Calculator]


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>

Fields Calculator Script Commands 19-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name of the output file.

<PtsFile>
Type: <string>
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.
VB 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>

Fields Calculator Script Commands 19-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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>
Type: Array<string, string,...>
Array of strings containing the names of expression definitions to load from the file.
VB 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.

Fields Calculator Script Commands 19-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Example:
oModule.SaveNamedExpressions "C:\Ansoft\PersonalLib\smth.clc", Array
("smoothedtemp"), true

Fields Calculator Script Commands 19-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

19-18
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

20 - Radiation Module Script Commands


Radiation field commands should be executed by the RadField module.
Set oModule = oDesign.GetModule("RadField")
oModule.CommandName <args>
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.
The topics for this section include:
General Commands Recognized by the Radiation Module
Script Commands for Creating and Modifying Radiation Setups
Script Commands for Modifying Antenna Array Setups
Script Commands for Exporting Antenna Parameters and Max Field Parameters

General Commands Recognized by the Radiation Module


DeleteFarFieldSetup
DeleteNearFieldSetup
EditRadiatedPowerCalculationMethod
GetChildObject [Radiation]
GetChildNames [Radiation]
GetChildTypes [Radiation]
GetPropNames [Radiation]
GetPropValue [Radiation]

Radiation Module Script Commands 20-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetSetupNames
RenameSetup
SetPropValue [Radiation]
DeleteFarFieldSetup
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.
VB Example:
oModule.DeleteFarFieldSetup Array("Infinite Sphere1")

DeleteNearFieldSetup
Deletes an existing near-field line radiation setup.

UI Access Project Manager > Radiation. Right-click a setup and click Delete.

Name Type Description


Parameters
<NameArray> Array List of fields for deletion.

Return Value None.

Python Syntax DeleteNearFieldSetup(NameArray)


oModule = oDesign.GetModule("RadField")
Python
Example arr = oModule.DeleteNearFieldSetup(['Line1',
'Sphere1', 'Box2', 'Rectangle1'])

VB Syntax DeleteNearFieldSetup(NameArray)
oModule.DeleteNearFieldSetup Array("Line1",
VB Example
"Sphere1", "Box2", "Rectangle1")

Radiation Module Script Commands 20-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

EditRadiatedPowerCalculationMethod
Use: Select the method used to calculate radiated power.
Syntax: EditRadiatedPowerCalculationMethod(<PowerCalculationMethod>)
Return Value: None
Parameters: <PowerCalculationMethod>
Type: <string>
One of: "Auto", "Raidation Surface Integral", or "Far Field Integral">
VB Example:
oModule = oDesign.GetModule("RadField")
oModule.EditRadiatedPowerCalculationMethod("Auto")
oModule.EditRadiatedPowerCalculationMethod("Radiation Surface Integ-
ral")
oModule.EditRadiatedPowerCalculationMethod("Far Field Integral")

Python Syn- EditRadiatedPowerCalculationMethod(<RadiationCalculationMethod>)


tax

oModule = oDesign.GetModule("RadField")
Python
Example oModule.EditRadiatedPowerCalculationMethod("Radiation
Surface Integral")

GetChildNames [Radiation]
Use: Gets setupup names .
Syntax: GetChildNames()
Return Value: All setup names.
Parameters: Optional, this parameter is ignored.

Python Syn- GetChildNames ()


tax

Python GetChildNames() //return all setup names.


Example

GetChildObject [Radiation]
Gets a Setup Object of the Radiation module.

Radiation Module Script Commands 20-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- GetChildObject()


tax

oOverlay= oRadModule.GetChildObject('Antenna Parameter


Python Overlay1')
Example
oSphere = oRadModule.GetChildObject('Infinite Sphere1')

GetChildTypes [Radiation]
Use: Gets child types of queried Radiation module object.
Syntax: GetChildTypes()
Return Value: Returns empty array.

Python Syn- GetChildTypes ()


tax

oRad = oDesign.GetChildObject(“RadField”)
Python
oRadModule.GetChildTypes()
Example

GetPropNames [Radiation]
Use: Radiation module does not have its own property, this function always returns empty array.
Syntax: GetPropNames(bIncludeReadOnly)
Return Value: Returns empty set.
Parameters: bIncludeReadOnly—optional, default to True.

Python Syn- GetPropNames ()


tax

oRadModule.GetPropNames()
Python
oRadModule.GetPropNames(True)
Example
oRadModule.GetPropNames(False)

GetPropValue [Radiation]
Get the property value for a setup object.

UI Access NA

Radiation Module Script Commands 20-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name Type Description


Parameters PropPath Value text string A Property path begin with a setup name.
See property path discussion here.

Return Value The property value.

Python Syn- GetPropValue(propPath)


tax

Python oRadModule.GetPropValue('Line1/Num Points') //Get the


Example Line1 setups’ “Num Points” property value.

GetSetupNames
Use: Gets the names of far field and near field radiation setups in a design.
Syntax: GetSetupNames(<RadiationType>)
Return Value: Array of setup names.
Parameters: <RadiationType>
Type: <string>
For example: "Sphere"
VB 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>

Radiation Module Script Commands 20-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<NewName>
Type: <string>
VB Example:
oModule.RenameSetup "Sphere1", "MyNearSphere"

SetPropValue [Radiation]
Sets the property value for the active Radiation property object.

UI Access Edit Properties on ProjectTree objects

Name Type Description


propPath text string A Property path begin with a setup name.
Parameters
See property path discussion here.
Value Text String, New value data type is depending on the prop-
Number, or erty type.
Boolean

Return Value True if the property is found and the new value is valid. Otherwise return False.

Python Syn- SetPropValue(propPath, value)


tax

oRadModule.SetPropValue('Line1/Num Points', 100) ; Set


Python the Line1 setups’ “Num Points” property to 100.
Example

VB Syntax SetPropValue(propPath, value)


VB Example SetPropValue(“Color/r”,111)

Script Commands for Creating and Modifying Radiation


Setups
EditBoxSetup
EditFarFieldSphereSetup
EditNearFieldLineSetup
EditNearFieldRectangleSetup

Radiation Module Script Commands 20-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

EditNearFieldSphereSetup
InsertBoxSetup
InsertFarFieldSphereSetup
InsertNearFieldLineSetup
InsertNearFieldRectangleSetup
InsertNearFieldSphereSetup
EditBoxSetup
Edits a near-field box radiation setup.

UI Access Project Manager > Radiation > Box. Double-click and edit information.

Name Type Description


<boxParams> Structured Array Array("NAME:<SetupName>",
"UseCus-
tomRadiationSurface:=",
<bool>,
"Cus-
tomRadiationSurface:=",
<FaceListName>,
"Length:=", <string>,
"Width:=", <string>,
Para-
meters "LengthSamples:=", <int>,
"WidthSamples:=", <int>,
"CoordSystem:=", <CSname>

"Height:=", <string>,
"HeightSamples:=", <int>)
For UseCustomRadiationSurface para-
meter, provide value if True. If False, radi-
ation boundary/PML boundaries will be
used as radiation surfaces.

Return None.
Value

Python Syntax EditBoxSetup(boxParams)

Radiation Module Script Commands 20-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModule = oDesign.GetModule("RadField")
arr = oModule.EditBoxSetup(['NAME:MyBox', 'UseCus-
Python tomRadiationSurface:=', False, 'Length:=', '20mm',
Example 'Width:=', '20mm', 'LengthSamples:=', 21,
'WidthSamples:=', 21, 'CoordSystem:=', 'Global',
'Height:=', '20mm', 'HeightSamples:=', 21])

VB Syntax EditBoxSetup(boxParams)
oModule.EditBoxSetup Array("NAME:MyBox", _
"UseCustomRadiationSurface:=", false, _
"Length:=", "20mm", _
"Width:=", "20mm", _
VB Example "LengthSamples:=", 21 _
"WidthSamples:=", 21 _
"CoordSystem:=", "Global" _
"Height:=", "20mm" _
"HeightSamples:=", 21, _

EditInfiniteSphereSetup
Modifies an existing far-field infinite sphere setup, or right click on Infinite Sphere under Radiation
in the Project tree and select Properties...

Double-click a radiation setup in the project tree to modify its settings, or right click
UI Access
on Infinite Sphere under Radiation in the Project tree and select Properties...

Name Type Description


<FarFieldSphereName> String Name of the Far
Field Sphere Radi-
ation Setup found in
the project
Parameters Array<Parameters>
"UseCustomRadiationSurface:=" Boolean
"ThetaStart:=" <int><unit>
"ThetaStop:=" <int><unit>
"ThetaStep:=" <int><unit>
"PhiStart:=" <int><unit>

Radiation Module Script Commands 20-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"PhiStop:=" <int><unit>
"PhiStep:=" <int><unit>
"UseLocalCS:=" Boolean Whether to use local
CS

Return None
Value

Python EditInfiniteSphereSetup "<name>, Array(<parameterArray>)


Syntax

oModule = oDesign.GetModule("RadField")
oModule.EditInfiniteSphereSetup("Infinite Sphere1",
[
"NAME:Infinite Sphere1",
"UseCustomRadiationSurface:=", False,
"ThetaStart:=" , "0deg",
Python
"ThetaStop:=" , "180deg",
Example
"ThetaStep:=" , "3deg",
"PhiStart:=" , "-180deg",
"PhiStop:=" , "180deg",
"PhiStep:=" , "3deg",
"UseLocalCS:=" , False
])

VB Syntax EditInfiniteSphereSetup "<name>, Array(<parameterArray>)


Set oModule = oDesign.GetModule("RadField")
oModule.EditInfiniteSphereSetup "Infinite Sphere1",
VB Example Array("NAME:Infinite Sphere1",_ "UseCus-
tomRadiationSurface:=", false, "ThetaStart:=", "0deg",_
"ThetaStop:=", "180deg", "ThetaStep:=", "2deg",
"PhiStart:=", _

Radiation Module Script Commands 20-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"-180deg", "PhiStop:=", "180deg", "PhiStep:=", "2deg",


"UseLocalCS:=", false)

EditNearFieldLineSetup
Edits a near-field line radiation setup.

UI Access Project Manager > Radiation > Line. Double-click and edit a line.

Name Type Description


<lineParams> Structured Array Array("NAME:<SetupName>",
"UseCus-
tomRadiationSurface:=",
<bool>,
"Cus-
tomRadiationSurface:=",
<FaceListName>,
Para-
meters "Line:=", <PolyLineName>,
"NumPts:=", <int>)
For PolyLineName, use polyline name in
the history tree.
For UseCustomRadiationSurface para-
meter, provide value if True. If False, radi-
ation boundary/PML boundaries will be
used as radiation surfaces.

Return None.
Value

Python Syntax EditNearFieldLineSetup(lineParams)


oModule = oDesign.GetModule("RadField")
Python arr = oModule.EditNearFieldLineSetup(['NAME:MyLine',
Example 'UseCustomRadiationSurface:=', False, 'Line:=',
'Polyline1', 'NumPts:=', '100'])

VB Syntax EditNearFIeldLineSetup(lineParams)
oModule.EditNearFieldLineSetup Array("NAME:MyLine",
VB Example
_

Radiation Module Script Commands 20-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"UseCustomRadiationSurface:=", false, _
"Line:=", "Polyline1", _
"NumPts:=", "100")

EditNearFieldRectangleSetup
Edits a near-field rectangle radiation setup.

UI Access Project Manager > Radiation > Rectangle. Double-click and edit a rectangle.

Name Type Description


<rectParams> Structured Array Array("NAME:<SetupName>",
"UseCus-
tomRadiationSurface:=",
<bool>,
"Cus-
tomRadiationSurface:=",
<FaceListName>,
"Length:=", <length>,
Para-
meters "Width:=", <width>,
"LengthSamples:=", <int>
"WidthSamples:=", <int>
"CoordSystem:=",
<CSname>)
For UseCustomRadiationSurface para-
meter, provide value if True. If False, radi-
ation boundary/PML boundaries will be
used as radiation surfaces.

Return None.
Value

Python Syn- EditNearFieldRectangleSetup(rectParams)


tax

oModule = oDesign.GetModule("RadField")
arr = oModule.EditNearFieldRectangleSetup(['NAME:MyRect-
Python angle', 'UseCustomRadiationSurface:=', False,
Example 'Length:=', '20mm', 'Width:=', '20mm',
'LengthSamples:=', 41, 'WidthSamples:=', 41, 'CoordSys-
tem:=', 'RelativeCS1'])

Radiation Module Script Commands 20-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Syntax EditNearFIeldRectangleSetup(rectParams)
oModule.EditNearFieldRectangleSetup Array
("NAME:MyRectangle", _
"UseCustomRadiationSurface:=", false, _
"Length:=", "20mm", _
VB Example
"Width:=", "20mm", _
"LengthSamples:=", 41 _
"WidthSamples:=", 41 _
"CoordSystem:=", "RelativeCS1")

EditNearFieldSphereSetup
Edits a near-field sphere radiation setup.

UI Access Project Manager > Radiation > Sphere. Double-click and edit a sphere.

Name Type Description


<sphereParams> Structured Array Array("NAME:<SetupName>",
"UseCus-
tomRadiationSurface:=",
<bool>,
"Cus-
tomRadiationSurface:=",
<FaceListName>,
"Radius:=", <value>,
Para- "ThetaStart:=", <value>,
meters
"ThetaStop:=", <value>,
"ThetaStep:=", <value>,
"PhiStart:=", <value>,
"PhiStop:=", <value>,
"PhiStep:=", <value>,
"UseLocalCS:=", <bool>,
"CoordSystem:=",
<CSName>)

Radiation Module Script Commands 20-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

For CustomRadiationSurface parameter,


provide value if True. If False, radiation
boundary/PML boundaries will be used as
radiation surfaces.
For UseLocalCS parameter, provide value
if True. If False, global coordinate system
will be used.

Return None.
Value

Python Syntax EditNearFieldSphereSetup(sphereParams)


oModule = oDesign.GetModule("RadField")
arr = oModule.EditNearFieldSphereSetup
(['NAME:MySphere', 'UseCustomRadiationSurface:=',
Python True, 'CustomRadiationSurface:=', 'FaceList1', 'Thet-
Example aStart:=', '0deg', 'ThetaStop:=', '180deg', 'Thet-
aStep:=', '10deg', 'PhiStart:=', '0deg', 'PhiStop:=',
'360deg', 'PhiStep:=', '10deg', 'UseLocalCS:=', True,
'CoordSystem:=', 'FaceCS1'])

VB Syntax EditNearFIeldSphereSetup(sphereParams)
oModule.EditNearFieldSphereSetup _
Array("NAME:MySphere", _
"UseCustomRadiationSurface:=", true, _
"CustomRadiationSurface:=", "FaceList1", _
"ThetaStart:=", "0deg", "ThetaStop:=", "180deg",
VB Example
_
"ThetaStep:=", "10deg", "PhiStart:=", "0deg", _
"PhiStop:=", "360deg", "PhiStep:=", "10deg", _
"UseLocalCS:=", true, _
"CoordSystem:=", "FaceCS1")

InsertBoxSetup
Inserts a near-field box radiation setup.

UI Access HFSS > Radiation > Insert Near Field Setup > Box.

Radiation Module Script Commands 20-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Name Type Description


<boxParams> Structured Array Array("NAME:<SetupName>",
"UseCus-
tomRadiationSurface:=",
<bool>,
"Cus-
tomRadiationSurface:=",
<FaceListName>,
"Length:=", <string>,
"Width:=", <string>,
Para-
meters "LengthSamples:=", <int>,
"WidthSamples:=", <int>,
"CoordSystem:=", <CSname>

"Height:=", <string>,
"HeightSamples:=", <int>)
For UseCustomRadiationSurface para-
meter, provide value if True. If False, radi-
ation boundary/PML boundaries will be
used as radiation surfaces.

Return None.
Value

Python Syntax InsertBoxSetup(boxParams)


oModule = oDesign.GetModule("RadField")
arr = oModule.InsertBoxSetup(['NAME:MyBox', 'UseCus-
Python tomRadiationSurface:=', False, 'Length:=', '20mm',
Example 'Width:=', '20mm', 'LengthSamples:=', 21,
'WidthSamples:=', 21, 'CoordSystem:=', 'Global',
'Height:=', '20mm', 'HeightSamples:=', 21])

VB Syntax InsertBoxSetup(boxParams)
oModule.InsertBoxSetup Array("NAME:MyBox", _
VB Example
"UseCustomRadiationSurface:=", false, _

Radiation Module Script Commands 20-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Length:=", "20mm", _
"Width:=", "20mm", _
"LengthSamples:=", 21 _
"WidthSamples:=", 21 _
"CoordSystem:=", "Global" _
"Height:=", "20mm" _
"HeightSamples:=", 21, _

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>
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

Radiation Module Script Commands 20-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

If true, provide CoordSystem parameter.


If false, global coordinate system will be used.
VB 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
Inserts a near-field line radiation setup.

UI Access HFSS > Radiation > Insert Near Field Setup > Line.

Name Type Description


<lineParams> Structured Array Array("NAME:<SetupName>",
"UseCus-
tomRadiationSurface:=",
<bool>,
"Cus-
tomRadiationSurface:=",
<FaceListName>,
Para-
meters "Line:=", <PolyLineName>,
"NumPts:=", <int>)
For PolyLineName, use polyline name in
the history tree.
For UseCustomRadiationSurface para-
meter, provide value if True. If False, radi-
ation boundary/PML boundaries will be
used as radiation surfaces.

Radiation Module Script Commands 20-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Return None.
Value

Python Syntax InsertNearFieldLineSetup(lineParams)


oModule = oDesign.GetModule("RadField")
Python arr = oModule.InsertNearFieldLineSetup(['NAME:MyLine',
Example 'UseCustomRadiationSurface:=', False, 'Line:=',
'Polyline1', 'NumPts:=', '100'])

VB Syntax InsertNearFIeldLineSetup(lineParams)
oModule.InsertNearFieldLineSetup Array
("NAME:MyLine", _

VB Example "UseCustomRadiationSurface:=", false, _


"Line:=", "Polyline1", _
"NumPts:=", "100")

InsertNearFieldRectangleSetup
Inserts a near-field rectangle radiation setup.

UI Access HFSS > Radiation > Insert Near Field Setup > Rectangle.

Name Type Description


<rectParams> Structured Array Array("NAME:<SetupName>",
"UseCus-
tomRadiationSurface:=",
<bool>,
"Cus-
tomRadiationSurface:=",
Para- <FaceListName>,
meters
"Length:=", <length>,
"Width:=", <width>,
"LengthSamples:=", <int>
"WidthSamples:=", <int>
"CoordSystem:=",
<CSname>)

Radiation Module Script Commands 20-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

For UseCustomRadiationSurface para-


meter, provide value if True. If False, radi-
ation boundary/PML boundaries will be
used as radiation surfaces.

Return None.
Value

Python Syn- InsertNearFieldRectangleSetup(rectParams)


tax

oModule = oDesign.GetModule("RadField")
arr = oModule.InsertNearFieldRectangleSetup
Python (['NAME:MyRectangle', 'UseCustomRadiationSurface:=',
Example False, 'Length:=', '20mm', 'Width:=', '20mm',
'LengthSamples:=', 41, 'WidthSamples:=', 41, 'CoordSys-
tem:=', 'RelativeCS1'])

VB Syntax InsertNearFIeldRectangleSetup(rectParams)
oModule.InsertNearFieldRectangleSetup Array
("NAME:MyRectangle", _
"UseCustomRadiationSurface:=", false, _
"Length:=", "20mm", _
VB Example
"Width:=", "20mm", _
"LengthSamples:=", 41 _
"WidthSamples:=", 41 _
"CoordSystem:=", "RelativeCS1")

InsertNearFieldSphereSetup
Inserts a near-field sphere radiation setup.

UI Access HFSS > Radiation > Insert Near Field Setup > Sphere.

Name Type Description


<sphereParams> Structured Array Array("NAME:<SetupName>",
Para-
meters "UseCus-
tomRadiationSurface:=",
<bool>,

Radiation Module Script Commands 20-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Cus-
tomRadiationSurface:=",
<FaceListName>,
"Radius:=", <value>,
"ThetaStart:=", <value>,
"ThetaStop:=", <value>,
"ThetaStep:=", <value>,
"PhiStart:=", <value>,
"PhiStop:=", <value>,
"PhiStep:=", <value>,
"UseLocalCS:=", <bool>,
"CoordSystem:=",
<CSName>)
For CustomRadiationSurface parameter,
provide value if True. If False, radiation
boundary/PML boundaries will be used as
radiation surfaces.
For UseLocalCS parameter, provide value
if True. If False, global coordinate system
will be used.

Return None.
Value

Python Syn- InsertNearFieldSphereSetup(sphereParams)


tax

oModule = oDesign.GetModule("RadField")
arr = oModule.InsertNearFieldSphereSetup
(['NAME:MySphere', 'UseCustomRadiationSurface:=', True,
Python 'CustomRadiationSurface:=', 'FaceList1', 'Thet-
Example aStart:=', '0deg', 'ThetaStop:=', '180deg', 'Thet-
aStep:=', '10deg', 'PhiStart:=', '0deg', 'PhiStop:=',
'360deg', 'PhiStep:=', '10deg', 'UseLocalCS:=', True,
'CoordSystem:=', 'FaceCS1'])

VB Syntax InsertNearFIeldSphereSetup(sphereParams)

Radiation Module Script Commands 20-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oModule.InsertNearFieldSphereSetup _
Array("NAME:MySphere", _
"UseCustomRadiationSurface:=", true, _
"CustomRadiationSurface:=", "FaceList1", _
"ThetaStart:=", "0deg", "ThetaStop:=", "180deg",
VB Example
_
"ThetaStep:=", "10deg", "PhiStart:=", "0deg", _
"PhiStop:=", "360deg", "PhiStep:=", "10deg", _
"UseLocalCS:=", true, _
"CoordSystem:=", "FaceCS1")

Script Commands for Modifying Antenna Array Setups


EditAntennaArraySetup
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",
"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>

Radiation Module Script Commands 20-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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>)

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.

Radiation Module Script Commands 20-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<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"
VB Example: Using the "NoArray" option:
oModule.EditAntennaArraySetup _
Array("NAME:ArraySetupInfo", "UseOption:=", "NoArray")
VB Example: Using the "RegularArray" option:
oModule.EditAntennaArraySetup _
Array("NAME:ArraySetupInfo",_
"UseOption:=", "RegularArray", _

Radiation Module Script Commands 20-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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"))
VB 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 20-23


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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 quant-
ities 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-
h=5mm"
VB Example:
oModule.ExportRadiationParametersToFile _
Array("ExportFileName:=", _
"C:\projects\exportantparams.txt",_
"SetupName:=", "Infinite Sphere1", _

Radiation Module Script Commands 20-24


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"IntrinsicVariationKey:=", "Freq='10GHz'", _
"DesignVariationKey:=", "",
"SolutionName:=", "LastAdaptive")

Radiation Module Script Commands 20-25


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

20-26
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

21 - User Defined Solutions Commands


User Defined Solution commands should be executed by the "UserDefinedSolutionModule" mod-
ule.

Set oDesign = oProject.SetActiveDesign("TestDesign1")


Set oModule =
oDesign.GetModule("UserDefinedSolutionModule")

CreateUserDefinedSolution
DeleteUserDefinedSolutions
EditUserDefinedSolution

CreateUserDefinedSolution
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>, <Plu-
ginFileRelativePathName>, <PropertyValuesArray>, <ProbeSelectionArray>, <Dynam-
icProbesArray>
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

User Defined Solutions Commands 21-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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>
Type: Array of strings representing how a single probe is defined by a trace. The array
contains the following 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.

User Defined Solutions Commands 21-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<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 dynamic-
probes.
VB Example:
oModule.CreateUserDefinedSolution "User Defined Solution 1", _
"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()))

DeleteUserDefinedSolutions
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.

User Defined Solutions Commands 21-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Example: Example:
oModule.DeleteUserDefinedSolutions Array("Solution1", "Solution2")

Python DeleteUserDefinedSolutions (<UserDefinedSolutionNames>)


Syntax

Python oModule.DeleteUserDefinedSolutions(["Solution1", "Solu-


Exampl- tion2"])
e

EditUserDefinedSolution
Updates an existing user defined solution
Command: Command: 'Edit' button in the User Defined Solutions dialog
Syntax: Syntax: EditUserDefinedSolution <ExistingSolutionName>, <NewSolutionName>, <Plu-
ginFileLocation>, <PluginFileRelativePathName>, <PropertyValuesArray>, <ProbeSelec-
tionArray>, <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>
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>

User Defined Solutions Commands 21-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

See CreateUserDefinedSolution for more information.


<DynamicProbesArray>
See CreateUserDefinedSolution for more information.
VB 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()))

EditUserDefinedSolution (<ExistingSolutionName>, <NewSolutionName>, <Plu-


Python
Syntax
ginFileLocation>, <PluginFileRelativePathName>, <PropertyValuesArray>,
<ProbeSelectionArray>, <DynamicProbesArray>)
oModule.EditUserDefinedSolution (
"User Defined Solution 1", "User Defined Solution 2",
"SysLib", "Example", ["multiplication_factor:=",

"1.2"],[["Modal Solution Data", "Probe 1",


Python "Setup1 : LastAdaptive", [], ["Freq:=",
Exampl-
e
["All"]], ["Probe Component:=", ["dB(S(1,1))"]],
[]], ["Modal Solution Data", "Probe 2",
"Setup1 : LastAdaptive", [], ["Freq:=",
["All"]], ["Probe Component:=",
["mag(S(1,1))"]], []]], [["Modal _

User Defined Solutions Commands 21-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Solution Data", "Dynamic Probe 1", "Setup1 : LastAdaptive",


[], ["Freq:=", ["All"]],
["Probe Component:=", ["Freq"]], []]])

User Defined Solutions Commands 21-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

22 - Network Data Explorer Script Com-


mands
The definition manager controls the use of Network Data Explorer for scripts.
Set oProject = oDesktop.SetActiveProject("Project1")
Set oDefinitionManager = oProject.GetDefinitionManager()

Network Data Explorer Manager Script Commands


The Network Data Explorer manager provides access to scripting for Network Data Explorer. The
manager object is accessed via the definition manager.
Set oDefinitionManager = oProject.GetDefinitionManager()
Set oNdExplorerManager = oDefinitionManager.GetManager("NdExplorer")

The Network Data Explorer manager script commands are listed below.
ExportFullWaveSpice [Network Data Explorer]
ExportNetworkData [Network Data Explorer]
ExportNMFData [Network Data Explorer]

ExportFullWaveSpice [Network Data Explorer]


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
"variation", // Pick a particular variation. Leave blank if no variation.
Array("NAME:Frequencies"), // Optional; if none defined all frequencies are used
Array("NAME:SpiceData", // Spice export options object
"SpiceType:=", "SSS", // SpiceType can be "PSpice", "HSpice", "Spectre", "SSS",
                                  // "Simplorer", "TouchStone1.0", "TouchStone2.0"

Network Data Explorer Script Commands 22-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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 "Con-
vexOptimization",
                                          // "PassivityByPerturbation", or "IteratedFittingOfPV"
"ColumnFittingType:=", "Column", // Column FittingType can be "Column", "Entry", "Mat-
rix"
"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", // Touchstone Units "Hz", "KHz", "MHz", "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 [Network Data Explorer]


Use: Export the solution in a format of your choice (Citifile, Spreadsheet, Matlab, Touchstone, Neut-
ral)
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
                  // full path of the file from which the solution is loaded
"ExportFile", // full path of file to export to
"variation", // Pick a particular variation. Leave blank if no variation

Network Data Explorer Script Commands 22-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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 [Network Data Explorer]


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", // Export NMF options object
"DataTypes:=", Array("S"), // DataTypes can be "S", "Y","Z", "G", and "Z0",
                                              // for S , Y, Z matrix, Gamma and Z0 (zero)

Network Data Explorer Script Commands 22-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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
"Variables:=", ARRAY("FF", "cap", "Rs") // Array of variables
"Variations:=", ARRAY("", "", "") // Array of variations to export solutions for
Array("NAME:ConstantVars") // Array of variables that are constant, can be empty
Array("NAME: DependentVars") // Array of variables that are dependent, can be empty
"MatrixSize:=", 2, // Matrix size, optional (used in nmf file header)
"CreateNPortModel:=", true // Create a model based on the exported file true/false
)

Network Data Explorer Script Commands 22-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

23 - Definition Manager Script Commands


The definition manager controls the use of materials and scripts in a project. It also provides access
to the managers for symbols, footprints, padstacks, and components in a project.
Set oProject = oDesktop.SetActiveProject("Project1")
Set oDefinitionManager = oProject.GetDefinitionManager()
The topics for this section include:

AddMaterial
CloneMaterial
DoesMaterialExist
EditMaterial
ExportMaterial
RemoveMaterial
RemoveUnusedDefinitions

Component Manager Script Commands


Material Manager Script Commands
Model Manager Script Commands
Symbol Manager Script Commands
Footprint Manager Script Commands
Padstack Manager Script Commands
Script and Library Scripts

AddMaterial
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)

Definition Manager Script Commands 23-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"<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)
VB Example:
Set oDefinitionManager = oProject.GetDefinitionManager()

Definition Manager Script Commands 23-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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")

An example related to Q3D Extractor is given below.


VB Example: oProject.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")

Python Syn- AddMaterial (["NAME:<MaterialName>",


tax
<MatProperty>, <MatProperty>, ...])

Python oDefinitionManager.AddMaterial(
Example ["permittivity:=", "2.2", "0.002"])

CloneMaterial
Clones a local material.
Command: None
Syntax: CloneMaterial(<name>, <newName>)
Return Value: True if Material is cloned successfully. False if the existing material is not found or if
there is a name conflict with the new material name.

Definition Manager Script Commands 23-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters: name
Type: <string>
Existing material name.
<newName>
Type: <string>
The new material name for newly cloned material.
VB Example:
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Project1")
Set oDefinitionManager = oProject.GetDefinitionManager()
oDefinitionManager.CloneMaterial("copper1", "copper3")

Python CloneMaterial(<name>, <newName>)


Syntax

Python oDefinitionManager.CloneMaterial(["copper1", "copper3"])


Example

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

UI Access None.

Name Type Description


<Parameters>
Parameters
<materialName> <string> Name of the material to
search for in the material

Definition Manager Script Commands 23-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

database

Return Boolean
Value

Python DoesMaterialExist(<MaterialName>)
Syntax

oProject = oDesktop.GetActiveProject()
Python
oDefinitionManager = oProject.GetDefinitionManager()
Example
oDefinitionManager.DoesMaterialExist("modified_epoxy")

VB Syn- DoesMaterialExist(<MaterialName>)
tax

Set oProject = oDesktop.GetActiveProject()


VB
Set oDefinitionManager = oProject.GetDefinitionManager()
Example
oDefinitionManager.DoesMaterialExist("modified_epoxy")

EditMaterial
Modifies an existing material.

UI Access View/Edit Materials command in the material editor

Name Type Description


Parameters <OriginalName> String Name of the material before editing
<NewName> String New name for the material

Return Value None

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


Syntax
<MatProperty>, <MatProperty>, ...)
oDefinitionManager.EditMaterial("alumina_92pct",
Python
[
Example
"NAME:alumina_92pct",

Definition Manager Script Commands 23-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"CoordinateSystemType:=", "Cartesian",
"BulkOrSurfaceType:=" , 1,
[
"NAME:PhysicsTypes",
"set:=" , ["Electromagnetic","Thermal","Structur
],
"permittivity:=" , "9.3",
"dielectric_loss_tangent:=", "0.008",
"thermal_conductivity:=", "26",
"mass_density:=" , "3720",
"specific_heat:=" , "790",
"youngs_modulus:=" , "267000000000",
"poissons_ratio:=" , "0.26",
"thermal_expansion_coeffcient:=", "7.2e-006"
])

VB Syn-  EditMaterial <OriginalName>, Array("NAME:<NewName>",


tax
<MatProperty>, <MatProperty>, ...)
oDefinitionManager.EditMaterial("alumina_92pct",
Array(
"NAME:alumina_92pct",
"CoordinateSystemType:=", "Cartesian",
"BulkOrSurfaceType:=", 1,
VB
Exampl- Array("NAME:PhysicsTypes",
e
"set:=", Array("Elec-
tromagnetic","Thermal","Structural")),
"permittivity:=", "9.3",
"dielectric_loss_tangent:=", "0.008",
"thermal_conductivity:=", "26",

Definition Manager Script Commands 23-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"mass_density:=", "3720",
"specific_heat:=", "790",
"youngs_modulus:=", "267000000000",
"poissons_ratio:=", "0.26",
"thermal_expansion_coeffcient:=", "7.2e-006"
))

ExportMaterial
Exports a local material to a library.

UI Access Export to Library command in the material editor

Name Type Description


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

Return None
Value

Python ExportMaterial (<ExportData>, <Library location>)


Syntax

oDefinitionManager.ExportMaterial (["NAME:mo0907b",_
Python
Example "Material1", "Material2", "Material3"], "UserLib")

VB Syn- ExportMaterial <ExportData>, <Library location>


tax

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

RemoveMaterial
Use: Removes a material from a library.
Command: Remove Material(s) command in the material editor .

Definition Manager Script Commands 23-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

UI Access Remove Material(s) command in the material editor

Name Type Description


<MaterialName> String Name of the material to be removed.
<IsProjectMaterial> Boolean If true, HFSS (or )assumes the material is a
project material. In this case, the last two para-
Parameters meters will be ignored.
<LibraryName> String The name of the user or personal library
where the material resides.
<LibraryLocation> String Should be "UserLib" or "Per-
sonalLib".

Return Value None

Python Syn- RemoveMaterial (<MaterialName>, <IsProjectMaterial>,


tax
<LibraryName>, <LibraryLocation>)

Python oDefinitionManager.RemoveMaterial ([
Example "Material1", false, "mo0907","UserLib"])

RemoveMaterial <MaterialName>, <IsProjectMaterial>,


VB Syntax
<LibraryName>, <LibraryLocation>
oDefinitionManager.RemoveMaterial
VB Example
"Material1", false, "mo0907","UserLib"

RemoveUnusedDefinitions
Removes any unused project definitions.

UI Access Tools > Project Tools > Remove Unused Definitions.

Name Type Description


Parameters NAME:<type of <Array> Definitions to be removed, such as materials
definition> and surface materials.

Return Value None

Python Syn- RemoveUnusedDefinitions())


tax

Definition Manager Script Commands 23-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oProject.RemoveUnusedDefinitions(
[
[
"NAME:Materials",
"Al-Extruded"
Python
],
Example
[
"NAME:SurfaceMaterials",
"Steel-oxidised-surface"
]
])

VB RemoveUnusedDefinitions
Syn-
tax

VB oProject.RemoveUnusedDefinitions Array(Array("NAME:Materials",
Exa- "Al-Extruded"), Array("NAME:SurfaceMaterials", _
mpl-
e "Steel-oxidised-surface"))

Component Manager Script Commands


The component manager provides access to components in a project. The manager object is
accessed via the definition manager.
Set oDefinitionManager = oProject.GetDefinitionManager()
Set oComponentManager = oDefinitionManager.GetManager("Component")
The topics for this section include:
Add
AddDynamicNPortData
AddNPortData
AddAddSolverOnDemandModel
ClearSolutionCache
Edit

Definition Manager Script Commands 23-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

EditSolverOnDemandModel
EditWithComps
Export
GetNPortData
GetSolverOnDemandData
GetSolverOnDemandModelList
Remove
RemoveSolverOnDemandMode
UpdateDynamicLink
Add [component manager]
Use:Add a component
Command: Tools > Edit Configured Libraries > Components > Add Component
Syntax:Add Array("NAME:<ComponentName>",
"Info:=", <ComponentInfo>,
"RefBase:=", <string>, // reference designator
"NumParts:=", <int>, // parts per component
"OriginalComponent:=", <string>
"Terminal:=", <TerminalInfo>,
"Terminal:=", <TerminalInfo>, ...
// The remaining parameters are optional
Array("NAME:Parameters", // any combo of the following
"VariableProp:=", <VariableInfo>,
"CheckboxProp:=", <CheckBoxInfo>,
"ButtonProp:=", <ButtonInfo>,
"TextProp:=", <TextInfo>,
"NumberProp:=", <NumberInfo>,
"SeparatorProp:=", <SeparatorInfo>,
"ValueProp:=", <ValueInfo>,
"MenuProp:=", <MenuInfo>),
Array("NAME:Properties", // any combo of the following

Definition Manager Script Commands 23-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"CheckboxProp:=", <CheckBoxInfo>,
"TextProp:=", <TextInfo>,
"NumberProp:=", <NumberInfo>,
"SeparatorProp:=", <SeparatorInfo>,
"ValueProp:=", <ValueInfo>,
"MenuProp:=", <MenuInfo>),
"VPointProp:=", <VPointInfo>,
"PointProp:=", <PointInfo>),
Array("Quantities",
"QuantityProp:=", <QuantityPropInfo>...),
Array("NAME:CosimDefinitions",
<CosimDefInfo>,
<CosimDefInfo>...)
Return Value:<string>
// composite name of the component.
// If the name requested conflicts with the name of an existing
// component, the requested name is altered to be unique.
// The name returned reflects any change made to be unique.

Parameters:<ComponentName>:
<string> // simple name of the component

<ComponentInfo>:
Array("Type:=", <TypeInfo>,
"NumTerminals:=", <int>,
"DataSource:=", <string>,
"ModifiedOn:=", <ModifiedOnInfo>,
"Manufacturer:=", "<string>,
"Symbol:=", <string>,
"Footprint:=", <string>,

Definition Manager Script Commands 23-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Description:=", <string>,
"InfoTopic:=", <string>,
"InfoHelpFile:=", <string>,
"IconFile:=", <string>,
"LibraryName:=", "",
"OriginalLocation:=", "Project", // Project Location
"Author:=", <string>,
"OriginalAuthor:=", <string>,
"CreationDate:= ", <int>)

<TypeInfo>:
An integer that is the or-ing of bits for each product listed below. The default setting is
0xffffffff (4294967295) which indicates valid for all products. In the component editing dia-
log, checking different boxes in the "Specify products for which this component is valid"
grid control sets specific flags that correspond to the following hex/decimal settings:
Nexxim -- 100 binary, 4 decimal, 0x4
SIwaveDeNovo -- 1000 binary, 8 decimal, 0x8
Simplorer -- 10000 binary, 16 decimal, 0x10
MaxwellCircuit -- 100000 binary, 32 decimal, 0x20

<ModifiedOnInfo>:
An integer that corresponds to the number of seconds that have elapsed since 00:00
hours, Jan 1, 1970 UTC from the system clock.

<TerminalInfo>:
Array(<string>, // symbol pin
<string> // footprint pin
<string >, // gate name
<bool>, // shared
<int>, // equivalence number
<int>, // what to do if unconnected: flag as error:0, ignore:1
<string> // description

Definition Manager Script Commands 23-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<Nature>)

<Nature>:
<string> // content varies as follows

Nexxim/Circuit:
"Electrical" // the only choice

Simplorer:
// several choices
"Electrical", "Magnetic", "Fluidic", "Translational",
"Translational_V", "Rotational", "Rotational_V",
""Radiant", "Thermal", or <VHDLPackageName>

<VHDLPackageName>:
<string> // in the form <Library>.<Package>

<Library>:
<string> // name of the VHDL library

<Package>:
<string> // name of the VHDL package

<VariableInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<string>) // value: number, variable, or expression

Definition Manager Script Commands 23-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<FlagLetters>:
<string> // "D" - has description parameter,
// "RD" - readonly & has description parameter,
// or "RHD" - readonly, hidden, & has description parameter

<CheckBoxInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<bool>) // value: true or false

<ButtonInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
<string>, // button title
<string>, // extra text
<ClientID>,
"ButtonPropClientData:= ", <ClientDataArray>)

<ClientID>:
<int> // specifies Button Prop Client
// 0 - unknown, ButtonPropClientData
// array will be empty
// 1 - Netlist Prop Client
// 2 - not used
// 3 - File Name Prop Client

<ClientDataArray>:

Definition Manager Script Commands 23-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

varies with <ClientID>

<ClientId> is 0 or 1: empty array


Array()

<ClientID> is 3:
Array("InternalFormatText:=", "<prefix><RelativePath>")

<prefix>:
<string> // "<Project>", "<PersonalLib>", "<UserLib>", or "<SysLib>"

<RelativePath>:
<string> // relative path to file from <prefix>

<TextInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<string>) // value: a text string

<NumberInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<real>, // value: a number
<string>) // units

<SeparatorInfo>:
Array(<string>, // name

Definition Manager Script Commands 23-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<string>) // value: a text string

<ValueInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<string>) // value: a number, variable or expression

<MenuPropInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
<string>, // menu choices - separated by commas
<int>) // 0 based index of current menu choice

<VPointInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<string>, // x value: number with length units
<string>) // y value: number with length units

<PointInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description

Definition Manager Script Commands 23-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"CB:=", <string>, // optional - script for call back


<real>, // x value
<real>) // y value

<QuantityPropInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
<string>, // value
<TypeString>,
<TypeStringDependentInfo>)

<TypeString>:
<string> // "Across", "Through", or "Free"

<TypeStringDependentInfo>:

<TypeString> is "Free" :
<string>, // direction: "In", "Out", "InOut", or "DontCare"
// Following <string> is not present if direction is "DontCare"
<string> // when to calculate: "BeforeAnalogSolver",
// "BeforeStateGraph", "AfterStateGraph", or "DontCareWhen"

<TypeString> is "Across" or "Through":


<int>, // terminal 1
<int> // terminal 2

<CosimDefInfo>:
Array("NAME:CosimDefinition",
"CosimulatorType:=", <int>,
"CosimDefName:=", <string> // "HFSS 3D Layout", "Circuit",

Definition Manager Script Commands 23-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

// "Custom", or "Netlist"
"IsDefinition:=", <bool>,
final array member(s) vary with CosimDefName)

final array members for HFSS 3D Layout:


"CosimStackup:=", <string>,
"CosimDmbedRatio:=", <int>

final array members for Circuit:


"ExportAsNport:=", <int>,
"UsePjt:=", <int>

final array member for Custom:


"DefinitionCompName:=", <string>

final array member for Netlist:


"NetlistString:=", <string>

VB Example:
Dim name
oComponentManager.Add (Array("NAME:MyComponent", _
"Info:=", Array("Type:=", 4294901767, _
"NumTerminals:=", 2, _
"DataSource:=", "", _
"ModifiedOn:=", 1071096503, _
"Manufacturer:=", "Ansys", _
"Symbol:=", "bendo", _
"Footprint:=", "BENDO", _
"Description:=", "",_
"InfoTopic:=", "", _

Definition Manager Script Commands 23-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"InfoHelpFile:=", "", _
"IconFile:=", "", _
"LibraryName:=", "", _
"OriginalLocation:=", "Project", _
"Author:=", "", _
"OriginalAuthor:=", "", _
"CreationDate:= ", 1147460679), _
"Refbase:=", "U", _
"NumParts:=", 1, _
"OriginalComponent:=", "", _
"Terminal:=", Array("n1", _
"n1", _
"A", _
false, _
0, _
1, _
"", _
"Electrical"), _
"Terminal:=", Array("n2", _
"n2", _
"A", _
false, _
1, _
0, _
"", _
"Electrical"), _
Array("NAME:Parameters", _
"MenuProp:=", Array("CoSimulator", _
"D", _
"", _

Definition Manager Script Commands 23-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Default,HFSS 3D Layout,Circuit,Custom,Netlist", _
0), _
"ButtonProp:=", Array("CosimDefinition", _
"D", _
"", _
"", _
"Edit", _
0, _
"ButtonPropClientData:=", Array())), _
Array("NAME:CosimDefinitions", _
Array("NAME:CosimDefinition", _
"CosimulatorType:=", 0, _
"CosimDefName:=", "HFSS 3D Layout", _
"IsDefinition:=", true, _
"CosimStackup:=", "Layout stackup", _
"CosimDmbedRatio:=", 3), _
Array("NAME:CosimDefinition", _
"CosimulatorType:=", 1, _
"CosimDefName:=", "Circuit", _
"IsDefinition:=", true, _
"ExportAsNport:=", 0, _
"UsePjt:=", 0), _
Array("NAME:CosimDefinition", _
"CosimulatorType:=", 2, _
"CosimDefName:=", "Custom", _
"IsDefinition:=", true, _
"DefinitionCompName:=", ""), _
Array("NAME:CosimDefinition", _
"CosimulatorType:=", 3, _
"CosimDefName:=", "Netlist", _

Definition Manager Script Commands 23-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"IsDefinition:=", true, _
"NetlistString:=", "")))

Add [("NAME:<ComponentName>",
"Info:=", <ComponentInfo>,
"RefBase:=", <string>, // reference designator
"NumParts:=", <int>, // parts per component
"OriginalComponent:=", <string>
"Terminal:=", <TerminalInfo>,
"Terminal:=", <TerminalInfo>, ...
The remaining parameters are optional.
["NAME:Parameters", // any combo of the following
"VariableProp:=", <VariableInfo>,
"CheckboxProp:=", <CheckBoxInfo>,
"ButtonProp:=", <ButtonInfo>,

Python Syn- "TextProp:=", <TextInfo>,


tax
"NumberProp:=", <NumberInfo>,
"SeparatorProp:=", <SeparatorInfo>,
"ValueProp:=", <ValueInfo>,
"MenuProp:=", <MenuInfo>],
["NAME:Properties", Any combination of the following:
"CheckboxProp:=", <CheckBoxInfo>,
"TextProp:=", <TextInfo>,
"NumberProp:=", <NumberInfo>,
"SeparatorProp:=", <SeparatorInfo>,
"ValueProp:=", <ValueInfo>,
"MenuProp:=", <MenuInfo>,
"VPointProp:=", <VPointInfo>,
"PointProp:=", <PointInfo>],

Definition Manager Script Commands 23-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

["Quantities",
"QuantityProp:=", <QuantityPropInfo>...],
["NAME:CosimDefinitions",
<CosimDefInfo>,
<CosimDefInfo>...]]

oComponentManager.Add(
[
"NAME:Component",
"Info:=", [
"Type:=", 0,
"NumTerminals:=", 0,
"DataSource:=", "",
"ModifiedOn:=", 1467910752,
"Manufacturer:=", "",
"Symbol:=", "Component",
"ModelNames:=", "",
"Footprint:=", "",
Python
Example
"Description:=" , "",
"InfoTopic:=", "",
"InfoHelpFile:=", "",
"IconFile:=", "",
"Library:=", "",
"OriginalLocation:=", "Project",
"IEEE:=", "",
"Author:=", "",
"OriginalAuthor:=", "",
"CreationDate:=", 1467910746,
"ExampleFile:=", ""],
"Refbase:=", "U",
"NumParts:=", 1,

Definition Manager Script Commands 23-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"ModSinceLib:=", True,
"CompExtID:=", 2
])

AddDynamicNPortData [component manager]


Adds a component using the specified data
Command: Project Menu > Add Model > Add 2DExtractor Model
Project Menu > Add Model > Add HFSS Model
Project Menu > Add Model > Add Nexsys Matlab Model
Project Menu > Add Model > Add Nport Model
Project Menu > Add Model > Add Parametric Model
Project Menu > Add Model > Add Q3D Model
Project Menu > Add Model > Add SIwave Model
Project Menu > Add Model > Add State-space Model
Syntax: AddDynamicNPortData Array("NAME:<ComponentDataName>",
"ComponentDataType:=", <DataType>,
"name:=", <string>, // Name of the item
"filename:=", <string>, // Path to the file to find the data>
"numberofports:=", <int>,
"DesignName:=", <string>, // Name of the internal design
"SolutionName:=", <string>, // Name of the solution to reference
"Simulate:=", <bool>,
"CloseProject:=", <bool>,
"SaveProject:=", <bool>,
"RefNode:=", <bool>,
"InterpY:=", <bool>, // true to choose interpolating
"InterpAlg:=", <InterpolationAlgorithm>,
"NewToOldMap:=", <NewToOldMapPairs>,
"OldToNewMap:=", <OldToNewMapPairs>,
"PinNames:=", Array(<string>, <string>...))
Return Value: <string>

Definition Manager Script Commands 23-23


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

// composite name of the component.


// If the name requested conflicts with the name of an existing
// component, the requested name is altered to be unique.
// The name returned reflects any change made to be unique.
Parameters: <ComponentDataName>:
<string> // simple name of the component

<DataType>:
<string> // "DesignerData" or "Q3DData"

<InterpolationAlgorithm>:
<string> // "auto", "lin", "shadH", or "shadNH"

<NewToOldMapPairs>:
Array of name/value pairs such as "V1", "V2" that will have the new variable name first
and the old variable name second.

<OldToNewMapPairs>:
Array of name/value pairs such as "V1", "V2" that will have the old variable name first
and the new variable name second.
VB Example:
oComponentManager.AddDynamicNPortData
Array("NAME:ComponentData", _
"ComponentDataType:=", "DesignerData", _
"name:=", "DesignerData", _
"filename:=", _
"C:/Program Files/An-
sysEM/Designer/Examples/Projects/optiguides/optiguides.adsn", _
"numberofports:=", 2, _
"DesignName:=", "DesignerModel1", _
"SolutionName:=", "Setup1 : Adaptive_1", _

Definition Manager Script Commands 23-24


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Simulate:=", true, _
"CloseProject:=", false, _
"SaveProject:=", true, _
"RefNode:=", false, _
"InterpY:=", true, _
"InterpAlg:=", "auto", _
"NewToOldMap:=", Array("nport_height:=", "$height", _
"nport_length:=", "$length", _
"nport_width:=", "$width"), _
"OldToNewMap:=", Array("$height:=", "nport_height", _
"$length:=", "nport_length", _
"$width:=", "nport_width"), _
"PinNames:=", Array( "WavePort1:1", "WavePort2:1"))
AddNPortData [component manager]
Use: Adds a component using the specified data
Command: Project Menu > Add Model > Add Nport Model
Syntax: AddNPortData Array("NAME:<ComponentDataName>",
"ComponentDataType:=", "NportData",
"name:=", <string>, // Name of the item
"filename:=", <string>, // Path to the file to find the data
"numberofports:=", <int>,
"filelocation:=", <LocationType>,
"domain:=", <string>, // "time" or "frequency"
"datamode:=", <string> // "EnterData", "Import", or "Link"
"devicename:=", <string>,
"ImpedanceTab:=", <bool>,
"NoiseDataTab:=", <bool>,
"DCBehaviorTab:=", <bool>,
"SolutionName:=", <string>,
"displayformat:=", <DisplayInfo>,

Definition Manager Script Commands 23-25


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"datatype:=", <string>, // "SMatrix", "YMatrix", or "ZMatrix"


"ShowRefPin:=", <bool>,
"RefNodeCheckbox:=", <bool>, ...
<ProductOptionsInfo>)
Return Value: <string>
// composite name of the component.
// If the name requested conflicts with the name of an existing
// component, the requested name is altered to be unique.
// The name returned reflects any change made to be unique.

Parameters: <ComponentDataName>:
<string> // simple name of the component

<LocationType>:
<string> // one of "UsePath", "PersonalLib", "UserLib", "SysLib",
// or "Project".

<dcInfo>:
<string> // one of "DCOpen", "DCShort", "DCShShort",
// "DCNone", or "DCEmpty".

<DisplayInfo>:
<string> // one of "MagnitudePhase", "RealImaginary",
// or "DbPhase".

<ProductOptionsInfo>:
// The remaining parameters differ by product

// HFSS 3D Layout - doesn't support interpolation/DC behavior


"DCOption:=", -1,

Definition Manager Script Commands 23-26


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"InterpOption:=", -1,
"ExtrapOption:=",-1,
"DataType:=", 0

// Nexxim
"DCOption:=", <NexximDCOption>,
"InterpOption:=", <NexximInterpOption>,
"ExtrapOption:=", <NexximExtrapOption>,
"DataType:=", 2

<NexximDCOption>:
<int> // 0 : Zero Padding
// 1 : Same as last point
// 2 : Linear extrapolation from last 2 points
// 3 : Constant magnitude, linear phase extrapolation
// 4 : Leave all signal lines open circuited
// 5 : Short all signal lines together
// 6 : Short all signal lines to ground

<NexximInterpOption>:
<int> // 0 : Step
// 1 : Linear

<NexximExtrapOption>:
<int> // 0 : Zero padding
// 1 : Same as last point
// 2 : Linear extrapolation from last 2 points
// 3 : Constant magnitude, linear phase extrapolation

<CircuitDCOption>:

Definition Manager Script Commands 23-27


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<int> // 0 : Leave all signal lines open circuited


// 1 : Short all signal lines together
// 2 : Short all signal lines to ground
// 3 : Extrapolate from data provided (not recommended)

<CircuitInterpOption>:
<int> // 0 : Linear
// 1 : Cubic spline
// 2 : Rational polynomial

<CircuitExtrapOption>:
<int> // 0 : Same as interpolation
// 1 : Zero padding
// 2 : Same as last point
VB Example:
oComponentManager.AddNPortData Array("NAME:ComponentData", _
"ComponentDataType:=", "NPortData", _
"name:=", "NportData", _
"filename:=", "", _
"numberofports:=", 2, _
"filelocation:=", "UsePath", _
"domain:=", "frequency", _
"datamode:=", "Import", _
"devicename:=", "", _
"ImpedenceTab:=", true, _
"NoiseDataTab:=", true, _
"DCBehaviorTab:=", true, _
"SolutionName:=", "", _
"displayformat:=", "MagnitudePhase", _
"datatype:=", "SMatrix", _

Definition Manager Script Commands 23-28


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"ShowRefPin:=", true, _
"RefNodeCheckbox:=", false, _
"DCOption:=", 3, _
"InterpOption:=", 1, _
"ExtrapOption:=", 3, _
"DataType:=", 2, _
"DCOption:=", 3, _
"InterpOption:=", 1, _
"ExtrapOption:=", 3, _
"DataType:=", 2)
AddSolverOnDemandModel
Use: This method looks for a local component of the name passed in, and to this component it adds
an SOD model definition using the information passed in the VARIANT. It returns the name of the
SOD model added.
Parameters: BSTR component name.
Parameters: VARIANT which is the SOD model data.
Return Value: Returns the name of the model added.
ClearSolutionCache [component manager]
Use: Clear the solution cache for dynamic link component.
Command:Each of the following commands will clear the solution cache:
— Dynamic Link Item RCM > Clear Solution Cache
— Dynamic Link Component in schematic RCM > Clear Solution Cache
Syntax: ClearSolutionCache <Component Name >
Return Value: None
Parameters: <component name> is the name of the dynamic link com-
ponent
VB Example:
oComponentManager.ClearSolutionCache "TeeModel1"
Edit [component manager]
Modifies an existing component
Command: Tools > Edit Configured Libraries > Components > Edit Component

Definition Manager Script Commands 23-29


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax: Edit <ComponentName>,


Array("NAME:<NewComponentName>",
"Info:=", <ComponentInfo>,
"RefBase:=", <string>, // reference designator
"NumParts:=", <int>, // parts per component
"OriginalComponent:=", <string>
"Terminal:=", <TerminalInfo>,
"Terminal:=", <TerminalInfo>, ...
// The remaining parameters are optional
Array("NAME:Parameters", // any combo of the following
"VariableProp:=", <VariableInfo>,
"CheckboxProp:=", <CheckBoxInfo>,
"ButtonProp:=", <ButtonInfo>,
"TextProp:=", <TextInfo>,
"NumberProp:=", <NumberInfo>,
"SeparatorProp:=", <SeparatorInfo>,
"ValueProp:=", <ValueInfo>,
"MenuProp:=", <MenuInfo>),
Array("NAME:Properties", // any combo of the following
"CheckboxProp:=", <CheckBoxInfo>,
"TextProp:=", <TextInfo>,
"NumberProp:=", <NumberInfo>,
"SeparatorProp:=", <SeparatorInfo>,
"ValueProp:=", <ValueInfo>,
"MenuProp:=", <MenuInfo>),
"VPointProp:=", <VPointInfo>,
"PointProp:=", <PointInfo>),
Array("Quantities",
"QuantityProp:=", <QuantityPropInfo>...),
Array("NAME:CosimDefinitions",

Definition Manager Script Commands 23-30


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<CosimDefInfo>,
<CosimDefInfo>...)
Return Value: <string>
// composite name of the component.
// If the name requested conflicts with the name of an existing
// component, the requested name is altered to be unique.
// The name returned reflects any change made to be unique.

Parameters: <ComponentName>:
<string> // composite name of the component to edit

<NewComponentName>:
<string> // new simple name for the component

<ComponentInfo>:
Array("Type:=", <TypeInfo>,
"NumTerminals:=", <int>,
"DataSource:=", <string>,
"ModifiedOn:=", <ModifiedOnInfo>,
"Manufacturer:=", "<string>,
"Symbol:=", <string>,
"Footprint:=", <string>,
"Description:=", <string>,
"InfoTopic:=", <string>,
"InfoHelpFile:=", <string>,
"IconFile:=", <string>,
"LibraryName:=", <string>,
"OriginalLocation:=", <string>, // Project Location
"Author:=", <string>,
"OriginalAuthor:=", <string>,

Definition Manager Script Commands 23-31


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"CreationDate:= ", <int>)

<TypeInfo>:
An integer that is the or-ing of bits for each product listed below. The default setting is
0xffffffff (4294967295) which indicates valid for all products. In the component editing dia-
log, checking different boxes in the "Specify products for which this component is valid"
grid control sets specific flags that correspond to the following hex/decimal settings:
Nexxim -- 100 binary, 4 decimal, 0x4
SIwaveDeNovo -- 1000 binary, 8 decimal, 0x8
Simplorer -- 10000 binary, 16 decimal, 0x10
MaxwellCircuit -- 100000 binary, 32 decimal, 0x20

<ModifiedOnInfo>:
An integer that corresponds to the number of seconds that have elapsed since 00:00
hours, Jan 1, 1970 UTC from the system clock.

<TerminalInfo>:
Array(<string>, // symbol pin
<string> // footprint pin
<string >, // gate name
<bool>, // shared
<int>, // equivalence number
<int>, // what to do if unconnected: flag as error:0, ignore:1
<string>, // description
<Nature>)

<Nature>:
<string> // content varies as follows

Nexxim/Circuit:
"Electrical" // the only choice

Definition Manager Script Commands 23-32


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Simplorer:
// several choices
"Electrical", "Magnetic", "Fluidic", "Translational",
"Translational_V", "Rotational", "Rotational_V",
""Radiant", "Thermal", or <VHDLPackageName>

<VHDLPackageName>:
<string> // in the form <Library>.<Package>

<Library>:
<string> // name of the VHDL library

<Package>:
<string> // name of the VHDL package

<VariableInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<string>) // value: number, variable, or expression

<FlagLetters>:
<string> // "D" - has description parameter,
// "RD" - readonly & has description parameter,
// or "RHD" - readonly, hidden, & has description parameter

<CheckBoxInfo>:
Array(<string>, // name

Definition Manager Script Commands 23-33


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<bool>) // value: true or false

<ButtonInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
<string>, // button title
<string>, // extra text
<ClientID>,
"ButtonPropClientData:= ", <ClientDataArray>)

<ClientID>:
<int> // specifies Button Prop Client
// 0 - unknown, "ButtonPropClientData
// array will be empty
// 1 - Netlist Prop Client
// 2 - not used
// 3 - File Name Prop Client

<ClientDataArray>:
varies with <ClientID>

<ClientID> is 0 or 1: empty array


Array()

<ClienID> is 3:
Array("InternalFormatText:=", "<prefix><RelativePath>")

Definition Manager Script Commands 23-34


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<prefix>:
<string> // "<Project>", "<PersonalLib>", "<UserLib>", or "<SysLib>"

<RelativePath>:
<string> // relative path to file from <prefix>

<TextInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<string>) // value: a text string

<NumberInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<real>, // value: a number
<string>) // units

<SeparatorInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<string>) // value: a text string

<ValueInfo>:
Array(<string>, // name

Definition Manager Script Commands 23-35


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<string>) // value: a number, variable or expression

<MenuPropInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
<string>, // menu choices - separated by commas
<int>) // 0 based index of current menu choice

<VPointInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<string>, // x value: number with length units
<string>) // y value: number with length units

<PointInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<real>, // x value
<real>) // y value

<QuantityPropInfo>:
Array(<string>, // name
<FlagLetters>,

Definition Manager Script Commands 23-36


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<string>, // description
<string>, // value
<TypeString>,
<TypeStringDependentInfo>)

<TypeString>:
<string> // "Across", "Through", or "Free"

<TypeStringDependentInfo>:

"Free" :
<string>, // direction: "In", "Out", "InOut", or "DontCare"
// Following <string> is not present if direction is "DontCare"
<string> // when to calculate: "BeforeAnalogSolver",
// "BeforeStateGraph", "AfterStateGraph", or "DontCareWhen"

"Across" or "Through"
<int>, // terminal 1
<int> // terminal 2

<CosimDefInfo>:
Array("NAME:CosimDefinition",
"CosimulatorType:=", <int>,
"CosimDefName:=", <string> // "HFSS3D", "Circuit",
// "Custom", or "Netlist"
"IsDefinition:=", <bool>,
final array member(s) vary with CosimDefName)

final array members for HFSS 3D Layout:


"CosimStackup:=", <string>,
"CosimDmbedRatio:=", <int>

Definition Manager Script Commands 23-37


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

final array members for Circuit:


"ExportAsNport:=", <int>,
"UsePjt:=", <int>

final array member for Custom:


"DefinitionCompName:=", <string>

final array member for Netlist:


"NetlistString:=", <string>
VB Example:
Dim name
name = oComponentManager.Edit ("Nexxim Circuit Ele-
ments\BJTs:Level01_NPN", _
Array("NAME:Level01_NPN", _
"Info:=", Array("Type:=", 4294901764,_
"NumTerminals:=", 3, _
"DataSource:=", "Ansys built-in component", _
"ModifiedOn:=", 1152722112, _
"Manufacturer:=", "", _
"Symbol:=", "nexx_bjt_npn", _
"Footprint:=", "", _
"Description:=", "BJT, GP, NPN", _
"InfoTopic:=", "NXBJT1.htm", _
"InfoHelpFile:=", "nexximcomponents.chm", _
"IconFile:=", "bjtsn.bmp", _
"Library:=", "Nexxim Circuit Elements\BJTs", _
"OriginalLocation:=", "SysLibrary ", _
"Author:=", "", _
"OriginalAuthor:=", "", _

Definition Manager Script Commands 23-38


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"CreationDate:=", 1152722102), _
"Refbase:=", "Q", _
"NumParts:=", 1, _
"Terminal:=", Array("collector", _
"collector", _
"A", _
false, _
6, _
0, _
"", _
"Electrical"), _
"Terminal:=", Array("base", _
"base", _
"A", _
false, _
7, _
0, _
"", _
"Electrical"), _
"Terminal:=", Array("emitter", _
"emitter", _
"A", _
false, _
8, _
0, _
"", _
"Electrical"), _
Array("NAME:Parameters", _
"TextProp:=", Array("LabelID", _
"HD", _

Definition Manager Script Commands 23-39


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Property string for netlist ID", _


"Q@ID"), _
"TextProp:=", Array("MOD", _
"D", _
"Name of model data reference", _
"required"), _
"VariableProp:=", Array("AREA", _
"D", _
"Emitter area multiplying factor, which affects curents, res-
istances, and capacitances", _ "1"), _
"VariableProp=", Array("AREAB", _
"D", _
"Base AREA", _
"1"), _
"VariableProp:=", Array( "AREAC", _
"D", _
Collector AREA", _
"1"), _
"VariableProp:=", Array("DTEMP", _
"D", _
"The difference between element and circuit temperature deg Cel)", _
"0"), _
"VariableProp:=", Array("M", _
"D", _
"Multiplier factor to simulate multiple BJTs in paralel", _ "1"), _
"ButtonProp:=", Array("NexximNetlist", _
"HD", _
"", _
"Q@ID %0 %1 %2 *MOD(@MOD) *AREA(AREA=@AREA)" & _
" *AREAB(AREAB=@AREAB) *AREAC(AREAC=@" & _

Definition Manager Script Commands 23-40


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"AREAC) *DTEMP(DTEMP=@DTEMP) *M(M=@M)", _


"Q@ID %0 %1 %2 *MOD(@MOD) " & _ "*AREA(AREA=@AREA) AREAB(AREAB-
B=@AREAB) *AREAC(AREAC=@" & _
"AREAC) *DTEMP(DTEMP=@DTEMP) *M(M=@M)", _
1, _
"ButtonPropClientData:=", Array()), _
"TextProp:=", Array( "ModelName", _
"HD", _
"", _
"Q"))))
VB Example:
Dim name2
name2 = oComponentManager.Edit "MyComponent", _
(Array("NAME:MyOtherComponent", _
"Info:=", Array("Type:=", 4294901767, _
"NumTerminals:=", 2, _
"DataSource:=", "", _
"ModifiedOn:=", 1071096503, _
"Manufacturer:=", "Ansys", _
"Symbol:=", "bendo", _
"Footprint:=", "BENDO", _
"Description:=", "",_
"InfoTopic:=", "", _
"InfoHelpFile:=", "", _
"IconFile:=", "", _
"LibraryName:=", "", _
"OriginalLocation:=", "Project", _
"Author:=", "", _
"OriginalAuthor:=", "", _
"CreationDate:= ", 1147460679), _

Definition Manager Script Commands 23-41


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Refbase:=", "U", _
"NumParts:=", 1, _
"OriginalComponent:=", "", _
"Terminal:=", Array("n1", _
"n1", _
"A", _
false, _
0, _
0, _
"", _
"Electrical"), _
"Terminal:=", Array("n2", _
"n2", _
"A", _
false, _
1, _
0, _
"", _
Electrical"), _
Array("NAME:Parameters", _
"MenuProp:=", Array("CoSimulator", _
"D", _
"", _
"Default,HFSS3D,Circuit,Custom,Netlist", _
0), _
"ButtonProp:=", Array("CosimDefinition", _
"D", _
"", _
"", _
"Edit", _

Definition Manager Script Commands 23-42


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

0, _
"ButtonPropClientData:=", Array())), _
Array("NAME:CosimDefinitions", _
Array("NAME:CosimDefinition", _
"CosimulatorType:=", 0, _
"CosimDefName:=", "HFSS3D", _
"IsDefinition:=", true, _
"CosimStackup:=", "Layout stackup", _
"CosimDmbedRatio:=", 3), _
Array("NAME:CosimDefinition", _
"CosimulatorType:=", 1, _
"CosimDefName:=", "Circuit", _
"IsDefinition:=", true, _
"ExportAsNport:=", 0, _
"UsePjt:=", 0), _
Array("NAME:CosimDefinition", _
"CosimulatorType:=", 2, _
"CosimDefName:=", "Custom", _
"IsDefinition:=", true, _
"DefinitionCompName:=", ""), _
Array("NAME:CosimDefinition", _
"CosimulatorType:=", 3, _
"CosimDefName:=", "Netlist", _
"IsDefinition:=", true, _
"NetlistString:=", "")))

Edit <ComponentName>,
Pytho-
n Syn- ["NAME:<NewComponentName>",
tax
"Info:=", <ComponentInfo>,

Definition Manager Script Commands 23-43


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"RefBase:=", <string>, // reference designator


"NumParts:=", <int>, // parts per component
"OriginalComponent:=", <string>
"Terminal:=", <TerminalInfo>,
"Terminal:=", <TerminalInfo>, ...
#The remaining parameters are optional
["NAME:Parameters", // any combo of the following
"VariableProp:=", <VariableInfo>,
"CheckboxProp:=", <CheckBoxInfo>,
"ButtonProp:=", <ButtonInfo>,
"TextProp:=", <TextInfo>,
"NumberProp:=", <NumberInfo>,
"SeparatorProp:=", <SeparatorInfo>,
"ValueProp:=", <ValueInfo>,
"MenuProp:=", <MenuInfo>],
["NAME:Properties", # any combo of the following
"CheckboxProp:=", <CheckBoxInfo>,
"TextProp:=", <TextInfo>,
"NumberProp:=", <NumberInfo>,
"SeparatorProp:=", <SeparatorInfo>,
"ValueProp:=", <ValueInfo>,
"MenuProp:=", <MenuInfo>),
"VPointProp:=", <VPointInfo>,
"PointProp:=", <PointInfo>),
["Quantities",
"QuantityProp:=", <QuantityPropInfo>...],
["NAME:CosimDefinitions",
<CosimDefInfo>,
<CosimDefInfo>...])
Pytho- name = oComponentManager.Edit ("Simplorer Circuit Ele-

Definition Manager Script Commands 23-44


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ments\BJTs:Level01_NPN", _
["NAME:Level01_NPN", "Info:=", ["Type:=", 4294901764,_
"NumTerminals:=", 3, "DataSource:=", "Ansoft built-in com-
ponent",_
"ModifiedOn:=", 1152722112, "Manufacturer:=", "", _
"Symbol:=", "nexx_bjt_npn", "Footprint:=", "", _
"Description:=", "BJT, GP, NPN", "InfoTopic:=",
"NXBJT1.htm", _
"InfoHelpFile:=", "nexximcomponents.chm", "IconFile:=", "bjt-
sn.bmp", _
"Library:=", "Nexxim Circuit Elements\BJTs",_
"OriginalLocation:=", "SysLibrary ", "Author:=", "", _
"OriginalAuthor:=", "", "CreationDate:=", 1152722102], _
"Refbase:=", "Q", "NumParts:=", 1, "Terminal:=", ["col-
lector", _

n "collector", "A", false, 6, 0, "", "Electrical"], _


Exam-
"Terminal:=", ["base", "base", "A", false, _
ple
7, 0, "", "Electrical"], "Terminal:=", ["emitter", _
"emitter", "A", false, 8, 0, "", "Electrical"], _
["NAME:Parameters", "TextProp:=", ["LabelID", _
"HD", "Property string for netlist ID", _
"Q@ID"], "TextProp:=", ["MOD", "D", _
"Name of model data reference", "required"], _
"VariableProp:=", ["AREA", "D", _
"Emitter area multiplying factor, which affects
cur-
rents, resistances, and capacitances", "1"], _
"VariableProp:=", ["AREAB", "D", "Base AREA", _
"1"], "VariableProp:=", ["AREAC", "D", "Collector AREA", _
"1"], "VariableProp:=", ["DTEMP", "D", _
"The difference between element and circuit temperature (deg
Cel)", _

Definition Manager Script Commands 23-45


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"0"], "VariableProp:=", ["M", "D", _


"Multiplier factor to simulate multiple BJTs in parallel", _
"1"], "ButtonProp:=", ["NexximNetlist", "HD", "", _
"Q@ID %0 %1 %2 *MOD(@MOD) *AREA(AREA=@AREA)"& _

" *AREAB(AREAB=@AREAB) *AREAC(AREAC=@" &_


"AREAC) *DTEMP(DTEMP=@DTEMP) *M(M=@M)", _
"Q@ID %0 %1 %2 *MOD(@MOD) " & "*AREA(AREA=@AREA)
*AREAB(AREAB=@AREAB) *AREAC(AREAC=@" & _
"AREAC) *DTEMP(DTEMP=@DTEMP) *M(M=@M)", 1, _
"ButtonPropClientData:=", []],
"TextProp:=", ["ModelName", "HD", "", "Q"]]])

name2 = oComponentManager.Edit
("MyComponent",_

(["NAME:MyOtherComponent","Info:=", ["Type:=", 4294901767, _

"NumTerminals:=", 2, "DataSource:=", "", _

Pytho- "ModifiedOn:=", 1071096503, "Manufacturer:=", "Ansoft", _


n
Exam-
ple
2 "Symbol:=", "bendo", "Footprint:=", "BENDO", _

"Description:=", "", "InfoTopic:=", "", _

"InfoHelpFile:=", "", "IconFile:=", "", _

"LibraryName:=", "", "OriginalLocation:=", "Project", _

Definition Manager Script Commands 23-46


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Author:=", "", "OriginalAuthor:=", "", _

"CreationDate:= ", 1147460679], "Refbase:=", "U", _

"NumParts:=", 1, "OriginalComponent:=", "", _

"Terminal:=", ["n1", "n1", "A", false, 0, 0, "", _

"Electrical"], "Terminal:=", ["n2", "n2", "A", _

false, 1, 0, "", Electrical"], ["NAME:Parameters", _

"MenuProp:=", ["CoSimulator", "D", "", _

"Default,Custom,Netlist", 0], "ButtonProp:=", ["CosimDefin-


ition", _

"D", "", "", "Edit", 0, "ButtonPropClientData:=", []]], _

["NAME:CosimDefinitions", ["NAME:CosimDefinition", _

"CosimulatorType:=", 0, "CosimDefName:=", "HFSS3D", _

"IsDefinition:=", true, "CosimStackup:=", "Layout stackup",


_

"CosimDmbedRatio:=", 3], ["NAME:CosimDefinition", _

Definition Manager Script Commands 23-47


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"CosimulatorType:=", 1, "CosimDefName:=", "", _

"IsDefinition:=", true, "ExportAsNport:=", 0, _

"UsePjt:=", 0], ["NAME:CosimDefinition", _

"CosimulatorType:=", 2, "CosimDefName:=", "Custom", _

"IsDefinition:=", true, "DefinitionCompName:=", ""], _

["NAME:CosimDefinition", "CosimulatorType:=", 3, _

"CosimDefName:=", "Netlist", "IsDefinition:=", true, _

"NetlistString:=", ""]]])

EditSolverOnDemandModel
Use: This method looks for a local component of the name passed in, and in this component it looks
for an SOD model using the name passed in the second BSTR. It modifies the SOD model using
the data in the VARIANT. It returns the name of the SOD model edited.
Return Value: Returns the name of the model edited.
Parameters: BSTR component name.
Parameters: BSTR SOD model name.
Parameters: VARIANT which is the new SOD model data (can include
changed name).
EditWithComps [component manager]
Edit an existing component.
Command: None
Syntax: EditWithComps <ComponentName>,

Definition Manager Script Commands 23-48


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:<NewComponentName>",
"ModTime:=", <ModifiedTimeInfo>,
"Library:=", <string>, // Library name
"LibLocation:=", <string>, // Project Location
<PinDefInfo>,
<PinDefInfo>,... // optional, to define pins
<GraphicsDataInfo>, // optional, to define graphics
<PropDisplayMapInfo>), // optional, to define property displays
Array(<ListOfComponentNames>) // Component names

Return Value: <string>


// composite name of the component.
// If the name requested conflicts with the name of an existing
// component, the requested name is altered to be unique.
// The name returned reflects any change made to be unique.

Parameters: <ComponentName>:
<string> // composite name of the component being edited

<NewComponentName>:
<string> // new simple name for the component

<ModifiedOnInfo>:
An integer that corresponds to the number of seconds that have elapsed
since 00:00 hours, Jan 1, 1970 UTC from the system clock.

<PinDefInfo>:
Array("NAME:PinDef",
"Pin:=", Array (<string>, // pin name
<real>, // x location

Definition Manager Script Commands 23-49


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<real>, // y location
<real>, // angle in radians
<PinType>,
<real>, // line width
<real>, // line length
<bool>, // mirrored
<int>, // color
<bool>, // true if visible, false if not
<string>, // hidden net name
<OptionalPinInfo>, // optional info
<PropDisplayMapInfo>)) // optional

<PinType>:
<string> // "N" : normal pin
// "I" : input pin
// "O" : output pin

<OptionalPinInfo>:
// Specify both or neither
<bool>, // true if name is to be shown
<bool>, // true if number is to be shown

<PropDisplayMapInfo>:
Array("NAME:PropDisplayMap",
<PropDisplayInfo>,
<PropDisplayInfo>,...)

<PropDisplayInfo>:
<NameString>, Array(<DisplayTypeInfo>,
<DisplayLocationInfo>,

Definition Manager Script Commands 23-50


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<int>, // optional, level number


<TextInfo>)

<NameString>:
<string> // PropertyName:=, where PropertyName is the name of
// the property to be displayed

<DisplayTypeInfo>:
<int> // 0 : No display
// 1 : Display name only
// 2 : Display value only
// 3 : Display both name and value
// 4: Display evaluated value only
// 5: Display both name and evaluated value

<DisplayLocationInfo>:
<int> // 0 : Left
// 1 : Top
// 2 : Right
// 3 : Bottom
// 4 : Center
// 5 : Custom placement

<GraphicsDataInfo>:
Array("NAME:Graphics",
// one or more of the following
<RectInfo>,
<CircleInfo>,
<ArcInfo>,
<LineInfo>,

Definition Manager Script Commands 23-51


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<PolygonInfo>,
<TextInfo>,
<ImageInfo>)

<RectInfo>:
"Rect:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<real>, // angle, in radians
<real>, // x position of center
<real>, // y position of center
<real>, // width
< real>) // height

<CircleInfo>:
"Circle:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<real>, // x position of center
<real>, // y position of center
< real>) // radius

<ArcInfo>:
"Arc:=", Array(<real>, // line width
<int>, // line pattern
<int>, // color
<real>, // x position of center
<real>, // y position of center
< real>, // radius
<real>, // start angle, in radians

Definition Manager Script Commands 23-52


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<end>) // end angle, in radians

<LineInfo>:
"Line:=", Array(<real>, // line width
<int>, // line pattern
<int>, // color
<PointInfo>, // must specify at least 2 points
<PointInfo>...)
<PointInfo>:
<real>, // x position
<real> // y position

<PolygonInfo>:
"Polygon:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<PointInfo>, // must specify at least 3 points
<PointInfo>...)

<TextInfo>:
"Text:=", Array(<real>, // x position
<real>, // y position
<real>, // angle, in radians
<Justification>,
<bool>, // is plotter font
<string>, // font name
<int>, // color
<string>) // text string

<Justification>:

Definition Manager Script Commands 23-53


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<int> // 0 : left top


// 1 : left base
// 2 : left bottom
// 3 : center top
// 4 : center base
// 5 : center bottom
// 6 : right top
// 7 : right base
// 8 : right bottom

<ImageInfo>:
"Image:=", Array(<RectInfo>,
<ImageData>,
<bool>) // is mirrored

<ImageData>:
<string>, // file path
<int>, // 0 : use the file path and link to it
// 1 : ignore file path and use next parameter
<string> // text data, only present if preceding int is 1

<ListOfComponentNames>:
<string>,<string> ...
// The list may be empty. When not empty, each string that is listed is a component
// that references the component to be edited. Prior to editing, a clone of the component
is
// made, and the components that are listed are modified so that they now refer to
// the clone.

VB Example:

Definition Manager Script Commands 23-54


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim nam
oModelManager.EditWithComps_
("Nexxim Circuit Elements\Distributed\Distributed:bendo", _
Array("NAME:bendo new name", _
"ModTime:=", 1152722165, _
"Library:=", "Nexxim Circuit Elements\Distributed\Distributed", _
"LibLocation:=", "SysLibrary", _
Array("NAME:PinDef", _
"Pin:=", Array( "n1", _
-0.00254, _
0.00254, _
0, _
"N", _
0, _
0, _
false, _
0, _
true, _
"", _
false, _
false)), _
Array("NAME:PinDef", _
"Pin:=", Array( "n2", _
0.00254, _
-0.00254, _
1.5708, _
"N", _
0, _
0, _
false, _

Definition Manager Script Commands 23-55


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

0, _
true, _
"", _
false, _
false)), _
Array("NAME:Graphics", _
"Polygon:=", Array( 0, 0, 12566272, 0, 0.00381, 0, .00127, 0.00127,
_
0.00127, 0.00127, 0, 0.00381, 0, 0.00381, _
0.002032, 0.00127, 0.00381), _
"Line:=", Array(0, 1, 12566272, -0.00254, 0.00254, 0, .00254), _
"Line:=", Array(0, 1, 12566272, 0.00254, -0.00254, .00254, 0)), _
Array("NAME:PropDisplayMap", _
"W:=", Array(3, _
5, _
0, _
"Text:=", Array( 2.1684E-019, _
0.00504119, _
0, _
1, _
5, _
false, _
"Arial", _
0, _
"W=***"))))), _
Array("MY_COMP")

Export [component manager]


Export component(s) to a library
Command: Tools > Edit Configured Libraries > Components > Export to Library

Definition Manager Script Commands 23-56


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax: Export Array("NAME:<LibraryName>",


<ComponentName>,
<ComponentName>...),
<LibraryLocation>
Return Value: None
Parameters: <LibraryName>:
<string> // name of the library

<ComponentName>:
<string> // composite name of the component to export

<LibraryLocation>:
<string> // location of the library in <LibraryName>
// One of "Project", "PersonalLib", or "UserLib"

VB Example:
oComponentManager.Export Array("NAME:mylib", "Nexxim Circuit Ele-
ments\BJTs:Level01_NPN"),"PersonalLib"

Python Export(["NAME:<LibraryName>", <ComponentName>, <ComponentName>...],


Syntax <LibraryLocation>)
oComponentManager.Export(["NAME:mylib",
Python
"Simplorer Circuit Elements\BJTs:Level01_NPN"],
Example
"PersonalLib")

GetData [component manager]


Gets data that describes the definition.
Command: None
Syntax: GetData(<DefinitionName>)
Return Value: <DefinitionData> This is an array of data for the definition.
Parameters: <DefinitionName>:

Definition Manager Script Commands 23-57


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<string> // composite name of the definition to edit


VB Example:
Dim compData
compData = oComponentManager.GetData("Level01_NPN")

Note:

GetData allows the user to access definition information, make modifications, and then
use the Edit or EditWithComps script commands to save the modified definition. Accord-
ingly, for each type of definition, the array data returned to GetData should be the same
array information that is supplied to the Edit or EditWithComps commands.

Python GetData(<DefinitionName>)
Syntax

Python compData = oComponentManager.GetData("Level01_NPN")


Example

GetNames [component manager]


Returns the names of the components (used and unused) in a design. The following script com-
mand, IsUsed, can then be used to separate used and unused components.
Command: None
Syntax: GetNames()
Return Value: An array of strings
Parameters: None
VB Example:
Dim componentNames
componentNames = oComponentManager.GetNames()

Python Syn- GetNames()


tax

Python componentNames = oComponentManager.GetNames()


Example

Definition Manager Script Commands 23-58


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetNPortData [component manager]


Returns NPort data for the component with the specified name.
Command: None
Return Value: Variant array, whose contents depend on the type of component. The array will be
empty if the component does not have NPort data. See the syntax for AddDynamicNPortData and
AddNPortData for descriptions of the array contents for components with those types of NPort
data.
Parameters: <ComponentName>:
<string>
Example: This script displays each item in the returned array for
each component in the design.

Sub DisplayVariant(x)
Dim index
index = 0

For Each info In x


curr = x(index)
If TypeName(curr) <> "Variant()" Then
If TypeName(curr) <> "Empty" And TypeName(curr) <> "Null"
Then
str = CStr(curr)
If str = "" Then
str = ChrW(34) & ChrW(34)
End If
Msgbox str
Else
str = "Empty/Null item."
Msgbox str
End If
Else
DisplayVariant curr

Definition Manager Script Commands 23-59


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

End If

index = index + 1
Next

End Sub

Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim dnpInfo
Dim index

Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")


Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.GetActiveProject()
Set oDefinitionManager = oProject.GetDefinitionManager()

Set oComponentManager = oDefinitionManager.GetManager("Component")

Dim componentNames
componentNames = oComponentManager.GetNames()

index = 0
For Each name In componentNames
name = componentNames(index)
message = "NPort data for component " + name
Msgbox message
dnpInfo = oComponentManager.GetNPortData(name)

Definition Manager Script Commands 23-60


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

DisplayVariant dnpInfo
index = index + 1
Next

GetSolverOnDemandData
Use: This method looks for a local component of the name passed in, and in this component it looks
for an SOD model of the name passed in and returns the SOD data pertaining to that model.
Parameters: BSTR component name.
Parameters: BSTR SOD model name
Return Value: VARIANT which is the SOD data.
GetSolverOnDemandModelList
Use: This method looks for a local component of the name passed in, and returns a list of SOD
model names defined in the component.
Parameters: BSTR component name.
Return Value: VARIANT which is a list of SOD model names.
IsUsed [component manager]
Used to determine if a component is used in the design.
Command: None
Syntax: IsUsed(<ComponentName>)
Return Value: <Boolean> // true if the specified component is used in the design
Parameters: <ComponentName>:
<string>
VB Example:
Dim isUsed
isUsed = oComponentManager.IsUsed("MyComponent")

Python  IsUsed(<ComponentName>)
Syntax

Python IsUsed = oComponentManager.IsUsed("MyComponent")


Example

Definition Manager Script Commands 23-61


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Remove [component manager]


Remove a component from a library
Command: Tools > Edit Configured Libraries > Components > Remove Component
Syntax: Remove <ComponentName>,
<IsProjectComponent>,
<LibraryName>,
<LibraryLocation>
Return Value: None
Parameters: <ComponentName>:
<string> // composite name of the component to remove

<IsProjectComponent>:
<bool>

<LibraryName>:
<string> // name of the library

<LibraryLocation>:
<string> // location of the library in <LibraryName>
// One of "Project", "PersonalLib", or "UserLib"

VB Example:
oComponentManager.Remove "Nexxim Circuit Elements\BJTs:Level01_NPN",
_ true, "Project"

Python Remove (<ComponentName>, <IsProjectComponent>, <LibraryName>,


Syntax <LibraryLocation>)

Python oComponentManager.Remove ("Simplorer Circuit


Example Elements\BJTs:Level01_NPN", _ true, "Project")

Definition Manager Script Commands 23-62


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

RemoveSolverOnDemandModel
Use: This method looks for a local component of the name passed in, and in this component it looks
for an SOD model of the name passed in and deletes the SOD model definition from the com-
ponent.
Parameters: BSTR component name.
Parameters: BSTR SOD model name
Return Value: None.
RemoveUnused [component manager]
Removes components that are not used in the design.
Command: Project->Remove Unused Definitions is similar but operates slightly different and
does not record script commands.
Syntax: RemoveUnused()
Return Value: <bool> True if one or more components are removed.
Parameters: None
VB Example:
Dim removedDefs
removedDefs = oComponentManager.RemoveUnused()

Note:

The order of calls to RemoveUnused is significant. As a result, removing definitions in an


unordered fashion may cause other components in dependent definitions to be rendered
unusable.

Also, the symbol and footprint of an unused component are not unusable until after the
component itself is removed using the Component Manager Remove script.

Python RemoveUnused()
Syntax

Python removedDefs = oComponentManager.RemoveUnused()


Example

Definition Manager Script Commands 23-63


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Update Dynamic Link [component manager]


Use:Reads data from the linked design and updates the dynamic link component. This will update
the following: properties, solutions, ports, geometry.
Command:Each of the following commands will record a non-undoable script command:
—Dynamic Link Item RCM > Refresh Dynamic Link
—Dynamic Link Component in schematic RCM > Refresh Dynamic Link
— Click the Refresh Dynamic Link button in the Footprint tab of the Properties Window for
selected Dynamic Link components in the Layout Editor.
Syntax:UpdateDynamicLink(<component name>)
Return Value:None
Parameters:<component name> is the name of the dynamic link com-
ponent
VB Example:
oComponentManager.UpdateDynamicLink("TeeModel_L1")

Material Manager Script Commands


The material manager provides access to materials in a project. The manager object is accessed
via the definition manager.
Set oDefinitionManager = oProject.GetDefinitionManager()
Set oMaterialManager = oDefinitionManager.GetManager("Material")
The topics for this section include:
GetData
GetNames
GetProperties
IsUsed
RemoveUnused
GetData [material manager]
Use: Get material data
Command: None
Syntax: GetData <material_name>
Return Value: Array of material data
Parameters: <material_name>
Type: string

Definition Manager Script Commands 23-64


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Value: Name of the project material


VB Example:
materialData = oMaterialMgr.GetData( "MyMaterial2" )

Python Syn- GetData(<SimpleName>)


tax

Python dataArray = oMaterialManager.GetData


Example ("mymaterial")

GetNames [material manager]


Use: Get the names of the materials in a project
Command: None
Syntax: GetNames
Return Value: Names of the materials in a project
Parameters: None
Example:
materialNames = oMaterialMgr.GetNames()

Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.NewProject
oProject.InsertDesign "Nexxim Circuit", "Nexxim1", "", ""
Set oMaterialMgr = oProject.GetDefinitionManager().GetManager("Mater-
ial")

Definition Manager Script Commands 23-65


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oMaterialMgr.Add( Array("NAME:MyMaterial1", "Coordin-


ateSystemType:=", "Cartesian", "permittivity:=", "0.123") )
oMaterialMgr.Add( Array("NAME:MyMaterial2", "Coordin-
ateSystemType:=", "Cartesian", "permittivity:=", "0.456")
Dim materialNames
materialNames = oMaterialMgr.GetNames()

Python Syn- GetNames()


tax

Python materialnames = oMaterialManager.GetNames()


Example

GetProperties [material manager]


Get material properties. Differs from GetData in that only material properties available to the user
are returned by GetProperties.

UI Access NA

Name Type Description


<material_name> string Name of the project material
Parameters Boolean True or False. If you use False or only a single
argument, then GetProperties returns only
the properties that are different from the
defaults.

Return Value Array of material data

Python Syn-  GetProperties (<materialname>)


tax

Python oMaterialManager.GetProperties("Gold", True)


Example oMaterialManager.GetProperties("vacuum")

VB Syntax GetProperties <material_name>


VB materialProps = oMaterialMgr.GetProperties( "MyMaterial2" )
Example

Definition Manager Script Commands 23-66


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

IsUsed [material manager]


Use: Checks if a project material is in use
Command: None
Syntax: IsUsed <material_name>
Return Value: Returns 'True' if the material is in use.
Parameters: <material_name>
Type: string
Value: Name of the project material to check.
VB Example:
used = oMaterialMgr.IsUsed( "MyMaterial2" )

Python IsUsed(<ComboName>)
Syntax

Python isused = oMaterialManager.IsUsed("mylib:mymaterial")


Example

RemoveUnused [material manager]


Use: Remove all unused materials from the project.
Command: None
Syntax: RemoveUnused
Return Value: None
Parameters: None
VB Example:
oMaterialMgr.RemoveUnused()

Python  RemoveUnused()
Syntax

Python thereWereExtras = oMaterialManager.RemoveUnused()


Example

Definition Manager Script Commands 23-67


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Model Manager Script Commands


The model manager provides access to models in a project. The manager object is accessed via
the definition manager.
Set oDefinitionManager = oProject.GetDefinitionManager()
Set oModelManager = oDefinitionManager.GetManager("Model")
The model manager script commands are listed below:
Add
ConvertToDynamic
ConvertToParametric
Edit
EditWithComps
Export
GetData
GetNames
IsUsed
Remove
RemoveUnused
Add [model manager]
Use: Add a model
Command: Tools > Edit Configured Libraries > Models > Add Model
Syntax: Add Array("NAME:<modelName>",
"ModTime:=", <ModifiedTimeInfo>,
"Library:=", "", // Library name
"LibLocation:=", "Project", // Project Location
<PinDefInfo>,
<PinDefInfo>,... // optional, to define pins
<GraphicsDataInfo>, // optional, to define graphics
<PropDisplayMapInfo>)) // optional, to define property displays

Return Value: <string>

Definition Manager Script Commands 23-68


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

// composite name of the model.


// If the name requested conflicts with the name of an existing
// model, the requested name is altered to be unique.
// The name returned reflects any change made to be unique.

Parameters: <modelName>:
<string> // simple name of the model being added

<ModifiedOnInfo>:
An integer that corresponds to the number of seconds that have elapsed
since 00:00 hours, Jan 1, 1970 UTC from the system clock.

<PinDefInfo>:
Array("NAME:PinDef",
"Pin:=", Array (<string>, // pin name
<real>, // x location
<real>, // y location
<real>, // angle in radians
<PinType>,
<real>, // line width
<real>, // line length
<bool>, // mirrored
<int>, // color
<bool>, // true if visible, false if not
<string>, // hidden net name
<OptionalPinInfo>, // optional info
<PropDisplayMapInfo>)) // optional

<PinType>:
<string> // "N" : normal pin

Definition Manager Script Commands 23-69


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

// "I" : input pin


// "O" : output pin

<OptionalPinInfo>:
// Specify both or neither
<bool>, // true if name is to be shown
<bool>, // true if number is to be shown

<PropDisplayMapInfo>:
Array("NAME:PropDisplayMap",
<PropDisplayInfo>,
<PropDisplayInfo>,...)

<PropDisplayInfo>:
<NameString>, Array(<DisplayTypeInfo>,
<DisplayLocationInfo>,
<int>, // optional, level number
<TextInfo>)
<NameString>:
<string> // PropertyName:=, where PropertyName is the name of
// the property to be displayed

<DisplayTypeInfo>:
<int> // 0 : No display
// 1 : Display name only
// 2 : Display value only
// 3 : Display both name and value
// 4: Display evaluated value only
// 5: Display both name and evaluated value

Definition Manager Script Commands 23-70


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<DisplayLocationInfo>:
<int> // 0 : Left
// 1 : Top
// 2 : Right
// 3 : Bottom
// 4 : Center
// 5 : Custom placement

<GraphicsDataInfo>:
Array("NAME:Graphics",
// one or more of the following
<RectInfo>,
<CircleInfo>,
<ArcInfo>,
<LineInfo>,
<PolygonInfo>,
<TextInfo>,
<ImageInfo>)

<RectInfo>:
"Rect:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<real>, // angle, in radians
<real>, // x position of center
<real>, // y position of center
<real>, // width
< real>) // height

Definition Manager Script Commands 23-71


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<CircleInfo>:
"Circle:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<real>, // x position of center
<real>, // y position of center
< real>) // radius

<ArcInfo>:
"Arc:=", Array(<real>, // line width
<int>, // line pattern
<int>, // color
<real>, // x position of center
<real>, // y position of center
< real>, // radius
<real>, // start angle, in radians
<end>) // end angle, in radians

<LineInfo>:
"Line:=", Array(<real>, // line width
<int>, // line pattern
<int>, // color
<PointInfo>, // must specify at least 2 points
<PointInfo>...)
<PointInfo>:
<real>, // x position
<real> // y position

<PolygonInfo>:
"Polygon:=", Array(<real>, // line width

Definition Manager Script Commands 23-72


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<int>, // fill pattern


<int>, // color
<PointInfo>, // must specify at least 3 points
<PointInfo>...)

<TextInfo>:
"Text:=", Array(<real>, // x position
<real>, // y position
<real>, // angle, in radians
<Justification>,
<bool>, // is plotter font
<string>, // font name
<int>, // color
<string>) // text string

<Justification>:
<int> // 0 : left top
// 1 : left base
// 2 : left bottom
// 3 : center top
// 4 : center base
// 5 : center bottom
// 6 : right top
// 7 : right base
// 8 : right bottom

<ImageInfo>:
"Image:=", Array(<RectInfo>,
<ImageData>,
<bool>) // is mirrored

Definition Manager Script Commands 23-73


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<ImageData>:
<string>, // file path
<int>, // 0 : use the file path and link to it
// 1 : ignore file path and use next parameter
<string> // text data, only present if preceding int is 1

VB Example:
oModelManager.Add Array("NAME:MyModel",_
"ModTime:=", 1070989137, _
"Library:=", "", _
"LibLocation:=", "Project", _
Array("NAME:PinDef", _
"Pin:=", Array ("newpin0", _
0.00254, _
0, _
0, _
"N",_
0, _
0.00254, _
false, _
0, _
true, _
"",_
false, _
false)), _
Array("NAME:PinDef", _
"Pin:=", Array ("newpin1", _
-0.00254, _
0, _
3.14159265358979, _

Definition Manager Script Commands 23-74


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"N",_
0, _
0.00254, _
false, _
0, _
true, _
"",_
false, _
false)),
Array("NAME:Graphics", _
"Rect:=", Array(0, _
0, _
12566272, _
0, _
4.33680868994202e-019, _
-0.000635, _
0.00508, _
0.002794), _
"Circle:=", Array(0, _
0, _
12566272, _
0.000127, _
-0.000635, _
0.000635)))
ConvertToDynamic
Use: Build a new dynamic model based on an existing parametric model.
Command: Right-click on a model under Definitions/Models in the Project Tree and choose Con-
vertToDynamic.
Syntax: ConvertToDynamic(defName, newname)
Return Value: <newname> // Name of the new model added

Definition Manager Script Commands 23-75


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters: <defName> // Model that is the base for the new con-
version
VB Example:
Dim newname
newname = oModelManager.ConvertToDynamic([in] BSTR defName, [out,
retval] BSTR* newName);
ConvertToParametric
Use: Build a new parametric model based on an existing dynamic model.
Command: Right-click on a model under Definitions/Models in the Project Tree and choose Con-
vertToParametric.
Syntax: ConvertToParametric(defName, newname)
Return Value: <newname> // Name of the new model added
Parameters: <defName> // Model that is the base for the new con-
version
VB Example: Dim newname
newname = oModelManager.ConvertToParametric([in] BSTR defName, [out, retval]
BSTR* newName);
Edit [deprecated]
Deprecated command — please use EditWithComps.
EditWithComps [model manager]
Use: Edit an existing model.
Command: None
Syntax: EditWithComps <ModelName>,
Array("NAME:<NewModelName>",
"ModTime:=", <ModifiedTimeInfo>,
"Library:=", <string>, // Library name
"LibLocation:=", <string>, // Project Location
<PinDefInfo>,
<PinDefInfo>,... // optional, to define pins
<GraphicsDataInfo>, // optional, to define graphics
<PropDisplayMapInfo>), // optional, to define property displays
Array(<ListOfComponentNames>) // Component names

Definition Manager Script Commands 23-76


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Return Value: <string>


// composite name of the model.
// If the name requested conflicts with the name of an existing
// model, the requested name is altered to be unique.
// The name returned reflects any change made to be unique.

Parameters: <ModelName>:
<string> // composite name of the model being edited

<NewModelName>:
<string> // new simple name for the model

<ModifiedOnInfo>:
An integer that corresponds to the number of seconds that have elapsed
since 00:00 hours, Jan 1, 1970 UTC from the system clock.

<PinDefInfo>:
Array("NAME:PinDef",
"Pin:=", Array (<string>, // pin name
<real>, // x location
<real>, // y location
<real>, // angle in radians
<PinType>,
<real>, // line width
<real>, // line length
<bool>, // mirrored
<int>, // color
<bool>, // true if visible, false if not
<string>, // hidden net name

Definition Manager Script Commands 23-77


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<OptionalPinInfo>, // optional info


<PropDisplayMapInfo>)) // optional

<PinType>:
<string> // "N" : normal pin
// "I" : input pin
// "O" : output pin

<OptionalPinInfo>:
// Specify both or neither
<bool>, // true if name is to be shown
<bool>, // true if number is to be shown

<PropDisplayMapInfo>:
Array("NAME:PropDisplayMap",
<PropDisplayInfo>,
<PropDisplayInfo>,...)

<PropDisplayInfo>:
<NameString>, Array(<DisplayTypeInfo>,
<DisplayLocationInfo>,
<int>, // optional, level number
<TextInfo>)

<NameString>:
<string> // PropertyName:=, where PropertyName is the name of
// the property to be displayed

<DisplayTypeInfo>:
<int> // 0 : No display

Definition Manager Script Commands 23-78


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

// 1 : Display name only


// 2 : Display value only
// 3 : Display both name and value
// 4: Display evaluated value only
// 5: Display both name and evaluated value

<DisplayLocationInfo>:
<int> // 0 : Left
// 1 : Top
// 2 : Right
// 3 : Bottom
// 4 : Center
// 5 : Custom placement

<GraphicsDataInfo>:
Array("NAME:Graphics",
// one or more of the following
<RectInfo>,
<CircleInfo>,
<ArcInfo>,
<LineInfo>,
<PolygonInfo>,
<TextInfo>,
<ImageInfo>)

<RectInfo>:
"Rect:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<real>, // angle, in radians

Definition Manager Script Commands 23-79


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<real>, // x position of center


<real>, // y position of center
<real>, // width
< real>) // height

<CircleInfo>:
"Circle:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<real>, // x position of center
<real>, // y position of center
< real>) // radius

<ArcInfo>:
"Arc:=", Array(<real>, // line width
<int>, // line pattern
<int>, // color
<real>, // x position of center
<real>, // y position of center
< real>, // radius
<real>, // start angle, in radians
<end>) // end angle, in radians

<LineInfo>:
"Line:=", Array(<real>, // line width
<int>, // line pattern
<int>, // color
<PointInfo>, // must specify at least 2 points
<PointInfo>...)
<PointInfo>:

Definition Manager Script Commands 23-80


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<real>, // x position
<real> // y position

<PolygonInfo>:
"Polygon:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<PointInfo>, // must specify at least 3 points
<PointInfo>...)

<TextInfo>:
"Text:=", Array(<real>, // x position
<real>, // y position
<real>, // angle, in radians
<Justification>,
<bool>, // is plotter font
<string>, // font name
<int>, // color
<string>) // text string

<Justification>:
<int> // 0 : left top
// 1 : left base
// 2 : left bottom
// 3 : center top
// 4 : center base
// 5 : center bottom
// 6 : right top
// 7 : right base
// 8 : right bottom

Definition Manager Script Commands 23-81


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<ImageInfo>:
"Image:=", Array(<RectInfo>,
<ImageData>,
<bool>) // is mirrored

<ImageData>:
<string>, // file path
<int>, // 0 : use the file path and link to it
// 1 : ignore file path and use next parameter
<string> // text data, only present if preceding int is 1

<ListOfComponentNames>:
<string>,<string> ...
// The list may be empty. When not empty, each string that is listed is a component
// that references the model to be edited. Prior to editing, a clone of the model is
// made, and the components that are listed are modified so that they now refer to
// the clone.

VB Example:
Dim nam
oModelManager.EditWithComps_
("Nexxim Circuit Elements\Distributed\Distributed:bendo", _
Array("NAME:bendo new name", _
"ModTime:=", 1152722165, _
"Library:=", "Nexxim Circuit Elements\Distributed\Distributed", _
"LibLocation:=", "SysLibrary", _
Array("NAME:PinDef", _
"Pin:=", Array( "n1", _
-0.00254, _

Definition Manager Script Commands 23-82


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

0.00254, _
0, _
"N", _
0, _
0, _
false, _
0, _
true, _
"", _
false, _
false)), _
Array("NAME:PinDef", _
"Pin:=", Array( "n2", _
0.00254, _
-0.00254, _
1.5708, _
"N", _
0, _
0, _
false, _
0, _
true, _
"", _
false, _
false)), _
Array("NAME:Graphics", _
"Polygon:=", Array( 0, 0, 12566272, 0, 0.00381, 0, .00127, 0.00127,
_
0.00127, 0.00127, 0, 0.00381, 0, 0.00381, _
0.002032, 0.00127, 0.00381), _

Definition Manager Script Commands 23-83


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Line:=", Array(0, 1, 12566272, -0.00254, 0.00254, 0, .00254), _


"Line:=", Array(0, 1, 12566272, 0.00254, -0.00254, .00254, 0)), _
Array("NAME:PropDisplayMap", _
"W:=", Array(3, _
5, _
0, _
"Text:=", Array( 2.1684E-019, _
0.00504119, _
0, _
1, _
5, _
false, _
"Arial", _
0, _
"W=***"))))), _
rray("MY_COMP")
Export [model manager]
Use: Exports model(s) to a library
Command: Tools > Edit Configured Libraries > Models > Export to Library
Syntax: Export Array("NAME:<LibraryName>",
<ModelName>,
<ModelName>...),
<LibraryLocation>
Return Value: None
Parameters: <LibraryName>:
<string> // name of the library

<ModelName>:
<string> // composite name of model to export

Definition Manager Script Commands 23-84


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<LibraryLocation>:
<string> // location of the library in <LibraryName>
// One of "Project", "PersonalLib", or "UserLib"

VB Example:
oModelManager.Export _
Array("NAME Nexxim Circuit Ele-
ments\Distributed\Distributed:bendo:mylib", _ "myModel"), "Per-
sonalLib"

Python Export (["NAME:<LibraryName>", <ComboName>, <ComboName>...],


Syntax <LibraryLocation>)
Python oModelManager.Export (["NAME:mylib", "model1", "model2"])
Example

GetData [model manager]


Use: Gets data that describes the definition.
Command: None
Syntax: GetData(<DefinitionName>)
Return Value: <DefinitionData> This is an array of data for the definition.
Parameters: <DefinitionName>:
<string> // composite name of the definition to edit
VB Example:
Dim ModelData
ModelData = oModelManager.GetData("Nexxim Circuit Ele-
ments\Hspice:nexx_bjt_npn")

Note:

GetData allows the user to access definition information, make modifications, and then
use the Edit or EditWithComps script commands to save the modified definition. Accord-
ingly, for each type of definition, the array data returned to GetData should be the same
array information that is supplied to the Edit or EditWithComps commands.

Definition Manager Script Commands 23-85


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python Syn- GetData(<ComboName>)


tax

Python dataArray = oModelManager.GetData


Example ("mylib:mymodel")

GetNames [model manager]


Use: Returns the names of the models (used and unused) in a design. The following script com-
mand, IsUsed, can then be used to separate used and unused models.
Command: None
Syntax: GetNames()
Return Value: An array of strings
Parameters: None
VB Example:
Dim modelNames
modelNames = oModelManager.GetNames()

Python Syn- GetNames()


tax

Python modelnames = oModelManager.GetNames()


Example

IsUsed [model manager]


Use: Used to determine if a model is used in the design.
Command: None
Syntax: IsUsed(<ModelName>)
Return Value: <Boolean> // true if the specified model is used in the design
Parameters: <ModelName>:
<string>
VB Example:
Dim isUsed
isUsed = oModelManager.IsUsed("MyModel")

Definition Manager Script Commands 23-86


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python IsUsed(<ComboName>)
Syntax

Python isused = oModelManager.IsUsed ("mylib:mymodel")


Example

Remove [model manager]


Use: Removes a model from a library
Command: Tools > Edit Configured Libraries > Models > Remove Model
Syntax: Remove <ModelName>,
<IsProjectModel>,
<LibraryName>,
<LibraryLocation>
Return Value: None
Parameters: <ModelName>:
<string> // composite name of the model to remove

<IsProjectModel>:
<bool>

<LibraryName>:
<string> // name of the library

<LibraryLocation>:
<string> // location of the library in <LibraryName>
// One of "Project", "PersonalLib", or "UserLib"

VB Example:
oModelManager.Remove "Nexxim Circuit Ele-
ments\Distributed\Distributed:bendo", true, "Project"

Python Syn- Remove (<ModelName>, <IsLocal>, <LibraryName>, <LibraryLocation>)


tax

Definition Manager Script Commands 23-87


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python
oModelManager.Export([
Example "NAME:mylib", "model1", "model2"])

RemoveUnused [model manager]


Use: Removes models that are not used in the design.
Command: Project->Remove Unused Definitions is similar but operates slightly different and
does not record script commands.
Syntax: RemoveUnused()
Return Value: <bool> True if one or more models are removed.
Parameters: None
VB Example:
Dim removedDefs
removedDefs = oModelManager.RemoveUnused()

Note:

The order of calls to RemoveUnused is significant. As a result, removing definitions in an


unordered fashion may cause other models in dependent definitions to be rendered unus-
able.

Also, the model and footprint of an unused component are not unusable until after the
component itself is removed using the Component Manager Remove script.

Python RemoveUnused()
Syntax

Python thereWereExtras = oModelManager.RemoveUnused()


Example

Symbol Manager Script Commands


The symbol manager provides access to symbols in a project. The manager object is accessed via
the definition manager.
Set oDefinitionManager = oProject.GetDefinitionManager()
Set oSymbolManager = oDefinitionManager.GetManager("Symbol")
The symbol manager script commands are listed below.

Definition Manager Script Commands 23-88


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Add
BringToFront
Edit
EditWithComps
Export
GetData
GetNames
IsUsed
Remove
RemoveUnused
Add [symbol manager]
Use: Add a symbol
Command: Tools > Edit Configured Libraries > Symbols > Add Symbol
Syntax: Add Array("NAME:<SymbolName>",
"ModTime:=", <ModifiedTimeInfo>,
"Library:=", "", // Library name
"LibLocation:=", "Project", // Project Location
<PinDefInfo>,
<PinDefInfo>,... // optional, to define pins
<GraphicsDataInfo>, // optional, to define graphics
<PropDisplayMapInfo>)) // optional, to define property displays

Return Value: <string>


// composite name of the symbol.
// If the name requested conflicts with the name of an existing
// symbol, the requested name is altered to be unique.
// The name returned reflects any change made to be unique.

Parameters: <SymbolName>:
<string> // simple name of the symbol being added

Definition Manager Script Commands 23-89


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<ModifiedOnInfo>:
An integer that corresponds to the number of seconds that have elapsed
since 00:00 hours, Jan 1, 1970 UTC from the system clock.

<PinDefInfo>:
Array("NAME:PinDef",
"Pin:=", Array (<string>, // pin name
<real>, // x location
<real>, // y location
<real>, // angle in radians
<PinType>,
<real>, // line width
<real>, // line length
<bool>, // mirrored
<int>, // color
<bool>, // true if visible, false if not
<string>, // hidden net name
<OptionalPinInfo>, // optional info
<PropDisplayMapInfo>)) // optional

<PinType>:
<string> // "N" : normal pin
// "I" : input pin
// "O" : output pin

<OptionalPinInfo>:
// Specify both or neither
<bool>, // true if name is to be shown
<bool>, // true if number is to be shown

Definition Manager Script Commands 23-90


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<PropDisplayMapInfo>:
Array("NAME:PropDisplayMap",
<PropDisplayInfo>,
<PropDisplayInfo>,...)

<PropDisplayInfo>:
<NameString>, Array(<DisplayTypeInfo>,
<DisplayLocationInfo>,
<int>, // optional, level number
<TextInfo>)
<NameString>:
<string> // PropertyName:=, where PropertyName is the name of
// the property to be displayed

<DisplayTypeInfo>:
<int> // 0 : No display
// 1 : Display name only
// 2 : Display value only
// 3 : Display both name and value
// 4: Display evaluated value only
// 5: Display both name and evaluated value

<DisplayLocationInfo>:
<int> // 0 : Left
// 1 : Top
// 2 : Right
// 3 : Bottom
// 4 : Center

Definition Manager Script Commands 23-91


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

// 5 : Custom placement

<GraphicsDataInfo>:
Array("NAME:Graphics",
// one or more of the following
<RectInfo>,
<CircleInfo>,
<ArcInfo>,
<LineInfo>,
<PolygonInfo>,
<TextInfo>,
<ImageInfo>)

<RectInfo>:
"Rect:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<real>, // angle, in radians
<real>, // x position of center
<real>, // y position of center
<real>, // width
< real>) // height

<CircleInfo>:
"Circle:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<real>, // x position of center
<real>, // y position of center
< real>) // radius

Definition Manager Script Commands 23-92


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<ArcInfo>:
"Arc:=", Array(<real>, // line width
<int>, // line pattern
<int>, // color
<real>, // x position of center
<real>, // y position of center
< real>, // radius
<real>, // start angle, in radians
<end>) // end angle, in radians

<LineInfo>:
"Line:=", Array(<real>, // line width
<int>, // line pattern
<int>, // color
<PointInfo>, // must specify at least 2 points
<PointInfo>...)
<PointInfo>:
<real>, // x position
<real> // y position

<PolygonInfo>:
"Polygon:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<PointInfo>, // must specify at least 3 points
<PointInfo>...)

<TextInfo>:
"Text:=", Array(<real>, // x position

Definition Manager Script Commands 23-93


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<real>, // y position
<real>, // angle, in radians
<Justification>,
<bool>, // is plotter font
<string>, // font name
<int>, // color
<string>) // text string

<Justification>:
<int> // 0 : left top
// 1 : left base
// 2 : left bottom
// 3 : center top
// 4 : center base
// 5 : center bottom
// 6 : right top
// 7 : right base
// 8 : right bottom

<ImageInfo>:
"Image:=", Array(<RectInfo>,
<ImageData>,
<bool>) // is mirrored

<ImageData>:
<string>, // file path
<int>, // 0 : use the file path and link to it
// 1 : ignore file path and use next parameter
<string> // text data, only present if preceding int is 1

VB Example:

Definition Manager Script Commands 23-94


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oSymbolManager.Add Array("NAME:MySymbol",_
"ModTime:=", 1070989137, _
"Library:=", "", _
"LibLocation:=", "Project", _
Array("NAME:PinDef", _
"Pin:=", Array ("newpin0", _
0.00254, _ 0, _
0, _
"N",_
0, _
0.00254, _
false, _
0, _
true, _
"",_
false, _
false)), _
Array("NAME:PinDef", _
"Pin:=", Array ("newpin1", _
-0.00254, _
0, _
3.14159265358979, _
"N",_
0, _
0.00254, _
false, _
0, _
true, _
"",_
false, _

Definition Manager Script Commands 23-95


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

false)),
Array("NAME:Graphics", _
"Rect:=", Array(0, _
0, _
12566272, _
0, _
4.33680868994202e-019, _
-0.000635, _
0.00508, _
0.002794), _
"Circle:=", Array(0, _
0, _
12566272, _
0.000127, _
0.000635, _
0.000635)))

BringToFront [symbol manager]


Use: Changes the drawing for the symbol so that the specified objects are drawn on top of other
overlapping objects.
Command: Draw > Bring To Front
Syntax: BringToFront Array("NAME:Selections", "Selections:=", Array (<Object>, <Object>, ...))
Return Value: None
Parameters: <Object>
<string> // object to bring to the front
VB Example:
oDefinitionEditor.BringToFront Array("NAME:Selections", "Selec-
tions:=", Array( "SchObj@10"))

Edit [deprecated]
Deprecated command — please use EditWithComps.

Definition Manager Script Commands 23-96


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

EditWithComps [symbol manager]


Use: Edit an existing symbol.
Command: None
Syntax: EditWithComps <SymbolName>,
Array("NAME:<NewSymbolName>",
"ModTime:=", <ModifiedTimeInfo>,
"Library:=", <string>, // Library name
"LibLocation:=", <string>, // Project Location
<PinDefInfo>,
<PinDefInfo>,... // optional, to define pins
<GraphicsDataInfo>, // optional, to define graphics
<PropDisplayMapInfo>), // optional, to define property displays
Array(<ListOfComponentNames>) // Component names

Return Value: <string>


// composite name of the symbol.
// If the name requested conflicts with the name of an existing
// symbol, the requested name is altered to be unique.
// The name returned reflects any change made to be unique.

Parameters: <SymbolName>:
<string> // composite name of the symbol being edited

<NewSymbolName>:
<string> // new simple name for the symbol

<ModifiedOnInfo>:
An integer that corresponds to the number of seconds that have elapsed
since 00:00 hours, Jan 1, 1970 UTC from the system clock.

Definition Manager Script Commands 23-97


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<PinDefInfo>:
Array("NAME:PinDef",
"Pin:=", Array (<string>, // pin name
<real>, // x location
<real>, // y location
<real>, // angle in radians
<PinType>,
<real>, // line width
<real>, // line length
<bool>, // mirrored
<int>, // color
<bool>, // true if visible, false if not
<string>, // hidden net name
<OptionalPinInfo>, // optional info
<PropDisplayMapInfo>)) // optional

<PinType>:
<string> // "N" : normal pin
// "I" : input pin
// "O" : output pin

<OptionalPinInfo>:
// Specify both or neither
<bool>, // true if name is to be shown
<bool>, // true if number is to be shown

<PropDisplayMapInfo>:
Array("NAME:PropDisplayMap",
<PropDisplayInfo>,
<PropDisplayInfo>,...)

Definition Manager Script Commands 23-98


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<PropDisplayInfo>:
<NameString>, Array(<DisplayTypeInfo>,
<DisplayLocationInfo>,
<int>, // optional, level number
<TextInfo>)

<NameString>:
<string> // PropertyName:=, where PropertyName is the name of
// the property to be displayed

<DisplayTypeInfo>:
<int> // 0 : No display
// 1 : Display name only
// 2 : Display value only
// 3 : Display both name and value
// 4: Display evaluated value only
// 5: Display both name and evaluated value

<DisplayLocationInfo>:
<int> // 0 : Left
// 1 : Top
// 2 : Right
// 3 : Bottom
// 4 : Center
// 5 : Custom placement

<GraphicsDataInfo>:
Array("NAME:Graphics",
// one or more of the following

Definition Manager Script Commands 23-99


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<RectInfo>,
<CircleInfo>,
<ArcInfo>,
<LineInfo>,
<PolygonInfo>,
<TextInfo>,
<ImageInfo>)

<RectInfo>:
"Rect:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<real>, // angle, in radians
<real>, // x position of center
<real>, // y position of center
<real>, // width
< real>) // height

<CircleInfo>:
"Circle:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<real>, // x position of center
<real>, // y position of center
< real>) // radius

<ArcInfo>:
"Arc:=", Array(<real>, // line width
<int>, // line pattern
<int>, // color

Definition Manager Script Commands 23-100


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<real>, // x position of center


<real>, // y position of center
< real>, // radius
<real>, // start angle, in radians
<end>) // end angle, in radians

<LineInfo>:
"Line:=", Array(<real>, // line width
<int>, // line pattern
<int>, // color
<PointInfo>, // must specify at least 2 points
<PointInfo>...)
<PointInfo>:
<real>, // x position
<real> // y position

<PolygonInfo>:
"Polygon:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<PointInfo>, // must specify at least 3 points
<PointInfo>...)

<TextInfo>:
"Text:=", Array(<real>, // x position
<real>, // y position
<real>, // angle, in radians
<Justification>,
<bool>, // is plotter font
<string>, // font name

Definition Manager Script Commands 23-101


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<int>, // color
<string>) // text string

<Justification>:
<int> // 0 : left top
// 1 : left base
// 2 : left bottom
// 3 : center top
// 4 : center base
// 5 : center bottom
// 6 : right top
// 7 : right base
// 8 : right bottom

<ImageInfo>:
"Image:=", Array(<RectInfo>,
<ImageData>,
<bool>) // is mirrored

<ImageData>:
<string>, // file path
<int>, // 0 : use the file path and link to it
// 1 : ignore file path and use next parameter
<string> // text data, only present if preceding int is 1

<ListOfComponentNames>:
<string>,<string> ...
// The list may be empty. When not empty, each string that is listed is a component
// that references the symbol to be edited. Prior to editing, a clone of the symbol is
// made, and the components that are listed are modified so that they now refer to

Definition Manager Script Commands 23-102


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

// the clone.

VB Example:
Dim nam
oSymbolManager.EditWithComps _
("Nexxim Circuit Elements\Distributed\Distributed:bendo", _
Array("NAME:bendo new name", _
"ModTime:=", 1152722165, _
"Library:=", "Nexxim Circuit Elements\Distributed\Distributed", _
"LibLocation:=", "SysLibrary", _
Array("NAME:PinDef", _
"Pin:=", Array( "n1", _
-0.00254, _
0.00254, _
0, _
"N", _
0, _
0, _
false, _
0, _
true, _
"", _
false, _
false)), _
Array("NAME:PinDef", _
"Pin:=", Array( "n2", _
0.00254, _
-0.00254, _
1.5708, _
"N", _

Definition Manager Script Commands 23-103


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

0, _
0, _
false, _
0, _
true, _
"", _
false, _
false)), _
Array("NAME:Graphics", _
"Polygon:=", Array( 0, 0, 12566272, 0, 0.00381, 0, .00127, 0.00127,
_
0.00127, 0.00127, 0, 0.00381, 0, 0.00381, _
0.002032, 0.00127, 0.00381), _
"Line:=", Array(0, 1, 12566272, -0.00254, 0.00254, 0, .00254), _
"Line:=", Array(0, 1, 12566272, 0.00254, -0.00254, .00254, 0)), _
Array("NAME:PropDisplayMap", _
"W:=", Array(3, _
5, _
0, _
"Text:=", Array( 2.1684E-019, _
0.00504119, _
0, _
1, _
5, _
false, _
"Arial", _
0, _
"W=***"))))), _
Array("MY_COMP")

Definition Manager Script Commands 23-104


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Export [symbol manager]


Use: Exports symbol(s) to a library
Command: Tools > Edit Configured Libraries > Symbols > Export to Library
Syntax: Export Array("NAME:<LibraryName>",
<SymbolName>,
<SymbolName>...),
<LibraryLocation>
Return Value: None
Parameters: <LibraryName>:
<string> // name of the library

<SymbolName>:
<string> // composite name of symbol to export

<LibraryLocation>:
<string> // location of the library in <LibraryName>
// One of "Project", "PersonalLib", or "UserLib"

VB Example:
oSymbolManager.Export _
Array("NAME Nexxim Circuit Ele-
ments\Distributed\Distributed:bendo:mylib", _ "mySymbol"), "Per-
sonalLib"
GetData [symbol manager]
Use: Gets data that describes the definition.
Command: None
Syntax: GetData(<DefinitionName>)
Return Value: <DefinitionData> This is an array of data for the definition.
Parameters: <DefinitionName>:
<string> // composite name of the definition to edit
VB Example:

Definition Manager Script Commands 23-105


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim symbolData
symbolData = oSymbolManager.GetData("Nexxim Circuit Ele-
ments\Hspice:nexx_bjt_npn")

Note:

GetData allows the user to access definition information, make modifications, and then
use the Edit or EditWithComps script commands to save the modified definition. Accord-
ingly, for each type of definition, the array data returned to GetData should be the same
array information that is supplied to the Edit or EditWithComps commands.

GetNames [symbol manager]


Use: Returns the names of the symbols (used and unused) in a design. The following script com-
mand, IsUsed, can then be used to separate used and unused symbols.
Command: None
Syntax: GetNames()
Return Value: An array of strings
Parameters: None
VB Example:
Dim symbolNames
symbolNames = oSymbolManager.GetNames()
IsUsed [symbol manager]
Use: Used to determine if a symbol is used in the design.
Command: None
Syntax: IsUsed(<SymbolName>)
Return Value: <Boolean> // true if the specified symbol is used in the design
Parameters: <SymbolName>:
<string>
VB Example: Dim isUsed
isUsed = oSymbolManager.IsUsed("MySymbol")
Remove [symbol manager]
Use: Removes a symbol from a library
Command: Tools > Edit Configured Libraries > Symbols > Remove Symbol

Definition Manager Script Commands 23-106


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Syntax: Remove <SymbolName>,


<IsProjectSymbol>,
<LibraryName>,
<LibraryLocation>
Return Value: None
Parameters: <SymbolName>:
<string> // composite name of the symbol to remove

<IsProjectSymbol>:
<bool>

<LibraryName>:
<string> // name of the library

<LibraryLocation>:
<string> // location of the library in <LibraryName>
// One of "Project", "PersonalLib", or "UserLib"

VB Example:
oSymbolManager.Remove "Nexxim Circuit Ele-
ments\Distributed\Distributed:bendo", true, "Project"

RemoveUnused [symbol manager]


Use: Removes symbols that are not used in the design.
Command: Project->Remove Unused Definitions is similar but operates slightly different and
does not record script commands.
Syntax: RemoveUnused()
Return Value: <bool> True if one or more symbols are removed.
Parameters: None
VB Example:
Dim removedDefs

Definition Manager Script Commands 23-107


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

removedDefs = oSymbolManager.RemoveUnused()

Note:

The order of calls to RemoveUnused is significant. As a result, removing definitions in an


unordered fashion may cause other symbols in dependent definitions to be rendered
unusable.

Also, the symbol and footprint of an unused component are not unusable until after the
component itself is removed using the Component Manager Remove script.

Footprint Manager Script Commands


The footprint manager provides access to footprints in a project. The manager object is accessed
via the definition manager.
Set oDefinitionManager = oProject.GetDefinitionManager()
Set oFootprintManager = oDefinitionManager.GetManager("Footprint")
The footprint manager script commands are listed below:
Add
Edit
EditWithComps
Export
GetData
GetNames
IsUsed
Remove
RemoveUnused
Add [footprint manager]
Use: Add a footprint
Command: Tools > Edit Configured Libraries > Footprints > Add Footprint
Syntax: Add Array("NAME:<FootprintName>,
"ModTime:=", <ModifiedOnInfo>,
"Library:=", "",

Definition Manager Script Commands 23-108


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"LibLocation:=", "Project",
"OkayToMirror:=", <bool>,
"DefUnits:=", <UnitType>,
Array(NAME:Lyrs",
"Layer:=", <LayerArray>,
"Layer:=", <LayerArray>…,
"SLayer:=", <StackupLayerArray>,
"SLayer:=", <StackupLayerArray>...),
"ActLyr:=", <string>, // name of active layer
"Tol:=", <ToleranceArray> // optional
<PrimitivesInfo>, // optional
<PinsInfo>, // optional
<ViasInfo>, // optional
<EdgeportsInfo>, // optional
<ComponentPropertyInfo>,
<ScriptInfo>) // optional, specified for scripted footprints

Return Value: <string>


// composite name of the footprint.
// If the name requested conflicts with the name of an existing
// footprint, the requested name is altered to be unique.
// The name returned reflects any change made to be unique.

Parameters: <FootprintName>:
<string> // simple name of footprint to create
<ModifiedOnInfo>:
An integer that corresponds to the number of seconds that have elapsed
since 00:00 hours, Jan 1, 1970 UTC from the system clock.

<UnitType>:

Definition Manager Script Commands 23-109


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<string> // default length units to use if units are not specified in other
// parameters

<LayerArray>:
Array("N:=", <string>, // layer name
"ID:=", <int> ,
"T:=", <LayerTypeInfo>, // layer type
"TB:=", <TopBottomInfo>,
"Col:=", <int>, // optional - color
"Pat:=", <int>, // optional - fill pattern
"Vis:=", <bool>, // optional - are objects on layer visible
"Sel:=", <bool>, // optional - are objects on layer selectable
"L:=", <bool>) // optional
// are objects on layer locked (can't be edited)

<LayerTypeInfo>:
<string> // one of: signal, dielectric, metalized signal, assembly, silkscreen, soldermask,
solderpaste, glue, or user

<TopBottomInfo>:
<string> // one of: top, neither, bottom, or template

<StackupLayerArray>:
Array(<LayerArray>,
"Elev:=", <ElevationInfo>,
"SubL:=", Array("Th:=", <Dimension>,
"LElev:=", <Dimension>,
"R:=", <Dimension>,
"M:=", <MaterialInfo>))

<ElevationInfo>:

Definition Manager Script Commands 23-110


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<string> // "top" - snap to top


// "mid" - snap to middle
// "bot" - snap to bottom
// "edit" - manual edit
// "none"

<Dimension>:
<string> // real number, may include units

<MaterialInfo>:
<string> // name of the layer material

<ToleranceArray>:
Array(<real>, // distance tolerance
<real>, // angle tolerance (radians)
<real>) // dimensionless tolerance

<PrimitivesInfo>:
Array("NAME:Prims",
// one or more of the following
<RectInfo>,
<CircleInfo>,
<ArcInfo>,
<LineInfo>,
<PolygonInfo>,
<TextInfo>,
<ImageInfo>)

<RectInfo>:
"Rect:=", Array(<real>, // line width

Definition Manager Script Commands 23-111


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<int>, // fill pattern


<int>, // color
<real>, // angle, in radians
<real>, // x position of center
<real>, // y position of center
<real>, // width
< real>) // height

<CircleInfo>:
"Circle:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<real>, // x position of center
<real>, // y position of center
< real>) // radius

<ArcInfo>:
"Arc:=", Array(<real>, // line width
<int>, // line pattern
<int>, // color
<real>, // x position of center
<real>, // y position of center
< real>, // radius
<real>, // start angle, in radians
<end>) // end angle, in radians

<LineInfo>:
"Line:=", Array(<real>, // line width
<int>, // line pattern
<int>, // color

Definition Manager Script Commands 23-112


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<PointInfo>, // must specify at least 2 points


<PointInfo>...)
<PointInfo>:
<real>, // x position
<real> // y position

<PolygonInfo>:
"Polygon:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<PointInfo>, // must specify at least 3 points
<PointInfo>...)

<TextInfo>:
"Text:=", Array(<real>, // x position
<real>, // y position
<real>, // angle, in radians
<Justification>,
<bool>, // is plotter font
<string>, // font name
<int>, // color
<string>) // text string
<Justification>: <int>
// 0 : left top
// 1 : left base
// 2 : left bottom
// 3 : center top
// 4 : center base
// 5 : center bottom
// 6 : right top

Definition Manager Script Commands 23-113


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

// 7 : right base
// 8 : right bottom

<ImageInfo>:
"Image:=", Array(<RectInfo>,
<ImageData>,
<bool>) // is mirrored

<ImageData>:
<string>, // file path
<int>, // 0 : use the file path and link to it
// 1 : ignore file path and use next parameter
<string> // text data, only present if preceding int is 1

<PinsInfo>:
Array("NAME:Pins",
"P:=", <PinArray>,
"P:=", <PinArray>,...)

<PinArray>:
Array("Port:=", Array("Id:=", <int>,
"Clr:=", <real>, // optional - clearance
"N:=", <string>), // pin name
"Pos:=", Array("x:=", <Location>, // padstack (x,y) position
"y:=", <Location>),
"VRt:=", <Angle>, // optional - rotation
"HD:=", <Size>, // optional - hole diameter
<PadstackImplementationInfo>)

<Location>:

Definition Manager Script Commands 23-114


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<string> specifying real number and units (may use variables)

<Angle>:
<string> specifying angle with a real number and units

<Size>:
<string> specifying size with a real number and units

<PadstackImplementationInfo>:
If another with the same implementation has already been specified:
"Ref:=", <int> // id of the other
If not:
"Ref:=", <string>, // name
"Frm:=", <int>, // id of highest layer
"To:=", <int>, // id of lowest layer
<LayerPlacementInfo>,
"Man:=", <int>, // optional, 1 if manually placed, 0 if not (default)
"Use:=", Array(<PadUseInfo>, <PadUseInfo>…) // array may be empty

<LayerPlacementInfo>:
"Lyr:=", Array("Mrg:=", <int>, // optional,
// 1 if all layers have been merged (default)
// 0 if layer are not merged
"Flp:=", <int>, // optional,
// 1 if placed bottom up
// 0 if not (default)
"Map:=", <ParentToLocalLayerInfo>)

<ParentToLocalLayerInfo>:
Array("U:=", <DirectionOfUniqueness>,

Definition Manager Script Commands 23-115


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"F:=", Array(<int>, <int>, …), // forward mapping


// -1 is not mapped
"B:=", Array(<int>, <int>, …)) // backward mapping
// -1 is not mapped

<PadUseInfo>:
"Pad:=", Array("Lid:=", <int>, // layer id
"T:=", <string>, // type : "connected", "thermal",
// "no_pad, "not_connected",
// or "not_connected_thermal"
"Man:=", <int>) // optional, 1 if manually placed
// 0 if not (default)

<DirectionOfUniqueness>:
<string> // one of "forward", "backward", or "two ways"

<ViasInfo>:
Array("NAME:Vias", <ViaInfo>, <ViaInfo>…)

<ViaInfo>:
"V:=", Array("Id:=", <int>,
"N:=", <string>, // name
"Pos:=", Array("x:=", <Location>, // via (x,y) position
"y:=", <Location>),
"VRt:=", <Angle>, // optional - rotation
<ImplementationInfo>

<EdgeportsInfo>:
Array("NAME:EPorts", <EdgePortArray>, <EdgePortArray>…)

Definition Manager Script Commands 23-116


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<EdgePortArray>:
Array("NAME:EP",
"LP:=", Array("Id:=", <int>, // port id
"N:=", <string>), // port name
"Eo:=", Array(<edge description>, <edge description>,...))

<edge description> for primitive edges

"et:=", "pe", "pr:=", <id>, "ei:=", <edge#>

<id>: integer that is the primitive id

<edge#>: integer that is the edge number on the primitive

<edge description> for via edges

"et:=", "pse", "layer:=", <layer id>, "se:=", <via id>,


"sx:=", <start X location>, "sy:=", <start Y location>, "ex:=", <end X location>,
"ey:=", <end Y location>, "h:=", <arc height>, "rad:=", <radians>

<via id>: an integer that is the id of the via to use


<layer id>: an integer that is the id of the layer of the pad of the via to use
<start X location>

<start Y Location>:
   doubles that are the X, Y location of the start point of the edge arc <end X location>
<end Y Location>:
   doubles that are the X, Y location of the end point of the edge arc

<arc height>: double giving the height of the edge arc (0 for a straight edge)

Definition Manager Script Commands 23-117


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<radians>: double giving the arc size in radians (0 for a straight edge)

<ComponentPropertyInfo>:
Array("NAME:CProps",
"VariableProp:=", <VariableInfo>,
"VariableProp:=", <VariableInfo>,
…)

<VariableInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<string>) // value: number, variable, or expression

<ScriptInfo>:
Array("NAME:script",
"language:=", <string>, // one of "javascript" or "vbscript"
"UsesScript:=", true,
"script:=", <string>) // contents of script

VB Example:
oFootprintManager.Add (Array("NAME:BCL", _
"ModTime:=", 1023388445, _
"Library:=", "", _
"LibLocation:=", "Project", _
"OkayToMirror:=", false, _
"DefUnits:=", "mm", _
Array("NAME:Lyrs", _
"Layer:=", Array("N:=", "Measures", _

Definition Manager Script Commands 23-118


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"ID:=", 8, _
"T:=", "measures", _
"Col:=", 4144959, _
"Pat:=", 1), _
"Layer:=", Array("N:=", "Rats", _
"ID:=", 1, _
"T:=", "rat", _
"Col:=", 16711680, _
"Pat:=", 1), _
"Layer:=", Array("N:=", "Errors", _
"ID:=", 2, _
"T:=", "error", _
"Col:=", 255, _
"Pat:=", 1, _
"L:=", true), _
"Layer:=", Array("N:=", "Symbols", _
"ID:=", 3, _
"T:=", "symbol", _
"Col:=", 8323199, _
"Pat:=", 4), _
"Layer:=", Array("N:=", "Assembly", _
"ID:=", 4, _
"T:=", "assembly", _
"TB:=", "top", _
"Col:=", 16711680, _
Pat:=", 3), _
"Layer:=", Array("N:=", "Silkscreen", _
"ID:=", 5, _
"T:=", "silkscreen", _
TB:=", "top", _

Definition Manager Script Commands 23-119


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Col:=", 8454143, _
"Pat:=", 6), _
SLayer:=", Array("Layer:=", Array("N:=", "Cover", _
"ID:=", 12, _
"T:=", "metalizedsignal", _
"Col:=", 32639, _
Pat:=", 7), _
"Elev:=", "mid", _
"SubL:=", Array("Th:=", "0mm", _
"LElev:=", "118.110236220472mil", _
"R:=", "0mm", _
"Mat:=", "")), _
"SLayer:=", Array("Layer:=", Array("N:=", "Dielec3", _
"ID:=", 11, _
"T:=", "dielectric", _
"Col:=", 8323199, _
"Pat:=", 6), _
"Elev:=", "none", _
"SubL:=", Array("Th:=", "1mm", _
"LElev:=", "78.740157480315mil", _
"R:=", "0mm", _
"Mat:=", "")), _
"SLayer:=", Array("Layer:=", Array("N:=", "Trace2", _
"ID:=", 10, _
"T:=", "signal", _
"Col:=", 8355584, _
"Pat:=", 5), _
"Elev:=", "mid", _
"SubL:=", Array("Th:=", "0mm", _
"LElev:=", "78.740157480315mil", _

Definition Manager Script Commands 23-120


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"R:=", "0mm", _
"Mat:=", "")), _
"SLayer:=", Array("Layer:=", Array("N:=", "Dielec2", _
"ID:=", 6, _
"T:=", "dielectric", _
"Col:=", 8323072, _
"Pat:=", 4), _
"Elev:=", "none", _
"SubL:=", Array("Th:=", "1mm", _
"LElev:=", "39.3700787401575mil", _
"R:=", "0mm", _
"Mat:=", "")), _
"SLayer:=", Array("Layer:=", Array("N:=", "Trace1", _
"ID:=", 0, _
"T:=", "signal", _
"Col:=", 32512, _
"Pat:=", 3), _
"Elev:=", "mid", _
"SubL:=", Array("Th:=", "0mm", _
"LElev:=", "39.3700787401575mil", _
"R:=", "0mm", _
"Mat:=", "")), _
"SLayer:=", Array("Layer:=", Array("N:=", "Dielec1", _
"ID:=", 7, _
"T:=", "dielectric", _
"Col:=", 127, _
"Pat:=", 7), _
"Elev:=", "none", _
"SubL:=", Array("Th:=", "1mm", _
"LElev:=", "0mil", _

Definition Manager Script Commands 23-121


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"R:=", "0mil", _
"Mat:=", "")), _
"SLayer:=", Array("Layer:=", Array("N:=", "Ground", _
"ID:=", 9, _
"T:=", "metalizedsignal", _
"Col:=", 4144959, _
"Pat:=", 6), _
"Elev:=", "mid", _
"SubL:=", Array("Th:=", "0mil", _
"LElev:=", "0mil", _
"R:=", "0mil", _
"Mat:=", ""))), _
"ActLyr:=", "Trace2", _
Array("NAME:Prims",
"rect:=", Array("Id:=", 10003, _
"Lyr:=", 10, _
"N:=", "rect101", _
"x:=", "0mm", _
"y:=", "0mm", _
"w:=", "P", _
"h:=", "W", _
"Vds:=", Array()), _
"rect:=", Array("Id:=", 10103, _
"Lyr:=", 0, _
"N:=", "rect103", _
"x:=", "0mm", _
"y:=", "0mm", _
"w:=", "P", _
"h:=", "W", _
"Vds:=", Array())), _

Definition Manager Script Commands 23-122


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:Pins",
"P:=", Array("Port:=", Array("Id:=", 3, "N:=", "n1"), _
"Pos:=", Array("x:=", "-P/2", "y:=", "0mm"), _
"VRt:=", "180deg", _
"Ref:=", "NoPad SMT East", _
"Frm:=", 12, _
"To:=", 9, _
"Lyr:=", Array("Map:=", Array("U:=", "forward",_
"F:=", Array(-1, -1, -1, -1,_
-1, -1, -1, -1,_
-1, -1, 0, -1, -1), _
"B:=", Array(10))), _
"Use:=", Array()), _
"P:=", Array("Port:=", Array("Id:=", 4, "N:=", "n4"),_
"Pos:=", Array("x:=","P/2", "y:=", "0mm"),_
"HD:=", "1mm", _
"Ref:=", 3), _
"P:=", Array("Port:=", Array("Id:=",5, "N:=", "n2"),_
"Pos:=", Array("x:=", "-P/2", "y:=", "0mm"),_
"VRt:=", "180deg",_
"Ref:=", "NoPad SMT East",_
"Frm:=", 12, _
"To:=", 9, _
"Lyr:=", Array("Map:=", Array("U:=", "forward",_
"F:=", Array(0, -1, -1, -1, -1,_
-1, -1, -1, -1, _
-1, -1, -1, -1), _
"B:=", Array(0))), _
"Use:=", Array()), _
"P:=", Array("Port:=", Array("Id:=", 6, "N:=", "n3"), _

Definition Manager Script Commands 23-123


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Pos:=", Array("x:=", "P/2", "y:=", "0mm"),_


"HD:=", "1mm", _
"Ref:=", 5)), _
Array("NAME:Nets"), _
Array("NAME:CProps",
"VariableProp:=", Array("W", _
"UD", _
"", _
"1.5mm"),_
"VariableProp:=", Array("P", _
"UD", _
"", _
10mm"))))

Edit [footprint manager]


Deprecated command — please use EditWithComps.
EditWithComps [footprint manager]
Use: Edit an existing footprint.
Command: None
Syntax: EditWithComps <FootprintName>,
Array("NAME:<NewFootprintName>,
"ModTime:=", <ModifiedOnInfo>,
"Library:=", "",
"LibLocation:=", "Project",
"OkayToMirror:=", <bool>,
"DefUnits:=", <UnitType>,
Array(NAME:Lyrs",
"Layer:=", <LayerArray>,
"Layer:=", <LayerArray>…,
"SLayer:=", <StackupLayerArray>,

Definition Manager Script Commands 23-124


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"SLayer:=", <StackupLayerArray>...),
"ActLyr:=", <string>, // name of active layer
"Tol:=", <ToleranceArray> // optional
<PrimitivesInfo>, // optional
<PinsInfo>, // optional
<ViasInfo>, // optional
<EdgeportsInfo>, // optional
<ComponentPropertyInfo>,
<ScriptInfo>, // optional, specified for scripted footprints
Array(<ListofComponentNames>) // Component names
Return Value: <string>
// composite name of the footprint.
// If the name requested conflicts with the name of an existing
// footprint, the requested name is altered to be unique.
// The name returned reflects any change made to be unique.

Parameters: <FootprintName>:
<string> // composite name of the footprint being edited

<NewFootprintName>:
<string> // new simple name for the footprint

<ModifiedOnInfo>:
An integer that corresponds to the number of seconds that have elapsed
since 00:00 hours, Jan 1, 1970 UTC from the system clock.

<UnitType>:
<string> // default length units to use if units are not specified in other
// parameters

Definition Manager Script Commands 23-125


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<LayerArray>:
Array("N:=", <string>, // layer name
"ID:=", <int> ,
"T:=", <LayerTypeInfo>, // layer type
"TB:=", <TopBottomInfo>,
"Col:=", <int>, // optional - color
"Pat:=", <int>, // optional - fill pattern
"Vis:=", <bool>, // optional - are objects on layer visible
"Sel:=", <bool>, // optional - are objects on layer selectable
"L:=", <bool>) // optional
// are objects on layer locked (can't be edited)

<LayerTypeInfo>:
<string> // one of: signal, dielectric, metalized signal, assembly, silkscreen, soldermask,
solderpaste, glue, or user

<TopBottomInfo>:
<string> // one of: top, neither, bottom, or template

<StackupLayerArray>:
Array(<LayerArray>,
"Elev:=", <ElevationInfo>,
"SubL:=", Array("Th:=", <Dimension>,
"LElev:=", <Dimension>,
"R:=", <Dimension>,
"M:=", <MaterialInfo>))

<ElevationInfo>:
<string> // "top" - snap to top
// "mid" - snap to middle

Definition Manager Script Commands 23-126


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

// "bot" - snap to bottom


// "edit" - manual edit
// "none"

<Dimension>:
<string> // real number, may include units

<MaterialInfo>:
<string> // name of the layer material

<ToleranceArray>:
Array(<real>, // distance tolerance
<real>, // angle tolerance (radians)
<real>) // dimensionless tolerance

<PrimitivesInfo>:
Array("NAME:Prims",
// one or more of the following
<RectInfo>,
<CircleInfo>,
<ArcInfo>,
<LineInfo>,
<PolygonInfo>,
<TextInfo>,
<ImageInfo>)

<RectInfo>:
"Rect:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color

Definition Manager Script Commands 23-127


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<real>, // angle, in radians


<real>, // x position of center
<real>, // y position of center
<real>, // width
< real>) // height

<CircleInfo>:
"Circle:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<real>, // x position of center
<real>, // y position of center
< real>) // radius

<ArcInfo>:
"Arc:=", Array(<real>, // line width
<int>, // line pattern
<int>, // color
<real>, // x position of center
<real>, // y position of center
< real>, // radius
<real>, // start angle, in radians
<end>) // end angle, in radians

<LineInfo>:
"Line:=", Array(<real>, // line width
<int>, // line pattern
<int>, // color
<PointInfo>, // must specify at least 2 points
<PointInfo>...)

Definition Manager Script Commands 23-128


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<PointInfo>:
<real>, // x position
<real> // y position

<PolygonInfo>:
"Polygon:=", Array(<real>, // line width
<int>, // fill pattern
<int>, // color
<PointInfo>, // must specify at least 3 points
<PointInfo>...)

<TextInfo>:
"Text:=", Array(<real>, // x position
<real>, // y position
<real>, // angle, in radians
<Justification>,
<bool>, // is plotter font
<string>, // font name
<int>, // color
<string>) // text string
<Justification>: <int>
// 0 : left top
// 1 : left base
// 2 : left bottom
// 3 : center top
// 4 : center base
// 5 : center bottom
// 6 : right top
// 7 : right base
// 8 : right bottom

Definition Manager Script Commands 23-129


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<ImageInfo>:
"Image:=", Array(<RectInfo>,
<ImageData>,
<bool>) // is mirrored

<ImageData>:
<string>, // file path
<int>, // 0 : use the file path and link to it
// 1 : ignore file path and use next parameter
<string> // text data, only present if preceding int is 1

<PinsInfo>:
Array("NAME:Pins",
"P:=", <PinArray>,
"P:=", <PinArray>,...)

<PinArray>:
Array("Port:=", Array("Id:=", <int>,
"Clr:=", <real>, // optional - clearance
"N:=", <string>), // pin name
"Pos:=", Array("x:=", <Location>, // padstack (x,y) position
"y:=", <Location>),
"VRt:=", <Angle>, // optional - rotation
"HD:=", <Size>, // optional - hole diameter
<PadstackImplementationInfo>)

<Location>:
<string> specifying real number and units (may use variables)

Definition Manager Script Commands 23-130


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<Angle>:
<string> specifying angle with a real number and units

<Size>:
<string> specifying size with a real number and units

<PadstackImplementationInfo>:
If another with the same implementation has already been specified:
"Ref:=", <int> // id of the other
If not:
"Ref:=", <string>, // name
"Frm:=", <int>, // id of highest layer
"To:=", <int>, // id of lowest layer
<LayerPlacementInfo>,
"Man:=", <int>, // optional, 1 if manually placed, 0 if not (default)
"Use:=", Array(<PadUseInfo>, <PadUseInfo>…) // array may be empty

<LayerPlacementInfo>:
"Lyr:=", Array("Mrg:=", <int>, // optional,
// 1 if all layers have been merged (default)
// 0 if layer are not merged
"Flp:=", <int>, // optional,
// 1 if placed bottom up
// 0 if not (default)
"Map:=", <ParentToLocalLayerInfo>)

<ParentToLocalLayerInfo>:
Array("U:=", <DirectionOfUniqueness>,
"F:=", Array(<int>, <int>, …), // forward mapping
// -1 is not mapped

Definition Manager Script Commands 23-131


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"B:=", Array(<int>, <int>, …)) // backward mapping


// -1 is not mapped

<PadUseInfo>:
"Pad:=", Array("Lid:=", <int>, // layer id
"T:=", <string>, // type : "connected", "thermal",
// "no_pad, "not_connected",
// or "not_connected_thermal"
"Man:=", <int>) // optional, 1 if manually placed
// 0 if not (default)

<DirectionOfUniqueness>:
<string> // one of "forward", "backward", or "two ways"

<ViasInfo>:
Array("NAME:Vias", <ViaInfo>, <ViaInfo>…)

<ViaInfo>:
"V:=", Array("Id:=", <int>,
"N:=", <string>, // name
"Pos:=", Array("x:=", <Location>, // via (x,y) position
"y:=", <Location>),
"VRt:=", <Angle>, // optional - rotation
<ImplementationInfo>

<EdgeportsInfo>:
Array("NAME:EPorts", <EdgePortArray>, <EdgePortArray>…)

<EdgePortArray>
Array("NAME:EP",

Definition Manager Script Commands 23-132


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"LP:=", Array("Id:=", <int>, // port id


"N:=", <string>), // port name
"Eo:=", Array(<edge description>, <edge description>,...))

<edgedescription> for primitive edges

"et:=", "pe", "pr:=", <id>, "ei:=", <edge#>

<id>: integer that is the primitive id

<edge#>: integer that is the edge number on the primitive

<edge description> for via edges

"et:=", "pse", "sel:=", <"via">, "layer:=", <layer id>,


"sx:=", <start X location>, "sy:=", <start Y location>, "ex:=", <end X location>, "ey:=",
<end Y location>, "h:=", <arc height>, "rad:=", <radians>

<"via">: text that is the name of the via to use


<layer id>: an integer that is the id of the layer of the pad of the via to use

<start X location>, <start Y Location>:


   doubles that are the X, Y location of the start point of the edge arc
<end X location>, <end Y Location>:
   doubles that are the X, Y location of the end point of the edge arc

<arc height>: double giving the height of the edge arc (0 for a straight edge)
<radians>: double giving the arc size in radians (0 for a straight edge)

<ComponentPropertyInfo>:

Definition Manager Script Commands 23-133


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:CProps",
"VariableProp:=", <VariableInfo>,
"VariableProp:=", <VariableInfo>,
…)

<VariableInfo>:
Array(<string>, // name
<FlagLetters>,
<string>, // description
"CB:=", <string>, // optional - script for call back
<string>) // value: number, variable, or expression

<ScriptInfo>:
Array("NAME:script",
"language:=", <string>, // one of "javascript" or "vbscript"
"UsesScript:=", true,
"script:=", <string>) // contents of script

<ListOfComponentNames>:
<string>,<string> ...
// The list may be empty. When not empty, each string that is listed is a component
// that references the footprint to be edited. Prior to editing, a clone of the footprint is
// made, and the components that are listed are modified so that they now refer to
// the clone.

VB Example:
Dim nam
oFootprintManager.EditWithComps _
("Nexxim Circuit Elements\Distributed\Distributed:bendo", _
Array("NAME:bendo new name", _

Definition Manager Script Commands 23-134


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"ModTime:=", 1152722165, _
"Library:=", "Nexxim Circuit Elements\Distributed\Distributed", _
"LibLocation:=", "SysLibrary", _
Array("NAME:PinDef", _
"Pin:=", Array( "n1", _
-0.00254, _
0.00254, _
0, _
"N", _
0, _
0, _
false, _
0, _
true, _
"", _
false, _
false)), _
Array("NAME:PinDef", _
"Pin:=", Array( "n2", _
0.00254, _
-0.00254, _
1.5708, _
"N", _
0, _
0, _
false, _
0, _
true, _
"", _
false, _

Definition Manager Script Commands 23-135


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

false)), _
Array("NAME:Graphics", _
"Polygon:=", Array( 0, 0, 12566272, 0, 0.00381, 0, .00127, 0.00127,
_
0.00127, 0.00127, 0, 0.00381, 0, 0.00381, _
0.002032, 0.00127, 0.00381), _
"Line:=", Array(0, 1, 12566272, -0.00254, 0.00254, 0, .00254), _
"Line:=", Array(0, 1, 12566272, 0.00254, -0.00254, .00254, 0)), _
Array("NAME:PropDisplayMap", _
"W:=", Array(3, _
5, _
0, _
"Text:=", Array( 2.1684E-019, _
0.00504119, _
0, _
1, _
5, _
false, _
"Arial", _
0, _
"W=***"))))), _
Array("MY_COMP")
Export [footprint manager]
Use: Export a footprint to a library
Command: Tools > Edit Configured Libraries > Footprints > Export to Library
Syntax: Export Array("NAME:<LibraryName>",
<FootprintName>,
<FootprintName>...),
<LibraryLocation>
Return Value: None

Definition Manager Script Commands 23-136


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Parameters: <LibraryName>:
<string> // name of the library

<FootprintName>:
<string> // composite name of footprint to export

<LibraryLocation>:
<string> // location of the library in <LibraryName>
// One of "Project", "PersonalLib", or "UserLib"

VB Example:
oFootprintManager.Export Array("NAME:mylib", "Distributed Foot-
prints:BPAD"), "PersonalLib"
GetData [footprint manager]
FootprintGetData
Use: Gets data that describes the definition.
Command: None
Syntax: GetData(<DefinitionName>)
Return Value: <DefinitionData> This is an array of data for the definition.
Parameters: <DefinitionName>:
<string> // composite name of the definition to edit
VB Example:
Dim footprintData
footprintData = oFootprintManager.GetData("Nexxim Circuit Ele-
ments\Distributed\Nexxim_Footprints:MCPL13_Nexx")

Definition Manager Script Commands 23-137


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Note:

GetData allows the user to access definition information, make modifications, and then
use the Edit or EditWithComps script commands to save the modified definition. Accord-
ingly, for each type of definition, the array data returned to GetData should be the same
array information that is supplied to the Edit or EditWithComps commands.

GetNames [footprint manager]


Use: Returns the names of the footprints (used and unused) in a design. The following script com-
mand, IsUsed, can then be used to separate used and unused footprints.
Command: None
Syntax: GetNames()
Return Value: An array of strings
Parameters: None
VB Example:
Dim footprintNames
footprintNames = oFootprintManager.GetNames()
IsUsed [footprint manager]
Use: Used to determine if a footprint is used in the design.
Command: None
Syntax: IsUsed(<FootprintName>)
Return Value: <Boolean> // true if the specified footprint is used in the design
Parameters: <FootprintName>:
<string>
VB Example:
Dim isUsed
isUsed = oFootprintManager.IsUsed("MyFootprint")
Remove [footprint manager]
Use: Removes a footprint from a library
Command: Tools > Edit Configured Libraries > Footprints > Remove Footprint
Syntax: Remove <FootprintName>,
<IsProjectFootprint>,

Definition Manager Script Commands 23-138


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<LibraryName>,
<LibraryLocation>
Return Value: None
Parameters: <FootprintName>:
<string> // composite name of the footprint to remove

<IsProjectFootprint>:
<bool>

<LibraryName>:
<string> // name of the library

<LibraryLocation>:
<string> // location of the library in <LibraryName>
// One of "Project", "PersonalLib", or "UserLib"

VB Example:
oFootprintManager.Remove "BPAD", true, "Distributed Footprints",
"Project"
oFootprintManager.Remove "BPAD", false, "MyLib", "PersonalLib"
RemoveUnused [footprint manager]
Use: Removes footprints that are not used in the design.
Command: Project->Remove Unused Definitions is similar but operates slightly different and
does not record script commands.
Syntax: RemoveUnused()
Return Value: <bool> True if one or more footprints are removed.
Parameters: None
VB Example:
Dim removedDefs
removedDefs = oFootprintManager.RemoveUnused()

Definition Manager Script Commands 23-139


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Note:

The order of calls to RemoveUnused is significant. As a result, removing definitions in an


unordered fashion may cause other footprints in dependent definitions to be rendered
unusable.

Also, the symbol and footprint of an unused component are not unusable until after the
component itself is removed using the Component ManagerRemove script.

Padstack Manager Script Commands


The padstack manager provides access to padstacks in a project. The manager object is accessed
via the definition manager.
Set oDefinitionManager = oProject.GetDefinitionManager()
Set oPadstackManager = oDefinitionManager.GetManager("Padstack")
The padstack manager script commands are listed below.
Add
Edit
EditWithComps
Export
GetData
GetNames
IsUsed
Remove
RemoveUnused
Add [padstack manager]
Use: Add a padstack
Command: Tools > Edit Configured Libraries > Padstacks > Add Padstack
Syntax: Add Array("NAME:<PadstackName>",
"ModTime:=", <ModifiedOnInfo>,
"Library:=", "", // name of the library
"LibLocation:=", "Project", // location of the named library

Definition Manager Script Commands 23-140


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:psd",
"nam:= ", <PadstackName>,
"lib:=", "", // name of the library
"mat:=", "", // hole plating material
"plt:=", "0", // percent of hole's radius filled by plating
Array("NAME:pds",
<LayerGeometryArray>,
<LayerGeometryArray....),
"hle:=", <PadInfo>
"hRg:=", <HoleRange>,
"sbsh:=", <SolderballShape>,
"sbpl:=", <SolderballPlacement>,
"sbr:=", <string>, // solderball diameter, real with units
"sb2:=", <string>, // solderball mid diameter, real with units
"sbn:=", <string>), // name of solderball material
"ppl:=", <PadPortLayerArray>)
Return Value: simple name of the added padstack
// If the name requested conflicts with the name of an existing
// padstack, the requested name is altered to be unique.
// The name returned reflects any change made to be unique.

Parameters: <PadstackName>:
<string> // simple name of padstack to create

<ModifiedOnInfo>:
An integer that corresponds to the number of seconds that have elapsed
since 00:00 hours, Jan 1, 1970 UTC from the system clock.

<LayerGeometryArray>:
Array("Name:lgm",

Definition Manager Script Commands 23-141


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"lay:=", <string>, // definition layer name


"id:=", <int>, // definition layer id
"pad:=", <PadInfo>, // pad
"ant:=", <PadInfo>, // antipad
"thm:=", <PadInfo>, // themal pad
"X:=", <string>, // pad x connection, real with units
"Y:=", <string>, // pad y connection, real with units
"dir:=", <DirectionString>) // pad connection direction

<PadInfo>:
Array("shp:=", <PadShape>,
"Szs:=", <DimensionArray>,
"X:=", <string>, // x offset, real with units
"Y:=", <string>, // y offset, real with units
"R:=", <string>) // rotation, real with units

<PadShape>:
<string> one of these choices
"No" // no pad
"Cir" // Circle
"Sq" // Square
"Rct" // Rectangle
"Ov" // Oval
"Blt" // Bullet
"Ply" // Polygons
"R45" // Round 45 thermal
"R90" // Round 90 thermal
"S45" // Square 45 thermal
"S90" // Square 90 thermal

Definition Manager Script Commands 23-142


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<DimensionArray>:
Array(<string>, ...) // each string is a real with units for one of the dimensions of the
shape

<DirectionString>:
<string> one of these choices
"No" // no direction
"Any" // any direction
"0" // 0 degrees
"45" // 45 degrees
"90" // 90 degrees
"135" // 135 degrees
"180" // 180 degrees
"225" // 225 degrees
"270" // 270 degrees
"315" // 315 degrees

<HoleRange>:
<string> one of these choices
"Thr" // through all layout layers
"Beg" // from upper pad layer to lowest layout layer
"End" // from upper layout layer to lowest pad layer
"UTL" // from upper pad layer to lowest pad layer
<SolderballShape>:
<string> one of these choices
"None" // no solderball
"Cyl" // cylinder solderball
"Sph" // spheroid solderball

<SolderballPlacement>:
<string> one of these choices
"abv" // above padstack

Definition Manager Script Commands 23-143


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"blw" // below padstack

<PadPortLayerArray>:
Array( <int>, <int>,....) where each int is a layer id
VB Example:

oPadstackManager.Add Array("NAME:Circle - through3", "ModTime:=",


1235765635, "Library:=", _
"", "LibLocation:=", "Project", Array("NAME:psd", "nam:=", "Circle -
through3", "lib:=", _
"", "mat:=", "", "plt:=", "0", Array("NAME:pds", Array("NAME:lgm",
"lay:=", "Top Signal", "id:=", _
0, "pad:=", Array("shp:=", "Cir", "Szs:=", Array("2.5mm"), "X:=",
"0mm", "Y:=", _
"0mm", "R:=", "0deg"), "ant:=", Array("shp:=", "Cir", "Szs:=", Array
("3.5mm"), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0"), "thm:=", Array("shp:=", "No",
"Szs:=", Array(), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0"), "X:=", "0mm", "Y:=", "0mm",
"dir:=", "Any"), Array("NAME:lgm", "lay:=", _
"SignalA", "id:=", 1, "pad:=", Array("shp:=", "Cir", "Szs:=", Array
("2mm"), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0deg"), "ant:=", Array("shp:=", "Cir",
"Szs:=", Array( _
"3mm"), "X:=", "0mm", "Y:=", "0mm", "R:=", "0"), "thm:=", Array
("shp:=", "No", "Szs:=", Array(), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0"), "X:=", "0mm", "Y:=", "0mm",
"dir:=", "Any"), Array("NAME:lgm", "lay:=", _
"SignalB", "id:=", 2, "pad:=", Array("shp:=", "Cir", "Szs:=", Array
("2mm"), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0deg"), "ant:=", Array("shp:=", "Cir",
"Szs:=", Array( _
"3mm"), "X:=", "0mm", "Y:=", "0mm", "R:=", "0deg"), "thm:=", Array
("shp:=", "No", "Szs:=", Array(), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0"), "X:=", "0mm", "Y:=", "0mm",
"dir:=", "Any"), Array("NAME:lgm", "lay:=", _

Definition Manager Script Commands 23-144


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Ground", "id:=", 3, "pad:=", Array("shp:=", "No", "Szs:=", Array(),


"X:=", _
"0mm", "Y:=", "0mm", "R:=", "0deg"), "ant:=", Array("shp:=", "No",
"Szs:=", Array(), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0"), "thm:=", Array("shp:=", "R90",
"Szs:=", Array( _
"3mm", "0.75mm", "1mm"), "X:=", "0mm", "Y:=", "0mm", "R:=", "0"),
"X:=", "0mm", "Y:=", _
"0mm", "dir:=", "Any"), Array("NAME:lgm", "lay:=", "Bottom signal",
"id:=", 5, "pad:=", Array("shp:=", _
"Cir", "Szs:=", Array("1mm"), "X:=", "0mm", "Y:=", "0mm", "R:=",
"0deg"), "ant:=", Array("shp:=", _
"Cir", "Szs:=", Array("2mm"), "X:=", "0mm", "Y:=", "0mm", "R:=",
"0deg"), "thm:=", Array("shp:=", _
"No", "Szs:=", Array(), "X:=", "0mm", "Y:=", "0mm", "R:=", "0"),
"X:=", "0mm", "Y:=", _
"0mm", "dir:=", "Any")), "hle:=", Array("shp:=", "Cir", "Szs:=",
Array("1.5mm"), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0deg"), "hRg:=", "End", "sbsh:=",
"Sph", "sbpl:=", _
"abv", "sbr:=", "750um", "sb2:=", "1200um", "1200um", "sbn:=",
"solder"), "ppl:=", Array( _
0, 1, 2, 3, 5))
Edit [padstack manager]
Use: Edit an existing padstack.
Command: Tools > Edit Configured Libraries > Padstacks > Edit Padstack
Syntax: Edit <PadstackName>,
Array("NAME:<NewPadstackName>",
"ModTime:=", <ModifiedOnInfo>,
"Library:=", "", // name of the library
"LibLocation:=", "Project", // location of the named library
Array("NAME:psd",
"nam:= ", <PadstackName>,
"lib:=", "", // name of the library

Definition Manager Script Commands 23-145


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"mat:=", "", // hole plating material


"plt:=", "0", // percent of hole's radius filled by plating
Array("NAME:pds",
<LayerGeometryArray>,
<LayerGeometryArray....),
"hle:=", <PadInfo>
"hRg:=", <HoleRange>,
"sbsh:=", <SolderballShape>,
"sbpl:=", <SolderballPlacement>,
"sbr:=", <string>, // solderball diameter, real with units
"sb2:=", <string>, // solderball mid diameter, real with units
"sbn:=", <string>), // name of solderball material
"ppl:=", <PadPortLayerArray>)
Return Value: <string> // composite name of the padstack
// If the name requested conflicts with the name of an existing
// padstack, the requested name is altered to be unique.
// The name returned reflects any change made to be unique.

Parameters: <PadstackName>:
<string> // composite name of padstack to edit

<NewPadstackName>:
<string> // new simple name for padstack

<ModifiedOnInfo>:
An integer that corresponds to the number of seconds that have elapsed
since 00:00 hours, Jan 1, 1970 UTC from the system clock.

<LayerGeometryArray>:
Array("Name:lgm",

Definition Manager Script Commands 23-146


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"lay:=", <string>, // definition layer name


"id:=", <int>, // definition layer id
"pad:=", <PadInfo>, // pad
"ant:=", <PadInfo>, // antipad
"thm:=", <PadInfo>, // themal pad
"X:=", <string>, // pad x connection, real with units
"Y:=", <string>, // pad y connection, real with units
"dir:=", <DirectionString>) // pad connection direction

<PadInfo>:
Array("shp:=", <PadShape>,
"Szs:=", <DimensionArray>,
"X:=", <string>, // x offset, real with units
"Y:=", <string>, // y offset, real with units
"R:=", <string>) // rotation, real with units

<PadShape>:
<string> one of these choices
"No" // no pad
"Cir" // Circle
"Sq" // Square
"Rct" // Rectangle
"Ov" // Oval
"Blt" // Bullet
"Ply" // Polygons
"R45" // Round 45 thermal
"R90" // Round 90 thermal
"S45" // Square 45 thermal
"S90" // Square 90 thermal

Definition Manager Script Commands 23-147


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<DimensionArray>:
Array(<string>, ...) // each string is a real with units for one of the
// dimensions of the shape

<DirectionString>:
<string> one of these choices
"No" // no direction
"Any" // any direction
"0" // 0 degrees
"45" // 45 degrees
"90" // 90 degrees
"135" // 135 degrees
"180" // 180 degrees
"225" // 225 degrees
"270" // 270 degrees
"315" // 315 degrees

<HoleRange>:
<string> one of these choices
"Thr" // through all layout layers
"Beg" // from upper pad layer to lowest layout layer
"End" // from upper layout layer to lowest pad layer
"UTL" // from upper pad layer to lowest pad layer

<SolderballShape>:
<string> one of these choices
"None" // no solderball
"Cyl" // cylinder solderball
"Sph" // spheroid solderball

<SolderballPlacement>:

Definition Manager Script Commands 23-148


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

<string> one of these choices


"abv" // above padstack
"blw" // below padstack

<PadPortLayerArray>:
Array( <int>, <int>,....) where each int is a layer id

VB Example:
oPadstackManager.Edit "Circle - through1", Array("NAME:Circle -
through1", "ModTime:=", _
1235765635, "Library:=", "", "LibLocation:=", "Project", Array
("NAME:psd", "nam:=", _
"Circle - through1", "lib:=", "", "mat:=", "", "plt:=", "0", Array
("NAME:pds", Array("NAME:lgm", "lay:=", _
"Top Signal", "id:=", 0, "pad:=", Array("shp:=", "Cir", "Szs:=",
Array("2.5mm"), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0deg"), "ant:=", Array("shp:=", "Cir",
"Szs:=", Array( _
"3.5mm"), "X:=", "0mm", "Y:=", "0mm", "R:=", "0"), "thm:=", Array
("shp:=", "No", "Szs:=", Array(), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0"), "X:=", "0mm", "Y:=", "0mm",
"dir:=", "Any"), Array("NAME:lgm", "lay:=", _
"SignalA", "id:=", 1, "pad:=", Array("shp:=", "Cir", "Szs:=", Array
("2mm"), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0deg"), "ant:=", Array("shp:=", "Cir",
"Szs:=", Array( _
"3mm"), "X:=", "0mm", "Y:=", "0mm", "R:=", "0"), "thm:=", Array
("shp:=", "No", "Szs:=", Array(), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0"), "X:=", "0mm", "Y:=", "0mm",
"dir:=", "Any"), Array("NAME:lgm", "lay:=", _
"SignalB", "id:=", 2, "pad:=", Array("shp:=", "Cir", "Szs:=", Array
("2mm"), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0deg"), "ant:=", Array("shp:=", "Cir",
"Szs:=", Array( _
"3mm"), "X:=", "0mm", "Y:=", "0mm", "R:=", "0deg"), "thm:=", Array
("shp:=", "No", "Szs:=", Array(), "X:=", _

Definition Manager Script Commands 23-149


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"0mm", "Y:=", "0mm", "R:=", "0"), "X:=", "0mm", "Y:=", "0mm",


"dir:=", "Any"), Array("NAME:lgm", "lay:=", _
"Ground", "id:=", 3, "pad:=", Array("shp:=", "No", "Szs:=", Array(),
"X:=", _
"0mm", "Y:=", "0mm", "R:=", "0deg"), "ant:=", Array("shp:=", "No",
"Szs:=", Array(), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0"), "thm:=", Array("shp:=", "R90",
"Szs:=", Array( _
"3mm", "0.75mm", "1mm"), "X:=", "0mm", "Y:=", "0mm", "R:=", "0"),
"X:=", "0mm", "Y:=", _
"0mm", "dir:=", "Any"), Array("NAME:lgm", "lay:=", "Bottom signal",
"id:=", 5, "pad:=", Array("shp:=", _
"Cir", "Szs:=", Array("1mm"), "X:=", "0mm", "Y:=", "0mm", "R:=",
"0deg"), "ant:=", Array("shp:=", _
"Cir", "Szs:=", Array("2mm"), "X:=", "0mm", "Y:=", "0mm", "R:=",
"0deg"), "thm:=", Array("shp:=", _
"No", "Szs:=", Array(), "X:=", "0mm", "Y:=", "0mm", "R:=", "0"),
"X:=", "0mm", "Y:=", _
"0mm", "dir:=", "Any")), "hle:=", Array("shp:=", "Cir", "Szs:=",
Array("1.5mm"), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0deg"), "hRg:=", "End", "sbsh:=",
"Sph", "sbpl:=", _
"abv", "sbr:=", "750um", "sb2:=", "1200um", "1200um", "sbn:=",
"solder"), "ppl:=", Array( _
0, 1, 2, 3, 5))
EditWithComps [padstack manager]
Use: Edit an existing padstack.
Command: None
Syntax: EditWithComps <PadstackName>,
Array("NAME:<NewPadstackName>",
"ModTime:=", <ModifiedOnInfo>,
"Library:=", "", // name of the library
"LibLocation:=", "Project", // location of the named library
Array("NAME:psd",
"nam:= ", <PadstackName>,

Definition Manager Script Commands 23-150


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"lib:=", "", // name of the library


"mat:=", "", // hole plating material
"plt:=", "0", // percent of hole's radius filled by plating
Array("NAME:pds",
<LayerGeometryArray>,
<LayerGeometryArray....),
"hle:=", <PadInfo>
"hRg:=", <HoleRange>,
"sbsh:=", <SolderballShape>,
"sbpl:=", <SolderballPlacement>,
"sbr:=", <string>, // solderball diameter, real with units
"sb2:=", <string>, // solderball mid diameter, real with units
"sbn:=", <string>), // name of solderball material
"ppl:=", <PadPortLayerArray>,
Array(<ListOfComponentNames>) // Component names

Return Value: <string>


// composite name of the padstack.
// If the name requested conflicts with the name of an existing
// padstack, the requested name is altered to be unique.
// The name returned reflects any change made to be unique.

Parameters: <PadstackName>:
<string> // composite name of the padstack being edited

<NewPadstackName>:
<string> // new simple name for the padstack

<ModifiedOnInfo>:
An integer that corresponds to the number of seconds that have elapsed

Definition Manager Script Commands 23-151


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

since 00:00 hours, Jan 1, 1970 UTC from the system clock.

<LayerGeometryArray>:
Array("Name:lgm",
"lay:=", <string>, // definition layer name
"id:=", <int>, // definition layer id
"pad:=", <PadInfo>, // pad
"ant:=", <PadInfo>, // antipad
"thm:=", <PadInfo>, // themal pad
"X:=", <string>, // pad x connection, real with units
"Y:=", <string>, // pad y connection, real with units
"dir:=", <DirectionString>) // pad connection direction

<PadInfo>:
Array("shp:=", <PadShape>,
"Szs:=", <DimensionArray>,
"X:=", <string>, // x offset, real with units
"Y:=", <string>, // y offset, real with units
"R:=", <string>) // rotation, real with units

<PadShape>:
<string> one of these choices
"No" // no pad
"Cir" // Circle
"Sq" // Square
"Rct" // Rectangle
"Ov" // Oval
"Blt" // Bullet
"Ply" // Polygons
"R45" // Round 45 thermal

Definition Manager Script Commands 23-152


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"R90" // Round 90 thermal


"S45" // Square 45 thermal
"S90" // Square 90 thermal

<DimensionArray>:
Array(<string>, ...) // each string is a real with units for one of the
// dimensions of the shape

<DirectionString>:
<string> one of these choices
"No" // no direction
"Any" // any direction
"0" // 0 degrees
"45" // 45 degrees
"90" // 90 degrees
"135" // 135 degrees
"180" // 180 degrees
"225" // 225 degrees
"270" // 270 degrees
"315" // 315 degrees

<HoleRange>:
<string> one of these choices
"Thr" // through all layout layers
"Beg" // from upper pad layer to lowest layout layer
"End" // from upper layout layer to lowest pad layer
"UTL" // from upper pad layer to lowest pad layer

<SolderballShape>:
<string> one of these choices
"None" // no solderball

Definition Manager Script Commands 23-153


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Cyl" // cylinder solderball


"Sph" // spheroid solderball

<SolderballPlacement>:
<string> one of these choices
"abv" // above padstack
"blw" // below padstack

<PadPortLayerArray>:
Array( <int>, <int>,....) where each int is a layer id

<ListOfComponentNames>:
<string>,<string> ...
// The list may be empty. When not empty, each string that is listed is a component
// that references the padstack to be edited. Prior to editing, a clone of the padstack is
// made, and the components that are listed are modified so that they now refer to
// the clone.

VB Example:
oPadstackManager.EditWithComps "Circle - through1", Array
("NAME:Circle - through1", "ModTime:=", _
1235765635, "Library:=", "", "LibLocation:=", "Project", Array
("NAME:psd", "nam:=", _
"Circle - through1", "lib:=", "", "mat:=", "", "plt:=", "0", Array
("NAME:pds", Array("NAME:lgm", "lay:=", _
"Top Signal", "id:=", 0, "pad:=", Array("shp:=", "Cir", "Szs:=",
Array("2.5mm"), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0deg"), "ant:=", Array("shp:=", "Cir",
"Szs:=", Array( _
"3.5mm"), "X:=", "0mm", "Y:=", "0mm", "R:=", "0"), "thm:=", Array
("shp:=", "No", "Szs:=", Array(), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0"), "X:=", "0mm", "Y:=", "0mm",
"dir:=", "Any"), Array("NAME:lgm", "lay:=", _

Definition Manager Script Commands 23-154


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"SignalA", "id:=", 1, "pad:=", Array("shp:=", "Cir", "Szs:=", Array


("2mm"), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0deg"), "ant:=", Array("shp:=", "Cir",
"Szs:=", Array( _
"3mm"), "X:=", "0mm", "Y:=", "0mm", "R:=", "0"), "thm:=", Array
("shp:=", "No", "Szs:=", Array(), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0"), "X:=", "0mm", "Y:=", "0mm",
"dir:=", "Any"), Array("NAME:lgm", "lay:=", _
"SignalB", "id:=", 2, "pad:=", Array("shp:=", "Cir", "Szs:=", Array
("2mm"), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0deg"), "ant:=", Array("shp:=", "Cir",
"Szs:=", Array( _
"3mm"), "X:=", "0mm", "Y:=", "0mm", "R:=", "0deg"), "thm:=", Array
("shp:=", "No", "Szs:=", Array(), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0"), "X:=", "0mm", "Y:=", "0mm",
"dir:=", "Any"), Array("NAME:lgm", "lay:=", _
"Ground", "id:=", 3, "pad:=", Array("shp:=", "No", "Szs:=", Array(),
"X:=", _
"0mm", "Y:=", "0mm", "R:=", "0deg"), "ant:=", Array("shp:=", "No",
"Szs:=", Array(), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0"), "thm:=", Array("shp:=", "R90",
"Szs:=", Array( _
"3mm", "0.75mm", "1mm"), "X:=", "0mm", "Y:=", "0mm", "R:=", "0"),
"X:=", "0mm", "Y:=", _
"0mm", "dir:=", "Any"), Array("NAME:lgm", "lay:=", "Bottom signal",
"id:=", 5, "pad:=", Array("shp:=", _
"Cir", "Szs:=", Array("1mm"), "X:=", "0mm", "Y:=", "0mm", "R:=",
"0deg"), "ant:=", Array("shp:=", _
"Cir", "Szs:=", Array("2mm"), "X:=", "0mm", "Y:=", "0mm", "R:=",
"0deg"), "thm:=", Array("shp:=", _
"No", "Szs:=", Array(), "X:=", "0mm", "Y:=", "0mm", "R:=", "0"),
"X:=", "0mm", "Y:=", _
"0mm", "dir:=", "Any")), "hle:=", Array("shp:=", "Cir", "Szs:=",
Array("1.5mm"), "X:=", _
"0mm", "Y:=", "0mm", "R:=", "0deg"), "hRg:=", "End", "sbsh:=",
"Sph", "sbpl:=", _

Definition Manager Script Commands 23-155


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"abv", "sbr:=", "750um", "sb2:=", "1200um", "1200um", "sbn:=",


"solder"), "ppl:=", Array( _
0, 1, 2, 3, 5), Array("")
Export [padstack manager]
Use: Export a padstack to a library
Command: Tools > Edit Configured Libraries > Padstacks > Export to Library
Syntax: Export Array("NAME:<LibraryName>",
<PadstackName>,
<PadstackName>...),
<LibraryLocation>
Return Value: None
Parameters: <LibraryName>:
<string> // name of the library

<PadstackName>:
<string> // simple name of padstack to export

<LibraryLocation>:
<string> // location of the library in <LibraryName>
// One of "Project", "PersonalLib", or "UserLib"

VB Example:
oPadstackManager.Export Array("NAME:mylib", "myPadstack"), "Per-
sonalLib"
GetData [padstack manager]
Use: Gets data that describes the definition.
Command: None
Syntax: GetData(<DefinitionName>)
Return Value: <DefinitionData> This is an array of data for the definition.
Parameters: <DefinitionName>:
<string> // composite name of the definition to edit

Definition Manager Script Commands 23-156


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

VB Example:
Dim padstackData
padstackData = oPadstackManager.GetData("NoPad SMT East")

Note:

GetData allows the user to access definition information, make modifications, and then
use the Edit or EditWithComps script commands to save the modified definition. Accord-
ingly, for each type of definition, the array data returned to GetData should be the same
array information that is supplied to the Edit or EditWithComps commands.

GetNames [padstack manager]


Use: Returns the names of the padstack (used and unused) in a design. The following script com-
mand, IsUsed, can then be used to separate used and unused padstacks.
Command: None
Syntax: GetNames()
Return Value: An array of strings
Parameters: None
VB Example:
Dim padstackNames
padstackNames = oPadstackManager.GetNames()
IsUsed [padstack manager]
Use: Used to determine if a component is used in the design.
Command: None
Syntax: IsUsed(<PadstackName>)
Return Value: <Boolean> // true if the specified padstack is used in the design
Parameters: <PadstackName>:
<string>
VB Example:
Dim isUsed
isUsed = oPadstackManager.IsUsed("MyPadstack")
Remove [padstack manager]
Use: Removes a padstack from a library

Definition Manager Script Commands 23-157


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Command: Tools > Edit Configured Libraries > Padstacks > Remove Padstacks
Syntax: Remove <PadstackName>,
<IsProjectPadstack>,
<LibraryName>,
<LibraryLocation>
Return Value: None
Parameters: <PadstackName>:
<string> // simple name of the padstack to remove

<IsProjectPadstack>:
<bool>

<LibraryName>:
<string> // name of the library

<LibraryLocation>:
<string> // location of the library in <LibraryName>
// One of "Project", "PersonalLib", or "UserLib"

VB Example:

oPadstackManager.Remove "Polygon SMT", true, "Padstacks", "Project"


oPadstackManager.Remove "Polygon SMT", false, "MyLib", "PersonalLib"
RemoveUnused [padstack manager]
Use: Removes padstacks that are not used in the design.
Command: Project->Remove Unused Definitions is similar but operates slightly different and
does not record script commands.
Syntax: RemoveUnused()
Return Value: <bool> True if one or more padstacks are removed.
Parameters: None
VB Example:

Definition Manager Script Commands 23-158


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Dim removedDefs
removedDefs = oPadstackManager.RemoveUnused()

Note:

The order of calls to RemoveUnused is significant. As a result, removing definitions in an


unordered fashion may cause other padstacks in dependent definitions to be rendered
unusable.

Script and Library Scripts


The definition manager provides access to materials in a project. The manager object is accessed
via the definition manager.
Set oDefinitionManager = oProject.GetDefinitionManager()
The script and library script commands are listed below.
AddScript
EditScript
ExportScript
RemoveScript
ModifyLibraries
AddScript
Use: Add Script in the script definition manager
Command: None
Syntax: AddScript Array(<AddScriptArray>)
Return Value: None
Parameters: <AddScriptArray>
Array("NAME<ScriptName>", <string>,
<ScriptLanguage>,<string> ("vbscript" or "javascript")
<ScriptText>, <string> // text of script
VB Example: oDefinitionManager.AddScript Array("NAME:MyScript", _
"ScriptLang:=", "vbscript", _
"ScriptText:=", "MsgBox(" & Chr(34) & "Hello World" & Chr(34) & ")")

Definition Manager Script Commands 23-159


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Python AddScript (<AddScriptArray>)


Syntax

oDefinitionManager.AddScript (["NAME:MyScript", _
Python
"ScriptLang:=", "vbscript", _
Examp-
le "ScriptText:=", "MsgBox(" & Chr(34) & "Hello World" & Chr
(34) &")"])

EditScript
Use: Edit Script in the script definition manager
Command: None
Syntax: EditScript <OriginalName>,Array("NAME:<NewName>", < ScriptText >)
Return Value: None
Parameters: <OriginalName>
Type: <String>
Name of the script before editing.
<NewName>
Type: <String>
New name for the script.
<ScriptText>
Type: <string> // text of script
VB Example:
oDefinitionManager.EditScript "myscript",
Array("NAME:myscript", "ScriptLang:=", _
"vbscript", "ScriptText:=", _
"MsgBox(" & Chr(34) & "Hello Again" & Chr(34) & ")")

Python Syn- EditScript(<OriginalName>,["NAME:<NewName>", < ScriptText >])


tax

oDefinitionManager.EditScript ("myscript",
Python
["NAME:myscript", "ScriptLang:=", _
Example
"vbscript", "ScriptText:=", _

Definition Manager Script Commands 23-160


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"MsgBox(" & Chr(34) & "Hello Again"


& Chr(34) & ")"])

ExportScript
Use: Export to Library in the script definition manager
Command: None
Syntax: ExportScript <ExportData>,<Library location>
Return Value: None
Parameters: <ExportData>
Array("NAME:<LibraryName>",<ScriptName>,<ScriptName>,…)
VB Example:
oProject.ExportComponent Array("NAME:mylib", "myscript"), "Per-
sonalLib"

Python Syn-  ExportScript( <ExportData>,<Library location>)


tax

Python oProject.ExportComponent
Example (["NAME:mylib", "myscript"], "PersonalLib")

RemoveScript
Use: Remove Script in the script definition manager
Command: None
Syntax: RemoveScript <ScriptName>,<IsProjectScript>, <LibraryName>,<LibraryLocation>
Return Value: None
Parameters: <ScriptName>
Type: <string>
<IsProjectScript>
Type: <bool>
<LibraryName>
Type: <string>
<LibraryLocation>
Type: <string>
VB Example:

Definition Manager Script Commands 23-161


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oDefinitionManager.RemoveScript "myscript", true, "Local", "Project"

Python Syn- RemoveScript (<ScriptName>,<IsProjectScript>, <LibraryName>,<LibraryLoca-


tax tion>)

Python
oDefinitionManager.RemoveScript(
Example "myscript", true, "Local", "Project")

ModifyLibraries
Use: Configure Libraries on the Tools menu
Command: None
Syntax: ModifyLibraries <DesignName>,Array(<ConfigLibArray>)
Return Value: None
Parameters: <DesignName>
Type: <string>
<ConfigLibArray>
Array("NAME:<LibraryType>,<ConfiguredLib>,<ConfiguredLib>,…),…
<ConfiguredLib> // blank to leave unchanged
<DefinitionType>
Array("<libraryname >","<libraryname>",…)
VB Example:
oDefinitionManager.ModifyLibraries "MyCircuit", _
Array("NAME:PersonalLib"), _
Array("NAME:UserLib"), _
Array("NAME:SystemLib", _
"Symbols:=", Array( "Circuit Elements", "Symbols", _
"ParamExtraElements\PE_Symbols", _
"Vendor Elements\Nonlinear"))

Python ModifyLibraries (<DesignName>,[<ConfigLibArray>])


Syntax

Python oDefinitionManager.ModifyLibraries(

Definition Manager Script Commands 23-162


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"MyCircuit", _
["NAME:PersonalLib"], _
["NAME:UserLib"], _

Example ["NAME:SystemLib", _
"Symbols:=", [ "Circuit Elements", "Symbols",_
"ParamExtraElements\PE_Symbols", _
"Vendor Elements\Nonlinear"]])

Definition Manager Script Commands 23-163


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

23-164
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

24 - Example Scripts
This section contains VBScript and IronPython example scripts.

VBScript Example Scripts


VBScript Examples:

l Variable Helix Script


l HFSS Data Export Script

Data Export Script


The following sample script demonstrates how to export data and save it to a file. The output data in
the example script is in 3 columns. The first column is frequency 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 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 ( ') and offer explanations
for each subsequent line or lines.
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
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) & _

Example Scripts 24-1


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"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")
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))

Example Scripts 24-2


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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.
'
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, "")

Example Scripts 24-3


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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
Variable Helix Script
This sample script creates a tapered helix. Tapering helices is not supported from the interface.
The script includes comment lines, which are preceded by an apostrophe ( ') and offer explanations
for each subsequent line or lines.

Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()

Example Scripts 24-4


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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"
Case "mm"
Case "um"
Case "in"
Case "mil"
Case Else
MsgBox("Invalid Units - defaults to m")
Units = ""

Example Scripts 24-5


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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)
Angle = (n-1)*2*Pi/PointsPerTurn
Radius = R(0) + ((n-1)/NumPoints)*(R(1)-R(0))

Example Scripts 24-6


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

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 _

Example Scripts 24-7


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Array("NAME:CircleParameters", "IsCovered:=", true, "XCenter:=",_


cstr(R(0))&Units, "YCenter:=", 0, "ZCenter:=", 0, "Radius:=", _
"1"&Units, "WhichAxis:=", "Y"), _
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")

IronPython Example Scripts


IronPython Examples:

l BH Coordinates Python Script


l HFSS Waveguide Array Python Script
l Equation Based Curve Python Script

BH Coordinates Python Script


This sample Python script adds a material ("Posco 35PN250") with BH coordinates from a spe-
cified file (Posco_BH_curve.tab):

Example Scripts 24-8


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

To recreate this tab file, paste the text below the script into a text editor and save as Posco_BH_
curve.tab.
The script itself includes comment lines, which are preceded by # and offer explanations for the sub-
sequent line(s).
Script Contents
# specify path to the file with BH coordinates
path_to_file = r"D:\Posco_BH_curve.tab"
# specify name of the material
material_name = "Posco 35PN250"
oProject = oDesktop.GetActiveProject()
oDefinitionManager = oProject.GetDefinitionManager()
""" create list with B and H points to pass to AddMaterial command
bh_coordinates list is a three dimensional array: 1D: name, 2D:
Coordinate list, 3D: BH point"""
bh_coordinates = ["NAME:BHCoordinates", ["NAME:DimUnits", "", ""]]

Example Scripts 24-9


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

with open(path_to_file) as input_file:


for line in input_file:
h, b = line.split()

bh_coordinates.append(["NAME:Coordinate", [
"NAME:CoordPoint",
float(h),
float(b)
]
])
# create a new magnetic material with BH curve
oDefinitionManager.AddMaterial(
[
"NAME:" + material_name,
"CoordinateSystemType:=", "Cartesian",
"BulkOrSurfaceType:=" , 1,
[
"NAME:PhysicsTypes",
"set:=" , ["Electromagnetic"]
],
[
"NAME:permeability",
"property_type:=" , "nonlinear",
"BTypeForSingleCurve:=" , "normal",
"HUnit:=" , "A_per_meter", # unit can be specified
as variable
"BUnit:=" , "tesla", # unit can be specified as vari-
able
"IsTemperatureDependent:=", False,
bh_coordinates,
[

Example Scripts 24-10


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"NAME:Temperatures"
]
],
"conductivity:=" , "1818181.82",
[
"NAME:magnetic_coercivity",
"property_type:=" , "VectorProperty",
"Magnitude:=" , "0A_per_meter",
"DirComp1:=" , "1",
"DirComp2:=" , "0",
"DirComp3:=" , "0"
]
])
Posco_BH_Curve.tab Contents
0 0.000
10 0.050
20 0.130
23 0.152
25 0.175
28 0.202
30 0.229
33 0.257
35 0.287
38 0.318
40 0.356
43 0.395
45 0.435
48 0.477
52 0.523
56 0.574

Example Scripts 24-11


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

60 0.626
66 0.683
72 0.740
78 0.795
87 0.850
97 0.906
112 0.964
130 1.024
151 1.084
175 1.140
200 1.189
225 1.228
252 1.258
282 1.283
317 1.304
357 1.324
402 1.343
450 1.360
500 1.375
550 1.387
602 1.398
657 1.407
717 1.417
784 1.426
867 1.437
974 1.448
1117 1.461
1299 1.478
1515 1.495
1752 1.513

Example Scripts 24-12


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

2000 1.529
2253 1.543
2521 1.557
2820 1.570
3167 1.584
3570 1.600
4021 1.617
4503 1.634
5000 1.652
5503 1.669
6021 1.685
6570 1.701
7167 1.717
7839 1.733
8667 1.749
9745 1.769
11167 1.793
12992 1.820
15146 1.851
17518 1.882
20000 1.909
22552 1.931
25417 1.948
28906 1.961
33333 1.971
38932 1.981
Equation Based Curve Python Script
This sample Python script creates an equation based curve that produces a helix.
from math import pi, sin, cos

Example Scripts 24-13


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oProject = oDesktop.GetActiveProject()
oDesign = oProject.GetActiveDesign()
oEditor = oDesign.SetActiveEditor("3D Modeler")

Start_t = 0
End_t = pi*2

Npoint = 128
Nsection = Npoint-1

d_t = (End_t-Start_t)/Nsection

for n in range(1,Nsection):

P1 = Start_t+d_t*(n-1)
P2 = P1+d_t
X_t1 = cos(P1*6)
Y_t1 = sin(P1*6)
Z_t1 = P1
X_t2 = cos(P2*6)
Y_t2 = sin(P2*6)
Z_t2 = P2

oEditor.CreatePolyline(
[
"NAME:PolylineParameters",
"IsPolylineCovered:=" , True,
"IsPolylineClosed:=" , False,
[

Example Scripts 24-14


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"NAME:PolylinePoints",
[
"NAME:PLPoint",
"X:=" , '1mm*' + str(X_t1),
"Y:=" , '1mm*' + str(Y_t1),
"Z:=" , '1mm*' + str(Z_t1)
],
[
"NAME:PLPoint",
"X:=" , '1mm*' + str(X_t2),
"Y:=" , '1mm*' + str(Y_t2),
"Z:=" , '1mm*' + str(Z_t2)
]
],
[
"NAME:PolylineSegments",
[
"NAME:PLSegment",
"SegmentType:=" , "Line",
"StartIndex:=" , 0,
"NoOfPoints:=" , 2
]
],
[
"NAME:PolylineXSection",
"XSectionType:=" , "None",
"XSectionOrient:=" , "Auto",
"XSectionWidth:=" , "0mm",
"XSectionTopWidth:=" , "0mm",
"XSectionHeight:=" , "0mm",

Example Scripts 24-15


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"XSectionNumSegments:=" , "0",
"XSectionBendType:=" , "Corner"
]
],
[
"NAME:Attributes",
"Name:=" , "Polyline"+str(n),
"Flags:=" , "",
"Color:=" , "(132 132 193)",
"Transparency:=" , 0,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"vacuum\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , True,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False,
"IsLightweight:=" , False
])
HFSS Waveguide Array Python Script
This sample Python script creates an HFSS Waveguide array. The script includes comment lines,
which are preceded by an apostrophe ( ’ ), that offer explanations for each subsequent line or lines.
The script includes examples of creating a 3D model, boundaries and excitation, solution setup and
sweep, as well as reports.
You must insert an HFSS project before running the script. Running the script causes a series of
input dialogs to appear that lets you set parameters.
The first dialog asks for input for a and be dimensions and the waveguide length.

Example Scripts 24-16


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

The next asks for the array frequency.

The next asks for start, stop and step values for in an interpolating frequency sweep.

The last one asks for the array definition.

Example Scripts 24-17


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

The following figure shows the waveguide array generated by the defaults.

After running the simulation, the plots defined by the script shows the following results.

Example Scripts 24-18


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Example Scripts 24-19


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

The waveguide script in Python follows.

import clr
clr.AddReferenceByPartialName("Microsoft.VisualBasic")
from Microsoft.VisualBasic.Constants import
vbOKOnly,vbOKCancel,vbAbortRetryIgnore,vbYesNoCancel,vbYesNo,vbRetry-
Cancel
from Microsoft.VisualBasic.Constants import
vbOK,vbCancel,vbAbort,vbRetry,vbIgnore,vbYes,vbNo
from Microsoft.VisualBasic.Interaction import InputBox, MsgBox

oProject = oDesktop.GetActiveProject()

Example Scripts 24-20


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oDesign = oProject.GetActiveDesign()
oEditor = oDesign.SetActiveEditor("3D Modeler")

# Ask for dimensions for waveguide dimensions


# -------------------------------------------------------------
dim = InputBox("Please enter the dimensions for the waveguide 'a'
and 'b' dimensions "
+ "and the waveguide length in mm. Defaults are a = 23mm, b =
10mm, WaveguideLength = 25mm",
"Waveguide array generator", "23,10,25")
Dimensions = dim.split(',')

a_str = Dimensions[0] + "mm"


b_str = Dimensions[1] + "mm"
b_over2 = float(Dimensions[1])/2

WaveguideLength_str = Dimensions[2] + "mm"

#Ask for the frequency of operation


#----------------------------------
Frequency = InputBox("Please enter the desired array frequency.
Distances will " +
"be based on the free space wavelength at this frequency",
"Waveguide array generator", "10GHz")

#Ask for the start, stop, and step of the interpolating frequency
sweep
#-------------------------------------------------------------------
---
inputText = InputBox("Please enter the start, stop, and step of the
interpolating " +

Example Scripts 24-21


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"frequency sweep.", "Waveguide array generator",


"8GHz,12GHz,50MHz")
StartFrequency, StopFrequency, StepFrequency = inputText.split
(',')

#Ask for the number of elements in the x and y directions


#--------------------------------------------------------
inputText = InputBox("Please enter the number of elements in the x
and y directions.",
"Waveguide array generator", "7,7")
numX, numY = [float(elem) for elem in inputText.split(',')]
TotalElements = numX*numY

# Make variables and set them equal to the values from the user
input
# ------------------------------------------------------------------
-
oDesign.ChangeProperty(
[
"NAME:AllTabs",
[
"NAME:LocalVariableTab",
[
"NAME:PropServers",
"LocalVariables"
],
[
"NAME:NewProps",
[
"NAME:a", "PropType:=", "VariableProp", "UserDef:=", True,
"Value:=", a_str
],

Example Scripts 24-22


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

[
"NAME:b", "PropType:=", "VariableProp", "UserDef:=", True,
"Value:=", b_str
],
[
"NAME:NumX", "PropType:=", "VariableProp", "UserDef:=", True,
"Value:=", numX
],
[
"NAME:NumY", "PropType:=", "VariableProp", "UserDef:=", True,
"Value:=", numY
],
[
"NAME:WaveguideLength", "PropType:=", "VariableProp", "User-
Def:=", True,
"Value:=", WaveguideLength_str
],
[
"NAME:Frequency", "PropType:=", "VariableProp", "UserDef:=",
True,
"Value:=", Frequency
],
[
"NAME:Lambda", "PropType:=", "VariableProp", "UserDef:=", True,
"Value:=", "c0/" + Frequency
],
[
"NAME:RadBoundDist", "PropType:=", "VariableProp", "UserDef:=",
True,
"Value:=", "Lambda/4"
]

Example Scripts 24-23


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

]
]
])
#Create the radiation box
#------------------------
oEditor.CreateBox(
[
"NAME:BoxParameters",
"XPosition:=" , "-a/2-RadBoundDist",
"YPosition:=" , "-b/2-RadBoundDist",
"ZPosition:=" , "0mm",
"XSize:=" , "NumX*a+(NumX-1)*Lambda/2+2*RadBoundDist",
"YSize:=" , "NumY*b+(NumY-1)*Lambda/2+2*RadBoundDist",
"ZSize:=" , "RadBoundDist"
],
[
"NAME:Attributes",
"Name:=" , "RadiationBox",
"Flags:=" , "",
"Color:=" , "(132 132 193)",
"Transparency:=" , 0.8,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"vacuum\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , True,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False,
"IsLightweight:=" , False
])

Example Scripts 24-24


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oEditor.FitAll() # Zoom out


#Create first element
#--------------------
oEditor.CreateBox(
[
"NAME:BoxParameters",
"XPosition:=" , "-a/2",
"YPosition:=" , "-b/2",
"ZPosition:=" , "0mm",
"XSize:=" , "a",
"YSize:=" , "b",
"ZSize:=" , "-WaveguideLength"
],
[
"NAME:Attributes",
"Name:=" , "Element1",
"Flags:=" , "",
"Color:=" , "(132 132 193)",
"Transparency:=" , 0.8,
"PartCoordinateSystem:=", "Global",
"UDMId:=" , "",
"MaterialValue:=" , "\"vacuum\"",
"SurfaceMaterialValue:=", "\"\"",
"SolveInside:=" , True,
"IsMaterialEditable:=" , True,
"UseMaterialAppearance:=", False,
"IsLightweight:=" , False
])

Example Scripts 24-25


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

# Define the port


# ---------------
# Get the numeric value of half of the b dimension of the port.
# The values fed in to the "Start" and "End" arrays cannot have math-
ematical operators. For example, if HFSS
# has a variable 'b', and a desired coordinate is 'b/2', that value
cannot be entered here as "b/2". The number
# has to be computed explicitly in script and entered as a string
such as "-200mm".
oModule = oDesign.GetModule("BoundarySetup")

# get bottom face ID


element1FaceID = oEditor.GetFaceByPosition(
[
"NAME:Parameters",
"BodyName:=", "Element1",
"XPosition:=", "-a/2",
"YPosition:=", "-b/2",
"ZPosition:=", "-WaveguideLength"
])
oModule.AssignWavePort(
[
"NAME:WavePort1",
"Faces:=" , [element1FaceID],
"NumModes:=" , 1,
"RenormalizeAllTerminals:=", True,
"UseLineModeAlignment:=", False,
"DoDeembed:=" , False,
[
"NAME:Modes",
[

Example Scripts 24-26


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"NAME:Mode1",
"ModeNum:=" , 1,
"UseIntLine:=" , True,
[
"NAME:IntLine",
"Start:=" , ["0mm", "-" +str(b_over2) + "mm", "-" + Wave-
guideLength_str],
"End:=" , ["0mm", str(b_over2) + "mm", "-" + WaveguideLength_
str]
],
"AlignmentGroup:=" , 0,
"CharImp:=" , "Zpi"
]
],
"ShowReporterFilter:=" , False,
"ReporterFilter:=" , [True],
"UseAnalyticAlignment:=", False
])

#Set the radiation boundary


#--------------------------
# Get face IDs for further assignment
top_face_id = oEditor.GetFaceByPosition(["NAME:FaceParameters",
"BodyName:=", "RadiationBox",
"XPosition:=", "0mm",
"YPosition:=", "NumY*b-b/2+(NumY-1)*Lambda/2+RadBoundDist",
"ZPosition:=", "0mm"])

faceIDs = [int(elem) for elem in oEditor.GetFaceIDs("RadiationBox")


if elem != str(top_face_id)]
oModule.AssignRadiation(

Example Scripts 24-27


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

[
"NAME:Radiation",
"Faces:=" , faceIDs,
"IsFssReference:=" , False,
"IsForPML:=" , False
])

# Copy and paste elements/ports into a rectangular array.


# Duplicate boundaries with geometry" must be turned on under Tools-
>Options->HFSS Options
# ------------------------------------------------------------------
-----------------------
ElementNum = 1
for i in range(1, int(numX)+1):
for j in range(1, int(numY)+1):
if ElementNum == 1:
pass

elif ElementNum <= numY: #If in the first column, only


oEditor.Copy(["NAME:Selections", "Selections:=", "Element1"])
oEditor.Paste()
oEditor.Move(["NAME:Selections", "Selections:=", "Element" +
str(ElementNum)],
["NAME:TranslateParameters", "CoordinateSystemID:=", -1,
"TranslateVectorX:=", "0mm",
"TranslateVectorY:=", str(j-1) + "*(b+Lambda/2)",
"TranslateVectorZ:=", "0mm"])

elif ElementNum > numY:


oEditor.Copy(["NAME:Selections", "Selections:=", "Element1"])
oEditor.Paste()

Example Scripts 24-28


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

oEditor.Move(["NAME:Selections", "Selections:=", "Element" +


str(ElementNum)],
["NAME:TranslateParameters", "CoordinateSystemID:=", -1,
"TranslateVectorX:=", str(i-1) + "*(a+Lambda/2)",
"TranslateVectorY:=", str(j-1) + "*(b+Lambda/2)",
"TranslateVectorZ:=", "0mm"])

ElementNum += 1

#Create the setup and interpolating sweep


#----------------------------------------
oModule = oDesign.GetModule("AnalysisSetup")
oModule.InsertSetup("HfssDriven",
[
"NAME:Setup1",
"AdaptMultipleFreqs:=" , False,
"Frequency:=" , Frequency,
"MaxDeltaS:=" , 0.02,
"PortsOnly:=" , False,
"UseMatrixConv:=" , False,
"MaximumPasses:=" , 15,
"MinimumPasses:=" , 1,
"MinimumConvergedPasses:=", 1,
"PercentRefinement:=" , 50,
"IsEnabled:=" , True,
"BasisOrder:=" , 1,
"DoLambdaRefine:=" , True,
"DoMaterialLambda:=" , True,
"SetLambdaTarget:=" , False,
"Target:=" , 0.3333,

Example Scripts 24-29


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"UseMaxTetIncrease:=" , False,
"PortAccuracy:=" , 2,
"UseABCOnPort:=" , False,
"SetPortMinMaxTri:=" , False,
"UseDomains:=" , False,
"UseIterativeSolver:=" , False,
"SaveRadFieldsOnly:=" , False,
"SaveAnyFields:=" , True,
"IESolverType:=" , "Auto",
"LambdaTargetForIESolver:=", 0.15,
"UseDefaultLambdaTgtForIESolver:=", True
])

oModule.InsertFrequencySweep("Setup1",
[
"NAME:InterpolatingSweep",
"IsEnabled:=" , True,
"RangeType:=" , "LinearStep",
"RangeStart:=" , StartFrequency,
"RangeEnd:=" , StopFrequency,
"RangeStep:=" , StepFrequency,
"Type:=" , "Interpolating",
"SaveFields:=" , False,
"InterpTolerance:=" , 0.5,
"InterpMaxSolns:=" , 50,
"InterpMinSolns:=" , 0,
"InterpMinSubranges:=" , 1,
"ExtrapToDC:=" , False,
"InterpUseS:=" , True,
"InterpUsePortImped:=" , False,

Example Scripts 24-30


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"InterpUsePropConst:=" , True,
"UseDerivativeConvergence:=", False,
"InterpDerivTolerance:=", 0.2,
"UseFullBasis:=" , True,
"EnforcePassivity:=" , True,
"PassivityErrorTolerance:=", 0.0001
])

#Create a relative coordinate system centered on the array for radi-


ation pattern calculations
#-------------------------------------------------------------------
-------------------------
oEditor.CreateRelativeCS(
[
"NAME:RelativeCSParameters",
"Mode:=" , "Axis/Position",
"OriginX:=" , "-a/2+NumX*a/2+(NumX-1)*Lambda/4",
"OriginY:=" , "-b/2+NumY*b/2+(NumY-1)*Lambda/4",
"OriginZ:=" , "0mm",
"XAxisXvec:=" , "1mm",
"XAxisYvec:=" , "0mm",
"XAxisZvec:=" , "0mm",
"YAxisXvec:=" , "0mm",
"YAxisYvec:=" , "1mm",
"YAxisZvec:=" , "0mm"
],
[
"NAME:Attributes",
"Name:=" , "RelativeCS1"
])

Example Scripts 24-31


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

#Create an infinite sphere with fine theta resolution and phi cuts
at 0 and 90 degrees
#-------------------------------------------------------------------
------------------
oModule = oDesign.GetModule("RadField")
oModule.InsertFarFieldSphereSetup(
[
"NAME:Infinite Sphere1",
"UseCustomRadiationSurface:=", False,
"ThetaStart:=" , "-90deg",
"ThetaStop:=" , "90deg",
"ThetaStep:=" , "1deg",
"PhiStart:=" , "0deg",
"PhiStop:=" , "90deg",
"PhiStep:=" , "90deg",
"UseLocalCS:=" , True,
"CoordSystem:=" , "RelativeCS1"
])

#Create output plots for Ephi/Etheta real and imaginary components


for Phi = 0 and separately for Phi = 90
#-------------------------------------------------------------------
--------------------------------------
oModule = oDesign.GetModule("ReportSetup")
#For phi = 0
oModule.CreateReport("Etheta/Ephi Re/Im Components for Phi=0", "Far
Fields",
"Rectangular Plot", "Setup1 : LastAdaptive",
[
"Context:=" , "Infinite Sphere1"
],
[

Example Scripts 24-32


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"Theta:=" , ["All"],
"Phi:=" , ["0deg"],
"Freq:=" , ["All"],
"a:=" , ["Nominal"],
"b:=" , ["Nominal"],
"NumX:=" , ["Nominal"],
"NumY:=" , ["Nominal"],
"WaveguideLength:=" , ["Nominal"],
"Frequency:=" , ["Nominal"]
],
[
"X Component:=" , "Theta",
"Y Component:=" , ["im(rEPhi)","re(rEPhi)","im(rETheta)","re
(rETheta)"]
], [])

#For phi = 90
#------------
oModule.CreateReport("Etheta/Ephi Re/Im Components for Phi=90", "Far
Fields",
"Rectangular Plot", "Setup1 : LastAdaptive",
[
"Context:=" , "Infinite Sphere1"
],
[
"Theta:=" , ["All"],
"Phi:=" , ["90deg"],
"Freq:=" , ["All"],
"a:=" , ["Nominal"],
"b:=" , ["Nominal"],
"NumX:=" , ["Nominal"],

Example Scripts 24-33


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

"NumY:=" , ["Nominal"],
"WaveguideLength:=" , ["Nominal"],
"Frequency:=" , ["Nominal"]
],
[
"X Component:=" , "Theta",
"Y Component:=" , ["im(rEPhi)","re(rEPhi)","im(rETheta)","re
(rETheta)"]
], [])

Example Scripts 24-34


ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Index CreateObjectFromdges 10-86


CreateObjectFromFaces 10-88

3 CreatePoint 10-20

3D Modeler editor commands 10-1 CreatePolyline 10-23

AssignMaterial 10-74 CreateRectangle 10-27

Chamfer 10-75 CreateRegion 10-29

ChangeProperty 10-137 CreateRegularPolygon 10-33

Connect 10-76 CreateRegularPolyhedron 10-33

Copy 10-63 CreateRelativeCS 10-89

CoverLines 10-76 CreateSphere 10-35

CoverSurfaces 10-76 CreateSpiral 10-36

Create3DComponent 10-3 CreateTorus 10-37

CreateBondwire 10-5 CreateUserDefinedModel 10-39

CreateBox 10-5 CreateUserDefinedPart 10-22, 10-


41
CreateCircle 10-7
Delete 10-139
CreateCone 10-9
DeleteEmptyGroups 10-90
CreateCutplane 10-10
DeleteLastOperation 10-91
CreateCylinder 10-11
DeletePolylinePoint 10-63
CreateEllipse 10-12
DetachFaces 10-91
CreateEntityList 10-76
DuplicateAlongLine 10-63
CreateEquationCurve 10-14
DuplicateAroundAxi 10-65
CreateEquationSurface 10-16
DuplicateMirror 10-67
CreateFaceCS 10-80, 10-83
Edit3dComponent 10-44
CreateGroup 10-82
EditEntityList 10-92
CreateHelix 10-20

Index-1
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

EditFaceCS 10-93 Mirror 10-69


EditObjectCS 10-93 Move 10-70
EditPolyline 10-47 MoveCSToEnd 10-113
EditRelativeCS 10-96 MoveEntityToGroup 10-114
Export 10-97 MoveFaces 10-115
ExportModelImagetoFile 10-97 OffsetFaces 10-70
Fillet 10-100 PageSetup 10-162
FlattenGroup 10-101 ProjectSheet 10-117
GenerateHistory 10-102 RenamePart 10-163
GetActiveCoordinateSystem 10- Replacewith3DComponent 10-119
105
Rotate 10-71
GetBodyNamesByPosition 10-
140 Scale 10-72

GetCoordinateSystems 10-106 Section 10-121

GetEdgeByPosition 10-144 SeparateBody 10-122

GetEdgeIDsfromFace 10-145 SetModelUnits 10-122

GetEdgeIDsfromObject 10-146 SetWCS 10-123

GetEntityListIDByName 10-146 Split 10-124

GetFaceArea 10-147 Subtract 10-124

GetFaceByPosition 10-148 SweepAlongPath 10-54

GetFaceCenter 10-148 SweepAlongVector 10-56

GetFaceIDs 10-149 SweepAroundAxis 10-57

GetModelBoundingBox 10-151 SweepFacesAlongNormal 10-59, 10-


59, 10-125, 10-125
Import 10-106
SweepFacesAlongNormalWithAttributes
ImportDXF 10-109 10-60
ImportGDSII 10-111 ThickenSheet 10-127
Insert3DComponent 10-50, 10- UncoverFaces 10-128
51
Ungroup 10-130
InsertPolylineSegment 10-53
Unite 10-129
Intersect 10-113

Index-2
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

WrapSheet 10-131 Analysis module commands


Analyze 8-5
A
CopySetup 15-2, 16-4
Aborting Scripts 1-10
CopySweep 15-3, 15-53
Add 23-10, 23-68, 23-89, 23-108,
23-140 DeleteDrivenSweep 15-3, 15-4

Add Ground 23-1 DeleteSetups 15-4

AddAddSolverOnDemandModel 23- EditFrequencySweep 15-5, 15-8


29 EditSetup 15-6
AddAntennaOverlay 18-1 GetSetupCount 15-12
AddCartesianLimitLine 12-4 GetSetups 15-13
AddCartesianXMarker 12-5 GetSweepCount 15-13
AddCartesianYMarker 12-5 GetSweeps 15-14
AddDataset 7-1 InsertFrequencySweep 15-14, 15-
AddDeltaMarker 12-6 46

AddDesignVari- InsertSetup 15-22


ablesForDynamicLink 8-3 InsertSetup HFSS-IE 15-39
AddDynamicNPortData 23-23 InsertSetup Transient 15-40
Additional Property Scripting PasteSetup 15-50
Example 6-22
PasteSweep 15-50
AddMarker 12-7
RenameDrivenSweep 15-50
AddMarkerToPlot 18-3
RenameSetup 15-50
AddMaterial 23-1, 23-4
RevertAllToInitial 15-52
AddMessage 3-3
RevertSetupToInitial 15-52
AddNamedExpr 19-2
Analysis Setup Module Script Com-
AddNamedExpression 19-2 mands 15-1
AddNote 12-7 Analyze
AddNPortData 23-25 Analysis module command 8-5
AddScript 23-159 AnalyzeDistributed 8-5
AddTraceCharacteristics 12-9
AddTraces 12-11, 12-19

Index-3
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Ansoft Application Object AssignMaster 13-38


commands 2-1
AssignMaterial 10-74
GetAppDesktop 2-1
AssignModelResolutionOp 14-5
ApplyMeshOps 8-4, 8-30
AssignPerfectE 13-39
arithmetic operators 1-5
AssignPerfectH 13-39
array variables 1-3
AssignRadiation 13-40
AssignAperture 13-69
AssignScreeningImpedance 13-41
AssignArray 9-1
AssignSkinDepthLayerSetting 14-7
AssignCircuitPort 13-17, 13-51
AssignSkinDepthOp 14-7
AssignCurrent 13-19
AssignSlave 13-44
AssignCurvatureExtractionOp 14-6,
14-11 AssignSymmetry 13-45

AssignCurvilinearElementsOp 14-3, AssignTerminal 13-46


14-9 AssignTrueSurfOp 14-8
AssignDCThickness 8-6 AssignVoltage 13-47
AssignFEBI 13-19, 13-20 AssignWavePort 13-48
AssignFiniteCond 13-21, 13-70 AutoIdentifyNets 13-4
AssignFloquet 13-23 AutoIdentifyPorts 13-4
AssignHalfSpace 13-26, 13-71 AutoIdentifyTerminals 13-5
AssignHybridRegion 13-27
AssignIERegion 13-28 B

AssignImpedance 13-28, 13-72 Boundary and Excitation Module Script


Commands 13-1
AssignIncidentWave 13-29
Boundary/Excitation module commands
AssignInfiniteGroundPlane 13-72
AssignAperture 13-69
AssignLayeredImp 13-30
AssignCircuitPort 13-17, 13-51
AssignLengthOp 14-4
AssignCurrent 13-19
AssignLinkedRegion 13-32
AssignFEBI 13-19, 13-20, 13-32
AssignLumpedPort 13-33, 13-73
AssignFiniteCond 13-21, 13-70
AssignLumpedRLC 13-35
AssignFloquet 13-23
AssignMagneticBias 13-37

Index-4
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

AssignHalfSpace 13-26, 13-71 EditCurrent 13-52


AssignHybridRegion 13-27 EditFiniteCond 13-53
AssignIERegion 13-28 EditHalfSpace 13-54, 13-55
AssignImpedance 13-28, 13-72 EditImpedance 13-55
AssignIncidentWave 13-29 EditIncidentWave 13-55
AssignLayeredImp 13-30 EditLayeredImpedance 13-57
AssignLumpedPort 13-33 EditLumpedPort 13-57
AssignLumpedRLC 13-35 EditLumpedRLC 13-58
AssignMagneticBias 13-37 EditMagneticBias 13-59
AssignMaster 13-38 EditMaster 13-57
AssignPerfectE 13-39 EditPerfectE 13-57
AssignPerfectH 13-39 EditPerfectH 13-57
AssignRadiation 13-40 EditRadiation 13-59
AssignScreeningImpedance 13- EditSlave 13-60
41
EditSymmetry 13-60
AssignSlave 13-44
EditTerminal 13-60
AssignSymmetry 13-45
EditVoltage 13-61
AssignTerminal 13-46
EditVoltageDrop 13-61
AssignVoltage 13-47
EditWavePort 13-61
AssignWavePort 13-48
GetBoundaries 13-9
AutoIdentifyNets 13-4
GetBoundariesofType 13-9
AutoIdentifyPorts 13-4
GetBoundaryAssignment 13-9
AutoIdentifyTerminals 13-5
GetDefaultBaseName 13-10
ChangeImpedanceMult 13-5
GetExcitations 13-10
CircuitPortToLumpedPort 13-50
GetExcitationsOfType 13-10
ConvertNportCircuittoPort 13-6
GetNumBoundaries 13-11
DeleteAllBoundaries 13-8
GetNumBoundariesofType 13-11
DeleteAllExcitations 13-8
GetNumExcitations 13-11
DeleteBoundaries 13-8
GetNumExcitationsOfType 13-12

Index-5
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetPortExcitationsCounts 13-12 ClcEval 19-6


LumpedPortToCircuitPort 13-62 ClcMaterial 19-6
ReassignBoundaries 13-3, 13-6, ClearAllMarkers 12-16
13-12, 13-13
ClearAllNamedExpr 19-7
RenameBoundary 13-14
ClearAllTraceCharacteristics 12-18
ReprioritizeBoundary 13-15
ClearMessages 3-4, 5-2
SBR Wedge Settings 13-64, 13-
66 ClearSolutionCache 23-29

SetDefaultBaseName 13-15 CloneMaterial 23-3

SetHybridRegionCoupledGroup Close 5-3


13-62 CloseAllWindows 3-5
SetTerminalReferenceImpedances CloseProject 3-5
13-64
CloseProjectNoForce 3-6
SwapCircuitPortAssignment 13-
68 comment lines 1-11
UnassignIERegions 13-68 comparison operators 1-6
boundary/excitation script com- Component Manager Script
mands 13-2 Commands 23-9
BreakUDMConnection 10-136 conditional statements
BringToFront 23-96 If...Then... Else 1-7
Select Case 1-7
C
types of 1-7
CalcOp 19-3
Connect 10-76
CalcRead (deprecated) 19-3
ConstructVariationString 8-8
CalcStack 19-4
conventions
CalculatorRead 19-3
command syntax 1-87
CalculatorWrite 19-5
data types 1-87
Chamfer 10-75
script command 1-87
ChangeGeomSettings 19-5
converting data types 1-9
ChangeImpedanceMult 13-5
ConvertToDynamic 23-75
ChangeProperty 10-137, 12-15
ConvertToParametric 23-76
CircuitPortToLumpedPort 13-50

Index-6
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Copy 10-63 CreateFieldPlot 18-3


CopyDesign 5-3 CreateGroup 10-82
CopyNamedExprToStack 19-7 CreateHelix 10-20
CopyReportData 12-19 CreateObjectFromEdges 10-86
CopyReportDefinition 12-20 CreateObjectFromFaces 10-88
Copyright and Trademark Inform- CreateOutputVariable 11-1
ation 2
CreatePML;Boundary/Excitation mod-
CopySetup ule commands:CreatePML 13-
73
Analysis module command 15-2,
16-4 CreatePoint 10-20
Optimetrics module command 15- CreatePolyline 10-23
2, 16-4
CreateRectangle 10-27
CopySweep, Analysis module com-
mand 15-3, 15-53 CreateRegion 10-29

CopyTracesDefinitions 12-20 CreateRegularPolygon 10-33

Count 3-7 CreateRegularPolyhedron 10-33

CoverLines 10-76 CreateRelativeCS 10-89

CoverSurfaces 10-76 CreateReport 12-21

Create3DComponent 10-3 CreateReport [Designer] 12-26

CreateBondwire 10-5 CreateReportFromFile 12-31

CreateBox 10-5 CreateReportFromTemplate 12-31

CreateCircle 10-7 CreateReportofAllQuantities 12-33

CreateCone 10-9 CreateSphere 10-35

CreateCutplane 10-10 CreateSpiral 10-36

CreateCylinder 10-11 CreateTorus 10-37

CreateEllipse 10-12 CreateUserDefinedModel 10-39

CreateEntityList 10-76 CreateUserDefinedPart 10-22, 10-41

CreateEquationCurve 10-14 CreateUserDefinedSolution 21-1

CreateEquationSurface 10-16 CutDesign 5-4

CreateFaceCS 10-80, 10-83

Index-7
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

DeleteOp 14-2
D
DeleteOutputVariable 11-4
dataset commands
DeletePolylinePoint 10-63
AddDataset 7-1
DeleteProject 3-8
DeleteDataset 7-2
DeleteReport 12-35
EditDataset 7-3
DeleteSetups
ImportDataset 7-4
Analysis module command 15-3
Dataset Script Commands 7-1
Optimetrics module command 16-5
Definition Manager Script Com-
mands 23-1 DeleteSolutionVariation 17-5

Delete 10-139 Deletetraces 12-36

DeleteAllBoundaries 13-8 DeleteUserDefinedSolution 21-3

DeleteAllExcitations 13-8 DeleteVariation 8-13, 17-6

DeleteAllReports 12-35 Design object commands 12-44, 12-45, 12-


47, 12-48, 12-48, 12-49, 12-61, 12-
DeleteArray 9-2 62, 12-62
DeleteBoundaries 13-8 AddCartesianLimitLine 12-4
DeleteDataset 7-2 AddCartesianXMarker 12-5
DeleteDesign 5-4 AddCartesianYMarker 12-5
DeleteDrivenSweep 15-3, 15-4 AddDeltaMarker 12-6
DeleteEmptyGroups 10-90 AddDesignVariablesForDynamicLink 8-
DeleteFarFieldSetup 20-2 3

DeleteFieldPlot 18-17 AddMarker 12-7

DeleteFieldVariation 8-9 AddMarkerToPlot 18-3

DeleteFullVariation 8-11 AddNote 12-7

DeleteImportData 17-1 AddTraceCharacteristics 12-9

DeleteLastOperation 10-91 AddTraces 12-11, 12-19

DeleteLinkedDataVariation 8-12 AnalyzeDistributed 8-5

DeleteMarker 12-34 ApplyMeshOps 8-4, 8-30

DeleteNamedExpr 19-7 AssignDCThickness 8-6

DeleteNearFieldSetup 20-2 CalculatorRead 19-3, 19-5

Index-8
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ClearAllMarkers 12-16 GeometryCheckAndAutofix 8-46


ClearAllTraceCharacteristics 12- GetDesignValidationInfo 8-34
18
GetDisplayType 12-54
CloseAllWindows 3-5
GetEditSourcesCount 8-35
CopyReportData 12-19
GetExcitations 8-36
CopyReportDefinition 12-20
GetLibraryDirectory 3-20
CopyTracesData 12-20
GetMatchedObjectName 10-150
CreateOutputVariable 11-1
GetModelUnits 10-151
CreateReport 12-21
GetModule 8-38
CreateReportFromFile 12-31
GetName 8-40
CreateReportFromTemplate 12-
31 GetNominalVariation 8-40

CreateReportOfAllQuantities 12- GetNumObjects 10-153


33 GetObjectIDByName 10-154
DeleteAllReports 12-35 GetObjectName 10-154, 10-155
DeleteOutputVariable 11-4 GetObjectsByMaterial 10-155
DeleteReport 12-35 GetObjectsInGroup 10-156
DeleteTraces 12-36 GetOutputVariableValue 11-8
DoesOutputVariableExist 11-5 GetProjectDirectory 3-29
DoesRegistryValueExist 3-68 GetPropNames 8-42, 20-4
EditDesignSettings 8-13 GetRegistryInt 3-69
EditOutputVariable 11-6 GetRegistryString 3-69
ExportConvergence 8-17 GetSelections 10-159
ExportMeshStats 8-29 GetSolutionType 8-44
ExportPlotImageToFile 12-37, GetSolveInsideThreshold 8-45
12-38
GetSourceContexts 8-45
ExportProfile 8-30
GetTempDirectory 3-33
ExportReport 12-39
GetUser Position 10-159
ExportToFile 12-40, 12-41
GetVariationVariableValue 8-46
FFTOnReport 12-42
GetVersion 3-36

Index-9
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetVertexIDsFromEdge 10-160 SetRegistryString 3-70


GetVertexIDsFromFace 10-161 SetSolutionType 8-59
GetVertexIDsFromObject 10-161 SetSolveInsideThreshold 8-60
GetVertexPosition 10-161 SetSourceContexts 8-61
GroupPlotCurvesByGroup- SetTempDirectory 3-64
ingStrategy 12-66
ShowWindow 10-123
ImportIntoReport 12-67
Solve 8-61, 8-67
MovePlotCurvesToGroup 12-69
UnGroupPlotCurvesInGroup 12-85
MovePlotCurvesToNewGroup
12-70 UpdateAllReports 12-84

PasteDesign 8-48 UpdateReports 12-84

PasteReports 12-70 UpdateTraces 12-75

PasteTraces 12-71 UpdateTracesContextandSweeps 12-


82
Redo 8-49
ValidateDesign 8-67
RenameDesignInstance 8-49
Design Object Script Commands 8-1
RenameReport 12-72
Desktop Commands For Registry Values 3-
RenameTraces 12-72 68
ResetPlotSettings 12-73 Desktop object commands
ResetToTimeZero 8-50 AddMessage 3-3
RunToolkit 8-63 ClearMessages 3-4, 5-2
SARSetup 8-51 CloseProject 3-5
SavePlotSettingsAsDefault 12- CloseProjectNoForce 3-6
74
Count 3-7
SetActiveEditor 8-52
DeleteProject 3-8
SetDesignSettings 8-53
DownloadJobResults 3-9
SetLibraryDirectory 3-62
EnableAutosave 3-10
SetProjectDirectoryVBCommand>
3-63 ExportOptionsFiles 3-11

SetRegistryFromFile 3-69 GetActiveProject 3-12

SetRegistryInt 3-70 GetAutosaveEnabled 3-13

Index-10
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetBuildTimeDateString 3-14 RunProgram 3-56


GetChildNames 5-6, 8-31, 20-3 RunScript 3-56
GetChildNames Modeler 10-141 SelectScheduler 3-59
GetChildTypes 5-8, 8-32, 10-144, SetActiveProject 3-60
20-4
SetActiveProjectByPath 3-61
GetChildTypes Optimetrics 16-10
Sleep 3-65
GetChildTypes ReportSetup 12-
51 SubmitJob 3-66

GetDesigns 3-16 TileWindows 3-67

GetDistributedAnalysisMachines Desktop Object Script Commands 3-1


3-17 Desktop Scripting Conventions 1-86
GetDis- DetachFaces 10-91
trib-
utedAna- DistributedAnalyzeSetup, Optimetrics
lysisMachinesForDesignType module command 16-6
3-18
DoesOutputVariableExist 11-5
GetName 3-25
DoesRegistryValueExist 3-68
GetProjectList 3-30
Draw Menu commands 10-2
GetProjects 3-22, 3-28
DuplicateAlongLine 10-63
GetPropNames 5-13, 12-59, 16-
11 DuplicateAroundAxis 10-65

LaunchJobMonitor 3-40 DuplicateMirror 10-67

NewProject 3-41 E
OpenMultipleProjects 3-43
Edit 23-29, 23-76, 23-76, 23-96, 23-
OpenProject 3-43 96, 23-124, 23-145

PasteDesign 3-44 Edit Menu Commands 10-62

PauseRecording 3-47 Edit3DComponent 10-43, 10-44

PauseScript 3-48 EditAntennaArraySetup 20-20

Print 3-49 EditAntennaOverlay 18-17

QuitApplication 3-50 EditArray 9-3

RefreshJobMonitor 3-51 EditBoxSetup 20-7

RestoreWindow 3-54 EditCircuitSettings 15-4

Index-11
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

EditCurrent 13-52 EditPolyline 10-47


EditDataset 7-3 EditRadiation 13-59
EditDesignSettings 8-13 EditRelativeCS 10-96
EditDiffPairs 13-52 EditScript 23-160
EditEntityList 10-92 EditSetup
EditFaceCS 10-93 Analysis module command 15-6
EditFiniteCond 13-53 optimization command 16-22
EditFrequencySweep 15-5, 15-8 parametric command 16-17
EditHalfSpace 13-54, 13-55 sensitivity command 16-34
EditImpedance 13-55 statistical command 16-42
EditIncidentWave 13-55 EditSkinOp 14-12
EditInfiniteSphereSetup 20-8 EditSlave 13-60
EditLayeredImpedance 13-57 EditSolverOnDemandModel 23-48
EditLengthOp 14-10 EditSources 17-2
EditLumpedPort 13-57 EditSymmetry 13-60
EditLumpedRLC 13-58 EditTerminal 13-60
EditMagneticBias 13-59 EditTrueSurfOp 14-12
EditMaster 13-57 EditUserDefinedSolution 21-4
EditMaterial 23-5 EditVoltage 13-61
EditModelResolutionOp 14-10 EditVoltageDrop 13-61
EditNearFieldLineSetup 20-10 EditWavePort 13-61
EditNearFieldRectangleSetup 20- EditWithComps 23-48, 23-76, 23-97, 23-
11 124, 23-150
EditNearFieldSphereSetup 20-12 EnableAutoSave 3-10
EditNotes 8-16 EnterComplex 19-8
EditObjectCS 10-93 EnterComplexVector 19-8
EditOutputVariable 11-6 EnterLine 19-9
EditPerfectE 13-57 EnterPoint 19-9
EditPerfectH 13-57 EnterQty 19-9

Index-12
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

EnterScalar 19-10 ExportParametricResults, Optimetrics


module command 16-8
EnterScalarFunc 19-10
ExportPlotImageToFile 12-37, 12-38
EnterSurf 19-11
ExportProfile 8-30
EnterVector 19-11
ExportRadiationParametersToFile 20-
EnterVectorFunc 19-12 24
EnterVol 19-12 ExportReport 12-39
Event Callback Scripting 1-91 ExportScript 23-161
Example Scripts 24-1 ExportToFile 12-40, 12-41, 19-14
Export 10-97, 23-56, 23-84, 23-105,
23-136, 23-156 F
ExportCircuit 15-9 FFTONReport 12-42
ExportConvergence 8-17 Field Overlay module commands,
ExportDXConfigFile, Optimetrics GetFieldPlotNames 18-19
module command 16-6 field overlay script commands 18-1
ExportEignemodes 17-6 Field Overlays module commands
ExportForHSpice 17-7 AddNamedExpr 19-2
ExportFullWaveSpice 22-1 AddNamedExpression 19-2
ExportMarkerTable 12-42 CalcOp 19-3
ExportMaterial 23-7 CalcStack 19-4
ExportMatrixData 8-18 ChangeGeomSettings 19-5
ExportMesh Stats 8-29 ClcEval 19-6
ExportModelImagetoFile 10-97 ClcMaterial 19-6
ExportNetworkData 8-21, 17-9, 22-2 ClearAllNamedExpr 19-7
ExportNMFData 8-25, 17-13, 22-3 CopyNamedExprToStack 19-7
ExportOnGrid 19-12 CreateFieldPlot 18-3
ExportOptimetricsProfile, Optimetrics DeleteFieldPlot 18-17
module command 16-7
DeleteNamedExpr 19-7
ExportOptimetricsResults, Opti-
metrics module command 16- EnterComplex 19-8
8
EnterComplexVector 19-8
ExportOptionsFiles 3-11

Index-13
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

EnterLine 19-9 EnterLine 19-9


EnterPoint 19-9 EnterPoint 19-9
EnterQty 19-9 EnterQty 19-9
EnterScalar 19-10 EnterScalar 19-10
EnterScalarFunc 19-10 EnterScalarFunc 19-10
EnterSurf 19-11 EnterSurf 19-11
EnterVector 19-11 EnterVector 19-11
EnterVectorFunc 19-12 EnterVectorFunc 19-12
EnteVol 19-12 EnterVol 19-12
ExportOnGrid 19-12 ExportOnGrid 19-12
ExportToFile 19-14 ExportToFile 19-14
ModifyFieldPlot 18-21 Fields Calculator Script Commands 19-1
RenameFieldPlot 18-22 Fillet 10-100
RenamePlotFolder 18-23 FlattenGroup 10-101
SetFieldPlotSettings 18-23 footprint
SetPlotFolderSettings 18-24 manager script commands 23-108
UpdateAllFieldsPlots 18-29 For...Next loop 1-8
UpdateQuantityFieldsPlots 18-29 functions
Fields Calculator commands VBScript procedures 1-9
AddNamedExpr 19-2, 19-2, 19-7
G
CalcOp 19-3
GenerateHistory 10-102
CalcStack 19-4
GenerateVariationData Parametric, para-
ChangeGeomSettings 19-5 metric command 16-18
ClcEval 19-6 GeometryCheckAndAutofix 8-46
ClcMaterial 19-6 Get3DComponentDefinitionNames 10-48
CopyNamedExprToStack 19-7 Get3DComponentInstanceNames 10-48
DeleteNamedExpr 19-7 Get3DComponentMaterialNames 10-49
EnterComplex 19-8 Get3DComponentMaterialProperties 10-49
EnterComplexVector 19-8

Index-14
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Get3DComponentParameters 10- GetChildTypes 5-8, 8-32, 10-144, 20-4


47
GetChildTypes Optimetrics 16-10
GetActiveCoordinateSystem 10-105
GetChildTypes ReportSetup 12-51
GetActiveDesign 5-5
GetCoordinateSystems 10-106
GetActiveProject 3-12
GetData 23-57, 23-64, 23-85, 23-105,
GetAdaptiveFreq 17-14 23-137, 23-156
GetAllCategories 12-44 GetDataExpressions 12-51
GetAllQuantities 12-47 GetDataUnits 12-52
GetAllReportNames 12-45 GetDefaultBaseName 13-10
GetArrayVariables 6-14 GetDefinitionManager 5-8
GetAutoSaveEnabled 3-13 GetDependentFiles 5-9
GetAvailableDisplayTypes 12-48 GetDesigns 3-16
GetAvailableReportTypes 12-48 GetDesignType 8-33
GetAvailableSolutions 12-49 GetDesignValidationInfo 8-34
GetAvailableVariations 17-14 GetDesignVariableNames 12-52
GetBodyNamesByPosition 10-140 GetDesignVariableUnits 12-53
GetBoundaries 13-9 GetDesignVariableValue 12-53
GetBoundariesOfType 13-9 GetDesignVariationKey 12-54
GetBoundaryAssignment 13-9 GetDisplayType 12-54
GetBuildDateTimeString 3-14 GetDistributedAnalysisMachines 3-17
GetChild Object (Report Setup), GetDis-
Report module command 12- trib-
50 utedAna-
lysisMachinesForDesignType 3-
GetChildNames 5-6, 8-31, 20-3 18
GetChildNames (Optimetrics), GetEdgeByPosition 10-144
Report module command 12-
49 GetEdgeIDsFromFace 10-145
GetChildNames Modeler 10-141 GetEdgeIDsFromObject 10-146
GetChildObject Design 5-7, 8-31 GetEditSourcesCount 8-35
GetChildObject Modeler 10-142 GetEntityListIDByName 10-146
GetChildObject Radiation 20-3 GetExcitations 8-36, 13-10

Index-15
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetExcitationScaling 17-15 GetOperationNames, Mesh Operations


module command 14-2
GetExcitationsOfType 13-10
GetOutputVariableValue 11-8
GetExeDir 3-19
GetPath 5-11
GetFaceArea 10-147
GetPerQuantityPrimarySweepValues 12-
GetFaceByPosition 10-148
56
GetFaceCenter 10-148
GetPersonalLibDirectory 3-26
GetFaceIDs 10-149
GetPortExcitationsCounts 13-12
GetFieldPlotNames, Field Overlay
GetProcessID 3-27
module command 18-19
GetProjectDirectory 3-29
GetImagDataValues 12-55
GetProjectList 3-30
GetLibraryDirectory 3-20
GetProjects 3-22, 3-28
GetMatchedObjectName 10-150
GetProperties 6-14, 23-66
GetModelBoundingBox 10-151
GetPropertyValue 6-16, 10-156, 12-57
GetModelUnits 10-151
GetPropNames 5-13, 8-42, 12-59, 16-11,
GetModule 8-38
20-4
GetName 3-25, 5-11, 8-40
GetPropNames Modeler 10-152
GetNames 23-58, 23-65, 23-86, 23-
GetPropValue Modeler 10-152
106, 23-138, 23-157
GetPropValue Optimetrics 16-11
GetNominalVariation 8-40
GetPropValue Project 5-13, 8-42, 20-4
GetNPortData 23-60
GetPropValue Reporter 12-59
GetNumBoundaries 13-11
GetRealDataValues 12-60
GetNumBoundariesOfType 13-11
GetRegistryInt 3-69
GetNumExcitations 13-11
GetRegistryString 3-69
GetNumExcitationsOfType 13-12
GetReportTraceNames 12-61
GetNumObjects 10-153
GetSelections 8-43, 10-159
GetObjectIDByName 10-154
GetSetupCount, Analysis module
GetObjectName 10-154, 10-155
command 15-12
GetObjectsByMaterial 10-155
GetSetupNames 15-13, 20-3, 20-5
GetObjectsIngroup 10-156

Index-16
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetSetupNames (Optimetrics), Opti- GetValidISolutionList 17-16


metrics module command 16-
9, 16-10, 16-11 GetVariables 6-18

GetSetupNamesByType (Opti- GetVariableValue 6-19


metrics), Optimetrics module GetVariationVariableValue 8-46
command 16-12
GetVersion 3-36
GetSetups
GetVertexIDsFromEdge 10-160
Analysis module command 15-12
GetVertexIDsFromFace 10-161
GetSolutionContexts 12-62
GetVertexIDsFromObject 10-161
GetSolutionDataPerVariation 12-62
GetVertexPosition 10-161
GetSolutionType 8-44
GroupPlotCurvesByGroupingStrategy
GetSolutionVesrionID 17-15 12-66
GetSolveInsideThreshold 8-45
H
GetSolveRangeInfo 17-16
HasFields 17-17
GetSolverOnDemandData 23-61
HealObject 10-102
GetSolverOnDemandModelList 23-
61 HideAntennaParametersOverlay 18-
20
GetSourceContexts 8-45
hierarchy of variables in HFSS 1-76
GetSweepCount, Analysis module
command 15-13
I
GetSweepNames 12-64
If...Then... Else statement 1-7
GetSweeps
Import (3D Modeler command) 10-106
Analysis module command 15-14
ImportANF 3-37
GetSweepUnits 12-65
ImportAutoCAD 3-38
GetSweepValues 12-66
ImportDataset 7-4
GetSysLibDirectory 3-32
ImportDXF 10-109
GetTempDirectory 3-33
ImportGDSII 3-38, 10-111
GetTopDesignList 5-12
ImportIntoReport 12-67
GetTopEntryValue 19-15
ImportODB 3-39
GetUserLibDirectory 3-34
ImportSetup, Optimetrics module com-
GetUserPosition 10-159 mand 16-13

Index-17
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ImportSolution 17-18 IronPython 1-13


ImportTable 17-19 IronPython, indentation 1-19
include files IsDataComplex 12-68
scripts 1-10 IsFieldAvailableAt 17-21
indentation, IronPython 1-19 IsPerQuantityPrimarySweep 12-68
InitialMeshSettings 14-13 IsUsed 23-61, 23-67, 23-86, 23-106, 23-
138, 23-157
InputBox function 1-10
Insert3DComponent 10-50, 10-51 K
InsertBoxSetup 20-13 keywords, VBScript 1-11
InsertDesign 5-14
L
InsertDesignWithWorkflow 5-16
InsertFarFieldSphereSetup 20-15 LaunchJobMonitor 3-40

InsertFrequencySweep 15-14, 15- Layout Scripting 1-90


46 ListMatchingVariations 17-21
InsertNearFieldLineSetup 20-16 ListValuesOfVariable 17-22
InsertNearFieldRectangleSetup 20- ListVariations 17-22, 17-22
17
LoadNamedExpressions 19-15
InsertNearFieldSphereSetup 20-18
logical operators 1-6
InsertPolylineSegment 10-53
looping through code
InsertSetup
Do ... Loop 1-8
Analysis module command 15-22
For ... Next 1-8
optimization command 16-26
LumpedPortToCircuitPort 13-62
parametric command 16-18
sensitivity command 16-39 M
statistical command 16-45 material commands
InsertSetup HFSS-IE, Analysis mod- AddMaterial 23-1, 23-4
ule command 15-39
CloneMaterial 23-3
InsertSetup Transient, Analysis mod-
ule command 15-40 EditMaterial 23-5

Intersect 10-113 ExportMaterial 23-7

Index-18
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

RemoveMaterial 23-7 DeleteArray 9-2


Mesh Operations module commands EditArray 9-3
AssignCurvatureExtrationOp 14- Model Setup Script Commands 9-1
6, 14-11
Modeler Menu Commands 10-72
AssignCurvilinearElementsOp
14-3, 14-9 ModifyFieldPlot 18-21

AssignLengthOp 14-4 ModifyLibraries 23-162

AssignModelResolutionOp 14-5 ModifyPMLGroup;Boundary/Excitation


module com-
AssignSkinDepthLayerSetting mands:ModifyPMLGroup 13-75
14-7
module script commands
AssignSkinDepthOp 14-7
boundary/excitation 13-2
AssignTrueSurfOp 14-8
field overlay 18-1
DeleteOp 14-2
mesh operations 14-1
EditLengthOp 14-10
radiation 20-1
EditModelResolutionOp 14-10
ModuleHasMatrixData 17-17
EditSkinOp 14-12
ModuleHasMesh 17-18
EditTrueSurfOp 14-12
modules in HFSS scripting 1-76
GetOperationNames 14-2
Move 10-70
InitialMeshSettings 14-13
MoveCSToEnd 10-113
RenameOp 14-2
MoveEnityToGroup 10-114
Mesh Operations Module Script Com-
mands 14-1 MoveFaces 10-115

mesh operations script MovePlotCurvestoGroup 12-69


commands 14-1 MovePlotCurvestoNewGroup 12-70
Microsoft MsgBox function 1-10
VBScript user’s guide 1-11
N
Mirror 10-69
Named Arguments 1-89
Model Manager Script
Commands 23-68 NdExplorer
Model Setup commands Script Commands 22-1
AssignArray 9-1 NewProject 3-41

Index-19
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

GetSetupNamesByType 16-12
O
ImportSetup 16-13
oAnsoftApp object 1-76
RenameSetup 16-14
oDesign object 1-76
SolveSetup 15-2, 16-4, 16-16, 16-16
oDesktop object 1-76
Optimetrics Module Script Commands 16-1
oEditor object 1-76
optimization commands
OffsetFaces 10-70
EditSetup 16-22
oModule object 1-76
InsertSetup 16-26
OpenAndConvertProject 3-42
Optimization Script Commands 16-22
OpenExternalEditor 10-162
Other oEditor Commands 10-132
OpenMultipleProjects 3-43
output variable commands
OpenProject 3-43
CreateOutputVariable 11-1
operators
DeleteOutputVariable 11-4
arithmetic 1-5
DoesOutputVariableExist 11-5
categories in VBScript 1-4
EditOutputVariable 11-6
comparison 1-6
GetOutputVariableValue 11-8
concatenation 1-6
Output Variable Script Commands 11-1
logical 1-6
precedence of 1-4 P
oProject object 1-76 Padstack Manager Script Commands 23-
140
Optimetrics module commands
PageSetup 10-162
DeleteSetups 16-5
parametric commands
DistributeAnalyzeSetup 16-6
EditSetup 16-17
ExportDXConfigFile 16-6
GenerateVariationData Parametric 16-
ExportOptimetricsProfile 16-7
18
ExportOptimetricsResults 16-8
InsertSetup 16-18
ExportParametricResults 16-8
Parametric Script Commands 16-17
GetChildNames 16-9, 16-10
Paste 3-44, 3-46, 5-18, 8-48
GetSetupNames 16-12
Paste (Model Editor) 10-71

Index-20
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Paste (Project Object) 3-46, 5-18 EditMaterial 23-5


PasteDesign 3-44, 8-48 ExportMaterial 23-7
PasteReports 12-70 GetActiveDesign 5-5
PasteSetup GetArrayVariables 6-14
Analysis module command 15-50 GetChildObject Design 5-7, 8-31
Optimetrics module command 16- GetChildObject Modeler 10-142
14
GetChildObject Radiation 20-3
PasteSweep, Analysis module com-
mand 15-50 GetDependentFiles 5-9

PasteTraces 12-71 GetDesignType 8-33

PauseRecording 3-47 GetName 5-11

PauseScript 3-48 GetPath 5-11

PMLGroupCreated;Bound- GetProperties 6-14


ary/Excitation module com- GetPropertyValue 6-16, 10-156,
mands:PMLGroupCreated 13- 12-57
76
GetPropNames Modeler 10-152
PMLGroupModi-
fied;Boundary/Excitation mod- GetPropvalue Modeler 10-152
ule
com- GetPropvalue Optimetrics 16-11
mands:PMLGroupModified GetPropvalue Project 5-13, 8-42
13-76
GetPropvalue Radiation 20-4
Print 3-49
GetPropvalue Reporter 12-59
Project object commands
GetTopDesignList 5-12
AddDataset 7-1
GetTopEntryValue 19-15
AddMaterial 23-1, 23-4
GetVariables 6-18
CloneMaterial 23-3
GetVariableValue 6-19
Close 5-3
InsertDesign 5-14
CopyDesign 5-3
Paste 3-44, 3-46, 3-46, 5-18, 5-18,
CutDesign 5-4 8-48
DeleteDataset 7-2 Redo 5-19
DeleteDesign 5-4 RemoveMaterial 23-7
EditDataset 7-3, 7-4

Index-21
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Rename 5-20 Property Script Commands 6-1


RestoreProjectArchive 3-53, 5- Conventions uSed in thie Chapter 6-9
20
Object Script Property Function Sum-
Save 5-21 mary 6-2
SaveAs 5-22 PurgeHistory 10-118
SaveProjectArchive 5-24
Q
SetActiveDesign 5-26, 8-57, 8-59
QuitApplication 3-50
SetPropertyValue 6-19
SetPropValue Design 8-58, 20-6 R
SetPropValue Modeler 10-164 Radiation module commands
SetPropValue Optimetrics 16-15 DeleteFarFieldSetup 20-2
SetPropValue Project 5-27, 12- DeleteNearFieldSetup 20-2
75
EditAntennaArraySetup 20-20
SetVariableValue 6-21
EditBoxSetup 20-7
SimulateAll 5-2, 5-28
EditInfiniteSphereSetup 20-8
Undo 5-28
EditNearFieldLineSetup 20-10
UpdateDefinitions 5-29
EditNearFieldRectangleSetup 20-11
Project Object Script Commands 5-
1 EditNearFieldSphereSetup 20-12

ProjectSheet 10-117 EditRadiatedPowerCalculationMethod


20-3
property commands
ExportRadiationParametersToFile 20-
GetArrayVariables 6-14 24
GetProperties 6-14 GetSetupNames 15-13, 20-5
GetPropertyValue 6-16, 10-156, InsertBoxSetup 20-13
12-57
InsertFarFieldSphereSetup 20-15
GetTopEntryValue 19-15
InsertNearFieldLineSetup 20-16
GetVariables 6-18
InsertNearFieldRectangleSetup 20-17
GetVariableValue 6-19
InsertNearFieldSphereSetup 20-18
SetPropertyValue 6-19
RenameSetup 20-5
SetVariableValue 6-21

Index-22
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Radiation Module Script RenamePart 10-163


Commands 20-1
RenamePlotFolder 18-23
radiation script commands 20-1
RenameReport 12-72
ReassignBoundaries 13-3, 13-6, 13-
6, 13-12, 13-13 RenameSetup

Recal- Analysis module command 15-50


culatePMLMa- Optimetrics module command 16-
terials;Boundary/Excitation 14
module com-
mand- Radiation module command 20-5
s:RecalculatePMLMaterials
13-76 RenameSweep 15-51

Record Script and Edit Properties 6- RenameTraces 12-72


25 Repeating a Statement Until a Condi-
Redo tion Becomes True 1-8

design-level command 8-49 Repeating Statements While a Condi-


tion is True 1-8
project-level command 5-19
Replacewith3DComponent 10-119
references, for VBScript 1-11
Report module commands
RefreshJobMonitor 3-51
GetChildNames 12-49
ReleaseData 12-71
Reporter editor commands
Remove 23-62, 23-87, 23-106, 23-
138, 23-157 AddCartesianLimitLine 12-4

RemoveMaterial 23-7 AddCartesianXMarker 12-5, 12-5

RemoveScript 23-161 AddDeltaMarker 12-6

RemoveSolverOnDemandModel AddMarker 12-7


23-62 AddMarkerToPlot 18-3
RemoveUnused 23-63, 23-67, 23- AddNote 12-7
88, 23-107, 23-139, 23-158
AddTraceCharacteristics 12-9
Rename 5-20
AddTraces 12-11, 12-19
RenameBoundary 13-14
ClearAllMarkers 12-16
RenameDesignInstance 8-49
ClearAllTraceCharacteristics 12-18
RenameDrivenSweep 15-50
CopyReportDefinition 12-19, 12-20
RenameFieldPlot 18-22
CopyTracesData 12-20
RenameOp 14-2

Index-23
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

CreateReport 12-21, 12-33 ResetPlotSettings 12-73


CreateReportFromFile 12-31 SavePlotSettingsAsDefault 12-74
CreateReportFromTemplate 12- UnGroupPlotCurvesInGroup 12-85
31
UpdateAllReports 12-84
DeleteAllReports 12-35
UpdateReports 12-84
DeleteReport 12-35
UpdateTraces 12-75
DeleteTraces 12-36
UpdateTracesContextandSweeps 12-
ExportPlotImageToFile 12-37, 82
12-38
Reporter Editor Script Commands 12-1
ExportReport 12-39
Reporter module commands
ExportToFile 12-40, 12-41, 12-67
GetChildObject 12-50
FFTOnReport 12-42
ReportSetup commands
GetAllCategories 12-44
ChangeProperty 12-15
GetAllQuantities 12-47
ReprioritizeBoundary 13-15
GetAllReportNames 12-45
ResetPlotSettings 12-73
GetAvailableDisplayTypes 12-48
RestoreWindow 3-54
GetAvailableReportTypes 12-48
RestToTimeZero 8-50
GetAvailableSolutionss 12-49
ResumeRecording 3-55
GetDisplayType 12-54
RevertAllToInitial 15-52
GetReportTraceNames 12-61
RevertSetupToInitial 15-52
GetSolutionContextss 12-62, 12-
62 Rotate 10-71

GroupPlotCurvesByGroup- Running Instance Manager Script Com-


ingStrategy 12-66 mands 4-1

MovePlotCurvestoGroup 12-69 RunProgram 3-56

MovePlotCurvestoNewGroup RunScript 3-56


12-70 RunScriptWithArguments 3-58
PasteReports 12-70 RunToolkit 8-63
PasteTraces 12-71
RenameReport 12-72
RenameTraces 12-72

Index-24
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

Script Commands for Exporting


S Antenna Parameters and Max
Field Parameters 20-24
sample scripts
Script Commands for Modifying
simple HFSS 1-11
Antenna Array Setups 20-20
variable helix 24-13
scripts
waveguide 24-16
IronPython 1-13
SARSetup 8-51
overview 1-1
Save 5-21
recording 1-81
SaveAs 5-22
running 1-83
SaveNamedExpressions 19-16
stopping 1-85
SavePlotSettingsAsDefault 12-74
VBScript 1-1
Scale 10-72
Scripts and Locked Layers 1-91
Scope and Lifetime of Variables 1-3
Section 10-121
Script and Library Scripts 23-159
Select Case statement 1-7
script commands
SelectScheduler 3-9, 3-59
boundary/excitation 13-2
sensitivity commands
field overlay 18-1
EditSetup 16-34
mesh operations 14-1
InsertSetup 16-39
radiation 20-1
Sensitivity Script Commands 16-34
Script Commands for Creating and
SeparateBody 10-122
Modifying Boundaries in
HFSS-IE 13-69 Set SBR Sources 13-64
Script Commands for Creating and Set SBR Wedge Settings 13-66
Modifying PMLs 13-73
SetActiveDefinitionEditor 5-25
Script Commands for Creating and
Modifying Mesh SetActiveDesign 5-26, 8-57, 8-59
Operations 14-3 SetActiveEditor 8-52
Script Commands for Creating and SetActiveProject 3-60
Modifying Boundaries 13-16
SetActiveProjectByPath 3-61
Script Commands for Creating and
Modifying Radiation SetBackgroundMaterial 8-52
Setups 20-6
SetDefaultBaseName 13-15

Index-25
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

SetDesignSettings 8-53 simple and composite names 1-2


SetFieldPlotSettings 18-23 SimulateAll 5-2, 5-28
SetHybridRegionCoupledGroup 13- SimValueContext 11-16
62
Sleep 3-65
SetLengthSettings 8-55
Solutions module commands
SetLibraryDirectory 3-62
ConstructVariationString 8-8
SetModelUnits 10-122
DeleteFieldVariation 8-9
SetPlotFolderSettings 18-24
DeleteFullVariation 8-11
SetProjectDirectory 3-63
DeleteImportData 17-1
SetPropertyValue 6-19
DeleteLinkedDataVariation 8-12
SetPropValue Design 8-58, 20-6
DeleteSolutionVariation 17-5
SetPropValue Modeler 10-164
DeleteVariation 17-6
SetPropValue Optimetrics 16-15
EditSources 17-2
SetPropValue Project 5-27, 12-75
ExportEigenmodes 17-6
SetRegistryFromFile 3-69
ExportForHSpice 17-7
SetRegistryInt 3-70
ExportNetworkData 8-21, 17-9
SetRegistryString 3-70
ExportNMF 17-13
SetSolutionType 8-59
GetAdaptiveFreq 17-14
SetSolveInsideThreshold 8-60
GetAvailableVariations 17-14
SetSourceContexts 8-61
GetExcitationScaling 17-15
SetTempDirectory 3-64
GetSolutionVersionID 17-15
SetTerminalReferenceImpedances
13-64 GetSolveRangeInfo 17-16

Setting Numerical Values 1-90 GetValidISolutionLIst 17-16

SetVariableValue 6-21 HasFields 17-17

SetWCS 10-123 ImportSolution 17-18

SGetAppDesktop 2-1 ImportTable 17-19

ShowAntennaParameterOverlay IsFieldAvailableAt 17-21


18-28 ListMatchingVariations 17-21
ShowlWindow 10-123

Index-26
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

ListValuesOfVariable 17-22
T
ListVariations 17-22, 17-22
ThickenSheet 10-127
ModuleHasMatrixData 17-17
TileWindows 3-67
ModuleHasMesh 17-18
Solutions Module Script U
Commands 17-1
UnassignIERegions 13-68
Solve 8-61
UncoverFaces 10-128
SolveAllSetup, Optimetrics module
command 16-16 underscore ( _ ) character 1-11

SolveSetup, Optimetrics module com- Undo


mand 16-16 design-level command 8-67
Split 10-124 project-level command 5-28
statistical commands Ungroup 10-130
EditSetup 16-42 UnGroupPlotCurvesInGroup 12-85
InsertSetup 16-45 Unite 10-129
Statistical Script Commands 16-42 UpdateAllFieldsPlots 18-29
string concatenation operator 1-6 UpdateAllReports 12-84
Sub procedures 1-11 UpdateComponentDefinition 10-62
Sub Procedures 1-9 UpdateDefinitions, project-level com-
SubmitJob 3-66 mand 5-29

Subtract 10-124 UpdateDynamicLink 23-64

SwapCircuitPortAssignment 13-68 UpdateQuantityFieldsPlots 18-29

SweepAlongPath 10-54 UpdateReports 12-84

SweepAlongVector 10-56 UpdateTraces 12-75

SweepAroundAxis 10-57 UpdateTracesContextandSweeps 12-


82
SweepFacesAlongNormal 10-59,
10-59, 10-125, 10-125 User Defined Solutions
Commands 21-1
Sweep-
FacesAlongNormalWithAt- UserDefinedSolutions module com-
tributes 10-60 mands

Symbol Manager Script CreateUserDefinedSolution 21-1


Commands 23-88

Index-27
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.
HFSS Scripting Guide

DeleteUserDefinedSolution 21-3
EditUserDefinedSolution 21-4
Using a Do Loop 1-8

V
ValidateDesign 8-67
Variable Naming Conventions 1-3
variables
array 1-3
assigning information 1-2
declaring 1-2
hierarchy in HFSS 1-76
used as objects 1-11
used in HFSS scripts 1-76
VBScript 1-1
Microsoft user’s guide 1-11
operators 1-4
references 1-11
Sub procedures 1-11
VBScript Procedures 1-9

W
WrapSheet 10-131

Index-28
ANSYS Electromagnetics Suite 2020 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
information of ANSYS, Inc. and its subsidiaries and affiliates.

You might also like