2020年12月18日 星期五

在3D Layout當中如何取得元件的座標

元件的尺寸大小不一,嚴格來說,更有用的是取得元件所有的pin及pin所在的位置,下面的程式碼可以取得上層電阻的pin及其座標以及pin連接的net name

import ScriptEnv
ScriptEnv.Initialize("Ansoft.ElectronicsDesktop")
oDesktop.RestoreWindow()
oProject = oDesktop.GetActiveProject()
oDesign = oProject.GetActiveDesign()
oEditor = oDesign.GetActiveEditor()
R_top = []
R_bot = []
for i in oEditor.FindObjects('Type', 'component'):
part_type = oEditor.GetPropertyValue('BaseElementTab', i, 'Part Type')
placement_layer = oEditor.GetPropertyValue('BaseElementTab', i, 'PlacementLayer')
if part_type == 'Resistor':
if placement_layer == 'TOP':
R_top.append(i)

for i in R_top:
for pin in oEditor.GetComponentPins(i):
AddWarningMessage(str(oEditor.GetComponentPinInfo(i, pin)))
(圖一) 輸出Top R對應pin的座標及net name


沒有留言:

張貼留言