diff --git a/_unittest/test_40_3dlayout_edb.py b/_unittest/test_40_3dlayout_edb.py index 89c083d64d8..372c3cb0650 100644 --- a/_unittest/test_40_3dlayout_edb.py +++ b/_unittest/test_40_3dlayout_edb.py @@ -105,6 +105,7 @@ def test_02a_get_geometries(self): assert poly.top_edge_x == 2 assert poly.top_edge_y == 3 assert poly.placement_layer == "1_Top" + assert poly.obounding_box poly.placement_layer = "16_Bottom" assert poly.placement_layer == "16_Bottom" poly.placement_layer = "1_Top" diff --git a/pyaedt/modeler/modelerpcb.py b/pyaedt/modeler/modelerpcb.py index 0bd42b63b62..c5b00c754d3 100644 --- a/pyaedt/modeler/modelerpcb.py +++ b/pyaedt/modeler/modelerpcb.py @@ -185,16 +185,24 @@ def primitives(self): warn(mess, DeprecationWarning) return self._primitives - @property - def obounding_box(self): - """Bounding box. + @pyaedt_function_handler + def obounding_box(self, object_name): + """Bounding box of a specified object. + + Returns + ------- + list + List of [LLx, LLy, URx, URy] coordinates. References ---------- - >>> oEditor.GetModelBoundingBox + >>> oEditor.GetBBox """ - return self.oeditor.GetModelBoundingBox() + bb = self.oeditor.GetBBox(object_name) + pll = bb.BBoxLL() + pur = bb.BBoxUR() + return [pll.GetX(), pll.GetY(), pur.GetX(), pur.GetY()] @pyaedt_function_handler() def _arg_with_dim(self, value, units=None): diff --git a/pyaedt/modeler/pcb/object3dlayout.py b/pyaedt/modeler/pcb/object3dlayout.py index 5c9cdb70f41..b20a170d84e 100644 --- a/pyaedt/modeler/pcb/object3dlayout.py +++ b/pyaedt/modeler/pcb/object3dlayout.py @@ -856,6 +856,22 @@ def __init__(self, primitives, name, prim_type="poly", is_void=False): self.is_void = is_void self._name = name + @property + def obounding_box(self): + """Bounding box of a specified object. + + Returns + ------- + list + List of [LLx, LLy, URx, URy] coordinates. + + References + ---------- + + >>> oEditor.GetBBox + """ + return self._primitives.obounding_box(self.name) + @property def name(self): """Name of Primitive.""" @@ -1458,14 +1474,18 @@ def length(self): @property def center_line(self): - """Get the center line points. + """Get the center line points and arc height. Returns ------- dict Points. """ - props = [i for i in list(self._oeditor.GetProperties("BaseElementTab", self.name)) if i.startswith("Pt")] + props = [ + i + for i in list(self._oeditor.GetProperties("BaseElementTab", self.name)) + if i.startswith("Pt") or i.startswith("ArcHeight") + ] self._center_line = {} for i in props: self._center_line[i] = [ @@ -1477,7 +1497,12 @@ def center_line(self): def center_line(self, points): u = self._primitives.model_units for point_name, value in points.items(): - vpoint = ["NAME:{}".format(point_name), "X:=", _dim_arg(value[0], u), "Y:=", _dim_arg(value[1], u)] + if len(value) == 2: + vpoint = ["NAME:{}".format(point_name), "X:=", _dim_arg(value[0], u), "Y:=", _dim_arg(value[1], u)] + elif isinstance(value, list): + vpoint = ["NAME:{}".format(point_name), "Value:=", _dim_arg(value[0], u)] + else: + vpoint = ["NAME:{}".format(point_name), "Value:=", _dim_arg(value, u)] self.change_property(vpoint) self._center_line = {} diff --git a/pyaedt/modeler/schematic.py b/pyaedt/modeler/schematic.py index 0872d4914a5..d287d898648 100644 --- a/pyaedt/modeler/schematic.py +++ b/pyaedt/modeler/schematic.py @@ -79,16 +79,6 @@ def oeditor(self): >>> oEditor = oDesign.SetActiveEditor("SchematicEditor")""" return self._app.oeditor - @property - def obounding_box(self): - """Bounding box. - - References - ---------- - - >>> oEditor.GetModelBoundingBox()""" - return self.oeditor.GetModelBoundingBox() - @pyaedt_function_handler() def zoom_to_fit(self): """Zoom To Fit.