• No results found

scriptingMaxwell_onlinehelp

N/A
N/A
Protected

Academic year: 2021

Share "scriptingMaxwell_onlinehelp"

Copied!
364
0
0

Loading.... (view fulltext now)

Full text

(1)

Introduction to Scripting in Maxwell

ANSYS, Inc. 275 Technology Drive Canonsburg, PA 15317 USA Tel: (+1) 724-746-3304 Fax: (+1) 724-514-9494

General Information: [email protected] Technical Support: [email protected]

(2)

The information contained in this document is subject to change without notice. ANSYS, Inc. 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. ANSYS, Inc. shall not be liable for errors contained herein or for incidental or consequential dam-ages in connection with the furnishing, performance, or use of this material.

ANSYS, Inc, is a UL registered ISO 9001:2008 company. Unauthorized use, distribution, or duplication is prohibited.

© 2011 SAS IP, Inc. All rights reserved.

Ansoft, Simplorer, Optimetrics, Maxwell, and RMxprt are registered trademarks or trade-marks of SAS IP, Inc. All other tradetrade-marks are the property of their respective owners.

Printing History

New editions of this manual incorporate all material updated since the previous edition. The manual printing date, which indicates the manual’s current edition, changes when a new edition is printed. Minor corrections and updates that are incorporated at reprint do not cause the date to change.

Update packages may be issued between editions and contain additional and/or replace-ment pages to be merged into the manual by the user. Pages that are rearranged due to changes on a previous page are not considered to be revised.

Edition Date Software

Version 1 October 2005 11 2 February 2006 11 SP 1 3 February 2008 12 4 January 2010 13 5 September 2010 14 6 November 2011 15.0

(3)

Getting Help

Ansoft Technical Support

To contact Ansoft technical support staff in your geographical area,

please log on to the ANSYS corporate website,

http://www.ansys.com

,

click the Contact button, and then click Support. Your ANSYS 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. This

allows more rapid and effective debugging.

(4)
(5)

Table of Contents

1. Introduction to VBScript

Sample Maxwell Script . . . 1-3

VBScript Variables . . . 1-5

Declaring Variables . . . 1-5

Variable Naming Conventions . . . 1-6

Scope and Lifetime of Variables . . . 1-6

Array Variables . . . 1-6

VBScript Operators . . . 1-8

Operator Precedence . . . 1-8

Arithmetic Operators . . . 1-8

Comparison Operators . . . 1-9

Logical Operators . . . 1-9

Controlling Program Execution . . . 1-10

Using If...Then...Else . . . 1-10

Using Select Case . . . 1-10

Looping Through Code . . . 1-11

Using a For...Next Loop . . . 1-11

Using a Do Loop . . . 1-11

Repeating Statements While a Condition is True . . . 1-11

Repeating a Statement Until a Condition Becomes True . 1-11

(6)

Function Procedures . . . 1-12

Sub Procedures . . . 1-12

Converting Between Data Types . . . 1-12

Interacting with a Script . . . 1-13

Recommended VBScript References . . . 1-13

2. Maxwell and VBScript

Overview of Maxwell Script Variables . . . 2-2

Recording a Script . . . 2-5

Stopping Script Recording . . . 2-5

Running a Script . . . 2-6

Pausing and Resuming a Script . . . 2-7

Stopping a Script . . . 2-7

Maxwell Scripting Conventions . . . 2-7

Syntax Conventions . . . 2-7

Script Command Conventions . . . 2-8

Named Arguments . . . 2-9

Setting Numerical Values . . . 2-10

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

Editing Properties . . . 2-11

3. Ansoft Application Object Script Commands

General Application Script Commands . . . 3-2

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

(7)

4. Desktop Object Script Commands

General Desktop Script Commands . . . 3-2

CloseAllWindows . . . 3-2 CloseProject . . . 3-3 CloseProjectNoForce . . . 3-3 EnableAutoSave . . . 3-3

ExportOptionsFiles . . . 3-3

GetActiveProject . . . 3-4 GetLibraryDirectory . . . 3-4 GetProjectDirectory . . . 3-4 GetProjectList . . . 3-4 GetTempDirectory . . . 3-5 GetVersion . . . 3-5 NewProject . . . 3-5 OpenMultipleProjects . . . 3-5 OpenProject . . . 3-6 PauseScript . . . 3-6 Print . . . 3-6 QuitApplication . . . 3-6 RestoreWindow . . . 3-7 RunProgram . . . 3-7 RunScript . . . 3-7 SetActiveProject . . . 3-8 SetActiveProjectByPath . . . 3-8 SetLibraryDirectory . . . 3-9 SetProjectDirectory . . . 3-9 SetTempDirectory . . . 3-9 Sleep . . . 3-9

Commands for Querying Objects . . . 3-11

Count . . . 3-11 GetDesigns . . . 3-12 GetDistributedAnalysisMachines . . . 3-12 GetName (Desktop) . . . 3-12

(8)

GetProjects . . . 3-12

5. Project Object Script Commands

General Project Object Script Commands . . . 4-2

GetName (Project) . . . 4-2 GetPath . . . 4-2 GetActiveDesign . . . 4-3 SetActiveDesign . . . 4-3 GetTopDesignList . . . 4-3 GetDesign . . . 4-3 Close . . . 4-4 Save . . . 4-4 SaveAs . . . 4-4 InsertDesign . . . 4-4 CopyDesign . . . 4-5 Paste (Project) . . . 4-6 CutDesign . . . 4-6 DeleteDesign . . . 4-6 Undo (Project) . . . 4-6 Redo (Project) . . . 4-7 AnalyzeAll (Project menu) . . . 4-7

6. Material Script Commands

Material Level Script Commands . . . 5-2

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

7. Property Script Commands

Conventions Used in the Property Script Chapter . . . 6-2

General Property Scripting Commands . . . 6-4

ChangeProperty . . . 6-4

(9)

PropHost Functions . . . 6-13

