Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Nport model find missing #395

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/ansys/edb/core/definition/component_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,31 @@ def component_pins(self):
"""
objs = self.__stub.GetComponentPins(self.msg).items
return map_list(objs, component_pin.ComponentPin)

def add_component_model(self, value):
"""Add a component model to this component def.

Parameters
----------
value : :class:`Component Model <ansys.edb.core.definition.ComponentModel>`
Component Model to be added.

Notes
-----
Once a component model is added to one component def, it cannot be added to any other, even when removed.
"""
self.__stub.AddComponentModel(messages.pointer_property_message(self, value))

def remove_component_model(self, value):
"""Remove a component model from this component def.

Parameters
----------
value : :class:`Component Model <ansys.edb.core.definition.ComponentModel>`
Component Model to be removed.

Notes
-----
Once a component model is added to one component def, it cannot be added to any other, even when removed.
"""
self.__stub.RemoveComponentModel(messages.pointer_property_message(self, value))
38 changes: 38 additions & 0 deletions src/ansys/edb/core/definition/component_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,44 @@ def reference_file(self):
def reference_file(self, value):
self.__stub.SetReferenceFile(messages.string_property_message(self, value))

@classmethod
def find_by_name(cls, comp_def, value):
"""Find a component model by name in a given component def.

Parameters
----------
comp_def : :class:`ComponentDef <ansys.edb.core.definition.ComponentDef>`
Component def to search for the component model.
value : str
Name of the component model.

Returns
-------
ComponentModel
Component model that is found, ``None`` otherwise.
"""
return ComponentModel(
cls.__stub.FindByName(messages.string_property_message(comp_def, value))
)

@classmethod
def find_by_id(cls, comp_def, value):
"""Find a component model by ID in a given component def.

Parameters
----------
comp_def : :class:`ComponentDef <ansys.edb.core.definition.ComponentDef>`
Component def to search for the component model.
value : int
ID of the component model.

Returns
-------
ComponentModel
Component model that is found, ``None`` otherwise.
"""
return ComponentModel(cls.__stub.FindById(messages.int_proprty_message(comp_def, value)))


class NPortComponentModel(ComponentModel):
"""Represents an NPort component model."""
Expand Down
Loading