fix: Flip() after board.Add() to avoid 30s hang in KiCAD 9
FootprintLoad+Flip() on standalone footprint (not yet in board) causes a 30-second block in KiCAD 9 pcbnew. Solution: add footprint to board first, then call Flip() with board context available. Fixes B.Cu placement timeout that killed the Python process.
This commit is contained in:
@@ -125,19 +125,20 @@ class ComponentCommands:
|
|||||||
angle = pcbnew.EDA_ANGLE(rotation, pcbnew.DEGREES_T)
|
angle = pcbnew.EDA_ANGLE(rotation, pcbnew.DEGREES_T)
|
||||||
module.SetOrientation(angle)
|
module.SetOrientation(angle)
|
||||||
|
|
||||||
# Set layer — for B.Cu the footprint must be flipped (mirrored),
|
# Set layer for F.Cu (or non-B.Cu) before adding to board
|
||||||
# not just layer-assigned. Flip() handles layer + mirror in one step.
|
if layer != "B.Cu":
|
||||||
if layer == "B.Cu":
|
|
||||||
if not module.IsFlipped():
|
|
||||||
module.Flip(module.GetPosition(), False)
|
|
||||||
else:
|
|
||||||
layer_id = self.board.GetLayerID(layer)
|
layer_id = self.board.GetLayerID(layer)
|
||||||
if layer_id >= 0:
|
if layer_id >= 0:
|
||||||
module.SetLayer(layer_id)
|
module.SetLayer(layer_id)
|
||||||
|
|
||||||
# Add to board
|
# Add to board first — Flip() requires board context in KiCAD 9
|
||||||
self.board.Add(module)
|
self.board.Add(module)
|
||||||
|
|
||||||
|
# Flip to B.Cu after add (board context needed, otherwise hangs 30s)
|
||||||
|
if layer == "B.Cu":
|
||||||
|
if not module.IsFlipped():
|
||||||
|
module.Flip(module.GetPosition(), False)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"success": True,
|
"success": True,
|
||||||
"message": f"Placed component: {component_id}",
|
"message": f"Placed component: {component_id}",
|
||||||
|
|||||||
Reference in New Issue
Block a user