AddMenuProp . . . 6-13 AddMenuProp2 . . . 6-14 AddProp . . . 6-14 AddProp2 . . . 6-14 ExecuteScript . . . 6-15 GetCallback . . . 6-15 GetChangedProperty . . . 6-15 GetDescription . . . 6-15 GetEditor . . . 6-16 GetFileName . . . 6-16 GetHidden . . . 6-16 GetPropServers . . . 6-16 GetPropTabType . . . 6-17 GetReadOnly . . . 6-17 GetTabTypeName . . . 6-17 GetText . . . 6-17 GetValue . . . 6-18 PropertyExists . . . 6-18 RemoveProp . . . 6-18 SetCallback . . . 6-18 SetDescription . . . 6-19 SetHidden . . . 6-19 SetReadOnly . . . 6-19 SetText . . . 6-19 SetValue . . . 6-19

Additional Property Scripting Commands . . . 6-21

GetPropertyValue . . . 6-21 SetPropertyValue . . . 6-21 GetProperties . . . 6-22 GetVariableValue . . . 6-22 SetVariableValue . . . 6-23 GetVariables . . . 6-23

(10)

Additional Property Scripting Example . . . 6-24

Example: Using Record Script and Edit Properties . . . 6-25

8. Dataset Script Commands

General Dataset Script Commands . . . 7-2

AddDataset . . . 7-2 EditDataset . . . 7-2 DeleteDataset . . . 7-3

9. Design Object Script Commands

Conventions Used in the Design Object Chapter . . . 8-2

General Design Object Script Commands . . . 8-3

GetName (Design) . . . 8-3 GetModule . . . 8-4 SetDesignSettings . . . 8-4 DeleteVariation . . . 8-6 SetSolutionType . . . 8-7 SetActiveEditor . . . 8-7 Solve . . . 8-8 Undo (Design) . . . 8-8 Redo (Design) . . . 8-8 RenameDesignInstance . . . 8-8 ApplyMeshOps . . . 8-9 EditNotes . . . 8-9 AnalyzeAll (Maxwell menu) . . . 8-10 AnalyzeAllNominal . . . 8-10 Analyze . . . 8-10 AnalyzeDistributed . . . 8-10 SetConductivityThreshold . . . 8-11 ExportConvergence . . . 8-11 GetVariationVariableValue . . . 8-12 ExportMeshStats . . . 8-12 ExportProfile . . . 8-13 GetNominalVariation . . . 8-14

(11)

Is2D . . . 8-14 Is3D . . . 8-14 GetOutputVariableValue, AddOutputVariable, EditOutputVari-able, DeleteOutputVariable . . . 8-14 ChangeProperty, GetPropertyValue, SetPropertyValue, Get-Properties, GetVariableValue, SetVariableValue, GetVariables 8-15

CreateReport, RemoveReport, GetReportNames . . . 8-15 AddDataset, EditDataset, DeleteDataset . . . 8-15

10. Output Variable Script Commands

General Output Variable Script Commands . . . 9-2

CreateOutputVariable . . . 9-2 EditOutputVariable . . . 9-3 DeleteOutputVariable . . . 9-4 DoesOutputVariableExist . . . 9-4 GetOutputVariables . . . 9-4 GetOutputVariableValue . . . 9-4

11. 3D Modeler Editor Script Commands

Conventions Used in the 3D Modeler Chapter . . . 10-2

Draw Menu Commands . . . 10-3

CreateBondwire . . . 10-3 CreateBox . . . 10-4 CreateCircle . . . 10-5 CreateCone . . . 10-6 CreateCutplane . . . 10-6 CreateCylinder . . . 10-7 CreateEllipse . . . 10-7 CreateHelix . . . 10-8 CreatePoint . . . 10-8 CreateUserDefinedPart . . . 10-9 CreatePolyline . . . 10-9 CreateRectangle . . . 10-10

(12)

CreateRegularPolyhedron . . . 10-11 CreateRegularPolygon . . . 10-12 CreateSphere . . . 10-12 CreateSpiral . . . 10-13 CreateTorus . . . 10-13 EditPolyline . . . 10-14 InsertPolylineSegment . . . 10-14 PurgeHistory . . . 10-15 DeletePolylinePoint . . . 10-16 SweepAlongPath . . . 10-16 SweepAlongVector . . . 10-17 SweepAroundAxis . . . 10-17

Edit Menu Commands . . . 10-19

Copy . . . 10-19 DuplicateAlongLine . . . 10-19 DuplicateAroundAxis . . . 10-20 DuplicateMirror . . . 10-20 Mirror . . . 10-21 Move . . . 10-21 OffsetFaces . . . 10-21 Paste (Modeler) . . . 10-22 Rotate . . . 10-22 Scale . . . 10-22

Modeler Menu Commands . . . 10-24

AssignMaterial . . . 10-25 Chamfer . . . 10-25 Connect . . . 10-25 CoverLines . . . 10-26 CoverSurfaces . . . 10-26 CreateEntityList . . . 10-26 CreateFaceCS . . . 10-27 CreateObjectCS . . . 10-28 CreateObjectFromEdges . . . 10-30

(13)

CreateObjectFromFaces . . . 10-31 CreateRelativeCS . . . 10-32 DeleteLastOperation . . . 10-32 DetachFaces . . . 10-33 EditEntityList . . . 10-33 EditFaceCS . . . 10-34 EditObjectCS . . . 10-34 EditRelativeCS . . . 10-36 Export . . . 10-37 Fillet . . . 10-37 GenerateHistory . . . 10-38 Import . . . 10-38 ImportDXF . . . 10-38 Intersect . . . 10-41 MoveFaces . . . 10-42 Section . . . 10-43 SeparateBody . . . 10-43 SetModelUnits . . . 10-43 SetWCS . . . 10-44 ShowWindow . . . 10-44 Split . . . 10-44 Subtract . . . 10-45 UncoverFaces . . . 10-45 Unite . . . 10-46

Other oEditor Commands . . . 10-47

Delete . . . 10-47 GetModelBoundingBox . . . 10-47 GetEdgeByPosition . . . 10-47 GetFaceByPosition . . . 10-48 GetUserPosition . . . 10-49 GetObjectName . . . 10-49 GetObjectIDByName . . . 10-49 GetObjectNameByFaceID . . . 10-50

