Skip to content

Commit a752dd6

Browse files
authored
FIX: Nport model find missing (#395)
1 parent afe3bad commit a752dd6

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

src/ansys/edb/core/definition/component_def.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,31 @@ def component_pins(self):
9898
"""
9999
objs = self.__stub.GetComponentPins(self.msg).items
100100
return map_list(objs, component_pin.ComponentPin)
101+
102+
def add_component_model(self, value):
103+
"""Add a component model to this component def.
104+
105+
Parameters
106+
----------
107+
value : :class:`Component Model <ansys.edb.core.definition.ComponentModel>`
108+
Component Model to be added.
109+
110+
Notes
111+
-----
112+
Once a component model is added to one component def, it cannot be added to any other, even when removed.
113+
"""
114+
self.__stub.AddComponentModel(messages.pointer_property_message(self, value))
115+
116+
def remove_component_model(self, value):
117+
"""Remove a component model from this component def.
118+
119+
Parameters
120+
----------
121+
value : :class:`Component Model <ansys.edb.core.definition.ComponentModel>`
122+
Component Model to be removed.
123+
124+
Notes
125+
-----
126+
Once a component model is added to one component def, it cannot be added to any other, even when removed.
127+
"""
128+
self.__stub.RemoveComponentModel(messages.pointer_property_message(self, value))

src/ansys/edb/core/definition/component_model.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,44 @@ def reference_file(self):
2424
def reference_file(self, value):
2525
self.__stub.SetReferenceFile(messages.string_property_message(self, value))
2626

27+
@classmethod
28+
def find_by_name(cls, comp_def, value):
29+
"""Find a component model by name in a given component def.
30+
31+
Parameters
32+
----------
33+
comp_def : :class:`ComponentDef <ansys.edb.core.definition.ComponentDef>`
34+
Component def to search for the component model.
35+
value : str
36+
Name of the component model.
37+
38+
Returns
39+
-------
40+
ComponentModel
41+
Component model that is found, ``None`` otherwise.
42+
"""
43+
return ComponentModel(
44+
cls.__stub.FindByName(messages.string_property_message(comp_def, value))
45+
)
46+
47+
@classmethod
48+
def find_by_id(cls, comp_def, value):
49+
"""Find a component model by ID in a given component def.
50+
51+
Parameters
52+
----------
53+
comp_def : :class:`ComponentDef <ansys.edb.core.definition.ComponentDef>`
54+
Component def to search for the component model.
55+
value : int
56+
ID of the component model.
57+
58+
Returns
59+
-------
60+
ComponentModel
61+
Component model that is found, ``None`` otherwise.
62+
"""
63+
return ComponentModel(cls.__stub.FindById(messages.int_proprty_message(comp_def, value)))
64+
2765

2866
class NPortComponentModel(ComponentModel):
2967
"""Represents an NPort component model."""

0 commit comments

Comments
 (0)