pyedb 0.7.1__py3-none-any.whl → 0.8.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyedb might be problematic. Click here for more details.

Files changed (32) hide show
  1. pyedb/__init__.py +1 -1
  2. pyedb/dotnet/edb.py +1 -0
  3. pyedb/dotnet/edb_core/cell/hierarchy/model.py +1 -1
  4. pyedb/dotnet/edb_core/components.py +15 -12
  5. pyedb/dotnet/edb_core/configuration.py +37 -5
  6. pyedb/dotnet/edb_core/definition/component_def.py +1 -1
  7. pyedb/dotnet/edb_core/definition/component_model.py +1 -1
  8. pyedb/dotnet/edb_core/definition/definition_obj.py +1 -1
  9. pyedb/dotnet/edb_core/definition/definitions.py +8 -2
  10. pyedb/dotnet/edb_core/definition/package_def.py +34 -15
  11. pyedb/dotnet/edb_core/dotnet/database.py +5 -4
  12. pyedb/dotnet/edb_core/edb_data/components_data.py +1 -1
  13. pyedb/dotnet/edb_core/edb_data/connectable.py +1 -1
  14. pyedb/dotnet/edb_core/edb_data/layer_data.py +3 -2
  15. pyedb/dotnet/edb_core/edb_data/primitives_data.py +4 -2
  16. pyedb/dotnet/edb_core/edb_data/siwave_simulation_setup_data.py +6 -0
  17. pyedb/dotnet/edb_core/geometry/__init__.py +0 -0
  18. pyedb/dotnet/edb_core/{edb_data/obj_base.py → geometry/point_data.py} +12 -26
  19. pyedb/dotnet/edb_core/geometry/polygon_data.py +77 -0
  20. pyedb/dotnet/edb_core/materials.py +128 -106
  21. pyedb/dotnet/edb_core/nets.py +3 -3
  22. pyedb/dotnet/edb_core/obj_base.py +94 -0
  23. pyedb/dotnet/edb_core/siwave.py +33 -2
  24. pyedb/dotnet/edb_core/stackup.py +49 -42
  25. pyedb/dotnet/sim_setup_data/data/siw_dc_ir_settings.py +46 -0
  26. pyedb/edb_logger.py +15 -1
  27. pyedb/generic/settings.py +20 -9
  28. pyedb/siwave.py +50 -1
  29. {pyedb-0.7.1.dist-info → pyedb-0.8.1.dist-info}/METADATA +5 -5
  30. {pyedb-0.7.1.dist-info → pyedb-0.8.1.dist-info}/RECORD +32 -28
  31. {pyedb-0.7.1.dist-info → pyedb-0.8.1.dist-info}/LICENSE +0 -0
  32. {pyedb-0.7.1.dist-info → pyedb-0.8.1.dist-info}/WHEEL +0 -0
pyedb/__init__.py CHANGED
@@ -44,7 +44,7 @@ deprecation_warning()
44
44
  #
45
45
 
46
46
  pyedb_path = os.path.dirname(__file__)
47
- __version__ = "0.7.1"
47
+ __version__ = "0.8.1"
48
48
  version = __version__
49
49
 
50
50
  #
pyedb/dotnet/edb.py CHANGED
@@ -3637,6 +3637,7 @@ class Edb(Database):
3637
3637
  >>> setup1.hfss_port_settings.max_delta_z0 = 0.5