(14)

GetMatchedObjectName . . . 10-50 GetNumObjects . . . 10-50 GetSelections . . . 10-50 PageSetup . . . 10-51 RenamePart . . . 10-51 GetModelBoundingBox . . . 10-52

12. Reporter Editor Script Commands

General Reporter Editor Script Commands . . . 11-2

AddCartesianXMarker . . . 11-2 AddDeltaMarker . . . 11-3 AddMarker . . . 11-4 AddNote . . . 11-4 AddTraces . . . 11-5 ClearAllMarkers . . . 11-6 CopyTracesData . . . 11-7 CopyReportData . . . 11-7 CopyReportDefinitions . . . 11-7 CopyTraceDefinitions . . . 11-8 CreateReport . . . 11-8 CreateReportFromTemplate . . . 11-10 DeleteTraces . . . 11-11 ExportToFile . . . 11-11 FFTOnReport . . . 11-12 GetAllReportNames . . . 11-13 GetDisplayType . . . 11-13 ImportIntoReport . . . 11-13 PasteReports . . . 11-14 PasteTraces . . . 11-14 DeleteAllReports . . . 11-15 DeleteReports . . . 11-15 RenameReport . . . 11-15 RenameTrace . . . 11-15 UpdateTraces . . . 11-16

(15)

UpdateTracesContextAndSweeps . . . 11-17

13. Boundary and Excitation Module Script

Com-mands

Conventions Used in this Chapter . . . 12-2

General Commands Recognized by the Boundary/Excitation

Module . . . 12-3

DeleteBoundaries . . . 12-3 DeleteAllBoundaries . . . 12-3 DeleteAllExcitations . . . 12-4 GetBoundaries . . . 12-4 GetBoundariesOfType . . . 12-4 GetBoundaryAssignment . . . 12-4 GetNumBoundaries . . . 12-5 GetNumBoundariesOfType . . . 12-5 GetExcitations . . . 12-5 GetExcitationsOfType . . . 12-5 GetNumExcitations . . . 12-6 GetNumExcitationsOfType . . . 12-6 RenameBoundary . . . 12-6 ReassignBoundary . . . 12-7 ReprioritizeBoundaries . . . 12-7

Script Commands for Creating and Modifying Boundaries 12-8

AssignZeroTangentialHField . . . 12-8 EditZeroTangentialHField . . . 12-9 AssignSymmetry . . . 12-9 EditSymmetry . . . 12-9 AssignInsulating . . . 12-9 EditInsulating . . . 12-10 AssignMaster . . . 12-10 EditMaster . . . 12-11 AssignSlave . . . 12-11 EditSlave . . . 12-11 AssignRadiation . . . 12-11

(16)

EditRadiation . . . 12-12 AssignImpedance . . . 12-12 EditImpedance . . . 12-12 AssignTangentialHField . . . 12-13 EditTangentialHField . . . 12-13 AssignCylindricalHField . . . 12-13 EditCylindricalHField . . . 12-14

Script Commands for Creating and Modifying Excitations 12-15

AssignVoltage . . . 12-15 AssignVoltageGroup . . . 12-16 EditVoltage . . . 12-16 AssignVoltageDrop . . . 12-16 AssignVoltageDropGroup . . . 12-17 EditVoltageDrop . . . 12-17 AssignCurrentDensity . . . 12-17 AssignCurrentDensityGroup . . . 12-18 EditCurrentDensity . . . 12-18 AssignCurrentDensityTerminal . . . 12-18 AssignCurrentDensityTerminalGroup . . . 12-19 EditCurrentDensityTerminal . . . 12-19 AssignCurrent . . . 12-19 AssignCurrentGroup . . . 12-19 EditCurrent . . . 12-19 AssignFloating . . . 12-20 EditFloating . . . 12-20 AssignCharge . . . 12-20 EditCharge . . . 12-21 AssignVolumeChargeDensity . . . 12-21 EditVolumeChargeDensity . . . 12-21 AssignCoilTerminal . . . 12-21 AssignCoilTerminalGroup . . . 12-22 EditCoilTerminal . . . 12-22 AssignSink . . . 12-22

(17)

EditSink . . . 12-23

Other BoundarySetup Module Script Commands . . . 12-24

AssignWindingGroup . . . 12-24 EditWindingGroup . . . 12-25 AddTerminalsToWinding . . . 12-25 EditExternalCircuit . . . 12-25 SetCoreLoss . . . 12-26 SetEddyEffect . . . 12-26 SetMinimumTimeStep . . . 12-27

14. Mesh Operations Module Script Commands

Conventions Used in the Mesh Operations Chapter . . . 13-2

General Commands Recognized by the Mesh Operations

Mod-ule . . . 13-3

DeleteOp . . . 13-3 GetOperationNames . . . 13-3 RenameOp . . . 13-3

Script Commands for Creating and Modifying Mesh Operations

13-5

AssignLengthOp . . . 13-5 AssignSkinDepthOp . . . 13-6 AssignTrueSurfOp . . . 13-7 AssignModelResolutionOp . . . 13-7 EditLengthOp . . . 13-8 EditSkinDepthOp . . . 13-8 EditTrueSurfOp . . . 13-8 EditModelResolutionOp . . . 13-9

15. Analysis Module Script Commands

Analysis Setup Script Commands . . . 14-2

InsertSetup . . . 14-2 EditSetup . . . 14-8 RenameSetup . . . 14-9 DeleteSetups . . . 14-10

(18)

ExportCircuit . . . 14-10 ExportSolnData . . . 14-11 RevertSetupToInitial . . . 14-12 RevertAllToInitial . . . 14-12 ResetSetupToTimeZero . . . 14-13 ResetAllToTimeZero . . . 14-13 GetSetups . . . 14-13 GetSetupNames . . . 14-13 Analyze (Project Menu) . . . 14-14 CopySetup . . . 14-14 PasteSetup . . . 14-14

16. Optimetrics Module Script Commands

Conventions Used in the Optimetrics Module Chapter . 15-2

General Commands Recognized by the Optimetrics Module

15-5

