Skip to content

Commit

Permalink
Use as many native methods as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
yaqwsx committed Oct 29, 2024
1 parent 7228183 commit 06359be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions kikit/actionPlugins/panelize.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,22 @@ def presetDifferential(source, target):
def transplateBoard(source, target, update=lambda x: None):
CLEAR_MSG = "Clearing the old board in UI"
RENDER_MSG = "Rendering the new board in UI"

target.ClearProject()
target.DeleteAllFootprints()

items = chain(
list(target.GetDrawings()),
list(target.GetFootprints()),
list(target.GetTracks()),
list(target.Zones()))
for x in items:
update(CLEAR_MSG)
target.Remove(x)
target.RemoveNative(x)

for x in list(target.GetNetInfo().NetsByNetcode().values()):
update(CLEAR_MSG)
target.Remove(x)
target.RemoveNative(x)

update(RENDER_MSG)
target.SetProperties(source.GetProperties())
Expand Down
2 changes: 1 addition & 1 deletion kikit/panelize.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def appendItem(board: pcbnew.BOARD, item: pcbnew.BOARD_ITEM,
newItem = item.Duplicate()
except TypeError: # Footprint has overridden the method, cannot be called directly
newItem = pcbnew.Cast_to_BOARD_ITEM(item).Duplicate().Cast()
board.Add(newItem)
board.AddNative(newItem)
if not yieldMapping:
return
if isinstance(item, pcbnew.FOOTPRINT):
Expand Down

0 comments on commit 06359be

Please sign in to comment.