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

"AttributeError: 'NoneType' object has no attribute 'attrib'" when using "res_band" in custom footprint #116

Open
dhaillant opened this issue Sep 26, 2022 · 3 comments

Comments

@dhaillant
Copy link

I'm creating a set of custom footprints for PcbDraw.
And lately, I tried to add the res_band feature for the axial resistors, with no luck.

Once I add a rectangle named res_band1, pcbdraw crashes with this message:

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 928, in _apply_resistor_code
s = band.attrib["style"].split(";")
AttributeError: 'NoneType' object has no attribute 'attrib'

The rectangle is copied/pasted from one of the resistors in pcbdraw-lib.

Inkscape is V1.2 (1:1.2.1+202207142221+cd75a1ee6d)

Is there any setting, configuration that must be applied to the svg for the res_band feature to be recognized?

Thanks!

@dhaillant
Copy link
Author

BTW, this is with populate command.

@Electro707
Copy link
Contributor

Did you add the other res_bands (from 1 to 4)? This could be because it is crashing when it is trying to find the other bands after it finds the first one

@dhaillant
Copy link
Author

Indeed, it looks like in my first attempt, somehow the script couldn't find one or more of the 3 next bands.

So I copy/pasted the 4 bands at once from a resistor in the official lib to my custom lib and now it works.
As @Electro707 suggested, if I remove just one of the 3 bands (not the #1), it rises this error.

I think I understand what happened: In my first attempt, I copy/pasted only one band and renamed it. This was clearly not the right method.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants