-
Notifications
You must be signed in to change notification settings - Fork 12
/
select_obj.py
67 lines (57 loc) · 1.86 KB
/
select_obj.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
__all__ = ['SelectObj']
from typing import Union
class SelectObj:
def __init__(
self,
etabs=None,
):
self.etabs = etabs
self.SapModel = etabs.SapModel
def get_selected_obj_type(self,
n : int,
) -> list:
'''
n:
1 = points
2 = frames
5 = area
'''
try:
selected = self.etabs.SapModel.SelectObj.GetSelected()
except IndexError:
return []
types = selected[1]
all_names = selected[2]
names = []
for type_, name in zip(types, all_names):
if type_ == n:
names.append(name)
return names
def get_selected_objects(self):
'''
1 = points
2 = frames
5 = area
'''
try:
selected = self.etabs.SapModel.SelectObj.GetSelected()
except IndexError:
return {}
types = selected[1]
all_names = selected[2]
selected_objects = {}
for t, name in zip(types, all_names):
objects = selected_objects.get(t, None)
if objects is None:
selected_objects[t] = []
selected_objects[t].append(name)
return selected_objects
def select_concrete_columns(self):
_, columns = self.etabs.frame_obj.get_beams_columns(type_=2)
for name in columns:
self.SapModel.FrameObj.SetSelected(name, True)
def get_selected_floors(self):
all_selected_areas = self.get_selected_obj_type(n=5)
all_floors = self.etabs.area.get_names_of_areas_of_type(type_='floor')
selected_floors = set(all_selected_areas).intersection(all_floors)
return selected_floors