From 6472dc0309dfcd76d74d529b6bedc4f3bb2455a7 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Thu, 12 Sep 2024 13:33:48 -0300 Subject: [PATCH] [Fixed][Render 3D] Rotation/offset for highlighted bottom components Fixes #659 --- CHANGELOG.md | 2 ++ docs/source/Changelog.rst | 2 ++ kibot/out_base.py | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24d833431..f43d73e87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update XML: `check_pcb_parity` not usable for KiCad 8, must use the `drc` preflight (#633) - PCB Print: %ln and %ll substitution when using `repeat_for_layer` option +- Render_3D: bottom side components that doesn't rotate from its center got + displaced highlight (#659) - QR Lib output and various preflights: might remove DRC exclusions. This is a KiCad bug that we must workaround (#653) - 3D outputs: temporal .kicad_dru file not removed (#655) diff --git a/docs/source/Changelog.rst b/docs/source/Changelog.rst index 19e273119..747a0a192 100644 --- a/docs/source/Changelog.rst +++ b/docs/source/Changelog.rst @@ -110,6 +110,8 @@ Fixed: ``drc`` preflight (#633) - PCB Print: %ln and %ll substitution when using ``repeat_for_layer`` option +- Render_3D: bottom side components that doesn’t rotate from its center + got displaced highlight (#659) - QR Lib output and various preflights: might remove DRC exclusions. This is a KiCad bug that we must workaround (#653) - 3D outputs: temporal .kicad_dru file not removed (#655) diff --git a/kibot/out_base.py b/kibot/out_base.py index 2f9a2b13a..1eda60b2a 100644 --- a/kibot/out_base.py +++ b/kibot/out_base.py @@ -754,6 +754,8 @@ def highlight_3D_models(self, board, highlight): models = m.Models() m_pos = m.GetPosition() rot = m.GetOrientationDegrees() + if m.IsFlipped(): + rot = 180-rot # Measure the courtyard bbox = self.get_crtyd_bbox(board, m) if bbox.x1 is not None: @@ -773,7 +775,7 @@ def highlight_3D_models(self, board, highlight): if extra_debug: logger.debug(f'Highlight for {ref}') logger.debug(f' - Position {ToMM(m_pos.x)}, {ToMM(m_pos.y)}') - logger.debug(f' - Orientation {rot}') + logger.debug(f' - Orientation {rot} (Flipped: {m.IsFlipped()})') logger.debug(f' - Center {ToMM(m_cen.x)} {ToMM(m_cen.y)}') logger.debug(f' - w,h {ToMM(w)}, {ToMM(h)}') # Compute the offset @@ -782,6 +784,8 @@ def highlight_3D_models(self, board, highlight): rrot = math.radians(rot) # KiCad coordinates are inverted in the Y axis off_y = -off_y + if m.IsFlipped(): + off_x = -off_x # Apply the component rotation off_xp = off_x*math.cos(rrot)+off_y*math.sin(rrot) off_yp = -off_x*math.sin(rrot)+off_y*math.cos(rrot)