DeleteSetups (Optimetrics) . . . 15-5 DistributedAnalyzeSetup . . . 15-5 GetSetupNames (Optimetrics) . . . 15-5 GetSetupNamesByType (Optimetrics) . . . 15-6 RenameSetup (Optimetrics) . . . 15-6 SolveSetup (Optimetrics) . . . 15-6

Parametric Script Commands . . . 15-7

InsertSetup (Parametric) . . . 15-7 EditSetup (Parametric) . . . 15-9

Optimization Script Commands . . . 15-10

InsertSetup (Optimization) . . . 15-10 EditSetup (Optimization) . . . 15-12

Sensitivity Script Commands . . . 15-13

InsertSetup (Sensitivity) . . . 15-13 EditSetup (Sensitivity) . . . 15-14

Statistical Script Commands . . . 15-15

InsertSetup (Statistical) . . . 15-15 EditSetup (Statistical) . . . 15-17

(19)

17. Solutions Module Script Commands

DeleteSolutionVariation . . . 16-2

18. Field Overlays Module Script Commands

General Parameter Setup Script Commands . . . 17-2

CreateFieldPlot . . . 17-2 DeleteFieldPlot . . . 17-6 GetFieldPlotNames . . . 17-6 ModifyFieldPlot . . . 17-6 RenameFieldPlot . . . 17-7 RenamePlotFolder . . . 17-7 SetFieldPlotSettings . . . 17-8 SetPlotFolderSettings . . . 17-8

19. Fields Calculator Script Commands

Field Calculator Script Commands . . . 18-2

AddNamedExpression . . . 18-2 AddNamedExpr . . . 18-3 CalcOp . . . 18-3 CalcRead(deprecated) . . . 18-3 CalcStack . . . 18-4 CalculatorRead . . . 18-4 CalculatorWrite . . . 18-5 CalcWrite(deprecated) . . . 18-5 ChangeGeomSettings . . . 18-6 ClcEval . . . 18-6 ClcMaterial . . . 18-6 ClearAllNamedExpr . . . 18-6 CopyNamedExprToStack . . . 18-7 DeleteNamedExpr . . . 18-7 EnterComplex . . . 18-7 EnterComplexVector . . . 18-8 EnterLine . . . 18-8 EnterPoint . . . 18-8

(20)

EnterQty . . . 18-9 EnterScalar . . . 18-9 EnterScalarFunc . . . 18-9 EnterSurf . . . 18-10 EnterVector . . . 18-10 EnterVectorFunc . . . 18-10 EnterVol . . . 18-11 ExportOnGrid . . . 18-11 ExportToFile . . . 18-12 GetTopEntryValue . . . 18-12 LoadNamedExpressions . . . 18-13 SaveNamedExpressions . . . 18-13

20. Motion Setup Script Commands

Conventions Used in the Motion Setup Chapter . . . 18-2

General Motion Setup Script Commands . . . 18-3

DeleteMotionSetup . . . 18-3 ReassignMoving . . . 18-3

Commands to Create and Edit the Band . . . 18-3

AssignBand . . . 18-3 EditMotionSetup . . . 18-5

Other Commands Recognized By the ModelSetup Module

18-5

SetSymmetryMultiplier . . . 18-5

21. Parameter Setup Script Commands

Conventions Used in the Parameter Chapter . . . 18-2

General Parameter Setup Script Commands . . . 18-3

DeleteParameters . . . 18-3 DeleteAllParameters . . . 18-3 RenameParameter . . . 18-3 ReassignParameter . . . 18-4

Commands to Create and Edit Parameters . . . 18-5

(21)

EditForce . . . 18-5 AssignTorque . . . 18-6 EditTorque . . . 18-6 AssignMatrix . . . 18-6 EditMatrix . . . 18-7

22. User Defined Solutions Commands

CreateUserDefinedSolution . . . 19-2 DeleteUserDefinedSolutions . . . 19-4 EditUserDefinedSolution . . . 19-4

23. Example Scripts

Variable Helix Script . . . 20-2

Maxwell Data Export Script . . . 20-6

(22)
(23)

1

Introduction to VBScript

Maxwell 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. You can write a script using any text editor, or you can record a script from within the Maxwell interface. After recording the script from within Max-well, you can then modify it using a text editor.

Although Maxwell records scripts in VBScript format, it can also execute scripts in JavaScriptTM format. If you are running a script from a command prompt, the script can be written in any language that provides the Microsoft COM methods. The Maxwell 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.

Related Topics: Sample Maxwell Script VBScript Variables VBScript Operators

Controlling Program Execution Looping Through Code

VBScript Procedures

Converting Between Data Types Interacting with a Script

(24)
(25)

Sample Maxwell Script

Following is an example of a Maxwell 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.

Dim oAnsoftApp Dim oDesktop Dim oProject Dim oDesign Dim oEditor Dim oModule

REM Dim is used to declare variables and 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 Maxwell, variants that will be used as objects always begin with o. Set oAnsoftApp = CreateObject("AnsoftMaxwell.MaxwellScriptInterface") ’ You can use Set to assign an object reference to a variable. A copy of the object is not ’ created for that variable. Here CreateObject is a function that takes a string as input ’ and returns an object. The object is assigned to the variable oAnsoftApp.

Set oDesktop = oAnsoftApp.GetAppDesktop()

’ GetAppDesktop is a function of oAnsoftApp. This function does not take an input and it ’ returns an object. The object is assigned to the variable oDesktop.

oDesktop.NewProject

’ In VBScript, a Sub procedure is a procedure that is called by name, can receive arguments, ’ and can perform a specific task with a group of statements. Here the Sub procedure ’ NewProject of the object oDesktop is called. This Sub does not take an input. Set oProject = oDesktop.GetActiveProject

oProject.InsertDesign "Maxwell", "Maxwell Model1", "", "" ’ 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.

(26)

Set oDesign = oProject.SetActiveDesign("Maxwell Model1") 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

’ character ( _ ) here indicates that the statement continues to the next line. The ’ underscore character must be placed outside of string constants, or else VBScript ’ recognizes 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."

(27)

VBScript Variables

