forked from linmingchih/HowtoSim_Script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetInsertionLoss.py
47 lines (40 loc) · 1.26 KB
/
GetInsertionLoss.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 2 10:43:23 2019
@author: mlin
For HFSS and HFSS 3D Layout
"""
import re, clr
clr.AddReference('System.Windows.Forms')
from System.Windows.Forms import Clipboard
import ScriptEnv
ScriptEnv.Initialize("Ansoft.ElectronicsDesktop")
oDesktop.RestoreWindow()
oProject = oDesktop.GetActiveProject()
oDesign = oProject.GetActiveDesign()
oDesktop.ClearMessages("", "", 2)
try:
oModule = oDesign.GetModule("BoundarySetup")
ports=oModule.GetExcitations()[::2]
except:
oModule = oDesign.GetModule("Excitations")
ports=oModule.GetAllPortsList()
AddWarningMessage(str(ports))
x=[(i,j) for i in ports for j in ports]
def GetInsertionLoss():
match=[]
for i, j in x:
try:
if i[-8:]==j[-8:] and i.startswith('BGA') and j.startswith('FCHIP'):
match.append((i,j))
except:
pass
if not match:
AddWarningMessage('No match, Please check condition!')
return None
else:
AddWarningMessage('{} matches!'.format(len(match)))
[AddWarningMessage(str(i)) for i in match]
result=';'.join(['dB(S({},{}))'.format(i,j) for i,j in match])
Clipboard.SetText(result)
GetInsertionLoss()