MitjaNemec / ReplicateLayout

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

ReplicateLayout creating namesake groups. #60

Open SiTLOOMS opened 1 year ago

SiTLOOMS commented 1 year ago

ReplicateLayout creating namesake groups and dividing destination sheets' items by groups when "Group layouts" is chosen and destination footprint is already member of "proper" group.

https://github.com/MitjaNemec/ReplicateLayout/blob/62278e94812c5ef6d706d1a8ecc9758a4381b591/replicate_layout.py#LL897C11-L897C11

Tried to add GetName() to dst_fp.fp.GetParentGroup().

                if settings.group_footprints:
                    if (dst_fp.fp.GetParentGroup() is not None):
                        if dst_fp.fp.GetParentGroup().GetName() != self.dst_groups[st_index].GetName():
                            self.dst_groups[st_index].AddItem(dst_fp.fp)
                    else:
                        self.dst_groups[st_index].AddItem(dst_fp.fp)

While ReplicateLayout leaves footprint in it's "proper" group, it creates new group and adds another items of this sheet into this new group. In result there are two (may be more after several replications I think) groups with same names. And replicated sheet's items are placed in different groups. (3) in ReplicateLayout dir.

I suppose footprint may be added into new group if this footprint is a member of a "proper" group already. In this case if there is no extra items in old group, footprint will be moved to new group and old group will be automatically removed from board (there wont be any "empty" group in .kicad_pcb file). And whole replicated sheet will be in one group. (3-1) in ReplicateLayout dir.

If there is extra items in group this items will be leaved in old group, replicated items will be added into new group and there will be two namesake groups with different identifiers. But whole sheet will be in one group. (3-a) in ReplicateLayout dir.

In this way there will be just

                if settings.group_footprints:
                    self.dst_groups[st_index].AddItem(dst_fp.fp)

at 897 .

grouping-test.zip

Sorry if I'm doing it the wrong way, but I do not know where I really should write such things.