Skip to content

Commit

Permalink
Merge branch 'main' into release/0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcapodi78 authored and maxcapodi78 committed Jul 27, 2023
2 parents 19cca01 + 1569eac commit f0febf1
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 4 deletions.
12 changes: 12 additions & 0 deletions _unittest/example_models/T21/test.lib
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,16 @@

.subckt GRM2345 Port1 Port2
C1 Port1 Port2 1e-12
.ends

.subckt GRM5678 Port1 Port2
C1 Port1 Port2 1e-12
.ends

.subckt GRM6789 Port1 Port2
C1 Port1 Port2 1e-12
.ends

.subckt GRM9012 Port1 Port2
C1 Port1 Port2 1e-12
.ends
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions _unittest/test_21_Circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,18 @@ def test_29_create_circuit_from_spice(self):
assert self.aedtapp.modeler.schematic.create_component_from_spicemodel(model, "GRM2345", False)
assert not self.aedtapp.modeler.schematic.create_component_from_spicemodel(model, "GRM2346")

def test_29a_create_circuit_from_spice_edit_symbol(self):
model = os.path.join(local_path, "example_models", test_subfolder, "test.lib")
assert self.aedtapp.modeler.schematic.create_component_from_spicemodel(
model_path=model, model_name="GRM5678", symbol_name="nexx_cap"
)
assert self.aedtapp.modeler.schematic.create_component_from_spicemodel(
model_path=model, model_name="GRM6789", symbol_name="nexx_inductor"
)
assert self.aedtapp.modeler.schematic.create_component_from_spicemodel(
model_path=model, model_name="GRM9012", symbol_name="nexx_res"
)

def test_30_create_subcircuit(self):
subcircuit = self.aedtapp.modeler.schematic.create_subcircuit(location=[0.0, 0.0], angle=0)
assert type(subcircuit.location) is list
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions pyaedt/edb_core/dotnet/primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ def padstack_instance(self):
def net(self):
return self.prim_obj.GetNet()

@net.setter
def net(self, value):
try:
if "net" in dir(value):
self.prim_obj.SetNet(value.net_obj)
else:
self.prim_obj.SetNet(value)
except TypeError:
self._app.logger.error("Error setting net object")

@property
def polygon_data(self):
""":class:`PolygonData <ansys.edb.geometry.PolygonData>`: Outer contour of the Polygon object."""
Expand Down
5 changes: 3 additions & 2 deletions pyaedt/edb_core/edb_data/primitives_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ def net_name(self):
@net_name.setter
def net_name(self, name):
if isinstance(name, str):
self.net.SetName(name)
net = self._app.nets.nets[name].net_object
self.primitive_object.SetNet(net)
else:
try:
self.net.SetName(name.GetName())
self.net = name
except:
self._app.logger.error("Failed to set net name.")

Expand Down
31 changes: 29 additions & 2 deletions pyaedt/modeler/circuits/PrimitivesNexxim.py
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,15 @@ def _parse_spice_model(self, model_path):
return models

@pyaedt_function_handler()
def create_component_from_spicemodel(self, model_path, model_name=None, create_component=True, location=None):
def create_component_from_spicemodel(
self,
model_path,
model_name=None,
create_component=True,
location=None,
symbol_path="Nexxim Circuit Elements\\Nexxim_symbols:",
symbol_name="",
):
"""Create and place a new component based on a spice .lib file.
Parameters
Expand All @@ -1801,11 +1809,27 @@ def create_component_from_spicemodel(self, model_path, model_name=None, create_c
If set to ``True``, create a spice model component. Otherwise, only import the spice model.
location : list, optional
Position in the schematic of the new component.
symbol_path : str, optional
Path to the symbol library.
Default value is ``"Nexxim Circuit Elements\\Nexxim_symbols:"``.
symbol_name : str, optional
Symbol name to replace the spice model with.
Default value is an empty string which means the default symbol for spice is used.
Returns
-------
:class:`pyaedt.modeler.cad.object3dcircuit.CircuitComponent`
Circuit Component Object.
Examples
--------
>>> from pyaedt import Circuit
>>> cir = Circuit(specified_version="2023.2")
>>> model = os.path.join("Your path", "test.lib")
>>> cir.modeler.schematic.create_component_from_spicemodel(model_path=model,
>>> model_name="GRM1234",
>>> symbol_name="nexx_cap")
>>> cir.release_desktop(False, False)
"""
models = self._parse_spice_model(model_path)
if not model_name and models:
Expand All @@ -1817,7 +1841,10 @@ def create_component_from_spicemodel(self, model_path, model_name=None, create_c
for el in models:
arg2.append(el + ":=")
if el == model_name:
arg2.append([True, "", "", False])
if symbol_path and symbol_name:
arg2.append([True, symbol_path + symbol_name, "", False])
else:
arg2.append([True, "", "", False])
else:
arg2.append([False, "", "", False])
arg.append(arg2)
Expand Down

0 comments on commit f0febf1

Please sign in to comment.