(圖一) 部分紅色圓形與藍色方塊重疊 |
藍色方塊在Top層,紅色圓形在Bottom層。假設想要找出所有與藍色方塊重疊的紅色圓形並加以刪除,可參考底下程式碼:
import ScriptEnv
ScriptEnv.Initialize("Ansoft.ElectronicsDesktop")
oDesktop.RestoreWindow()
oProject = oDesktop.GetActiveProject()
oDesign = oProject.GetActiveDesign()
oEditor = oDesign.GetActiveEditor()
x1 = set(oEditor.FindObjects('Type', 'rect'))
y1 = set(oEditor.FindObjects('Layer', 'Top'))
z1 = x1.intersection(y1)
x2 = set(oEditor.FindObjects('Type', 'circle'))
y2 = set(oEditor.FindObjects('Layer', 'Bottom'))
z2 = x2.intersection(y2)
todelete = []
for i in z1:
poly_i = oEditor.GetPolygon(i)
for j in z2:
poly_j = oEditor.GetPolygon(j)
if poly_i.GetIntersectionType(poly_j):
todelete.append(j)
oEditor.Delete(todelete)
沒有留言:
張貼留言