在PyCharm開啟專案時,Existing Interpreter需指向AEDT的IronPython路徑,如圖一:
(圖一)開啟新檔時設定IronPython路徑
接著程式碼需先取得oApp,以下為範例程式碼,抓取SIwave版本及專案名稱,並輸出"Hello World"到訊息視窗:
 |
(圖二)取得並輸出SIwave訊息
|
from System import Activator, Type
SIwaveVerision = "SIwave.Application.2020.2"
oApp = Activator.CreateInstance(Type.GetTypeFromProgID(SIwaveVerision))
print(oApp.GetVersion())
oDoc = oApp.GetActiveProject()
print(oDoc.GetName())
oDoc.ScrLogMessage("Hello World")
 |
(圖三)SIwave輸出訊息
|
沒有留言:
張貼留言