forked from linmingchih/HowtoSim_Script
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobustUniteAll.py
More file actions
36 lines (30 loc) · 1017 Bytes
/
RobustUniteAll.py
File metadata and controls
36 lines (30 loc) · 1017 Bytes
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
'''
This script will sort size of models and then do Unite operation. It is more robust compared to default Unite Operation in HFSS2019U2
'''
import ScriptEnv
ScriptEnv.Initialize("Ansoft.ElectronicsDesktop")
oDesktop.RestoreWindow()
oProject = oDesktop.GetActiveProject()
oDesign = oProject.GetActiveDesign()
oEditor = oDesign.SetActiveEditor("3D Modeler")
def getsortedObjects():
totalobjects = oEditor.GetNumObjects()
data=[]
for i in range(totalobjects):
objectname = oEditor.GetObjectName(i)
faces=oEditor.GetFaceIDs(objectname)
area=0
for j in faces:
area+=float(oEditor.GetFaceArea(j))
data.append((objectname, area))
return sorted(data, key=lambda tup: tup[1])[::-1]
totalobjects =','.join([i for i,j in getsortedObjects()])
oEditor.Unite(
[
"NAME:Selections",
"Selections:=" , totalobjects
],
[
"NAME:UniteParameters",
"KeepOriginals:=" , False
])