Closed person678 closed 1 year ago
Hello Paul.
First of all thanks for your mail and your contribution. For what I see from the log, the line doesn't match the first condition, because it isn't the subcircuit it is expecting, but it is still a SpiceCircuit, and not a str object.
This is a bug on my code, and I deeply regret that this has driven you up the wall. I suggest you replace the code in line 377 to 379 on the spice_editor.py from
if isinstance(line, SpiceCircuit) and line.name() == subcircuit_name:
sub_circuit = line # The circuit was already found
break
to:
if isinstance(line, SpiceCircuit):
if line.name() == subcircuit_name:
sub_circuit = line # The circuit was already found
break
Let me know if this solves your problem. I'll make sure this will be integrated in the next revision of code.
Kindest regards and my sincere apologies for the inconvinience. Nuno
I've tested this and it now runs succesfully and looking at the netlists is correctly updating the components.
Even accounting for this problem this library is still going to save me mountains of time, so no apologies needed. Thank you very very much!
Hello, I'm running into the following error when trying to start a simulation in which I am editing a subcircuit component value, with the line netlist.set_component_value('XNonLin:RNL', '350') where netlist is an instance of SpiceEditor.
Traceback (most recent call last): File "c:\Users\Paul\OneDrive\Uni\Placement\Mackey-Glass-Circuit\LTSpice\PyLTSpice\PyLTSpiceTemplate.py", line 146, in
netlist.set_component_value('XNonLin:RNL', '350')
File "C:\Users\Paul.pyenv\pyenv-win\versions\3.10.11\lib\site-packages\PyLTSpice\sim\spice_editor.py", line 640, in set_component_value
self._set_model_and_value(device, value)
File "C:\Users\Paul.pyenv\pyenv-win\versions\3.10.11\lib\site-packages\PyLTSpice\sim\spice_editor.py", line 855, in _set_model_and_value
sub_circuit_original = self._get_subcircuit(modified_path) # If not will look of it.
File "C:\Users\Paul.pyenv\pyenv-win\versions\3.10.11\lib\site-packages\PyLTSpice\sim\spice_editor.py", line 381, in _get_subcircuit
m = lib_inc_regex.match(line) TypeError: expected string or bytes-like object
It seems to be expecting a string, however as far as I can tell I am using the netlist.set_component_value function exactly as described in the documentation? I've double and triple checked everything and cannot spot my mistake if I have made one. Given it's a type issue and I'm using the function as described, I'm thinking this might be a bug?
Appreciate any help and time given, this is driving me up the wall. Still very new to Python so please go easy on me if this is a rather obvious mistake I'm making. PyLTSpiceTemplate.txt