淘宝官方店     推荐课程     在线工具     联系方式     关于我们  
 
 

微波射频仿真设计   Ansoft Designer 中文培训教程   |   HFSS视频培训教程套装

 

Agilent ADS 视频培训教程   |   CST微波工作室视频教程   |   AWR Microwave Office

          首页 >> Ansoft Designer >> Ansoft Designer在线帮助文档


Ansoft Designer / Ansys Designer 在线帮助文档:


Script Guide >
   Creating and Interacting with Scripts >
       A Sample Designer Script           


A Sample Designer Script

Following is an example of a Designer script. It includes comment lines, which are preceded by either an apostrophe ( ) or the word REM, that offer explanations for each preceding line or lines. VBScript keywords appear in bold font.

 

' ----------------------------------------------

' Script Recorded by Designer/Nexxim

' 8:10 AM Dec 05, 2003

' ----------------------------------------------

Dim oAnsoftApp

Dim oDesktop

Dim oProject

Dim oDesign

Dim oEditor

Dim oModule

 

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

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

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

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

REM scripts in Designer, variants that will be used as objects always begin with

REM the letter o.

 

Set oAnsoftApp = CreateObject("AnsoftDesigner.DesignerScript")

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

‘but returns an object that is then assigned to the variable oDesktop.

oDesktop.RestoreWindow

oDesktop.NewProject

‘In VBScript a Sub procedure is a procedure that is called by name, can optionally

‘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 "Planar EM", "PlanarEM1", _

"C:\Program Files\Ansoft\Designer\syslib\PCB - SingleSided.asty", ""

 

‘In a Sub or Function procedure call, you can group the input parameters inside

‘parentheses or without parentheses. Here the four strings are input parameters

‘of the Sub procedure InsertDesign of the object oProject.

 

Set oDesign = oProject.SetActiveDesign("PlanarEM1")

Set oEditor = oDesign.SetActiveEditor("Layout")

oEditor.CreateRectangle Array("NAME:Contents", "rectGeometry:=", Array("Name:=", _

"rect_1", "LayerName:=", "Top", "lw:=", "0mm", "Ax:=", "-22mm", "Ay:=", "20mm", "Bx:=", _

"29mm", "By:=", "-4mm", "ang:=", "0deg"))

 

‘oEditor.CreateRectangle is a Sub procedure that takes an array variable

‘as an argument. This array variable contains two string variables and an array

‘containing the geometric parameters of the rectangle. You can use variables to

‘modify the geometric parameters of the rectangle.

 

‘In VBScript Array is a function that returns a variant containing an array. The

‘underscore character (_) here indicates that the statement continues on 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 in 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.”)

 

oProject.SaveAs "C:\Program Files\Ansoft\Designer\Examples\test.adsn", true

‘The use of VBScript is a powerful way to control Designer.




HFSS视频教学培训教程 ADS2011视频培训教程 CST微波工作室教程 Ansoft Designer 教程

                HFSS视频教程                                      ADS视频教程                               CST视频教程                           Ansoft Designer 中文教程


 

      Copyright © 2006 - 2013   微波EDA网, All Rights Reserved    业务联系:mweda@163.com