Notice: Due to a technical issue new user registrations on Ansys Innovation Space sites are currently disabled. We apologize for the inconvenience and are working to restore functionality as soon as possible.
Yang Zhao
Ansys Employee

以下3种最简单的方法:

1、 Copy以下2句到录制的脚本前面,便可以直接在Python中运行

2、 # Mthod 1

3、 # This method imports ScriptEnv to run aedt and script

4、 import sys

5、 sys.path.append(r'C:\Program Files\AnsysEM\v222\Win64\PythonFiles\DesktopPlugin')

 

2、使用以下AEDT初始化方法,删除录制脚本中前面有效的4

6、 #Method 2

7、 #run aedt

8、 from win32com import client

9、  

10、                   oApp = client.Dispatch("Ansoft.ElectronicsDesktop.2022.2")

oDesktop = oApp.GetAppDesktop()

oDesktop.RestoreWindow()

oProject = oDesktop.NewProject()

 

3、运行特定脚本这个需求是以下这两句来实现

##

YourScript = r'C:\Program Files\AnsysEM\v222\Win64\syslib\Toolkits\HFSS\Wavelength Calculator.py'

oDesktop.RunScript(YourScript)