HFSS脚本建模入门教程

摘要:

HFSS作为高频结构设计的首选工具和行业标准,能从几何结构、材料特性到分析、控制及所有后处理进行全参量化设计。可对于仿真设计相关的工程师来说,利用HFSS软件进行3D可视化建模容易,但是后期的模型维护和传阅却难以为继。

本文使用的电磁仿真软件为ANSYS Electronics Desktop Version 2017.2.0

           :                   脚       本       录       制           01  :  H F S S  脚   本   录   制     {\color{red}{01:HFSS脚本录制}}{\color{red}{01:HFSS脚本录制}}

下图所示环形器的HFSS建模不难,但是工程师们建模习惯不同,最后各自的仿真模型在进行传阅时,其可读性就难免参差不齐。有的喜欢预估好初始值后进行纯数字建模,有的喜欢variables和数字混用,即使是有些人采用全参量化建模,由于大家命名习惯大相径庭,最终拿到别人的仿真文件进行参数微调时,也会对模型的建立逻辑和某些结构对应的变量有所困惑。


特别是在别人已经建立好的模型上进行调试优化时,面对“一砖一瓦”构成的复杂结构时,想通过Delete Last Operation操作来窥视开发者的模型确实比较麻烦。


这里提供一种最简单的方法:HFSS自带的Record Script To File功能进行vbs脚本的录制。可能大家听说过这个功能,但是在实施过程中遇到一些困难。比如明明录制好了,再次Run Script进行重构模型为什么报错呢?


如下图所示,随便建立一个文件进行模型的绘制,对其进行vbs脚本录制:


Run Script后,HFSS软件提示报错,很多人第一次使用这个可能都会遇到这种问题。


其实只需要在录制脚本前,软件处于空文件状态(Project Manager下无Project和Design),这样从零开始录制的脚本执行起来就不会报错。


经过上述操作后录制的vbs代码如下(可直接复制到txt文件里,将文件类型后缀改为.vbs,在HFSS软件中的Tool->Run Script载入执行即可):


' ----------------------------------------------
' Script Recorded by ANSYS Electronics Desktop Version 2017.2.0
' ----------------------------------------------
Dim oAnsoftApp
Dim oDesktop
Dim oProject
Dim oDesign
Dim oEditor
Dim oModule
Set oAnsoftApp = CreateObject("Ansoft.ElectronicsDesktop")
Set oDesktop = oAnsoftApp.GetAppDesktop()
oDesktop.RestoreWindow
Set oProject = oDesktop.NewProject
oProject.InsertDesign "HFSS", "HFSSDesign1", "DrivenModal", ""
Set oDesign = oProject.SetActiveDesign("HFSSDesign1")
Set oEditor = oDesign.SetActiveEditor("3D Modeler")
oEditor.CreateRegularPolyhedron Array("NAME:PolyhedronParameters", "XCenter:=",  _
  "-0.4mm", "YCenter:=", "-0.4mm", "ZCenter:=", "0mm", "XStart:=", "0.2mm", "YStart:=",  _
  "0.2mm", "ZStart:=", "0mm", "Height:=", "1.2mm", "NumSides:=", "12", "WhichAxis:=",  _
  "Z"), Array("NAME:Attributes", "Name:=", "RegularPolyhedron1", "Flags:=", "", "Color:=",  _
  "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=", "Global", "UDMId:=",  _
  "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SurfaceMaterialValue:=",  _
  "" & Chr(34) & "" & Chr(34) & "", "SolveInside:=", true, "IsMaterialEditable:=",  _
  true, "UseMaterialAppearance:=", false)
oEditor.CreateCylinder Array("NAME:CylinderParameters", "XCenter:=", "0.8mm", "YCenter:=",  _
  "1.8mm", "ZCenter:=", "0mm", "Radius:=", "0.2mm", "Height:=", "1mm", "WhichAxis:=",  _
  "Z", "NumSides:=", "0"), Array("NAME:Attributes", "Name:=", "Cylinder1", "Flags:=",  _
  "", "Color:=", "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=",  _
  "Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SurfaceMaterialValue:=",  _
  "" & Chr(34) & "" & Chr(34) & "", "SolveInside:=", true, "IsMaterialEditable:=",  _
  true, "UseMaterialAppearance:=", false)
oEditor.CreateBox Array("NAME:BoxParameters", "XPosition:=", "0.6mm", "YPosition:=",  _
  "-2.6mm", "ZPosition:=", "0mm", "XSize:=", "0.8mm", "YSize:=", "0.4mm", "ZSize:=",  _
  "0.8mm"), Array("NAME:Attributes", "Name:=", "Box1", "Flags:=", "", "Color:=",  _
  "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=", "Global", "UDMId:=",  _
  "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SurfaceMaterialValue:=",  _
  "" & Chr(34) & "" & Chr(34) & "", "SolveInside:=", true, "IsMaterialEditable:=",  _
  true, "UseMaterialAppearance:=", false)
oEditor.CreateCone Array("NAME:ConeParameters", "XCenter:=", "2.2mm", "YCenter:=",  _
  "-0.2mm", "ZCenter:=", "0mm", "WhichAxis:=", "Z", "Height:=", "0.6mm", "BottomRadius:=",  _
  "0.447213595499958mm", "TopRadius:=", "0.4mm"), Array("NAME:Attributes", "Name:=",  _
  "Cone1", "Flags:=", "", "Color:=", "(143 175 143)", "Transparency:=", 0, "PartCoordinateSystem:=",  _
  "Global", "UDMId:=", "", "MaterialValue:=", "" & Chr(34) & "vacuum" & Chr(34) & "", "SurfaceMaterialValue:=",  _
  "" & Chr(34) & "" & Chr(34) & "", "SolveInside:=", true, "IsMaterialEditable:=",  _
  true, "UseMaterialAppearance:=", false)
  


免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删

QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空