import ScriptEnv
ScriptEnv.Initialize("Ansoft.ElectronicsDesktop")
oDesktop.RestoreWindow()
oProject = oDesktop.GetActiveProject()
oDesign = oProject.GetActiveDesign()
oEditor = oDesign.GetActiveEditor()
def create_rect(x, y, w, l, layer):
x0, y0 = x - w / 2, y - l / 2
x1, y1 = x + w / 2, y + l / 2
objname = oEditor.CreateRectangle(
[
"NAME:Contents",
"rectGeometry:=",
["Name:=", "", "LayerName:=", layer, "lw:=", "0", "Ax:=", str(x0), "Ay:=", str(y0), "Bx:=", str(x1), "By:=",
str(y1), "cr:=", "0deg", "ang:=", "0deg"]
])
return objname
def build_array(obj_name, m, n, dx, dy):
obj_type = oEditor.GetPropertyValue('BaseElementTab', obj_name, 'Type')
old = oEditor.FindObjects('Type', obj_type)
oEditor.Duplicate(
[
"NAME:options",
"count:=" , m
],
[
"NAME:elements",
obj_name
], [dx, 0])
new = oEditor.FindObjects('Type', obj_type)
x = [obj_name] + list(set(new) -set(old))
oEditor.Duplicate(
[
"NAME:options",
"count:=" , n
],
["NAME:elements"] + x,
[0, dy])
new = oEditor.FindObjects('Type', obj_type)
return [obj_name] + list(set(new) -set(old))
def copytolayer(obj_list, layer_name):
oEditor.DuplicateAcrossLyrs(
["NAME:elements"] + obj_list,
[
"NAME:layers",
layer_name,
])
x = create_rect(0, 0, 1e-3, 1e-3, layer='top')
y = build_array(x, 5, 5, 2e-3, 2e-3)
copytolayer(y, 'bottom')
(圖一)多層陣列 |
沒有留言:
張貼留言