MitjaNemec / ReplicateLayout

GNU General Public License v2.0
97 stars 12 forks source link

Texts within footprints are misplaced after replicate layout #72

Closed showier-drastic closed 4 months ago

showier-drastic commented 5 months ago

bug-demo.zip

Before replication:

image

After replication:

image

Steps to reproduce:

KiCad Version info:

Application: KiCad PCB Editor arm64 on arm64

Version: 8.0.1-132-gf7765ea5b9, release build

Libraries:
    wxWidgets 3.2.4
    FreeType 2.13.2
    HarfBuzz 8.3.0
    FontConfig 2.15.0
    libcurl/8.4.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.58.0

Platform: macOS Sonoma Version 14.3.1 (Build 23D60), 64 bit, Little endian, wxMac

Build Info:
    Date: Apr 11 2024 05:41:36
    wxWidgets: 3.2.4 (wchar_t,wx containers)
    Boost: 1.84.0
    OCC: 7.7.2
    Curl: 7.87.0
    ngspice: 42
    Compiler: Clang 14.0.3 with C++ ABI 1002

Build settings:
showier-drastic commented 5 months ago

Also, on this project, you can reproduce https://github.com/MitjaNemec/ReplicateLayout/issues/15 when you press Ctrl+Z.

MitjaNemec commented 5 months ago

Whoa, this really should not happen. It looks like KiCad internals changed a bit with V8. As it will be a while before I can test it much less fix it, can you try running the plugin and disabling replication of text items. If you report back what the results are I'd appreciate it.

showier-drastic commented 5 months ago

Still happens with text option disabled

image
MitjaNemec commented 5 months ago

Thanks for the prompt response. Can you retry with drawings disabled also?

showier-drastic commented 5 months ago

Same with drawings & texts disabled.

MitjaNemec commented 5 months ago

Whoa, this is something seriously wrong. By the look of it it seem that Kicad has reverted to the old style of footprint text positioning. So if I look at the V7 and V8 plugin releases this was the difference I had to indroduce to correct for KiCad internal changes

@@ -933,3 +988,3 @@
                         dst_text.SetPosition(dst_txt_pos)
-                        dst_text.SetTextAngleDegrees(-src_txt_orientation)
+                        dst_text.SetTextAngleDegrees(-src_txt_orientation - anchor_delta_angle)
                         dst_text.SetMirrored(not src_text.IsMirrored())
@@ -939,17 +994,5 @@
                         dst_text.SetPosition(dst_txt_pos)
-                        dst_text.SetTextAngleDegrees(src_txt_orientation)
+                        dst_text.SetTextAngleDegrees(src_txt_orientation - anchor_delta_angle)
                         dst_text.SetMirrored(src_text.IsMirrored())

notice the addition of anchor_delta_angle.

I suspect that this has been changed sometime after the KiCad 8 has been released. Which will make it PITA to test as I certainly don't have the same KiCad version as you do.

Anyhow, if you feel courageous, you can find the replcate_layout.py file and change the lines 989 and 995 from

                        dst_text.SetTextAngleDegrees(-src_txt_orientation - anchor_delta_angle)

to

                        dst_text.SetTextAngleDegrees(-src_txt_orientation)

If you do please report back the results. I'll look at the KiCad internal changes to figure out when did this change and how to properly solve it. But as I've already said, it'll take quite some time before I do

MitjaNemec commented 5 months ago

this is jas a not for me:

the likely source of the bug is that self.get_footprint_text_items() does not return the same ordered list for source and destination footprints.

MitjaNemec commented 4 months ago

@showier-drastic this should be solved in 3.0.3. The release should be available within PCM in a couple of days

Again, thanks for reporting this. Either the bug did no show as most users' footprints have only a few text items or KiCad's internals changed and text items that I get are not sorted anymore. anyhow, this should not be an issue anymore

showier-drastic commented 4 months ago

Yes, after updating to 3.0.3, it works great. Thanks for your hard work!

MitjaNemec commented 4 months ago

Thanks for the feedback and for appreciation.