31
31
from ansys .aedt .core .generic .general_methods import pyaedt_function_handler
32
32
from ansys .aedt .core .generic .numbers_utils import decompose_variable_value
33
33
from ansys .aedt .core .generic .settings import settings
34
+ from ansys .aedt .core .modeler .geometry_operators import GeometryOperators
34
35
from ansys .aedt .core .modeler .geometry_operators import GeometryOperators as go
35
36
36
37
@@ -48,6 +49,11 @@ def units(self):
48
49
"""Length units."""
49
50
return self ._circuit_comp .units
50
51
52
+ @property
53
+ def total_angle (self ):
54
+ """Return the pin orientation in the schematic."""
55
+ return int (self .angle + self ._circuit_comp .angle )
56
+
51
57
@property
52
58
def location (self ):
53
59
"""Pin Position in [x,y] format.
@@ -152,7 +158,14 @@ def _get_deltas(self, point, move_x=True, move_y=True, positive=True, units=1):
152
158
153
159
@pyaedt_function_handler (component_pin = "assignment" )
154
160
def connect_to_component (
155
- self , assignment , page_name = None , use_wire = False , wire_name = "" , clearance_units = 1 , page_port_angle = None
161
+ self ,
162
+ assignment ,
163
+ page_name = None ,
164
+ use_wire = False ,
165
+ wire_name = "" ,
166
+ clearance_units = 1 ,
167
+ page_port_angle = None ,
168
+ offset = 0 ,
156
169
):
157
170
"""Connect schematic components.
158
171
@@ -174,6 +187,8 @@ def connect_to_component(
174
187
page_port_angle : int, optional
175
188
Page port angle on the source pin. The default is ``None``, in which case
176
189
the angle is automatically computed.
190
+ offset : float, optional
191
+ Page port offset in the direction of the pin. The default is ``0``.
177
192
178
193
Returns
179
194
-------
@@ -274,11 +289,7 @@ def connect_to_component(
274
289
if page_name is None :
275
290
page_name = f"{ self ._circuit_comp .composed_name .replace ('CompInst@' , '' ).replace (';' , '_' )} _{ self .name } "
276
291
277
- if (
278
- len (assignment ) == 1
279
- and (abs (self .location [1 ] - assignment [0 ].location [1 ]) + abs (self .location [0 ] - assignment [0 ].location [0 ]))
280
- < 0.01524
281
- ):
292
+ if len (assignment ) == 1 and GeometryOperators .points_distance (self .location , assignment [0 ].location ) < 0.01524 :
282
293
self ._circuit_comp ._circuit_components .create_wire ([self .location , assignment [0 ].location ], name = page_name )
283
294
return True
284
295
if "Port" in self ._circuit_comp .composed_name :
@@ -296,19 +307,25 @@ def connect_to_component(
296
307
self ._component ._circuit_components .logger .debug (
297
308
"Cannot parse page name from circuit component name"
298
309
)
299
- if self .location [0 ] > self ._circuit_comp .location [0 ]:
300
- angle = 180
301
- else :
302
- angle = 0
303
- ret1 = self ._circuit_comp ._circuit_components .create_page_port (page_name , self .location , angle = angle )
310
+ angle = page_port_angle if page_port_angle else self .total_angle
311
+ location = [
312
+ self .location [0 ] - offset * math .cos (self .total_angle * math .pi / 180 ),
313
+ self .location [1 ] - offset * math .sin (self .total_angle * math .pi / 180 ),
314
+ ]
315
+ ret1 = self ._circuit_comp ._circuit_components .create_page_port (page_name , location , angle = angle )
316
+ if offset != 0 :
317
+ self ._circuit_comp ._circuit_components .create_wire ([self .location , location ])
304
318
for cmp in assignment :
305
- if cmp .location [0 ] > cmp ._circuit_comp .location [0 ]:
306
- angle = 180
307
- else :
308
- angle = 0
319
+ location = [
320
+ cmp .location [0 ] - offset * math .cos (cmp .total_angle * math .pi / 180 ),
321
+ cmp .location [1 ] - offset * math .sin (cmp .total_angle * math .pi / 180 ),
322
+ ]
323
+
309
324
ret2 = self ._circuit_comp ._circuit_components .create_page_port (
310
- page_name , location = cmp . location , angle = angle
325
+ page_name , location = location , angle = cmp . total_angle
311
326
)
327
+ if offset != 0 :
328
+ self ._circuit_comp ._circuit_components .create_wire ([cmp .location , location ])
312
329
if ret1 and ret2 :
313
330
return True , ret1 , ret2
314
331
else :
0 commit comments