官方淘宝店 易迪拓培训 旧站入口
首页 > 微波射频 > 射频工程师交流 > 求懂VB脚本的大师,有一部分VB脚本写成完整的VB语言。谢谢!

求懂VB脚本的大师,有一部分VB脚本写成完整的VB语言。谢谢!

05-08
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("AnsoftHfss.HfssScriptInterface")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.SetActiveProject("Tee1")
oProject.SaveAs "D:\Ansoft\Tee2.hfss", true
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
oDesign.SetSolutionType "DrivenModal"
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.SetModelUnits Array("NAME:Units Parameter", "Units:=", "in", "Rescale:=",  _
  false)
oEditor.CreateBox Array("NAME:BoxParameters", "CoordinateSystemID:=", -1, "XPosition:=",  _
  "0in", "YPosition:=", "0in", "ZPosition:=", "0in", "XSize:=", "2in", "YSize:=",  _
  "0.9in", "ZSize:=", "0.4in"), Array("NAME:Attributes", "Name:=", "Box1", "Flags:=",  _
  "", "Color:=", "(132 132 193)", "Transparency:=", 0, "PartCoordinateSystem:=",  _
  "Global", "MaterialName:=", "vacuum", "SolveInside:=", true)
oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DCmdTab", Array("NAME:PropServers",  _
  "Box1:CreateBox:1"), Array("NAME:ChangedProps", Array("NAME:Position", "X:=", "0in", "Y:=",  _
  "-0.45in", "Z:=", "0in"))))
oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DAttributeTab", Array("NAME:PropServers",  _
  "Box1"), Array("NAME:ChangedProps", Array("NAME:Name", "Value:=", "Tee"))))
oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DAttributeTab", Array("NAME:PropServers",  _
  "Tee"), Array("NAME:ChangedProps", Array("NAME:Transparent", "Value:=", 0.4))))
Set oModule = oDesign.GetModule("BoundarySetup")
oModule.AssignWavePort Array("NAME:Port1", "NumModes:=", 1, "PolarizeEField:=",  _
  false, "DoDeembed:=", false, Array("NAME:Modes", Array("NAME:Mode1", "ModeNum:=", 1, "UseIntLine:=",  _
  true, Array("NAME:IntLine", "Start:=", Array("2in", "0in", "0in"), "End:=", Array( _
  "2in", "0in", "0.4in")), "CharImp:=", "Zpi")), "Faces:=", Array(12))
oEditor.DuplicateAroundAxis Array("NAME:Selections", "Selections:=", "Tee"), Array("NAME:DuplicateAroundAxisParameters", "WhichAxis:=",  _
  "Z", "AngleStr:=", "90deg", "NumClones:=", 2), Array("NAME:Options", "DuplicateBoundaries:=",  _
  true)
oEditor.DuplicateAroundAxis Array("NAME:Selections", "Selections:=", "Tee"), Array("NAME:DuplicateAroundAxisParameters", "WhichAxis:=",  _
  "Z", "AngleStr:=", "-90deg", "NumClones:=", 2), Array("NAME:Options", "DuplicateBoundaries:=",  _
  true)
oEditor.Unite Array("NAME:Selections", "Selections:=", "Tee,Tee_1,Tee_2"), Array("NAME:UniteParameters", "CoordinateSystemID:=",  _
  -1, "KeepOriginals:=", false)
oEditor.CreateBox Array("NAME:BoxParameters", "CoordinateSystemID:=", -1, "XPosition:=",  _
  "0in", "YPosition:=", "0in", "ZPosition:=", "0in", "XSize:=", "0.2in", "YSize:=",  _
  "0.2in", "ZSize:=", "0.2in"), Array("NAME:Attributes", "Name:=", "Box1", "Flags:=",  _
  "", "Color:=", "(132 132 193)", "Transparency:=", 0, "PartCoordinateSystem:=",  _
  "Global", "MaterialName:=", "vacuum", "SolveInside:=", true)
oDesign.ChangeProperty Array("NAME:AllTabs", Array("NAME:LocalVariableTab", Array("NAME:PropServers",  _
  "LocalVariables"), Array("NAME:NewProps", Array("NAME:offset", "PropType:=",  _
  "VariableProp", "UserDef:=", true, "Value:=", "0in"))))
