From def864e49cf2d6de396c2bff53ab1b226b91111d Mon Sep 17 00:00:00 2001 From: maxcapodi78 Date: Thu, 27 Apr 2023 17:26:30 +0200 Subject: [PATCH 1/3] Add point_data and point_3d_data to Edb class. --- _unittest/test_00_Advanced_EDB.py | 14 ++++---- pyaedt/edb.py | 42 ++++++++++++++++++++++ pyaedt/edb_core/components.py | 18 ++++------ pyaedt/edb_core/edb_data/padstacks_data.py | 8 +---- pyaedt/edb_core/layout.py | 20 ++++------- pyaedt/edb_core/stackup.py | 30 +++++++--------- 6 files changed, 74 insertions(+), 58 deletions(-) diff --git a/_unittest/test_00_Advanced_EDB.py b/_unittest/test_00_Advanced_EDB.py index 1a09b9f0ba1..6d58f1271db 100644 --- a/_unittest/test_00_Advanced_EDB.py +++ b/_unittest/test_00_Advanced_EDB.py @@ -286,14 +286,13 @@ def test_07_place_on_lam_with_mold(self): ) = cellInstance.Get3DTransformation() assert res zeroValue = chipEdb.edb_value(0) - oneValue = chipEdb.edb_value(1) - originPoint = chipEdb.edb.Geometry.Point3DData(zeroValue, zeroValue, zeroValue) - xAxisPoint = chipEdb.edb.Geometry.Point3DData(oneValue, zeroValue, zeroValue) + originPoint = chipEdb.point_3d_data(0.0, 0.0, 0.0) + xAxisPoint = chipEdb.point_3d_data(1.0, 0.0, 0.0) assert localOrigin.IsEqual(originPoint) assert rotAxisFrom.IsEqual(xAxisPoint) assert rotAxisTo.IsEqual(xAxisPoint) assert angle.IsEqual(zeroValue) - assert loc.IsEqual(chipEdb.edb.Geometry.Point3DData(zeroValue, zeroValue, chipEdb.edb_value(170e-6))) + assert loc.IsEqual(chipEdb.point_3d_data(0.0, 0.0, chipEdb.edb_value(170e-6))) finally: chipEdb.close_edb() laminateEdb.close_edb() @@ -349,14 +348,13 @@ def test_08_place_on_bottom_of_lam_with_mold(self): ) = cellInstance.Get3DTransformation() assert res zeroValue = chipEdb.edb_value(0) - oneValue = chipEdb.edb_value(1) - originPoint = chipEdb.edb.Geometry.Point3DData(zeroValue, zeroValue, zeroValue) - xAxisPoint = chipEdb.edb.Geometry.Point3DData(oneValue, zeroValue, zeroValue) + originPoint = chipEdb.point_3d_data(0.0, 0.0, 0.0) + xAxisPoint = chipEdb.point_3d_data(1.0, 0.0, 0.0) assert localOrigin.IsEqual(originPoint) assert rotAxisFrom.IsEqual(xAxisPoint) assert rotAxisTo.IsEqual(xAxisPoint) assert angle.IsEqual(zeroValue) - assert loc.IsEqual(chipEdb.edb.Geometry.Point3DData(zeroValue, zeroValue, chipEdb.edb_value(-90e-6))) + assert loc.IsEqual(chipEdb.point_3d_data(0.0, 0.0, chipEdb.edb_value(-90e-6))) finally: chipEdb.close_edb() laminateEdb.close_edb() diff --git a/pyaedt/edb.py b/pyaedt/edb.py index 60ed537e635..99223c67f19 100644 --- a/pyaedt/edb.py +++ b/pyaedt/edb.py @@ -1093,6 +1093,8 @@ def edb_value(self, val): Instance of `Edb.Utility.Value` """ + if isinstance(val, self.edb.Utility.Value): + return val if isinstance(val, (int, float)): return self.edb.Utility.Value(val) m1 = re.findall(r"(?<=[/+-/*//^/(/[])([a-z_A-Z/$]\w*)", str(val).replace(" ", "")) @@ -1110,6 +1112,46 @@ def edb_value(self, val): return self.edb.Utility.Value(val, var_server_db) return self.edb.Utility.Value(val) + @pyaedt_function_handler() + def point_3d_data(self, x, y, z=0.0): + """Compute the Edb 3d Point Data. + + Parameters + ---------- + x : float, int or str + X value. + y : float, int or str + Y value. + z : float, int or str, optional + Z value. + + Returns + ------- + ``Geometry.Point3DData``. + """ + return self.edb.Geometry.Point3DData(self.edb_value(x), self.edb_value(y), self.edb_value(z)) + + @pyaedt_function_handler() + def point_data(self, x, y=None): + """Compute the Edb Point Data. + + Parameters + ---------- + x : float, int or str + X value. + y : float, int or str, optional + Y value. + + + Returns + ------- + ``Geometry.PointData``. + """ + if y is None: + return self.edb.Geometry.PointData(self.edb_value(x)) + else: + return self.edb.Geometry.PointData(self.edb_value(x), self.edb_value(y)) + @pyaedt_function_handler() def _is_file_existing_and_released(self, filename): if os.path.exists(filename): diff --git a/pyaedt/edb_core/components.py b/pyaedt/edb_core/components.py index 7abbeb02744..e988feb3088 100644 --- a/pyaedt/edb_core/components.py +++ b/pyaedt/edb_core/components.py @@ -873,9 +873,7 @@ def _create_terminal(self, pin): """ pin_position = self.get_pin_position(pin) # pragma no cover - pin_pos = self._edb.Geometry.PointData( - self._get_edb_value(pin_position[0]), self._get_edb_value(pin_position[1]) # pragma no cover - ) + pin_pos = self._pedb.point_data(*pin_position) res, from_layer, _ = pin.GetLayerRange() cmp_name = pin.GetComponent().GetName() net_name = pin.GetNet().GetName() @@ -902,14 +900,14 @@ def _get_closest_pin_from(self, pin, ref_pinlist): """ res, pin_position, pin_rot = pin.GetPositionAndRotation( - self._edb.Geometry.PointData(self._get_edb_value(0.0), self._get_edb_value(0.0)), + self._pedb.point_data(0.0, 0.0), 0.0, ) distance = 1e3 closest_pin = ref_pinlist[0] for ref_pin in ref_pinlist: res, ref_pin_position, ref_pin_rot = ref_pin.GetPositionAndRotation( - self._edb.Geometry.PointData(self._get_edb_value(0.0), self._get_edb_value(0.0)), + self._pedb.point_data(0.0, 0.0), 0.0, ) temp_distance = pin_position.Distance(ref_pin_position) @@ -989,9 +987,8 @@ def add_port_on_rlc_component(self, component=None): pins = self.get_pin_from_component(component.refdes) if len(pins) == 2: # pragma: no cover pos_pin_loc = self.get_pin_position(pins[0]) - pt = self._pedb.edb.Geometry.PointData( - self._get_edb_value(pos_pin_loc[0]), self._get_edb_value(pos_pin_loc[1]) - ) + pt = self._pedb.point_data(*pos_pin_loc) + pin_layers = self._padstack._get_pin_layer_range(pins[0]) pos_pin_term = self._pedb.edb.Cell.Terminal.PointTerminal.Create( self._active_layout, @@ -1003,9 +1000,8 @@ def add_port_on_rlc_component(self, component=None): if not pos_pin_term: # pragma: no cover return False neg_pin_loc = self.get_pin_position(pins[1]) - pt = self._pedb.edb.Geometry.PointData( - self._get_edb_value(neg_pin_loc[0]), self._get_edb_value(neg_pin_loc[1]) - ) + pt = self._pedb.point_data(*neg_pin_loc) + neg_pin_term = self._pedb.edb.Cell.Terminal.PointTerminal.Create( self._active_layout, pins[1].GetNet(), diff --git a/pyaedt/edb_core/edb_data/padstacks_data.py b/pyaedt/edb_core/edb_data/padstacks_data.py index 6479b090967..6cf4a0ad910 100644 --- a/pyaedt/edb_core/edb_data/padstacks_data.py +++ b/pyaedt/edb_core/edb_data/padstacks_data.py @@ -1016,13 +1016,7 @@ def in_polygon(self, polygon_data, include_partial=True, simple_check=False): """ if simple_check: pos = [i for i in self.position] - int_val = ( - 1 - if polygon_data.PointInPolygon( - self._pedb.edb.Geometry.PointData(self._pedb.edb_value(pos[0]), self._pedb.edb_value(pos[1])) - ) - else 0 - ) + int_val = 1 if polygon_data.PointInPolygon(self._pedb.point_data(*pos)) else 0 else: plane = self._pedb.modeler.Shape("rectangle", pointA=self.bounding_box[0], pointB=self.bounding_box[1]) rectangle_data = self._pedb.modeler.shape_to_polygon_data(plane) diff --git a/pyaedt/edb_core/layout.py b/pyaedt/edb_core/layout.py index 4d374efae0e..5e15fced65b 100644 --- a/pyaedt/edb_core/layout.py +++ b/pyaedt/edb_core/layout.py @@ -356,9 +356,9 @@ def calc_slope(point, origin): if check_inside: xcoeff, ycoeff = calc_slope([point.X.ToDouble(), point.X.ToDouble()], origin) - new_points = self._edb.Geometry.PointData( - self._get_edb_value(point.X.ToString() + "{}*{}".format(xcoeff, offset_name)), - self._get_edb_value(point.Y.ToString() + "{}*{}".format(ycoeff, offset_name)), + new_points = self._pedb.point_data( + point.X.ToString() + "{}*{}".format(xcoeff, offset_name), + point.Y.ToString() + "{}*{}".format(ycoeff, offset_name), ) poligon_data.SetPoint(i, new_points) prev_point = point @@ -431,9 +431,7 @@ def _create_path( else: corner_style = self._edb.Cell.Primitive.PathCornerStyle.MiterCorner # pragma: no cover - pointlists = [ - self._edb.Geometry.PointData(self._get_edb_value(i[0]), self._get_edb_value(i[1])) for i in path_list.points - ] + pointlists = [self._pedb.point_data(i[0], i[1]) for i in path_list.points] polygonData = self._edb.Geometry.PolygonData(convert_py_list_to_net_list(pointlists), False) polygon = self._edb.Cell.Primitive.Path.Create( self._active_layout, @@ -868,14 +866,8 @@ def _createPolygonDataFromPolygon(self, shape): or endPoint[1].IsParametric() ) arc = self._edb.Geometry.ArcData( - self._edb.Geometry.PointData( - self._get_edb_value(startPoint[0].ToDouble()), - self._get_edb_value(startPoint[1].ToDouble()), - ), - self._edb.Geometry.PointData( - self._get_edb_value(endPoint[0].ToDouble()), - self._get_edb_value(endPoint[1].ToDouble()), - ), + self._pedb.point_data(*startPoint), + self._pedb.point_data(*endPoint), ) arcs.append(arc) elif len(endPoint) == 5: diff --git a/pyaedt/edb_core/stackup.py b/pyaedt/edb_core/stackup.py index d3b4b5928f2..8c15ff65dda 100644 --- a/pyaedt/edb_core/stackup.py +++ b/pyaedt/edb_core/stackup.py @@ -1318,12 +1318,10 @@ def place_in_layout_3d_placement( zero_data = self._edb_value(0.0) one_data = self._edb_value(1.0) - point3d_t = self._pedb.edb.Geometry.Point3DData(_offset_x, _offset_y, h_stackup) - point_loc = self._pedb.edb.Geometry.Point3DData(zero_data, zero_data, zero_data) - point_from = self._pedb.edb.Geometry.Point3DData(one_data, zero_data, zero_data) - point_to = self._pedb.edb.Geometry.Point3DData( - self._edb_value(math.cos(_angle)), self._edb_value(-1 * math.sin(_angle)), zero_data - ) + point3d_t = self._pedb.point_3d_data(_offset_x, _offset_y, h_stackup) + point_loc = self._pedb.point_3d_data(zero_data, zero_data, zero_data) + point_from = self._pedb.point_3d_data(one_data, zero_data, zero_data) + point_to = self._pedb.point_3d_data(math.cos(_angle), -1 * math.sin(_angle), zero_data) cell_inst2.Set3DTransformation(point_loc, point_from, point_to, rotation, point3d_t) self.refresh_layer_collection() return True @@ -1464,12 +1462,10 @@ def place_instance( zero_data = self._edb_value(0.0) one_data = self._edb_value(1.0) - point3d_t = self._pedb.edb.Geometry.Point3DData(_offset_x, _offset_y, h_stackup) - point_loc = self._pedb.edb.Geometry.Point3DData(zero_data, zero_data, zero_data) - point_from = self._pedb.edb.Geometry.Point3DData(one_data, zero_data, zero_data) - point_to = self._pedb.edb.Geometry.Point3DData( - self._edb_value(math.cos(_angle)), self._edb_value(-1 * math.sin(_angle)), zero_data - ) + point3d_t = self._pedb.point_3d_data(_offset_x, _offset_y, h_stackup) + point_loc = self._pedb.point_3d_data(zero_data, zero_data, zero_data) + point_from = self._pedb.point_3d_data(one_data, zero_data, zero_data) + point_to = self._pedb.point_3d_data(math.cos(_angle), -1 * math.sin(_angle), zero_data) cell_inst2.Set3DTransformation(point_loc, point_from, point_to, rotation, point3d_t) self.refresh_layer_collection() return True @@ -1511,12 +1507,10 @@ def place_a3dcomp_3d_placement(self, a3dcomp_path, angle=0.0, offset_x=0.0, offs """ zero_data = self._edb_value(0.0) one_data = self._edb_value(1.0) - local_origin = self._pedb.edb.Geometry.Point3DData(zero_data, zero_data, zero_data) - rotation_axis_from = self._pedb.edb.Geometry.Point3DData(one_data, zero_data, zero_data) + local_origin = self._pedb.point_3d_data(0.0, 0.0, 0.0) + rotation_axis_from = self._pedb.point_3d_data(1.0, 0.0, 0.0) _angle = angle * math.pi / 180.0 - rotation_axis_to = self._pedb.edb.Geometry.Point3DData( - self._edb_value(math.cos(_angle)), self._edb_value(-1 * math.sin(_angle)), zero_data - ) + rotation_axis_to = self._pedb.point_3d_data(math.cos(_angle), -1 * math.sin(_angle), 0.0) stackup_target = self._pedb.edb.Cell.LayerCollection(self._pedb.active_layout.GetLayerCollection()) sig_set = self._pedb.edb.Cell.LayerTypeSet.SignalLayerSet @@ -1530,7 +1524,7 @@ def place_a3dcomp_3d_placement(self, a3dcomp_path, angle=0.0, offset_x=0.0, offs flip_angle = self._edb_value("180deg") elevation = target_bottom_elevation h_stackup = self._edb_value(elevation) - location = self._pedb.edb.Geometry.Point3DData(self._edb_value(offset_x), self._edb_value(offset_y), h_stackup) + location = self._pedb.point_3d_data(offset_x, offset_y, h_stackup) mcad_model = self._pedb.edb.McadModel.Create3DComp(self._pedb.active_layout, a3dcomp_path) if mcad_model.IsNull(): # pragma: no cover From 46558cca96944102add898dd6e5e26024e160939 Mon Sep 17 00:00:00 2001 From: maxcapodi78 Date: Thu, 27 Apr 2023 17:57:39 +0200 Subject: [PATCH 2/3] Add point_data and point_3d_data to Edb class. --- pyaedt/edb_core/layout.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyaedt/edb_core/layout.py b/pyaedt/edb_core/layout.py index 5e15fced65b..8d278604995 100644 --- a/pyaedt/edb_core/layout.py +++ b/pyaedt/edb_core/layout.py @@ -866,8 +866,8 @@ def _createPolygonDataFromPolygon(self, shape): or endPoint[1].IsParametric() ) arc = self._edb.Geometry.ArcData( - self._pedb.point_data(*startPoint), - self._pedb.point_data(*endPoint), + self._pedb.point_data(startPoint[0], startPoint[1]), + self._pedb.point_data(endPoint[0], endPoint[1]), ) arcs.append(arc) elif len(endPoint) == 5: From e667811a8d8f04c146dbc6a2c9771d538da674ab Mon Sep 17 00:00:00 2001 From: maxcapodi78 Date: Thu, 27 Apr 2023 18:36:25 +0200 Subject: [PATCH 3/3] Add point_data and point_3d_data to Edb class. --- _unittest/test_00_Advanced_EDB.py | 12 ++++++------ pyaedt/edb.py | 2 +- pyaedt/edb_core/stackup.py | 24 ++++++++++++------------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/_unittest/test_00_Advanced_EDB.py b/_unittest/test_00_Advanced_EDB.py index 6d58f1271db..b0c335ec215 100644 --- a/_unittest/test_00_Advanced_EDB.py +++ b/_unittest/test_00_Advanced_EDB.py @@ -286,13 +286,13 @@ def test_07_place_on_lam_with_mold(self): ) = cellInstance.Get3DTransformation() assert res zeroValue = chipEdb.edb_value(0) - originPoint = chipEdb.point_3d_data(0.0, 0.0, 0.0) - xAxisPoint = chipEdb.point_3d_data(1.0, 0.0, 0.0) + originPoint = chipEdb.point_3d(0.0, 0.0, 0.0) + xAxisPoint = chipEdb.point_3d(1.0, 0.0, 0.0) assert localOrigin.IsEqual(originPoint) assert rotAxisFrom.IsEqual(xAxisPoint) assert rotAxisTo.IsEqual(xAxisPoint) assert angle.IsEqual(zeroValue) - assert loc.IsEqual(chipEdb.point_3d_data(0.0, 0.0, chipEdb.edb_value(170e-6))) + assert loc.IsEqual(chipEdb.point_3d(0.0, 0.0, chipEdb.edb_value(170e-6))) finally: chipEdb.close_edb() laminateEdb.close_edb() @@ -348,13 +348,13 @@ def test_08_place_on_bottom_of_lam_with_mold(self): ) = cellInstance.Get3DTransformation() assert res zeroValue = chipEdb.edb_value(0) - originPoint = chipEdb.point_3d_data(0.0, 0.0, 0.0) - xAxisPoint = chipEdb.point_3d_data(1.0, 0.0, 0.0) + originPoint = chipEdb.point_3d(0.0, 0.0, 0.0) + xAxisPoint = chipEdb.point_3d(1.0, 0.0, 0.0) assert localOrigin.IsEqual(originPoint) assert rotAxisFrom.IsEqual(xAxisPoint) assert rotAxisTo.IsEqual(xAxisPoint) assert angle.IsEqual(zeroValue) - assert loc.IsEqual(chipEdb.point_3d_data(0.0, 0.0, chipEdb.edb_value(-90e-6))) + assert loc.IsEqual(chipEdb.point_3d(0.0, 0.0, chipEdb.edb_value(-90e-6))) finally: chipEdb.close_edb() laminateEdb.close_edb() diff --git a/pyaedt/edb.py b/pyaedt/edb.py index 99223c67f19..92bf94b9f15 100644 --- a/pyaedt/edb.py +++ b/pyaedt/edb.py @@ -1113,7 +1113,7 @@ def edb_value(self, val): return self.edb.Utility.Value(val) @pyaedt_function_handler() - def point_3d_data(self, x, y, z=0.0): + def point_3d(self, x, y, z=0.0): """Compute the Edb 3d Point Data. Parameters diff --git a/pyaedt/edb_core/stackup.py b/pyaedt/edb_core/stackup.py index 8c15ff65dda..fc404eb1815 100644 --- a/pyaedt/edb_core/stackup.py +++ b/pyaedt/edb_core/stackup.py @@ -1318,10 +1318,10 @@ def place_in_layout_3d_placement( zero_data = self._edb_value(0.0) one_data = self._edb_value(1.0) - point3d_t = self._pedb.point_3d_data(_offset_x, _offset_y, h_stackup) - point_loc = self._pedb.point_3d_data(zero_data, zero_data, zero_data) - point_from = self._pedb.point_3d_data(one_data, zero_data, zero_data) - point_to = self._pedb.point_3d_data(math.cos(_angle), -1 * math.sin(_angle), zero_data) + point3d_t = self._pedb.point_3d(_offset_x, _offset_y, h_stackup) + point_loc = self._pedb.point_3d(zero_data, zero_data, zero_data) + point_from = self._pedb.point_3d(one_data, zero_data, zero_data) + point_to = self._pedb.point_3d(math.cos(_angle), -1 * math.sin(_angle), zero_data) cell_inst2.Set3DTransformation(point_loc, point_from, point_to, rotation, point3d_t) self.refresh_layer_collection() return True @@ -1462,10 +1462,10 @@ def place_instance( zero_data = self._edb_value(0.0) one_data = self._edb_value(1.0) - point3d_t = self._pedb.point_3d_data(_offset_x, _offset_y, h_stackup) - point_loc = self._pedb.point_3d_data(zero_data, zero_data, zero_data) - point_from = self._pedb.point_3d_data(one_data, zero_data, zero_data) - point_to = self._pedb.point_3d_data(math.cos(_angle), -1 * math.sin(_angle), zero_data) + point3d_t = self._pedb.point_3d(_offset_x, _offset_y, h_stackup) + point_loc = self._pedb.point_3d(zero_data, zero_data, zero_data) + point_from = self._pedb.point_3d(one_data, zero_data, zero_data) + point_to = self._pedb.point_3d(math.cos(_angle), -1 * math.sin(_angle), zero_data) cell_inst2.Set3DTransformation(point_loc, point_from, point_to, rotation, point3d_t) self.refresh_layer_collection() return True @@ -1507,10 +1507,10 @@ def place_a3dcomp_3d_placement(self, a3dcomp_path, angle=0.0, offset_x=0.0, offs """ zero_data = self._edb_value(0.0) one_data = self._edb_value(1.0) - local_origin = self._pedb.point_3d_data(0.0, 0.0, 0.0) - rotation_axis_from = self._pedb.point_3d_data(1.0, 0.0, 0.0) + local_origin = self._pedb.point_3d(0.0, 0.0, 0.0) + rotation_axis_from = self._pedb.point_3d(1.0, 0.0, 0.0) _angle = angle * math.pi / 180.0 - rotation_axis_to = self._pedb.point_3d_data(math.cos(_angle), -1 * math.sin(_angle), 0.0) + rotation_axis_to = self._pedb.point_3d(math.cos(_angle), -1 * math.sin(_angle), 0.0) stackup_target = self._pedb.edb.Cell.LayerCollection(self._pedb.active_layout.GetLayerCollection()) sig_set = self._pedb.edb.Cell.LayerTypeSet.SignalLayerSet @@ -1524,7 +1524,7 @@ def place_a3dcomp_3d_placement(self, a3dcomp_path, angle=0.0, offset_x=0.0, offs flip_angle = self._edb_value("180deg") elevation = target_bottom_elevation h_stackup = self._edb_value(elevation) - location = self._pedb.point_3d_data(offset_x, offset_y, h_stackup) + location = self._pedb.point_3d(offset_x, offset_y, h_stackup) mcad_model = self._pedb.edb.McadModel.Create3DComp(self._pedb.active_layout, a3dcomp_path) if mcad_model.IsNull(): # pragma: no cover