A VBScript variable is a placeholder representing information that may change while 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

Variable Naming conventions

Scope and Lifetime of Variables

Array Variables

Declaring Variables

To declare variables explicitly in a script, use the Dim, Public, or Private statements. For example:

Dim box_xsize

After declaring a variable, you can assign information to it. For example: box_xsize = "3mm"

You can declare multiple variables by separating each variable name with a comma. For exam-ple:

Dim Top, Bottom, Left, Right

You can also declare a variable implicitly by simply using its name in your script. Doing so is not generally 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 state-ment is available to require explicit declaration of all variables. The Option Explicit statestate-ment should be the first statement in your script.

(28)

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:

Begin with an alphabetic character.

Cannot contain an embedded period.

Must not exceed 255 characters.

Must be unique in the scope in which it is declared.

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

The lifetime of a variable depends on how long it exists. The script-level variables exist from declaration until the end of the script. A procedure-level variable exists only as long as you are in the procedure 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 vari-able. An array variable contains a series of values. For example:

Dim Primitives(2)

All arrays in VBScript are zero-based, so the array above actually contains 3 elements. You assign data to each of the array’s elements using an index into the array. Data can be assigned to the elements of an array as follows:

Primitives(0) = "Box1" Primitives(1) = "Cone1" Primitives(2) = "Cylinder1"

Similarly, the data can be retrieved from any element using an index into a particular array ele-ment. 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().

(29)

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 contents of the array as the resizing takes place.

ReDim FirstArray(25)

(30)

VBScript Operators

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

comparison operators, and logical operators.

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

Operator Precedence

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

(31)

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

<= Less than or equal to >= Greater than or equal to Is Object equivalence

Symbol Description Not Logical negation And Logical conjunction

Or Logical disjunction Xor Logical exclusion Eqv Logical equivalence Imp Logical implication

(32)

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:

If...Then...Else

Select Case

Using If...Then...Else

Following is an example that demonstrates the If...Then...Else conditional statement: If obj = "Box1" Then

<statements to execute> ElseIf obj = "Cylinder1" Then

<statements to execute> Else

<statements to execute> End If

Using Select Case

Following is an example that demonstrates the Select Case conditional statement: Select Case primitive_name

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

(33)

Looping Through Code

Looping allows you to run a group of statements repeatedly. There are two types of loops:

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

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

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 variable = start To end <statements to execute> Next

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

(34)

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 convert the string "2.5" to the number 2.5.

CInt Syntax: CInt(variablename).

(35)

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

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

(36)
(37)

2

Maxwell and VBScript

This chapter provides an overview of Maxwell scripting using VBScript. Infor-mation is included on the following topics:



Maxwell script variables.



Recording, running, pausing, resuming, and stopping a script from run-ning or recording.



Modifying a script for easier playback.



Maxwell scripting conventions, including script command syntax used in this guide, named arguments, and setting numerical values.



Executing a script from within a script.

(38)

Overview of Maxwell Script Variables

When you record a script, the beginning of the script looks like the following: Dim oAnsoftApp Dim oDesktop Dim oProject Dim oDesign Dim oEditor Dim oModule

Set oAnsoftApp = CreateObject("AnsoftMaxwell.MaxwellScriptInterface") 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 Maxwell in the script and assign values to the vari-ables. The variables are used in the following hierarchy:

Class hierarchy of variables.

oAnsoftApp oDesktop oProject oModule oDesign oEditor

(39)

oAnsoftApp

The oAnsoftApp object provides a handle for VBScript to access Maxwell.

oDesktop

The oDesktop object is used to perform desktop-level operations, including project manage-ment.

See Chapter 4, Desktop Object Script Commands, for details about script commands recognized by the oDesktop object.

oProject

The oProject object corresponds to one project open in the product. It is used to manipulate the project and its data. Its data includes variables, material definitions and one or more designs.

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

Chapter 5, Project Object Script Commands

Chapter 6, Material Script Commands

Chapter 7, Property Script Commands

Chapter 8, 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.

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

Chapter 9, Design Object Script Commands

Chapter 10, Output Variable Script Commands

(40)

oEditor

The oEditor object corresponds to an editor, such as the 3D Modeler. This object is used to add and modify data in the editor.

The Maxwell product scripting supports the following editors:

See Chapter 11, 3D Modeler Editor Script Commands, for details about the script commands rec-ognized by the oEditor object and Chapter 12, 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.

The Maxwell product scripting supports the following modules:

Editor Name in Script

3D Modeler Editor "3D Modeler"

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

Module Name in Script Chapter

Boundary Module

Corresponds to the Boundary and Excitation commands.

"BoundarySetup" Chapter 13, Boundary and Excitation Module Script Commands

Mesh Operations Module Corresponds to the Mesh

Operations folder in the project tree.

"MeshSetup" Chapter 14, Mesh Operations Module Script Commands

Analysis Module

Corresponds to the Analysis folder in the project tree.

"AnalysisSetup" Chapter 15, Analysis Module Script Commands

Optimetrics Module

Corresponds to the Optimetrics folder in the project tree.

"Optimetrics" Chapter 16, Optimetrics Script Commands

(41)

Recording a Script

Script commands can be found on the Tools menu in the Maxwell interface.

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.

To record a script:

1

Click Tools>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\Maxwell12\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

Script commands can be found on the Tools menu in the Maxwell interface. To stop recording a script:

On the Tools menu, click Stop Script Recording. Maxwell stops recording to the script.

Solutions Module

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

Solution Data.

"Solutions" Chapter 17, Solutions Module Script Commands

Field Overlays Module

Corresponds to the Field Overlays folder in the project tree.

"FieldsReporter" Chapter 18, Field Overlays Module Script Commands Model Module

Corresponds to the Model folder in the project tree.

"ModelSetup" Chapter 20, Motion Setup Script Commands

Parameter Module

Corresponds to the Parameters folder in the project tree.

"MaxwellParameterS etup"

Chapter 21, Parameter Setup Script Commands

(42)

Running a Script

Script commands can be found on the Tools menu in the Maxwell interface. To run a script:

1

Click Tools>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.