oEditor.ChangeProperty Array("NAME:AllTabs", Array("NAME:Geometry3DCmdTab", Array("NAME:PropServers",  _
  "Box1:CreateBox:1"), Array("NAME:ChangedProps", Array("NAME:Position", "X:=", "-0.45in", "Y:=",  _
  "offset-0.05in", "Z:=", "0in"), Array("NAME:XSize", "Value:=", "0.45in"), Array("NAME:YSize", "Value:=",  _
  "0.1in"), Array("NAME:ZSize", "Value:=", "0.4in"))), Array("NAME:Geometry3DAttributeTab", Array("NAME:PropServers",  _
  "Box1"), Array("NAME:ChangedProps", Array("NAME:Name", "Value:=", "Septum"))))
oEditor.Subtract Array("NAME:Selections", "Blank Parts:=", "Tee", "Tool Parts:=",  _
  "Septum"), Array("NAME:SubtractParameters", "CoordinateSystemID:=", -1, "KeepOriginals:=",  _
  false)
Set oModule = oDesign.GetModule("AnalysisSetup")
oModule.InsertSetup "HfssDriven", Array("NAME:Setup1", "Frequency:=", "10GHz", "PortsOnly:=",  _
  false, "MaxDeltaS:=", 0.02, "UseMatrixConv:=", false, "MaximumPasses:=", 3, "MinimumPasses:=",  _
  1, "MinimumConvergedPasses:=", 1, "PercentRefinement:=", 20, "ReducedSolutionBasis:=",  _
  false, "DoLambdaRefine:=", true, "DoMaterialLambda:=", true, "Target:=",  _
  0.3333, "UseConvOutputVariable:=", false, "IsEnabled:=", true, "ExternalMesh:=",  _
  false, "UseMaxTetIncrease:=", false, "MaxTetIncrease:=", 100000, "PortAccuracy:=",  _
  2, "UseABCOnPort:=", false, "SetPortMinMaxTri:=", false)
oModule.InsertDrivenSweep "Setup1", Array("NAME:Sweep1", "IsEnabled:=", true, "Type:=",  _
  "Interpolating", "InterpTolerance:=", 0.5, "InterpMaxSolns:=", 50, "InterpUseS:=",  _
  true, "InterpUseT:=", false, "InterpUsePortImped:=", false, "InterpUsePropConst:=",  _
  false, "UseFullBasis:=", true, "SetupType:=", "LinearStep", "StartFreq:=",  _
  "8GHz", "StopFreq:=", "10GHz", "StepSize:=", "0.02GHz", "SaveFields:=", false, "ExtrapToDC:=",  _
  false)
oProject.Save
oDesign.AnalyzeAll
Set oModule = oDesign.GetModule("FieldsReporter")
oModule.CreateFieldPlot Array("NAME:Mag_E1", "SolutionName:=",  _
  "Setup1 : LastAdaptive", "QuantityName:=", "Mag_E", "PlotFolder:=", "E Field", "UserSpecifyName:=",  _
  0, "UserSpecifyFolder:=", 0, "IntrinsicVar:=", "Freq=" & Chr(39) & "10GHz" & Chr(39) & " Phase=" & Chr(39) & "0deg" & Chr(39) & "", "PlotGeomInfo:=", Array( _
  1, "Surface", "FacesList", 1, "7"), "FilterBoxes:=", Array(0), Array("NAME:PlotOnSurfaceSettings", "Filled:=",  _
  false, "IsoValType:=", "Tone", "SmoothShade:=", true, "AddGrid:=", false, "MapTransparency:=",  _
  true, "Transparency:=", 0, Array("NAME:Arrow3DSpacingSettings", "ArrowUniform:=",  _
  true, "ArrowSpacing:=", 0, "MinArrowSpacing:=", 0, "MaxArrowSpacing:=", 0), "GridColor:=", Array( _
  255, 255, 255)))
oProject.Save

没搞懂为什么非要写成完整的VB语言  你直接RUN这个文件不可以么?

小编留言:

因为还要转换成MATLAB语言啊

为什么双击不能直接运行啊,总是加载失败

建议你去问问蒋仁培。

Top