MacroHFSS

download MacroHFSS

of 254

Transcript of MacroHFSS

  • 8/19/2019 MacroHFSS

    1/254

    HFSS v9.0

    Introduction to Scripting

    in HFSS

    June2003

  • 8/19/2019 MacroHFSS

    2/254

    The information contained in this document is subject to change without notice.

    Ansoft makes no warranty of any kind with regard to this material, including,

    but not limited to, the implied warranties of merchantability and fitness for a

    particular purpose. Ansoft shall not be liable for errors contained herein or forincidental or consequential damages in connection with the furnishing, perfor-

    mance, or use of this material.

    © 2003 Ansoft Corporation. All rights reserved.

    Ansoft Corporation

    Four Station SquareSuite 200

    Pittsburgh, PA 15219

    USA

    Phone: 412-261-3200

    Fax: 412-471-9427

    HFSS and Optimetrics are registered trademarks or trademarks of Ansoft Corpo-ration. Microsoft and Visual Basic are registered trademarks of Microsoft Corpo-

    ration in the United States and/or other countries. All other trademarks are theproperty of their respective owners.

    New editions of this manual will incorporate all material updated since the pre-

    vious edition. The manual printing date, which indicates the manual’s current

    edition, changes when a new edition is printed. Minor corrections and updates

    which are incorporated at reprint do not cause the date to change.Update packages may be issued between editions and contain additional and/or

    replacement pages to be merged into the manual by the user. Note that pages

    which are rearranged due to changes on a previous page are not considered to

    be revised.

    Edition Date Software

    Version1 June 2003 9.0

  • 8/19/2019 MacroHFSS

    3/254

    Introduction to Scripting in HFSS

     iii

    Getting Help

    Ansoft Technical Support

    To contact Ansoft technical support staff in your geographical area,please log on to the Ansoft corporate website, http://www.ansoft.com,

    click the Contact button, and then click Support. Your Ansoft sales engi-neer may also be contacted in order to obtain this information.

    E-mail can work well for technical support. All Ansoft software files are

    ASCII text and can be sent conveniently by e-mail. When reporting diffi-

    culties, it is extremely helpful to include very specific information about

    what steps were taken or what stages the simulation reached. Thisallows more rapid and effective debugging.

    Context Sensitive Help

    To access online help from the HFSS user interface, do one of the follow-

    ing:

    • To open a help topic about an HFSS menu command, press Shift+F1,

    and then click the command or toolbar icon.• To open a help topic about an HFSS dialog box, open the dialog box,

    and then press F1.

    http://www.ansoft.com/http://www.ansoft.com/

  • 8/19/2019 MacroHFSS

    4/254

    Introduction to Scripting in HFSS

     iv

  • 8/19/2019 MacroHFSS

    5/254

    Contents-1

    Table of Contents

    1. Introduction to VBScript

     ASampleHFSSScript............................ 1-2

    VBScriptVariables ............................... 1-4DeclaringVariables .............................. 1-4

     ArrayVariables .................................1-4

    VBScriptOperators .............................. 1-5

    OperatorPrecedence ............................ 1-5

     ArithmeticOperators............................. 1-5

    ComparisonOperators ........................... 1-6LogicalOperators ............................... 1-6

    ControllingProgramExecution..................... 1-7

    UsingIf...Then...Else ............................. 1-7

    UsingSelectCase ............................... 1-7

    UsingaFor...NextLoop...........................1-8

    ConvertingBetweenDataTypes.................... 1-9

    InteractingwithaScript........................... 1-9

    RecommendedVBScriptReferences................ 1-10

  • 8/19/2019 MacroHFSS

    6/254

    Introduction to Scripting in HFSS

    Contents-2

    2. HFSS and VBScript

    OverviewofHFSSScriptVariables.................. 2-2

    RecordingaScript ............................... 2-6StoppingScriptRecording ......................... 2-6

    RunningaScript................................. 2-6

    PausingandResumingaScript .................... 2-6

    StoppingaScript................................ 2-7

    ModifyingaScriptforEasierPlayback ............... 2-7

    HFSSScriptingConventions ....................... 2-7SyntaxConventions.............................. 2-7

    ScriptCommandConventions ..................... 2-8

    NamedArguments............................... 2-8

    SettingNumericalValues.........................2-10

    ExecutingaScriptfromWithinaScript ............... 2-11

    EditingProperties................................ 2-113. Desktop Object Script Commands

    CloseProject ................................... 3-2

    GetActiveProject................................ 3-2

    GetProjectList .................................. 3-2

    NewProject .................................... 3-2

    OpenMultipleProjects ............................ 3-3

    OpenProject................................... 3-3

    PauseScript ................................... 3-3

    Print.......................................... 3-4

    QuitApplication ................................. 3-4

    RestoreWindow ................................ 3-4

    RunProgram ................................... 3-5RunScript ..................................... 3-6

    SetActiveProject ................................ 3-6

    Sleep......................................... 3-7

  • 8/19/2019 MacroHFSS

    7/254

    Introduction to Scripting in HFSS

    Contents-3

    4. Project Object Script Commands

    Close......................................... 4-2

    CopyDesign ................................... 4-2CutDesign..................................... 4-2

    DeleteDesign.................................. 4-2

    GetActiveDesign................................ 4-3

    GetDesign..................................... 4-3

    GetName ..................................... 4-3

    GetPath....................................... 4-3GetTopDesignList............................... 4-4

    InsertDesign ................................... 4-4

    Paste......................................... 4-4

    Redo ......................................... 4-5

    Save......................................... 4-5

    SaveAs ....................................... 4-5SetActiveDesign ................................ 4-6

    SimulateAll.................................... 4-6

    Undo ......................................... 4-6

    5. Material Script Commands

     AddMaterial ................................... 5-2

    EditMaterial.................................... 5-3

    ExportMaterial ................................. 5-3

    RemoveMaterial ................................ 5-4

    6. Property Script Commands

    ChangeProperty ................................ 6-4

     AdditionalPropertyScriptingCommands ............. 6-9

    GetProperties .................................. 6-9

    GetPropertyValue............................... 6-9

    GetVariables................................... 6-9

    GetVariableValue ............................... 6-10

    SetPropertyValue ............................... 6-10

    SetVariableValue............................... 6-11

  • 8/19/2019 MacroHFSS

    8/254

    Introduction to Scripting in HFSS

    Contents-4

     AdditionalPropertyScriptingExample............... 6-12

    7. Dataset Script Commands

     AddDataset .................................... 7-2

    DeleteDataset.................................. 7-2

    EditDataset .................................... 7-3

    8. Design Object Script Commands

     AbortSolveAsynch .............................. 8-2

     ApplyMeshOps ................................. 8-2

    GetModule .................................... 8-2

    GetName ..................................... 8-3

    GetSolveAsynchStatus .......................... 8-3

    Redo ......................................... 8-3

    RenameDesignInstance.......................... 8-4

    SARSetup..................................... 8-4

    SetActiveEditor................................. 8-4

    SetSolutionType ................................ 8-5

    Solve......................................... 8-5

    SolveAsynch................................... 8-6

    Undo ......................................... 8-6

    9. Output Variable Script Commands AddOutputVariable .............................. 9-2

    DeleteOutputVariable............................ 9-2

    EditOutputVariable .............................. 9-3

    GetOutputVariableValue ......................... 9-3

    10. 3D Modeler Editor Script Commands

    DrawMenuCommands..........................10-3

    CreateBondwire............................... 10-3

    CreateBox.................................... 10-4

    CreateCircle.................................. 10-4

    CreateCone .................................. 10-5

    CreateCutplane ............................... 10-5

  • 8/19/2019 MacroHFSS

    9/254

    Introduction to Scripting in HFSS

    Contents-5

    CreateCylinder................................ 10-6

    CreateEllipse ................................. 10-6

    CreateHelix................................... 10-7

    CreatePoint................................... 10-8

    CreatePolyline ................................ 10-8

    CreateRectangle .............................. 10-9

    CreateRegularPolyhedron....................... 10-10

    CreateRegularPolygon.......................... 10-10

    CreateSphere ................................. 10-11

    CreateSpiral.................................. 10-12

    CreateTorus.................................. 10-12

    EditPolyline................................... 10-13

    SweepAlongPath.............................. 10-14

    SweepAlongVector............................. 10-14

    SweepAroundAxis ............................. 10-15

    EditMenuCommands...........................10-16

    Copy........................................ 10-16

    DuplicateAlongLine ............................ 10-16

    DuplicateAroundAxis ........................... 10-16

    DuplicateMirror ................................ 10-17

    Mirror ....................................... 10-17

    Move ........................................ 10-18

    OffsetFaces .................................. 10-18

    Paste........................................ 10-18

    Rotate ....................................... 10-19

    Scale........................................ 10-19

    3DModelerMenuCommands .................... 10-20

     AssignMaterial ................................ 10-20

    Connect ..................................... 10-20

    CoverLines................................... 10-20

    CoverSurfaces................................ 10-20

    CreateEntityList ............................... 10-21

    CreateFaceCS................................ 10-21

  • 8/19/2019 MacroHFSS

    10/254

    Introduction to Scripting in HFSS

    Contents-6

    CreateObjectFromFaces........................ 10-23

    CreateRelativeCS.............................. 10-24

    DeleteLastOperation ........................... 10-24

    DetachFaces ................................. 10-25

    EditEntityList.................................. 10-25

    EditFaceCS .................................. 10-26

    EditRelativeCS ................................ 10-26

    Export ....................................... 10-26

    GenerateHistory ............................... 10-27

    Import....................................... 10-27

    Intersect ..................................... 10-28

    MoveFaces ................................... 10-28

    Section...................................... 10-29

    SeparateBody................................. 10-29

    SetModelUnits ................................ 10-30

    SetWCS ..................................... 10-30

    Split......................................... 10-31

    Subtract ..................................... 10-31

    UncoverFaces ................................ 10-32

    Unite........................................ 10-33

    OtheroEditorCommands........................ 10-34

    Delete ....................................... 10-34

    GetFaceByPosition............................. 10-34

    PageSetup................................... 10-35

    RenamePart .................................. 10-35

    11. Reporter Editor Script Commands

    CreateReport ................................. 11-2

    RemoveReport ................................ 11-8

  • 8/19/2019 MacroHFSS

    11/254

    Introduction to Scripting in HFSS

    Contents-7

    12. Boundary and Excitation Module Script

    Commands

    GeneralCommandsRecognizedbytheBoundary/ExcitationsModule ....................................... 12-2

    ChangeImpedanceMult ......................... 12-2

    DeleteAllBoundaries............................ 12-2

    DeleteAllExcitations............................ 12-2

    DeleteBoundaries.............................. 12-3

    ReassignBoundary............................. 12-3RenameBoundary ............................. 12-3

    ReprioritizeBoundaries.......................... 12-4

    ScriptCommandsforCreatingandModifyingBoundaries12-5

     AssignCurent ................................. 12-5

     AssignFiniteCond .............................. 12-6

     AssignImpedance.............................. 12-7

     AssignIncidentWave............................ 12-7

     AssignLayeredImp............................. 12-8

     AssignLumpedPort ............................. 12-10

     AssignLumpedRLC ............................ 12-11

     AssignMagneticBias ............................ 12-12

     AssignMaster ................................. 12-13

     AssignPerfectE ................................ 12-13

     AssignPerfectH................................ 12-14

     AssignRadiation ............................... 12-14

     AssignSlave.................................. 12-14

     AssignSymmetry .............................. 12-15

     AssignVoltage................................. 12-16

     AssignWavePort ............................... 12-17

    EditCurrent................................... 12-21

    EditFiniteCond ................................ 12-21

    EditImpedance................................ 12-21

    EditIncidentWave .............................. 12-21

    EditLayeredImpedance ......................... 12-21

  • 8/19/2019 MacroHFSS

    12/254

  • 8/19/2019 MacroHFSS

    13/254

    Introduction to Scripting in HFSS

    Contents-9

    14. Analysis Module Script Commands

    DeleteDrivenSweep............................ 14-2

    DeleteSetups ................................. 14-2EditDrivenSweep.............................. 14-2

    EditSetup .................................... 14-3

    InsertDrivenSweep............................. 14-3

    InsertSetup ................................... 14-5

    RenameDrivenSweep .......................... 14-7

    RenameSetup................................. 14-8RevertAllToInitial .............................. 14-8

    RevertSetupToInitial............................ 14-8

    SolveSetup ................................... 14-8

    15. Optimetrics Module Script Commands

    GeneralCommandsRecognizedbytheOptimetrics

    Module ....................................... 15-5DeleteSetups ................................. 15-5

    RenameSetup................................. 15-5

    SolveSetup ................................... 15-5

    ParametricScriptCommands ..................... 15-6

    EditSetup .................................... 15-6

    InsertSetup ................................... 15-6OptimizationScriptCommands.................... 15-9

    EditSetup .................................... 15-9

    InsertSetup ................................... 15-9

    SensitivityScriptCommands ..................... 15-13

    EditSetup .................................... 15-13

    InsertSetup ................................... 15-13StatisticalScriptCommands ...................... 15-15

    EditSetup .................................... 15-15

    InsertSetup ................................... 15-15

  • 8/19/2019 MacroHFSS

    14/254

    Introduction to Scripting in HFSS

    Contents-10

    16. Solutions Module Script Commands

    DeleteImportData .............................. 16-2

    EditSources .................................. 16-2DeleteSolutionVariation......................... 16-4

    DeleteVariation................................ 16-5

    ExportForSpice................................ 16-6

    ExportForHSpice .............................. 16-7

    ExportNetworkData ............................ 16-9

    ExportNMFData............................... 16-10ImportSolution ................................ 16-11

    ImportTable .................................. 16-12

    17. Field Overlays Module Script Commands

    CreateFieldPlot................................ 17-2

    DeleteFieldPlot ................................ 17-6

    ModifyFieldPlot................................ 17-7

    RenameFieldPlot.............................. 17-8

    RenamePlotFolder ............................. 17-8

    SetFieldPlotSettings ............................ 17-9

    SetPlotFolderSettings .......................... 17-10

    18. Fields Calculator Script Commands

     AddNamedExpr ............................... 18-2

    CalcOp...................................... 18-2

    CalcStack.................................... 18-2

    ChangeGeomSettings .......................... 18-3

    ClcEval...................................... 18-3

    ClcMaterial................................... 18-3

    ClearAllNamedExpr............................ 18-4

    CopyNamedExprToStack........................ 18-4

    DeleteNamedExpr ............................. 18-4

    EnterComplex................................. 18-5

    EnterComplexVector ........................... 18-5

    EnterLine .................................... 18-6

  • 8/19/2019 MacroHFSS

    15/254

    Introduction to Scripting in HFSS

    Contents-11

    EnterPoint.................................... 18-6

    EnterQty..................................... 18-6

    EnterScalar ................................... 18-7

    EnterScalarFunc...............................18-7

    EnterSurf..................................... 18-7

    EnterVector................................... 18-8

    EnterVectorFunc............................... 18-8

    EnterVol ..................................... 18-9

    ExportOnGrid................................. 18-9

    ExportToFile .................................. 18-10

    WriteRegister ................................. 18-10

    19. Radiation Module Script Commands

    GeneralCommandsRecognizedbytheRadiationModule19-2

    DeleteFarFieldSetup ........................... 19-2

    DeleteNearFieldSetup.......................... 19-2RenameSetup................................. 19-3

    ScriptCommandsforCreatingandModifyingRadiation

    Setups....................................... 19-4

    EditFarFieldSphereSetup........................ 19-4

    EditNearFieldLineSetup ......................... 19-4

    EditNearFieldSphereSetup ...................... 19-5

    InsertFarFieldSphereSetup ...................... 19-6

    InsertNearFieldLineSetup ....................... 19-7

    InsertNearFieldSphereSetup ..................... 19-8

    ScriptCommandsforModifyingAntennaArraySetups . 19-9

    EditAntennaArraySetup......................... 19-9

    ScriptCommandsforExportingAntennaParametersandMax

    FieldParameters ............................... 19-13

    ExportRadiationParametersToFile................. 19-13

    20. Example Scripts

    VariableHelixScript............................. 20-2

    HFSSDataExportScript ......................... 20-6

  • 8/19/2019 MacroHFSS

    16/254

    Introduction to Scripting in HFSS

    Contents-12

  • 8/19/2019 MacroHFSS

    17/254

    Introduction to VBScript 1-1

    1 Introduction to VBScript

    HFSS uses the Microsoft® Visual Basic® Scripting Edition (VBScript) scripting

    language to record macros. VBScript is based on the Microsoft Visual Basic

    programming language.

    Using scripts is a fast, effective way to accomplish tasks you want to repeat.When you execute a script, the commands in the script are performed.

    You can write a script using any text editor or you can record a script from

    within the HFSS interface. After recording the script from within HFSS, you

    can then modify it if necessary using a text editor.

    Although HFSS records scripts in VBScript format, it can also execute scripts

    in JavaScriptTM format. If you are running a script from a command prompt,

    the script can be written in any language that provides the Microsoft COMmethods. The HFSS scripting documentation refers to VBScript format only.

    This chapter provides an overview of key VBScript components. For more

    details about VBScript, please see the Recommended VBScript References 

    section at the end of this chapter.

  • 8/19/2019 MacroHFSS

    18/254

    Introduction to Scripting in HFSS

    1-2 Introduction to VBScript

    A Sample HFSS Script

    Following is an example of an HFSS script. It includes comment lines, which are preceded by

    either an apostrophe ( ’  ) or the word REM, that offer explanations for each preceding line or

    lines. VBScript keywords appear in bold font.

    ’ ----------------------------------------------

    ’ Scr i pt Recor ded by Ansof t HFSS Versi on 9. 0 

    ’ 11: 03 AM May 30, 2003

    ’ ----------------------------------------------

    Dim   oDesi gn

    Dim   oEdi t or

    Dim   oModul e

    REM Dim  is used to declare variables. Dim  means dimension. In VBScript you can use Dim ,

    REM Public, or Private to declare variables. As VBScript has no built-in data types (like

    REM integer, string, etc.), all variables are treated as variants, which can store any type of 

    REM information. In this example, the three variables will be used as objects. When

    REM recording scripts in HFSS, variants that will be used as objects always begin with o.

    Set  oHf ssApp = Cr eat eObj ect ( "Ansof t Hf ss. Hf ssScr i pt I nt er f ace" )

    ’ You can use Set to assign an object reference to a variable. A copy of the object is not

    ’ created for that variable. Here Cr eat eObj ect  is a function that takes a string as input

    ’ and returns an object. The object is assigned to the variable oHf ssApp.

    Set  oDeskt op = oHf ssApp. Get AppDeskt op( )

    ’ Get AppDeskt op is a function of oHf ssApp. This function does not take an input and it

    ’ returns an object. The object is assigned to the variable oDeskt op.

    oDeskt op. NewProj ect

    ’ 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

    ’ NewPr oj ect  of the object oDeskt op is called. This Sub does not take an input.

    Set  oProj ect = oDeskt op. Get Act i veProj ect

    oPr oj ect . I nser t Desi gn "Hf ss" , "HFSSModel 1" , "Dr i venModal ", " "

  • 8/19/2019 MacroHFSS

    19/254

    Introduction to Scripting in HFSS

    Introduction to VBScript 1-3

    ’ 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 I nser t Desi gn of the object oPr oj ect .

    Set  oDesi gn = oPr oj ect . SetAct i veDesi gn("HFSSModel 1" )

    Set  oEdi t or = oDesi gn. Set Act i veEdi t or( "3D Model er " )

    oEdi t or . Cr eat eBox  Array( "NAME: BoxPar amet er s" , "XPosi t i on: =" , _ 

    "0mm", "YPosi t i on: =", "0mm", "ZPosi t i on: =", "0mm" , _ 

    "XSi ze: =", "1.6mm", "YSi ze: =", "1.2mm", "ZSi ze: =", _ 

    "0.8mm" ) ,  Array( "NAME: At t r i but es", "Name: =" , "Box1", "Fl ags: =", _  "", "Col or : =", "( 132 132 193) " , "Transpar ency: =" , _ 

    0.400000005960464, "Par t Coor di nat eSyst em: =" , _ 

    "Global" , "Mat er i al Name: =", "vacuum", "Sol veI nsi de: =", true)

    ’ oEdi t or . Cr eat eBox 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

    ’ 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( “Pl ease i ncl ude uni t s when cr eat i ng var i abl es ” & _

    ’ “t hat r equi r e di mensi ons. ”

    ’ Following is an example of improper use of the underscore character:

    ’ Msgbox( “Pl ease i ncl ude uni t s when cr eat i ng var i abl es _

    ’ t hat r equi r e di mensi ons. ”

    For additional HFSS script examples, see Chapter 20, Example Scripts.

  • 8/19/2019 MacroHFSS

    20/254

    Introduction to Scripting in HFSS

    1-4 Introduction to VBScript

    VBScript Variables

    A VBScript variable is a placeholder representing information that may change during the time

    your script is running. Use a variable name in a script to view or modify its value.

    Declaring Variables

    To declare variables explicitly in a script, use the Di m, Publ i c, or Pr i vat e statements. For

    example:

    Di m box_xsi ze

    After declaring a variable, you can assign information to it. For example:

    box_xsi ze = “3mm”

    Array Variables

    Create an array variable when you want to assign more than one related value to a single vari-

    able. An array variable contains a series of values. For example:

    Di m Pr i mi t i ves( 2)

    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

    elements of an array as follows:

    Pri mi t i ves( 0) = “Box1”

    Pr i mi t i ves( 1) = “Cone1”Pr i mi t i ves( 2) = “Cyl i nder 1”

    Similarly, the data can be retrieved from any element using an index into a particular array ele-

    ment. For example:

    one_pr i m = Pr i mi t i ves( 1)

    You can also use the Array function to assign an array of elements to a variable. For example:

    Di m Pr i mi t i ves

    Pri mi t i ves = Ar r ay ( “Box1”, “cone1”, “Cyl i nder 1”)

    Note When using the Array function, do not use parentheses on the variable when it is

    declared. For example, use Di m myar r ay, not Di m myar r ay( ) .

  • 8/19/2019 MacroHFSS

    21/254

    Introduction to Scripting in HFSS

    Introduction to VBScript 1-5

    VBScript Operators

    VBScript provides operators, which are grouped into these categories: arithmetic operators,

    comparison operators, and logical operators.

    Please see the online VBScript User’s Guide for more details.

    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 paren-theses, however, standard operator precedence is maintained.

    When expressions contain operators from more than one category, arithmetic operators are

    evaluated first, comparison operators are evaluated next, and logical operators are evaulated

    last. Comparison operators all have equal precedence, that is, they are evaluated in the left-to-

    right order in which they appear. Arithmetic and logical operators are evaluated in the following

    order of precedence.

    Arithmetic Operators

    Following is a list of VBScript’s arithmetic operators.

    Symbol Description

    ^ Exponentiation

    - Unary negation

    * Multiplication

    / Division

    \ Integer division

    Mod Modulus arithmetic

    + Addition

    - Subtraction& String concatenation

  • 8/19/2019 MacroHFSS

    22/254

    Introduction to Scripting in HFSS

    1-6 Introduction to VBScript

    Comparison Operators

    Following is a list of VBScript’s comparison operators.

    Logical Operators

    Following is a list of VBScript’s logical operators:

    Symbol Description= Equality

    Inequality

    < Less than

    > Greater than

    = Greater than or equal to

    I s Object equivalence

    Symbol DescriptionNot Logical negation

    And Logical conjunction

    Or Logical disjunction

    Xor Logical exclusion

    Eqv Logical equivalence

    I mp Logical implication

  • 8/19/2019 MacroHFSS

    23/254

    Introduction to Scripting in HFSS

    Introduction to VBScript 1-7

    Controlling Program Execution

    You can use conditional statements to control the flow of a script. There are two types of condi-

    tional statements in VBScript:

    • I f . . . Then. . . El se

    • Sel ect Case

    Using If...Then...Else

    Following is an example that demonstrates the I f . . . Then. . . El se conditional statement:

    I f obj = "Box1" Then

    El seI f obj = "Cyl i nder 1" Then

    El se

    End I f

    Using Select Case

    Following is an example that demonstrates the Sel ect Case conditional statement:

    Sel ect Case pr i mi t i ve_name

    Case "Box1"

    Case "Cyl i nder1"

    Case El se

    End Sel ect

  • 8/19/2019 MacroHFSS

    24/254

    Introduction to Scripting in HFSS

    1-8 Introduction to VBScript

    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 demon-

    strates the For . . . Next  loop:

    For var i abl e = st ar t To end

    Next

    You can exit early from a For . . . Next l oop with the Exi t For  statement.

  • 8/19/2019 MacroHFSS

    25/254

    Introduction to Scripting in HFSS

    Introduction to VBScript 1-9

    Converting Between Data Types

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

    Interacting with a ScriptVBScript provides two functions that enable you to interact with a script while it is running:

    the I nputBox function and the MsgBox function.

    The I nput Box function displays a dialog box with an input field. The value that is typed into

    the input field is returned. For example:

    Di m user s_st r i ng

    user s_st r i ng = I nput Box ( “t ext pr ompt ”, “t i t l e of t he pop- up di al og _ 

    box”, “def aul t t ext f or t he i nput box”)

    The last two arguments to the function are optional.

    The MsgBox function shows a message and returns a number based on the button the user

    presses. For example:

    MsgBox ( “message t ext ”)

    CStr Syntax: CSt r ( var i abl ename).Converts var i abl ename to a string. For example, it can be used to

    convert the number 2.5 to the string “2. 5”.

    CBool Syntax: CBool (var i abl ename).

    Converts var i abl ename to a boolean. If var i abl ename is 0 or “0”,

    CBool  returns Fal se. Otherwise it returns True.

    CDbl Syntax:  CDbl (var i abl ename).

    Converts var i abl ename to a double precision number. For example,

    it can be used to convert the string “2. 5” to the number 2.5.

    CInt Syntax: CI nt (var i abl ename).

    Converts var i abl ename to an integer.

    I d i S i i i HFSS

  • 8/19/2019 MacroHFSS

    26/254

    Introduction to Scripting in HFSS

    1-10 Introduction to VBScript

    Recommended VBScript References

    Microsoft Corporation. VBScript User’s Guide.

    Available http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/

    vbstutor.asp.

    Childs, M., Lomax, P., and Petrusha, R. VBScript in a Nutshell: A Desktop Quick Reference.

    May 2002. O’Reilly & Associates. ISBN: 1-56592-720-6.

  • 8/19/2019 MacroHFSS

    27/254

    HFSS and VBScript 2-1

    2 HFSS and VBScript

    This chapter provides an overview of HFSS scripting using VBScript. Informa-

    tion is included on the following topics:

      HFSS script variables.

      Recording, running, pausing, resuming, and stopping a script.

      Modifying a script for easier playback.

      HFSS scripting conventions, including script command syntax used in this

    guide, named arguments, and setting numerical values.

      Executing a script from within a script.

      Modifying properties.

    Introduction to Scripting in HFSS

  • 8/19/2019 MacroHFSS

    28/254

    Introduction to Scripting in HFSS

    2-2 HFSS and VBScript

    Overview of HFSS Script Variables

    When you record an HFSS script, the beginning of the script looks like the following:

    Di m oHf ssApp

    Di m oDeskt op

    Di m oPr oj ect

    Di m oDesi gn

    Di m oEdi t or

    Di m oModul e

    Set oHf ssApp = Cr eat eObj ect ( “Ansof t Hf ss. Hf ssScr i pt I nt er f ace”)

    Set oDeskt op = oHf ssApp. Get AppDeskt op( )

    Set oPr oj ect = oDeskt op. Set Act i veProj ect ( “Proj ect 1”)

    Set oDesi gn = oPr oj ect . SetAct i veDesi gn(“HFSSModel 1”)

    Set oEdi t or = oDesi gn. Set Act i veEdi t or( “3D Model er ”)

    Set oModul e = oDesi gn. Get Modul e( “Boundar ySet up”)

    The lines above define the variables used by HFSS in the script and assign values to the vari-

    ables. The variables are used in the following hierarchy:

    Class hierarchy of variables.

    Introduction to Scripting in HFSS

  • 8/19/2019 MacroHFSS

    29/254

    Introduction to Scripting in HFSS

    HFSS and VBScript 2-3

    oHfssApp

    The oHf ssApp object provides a handle for VBScript to access the Ansof t Hf ss product.

    One example of accessing this object is:

    Set oHf ssApp = Cr eat eObj ect ( “Ansof t Hf ss. Hf ssScr i pt I nt er f ace”)

    oDesktop

    The oDeskt op object is used to perform desktop-level operations, including project manage-

    ment.

    One example of accessing this object is:

    Set oDeskt op = oHf ssApp. Get AppDeskt op( )

    See Chapter 3, Desktop Object Script Commands, for details about script commands recognized

    by the oDeskt op object.

    oProject

    The oPr oj ect  object corresponds to one project open in the product. It is used to manipulate

    the project and its data. Its data includes variables, material definitions and one or more

    designs. One example of accessing this object is:

    Set oPr oj ect = oDeskt op. Get Act i veProj ect ( )

    See the following chapters for details about the script commands recognized by the oPr oj ect  

    object:

    Chapter 4, Project Object Script Commands• Chapter 5, Material Script Commands

    • Chapter 6, Property Script Commands

    • Chapter 7, Dataset Script Commands

    oDesign

    The oDesi gn 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 oDesi gn = oPr oj ect . GetAct i veDesi gn( )

    Introduction to Scripting in HFSS

  • 8/19/2019 MacroHFSS

    30/254

    p g

    2-4 HFSS and VBScript

    See the following chapters for details about the script commands recognized by the oDesi gn 

    object:

    • Chapter 8, Design Object Script Commands

    • Chapter 9, Output Variable Script Commands

    • Chapter 11, Reporter Editor Script Commands

    oEditor

    The oEdi t or  object corresponds to an editor, such as the 3D Modeler. This object is used to add

    and modify data in the editor.

    One example of accessing this object is:Set oEdi t or = oDesi gn. Set Act i veEdi t or( “3D Model er ”)

    The Ansof t Hf ss product scripting supports the following editors:

    See Chapter 10, 3D Modeler Editor Script Commands, for details about the script commands rec-

    ognized by the oEdi t or  object and Chapter 11, Reporter Editor Script Commands for details

    about Reporter editor commands.

    oModuleThe oModul e 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 oModul e = oDesi gn. Get Modul e( “Boundar ySet up”)

    Editor Name in Script

    3D Modeler Editor “3D Model er ”

    Reporter Editor There is no Reporter editor object in the script. Instead,Reporter editor commands are executed by the HFSS

    design object oDesi gn.

    Introduction to Scripting in HFSS

  • 8/19/2019 MacroHFSS

    31/254

    HFSS and VBScript 2-5

    The Ansof t Hf ss product scripting supports the following modules:

    Module Name in Script Chapter

    Boundary/Excitations Module

    Corresponds to the Boundaries and

    Excitations branches in the

    project tree.

    “Boundar ySet up” Chapter 12, Boundary and

    Excitation Module Script

    Commands

    Mesh Operations Module

    Corresponds to the MeshOperations branch in the project

    tree.

    “MeshSetup” Chapter 13, Mesh Operations

    Module Script Commands

    Analysis Module

    Corresponds to the Analysis branch

    in the project tree.

    “Anal ysi sSet up” Chapter 14, Analysis Module

    Script Commands

    Optimetrics Module

    Corresponds to the Optimetrics 

    branch in the project tree.

    “Opt i met r i cs” Chapter 15, Optimetrics Script

    Commands

    Solutions Module

    Corresponds to the operations in

    the Solution Data dialog box,

    which is accessed by clicking

    HFSS>Results>

    Solution Data.

    “Sol ut i ons” Chapter 16, Solutions Module

    Script Commands

    Field Overlays Module

    Corresponds to the Field Overlays 

    branch in the project tree.

    “Fi el dsRepor t er ” Chapter 17, Field Overlays

    Module Script Commands

    Radiation Module

    Corresponds to the Radiation 

    branch in the project tree.

    “RadFi el d” Chapter 18, Radiation Module

    Script Commands

    Introduction to Scripting in HFSS

  • 8/19/2019 MacroHFSS

    32/254

    2-6 HFSS and VBScript

    Recording a Script

    Once you start to record a script, your subsequent actions are added to the script. Each inter-

    face command has one or more associated script commands that are recorded to the script. The

    script is recorded to a text file in .vbs (VBScript) file format.

    1 On the Tools menu, click Record Script.

    The Save As dialog box appears.

    2 Use the file browser to locate the folder in which you want to save the script, such as

    C:\Ansoft\HFSS9\Scripts, and then double-click the folder’s name.

    3 Type the name of the script in the File name text box, and then click Save.

    The script is saved in the folder you selected by the file name filename.vbs.

    4 Perform the steps that you want to record.

    5 When you have finished recording the script, click Stop Script Recording on the Tools menu.

    Stopping Script Recording

    • On the Tools menu, click Stop Script Recording.

    HFSS stops recording to the script.

    Running a Script

    1 On the Tools menu, click Run Script.

    The Open dialog box appears.

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

    the folder’s name.

    3 Type the name of the script in the File name text box, or click its name, and then click

    Open.

    HFSS executes the script.

    Pausing and Resuming a Script

    To pause a script during its execution:

    • On the Tools menu, click Pause Script.

    To resume a script after pausing it:

    • On the Tools menu, click Resume Script.

    Introduction to Scripting in HFSS

  • 8/19/2019 MacroHFSS

    33/254

    HFSS and VBScript 2-7

    Stopping a Script

    • On the Tools menu, click Stop Script.

    HFSS stops executing the script that has been paused.

    Modifying a Script for Easier Playback

    In the sample script on page 2-2, note that the oPr oj ect  variable is set to “Pr oj ect 1”. That

    means that the script must be played back within Project1 to operate correctly. Alternatively,

    oPr oj ect  could be set to the active project without specifying a project name.

    For example:

    Set oPr oj ect = oDeskt op. Get Act i veProj ect ( )

    Using the line above, the script can be played back in any project.

    HFSS Scripting Conventions

    Syntax Conventions

    The following data types will be used throughout this scripting guide:

    A quoted string.

    A boolean value. Should be set to either t rue or f al se (no quotes).

    Example: “Sol veI nsi de: =”, t r ue

    A double precision value.

    Example: 1. 2

    An integer. Example: 1

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

    valid HFSS expression.

    Examples:

    - “XSi ze: =”, 1- “XSi ze: =”, “3mm”

    - “XSi ze: =”, VBScr i pt _Var

    - “XSi ze: =”, “Hf ss_Var + 10mm”

    Introduction to Scripting in HFSS

  • 8/19/2019 MacroHFSS

    34/254

    2-8 HFSS and VBScript

    Script Command Conventions

    The majority of this guide lists individual script commands. The following conventions are used

    to describe them:

    Script Command Name

    Use: Describes the function of the script command.

    Command: Lists the interface command that corresponds to the script command. Menu commands are separated by carats. For example,

    HFSS>Excitations>Assign>Wave Port.

    Syntax: Demonst r at es t he cor r ect synt ax f or t he command. Caratbr acket s < > encl ose i nf ormat i on or argument s t hat you

    must ent er .Return Value: Describes the return value, if any.

    Parameters: Descr i bes t he ar gument s or i nf or mat i on i n the synt axdescr i pt i on, i f an expl anat i on i s needed.

    Example: Provi des a worki ng exampl e of t he scr i pt command, i fneeded.

    Named Arguments

    Many HFSS script commands use named arguments. The names can appear in three ways:

    1. Named data, name precedes data.

    For example: . . . , "Sol veI ns i de: =", t r ue, . . .

    2. Named Array, name precedes array.

    For example: . . . , "At t r i but es: =" , Ar ray( . . . ) , . . .

    3. Named Array, name inside array.

    For example: . . . , Ar r ay( "NAME: At t r i butes" , . . . ) , . . .

    In the first and second examples, the name is formatted as “: =”. This signals HFSS that

    this is a name for the next argument in the script command. In the third example, the name is

    formatted as “NAME: ” and is the first element of the Array.

    The names are used both to identify what the data means to you and to inform HFSS which data

    is being given. The names must be included or the script will not play back correctly. However, if

    you are writing a script, you do not need to pass in every piece of data that the command can

    Introduction to Scripting in HFSS

  • 8/19/2019 MacroHFSS

    35/254

    HFSS and VBScript 2-9

    take. For example, if you are modifying a boundary, the script will be recorded to include every

    piece of data needed for the boundary, whether or not it was modified. If you are writing a

    script by hand, you can just add the data that changed and omit anything that you do not want

    to change. HFSS will use the names to determine which data you provided.

    For example, when editing an impedance boundary, HFSS records the ‘edit impedance boundary’

    command as follows:

    oModul e. Edi t I mpedance " I mped1" , Ar r ay( "NAME: I mped1", _ 

    "Resi st ance: =" , "100" , "React ance: =" , "50" , _ 

    " I nf Gr oundPl ane: =" , f al se)

    If you only want to change the resistance, then you can leave out the other data arguments

    when you are manually writing a script:

    oModul e. Edi t I mpedance " I mped1" , Ar r ay( "NAME: I mped1", _ 

    "Resi st ance: =" , "100")

    Introduction to Scripting in HFSS

  • 8/19/2019 MacroHFSS

    36/254

    2-10 HFSS and VBScript

    Setting Numerical Values

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

    • Pass in the number directly. For example:

    oModul e. Edi t Vol t age "Vol t age1" , Ar r ay( "NAME: Vol t age1" , _ 

    "Vol t age: =", 3. 5)

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

    oModul e. Edi t Vol t age "Vol t age1" , Ar r ay( "NAME: Vol t age1" , _ 

    "Vol t age: =", "3. 5V" )

    • Pass in an HFSS defined variable name. For example:

    oModul e. Edi t Vol t age "Vol t age1" , Ar r ay( "NAME: Vol t age1" , _ 

    "Vol t age: =", "$var 1" )

    •Pass in a VBScript variable. For example:vb_var = "3. 5V"

    oModul e. Edi t Vol t age "Vol t age1" , Ar r ay( "NAME: Vol t age1" , _ 

      "Vol t age: =" , vb_var )

    Introduction to Scripting in HFSS

  • 8/19/2019 MacroHFSS

    37/254

    HFSS and VBScript 2-11

    Executing a Script from Within a Script

    HFSS provides a script command that enables you to launch another script from within the script

    that is being executed:

    oDeskt op. RunScr i pt

    If the full path to the script is not specified, HFSS searches for the specified script in the follow-

    ing locations, in this order:

    • Personal library directory.

    This is the PersonalLib subdirectory in the project directory. The project directory can be

    specified in the General Options dialog box (click Tools>Options>General Options to open

    this dialog box) under the Project Options tab.

    • User library directory.

    This is the userlib subdirectory in the library directory. The library directory can be specified

    in the General Options dialog box (click Tools>Options>General Options to open this dialog

    box) under the Project Options tab.

    • System library directory.

    This is the syslib subdirectory in the library directory. The library directory can be specified

    in the General Options dialog box (click Tools>Options>General Options to open this dialog

    box) under the Project Options tab.

    • HFSS installation directory.

    Editing Properties

    Any data that is shown in the dockable Properties dialog box or in the modal Properties pop-up

    window is called a property. For example, project and local variables are properties. The XSize 

    of a box in the Geometry editor is also a property. See Chapter 6, Property Script Commands, 

    for an explanation of how to manipulate properties in a script.

    Introduction to Scripting in HFSS

  • 8/19/2019 MacroHFSS

    38/254

    2-12 HFSS and VBScript

  • 8/19/2019 MacroHFSS

    39/254

    Desktop Object Script Commands 3-1

    3 Desktop Object ScriptCommands

    Desktop commands should be executed by the oDeskt op object.

    Set oDeskt op =

    Cr eat eObj ect ( "Ansof t Hf ss. Hf ssScri pt I nt er f ace")

    oDeskt op. CommandName

    Introduction to Scripting in HFSS

    CloseProject

  • 8/19/2019 MacroHFSS

    40/254

    3-2 Desktop Object Script Commands

    CloseProject

    Use: Closes a specified project. Changes to the project will not be saved. Save

    the project using the Project command Save or SaveAs  before closing tosave changes.

    Command:   File>Close

    Syntax: Cl oseProj ect

    Return Value: None

    Parameters:

    Type:

    Example: oDeskt op. Cl osePr oj ect “Pr oj ect 1”

    GetActiveProject

    Use: Returns the project that is active in the desktop.

    Command: None

    Syntax: Get Act i vePr oj ect

    Return Value: The project that is active in the desktop.

    Parameters: None

    Example: Set oPr oj ect = oDeskt op. Get Act i veProj ect ( )

    GetProjectList

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

    Command: None 

    Syntax: Get Pr oj ect Li st

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

    Parameters: None

    Example: l i st _of _pr oj ect s = oDeskt op. Get Pr oj ect Li st ( )

    NewProject

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

    Command:   File>NewSyntax: NewPr oj ect

    Return Value: The project that is added.

    Parameters: None

    Example: Set oPr oj ect = oDeskt op. NewProj ect

    Introduction to Scripting in HFSS

    OpenMultipleProjects

  • 8/19/2019 MacroHFSS

    41/254

    Desktop Object Script Commands 3-3

    OpenMultipleProjects

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

    Command:   File>Multiple Open

    Syntax: OpenMul t i pl eProj ect s Return Value: None

    Parameters:  

    Type:

    Type:

    Example: oDeskt op. OpenMul t i pl ePr oj ect s "D: / Pr oj ect s", "*. hf ss"

    OpenProject

    Use: Opens a specified project.

    Command:   File>Open

    Syntax: OpenProj ect

    Return Value: The opened project.Parameters: :  Full path of the project to open.

    Type:

    Example: oDesktop. OpenPr oj ect “D: / Pr oj ect s/ Pr oj ect 1. hf ss”

    PauseScript

    Use: Pauses the script’s execution and displays a message in a pop-up dialog box

    to the user. The script execution will not resume until the user clicks

    Tools>Resume Script.

    Command:   Tools>Pause Script

    Syntax: PauseScr i pt

    Return Value: None

    Parameters:  

    Type:

    Example: oDeskt op. PauseScr i pt "Text t o di spl ay i n pop- up di al ogbox"

    Introduction to Scripting in HFSS

    Print

  • 8/19/2019 MacroHFSS

    42/254

    3-4 Desktop Object Script Commands

    Print

    Use: Prints the contents of the active view window.

    Command:   File>Print

    Syntax: Pr i ntReturn Value: None

    Parameters: None

    Example: oDeskt op. Pr i nt

    QuitApplication

    Use: Exits the desktop.

    Command:   File>Exit

    Syntax: Qui t Appl i cat i on

    Return Value: None

    Parameters: None

    Example: oDesktop. Qui t Appl i cat i on

    RestoreWindowUse: Restores a minimized HFSS window.

    Command: None

    Syntax: Rest oreWi ndow

    Return Value: None

    Parameters: None

    Example: oDeskt op. Rest oreWi ndow

    Introduction to Scripting in HFSS

    RunProgram

  • 8/19/2019 MacroHFSS

    43/254

    Desktop Object Script Commands 3-5

    g

    Use: Runs an external program.

    Command: None

    Syntax: RunProgram , , , Return Value: None

    Parameters:  

    Type:

    Name of the program to run.

    Type:

    Location of the program. Pass in an empty string to use the system path.

    Type:

    Working directory in which program will start.

    Type: Array of strings

    Arguments to pass to the program. If no arguments, pass in None.

    Example: oDeskt op. RunProgr am"wi nword. exe", _ 

    "C: \ Pr ogr am Fi l es\ Mi cr osof t Of f i ce\ Of f i ce10", _ 

    " " , None

  • 8/19/2019 MacroHFSS

    44/254

    Introduction to Scripting in HFSS

    Sleep

  • 8/19/2019 MacroHFSS

    45/254

    Desktop Object Script Commands 3-7

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

    60,000 milliseconds (1 minute).

    Command: noneSyntax: Sl eep

    Return Value: None

    Parameters:  

    Type:

    Example: oDeskt op. Sl eep 1000

  • 8/19/2019 MacroHFSS

    46/254

    4

  • 8/19/2019 MacroHFSS

    47/254

    Project Object Script Commands 4-1

    4 Project Object ScriptCommands

    Project commands should be executed by the oPr oj ect  object. One exam-

    ple of accessing this object is:

    Set oPr oj ect = oDeskt op. Get Act i veProj ect ( )

    Introduction to Scripting in HFSS

    Close

    Use: Closes the active project Unsaved changes will be lost

  • 8/19/2019 MacroHFSS

    48/254

    4-2 Project Object Script Commands

    Use: Closes the active project. Unsaved changes will be lost.

    Command: None

    Syntax: Cl oseReturn Value: None

    Parameters: None

    Example: oPr oj ect. Cl ose

    CopyDesign

    Use: Copies a design.

    Command:   Edit>Copy

    Syntax: CopyDesi gn

    Return Value: None

    Example: oPr oj ect . CopyDesi gn “HFSSModel 1”

    CutDesign

    Use: Cuts a design from the active project. The design is stored in memory andcan be pasted in any HFSS project.

    Command:   Edit>Cut

    Syntax: Cut Desi gn

    Return Value: None

    Example: oPr oj ect . CutDesi gn “HFSSModel 1”

    DeleteDesign

    Use: Deletes a specified design in the project.

    Command:   Edit>Delete

    Syntax: Del et eDesi gn

    Return Value: None

    Example: oPr oj ect . Del eteDesi gn “Hf ssModel 2”

    Introduction to Scripting in HFSS

    GetActiveDesign

    Use: Returns the design in the active project

  • 8/19/2019 MacroHFSS

    49/254

    Project Object Script Commands 4-3

    Use: Returns the design in the active project.

    Command: None

    Syntax: Get Act i veDesi gnReturn Value: The active design.

    Parameters: None

    Example: Set oDesi gn = oPr oj ect . GetAct i veDesi gn ( )

    GetDesign

    Use: Returns the specified design.

    Command: None

    Syntax: Get Desi gn

    Return Value: The specified design.

    Parameters:

    Type:

    Name of the design to return.

    Example: Set oDesi gn = oPr oj ect . GetDesi gn ( “Hf ssModel 1”)

    GetName

    Use: Returns the project name.

    Command: None

    Syntax: Get Name

    Return Value: The active project’s name.

    Parameters: None

    Example: name = oProj ect . Get Name ( )

    GetPath

    Use: Returns the location of the project on disk.

    Command: None

    Syntax: GetPat hReturn Value: The path to the project, which does not include the project name.

    Parameters: None

    Example: pat h = oProj ect . Get Pat h ( )

    Introduction to Scripting in HFSS

    GetTopDesignList

    Use: Returns a list of the names of the top-level designs

  • 8/19/2019 MacroHFSS

    50/254

    4-4 Project Object Script Commands

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

    Command: None

    Syntax: GetTopDesi gnLi stReturn Value: An array of strings that are the names of the top-level designs.

    Parameters: None

    Example: name_l i st = oPr oj ect . Get TopDesi gnLi st ( )

    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: I nser t Desi gn “HFSS”, , , “”

    Return Value: None

    Parameters:

    Type:

    Name of the new design.

    Type:

    Solution type of the new design. Can be “Dr i venModal ”,

    “Dr i venTer mi nal ”, or “Ei genmode”.

    Example: oPr oj ect. I nser t Desi gn "Hf ss", "Hf ssModel 3", _ 

    "Dr i venModal " , " "

    Paste

    Use: Pastes a design in the active project.

    Command:   Edit>Paste

    Syntax: Past e

    Return Value: NoneParameters: None

    Example: oPr oj ect. Past e

    Introduction to Scripting in HFSS

    Redo

    Use: Reapplies the last project-level command.

  • 8/19/2019 MacroHFSS

    51/254

    Project Object Script Commands 4-5

    Use: Reapplies the last project level command.

    Command:   Edit>Redo

    Syntax: RedoReturn Value: None

    Parameters: None

    Example: oPr oj ect . Redo

    Save

    Use: Saves the active project.

    Command:   File>Save

    Syntax: Save

    Return Value: None

    Parameters: None

    Example: oPr oj ect . Save

    SaveAsUse: Saves the project under a new name.

    Command:   File>Save As

    Syntax: SaveAs

    Return Value: None

    Parameters:  

    Type:

    New name for the file.

    Type:

    Set to t rue if an existing project by that name should be overwritten.

    Example: oPr oj ect. SaveAs “D: / pr oj ects/ pr oj ect1. hf ss”, t r ue

    Introduction to Scripting in HFSS

    SetActiveDesign

    Use: Sets a new design to be the active design.

  • 8/19/2019 MacroHFSS

    52/254

    4-6 Project Object Script Commands

    g g

    Command: None

    Syntax: SetAct i veDesi gn Return Value: The named design becomes active.

    Parameters:

    Type:

    Name of the design to set as the active design.

    Example: Set oDesi gn = oPr oj ect . SetAct i veDesi gn ( “Hf ssModel 2”)

    SimulateAll

    Use: Runs the Si mul at eAl l  project-level script command from the script,which will simulate all HFSS solution setups and Optimetrics setups for all

    design instances in the project.

    Command: None

    Syntax: None

    Return Value: Si mul at eAl l  script command.

    Parameters: None

    Example: oPr oj ect. Si mul at eAl l

    Undo

    Use: Cancels the last project level command.

    Command:   Edit>Undo

    Syntax: UndoReturn Value: None

    Parameters: None

    Example: oPr oj ect . Undo

    5 Material Script Commands

  • 8/19/2019 MacroHFSS

    53/254

    Material Script Commands 5-1

    5 Material Script Commands

    Material commands should be executed by the oPr oj ect  object. Material

    commands apply to all products.

    Set oPr oj ect = oDeskt op. Set Act i vePr oj ect ( "Pr oj ect 1")

    oPr oj ect . CommandName

    Introduction to Scripting in HFSS

    AddMaterial

    Use: Adds a local material.

  • 8/19/2019 MacroHFSS

    54/254

    5-2 Material Script Commands

    Command: Add Material command in the material editor.

    Syntax: AddMat er i al Ar r ay(“NAME: ”,, , . . . )

    Return Value: None

    Parameters: ( si mpl e mater i al )

    “: =”,

    ( ani sot r opi c mat er i al )

    Ar r ay( "NAME: ”,

    “pr oper t y_t ype: =”, “Ani soPr oper t y”,

    "uni t : =", ",

    “component1: =", ,

    "component2: =", ,

    "component 3: =", ) )

    Type:

    Should be one of the following: “per mi t t i vi t y”,

    “per meabi l i t y”, “conduct i vi t y”

    “di el ectr i c_l oss_tangent ”,

    “magnet i c_l oss_t angent “, “sat ur at i on_mag“,

    “l ande_g_f act or “, “del t a_H“

    pr oper t y_t ype

    Type:

    Should be “Ani soPr oper t y”.

    uni t

    Type:

    Possible values:

    del t a_H: “Oe”  

    sat ur at i on_mag: “Gauss”, “uGauss”, ”Tesl a”, “uTesl a”

    other properties: “” (empty string)

  • 8/19/2019 MacroHFSS

    55/254

    Introduction to Scripting in HFSS

    RemoveMaterial

    Use: Removes a material from a library.

  • 8/19/2019 MacroHFSS

    56/254

    5-4 Material Script Commands

    Command:   Remove Material(s) command in the material editor.

    Syntax: RemoveMat er i al , ,  ,

    Return Value: None

    Parameters:

    Type:

    Name of the material to be removed.

    Type:

    If true, HFSS assumes the material is a project material. In this case,

    the last two parameters will be ignored.

    Type:

    The name of the user or personal library where the material resides.

    Type:

    Should be “UserLi b” or “Per sonal Li b”.

    Example: oPr oj ect . RemoveMat er i al "Mat er i al 1" , f al se, "mo0907" ,

    "User Li b"Example: oPr oj ect . RemoveMat er i al "Mat er i al 1", t r ue, "Local " ,

    "Pr oj ect"

    6 Property Script Commands

  • 8/19/2019 MacroHFSS

    57/254

    Property Script Commands 6-1

    6 Property Script Commands

    Property commands should be executed by the oPr oj ect  object.

    Set oPr oj ect = oDeskt op. Set Act i vePr oj ect ( "Pr oj ect 1")

    oPr oj ect . CommandName

    Conventions Used in this Chapter

    • Property

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

    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.

    Corresponds to one tab in the Property dialog box – the tab under whichproperties are being edited.

    Name of a single property .

     and  Names

    Project

    Project Variables:

    “Pr oj ect Var i abl es”

    Introduction to Scripting in HFSS

    “Pr oj ect Var i abl eTab”

  • 8/19/2019 MacroHFSS

    58/254

    6-2 Property Script Commands

    Pr oj ect Var i abl eTab

    Ansof t Hf ss  Design

    Local Variables:

    “Local Var i abl es”

    “Local Var i abl eTab”

    Ansof t Hf ss  Modules

    Format is: : , where  is the

    boundary name, solution setup name, etc., depending on which module

    is being edited.Example:  for the boundary “PerfE1” is

    “BoundarySetup: Per f E1”

    Boundary module: “Hf ssTab”

    Mesh Operations module: “MeshSetupTab”

    Analysis module: “Hf ssTab”

    Optimetrics module: “Opt i met r i csTab”

    Solutions module: Does not support properties.

    Field Overlays module: “Fi el dsPost ProcessorTab”

    Radiation module: “RadFi el dSet upTab”

    Ansof t Hf ss  3D Model Editor

    Object in the module:

    Name of the object. For example: “Box1”.

    Introduction to Scripting in HFSS

    “Geomet r y3DAt t r i buteTab”

    Operation on an object:

  • 8/19/2019 MacroHFSS

    59/254

    Property Script Commands 6-3

    Operation on an object:

    Format is : :

    Concatenation of object name, operation name, and the index of the

    operation.

    For example: "Box2: Cr eat eBox: 2" refers to the second

    “Cr eat eBox” command in Box2’s history.

    “Geomet r y3DCmdTab”

  • 8/19/2019 MacroHFSS

    60/254

    Introduction to Scripting in HFSS

    “Pr opType: =”, ,

    “NewName: =”, ,

    “Descr i pt i on: =”, ,

  • 8/19/2019 MacroHFSS

    61/254

    Property Script Commands 6-5

    p g

    “NewRowPosi t i on: =”, ,“ReadOnl y: =”, ,

    “Hi dden: =”, ,

    )

    Type: string

    Identifies the type of property when a new property is added. In HFSS,only separator properties and variable properties can be added.

    "Separator Prop"

    “Var i abl ePr op"

    “Text Prop”

    "NumberPr op"

    "Val ueProp"

    “CheckboxPr op"

    “MenuProp”

    “Poi nt Prop"

    “VPoi nt Prop"

    "V3DPoi nt Prop"

    "But t onProp"

    NewName

    Specify the new name of a property if the property’s name is being

    edited. In HFSS, the name can only be changed for separators and vari-

    ables.

    Descri pt i on

    Specify a description of the property. In HFSS, the description can onlybe changed for separators and variables.

    NewRowPosi t i on

    Used to reorder rows in the Property dialog box. In HFSS, this onlyapplies to the Project>Project Variables panel and the Hfss>Design 

    Introduction to Scripting in HFSS

    Properties panel. Specify the new zero-based row index of the variableor separator.

  • 8/19/2019 MacroHFSS

    62/254

    6-6 Property Script Commands

    ReadOnl y

    Used to mark a property as “read only” so it can not be modified. In

    HFSS, this flag can only be set for variables and separators.

    Hi dden

    Used to hide a property so it can not be viewed outside of the Property dialog box. In HFSS, this flag can only be set for variables and separa-

    tors.

    SeparatorProp:  no arguments

     Text Pr op: “Val ue: =”,

    Number Pr op: “Val ue: =”,

    Val uePr op: “Val ue: =”,

    CheckboxProp: “Val ue: =”, MenuProp: “Val ue: =”,

    Poi nt Prop“X: =" , , "Y: =" ,

    VPoi nt Prop: "X: =", , "Y: =" ,

    V3DPoi ntProp: "X: =", , "Y: =" , ,

    "Z: =",

    Mat er i al But t on: “Mat er i al : =”,

    Col or But t on: "R: =", , "G: =" , , "B: =",

     Tr ansparency But t on: “Val ue: =”,

     for Var i abl ePr ops

    Syntax:

    “Val ue: =”, , ,

    , ,

    Parameters:

    Ar r ay( "NAME: Opt i mi zat i on" ,

    Introduction to Scripting in HFSS

    " I ncl uded: =" , ,

    "Mi n: =" , ,

    "Max: =", )

  • 8/19/2019 MacroHFSS

    63/254

    Property Script Commands 6-7

    Ar r ay( "NAME: Tuni ng" ,

    " I ncl uded: =" , ,

    "Step: =", ,

    "Mi n: =", ,

    "Max: =", )

    Ar r ay(" NAME: Sensi t i vi t y",

    " I ncl uded: =" , ,

    "Mi n: =" , ,

    "Max: =", ,

    " I Di sp: =" , )

    Ar r ay( “NAME: St at i st i cal ”,

    “I ncl uded: =”, ,

    “Di st : =”, ,

    “St dD: =”, ,

    “Mi n: =”, ,“Max: =”, ,

    “Tol : =”, )

    Type: string

    Value should be “Gauss i an” or “Uni f orm”

    St dD

    Standard deviation.

    Mi n

    Introduction to Scripting in HFSS

    Low cut-off for the distribution.

    Max

  • 8/19/2019 MacroHFSS

    64/254

    6-8 Property Script Commands

    High cut-off for the distribution.

     Tol

    Tolerance for uniform distributions. Format is “%”.

    Example: “20%”.

    Example: Adding a new project level variable “$wi dt h”:

    oPr oj ect . ChangePr oper t y Ar r ay( "NAME: Al l Tabs" , _ 

    Ar r ay( "NAME: Pr oj ect Var i abl eTab" , _Ar r ay( "NAME: Pr opSer ver s" , "Pr oj ect Var i abl es" ) , _ 

    Ar r ay( "NAME: NewProps" , _ 

    Ar r ay( "NAME: $wi dt h" , _ 

    "Pr opType: =" , "Var i abl ePr op", _ 

    "Val ue: =" , "3mm", _ 

    “Descr i pt i on: =”, “my new var i abl e”) ) ) )

    Example: Deleting the design level variable “hei ght ”:

    oDesi gn. ChangePropert y Ar r ay( "NAME: Al l Tabs" , _

    Ar r ay( "NAME: Local Var i abl eTab" , _ 

    Ar r ay( "NAME: Pr opSer ver s" , "Def i ni t i onPar amet er s" ) , _ 

    Ar r ay( “NAME: Del et edPr ops" , "hei ght " ) )

    Example: Changing a property’s value. If the following command were executed, thenthe value of the property “XSi ze” of the PropServer“Box1: Cr eat eBox: 1” on the “Geomet r y3DCmdTab”  tab would bechanged. ( oEdi t or  is the Geomet r y3D edi t or  in HFSS.)

    oEdi t or . ChangeProper t y Ar r ay( "NAME: Al l Tabs" , _ 

    Ar r ay( "NAME: Geomet r y3DCmdTab" , _ 

    Ar r ay( "NAME: PropServer s" , "Box1: Cr eat eBox: 1") , _ 

    Ar r ay("NAME: ChangedProps" , _ Ar r ay( "NAME: XSi ze" , "Val ue: =" , "1. 4mi l " ) ) ) )

    Introduction to Scripting in HFSS

    Additional Property Scripting Commands

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

  • 8/19/2019 MacroHFSS

    65/254

    Property Script Commands 6-9

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

    Pr opTab. This can be executed by the oPr oj ect , oDesi gn, or oEdi t or  variables.

    Command: None

    Syntax: Get Proper t i es( , )

    Return Value: Variant array of strings – the names of the properties belonging to the prop

    server.Example: Di m al l _pr ops

    al l _pr ops = oDesi gn. Get Pr oper t i es( “Hf ssTab”, _ 

    "BoundarySet up: WavePor t 1")

    GetPropertyValue

    Use: Gets the value of a single property. This can be executed by the oPr oj ect ,

    oDesi gn, or oEdi t or  variables.

    Command: None

    Syntax: Get Pr oper t yVal ue( , , )

    Return Value: String representing the property value.

    Example: val ue_st r i ng = _ 

    oEdi t or . Get Proper t yVal ue( “Geomet r y3DCmdTab”, _

    “Box1: Cr eateBox: 1”, “XSi ze”)

    GetVariables

    Use: Returns a list of all defined variables. To get a list of Project variables,

    execute this command using oPr oj ect . To get a list of local variables, useoDesi gn.

    Syntax: Get Var i abl es( )

    Return Value: Variant array of strings – the names of the variables.Example: Di m var _ar r ay

    Example: pr oj ect _var _ar r ay = oPr oj ect . Get Var i abl es( )

    Example: l ocal _var _arr ay = oDesi gn. Get Var i abl es( )

    Introduction to Scripting in HFSS

    GetVariableValue

    Use: Gets the value of a single variable. To get the value of Project variables,

    execute this command using oPr oj ect . To get the value of local variables,use oDesi gn.

  • 8/19/2019 MacroHFSS

    66/254

    6-10 Property Script Commands

    use oDesi gn.

    Command: None

    Syntax: Get Var i abl eVal ue( )

    Return Value: A string representing the value of the variable.

    Parameters:

    Type: string

    Name of the variable to access.

    Example: pr oj ect_var _val ue_st r i ng =oPr oj ect . GetVar i abl eVal ue(“var _name”)

    Example: l ocal _var _val ue_st r i ng =

    oDesi gn. GetVar i abl eVal ue( “var_name”)

    SetPropertyValue

    Use: Sets the value of one property. This is not supported for properties of the

    following types: But t onPr op, Poi nt Pr op, V3DPoi nt Prop, andVPoi nt Pr op. Only the ChangePr oper t y command can be used to modifythese properties. This can be executed by the oPr oj ect , oDesi gn, oroEdi t or  variables.

    Command: None

    Syntax: SetPr oper t yVal ue , , ,

    Return Value: NoneParameters:

    Type: String

    Contains the value to set the property. The formatting is different

    depending on what type of property is being edited. Use

    GetProper t yVal ue for the desired property to see the expected

    format.

    Example: oEdi t or . Set Pr oper t yVal ue _ 

    “Geomet r y3DCmdTab”, “Box1: Cr eateBox: 1”, _ 

    “XSi ze”, “3mm”

    Introduction to Scripting in HFSS

    SetVariableValue

    Use: Sets the value of a variable. To set the value of a Project variable, execute

    this command using oPr oj ect . To set the value of a local variable, useoDesi gn.

  • 8/19/2019 MacroHFSS

    67/254

    Property Script Commands 6-11

    g

    Syntax: SetVar i abl eVal ue ,

    Return Value: None

    Parameters:

    Type:

    New value for the variable.

    Example: oPr oj ect . SetVar i abl eVal ue “$Var1”, “3mm”

    Example: var _val ue = “2Ohm”oDesi gn. Set Var i abl eVal ue “Var 2”, var _val ue

    Introduction to Scripting in HFSS

    Additional Property Scripting Example

    Following is a sample script that uses the Get Proper t yVal ue, Set Proper t yVal ue, and

    Get Proper t i es functions. The script gets all the properties of the first Cr eateBox command

  • 8/19/2019 MacroHFSS

    68/254

    6-12 Property Script Commands

    of “Box1”. It then loops through the properites and for each one, shows the user the currentvalue and asks if the value should be changed.

    Example: Di m al l _pr ops

    Di m pr op

    al l _props = oEdi t or . GetPropert i es( “Geomet r y3DCmdTab”, _

    “Box1: Cr eateBox: 1”)

    For Each pr op I n al l _pr opsval = oEdi t or . Get Proper t yVal ue( “Geomet r y3DCmdTab”, _

    “Box1: Cr eat eBox: 1”, pr op)

    new_val = I nputBox("New Val ue of " + prop + " : " , _ 

    "Cur r ent Val ue of ' " + pr op + " ' i s " + val , val )

    I f new_val val Then

    oEdi t or . Set Proper t yVal ue “Geomet r y3DCmdTab”, _ 

    “Box1: Cr eat eBox: 1”, pr op, new_val

    val = _ 

    oEdi t or . Set Proper t yVal ue( “Geomet r y3DCmdTab”, _

    “Box1: Cr eat eBox: 1”, pr op)

    MsgBox( "Now t he val ue of ' " + pr op + " ' i s " + val )

    End I f 

    Next

  • 8/19/2019 MacroHFSS

    69/254

    Introduction to Scripting in HFSS

    AddDataset

    Use: Adds a dataset.

    Command:   Project>Datasets>Add

    Syntax: AddDat aset

  • 8/19/2019 MacroHFSS

    70/254

    7-2 Dataset Script Commands

    y y

    Return Value: None

    Parameters:

    Ar r ay( "NAME: ”,

    Ar r ay( “NAME: Coor di nat es”, ,

    , . . . )

    Type:

    Name of the dataset.

    Ar r ay( "NAME: Coor di nate",

    "X: =", , "Y: =" , )

    Example: oPr oj ect . AddDat aset Ar r ay( "NAME: ds1", _

    Ar r ay( "NAME: Coor di nates", _ 

    Ar r ay( "NAME: Coor di nat e" , "X: =", 1, "Y: =", 2, _ 

    Ar r ay( "NAME: Coor di nat e" , "X: =", 3, "Y: =", 4) , _ 

    Ar r ay( "NAME: Coor di nat e" , "X: =", 5, "Y: =", 7) , _ 

    Ar r ay( "NAME: Coor di nat e" , "X: =" , 6, "Y: =" , 20) ) )

    DeleteDataset

    Use: Deletes the specified dataset.

    Command:   Project>Datasets>Remove

    Syntax: Del et eDat aset

    Return Value: None

    Introduction to Scripting in HFSS

    EditDataset

    Use: Modifies a dataset. When a dataset is modified, its name as well as its data

    can be changed.

    Command:   Project>Datasets>Edit

  • 8/19/2019 MacroHFSS

    71/254

    Dataset Script Commands 7-3

    Syntax: Edi t Dat aset

    Return Value: None

    Parameters:

    Type:

    Name of the dataset before editing.

    Example: oPr oj ect . Edi t Dat aset “ds1” Ar r ay( "NAME: ds2" , _ 

    Ar r ay( "NAME: Coor di nates", _ Ar r ay( "NAME: Coor di nat e" , "X: =", 1, "Y: =", 2) , _ 

    Ar r ay( "NAME: Coor di nat e" , "X: =", 3, "Y: =", 4) ) )

    Introduction to Scripting in HFSS

  • 8/19/2019 MacroHFSS

    72/254

    7-4 Dataset Script Commands

    8 Design Object ScriptC d

  • 8/19/2019 MacroHFSS

    73/254

    Design Object Script Commands 8-1

    Commands

    Design object commands should be executed by the oDesi gn object.

    oDesi gn. CommandName

    Conventions Used in this Chapter

    Name used to access one of the following HFSS modules:

    • Boundary module: “BoundarySet up” 

    • Mesh Operations module: “MeshSetup”

    • Analysis module: “Anal ysi sSet up”

    •Optimetrics module: “Opt i met r i cs”

    • Solutions module: “Sol ut i ons”

    • Field Overlays module: “Fi el dsRepor t er ”

    • Radiation module: “RadFi el d”

    Introduction to Scripting in HFSS

    AbortSolveAsynch

    Use: Aborts a non-blocking simulation that was started by a previous call to the

    Sol veAsynch command.

    Command: none

    Syntax: Abor t Sol veAsynch

  • 8/19/2019 MacroHFSS

    74/254

    8-2 Design Object Script Commands

    Syntax: Abor t Sol veAsynch

    Return Value: None

    Example: oDesi gn. Abor t Sol veAsynch “Setup1”

    ApplyMeshOps

    Use: If there are any mesh operations that were defined and not yet performed

    in the current variation for the specified solution setups, they will be

    applied to the current mesh. If necessary, an initial mesh will be computed

    first. No further analysis will be performed.

    Command:   HFSS>Analysis Setup>Apply Mesh Operations

    Syntax: Appl yMeshOps

    Return Value:

    Type:

    -1: completed with error

    0: completed successfully

    Example: st at us = oDesi gn. Appl yMeshOps Ar r ay( “Setup1”, ”Setup2”)

    GetModule

    Use: Returns the IDispatch for the specified module.

    Command: none

    Syntax: Get Modul e

    Return Value: Module object.

    Example: Set oModul e = oDesi gn. Get Modul e “BoundarySetup”

    Introduction to Scripting in HFSS

    GetName

    Use: Returns the name of the Design.

    Command: none

    Syntax: Get Name

    R t V l Th f th D i

  • 8/19/2019 MacroHFSS

    75/254

    Design Object Script Commands 8-3

    Return Value: The name of the Design.

    Type:

    Example: name_s t r i ng = oDesi gn. Get Name

    GetSolveAsynchStatus

    Use: Returns the status of an asynchronous simulation that was started by a

    previous call to the Sol veAsynch command.Command: none

    Syntax: Get Sol veAsynchStat us

    Return Value: Type:

    -1: completed with error

     1: still running

     0: completed with no error

    Example: r etur n_st atus = oDesi gn. GetSol veAsynchSt atus “Set up1”

    Redo

    Use: Reapplies the last design-level command.

    Command:   Edit>Redo

    Syntax: Redo

    Return Value: NoneExample: oDesi gn. Redo

    Introduction to Scripting in HFSS

    RenameDesignInstance

    Use: Renames a design instance.

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

    Syntax: RenameDesi gnI nst ance

  • 8/19/2019 MacroHFSS

    76/254

    8-4 Design Object Script Commands

    Syntax: RenameDesi gnI nst ance ,

    Return Value: None

    Example: oDesi gn. RenameDesi gnI nst ance " HFSSModel 1", "HFSSModel 2"

    SARSetup

    Use: Sets up for the specific absorption rate (SAR) computation.

    Command:   HFSS>Fields>SAR SettingSyntax: SARSet up ,

    Return Value: None

    Parameters:

    Type:

    Double between 1 and 10 in grams.

    Type:

    Positive double in gram/cm3.

    Example: oDesi gn. SARSet up 1, 1

    SetActiveEditor

    Use: Sets the active editor.Command: None

    Syntax: SetAct i veEdi t or ( )

    Return Value: Editor object

    Example: Set oEdi t or = oDesi gn. Set Act i veEdi t or( "3D Model er" )

    Introduction to Scripting in HFSS

    SetSolutionType

    Use: Sets the solution type for the design.

    Command:   HFSS>Solution Type

    Syntax: SetSol ut i onType

    Return Value: None

  • 8/19/2019 MacroHFSS

    77/254

    Design Object Script Commands 8-5

    Return Value: None

    Parameters:

    Type:

    Possible values are: “Dr i venModal ”, “Dr i venTermi nal ”,or“Ei genmode”

    Example: oDesi gn. Set Sol ut i onType "Dr i venTer mi nal "

    Solve

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

    executed until the simulation is complete.

    Command:   HFSS>Analyze

    Syntax: Sol ve

    Return Value: Type:

    -1: command execution error 1: simulation error

     0: normal completion

    Parameters: : Ar r ay( , , . . . )

    Type:

    Name of the solution setup to solve.

    Example: r et ur n_st at us = oDesi gn. Sol ve Ar r ay( “Set up1”, “Set up2”)

    Introduction to Scripting in HFSS

    SolveAsynch

    Use: Performs a non-blocking simulation. The next script command will be

    executed while the simulation is being performed. If you want multiple

    solution setups to simulate in parallel, execute a separate Sol veAsynch 

    command for each setup.C d

  • 8/19/2019 MacroHFSS

    78/254

    8-6 Design Object Script Commands

    pCommand: none

    Syntax: Sol veAsynch

    Return Value: Type:

    -1: command execution error

    1: simulation error

    0: normal completion

    Example: r etur n_st atus = oDesi gn. Sol veAsynch “Set up1”

    Undo

    Use: Cancels the last design-level command.

    Command:   Edit>Undo

    Syntax: Undo

    Return Value: NoneExample: oDesi gn. Undo

    9 Output Variable Script

    Commands

  • 8/19/2019 MacroHFSS

    79/254

    Output Variable Script Commands 9-1

    Commands

    Output variable commands should be executed by the oDesi gn object.

    Set oDesi gn = Proj ect . SetAct i veDesi gn( "HFSSModel 1" )

    oDesi gn. CommandName

  • 8/19/2019 MacroHFSS

    80/254

    Introduction to Scripting in HFSS

    EditOutputVariable

    Use: Changes the name or expression of an existing output variable.

    Syntax: Edi t Out put Var i abl e

    Provide empty quotes “” as the NewVar Name or NewExpr essi on if itshould not be changed

  • 8/19/2019 MacroHFSS

    81/254

    Output Variable Script Commands 9-3

    should not be changed.

    Return Value: None

    Parameters:

    Type:

    Original name of the variable.

    Type:

    New name of the variable if any, or else pass an empty string.

    Type:

    New value to assign to the variable.

    GetOutputVariableValue

    Use: Gets the double value of an output variable. Only those expressions that

    return a double value are supported. The expression is evaluated only for a

    single point.

    Syntax: Get Out put Var i abl eVal ue , ,

    , Return Value: Double value of the output variable.

    Parameters:

    Type:

    Name of the solution as listed in the Traces dialog box.

    For example: “Set up1 : Last Adapt i ve”

    Type:

    A set of intrinsic variables, value pairs to use when evaluating the out-

    put expression.

    Example:  " Fr eq=' 20GHz' Thet a=' 20deg' Phi =' 30deg'

  • 8/19/2019 MacroHFSS

    82/254

    10 3D Modeler Editor Script

    Commands

  • 8/19/2019 MacroHFSS

    83/254

    3D Modeler Editor Script Commands 10-1

    Commands

    3D Modeler commands should be executed by the “3D Model er ” editor.

    Set oEdi t or = oDesi gn. Set Act i veEdi t or( “3D Model er”)

    oEdi t or . CommandName

    Conventions Used in this Chapter

    Ar r ay( “NAME: At t r i but es”,

    “Name: =”, ,

    “Fl ags: =”, ,

    “Col or : =”, ,“Tr anspar ency: =”, ,

    “Part Coor di nateSyst em: =”, ,

    “Mater i al Name: =”, ,

    “Sol vei nsi de: =”, )

    Fl ags 

    Format is a string containing any of the following flags separated by the

    # character:

    • NonModel

    • Wi r ef r ame

    Example: “Fl ags: =”, “NonModel #Wi r ef r ame”

    Introduction to Scripting in HFSS

    Col or

    Format is a string containing an R,G,B triple formatted as “( R G B) ”.

    Example: “Col or : =”, “( 255 255 255) ”

    T

  • 8/19/2019 MacroHFSS

    84/254

    10-2 3D Modeler Editor Script Commands

     Tr ansparency

    Specify a number between 0 and 1.

    Par t Coor di nat eSyst em

    Orientation of the primitive. The name of one of the defined coordinate

    systems should be specified.

    Ar r ay( "NAME: Sel ect i ons" ,

    "Sel ect i ons: =", )

    Sel ect i ons

    Comma-separated list of parts on which to perform the operation.Example: “Sel ect i ons: =”, “Rect 1, Rect 2”

    Introduction to Scripting in HFSS

    Draw Menu Commands

    CreateBondwire

    Use: Creates a bondwire primitive.

    Command:   Draw>Bondwire

  • 8/19/2019 MacroHFSS

    85/254

    3D Modeler Editor Script Commands 10-3

    Syntax: Cr eat eBondwi r e ,

    Return Value: None

    Parameters:

    Ar r ay( "NAME: Bondwi r eParameters" ,

    "Wi r eType: =", ,

    "Wi r eDi amet er : =" , ,"NumSi des: =", ,

    "XPadPos: =" , ,

    "YPadPos: =" , ,

    "ZPadPos: =" , ,

    "XDi r : =" , ,

    "YDi r : =" , ,

    "ZDi r : =" , ,

    "Di st ance: =", ,

    "h1: =" , ,

    "h2: =" , ,

    "al pha: =" , ,

    "bet a: =" , ,

    "Whi chAxi s: =" , )

    Wi r eType

    Should be one of: “J EDEC_4Poi nt s”, “J EDEC_5Poi nt s”

    Example: “Wi r eType: =”, “J EDEC_4Poi nts”

    Whi chAxi s

    Axis normal to the plane where the wire is drawn. Possible values are:

    “X”, “Y”, “Z”

    Example: “Whi chAxi s: =”, “Z”  means the bond wire will be drawnon the XY plane.

    Introduction to Scripting in HFSS

    CreateBox

    Use: Creates a box primitive.

    Command:   Draw>Box

    Syntax: Cr eat eBox ,

    Return Value: None

    Parameters:

  • 8/19/2019 MacroHFSS

    86/254

    10-4 3D Modeler Editor Script Commands

    Parameters:

    Ar r ay( “NAME: BoxPar amet er s” ,

    “XPosi t i on: =”, ,

    “YPosi t i on: =”, ,

    “ZPosi t i on: =”, ,

    “XSi ze: =”, ,“YSi ze: =”, ,

    “ZSi ze: =”, )

    CreateCircle

    Use: Creates a circle primitive.

    Command:   Draw>Circle

    Syntax: Cr eat eCi r cl e ,

    Return Value: None

    Parameters:

    Ar r ay( "NAME: Ci r cl ePar amet er s" ,

    "XCent er: =" , ,

    "YCent er: =" , ,

    "ZCent er: =" , ,"Radi us: =" , ,

    "Whi chAxi s: =" , )

    Whi chAxi s

    Axis of normal vector to the circle. Possible values are: “X”,  “Y”,  “Z”

    Example: “Whi chAxi s: =”, “Z” means the circle will be drawn in the

    XY plane.

    Introduction to Scripting in HFSS

    CreateCone

    Use: Creates a cone primitive.

    Command:   Draw>Cone

    Syntax: Cr eat eCone ,

    Return Value: None

    Parameters:

  • 8/19/2019 MacroHFSS

    87/254

    3D Modeler Editor Script Commands 10-5

    Parameters:

    Ar r ay("NAME: ConeParamet ers" ,

    "XCent er: =" , ,

    "YCent er : =" , ,

    "ZCent er : =" , ,

    "Whi chAxi s: =" , ,"Hei ght : =" , ,

    "Bot t omRadi us: =" , ,

    "TopRadi us: =" , )

    Whi chAxi s

    Axis of the cone. Possible values are: “X”,  “Y”,  “Z”

    Example: “Whi chAxi s: =”, “Z”

    CreateCutplane

    Use: Creates a cutpl