-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for existing groups and footprint membership in groups
- Loading branch information
1 parent
65fdbc1
commit da0a0bc
Showing
1 changed file
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -341,16 +341,35 @@ def prepare_for_replication(self, level, settings): | |
# if needed filter them by group | ||
self.src_drawings = self.get_drawings_for_replication(self.src_bounding_box, settings) | ||
|
||
# get all the existing groups | ||
groups = self.board.Groups() | ||
g_names = [] | ||
for g in groups: | ||
g_names.append(g.GetName()) | ||
|
||
# create groups for each destination layout if selected | ||
if settings.group_layouts: | ||
for sheet in self.dst_sheets: | ||
dst_group_name = "Replicated Group {}".format(sheet) | ||
# check if this group already exists | ||
if dst_group_name in g_names: | ||
raise LookupError(f"Destination group {dst_group_name} already exists") | ||
dst_group = pcbnew.PCB_GROUP(None) | ||
dst_group.SetName(dst_group_name) | ||
self.board.Add(dst_group) | ||
# store destination lauouts' groups | ||
self.dst_groups.append(dst_group) | ||
|
||
# check if any destination footprints are already members of some groups | ||
for sheet in self.dst_sheets: | ||
dst_sheet_fps = self.get_footprints_on_sheet(sheet) | ||
for fp in dst_sheet_fps: | ||
fp_group = fp.fp.GetParentGroup() | ||
if fp_group != "Replicated Group {}".format(sheet): | ||
raise LookupError(f"Destination footprint {fp} is a member of a different group. " | ||
f"All destination plugin have either have to be members of destination group" | ||
f" or no group at all.") | ||
|
||
@staticmethod | ||
def get_footprint_id(footprint): | ||
path = footprint.GetPath().AsString().upper().replace('00000000-0000-0000-0000-0000', '').split("/") | ||
|
@@ -873,7 +892,8 @@ def replicate_footprints(self, settings): | |
dst_fp.fp.SetZoneConnection(src_fp.fp.GetZoneConnection()) | ||
|
||
# add footprints to corresponding layout groups if selected | ||
if settings.group_footprints: | ||
# and if footprint is not already member of this group | ||
if settings.group_footprints and dst_fp.fp.GetParentGroup() != self.dst_groups[st_index].GetName(): | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
MitjaNemec
Author
Owner
|
||
self.dst_groups[st_index].AddItem(dst_fp.fp) | ||
|
||
# flip if dst anchor is flipped in regard to src anchor | ||
|
Will it ever be equal?
dst_fp.fp.GetParentGroup()
should be something like<pcbnew.PCB_GROUP; proxy of <Swig Object of type 'PCB_GROUP *' at 0x000001EB1F0A9C60> >
andself.dst_groups[st_index].GetName()
should be something likeReplicated Group ['sheet_name']