2022年7月29日 星期五

輸出Report所有維度的獨立變數

 

from win32com import client

oApp = client.Dispatch("Ansoft.ElectronicsDesktop.2022.2")
oDesktop = oApp.GetAppDesktop()
oDesktop.RestoreWindow()
oProject = oDesktop.GetActiveProject()
oDesign = oProject.GetActiveDesign()

oReportSetup = oDesign.GetModule("ReportSetup")
oSolutions = oDesign.GetModule("Solutions")

report_solution = {}
solutions = []
display = {}
context = {}
category = {}
quantities = {}
variations = {}
solve_range = {}

for report_type in oReportSetup.GetAvailableReportTypes():
display[report_type] = oReportSetup.GetAvailableDisplayTypes(report_type)
report_solution[report_type] = oReportSetup.GetAvailableSolutions(report_type)
for s in report_solution[report_type]:
if s not in solutions:
solutions.append(s)

for _report_type, _display in display.items():
for d in _display:
for _solution in report_solution[_report_type]:
ctxt = oReportSetup.GetSolutionContexts(_report_type, d, _solution)
context[(_report_type, d, _solution)] = ctxt
for _ctxt in ctxt:
cate = oReportSetup.GetAllCategories(_report_type, d, _solution, _ctxt)
category[(_report_type, d, _solution, _ctxt)] = cate
for _cate in cate:
q = oReportSetup.GetAllQuantities(_report_type, d, _solution, _ctxt, _cate)
quantities[(_report_type, d, _solution, _ctxt, _cate)] = q

for sol in solutions:
solve_range[sol] = oSolutions.GetSolveRangeInfo(sol)
variations[sol] = oSolutions.GetAvailableVariations(sol)



2022年7月26日 星期二

Q3D輸出Transion Region頻率範圍

 選擇金屬厚度邊,執行腳本即可輸出到訊息視窗。

import math
import ScriptEnv

oDesktop.ClearMessages("", "", 2)
oProject = oDesktop.GetActiveProject()
oDesign = oProject.GetActiveDesign()
oEditor = oDesign.SetActiveEditor("3D Modeler")

try:
selected = oEditor.GetSelections()
edge_id = selected[0].replace('Edge', '')

obj = oEditor.GetObjectNameByEdgeID(edge_id)
material = oEditor.GetPropertyValue('Geometry3DAttributeTab', obj, 'Material').replace('"', '')
AddWarningMessage('Material: {}'.format(material))

unit_map = {'meter': 1, 'mm': 1e-3, 'um': 1e-6, 'nm': 1e-9, 'mil': 2.54e-5, 'in': 2.54e-2}
freq_map = [(1, 'Hz'), (1e3, 'KHz'), (1e6, 'MHz'), (1e9, 'GHz'), (1e12, 'THz')]

unit = oEditor.GetModelUnits()
thickness = float(oEditor.GetEdgeLength(edge_id)) * unit_map[unit]
AddWarningMessage('Thicknetss: {}(m)'.format(thickness))

oDefinitionManager = oProject.GetDefinitionManager()
conductivity = float(
oDefinitionManager.GetPropertyValue('MaterialPropTab', 'Materials:' + material, 'Bulk Conductivity'))
permeability = float(
oDefinitionManager.GetPropertyValue('MaterialPropTab', 'Materials:' + material, 'Relative Permeability'))
AddWarningMessage('Conductivity: {}'.format(conductivity))
AddWarningMessage('Relative Permeability: {}'.format(permeability))

u0 = 4 * math.pi * 1e-7

ac_high = 9 / (math.pi * conductivity * permeability * u0 * thickness ** 2)

for n, (scale, unit) in enumerate(freq_map):
if ac_high / scale < 1:
scale, unit = freq_map[n - 1]
_ac_low = str(round(ac_high / 9 / scale, 3)) + unit
_ac_high = str(round(ac_high / scale, 3)) + unit
break

AddWarningMessage("Transition Region: {} - {}".format(_ac_low, _ac_high))

except:
AddErrorMessage("Please Select Metal Edge!")







2022年7月4日 星期一

SIwave API設定Pin Group Port

 

from win32com import client

oApp = client.Dispatch("SIwave.Application.2022.1")
oApp.RestoreWindow()
oDoc = oApp.GetActiveProject()

# ScrPlaceCircuitElement(string givenElementName,
# string givenPartName,
# int circuitElementType,
# int posTermConnectionType,
# string posTermParam1,
# string posTermParam2,
# string posTermParam3,
# int refTermConnectionType,
# string refTermParam1,
# string refTermParam2,
# string refTermParam3,
# double capVal,
# double indVal,
# double resVal,
# double refZRe,
# double mag,
# double phase) -> short

oDoc.ScrPlaceCircuitElement('ABC',
'DEF',
3,
1,
'FCHIP',
'FCHIP',
'FCHIP_VDD_15_Group',
1,
'FCHIP',
'FCHIP',
'FCHIP_VSS_Group',
0,
0,
0,
50,
0,
0)