3638
3638
  """
3639
3639
  if name in self.setups:
3640
+ self.logger.info("setup already exists")
3640
3641
  return False
3641
3642
  setup = HfssSimulationSetup(self).create(name)
3642
3643
  return setup
@@ -20,7 +20,7 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
- from pyedb.dotnet.edb_core.edb_data.obj_base import ObjBase
23
+ from pyedb.dotnet.edb_core.obj_base import ObjBase
24
24
  from pyedb.generic.general_methods import pyedb_function_handler
25
25
 
26
26
 
@@ -38,6 +38,7 @@ from pyedb.dotnet.edb_core.general import convert_py_list_to_net_list
38
38
  from pyedb.dotnet.edb_core.padstack import EdbPadstacks
39
39
  from pyedb.generic.general_methods import (
40
40
  _retry_ntimes,
41
+ generate_unique_name,
41
42
  get_filename_without_extension,
42
43
  pyedb_function_handler,
43
44
  )
@@ -878,7 +879,7 @@ class Components(object):
878
879
  Type of port to create. ``CoaxPort`` generates solder balls.
879
880
  ``CircuitPort`` generates circuit ports on pins belonging to the net list.
880
881
  do_pingroup : bool
881
- True activate pingroup during port creation (only used with combination of CoaxPort),
882
+ True activate pingroup during port creation (only used with combination of CircPort),
882
883
  False will take the closest reference pin and generate one port per signal pin.
883
884
  refnet : string or list of string.
884
885
  list of the reference net.
@@ -1015,17 +1016,10 @@ class Components(object):
1015
1016
  else:
1016
1017
  self._logger.info("No pins found on component {} for the net {}".format(component, net))
1017
1018
  else:
1018
- ref_pin_group = self.create_pingroup_from_pins(ref_pins)
1019
- if not ref_pin_group:
1020
- self._logger.warning("failed to create reference pin group")
1021
- return False
1022
- ref_pin_group_term = self._create_pin_group_terminal(ref_pin_group, isref=True)
1023
1019
  for net in net_list:
1024
1020
  pins = [pin for pin in cmp_pins if pin.GetNet().GetName() == net]
1025
1021
  for pin in pins:
1026
- pin_group = self.create_pingroup_from_pins([pin])
1027
- pin_group_term = self._create_pin_group_terminal(pin_group, isref=False)
1028
- pin_group_term.SetReferenceTerminal(ref_pin_group_term)
1022
+ self.create_port_on_pins(component, pin, ref_pins)
1029
1023
  return True
1030
1024
 
1031
1025
  @pyedb_function_handler()
@@ -1334,7 +1328,7 @@ class Components(object):
1334
1328
  return True
1335
1329
 
1336
1330
  @pyedb_function_handler()
1337
- def _create_pin_group_terminal(self, pingroup, isref=False, term_name=None):
1331
+ def _create_pin_group_terminal(self, pingroup, isref=False, term_name=None, term_type="circuit"):
1338
1332
  """Creates an EDB pin group terminal from a given EDB pin group.
1339
1333
 
1340
1334
  Parameters
@@ -1342,10 +1336,13 @@ class Components(object):
1342
1336
  pingroup : Edb pin group.
1343
1337
 
1344
1338
  isref : bool
1339
+ Specify if this terminal a reference terminal.
1345
1340
 
1346
1341
  term_name : Terminal name (Optional). If not provided default name is Component name, Pin name, Net name.
1347
1342
  str.
1348
1343
 
1344
+ term_type: Type of terminal, gap, circuit or auto.
1345
+ str.
1349
1346
  Returns
1350
1347
  -------
1351
1348
  Edb pin group terminal.
@@ -1359,6 +1356,10 @@ class Components(object):
1359
1356
  pingroup_term = self._edb.cell.terminal.PinGroupTerminal.Create(
1360
1357
  self._active_layout, pingroup.GetNet(), term_name, pingroup, isref
1361
1358
  )
1359
+ if term_type == "circuit":
1360
+ pingroup_term.SetIsCircuitPort(True)
1361
+ elif term_type == "auto":
1362
+ pingroup_term.SetIsAutoPort(True)
1362
1363
  return pingroup_term
1363
1364
 
1364
1365
  @pyedb_function_handler()
