-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
"ValueError: Cannot parse '470' to resistance" (populate) #117
Comments
Can confirm this is a bug, and I can pin-point what is the cause of the crash. |
That Pcbdraw doesn't accept values without any marking is on purpose - all the schematics that I have ever worked with never used raw numbers to mark the resistance. Therefore, a raw number was considered an error that should be reported to the user, and they should review if there is an error or not. @dhaillant Do you commonly use "ohm" values without any marking? Is it a common practice? If so, I will be happy to change the behavior. |
@yaqwsx Even with the marking, for example |
|
I am of the personal opinion that it should, as most schematic do not bother to add the unit if the symbol is clearly a resistor. |
Personally, for resistors, I use 470 without unit in my schematics, when there's no confusion possible (when the symbol is clearly a resistor). I did some quick research and found many different ways among magazines, service manuals, open source schematics etc. Now, I was wondering how the script handles values such as 4k7, 4.7k, 4.7R, 4R7, 0.47, 0R47, 4700k etc? Thanks! |
As currently implemented and with my fix (PR #118), here how the script handles the numbers you have:
|
With my recent commit 04c0e01, I was able to get the resistance parsing function to properly parse all the examples you gave:
|
Nice! |
|
@Electro707 How could I test your version? Thanks :) |
@dhaillant You can clone my fork of this project and checkout the Then you can run |
Thank you very much @Electro707 ! david@b101p02:~/tmp/test/PcbDraw$ python -m pcbdraw.ui populate ~/elec/simple\ vca/1.0/populate.txt ~/elec/simple\ vca/1.0/img/ The above exception was the direct cause of the following exception: Traceback (most recent call last): I'm not familiar with python, so I have no idea if I'm using it the right way... |
The reason for that is incompatibility introduced in KiCAD 6.0.8. The current PcbDraw upstream already addresses this, @Electro707's fork, did not. |
@dhaillant Which branch are you on? If you are on |
@Electro707 I'm on |
Hello,
I'm trying to use the res_band feature with populate.
I get this error:
Traceback (most recent call last):
File "/home/david/.local/bin/pcbdraw", line 8, in
sys.exit(run())
File "/home/david/.local/lib/python3.8/site-packages/click/core.py", line 1128, in call
return self.main(*args, **kwargs)
File "/home/david/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/home/david/.local/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/david/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/david/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/home/david/.local/lib/python3.8/site-packages/pcbdraw/populate.py", line 300, in populate
parsed_content = generate_images(parsed_content, board, prepare_params(header["params"]),
File "/home/david/.local/lib/python3.8/site-packages/pcbdraw/populate.py", line 193, in generate_images
generate_image(boardfilename, x["side"], x["components"],
File "/home/david/.local/lib/python3.8/site-packages/pcbdraw/populate.py", line 212, in generate_image
plot.main(args=plot_args)
File "/home/david/.local/lib/python3.8/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/home/david/.local/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/david/.local/lib/python3.8/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/home/david/.local/lib/python3.8/site-packages/pcbdraw/ui.py", line 174, in plot
image = plotter.plot()
File "/home/david/.local/lib/python3.8/site-packages/pcbdraw/plot.py", line 1053, in plot
plotter.render(self)
File "/home/david/.local/lib/python3.8/site-packages/pcbdraw/plot.py", line 812, in render
plotter.walk_components(invert_side=False, callback=self._append_component)
File "/home/david/.local/lib/python3.8/site-packages/pcbdraw/plot.py", line 1084, in walk_components
callback(lib, name, ref, value, pos)
File "/home/david/.local/lib/python3.8/site-packages/pcbdraw/plot.py", line 840, in _append_component
ret = self._create_component(lib, name, ref, value)
File "/home/david/.local/lib/python3.8/site-packages/pcbdraw/plot.py", line 890, in _create_component
self._apply_resistor_code(component_element, id_prefix, ref, value)
File "/home/david/.local/lib/python3.8/site-packages/pcbdraw/plot.py", line 912, in _apply_resistor_code
res, tolerance = self._get_resistance_from_value(value)
File "/home/david/.local/lib/python3.8/site-packages/pcbdraw/plot.py", line 947, in _get_resistance_from_value
res = read_resistance(value_l[0])
File "/home/david/.local/lib/python3.8/site-packages/pcbdraw/unit.py", line 39, in read_resistance
raise ValueError(f"Cannot parse '{value}' to resistance")
ValueError: Cannot parse '470' to resistance
If I understand correctly, the value '470' is retrieved from the .kicad_pcb file.
The script parses correctly an other value (100k) and generates correctly the corresponding picture.
Also, in this case I use the default resistor footprint. Not my custom one (see other issue #116 )
Thank you.
The text was updated successfully, but these errors were encountered: