Giter Club home page Giter Club logo

saverestorelayout's People

Contributors

mitjanemec avatar tomsaw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

saverestorelayout's Issues

Filename parsing cutting off characters

This seems slightly similar to #6 but I can specifically see an error in the schematic file name that the plugin is failing to find:

02-02 20:07:43 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 172:Plugin executed on: 'win32'
02-02 20:07:43 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 173:Plugin executed with python version: '3.9.14 (main, Dec 23 2022, 23:36:19) [MSC v.1934 64 bit (AMD64)]'
02-02 20:07:43 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 174:KiCad build version: (6.0.11)
02-02 20:07:43 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 175:Plugin version: 1.1.8
02-02 20:07:43 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 176:Frame repr: <wx._core.Frame object at 0x000001B34A459430>
02-02 20:07:43 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 194:Anchor footprint reference is 'U901'
02-02 20:07:47 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 274:Restore layout chosen
02-02 20:07:55 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 75:Initialization start
02-02 20:07:55 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 77:Initialization done Group name:
02-02 20:08:20 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 648:Getting board info
02-02 20:08:20 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 651:Get project schematics and layout data
02-02 20:08:20 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 132:getting a list of all footprints on board
02-02 20:08:20 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 299:Fatal error when creating an instance of RestoreLayout
Traceback (most recent call last):
  File "C:\Users\A\Documents\KiCad\6.0\3rdparty\plugins\com_github_MitjaNemec_SaveRestoreLayout\action_save_restore_layout.py", line 297, in Run
    restore_layout = RestoreLayout(board, dst_anchor_fp_ref, group_name)
  File "C:\Users\A\Documents\KiCad\6.0\3rdparty\plugins\com_github_MitjaNemec_SaveRestoreLayout\save_restore_layout.py", line 652, in __init__
    self.prj_data = PrjData(self.board)
  File "C:\Users\A\Documents\KiCad\6.0\3rdparty\plugins\com_github_MitjaNemec_SaveRestoreLayout\save_restore_layout.py", line 175, in __init__
    self.parse_schematic_files(self.sch_filename, schematic_found)
  File "C:\Users\A\Documents\KiCad\6.0\3rdparty\plugins\com_github_MitjaNemec_SaveRestoreLayout\save_restore_layout.py", line 209, in parse_schematic_files
    self.parse_schematic_files(sheetfile, dict_of_sheets)
  File "C:\Users\A\Documents\KiCad\6.0\3rdparty\plugins\com_github_MitjaNemec_SaveRestoreLayout\save_restore_layout.py", line 190, in parse_schematic_files
    with open(filename) as f:
FileNotFoundError: [Errno 2] No such file or directory: '5340A.kicad_sch'

5340A.kicad_sch is actually Si5340A.kicad_sch.

KiCAD version info:

Application: KiCad Schematic Editor (64-bit)

Version: (6.0.11), release build

Libraries:
	wxWidgets 3.2.1
	libcurl/7.83.1-DEV Schannel zlib/1.2.13

Platform: Windows 10 (build 19045), 64-bit edition, 64 bit, Little endian, wxMSW

Build Info:
	Date: Jan 26 2023 07:02:30
	wxWidgets: 3.2.1 (wchar_t,wx containers)
	Boost: 1.80.0
	OCC: 7.6.2
	Curl: 7.83.1-DEV
	ngspice: 38
	Compiler: Visual C++ 1934 without C++ ABI

Build settings:
	KICAD_USE_OCC=ON
	KICAD_SPICE=ON

Any idea why it is cutting off schematic name first two characters?

File Name Handling

    If this is unrelated, I'm happy to open a new issue. I get this failure which looks like it is at the hash check stage:

image

From log file

10-21 15:07:07 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 149:Plugin executed on: 'win32'
10-21 15:07:07 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 150:Plugin executed with python version: '3.9.14 (main, Sep 19 2022, 05:11:57) [MSC v.1932 64 bit (AMD64)]'
10-21 15:07:07 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 151:KiCad build version: (6.0.8)
10-21 15:07:07 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 152:Plugin version: 1.1.3
10-21 15:07:07 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 153:Frame repr: <wx._core.Frame object at 0x000002331921A550>
10-21 15:07:07 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 171:Anchor footprint reference is 'U201'
10-21 15:07:09 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 180:Save layout chosen
10-21 15:07:09 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 287:Working on C:/Users/local/Repos/_/hardware/TC_Radio_standalone/TC_Radio_standalone.kicad_pcb
10-21 15:07:09 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 132:getting a list of all footprints on board
10-21 15:07:09 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 144:Footprint REF** does not have Sheetfile property, it will not be considered for placement. Most likely it is only in layout
10-21 15:07:09 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 292:Saving the current board temporary in order to leave current layout intact
10-21 15:07:09 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 298:Saving board as tempfile: C:\Users\local\AppData\Local\Temp\temp_board_file_for_save.kicad_pcb
10-21 15:07:09 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 303:Loaded temp boardfile: C:\Users\local\AppData\Local\Temp\temp_board_file_for_save.kicad_pcb
10-21 15:07:09 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 304:Get project schematics and layout data
10-21 15:07:09 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 132:getting a list of all footprints on board
10-21 15:07:09 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 144:Footprint REF** does not have Sheetfile property, it will not be considered for placement. Most likely it is only in layout
10-21 15:07:17 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 219:Saving the layout in 'C:\\Users\\local\\Repos\\_\\hardware\\TC_Radio_standalone\\TC_Radio_standalone.pckl' for level 0
10-21 15:07:17 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 315:Saving layout for level: ['Radio']
10-21 15:07:17 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 316:Calculating hash of the layout schematics
10-21 15:07:17 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 320:Saving hash for files: ['File: Radio_.kicad_sch']

I'm afraid I can't share the project but grateful if any workaround is known.
The sub-sheet I'm trying to save layout for is sheet 2 in the hierarchy (root is sheet 1).

Originally posted by @SimonMerrett in #3 (comment)

Saving failes when subsheets are in subdirectory

It fails to save because the sheet can't be found. The reason is the the subsheet is actually located in my-project\sheets\subsheet.kicad_sch:

03-30 13:07:36 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 172:Plugin executed on: 'win32'
03-30 13:07:36 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 173:Plugin executed with python version: '3.9.14 (main, Feb 13 2023, 04:48:26) [MSC v.1934 64 bit (AMD64)]'
03-30 13:07:36 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 174:KiCad build version: 7.0.1
03-30 13:07:36 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 175:Plugin version: 2.0.6

03-30 13:07:52 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 259:Fatal error running SaveLayout
Traceback (most recent call last):
  File "C:\Users\ben\Documents\KiCad\7.0\3rdparty\plugins\com_github_MitjaNemec_SaveRestoreLayout\action_save_restore_layout.py", line 252, in Run
    save_layout.save_layout(save_layout.src_anchor_fp.sheet_id[0:selected_level + 1], data_file,
  File "C:\Users\ben\Documents\KiCad\7.0\3rdparty\plugins\com_github_MitjaNemec_SaveRestoreLayout\save_restore_layout.py", line 385, in save_layout
    md5hash = get_sch_hash(file_path, md5hash)
  File "C:\Users\ben\Documents\KiCad\7.0\3rdparty\plugins\com_github_MitjaNemec_SaveRestoreLayout\save_restore_layout.py", line 65, in get_sch_hash
    with open(sch_file, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\ben\\Documents\\my-project\\subsheet.kicad_sch'

Restoring a loyout failed with "Source and destination schematics don't match!"

Hello,

thanks for the plugin, it looks very promising.
Unfortunately, it does not work for me under Linux with KiCad 7.0.7

It looks like you compare hashes of the two schematic files, and this fails because the instances section of every symbol instance in the schematic is updated as soon as I copy the hierarchical sheet into the new project.

So, if I make a diff for the two sheets:

  • the original in the project AnalogPower_In5V_Out5V-+2V5; sheet name M_AnalogePower.kicad_sch
  • the copy in the project RedPitaya_PD_HAT_V1; sheet name M_AnalogePower.kicad_sch
    I see:
  (symbol (lib_id "Device:C") (at 83.82 83.82 0) (unit 1)
    (in_bom yes) (on_board yes) (dnp no)
    (uuid f4de520c-a4ed-4fc0-bcf6-e54e8493a81f)
    (property "Reference" "C3" (at 83.82 81.28 0)
      (effects (font (size 1.27 1.27)) (justify left))
    )
    (property "Value" "1u/25V" (at 87.63 86.36 0)
      (effects (font (size 1.27 1.27)) (justify right))
    )
    (property "Footprint" "Capacitor_SMD:C_0603_1608Metric" (at 84.7852 87.63 0)
      (effects (font (size 1.27 1.27)) hide)
    )
    (property "Datasheet" "~" (at 83.82 83.82 0)
      (effects (font (size 1.27 1.27)) hide)
    )
    (pin "1" (uuid 1844842e-e0ed-498a-b18e-a6c52239d0ac))
    (pin "2" (uuid a29a2047-2320-4859-bad6-8b2ab71d4a77))
    (instances
+      (project "RedPitaya_PD_HAT_V1"
+        (path "/3d3375cd-4de6-4078-82fa-39d0f373d068/fc1a81c4-d7d5-4cfe-92fb-80830ab2460d"
+          (reference "C3") (unit 1)
+        )
+      )
      (project "AnalogPower_In5V_Out5V-+2V5"
        (path "/53854ffa-83d7-44ca-aa23-c38aa4123b5e/25b7b422-ee30-4321-8b2d-215bafc28d1d"
          (reference "C3") (unit 1)
        )
      )
    )
  )

I am sot sure if that is new in KiCad 7, but it breaks the plugin unfortunately.

Workflow

  1. Copy the schematic of the hierarchical sheet from the module project to the new project.
  2. Open the new project and the module project and copy the hierarchical sheet block from the module project and past the block into the new projects schematic.
  3. Go to new projects PCB and update the board.
  4. Select a part and run the "Save/Restore Layout" plugin; chose restore ....

No editing the copied schematic, re-annotation parts or anything like that.

Here is the save_restore_layout.log

KiCad Info

Application: KiCad x86_64 on x86_64

Version: 7.0.7-7.0.7~ubuntu22.04.1, release build

Libraries:
wxWidgets 3.2.1
FreeType 2.11.1
HarfBuzz 6.0.0
FontConfig 2.13.1
libcurl/7.81.0 OpenSSL/3.0.2 zlib/1.2.11 brotli/1.0.9 zstd/1.4.8 libidn2/2.3.2 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.16

Platform: KDE neon 5.27, 64 bit, Little endian, wxGTK, KDE, x11

Build Info:
Date: Aug 13 2023 23:14:49
wxWidgets: 3.2.1 (wchar_t,wx containers) GTK+ 3.24
Boost: 1.74.0
OCC: 7.5.2
Curl: 7.88.1
ngspice: 38
Compiler: GCC 11.4.0 with C++ ABI 1016

Build settings:
KICAD_SPICE=ON

plugin is crashing

Apologies if I'm doing something wrong, but the plugin is crashing. Here is the log file.


11-18 08:40:20 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 159:Plugin executed on: 'win32'
11-18 08:40:20 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 160:Plugin executed with python version: '3.9.14 (main, Sep 19 2022, 05:11:57) [MSC v.1932 64 bit (AMD64)]'
11-18 08:40:20 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 161:KiCad build version: (6.0.9)
11-18 08:40:20 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 162:Plugin version: 1.1.5
11-18 08:40:20 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 163:Frame repr: <wx._core.Frame object at 0x0000016C2558B550>
11-18 08:40:20 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 181:Anchor footprint reference is 'L1-2'
11-18 08:40:25 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 190:Save layout chosen
11-18 08:40:25 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 287:Working on C:/Lattice-FPGAs-KiCAD/Juke_audio_8_zone.kicad_pcb
11-18 08:40:25 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 132:getting a list of all footprints on board
11-18 08:40:25 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 292:Saving the current board temporary in order to leave current layout intact
11-18 08:40:25 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 298:Saving board as tempfile: C:\Users\bradf\AppData\Local\Temp\temp_board_file_for_save.kicad_pcb
11-18 08:40:25 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 303:Loaded temp boardfile: C:\Users\bradf\AppData\Local\Temp\temp_board_file_for_save.kicad_pcb
11-18 08:40:25 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 304:Get project schematics and layout data
11-18 08:40:25 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 132:getting a list of all footprints on board
11-18 08:40:50 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 237:Saving the layout in 'C:\Lattice-FPGAs-KiCAD\Regulator.pckl' for level 0
11-18 08:40:50 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 315:Saving layout for level: ['Power Regulator']
11-18 08:40:50 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 316:Calculating hash of the layout schematics
11-18 08:40:50 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 320:Saving hash for files: ['File: Regulator.kicad_sch']
11-18 08:40:50 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 246:Fatal error running SaveLayout
Traceback (most recent call last):
File "C:\Users\bradf\Documents\KiCad\6.0\3rdparty\plugins\com_github_MitjaNemec_SaveRestoreLayout\action_save_restore_layout.py", line 239, in Run
save_layout.save_layout(save_layout.src_anchor_fp.sheet_id[0:selected_level + 1], data_file,
File "C:\Users\bradf\Documents\KiCad\6.0\3rdparty\plugins\com_github_MitjaNemec_SaveRestoreLayout\save_restore_layout.py", line 325, in save_layout
md5hash = get_sch_hash(file_path, md5hash)
File "C:\Users\bradf\Documents\KiCad\6.0\3rdparty\plugins\com_github_MitjaNemec_SaveRestoreLayout\save_restore_layout.py", line 65, in get_sch_hash
with open(sch_file, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Lattice-FPGAs-KiCAD\File: Regulator.kicad_sch'

Crash when saving layout

The plugin is crashing when trying to save a layout. Based on the attached log, it appears that the plugin is expecting the schematic to be saved in the /tmp directory along with the layout, but only the layout is saved into the /tmp directory. I've tried this on 3 different projects, and all of them behave the same. Log is attached.

09-06 15:26:41 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 172:Plugin executed on: 'linux'
09-06 15:26:41 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 173:Plugin executed with python version: '3.11.4 (main, Jun  7 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)]'
09-06 15:26:41 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 174:KiCad build version: 7.0.7-2.fc38
09-06 15:26:41 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 175:Plugin version: 2.0.8

09-06 15:26:41 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 176:Frame repr: <wx._core.Frame object at 0x7f88982c0f70>
09-06 15:26:41 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 194:Anchor footprint reference is 'A66'
09-06 15:26:42 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 203:Save layout chosen
09-06 15:26:42 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 354:Working on /home/mreaves/kicad-projects/big-board/big-board.kicad_pcb
09-06 15:26:42 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 132:getting a list of all footprints on board
09-06 15:26:42 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 359:Saving the current board temporary in order to leave current layout intact
09-06 15:26:42 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 365:Saving board as tempfile: /tmp/temp_board_file_for_save.kicad_pcb
09-06 15:26:43 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 370:Loaded temp boardfile: /tmp/temp_board_file_for_save.kicad_pcb
09-06 15:26:43 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 371:Get project schematics and layout data
09-06 15:26:43 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 132:getting a list of all footprints on board
09-06 15:26:43 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 208:Fatal error when creating an instance of SaveLayout
Traceback (most recent call last):
  File "/home/mreaves/.local/share/kicad/7.0/3rdparty/plugins/com_github_MitjaNemec_SaveRestoreLayout/action_save_restore_layout.py", line 206, in Run
    save_layout = SaveLayout(board, src_anchor_fp_ref)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mreaves/.local/share/kicad/7.0/3rdparty/plugins/com_github_MitjaNemec_SaveRestoreLayout/save_restore_layout.py", line 372, in __init__
    self.save_prjdata = PrjData(self.board)
                        ^^^^^^^^^^^^^^^^^^^
  File "/home/mreaves/.local/share/kicad/7.0/3rdparty/plugins/com_github_MitjaNemec_SaveRestoreLayout/save_restore_layout.py", line 175, in __init__
    self.parse_schematic_files(self.sch_filename, schematic_found)
  File "/home/mreaves/.local/share/kicad/7.0/3rdparty/plugins/com_github_MitjaNemec_SaveRestoreLayout/save_restore_layout.py", line 190, in parse_schematic_files
    with open(filename, encoding='utf-8') as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/temp_board_file_for_save.kicad_sch'

Add Layer Swapping option

Hey there,

I´ve noticed that with the newer versions and more complete checking, the plugin does not allow to import a layout when the number of layers is different between the projects.
This of course avoids a lot of confusion (e.g. where did my layer go... ) but also seriously hinders the reuse of layouts across different boards.
I would propose to allow this kind of import based on user input.
For now just checking which layers were used in the source layout and simply matching them with the desired layer in the active project seems to work okay.
For a quick test I put a version working with KiCAD 6 on my fork, if you like the idea I will update and clean the code a bit and start a merge request.
I have not done too much of testing (e.g. mirrored or rotated imports etc..) but only made a first proof of concept.
There´s quiet some room for improvements e.g.
Checking for components (why not put the bottom layer on In6 if there are no components there?)
or allowing to discard certain layers (import from 6 layers board to 4 layers, but throwing away two less used layers and starting from there)

Any takers for this function?

Cheers,
Nik

Plugin not entering case: "SAVE"

Hey,

i have been working for quite a long time with your plugin in KiCad 5. Now i tried to work with it in KiCad 6, but unluckly, i cant get it to work. Here is my setup and my Test-Project:

KiCad-Version:
image

KiCad-Test-Project:
Main-Sheet:
image

Hierachical Sheet:
image

RefFrame is just a rectangle on the silkscreen layer.

PCB-Layout:
image

Now Steps i do to save the Layout inside the RefFrame:

  1. Click and select the "RefFrame" U1 in PCBnew
  2. Start your Plugin
  3. Select "Save Layout"

After this, nothing happens anymore and no pckl file will be created. In my root directory of the project i find the log file which contains the following infos:

  • 05-03 12:10:00 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 149:Plugin executed on: 'win32'
  • 05-03 12:10:00 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 150:Plugin executed with python version: '3.9.10 (main, Feb 11 2022, 04:18:11) [MSC v.1928 64 bit (AMD64)]'
  • 05-03 12:10:00 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 151:KiCad build version: (6.0.2)
  • 05-03 12:10:00 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 152:Plugin version: 1.1.1
  • 05-03 12:10:00 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 153:Frame repr: <wx._core.Frame object at 0x000001808041FEE0>
  • 05-03 12:10:00 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 172:Anchor footprint reference is 'U1'

I was travelling through your code and, to me, it seems like, that the plugin is not entering the case if res == InitialDialog.SAVE: because nothing else will be added into the log file. I tried to setup your plugin in PyCharm, bypassing the gui and set the res variable manually. Unfortunatly, this ends up in other errors, which might be caused by my interventions:

sheet_file = fp.GetProperty('Sheetfile')
File "C:\Program Files\KiCad\6.0\bin\Lib\site-packages\pcbnew.py", line 17716, in GetProperty
raise KeyError("Property not found: " + key)
KeyError: 'Property not found: Sheetfile'

Do you have any kind of work-aorund for this? Im not sure, if the problem is on my side, or if i overlooked something.

Many thanks for your help and your work on this plugin!!

Kind regards,
René

Implement checks for layer count

Save current layer count when saving layout. when restoring layout make sure at least the same number of layers are available

Hierarchical sheet file name needs to be exactly the same for Restore layout to work (And maybe an idea on how to fix it?)

I was having trouble getting the plugin to work and one of the problems is the sheet file name needs to be the same when referencing.
The problem is that when you make a new sheet in the schematic editor it automatically references it to relative path name. So a file called Test.kicad_sch will have sheet file designator "Test.kicad_sch" because it is in the same folder.
When I now want to use the sheet and layout in another project (Which for KiCad is always in another folder) the file designator will change to absolute path "C:/folder/folder/folder/Test.kicad_sch".
If you now try to apply the layout in PCB editor you get the error:

LookupError: Destination hierarchy: ['Test.kicad_sch'] does not match source level: 'C:/folder/folder/folder/Test.kicad_sch'

The only way to resolve this is to copy and paste the Test.kicad_sch to the other project and also force it to reference it with relative path. Which defeats the purpose of checking if the destination hierarchy and stuff is the same.. Why is the name of the schematic even checked? If I want to change the name of Test.kicad_sch to Test2.kicad_sch it also doesn't work even though the schematic is the same.

Maybe an idea to not have to check if the Hierarchical sheet schematic and layout file are the same maybe make the layout file part of the Hierarchical sheet schematic file and not check the location etc.

Besides this it might be more user friendly to force users to make a group of the layout they made of a Hierarchical sheet and copy everything in the group over when the layout is restored. This way it is possible to copy over graphical designators etc which can be very useful.

Also once these changes are implemented it is not necessary to have a separate replicate and save and restore layout addon. The layout is part of the sub sheet and can hopefully work multiple times on the same PCB design file.
Workflow would be to link the layout made for a hierarchical sheet to the hierarchical sheet in grouped form. Then in schematic editor copy and paste the hierarchical sheet. And in PCB editor the layout can be copied and will also be in grouped form.

Would it make sense to get rid of the schematic hash check?

It's a check that's brittle, it's sensitive to even nonfunctional changes in the schematic. It also needs its own dedicated section in the readme. Does it make sense to just get rid of it?

I assume the goal is to guard against functional changes in the schematic, but it seems redundant. Wouldn't DRC catch cases where the schematic connectivity changed? And if there were differences in the component list, then it would be detected on a restore anyways, at which point it could restore the components that do match and warn the user of the nonmatching components?

[feature] hierarchical sheet name as default save name

hi,

Right now the save dialog uses the name of the project as default name of the .pckl file and I was thinking if it would make more sense to instead use the name of the hierarchical sheet the layout is based on. As soon as you want to save more then one layout part of a project you can't use the default name anymore anyway. Also the filename would then probably more descriptive of the function in case it isn't intended to be used right away or by another person.

So what I intend to have is for my_awesome_project with the hierarchical sheet controller the save dialog would open with controller.pckl as preselected filename and not with my_awesome_project.pckl.

In the end this would be just a small optimization (at least for me) so if it is too complicated to implement or interferes with other approaches this should be ignored.

Best Regards,
Tojan

Components without sheetfile stop plugin

When restoring a plugin to a board with PCB-only components (e.g. mounting holes ) the plugin stops working.

08-16 13:55:36 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 149:Plugin executed on: 'win32'
08-16 13:55:36 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 150:Plugin executed with python version: '3.9.10 (main, Jun 24 2022, 05:34:59) [MSC v.1932 64 bit (AMD64)]'
08-16 13:55:36 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 151:KiCad build version: (6.0.6)
08-16 13:55:36 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 152:Plugin version: 1.1.2
08-16 13:55:36 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 153:Frame repr: <wx._core.Frame object at 0x00000161572E1160>
08-16 13:55:36 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 171:Anchor footprint reference is 'RefFrame3001'
08-16 13:55:37 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 235:Restore layout chosen
08-16 13:55:41 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 602:Getting board info
08-16 13:55:41 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 604:Get project schematics and layout data
08-16 13:55:41 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 132:getting a list of all footprints on board
08-16 13:55:41 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 251:Fatal error when creating an instance of RestoreLayout
Traceback (most recent call last):
File "C:\X\plugins\com_github_MitjaNemec_SaveRestoreLayout\action_save_restore_layout.py", line 249, in Run
restore_layout = RestoreLayout(board, dst_anchor_fp_ref)
File "C:\X\plugins\com_github_MitjaNemec_SaveRestoreLayout\save_restore_layout.py", line 605, in init
self.prj_data = PrjData(self.board)
File "C:\X\plugins\com_github_MitjaNemec_SaveRestoreLayout\save_restore_layout.py", line 140, in init
sheet_file = fp.GetProperty('Sheetfile')
File "C:\Program Files\KiCad\6.0\bin\Lib\site-packages\pcbnew.py", line 17747, in GetProperty
raise KeyError("Property not found: " + key)
KeyError: 'Property not found: Sheetfile'

This seems to be a similar problem as mentioned in the replicate layout plugin Replicate Layout issue 10 .
Catching the exception as you did in the replicate layout plugin works here as well, but I do not fully understand the logic of the following elif/else ( Restorelayout.py L146 ) construct to judge any side effects.

'BOARD_ITEM' object has no attribute 'SetNetCode' (Since upgrading to KiCad 7.0

Hi Mitja,

Thanks for writing this plug-in which I have used extensively in the past. It has saved me a lot of time! Since upgrading to KiCAD 7.0 a few weeks ago it has failed every time I attempted to use it.

I'm using it on a project that was upgraded to KiCAD 7 from 6.

Here is the log file:

05-13 04:48:52 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 172:Plugin executed on: 'win32'
05-13 04:48:52 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 173:Plugin executed with python version: '3.9.16 (main, Apr 9 2023, 05:22:13) [MSC v.1934 64 bit (AMD64)]'
05-13 04:48:52 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 174:KiCad build version: 7.0.2
05-13 04:48:52 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 175:Plugin version: 2.0.7

05-13 04:48:52 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 176:Frame repr: <wx._core.Frame object at 0x0000025204DCF0D0>
05-13 04:48:52 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 194:Anchor footprint reference is 'U502'
05-13 04:48:53 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 274:Restore layout chosen
05-13 04:48:58 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 75:Initialization start
05-13 04:48:58 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 77:Initialization done Group name:
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 675:Getting board info
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 678:Get project schematics and layout data
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 132:getting a list of all footprints on board
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 684:Loading saved design
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 706:Source level is:['ADC_1.kicad_sch']
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 711:Destination footprint is:'U502'
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 712:Destination levels available are:['ADC_1.kicad_sch']
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 723:Destination level is:['ADC_1.kicad_sch']
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 728:All sch files required are: ['ADC_1.kicad_sch']
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 730:Getting current schematics hash
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 741:Source hash is:'94b43d6c31e25cdc2e676eb90591fc96'
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 742:Destination hash is: '94b43d6c31e25cdc2e676eb90591fc96'
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 759:Get layout data from saved board
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 132:getting a list of all footprints on board
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 907:Replicating footprints
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.save_restore_layout 1068:Replicating tracks
05-13 04:48:59 com_github_MitjaNemec_SaveRestoreLayout.action_save_restore_layout 323:Fatal error when restoring layout
Traceback (most recent call last):
File "[Path to my DOCUMENTS directory]\KiCad\7.0\3rdparty\plugins\com_github_MitjaNemec_SaveRestoreLayout\action_save_restore_layout.py", line 312, in Run
restore_layout.restore_layout(layout_file)
File "[Path to my DOCUMENTS directory]\KiCad\7.0\3rdparty\plugins\com_github_MitjaNemec_SaveRestoreLayout\save_restore_layout.py", line 792, in restore_layout
self.replicate_tracks(src_anchor_fp, saved_board.GetTracks(), self.dst_anchor_fp, net_pairs, self.layout_group)
File "[Path to my DOCUMENTS directory]\KiCad\7.0\3rdparty\plugins\com_github_MitjaNemec_SaveRestoreLayout\save_restore_layout.py", line 1100, in replicate_tracks
new_track.SetNetCode(to_net_code, True)
AttributeError: 'BOARD_ITEM' object has no attribute 'SetNetCode'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.