Skip to content

Commit de9a372

Browse files
authored
Fix bug for flipped mount when rotation zero (#1009)
* Fix bug for flipped mount when rotation zero get_component_placement_vector would return an incorrect Y-offset when flipped was True and the rotation angle was calculated to be zero. Add a test case for and fix this by modifying the merged component pin locations to account for the flip around the X-axis (Y-value changes sign) so that the correct flipped values propagate through the rest of the calculations. * Feedback from review Simplify offset calculation by not treating zero rotation as a special case. Also clean up the error checking for return: the existing code implied that the vector calculation could fail when it could not and would not capture a failure to get the solder ball height.
1 parent c0bf4b7 commit de9a372

File tree

4 files changed

+30
-15
lines changed

4 files changed

+30
-15
lines changed
Binary file not shown.
3.02 MB
Binary file not shown.

_unittest/test_00_EDB.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,24 @@ def test_79f_get_placement_vector_offset(self):
860860
chip_edb.close_edb()
861861
laminate_edb.close_edb()
862862

863+
def test_79g_get_placement_vector(self):
864+
board_edb = Edb(os.path.join(local_path, "example_models", "invert_board.aedb"), edbversion=desktop_version)
865+
package_edb = Edb(os.path.join(local_path, "example_models", "package2.aedb"), edbversion=desktop_version)
866+
try:
867+
laminate_cmp = board_edb.core_components.get_component_by_name("U100")
868+
chip_cmp = package_edb.core_components.get_component_by_name("BGA")
869+
result, vector, rotation, solder_ball_height = board_edb.core_components.get_component_placement_vector(
870+
chip_cmp, laminate_cmp, "A12", "A14", "A12", "A14", True
871+
)
872+
assert result
873+
assert abs(rotation) < 1e-9
874+
assert abs(solder_ball_height - 315e-6) < 1e-9
875+
assert abs(vector[0] + 48.7e-3) < 10e-9
876+
assert abs(vector[1] - 59.7e-3) < 10e-9
877+
finally:
878+
package_edb.close_edb()
879+
board_edb.close_edb()
880+
863881
def test_80_edb_without_path(self):
864882
edbapp_without_path = Edb(edbversion=desktop_version, isreadonly=False)
865883
time.sleep(2)

pyaedt/edb_core/components.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -467,26 +467,23 @@ def get_component_placement_vector(
467467
if hosting_component_pin2:
468468
h_pin2 = self._get_edb_pin_from_pin_name(hosting_component, hosting_component_pin2)
469469
h_pin2_pos = self.get_pin_position(h_pin2)
470-
#
471-
vector = [h_pin1_pos[0] - m_pin1_pos[0], h_pin1_pos[1] - m_pin1_pos[1]]
470+
471+
if flipped:
472+
m_pin1_pos[1] *= -1.0
473+
m_pin2_pos[1] *= -1.0
474+
472475
vector1 = GeometryOperators.v_points(m_pin1_pos, m_pin2_pos)
473476
vector2 = GeometryOperators.v_points(h_pin1_pos, h_pin2_pos)
474-
multiplier = 1
475-
if flipped:
476-
multiplier = -1
477-
vector1[1] = multiplier * vector1[1]
478477

479478
rotation = GeometryOperators.v_angle_sign_2D(vector1, vector2, False)
480-
if rotation != 0.0:
481-
x_v2 = m_pin1_pos[0] * math.cos(rotation) + multiplier * m_pin1_pos[1] * math.sin(rotation)
482-
y_v2 = -1 * m_pin1_pos[0] * math.sin(rotation) + multiplier * m_pin1_pos[1] * math.cos(rotation)
483-
new_vector = [x_v2, y_v2]
484-
vector = [h_pin1_pos[0] - new_vector[0], h_pin1_pos[1] - new_vector[1]]
485-
486-
if vector:
487-
solder_ball_height = self.get_solder_ball_height(mounted_component)
479+
offset_from_x = m_pin1_pos[0] * math.cos(rotation) + m_pin1_pos[1] * math.sin(rotation)
480+
offset_from_y = -1 * m_pin1_pos[0] * math.sin(rotation) + m_pin1_pos[1] * math.cos(rotation)
481+
vector = [h_pin1_pos[0] - offset_from_x, h_pin1_pos[1] - offset_from_y]
482+
483+
solder_ball_height = self.get_solder_ball_height(mounted_component)
484+
if isinstance(solder_ball_height, float):
488485
return True, vector, rotation, solder_ball_height
489-
self._logger.warning("Failed to compute vector.")
486+
self._logger.warning("Failed to compute solder ball height.")
490487
return False, [0, 0], 0, 0
491488

492489
@pyaedt_function_handler()

0 commit comments

Comments
 (0)