diff --git a/_unittest/example_models/T21/test.lib b/_unittest/example_models/T21/test.lib index c1be06decfb..e43d824673d 100644 --- a/_unittest/example_models/T21/test.lib +++ b/_unittest/example_models/T21/test.lib @@ -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 \ No newline at end of file diff --git a/_unittest/test_40_3dlayout_edb.py b/_unittest/test_01_3dlayout_edb.py similarity index 100% rename from _unittest/test_40_3dlayout_edb.py rename to _unittest/test_01_3dlayout_edb.py diff --git a/_unittest/test_41_3dlayout_modeler.py b/_unittest/test_01_3dlayout_modeler.py similarity index 100% rename from _unittest/test_41_3dlayout_modeler.py rename to _unittest/test_01_3dlayout_modeler.py diff --git a/_unittest/test_42_configuration_files.py b/_unittest/test_01_configuration_files.py similarity index 100% rename from _unittest/test_42_configuration_files.py rename to _unittest/test_01_configuration_files.py diff --git a/_unittest/test_17_SBR.py b/_unittest/test_04_SBR.py similarity index 100% rename from _unittest/test_17_SBR.py rename to _unittest/test_04_SBR.py diff --git a/_unittest/test_21_Circuit.py b/_unittest/test_21_Circuit.py index 3047a83d31f..86196685f53 100644 --- a/_unittest/test_21_Circuit.py +++ b/_unittest/test_21_Circuit.py @@ -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 diff --git a/_unittest_ironpython/test_17_SBR.py b/_unittest_ironpython/test_01_3dlayout_edb.py similarity index 100% rename from _unittest_ironpython/test_17_SBR.py rename to _unittest_ironpython/test_01_3dlayout_edb.py diff --git a/_unittest_ironpython/test_40_3dlayout_edb.py b/_unittest_ironpython/test_01_configuration_files.py similarity index 100% rename from _unittest_ironpython/test_40_3dlayout_edb.py rename to _unittest_ironpython/test_01_configuration_files.py diff --git a/_unittest_ironpython/test_42_configuration_files.py b/_unittest_ironpython/test_04_SBR.py similarity index 100% rename from _unittest_ironpython/test_42_configuration_files.py rename to _unittest_ironpython/test_04_SBR.py diff --git a/pyaedt/edb_core/dotnet/primitive.py b/pyaedt/edb_core/dotnet/primitive.py index 1bb8c5e8abd..5e753850f73 100644 --- a/pyaedt/edb_core/dotnet/primitive.py +++ b/pyaedt/edb_core/dotnet/primitive.py @@ -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 `: Outer contour of the Polygon object.""" diff --git a/pyaedt/edb_core/edb_data/primitives_data.py b/pyaedt/edb_core/edb_data/primitives_data.py index 268b247f988..012d581790e 100644 --- a/pyaedt/edb_core/edb_data/primitives_data.py +++ b/pyaedt/edb_core/edb_data/primitives_data.py @@ -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.") diff --git a/pyaedt/modeler/circuits/PrimitivesNexxim.py b/pyaedt/modeler/circuits/PrimitivesNexxim.py index 965faa1eaab..75cabc9513a 100644 --- a/pyaedt/modeler/circuits/PrimitivesNexxim.py +++ b/pyaedt/modeler/circuits/PrimitivesNexxim.py @@ -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 @@ -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: @@ -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)