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

Fix some of the issues to get it working #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

phodina
Copy link

@phodina phodina commented Oct 18, 2024

Hi @hoijui ,
wanted to get some Data matrix placed on the PCB board but failed.

Had to do some fixes and in the end still could not get it working as there are some issues in the pcbnew Python wrapper.

python3 placeholder2image.py --input ~/qr-code/qr-code.kicad_pcb gitlab.png 
Traceback (most recent call last):
  File "/home/cylon2p0/kicad-image-injector/placeholder2image.py", line 364, in <module>
    replace_all_cli()
  File "/usr/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cylon2p0/kicad-image-injector/placeholder2image.py", line 359, in replace_all_cli
    replace_all(pcb, images_root, repl_identifiers)
  File "/home/cylon2p0/kicad-image-injector/placeholder2image.py", line 306, in replace_all
    replace_all_with(pcb, placeholders, pixels_sources)
  File "/home/cylon2p0/kicad-image-injector/placeholder2image.py", line 287, in replace_all_with
    repl.drawPixels()
  File "/home/cylon2p0/kicad-image-injector/placeholder2image.py", line 194, in drawPixels
    self._drawPixel(footprint, pixel_i, pos)
  File "/home/cylon2p0/kicad-image-injector/placeholder2image.py", line 181, in _drawPixel
    footprint.Add(self._createAxisAlignedRect(footprint, pos, self.size_pixel))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cylon2p0/kicad-image-injector/placeholder2image.py", line 167, in _createAxisAlignedRect
    polygon = pcbnew.FP_SHAPE(footprint)
              ^^^^^^^^^^^^^^^
AttributeError: module 'pcbnew' has no attribute 'FP_SHAPE'

Also the image Converter does terrible job.

image

@hoijui
Copy link
Owner

hoijui commented Oct 19, 2024

ahh.. (KiCad) updates!
Terrible API; huge random changes in naming without a guide for updating.

"image Converter does terrible job"
Can you be more specific?
You mean the "roundish" pixels?

If you have a look at the sample image in the README:

![]|(https://github.com/hoijui/kicad-image-injector/raw/master/kicad-board-1-generated.svg)

you can see the same rounded pixels "issue" there, but only on one of the images.
I don't know by heart which layer that is, but it must be either the printing or the copper layer, and my guess is the copper one. I think it has to do with the way this layer gets constructed, and that it can not do sharp edges ... ?

Also.. sorry, I have no time nor mood to look into this.

And sorry for not writing in the README which version I made it work with! :/
Looks like the last update to the code was on Mar 4, 2022; which was the latest KiCad version at that time?
-> KiCad 6.0.2

we are now at KiCad 8.0.4, which I guess is what you are using.. two mayor versions later.. ouch! :/
... good luck!

@phodina
Copy link
Author

phodina commented Oct 19, 2024

ahh.. (KiCad) updates!
Terrible API; huge random changes in naming without a guide for updating.

Well they are good and bad :-D

"image Converter does terrible job"
Can you be more specific?
You mean the "roundish" pixels?

The image Coverter it creates round pixels so the image is unusable.

you can see the same rounded pixels "issue" there, but only on one of the images.
I don't know by heart which layer that is, but it must be either the printing or the copper layer, and my guess is the copper one. I think it has to do with the way this layer gets constructed, and that it can not do sharp edges ... ?

Thanks will try the different layers

Also.. sorry, I have no time nor mood to look into this.

Understood. Just a thought do you think adding the feature to Kicad directly would be better than making a plugin? It would have to be compatible with X versions.

And sorry for not writing in the README which version I made it work with! :/
Looks like the last update to the code was on Mar 4, 2022; which was the latest KiCad version at that time?
-> KiCad 6.0.2

Well I use Kicad 8.0.2

we are now at KiCad 8.0.4, which I guess is what you are using.. two mayor versions later.. ouch! :/
... good luck!

On that note I use NixOS so could I just build the Kicad package 6.0.2 (or download from the binary cache), run the script on dummy PCB and then import it into the newer Kicad 8.0.2?

@phodina
Copy link
Author

phodina commented Oct 19, 2024

image

Tried all 8 options there but none worked

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

Successfully merging this pull request may close these issues.

2 participants