Maxwell 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. You can access the script arguments using the

Ansoft-ScriptHost.arguments collection from vbscript. This is a standard COM collection. To run a script from a command line (as described in the Online Help):

1

Type one of the following command line options at the command line: -runscriptandexit or -runscript

2

Press Enter.

You can also pass the -scriptargs parameter to the script and specify arguments. Note If you run the script from DOS prompt as a .vbs file (that is, you do not launch Maxwell or

ePhysics, but simply 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, write the following:

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)

(43)

Pausing and Resuming a Script

Script commands can be found on the Tools menu in the Maxwell interface. To pause a script during its execution:

Click Tools>Pause Script. To resume a script after pausing it:

Click Tools>Resume Script.

Stopping a Script

Script commands can be found on the Tools menu in the Maxwell interface. To stop a script.

Click Tools>Stop Script.

Maxwell stops executing the script that has been paused.

Maxwell Scripting Conventions

This scripting guide uses the following conventions:

Syntax conventions

Script command conventions

Named arguments

Setting numerical values

Syntax Conventions

The following data types will be used throughout this scripting guide: <string> A quoted string.

<bool> A boolean value. Should be set to either true or false (no quotes). Example: "SolveInside:=", true

(44)

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.

Syntax: Demonstrates the correct syntax for the command. Carat brackets < > enclose information or arguments that you must enter.

Return Value: Describes the return value, if any.

Parameters: Describes the arguments or information in the syntax description, if an explanation is needed.

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, you can give -scriptargs parameters and specify arguments.

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.

The user can access the script arguments using the AnsoftScriptHost.arguments col-lection from vbscript. This is a standard COM colcol-lection.

<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 Maxwell expression.

Examples:

-"XSize:=", 1 -"XSize:=", "3mm"

-"XSize:=", VBScript_Var

(45)

There is an issue if the user runs the script from a DOS prompt as a .vbs file (that is, you don’t open Maxwell, but launch the vbs script directly, or use wscript.exe or cscript.exe). The arguments will be in the WSH.arguments collection, not the AnsoftScriptHost.arguments collection. To handle this, you can write this:

on error resume next dim args

Set args = AnsoftScript.arguments if(IsEmpty(args)) then

Set args = WSH.arguments End if

on error goto 0

'At this point, args has the arguments no matter if you are running 'under windows script host or Ansoft script host

msgbox "Count is " & args.Count for i = 0 to args.Count - 1 msgbox args(i)

next

Named Arguments

Many Maxwell 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 Maxwell 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 Maxwell which data is being given. The names must be included or the script will not play back correctly. How-ever, if you are writing a script, you do not need to pass in every piece of data that the com-mand can take. For example, if you are modifying a boundary, the script will be recorded to include every piece of data needed for the boundary, whether or not it was modified. If you are writing a script by hand, you can just add the data that changed and omit anything that you do not want to change. Maxwell will use the names to determine which data you provided.

(46)

For example, when editing an impedance boundary, Maxwell records the ‘edit impedance boundary’ command as follows:

oModule.EditImpedance "Imped1", Array("NAME:Imped1", "Resistance:=",_ "100", "Reactance:=", "50", "InfGroundPlane:=", false)

If you only want to change the resistance, then you can leave out the other data arguments when you are manually writing a script:

oModule.EditImpedance "Imped1", Array("NAME:Imped1", "Resistance:=",_ "100")

Setting Numerical Values

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

Pass in the number directly. For example:

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

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

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

Pass in an Maxwell defined variable name. For example:

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

Pass in a VBScript variable. For example: vb_var = "3.5V"

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

(47)

Executing a Script from Within a Script

Maxwell 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, Maxwell searches for the specified script in the fol-lowing 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 speci-fied 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.

Maxwell 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 7, Property Script Commands, for an explanation of how to manipulate properties in a script.

(48)
(49)

3

Ansoft Application Object

Script Commands

The Application object commands permit you to set parameters for RAM and processor use. Application object commands should be executed by the oAnsoftApp object.

(50)

General Application Script Commands

Following are general script commands recognized by the oAnsoftApp object:

GetAppDesktop

SetDesiredRamMBLimit

GetHPCLicenseType

SetHPCLicenseType

GetUseHPCForMP

SetUseHPCForMP

SetMaximumRamMBLimit

SetNumberOfProcessors

GetDesiredRamMBLimit

GetMaximumRamMBLimit

GetNumberOfProcessors

GetAppDesktop

Use: GetAppDesktop is a function of oAnsoftApp. This function does not take an input and it returns an object. The object is assigned to the variable oDesktop.

Syntax: GetAppDesktop()

Return Value: Object.

Parameters: None

Example: Set oDesktop = oAnsoftApp.GetAppDesktop()

SetDesiredRamMBLimit

Use: Sets the Desired RAM Limit (MB) value.

Syntax: SetDesiredRamMBLimit <DesiredRAMLimit>, <ProductName>

Return Value: None

Parameters: <DesiredRAMLimit>

Type: <int>

<ProductName>

Type: <String>

Values may be: Maxwell 3D, Maxwell 2D. If no ProductName is supplied, the setting is applied to both 2D and 3D.

Example: oAnsoftApp.SetDesiredRamMBLimit 2000, "Maxwell 3D" Note This function is not supported for RMxprt.

(51)

GetHPCLicenseType

Use: Returns the HPC license type if multiprocessing using HPC licenses has been enabled.

Syntax: GetHPCLicenseType <ProductName>

Return Value: <string> = "pack" or "pool"

Parameters: <ProductName> Type: <string>

Example: Dim oAnsoftApp Dim oDesktop Dim oProject Dim oDesign Dim oEditor Dim oModule

Set oAnsoftApp = CreateObject("AnsoftMaxwell.Max-wellScriptInterface")

Set oDesktop = oAnsoftApp.GetAppDesktop() oDesktop.RestoreWindow

Set oProject = oDesktop.SetActiveProject("Project6") Set oDesign = oProject.SetActiveDesign("MaxwellDesign1") oAnsoftApp.GetUseHPCForMP

oAnsoftApp.GetHPCLicenseType "Maxwell 15.0" oAnsoftApp.SetHPCLicenseType("Pool")

oAnsoftApp.SetUseHPCForMP(1)

GetUseHPCForMP

Use: Returns "true" if Use HPC licenses for multiprocessing and distributed frequency has been enabled on the Maxwell 2D Options Solver tab or Maxwell 3D Options Solver tab.

Syntax: GetUseHPCForMP <ProductName>

Return Value: "true" if Use HPC licenses for multiprocessing and

distributed frequency has been enabled on the Maxwell 2D Options Solver tab or Maxwell 3D Options Solver tab.

Parameters: <ProductName> Type: <string>

(52)

Dim oDesktop Dim oProject Dim oDesign Dim oEditor Dim oModule

Set oAnsoftApp = CreateObject("AnsoftMaxwell.Max-wellScriptInterface")

Set oDesktop = oAnsoftApp.GetAppDesktop() oDesktop.RestoreWindow

Set oProject = oDesktop.SetActiveProject("Project6") Set oDesign = oProject.SetActiveDesign("MaxwellDesign1") oAnsoftApp.GetUseHPCForMP "Maxwell 15.0"

oAnsoftApp.GetHPCLicenseType

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

SetUseHPCForMP

Use: Enables HPC licenses to be used for multiprocessing and distributed frequency sweeps.

Command: Tools>Options>Maxwell2D Options and Tools>Options>Maxwell3D

Options, Solver tab - Use HPC licenses for multiprocessing and distributed frequency.

Syntax: SetUseHPCForMP <bool>, <ProductName>

Return Value: None

Parameters: <bool>; ’true’ = use HPC for MP <ProductName>

Type: <string>

Example: Dim oAnsoftApp Dim oDesktop Dim oProject Dim oDesign Dim oEditor Dim oModule

Set oAnsoftApp = CreateObject("AnsoftMaxwell.Max-wellScriptInterface")

(53)

oDesktop.RestoreWindow

Set oProject = oDesktop.SetActiveProject("Project6") Set oDesign = oProject.SetActiveDesign("MaxwellDesign1") oAnsoftApp.GetUseHPCForMP

oAnsoftApp.GetHPCLicenseType

oAnsoftApp.SetHPCLicenseType("Pool")

oAnsoftApp.SetUseHPCForMP "true", "Maxwell 15.0"

SetHPCLicenseType

Use: Sets the HPC License Type, either "Pack" or "Pool".

Command: Tools>Options>Maxwell2D Options and Tools>Options>Maxwell3D Options, on the Solver tab

Syntax: SetHPCLicenseType <string>, <ProductName>

Return Value: None

Parameters: LicenseType: <string> = ’pack’ or ’pool’ <ProductName>

Type: <string>

Example: Dim oAnsoftApp Dim oDesktop Dim oProject Dim oDesign Dim oEditor Dim oModule

Set oAnsoftApp = CreateObject("AnsoftMaxwell.Max-wellScriptInterface")

Set oDesktop = oAnsoftApp.GetAppDesktop() oDesktop.RestoreWindow

Set oProject = oDesktop.SetActiveProject("Project6") Set oDesign = oProject.SetActiveDesign("MaxwellDesign1") oAnsoftApp.GetUseHPCForMP

oAnsoftApp.GetHPCLicenseType

oAnsoftApp.SetHPCLicenseType "pack", "Maxwell 15.0" oAnsoftApp.SetUseHPCForMP(1)

SetMaximumRamMBLimit

(54)

Syntax: SetMaximumRamMBLimit <MaximumRAMLimit>, <ProductName>

Return Value: None

Parameters: <MaximumRAMLimit>

Type: <int>

<ProductName>

Type: <String>

Values may be: Maxwell 3D, Maxwell 2D. If no ProductName is supplied, the setting is applied to both 2D and 3D.

Example: oAnsoftApp.SetMaximumRamMBLimit 2000, "Maxwell 2D"

SetNumberOfProcessors

Use: Sets the Number of Processors value.

Syntax: SetNumberOfProcessors <NumProcessors>, <ProductName>

Return Value: None

Parameters: <NumProcessors>

Type: <int>

<ProductName>

Type: <String>

Values may be: Maxwell 3D, Maxwell 2D. If no ProductName is supplied, the setting is applied to both 2D and 3D.

Example: oAnsoftApp.SetNumberOfProcessors 2, "Maxwell 3D"

GetDesiredRamMBLimit

Use: Gets the Desired RAM Limit (MB) value.

Syntax: GetDesiredRamMBLimit(<ProductName>)

Return Value: Returns the Desired RAM Limit in megabytes (MB). Type: <int>

Parameters: <ProductName>

Type: <String>

Values may be: Maxwell 3D, Maxwell 2D. Note This function is not supported for RMxprt.

Note This function is not supported for RMxprt.

(55)

Example: desired_ram = oAnsoftApp.GetDesiredRamMBLimit("Maxwell 2D")

GetMaximumRamMBLimit

Use: Gets the Maximum RAM Limit (MB) value.

Syntax: GetMaximumRamMBLimit(<ProductName>)

Return Value: Returns the Maximum RAM Limit in megabytes (MB). Type: <int>

Parameters: <ProductName> Type: <String>

Values may be: Maxwell 3D, Maxwell 2D.

Example: max_ram = oAnsoftApp.GetMaximumRamMBLimit("Maxwell 3D")

GetNumberOfProcessors

Use: Gets the Number of Processors value.

Syntax: GetNumberOfProcessors(<ProductName>)

Return Value: Returns the Number of Processors. Type: <int>

Parameters: <ProductName>

Type: <String>

Values may be: Maxwell 3D, Maxwell 2D.

Example: numprocessors = oAnsoftApp.GetNumberOfProcessors("Maxwell 2D")

Note This function is not supported for RMxprt.

(56)
(57)

4

Desktop Object Script

Commands

Desktop commands should be executed by the oDesktop object. Some com-mands permit you to query objects when you do not know the names. Set oAnsoftApp =

CreateObject ("AnsoftMaxwell.MaxwellScriptInterface") Set oDesktop = oAnsoftApp.GetAppDesktop()

(58)

General Desktop Script Commands

Following are general script commands recognized by the oDesktop object:

CloseAllWindows

CloseProject

CloseProjectNoForce

EnableAutoSave

GetActiveProject

GetLibraryDirectory

GetProjectDirectory

GetProjectList

GetTempDirectory

GetVersion

NewProject

OpenMultipleProjects

OpenProject

PauseScript

Print

QuitApplication

RestoreWindow

RunProgram

RunScript

SetActiveProject

SetActiveProjectByPath

SetLibraryDirectory

SetProjectDirectory

SetTempDirectory

Sleep

CloseAllWindows

Use: Closes all MDI child windows on the desktop.

Command: From the main menu, click Window>Close All.

Syntax: CloseAllWindows()

Return Value: None

Parameters: None

(59)

CloseProject

Use: Closes a specified project. Changes to the project are not saved. Save the project using the Project command Save or SaveAs.

Command: File>Close

Syntax: CloseProject <ProjectName>

Return Value: None

Parameters: <ProjectName> Type: <string>

Example: oDesktop.CloseProject "Project1"

CloseProjectNoForce

Use: Closes a specified project unless there are simulations ongoing. Changes to the project will not be saved. Save the project using the Project command Save or SaveAs before closing to save changes.

Command: File>Close

Syntax: CloseProjectNoForce <ProjectName>

Return Value: None

Parameters: <ProjectName> Type: <string>

Example: oDesktop.CloseProjectNoForce "Project1"

EnableAutoSave

Use: Enables or disables the autosave feature.

Command: None

Syntax: EnableAutoSave(bool bEnable)

Return Value: None

Parameters: None

Example: oDesktop.EnableAutoSave(true), enables autosave

ExportOptionsFiles

Use: Copies the options config files to the DestinationDirectory.

Command: Tools>Options>Export Options Files ...

Syntax: ExportOptionsFiles <DestinationDirectory>

Return Value: None.

(60)

Type: String

The path to the destination directory.

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

GetActiveProject

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

Command: None

Syntax: GetActiveProject

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

Parameters: None

Example: Set oProject = oDesktop.GetActiveProject ()

GetLibraryDirectory

Use: Gets the library directory path.

Syntax: GetLibraryDirectory

Return Value: Returns a directory path. Type: <string>

Parameters: None

Example: libdir = oDesktop.GetLibraryDirectory

GetProjectDirectory

Use: Gets the project directory path.

Syntax: GetProjectDirectory

Return Value: Returns a directory path. Type: <string>

Parameters: None

Example: projdir = oDesktop.GetProjectDirectory

GetProjectList

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

Command: None

Syntax: GetProjectList

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

Parameters: None

(61)

GetTempDirectory

Use: Gets the temp directory path.

Syntax: GetTempDirectory

Return Value: Returns a directory path. Type: <string>

Parameters: None

Example: tempdir = oDesktop.GetTempDirectory

GetVersion

Use: Returns a string representing the version.

Command: None

Syntax: GetVersion()

Return Value: string

Parameters: None

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

NewProject

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

Command: File>New

Syntax: NewProject

Return Value: The project that is added.

Parameters: None

Example: Set oProject = oDesktop.NewProject

OpenMultipleProjects

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

Command: File>Multiple Open

Syntax: OpenMultipleProjects <Directory> <FileType>

Return Value: None

Parameters: <Directory>

Type: <string> <FileType>

Type: <string>

(62)

OpenProject

Use: Opens a specified project.

Command: File>Open

Syntax: OpenProject <FileName>

Return Value: The opened project.

Parameters: <FileName>: Full path and name of the project to open. Type: <string>

Example: oDesktop.OpenProject "D:/Projects/Project1.mxwl"

PauseScript

Use: Pauses the script’s execution and displays a message in a pop-up dialog box to the user. The script execution does not resume until the user clicks Tools>Resume Script.

Command: Tools>Pause Script

Syntax: PauseScript <Message>

Return Value: None

Parameters: <Message>

Type: <string>

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

Print

Use: Prints the contents of the active view window.

Command: File>Print

Syntax: Print

Return Value: None

Parameters: None

Example: oDesktop.Print

QuitApplication

Use: Exits the desktop.

Command: File>Exit

Syntax: QuitApplication

Return Value: None

(63)

Example: oDesktop.QuitApplication

RestoreWindow

Use: Restores a minimized Maxwell window.

Command: None

Syntax: RestoreWindow

Return Value: None

Parameters: None

Example: oDesktop.RestoreWindow

RunProgram

Use: Runs an external program.

Command: None

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

Return Value: None

Parameters: <ProgName>

Type: <string>

Name of the program to run.

<ProgPath>

Type: <string>

Location of the program. To use the system path, pass in an empty string.

<WorkPath>

Type: <string>

Working directory in which program will start. <ArgArray>

Type: Array of strings

Arguments to pass to the program. If there are no argu-ments, pass in None.

Example: oDesktop.RunProgram "winword.exe", _

"C:\Program Files\Microsoft Office\Office10",_ "", None

RunScript

References

Related documents

Resultantly, this has given NBP an edge over peer banks, who have been in the Home Remittance Business since decades.Keeping its reputation of forming alliances with world's

DOD………..……….……….….Department of Defense DOT………..……….…..Department of Transportation DPH………Department of Public Health DSLR (CDC)……….…………..Division

- ease of migration as it can be phased and allows Cisco telephones to be retained The case below is that of a large Belgian administration: the Administration of the Province of

7 a shows that at large protein separations the lipids reorganize around each protein in a way similar to the case of one isolated protein of the same size and mismatch (Fig. 4

The parent company uses the cost or equity method to account for the investment during the year, but, at the end of the reporting period, must prepare consolidated financial

Using the map, the current position by a precise localization, the path from its current position to the desired destination and a goal in the path, IARA’s MPMP is able

Fifth, the whole reflection of economics into legal reasoning of the CJEU should be assessed in the context of its overall style of reasoning and methods of

American Association of Educational Research, Member National Association for Multicultural Education, Member National Association of Research in Science Teaching, Member