@@ -1450,7 +1451,7 @@ class Components(object):
1450
1451
  def create(
1451
1452
  self,
1452
1453
  pins,
1453
- component_name,
1454
+ component_name=None,
1454
1455
  placement_layer=None,
1455
1456
  component_part_name=None,
1456
1457
  is_rlc=False,
@@ -1496,6 +1497,8 @@ class Components(object):
1496
1497
  >>> edbapp.components.create(pins, "A1New")
1497
1498
 
1498
1499
  """
1500
+ if not component_name:
1501
+ component_name = generate_unique_name("Comp_")
1499
1502
  if component_part_name:
1500
1503
  compdef = self._getComponentDefinition(component_part_name, pins)
1501
1504
  else:
@@ -2292,7 +2295,7 @@ class Components(object):
2292
2295
  Filter on the net name as an alternative to
2293
2296
  ``pinName``. The default is ``None``.
2294
2297
  pinName : str, optional
2295
- Filter on the pin name an an alternative to
2298
+ Filter on the pin name an alternative to
2296
2299
  ``netName``. The default is ``None``.
2297
2300
 
2298
2301
  Returns
@@ -383,6 +383,7 @@ class Configuration:
383
383
  elif src_type == "current":
384
384
  src_obj = self._pedb.create_current_source(pos_terminal, neg_terminal)
385
385
  src_obj.magnitude = src["magnitude"]
386
+ src_obj.name = name
386
387
 
387
388
  @pyedb_function_handler
388
389
  def _load_setups(self):
@@ -401,6 +402,13 @@ class Configuration:
401
402
  self._pedb.logger.warning("Setup {} already existing. Editing it.".format(name))
402
403
  edb_setup = self._pedb.setups[name]
403
404
  edb_setup.set_dc_slider(setup["dc_slider_position"])
405
+ dc_ir_settings = setup.get("dc_ir_settings", None)
406
+ if dc_ir_settings:
407
+ for k, v in dc_ir_settings.items():
408
+ if k not in dir(edb_setup.dc_ir_settings):
409
+ self._pedb.logger.error(f"Invalid keyword {k}")
410
+ else:
411
+ setattr(edb_setup.dc_ir_settings, k, v)
404
412
  else:
405
413
  if setup_type.lower() == "hfss":
406
414
  if name not in self._pedb.setups:
@@ -553,13 +561,21 @@ class Configuration:
553
561
  @pyedb_function_handler
554
562
  def _load_pin_groups(self):
555
563
  """Imports pin groups information from JSON."""
564
+ comps = self._pedb.components.components
556
565
  for pg in self.data["pin_groups"]:
557
566
  name = pg["name"]
558
567
  ref_designator = pg["reference_designator"]
559
568
  if "pins" in pg:
560
569
  self._pedb.siwave.create_pin_group(ref_designator, pg["pins"], name)
561
570
  elif "net" in pg:
562
- self._pedb.siwave.create_pin_group_on_net(ref_designator, pg["net"], name)
571
+ nets = pg["net"]
572
+ nets = nets if isinstance(nets, list) else [nets]
573
+ comp = comps[ref_designator]
574
+ pins = [p for p, obj in comp.pins.items() if obj.net_name in nets]
575
+ self._pedb.siwave.create_pin_group(ref_designator, pins, name)
576
+ else:
577
+ pins = [i for i in comps[ref_designator].pins.keys()]
578
+ self._pedb.siwave.create_pin_group(ref_designator, pins, name)
563
579
 
564
580
  @pyedb_function_handler
565
581
  def _load_nets(self):
@@ -692,7 +708,11 @@ class Configuration:
692
708
  name = pkgd["name"]
693
709
  if name in self._pedb.definitions.package:
694
710
  self._pedb.definitions.package[name].delete()
695
- package_def = PackageDef(self._pedb, name=name)
711
+ extent_bounding_box = pkgd.get("extent_bounding_box", None)
712
+ if extent_bounding_box:
713
+ package_def = PackageDef(self._pedb, name=name, extent_bounding_box=extent_bounding_box)
714
+ else:
715
+ package_def = PackageDef(self._pedb, name=name, component_part_name=pkgd["component_definition"])
696
716
  package_def.maximum_power = pkgd["maximum_power"]
697
717
  package_def.therm_cond = pkgd["therm_cond"]
698
718
  package_def.theta_jb = pkgd["theta_jb"]
@@ -708,6 +728,18 @@ class Configuration:
708
728
  heatsink["fin_spacing"],
709
729
  heatsink["fin_thickness"],
710
730
  )
711
- json_comps = pkgd["components"] if isinstance(pkgd["components"], list) else [pkgd["components"]]
712
- for i in json_comps:
713
- comps[i].package_def = name
731
+
732
+ comp_def_name = pkgd["component_definition"]
733
+ comp_def = self._pedb.definitions.component[comp_def_name]
734
+
735
+ comp_list = dict()
736
+ if pkgd["apply_to_all"]:
737
+ comp_list.update(
738
+ {refdes: comp for refdes, comp in comp_def.components.items() if refdes not in pkgd["components"]}
739
+ )
740
+ else:
741
+ comp_list.update(
742
+ {refdes: comp for refdes, comp in comp_def.components.items() if refdes in pkgd["components"]}
743
+ )
744
+ for _, i in comp_list.items():
745
+ i.package_def = name
@@ -23,7 +23,7 @@
23
23
  import os
24
24
 
25
25
  from pyedb.dotnet.edb_core.definition.component_model import NPortComponentModel
26
- from pyedb.dotnet.edb_core.edb_data.obj_base import ObjBase
26
+ from pyedb.dotnet.edb_core.obj_base import ObjBase
27
27
  from pyedb.generic.general_methods import pyedb_function_handler
28
28
 
29
29
 
@@ -20,7 +20,7 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
- from pyedb.dotnet.edb_core.edb_data.obj_base import ObjBase
23
+ from pyedb.dotnet.edb_core.obj_base import ObjBase
24
24
  from pyedb.generic.general_methods import pyedb_function_handler
25
25
 
26
26
 
@@ -20,7 +20,7 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
- from pyedb.dotnet.edb_core.edb_data.obj_base import ObjBase
23
+ from pyedb.dotnet.edb_core.obj_base import ObjBase
24
24
 
25
25
 
26
26
  class DefinitionObj(ObjBase):
@@ -40,17 +40,23 @@ class Definitions:
40
40
  return {l.GetName(): PackageDef(self._pedb, l) for l in list(self._pedb.active_db.PackageDefs)}
41
41
 
42
42
  @pyedb_function_handler
43
- def add_package_def(self, name):
43
+ def add_package_def(self, name, component_part_name=None, boundary_points=None):
44
44
  """Add a package definition.
45
45
 
46
46
  Parameters
47
47
  ----------
48
48
  name: str
49
49
  Name of the package definition.
50
+ component_part_name : str, optional
51
+ Part name of the component.
52
+ boundary_points : list, optional
53
+ Boundary points which define the shape of the package.
50
54
 
51
55
  Returns
52
56
  -------
53
57
 
54
58
  """
55
- package_def = PackageDef(self._pedb, name=name)
59
+ package_def = PackageDef(
60
+ self._pedb, name=name, component_part_name=component_part_name, extent_bounding_box=boundary_points
61
+ )
56
62
  return package_def
@@ -20,8 +20,8 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
- from pyedb.dotnet.edb_core.dotnet.database import PolygonDataDotNet
24
- from pyedb.dotnet.edb_core.edb_data.obj_base import ObjBase
23
+ from pyedb.dotnet.edb_core.geometry.polygon_data import PolygonData
24
+ from pyedb.dotnet.edb_core.obj_base import ObjBase
25
25
  from pyedb.generic.general_methods import pyedb_function_handler
26
26
 
27
27
 
@@ -33,19 +33,24 @@ class PackageDef(ObjBase):
33
33
  pedb : :class:`pyedb.edb`
34
34
  Edb object.
35
35
  edb_object : object
36
- Edb PackageDef Object
36
+ Edb PackageDef Object
37
+ component_part_name : str, optional
38
+ Part name of the component.
39
+ extent_bounding_box : list, optional
40
+ Bounding box defines the shape of the package. For example, [[0, 0], ["2mm", "2mm"].
41
+
37
42
  """
38
43
 
39
- def __init__(self, pedb, edb_object=None, name=None):
40
- self._pedb = pedb
41
- if edb_object is None and name is not None:
42
- self._edb_object = self.__create_from_name(name)
44
+ def __init__(self, pedb, edb_object=None, name=None, component_part_name=None, extent_bounding_box=None):
45
+ super().__init__(pedb, edb_object)
46
+ if self._edb_object is None and name is not None:
47
+ self._edb_object = self.__create_from_name(name, component_part_name, extent_bounding_box)
43
48
  else:
44
49
  self._edb_object = edb_object
45
50
 
46
51
  @pyedb_function_handler
47
- def __create_from_name(self, name):
48
- """Create a package defininitiion.
52
+ def __create_from_name(self, name, component_part_name=None, extent_bounding_box=None):
53
+ """Create a package definition.
49
54
 
50
55
  Parameters
51
56
  ----------
@@ -58,13 +63,18 @@ class PackageDef(ObjBase):
58
63
  EDB PackageDef Object
59
64
  """
60
65
  edb_object = self._pedb.edb_api.definition.PackageDef.Create(self._pedb.active_db, name)
61
- pointA = self._pedb.edb_api.geometry.point_data(
62
- self._pedb.edb_value(0),
63
- self._pedb.edb_value(0),
64
- )
66
+ if component_part_name:
67
+ x_pt1, y_pt1, x_pt2, y_pt2 = list(
68
+ self._pedb.components.definitions[component_part_name].components.values()
69
+ )[0].bounding_box
70
+ x_mid = (x_pt1 + x_pt2) / 2
71
+ y_mid = (y_pt1 + y_pt2) / 2
72
+ bbox = [[y_pt1 - y_mid, x_pt1 - x_mid], [y_pt2 - y_mid, x_pt2 - x_mid]]
73
+ else:
74
+ bbox = extent_bounding_box
75
+ polygon_data = PolygonData(self._pedb, create_from_bounding_box=True, points=bbox)
65
76
 
66
- polygon = PolygonDataDotNet(self._pedb).create_from_bbox([pointA, pointA])
67
- edb_object.SetExteriorBoundary(polygon)
77
+ edb_object.SetExteriorBoundary(polygon_data._edb_object)
68
78
  return edb_object
69
79
 
70
80
  @pyedb_function_handler
@@ -72,6 +82,15 @@ class PackageDef(ObjBase):
72
82
  """Delete a package definition object from the database."""
73
83
  return self._edb_object.Delete()
74
84
 
85
+ @property
86
+ def exterior_boundary(self):
87
+ """Get the exterior boundary of a package definition."""
88
+ return PolygonData(self._pedb, self._edb_object.GetExteriorBoundary()).points
89
+
90
+ @exterior_boundary.setter
91
+ def exterior_boundary(self, value):
92
+ self._edb_object.SetExteriorBoundary(value._edb_object)
93
+
75
94
  @property
76
95
  def maximum_power(self):
77
96
  """Maximum power of the package."""
@@ -721,10 +721,11 @@ class EdbDotNet(object):
721
721
  """Initialize DLLs."""
722
722
  from pyedb.dotnet.clr_module import _clr, edb_initialized
723
723
 
724
- if settings.enable_screen_logs:
725
- self._logger.enable_stdout_log()
726
- else: # pragma: no cover
727
- self._logger.disable_stdout_log()
724
+ if not settings.use_pyaedt_log:
725
+ if settings.enable_screen_logs:
726
+ self._logger.enable_stdout_log()
727
+ else: # pragma: no cover
728
+ self._logger.disable_stdout_log()
728
729
  if not edb_initialized: # pragma: no cover
729
730
  self._logger.error("Failed to initialize Dlls.")
730
731
  return
@@ -329,7 +329,7 @@ class EDBComponent(object):
329
329
 
330
330
  @solder_ball_height.setter
331
331
  def solder_ball_height(self, value):
332
- if "GetSolderBallProperty" in dir(self.component_property) and value:
332
+ if "GetSolderBallProperty" in dir(self.component_property):
333
333
  sball_height = round(self._edb.utility.Value(value).ToDouble(), 9)
334
334
  cmp_property = self.component_property
335
335
  solder_ball_prop = cmp_property.GetSolderBallProperty().Clone()
@@ -20,7 +20,7 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
- from pyedb.dotnet.edb_core.edb_data.obj_base import ObjBase
23
+ from pyedb.dotnet.edb_core.obj_base import ObjBase
24
24
  from pyedb.generic.general_methods import pyedb_function_handler
25
25
 
26
26
 
@@ -563,8 +563,9 @@ class StackupLayerEdbClass(LayerEdbClass):
563
563
  else:
564
564
  material_data = layer["material"]
565
565
  if material_data is not None:
566
- self._pclass._pedb.materials.add_material(**material_data)
567
- self.material = layer["material"]["name"]
566
+ material_name = layer["material"]["name"]
567
+ self._pclass._pedb.materials.add_material(material_name, **material_data)
568
+ self.material = material_name
568
569
  if layer["dielectric_fill"]:
569
570
  if isinstance(layer["dielectric_fill"], str):
570
571
  self.dielectric_fill = layer["dielectric_fill"]
@@ -888,7 +888,7 @@ class EdbPath(EDBPrimitives, PathDotNet):
888
888
  return self._app.hfss.create_edge_port_vertical(self.id, pos, name, 50, reference_layer)
889
889
 
890
890
  @pyedb_function_handler()
891
- def create_via_fence(self, distance, gap, padstack_name):
891
+ def create_via_fence(self, distance, gap, padstack_name, net_name="GND"):
892
892
  """Create via fences on both sides of the trace.
893
893
 
894
894
  Parameters
@@ -899,6 +899,8 @@ class EdbPath(EDBPrimitives, PathDotNet):
899
899
  Gap between vias.
900
900
  padstack_name: str
901
901
  Name of the via padstack.
902
+ net_name: str, optional
903
+ Name of the net.
902
904
 
903
905
  Returns
904
906
  -------
@@ -990,7 +992,7 @@ class EdbPath(EDBPrimitives, PathDotNet):
990
992
  center_line = self.get_center_line()
991
993
  leftline, rightline = getParalletLines(center_line, distance)
992
994
  for x, y in getLocations(rightline, gap) + getLocations(leftline, gap):
993
- self._pedb.padstacks.place([x, y], padstack_name)
995
+ self._pedb.padstacks.place([x, y], padstack_name, net_name=net_name)
994
996
 
995
997
 
996
998
  class EdbRectangle(EDBPrimitives, RectangleDotNet):
@@ -27,6 +27,7 @@ from pyedb.dotnet.edb_core.general import (
27
27
  convert_pydict_to_netdict,
28
28
  )
29
29
  from pyedb.dotnet.edb_core.utilities.simulation_setup import BaseSimulationSetup
30
+ from pyedb.dotnet.sim_setup_data.data.siw_dc_ir_settings import SiwaveDCIRSettings
30
31
  from pyedb.generic.general_methods import is_linux, pyedb_function_handler
31
32
 
32
33
 
@@ -1144,6 +1145,11 @@ class SiwaveDCSimulationSetup(SiwaveSYZSimulationSetup):
1144
1145
  self.set_dc_slider(1)
1145
1146
  return self
1146
1147
 
1148
+ @property
1149
+ def dc_ir_settings(self):
1150
+ """DC IR settings."""
1151
+ return SiwaveDCIRSettings(self)
1152
+
1147
1153
  @pyedb_function_handler
1148
1154
  def get_configurations(self):
1149
1155
  """Get SIwave DC simulation settings.
File without changes
@@ -21,31 +21,17 @@
21
21
  # SOFTWARE.
22
22
 
23
23
 
24
- class ObjBase(object):
25
- """Manages EDB functionalities for a base object."""
24
+ class PointData:
25
+ """Point Data."""
26
26
 
27
- def __init__(self, pedb, edb_object):
27
+ def __init__(self, pedb, edb_object=None, x=None, y=None):
28
28
  self._pedb = pedb
29
- self._edb_object = edb_object
30
-
31
- @property
32
- def is_null(self):
33
- """Flag indicating if this object is null."""
34
- return self._edb_object.IsNull()
35
-
36
- @property
37
- def type(self):
38
- """Type of the edb object."""
39
- try:
40
- return self._edb_object.GetType()
41
- except AttributeError: # pragma: no cover
42
- return None
43
-
44
- @property
45
- def name(self):
46
- """Name of the definition."""
47
- return self._edb_object.GetName()
48
-
49
- @name.setter
50
- def name(self, value):
51
- self._edb_object.SetName(value)
29
+ if edb_object:
30
+ self._edb_object = edb_object
31
+ else:
32
+ x = x if x else 0
33
+ y = y if y else 0
34
+ self._edb_object = self._pedb.edb_api.geometry.point_data(
35
+ self._pedb.edb_value(x),
36
+ self._pedb.edb_value(y),
37
+ )
@@ -0,0 +1,77 @@
1
+ # Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
2
+ # SPDX-License-Identifier: MIT
3
+ #
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ from pyedb.dotnet.edb_core.geometry.point_data import PointData
24
+ from pyedb.dotnet.edb_core.obj_base import BBox
25
+ from pyedb.generic.general_methods import pyedb_function_handler
26
+
27
+
28
+ class PolygonData:
29
+ """Polygon Data."""
30
+
31
+ def __init__(
32
+ self,
33
+ pedb,
34
+ edb_object=None,
35
+ create_from_points=None,
36
+ create_from_circle=None,
37
+ create_from_rectangle=None,
38
+ create_from_bounding_box=None,
39
+ **kwargs,
40
+ ):
41
+ self._pedb = pedb
42
+
43
+ if create_from_points:
44
+ self._edb_object = self.create_from_points(**kwargs)
45
+ elif create_from_circle:
46
+ x_center, y_center, radius = kwargs
47
+ elif create_from_rectangle:
48
+ x_lower_left, y_lower_left, x_upper_right, y_upper_right = kwargs
49
+ elif create_from_bounding_box:
50
+ self._edb_object = self.create_from_bounding_box(**kwargs)
51
+ else: # pragma: no cover
52
+ self._edb_object = edb_object
53
+
54
+ @property
55
+ def points(self):
56
+ """Get all points in polygon.
57
+
58
+ Returns
59
+ -------
60
+ list[list[float]]
61
+ """
62
+ return [
63
+ [self._pedb.edb_value(i.X).ToDouble(), self._pedb.edb_value(i.Y).ToDouble()]
64
+ for i in list(self._edb_object.Points)
65
+ ]
66
+
67
+ @pyedb_function_handler
68
+ def create_from_points(self, points, closed=True):
69
+ list_of_point_data = []
70
+ for pt in points:
71
+ list_of_point_data.append(PointData(self._pedb, x=pt[0], y=pt[1]))
72
+ return self._pedb.edb_api.geometry.api_class.PolygonData(list_of_point_data, closed)
73
+
74
+ @pyedb_function_handler
75
+ def create_from_bounding_box(self, points):
76
+ bbox = BBox(self._pedb, point_1=points[0], point_2=points[1])
77
+ return self._pedb.edb_api.geometry.api_class.PolygonData.CreateFromBBox(bbox._edb_object)