29
29
from ansys .api .geometry .v0 .unsupported_pb2_grpc import UnsupportedStub
30
30
from ansys .geometry .core .connection import GrpcClient
31
31
from ansys .geometry .core .errors import protect_grpc
32
- from ansys .geometry .core .misc import auxiliary
32
+ from ansys .geometry .core .misc . auxiliary import get_all_bodies_from_design
33
33
from ansys .geometry .core .misc .checks import (
34
34
min_backend_version ,
35
35
)
38
38
from ansys .geometry .core .designer .body import Body
39
39
from ansys .geometry .core .designer .edge import Edge
40
40
from ansys .geometry .core .designer .face import Face
41
+ from ansys .geometry .core .modeler import Modeler
41
42
42
43
43
44
@unique
@@ -58,17 +59,17 @@ class UnsupportedCommands:
58
59
"""
59
60
60
61
@protect_grpc
61
- def __init__ (self , grpc_client : GrpcClient , modeler ):
62
+ def __init__ (self , grpc_client : GrpcClient , modeler : "Modeler" ):
62
63
"""Initialize an instance of the ``UnsupportedCommands`` class."""
63
64
self ._grpc_client = grpc_client
64
65
self ._unsupported_stub = UnsupportedStub (self ._grpc_client .channel )
65
66
self .__id_map = {}
66
67
self .__modeler = modeler
67
- self .__current_design = None
68
+ self .__current_design = modeler . get_active_design ()
68
69
69
70
@protect_grpc
70
71
@min_backend_version (25 , 2 , 0 )
71
- def __fill_imported_id_map (self , id_type : " PersistentIdType" ) -> None :
72
+ def __fill_imported_id_map (self , id_type : PersistentIdType ) -> None :
72
73
"""Populate the persistent id map for caching.
73
74
74
75
Parameters
@@ -96,7 +97,7 @@ def __clear_cache(self) -> None:
96
97
97
98
@protect_grpc
98
99
@min_backend_version (25 , 2 , 0 )
99
- def __is_occurrence (self , master : " EntityIdentifier" , occ : " str" ) -> bool :
100
+ def __is_occurrence (self , master : EntityIdentifier , occ : str ) -> bool :
100
101
"""Determine if the master is the master of the occurrence.
101
102
102
103
Parameters
@@ -118,7 +119,7 @@ def __is_occurrence(self, master: "EntityIdentifier", occ: "str") -> bool:
118
119
@protect_grpc
119
120
@min_backend_version (25 , 2 , 0 )
120
121
def __get_moniker_from_import_id (
121
- self , id_type : " PersistentIdType" , import_id : " str"
122
+ self , id_type : PersistentIdType , import_id : str
122
123
) -> "EntityIdentifier | None" :
123
124
"""Look up the moniker from the id map.
124
125
@@ -148,7 +149,7 @@ def __get_moniker_from_import_id(
148
149
149
150
@protect_grpc
150
151
@min_backend_version (25 , 2 , 0 )
151
- def set_export_id (self , moniker : " str" , id_type : " PersistentIdType" , value : " str" ) -> None :
152
+ def set_export_id (self , moniker : str , id_type : PersistentIdType , value : str ) -> None :
152
153
"""Set the persistent id for the moniker.
153
154
154
155
Parameters
@@ -175,7 +176,7 @@ def set_export_id(self, moniker: "str", id_type: "PersistentIdType", value: "str
175
176
@protect_grpc
176
177
@min_backend_version (25 , 2 , 0 )
177
178
def get_body_occurrences_from_import_id (
178
- self , import_id : " str" , id_type : " PersistentIdType"
179
+ self , import_id : str , id_type : PersistentIdType
179
180
) -> list ["Body" ]:
180
181
"""Get all body occurrences whose master has the given import id.
181
182
@@ -194,19 +195,19 @@ def get_body_occurrences_from_import_id(
194
195
moniker = self .__get_moniker_from_import_id (id_type , import_id )
195
196
196
197
if moniker is None :
197
- return list ()
198
+ return []
198
199
199
200
design = self .__modeler .get_active_design ()
200
201
return [
201
202
body
202
- for body in auxiliary . get_all_bodies_from_design (design )
203
+ for body in get_all_bodies_from_design (design )
203
204
if self .__is_occurrence (moniker , body .id )
204
205
]
205
206
206
207
@protect_grpc
207
208
@min_backend_version (25 , 2 , 0 )
208
209
def get_face_occurrences_from_import_id (
209
- self , import_id : " str" , id_type : " PersistentIdType"
210
+ self , import_id : str , id_type : PersistentIdType
210
211
) -> list ["Face" ]:
211
212
"""Get all face occurrences whose master has the given import id.
212
213
@@ -225,20 +226,20 @@ def get_face_occurrences_from_import_id(
225
226
moniker = self .__get_moniker_from_import_id (id_type , import_id )
226
227
227
228
if moniker is None :
228
- return list ()
229
+ return []
229
230
230
231
design = self .__modeler .get_active_design ()
231
232
return [
232
233
face
233
- for body in auxiliary . get_all_bodies_from_design (design )
234
+ for body in get_all_bodies_from_design (design )
234
235
for face in body .faces
235
236
if self .__is_occurrence (moniker , face .id )
236
237
]
237
238
238
239
@protect_grpc
239
240
@min_backend_version (25 , 2 , 0 )
240
241
def get_edge_occurrences_from_import_id (
241
- self , import_id : " str" , id_type : " PersistentIdType"
242
+ self , import_id : str , id_type : PersistentIdType
242
243
) -> list ["Edge" ]:
243
244
"""Get all edge occurrences whose master has the given import id.
244
245
@@ -257,12 +258,12 @@ def get_edge_occurrences_from_import_id(
257
258
moniker = self .__get_moniker_from_import_id (id_type , import_id )
258
259
259
260
if moniker is None :
260
- return list ()
261
+ return []
261
262
262
263
design = self .__modeler .get_active_design ()
263
264
return [
264
265
edge
265
- for body in auxiliary . get_all_bodies_from_design (design )
266
+ for body in get_all_bodies_from_design (design )
266
267
for edge in body .edges
267
268
if self .__is_occurrence (moniker , edge .id )
268
269
]
0 commit comments