mmccoo / kicad_mmccoo

This is a repository to hold example and utility code for scripting within kicad (currently limited to pcbnew)
Apache License 2.0
106 stars 26 forks source link

Replicate layout script not working #1

Closed sww1235 closed 6 years ago

sww1235 commented 7 years ago

I am attempting to use your replicate layout script to layout several duplicate hierarchal sheets. I am running the latest nightly release (April 7th) for macOS.

I am running into a problem where the script goes through all its initial setup but then does not actually replicate the layout of the parts. I have refreshed the screen as well as relaunched pcbnew entirely.

When I run the script, the last console line I get is J8 is in index 0. It never progresses to the point where it should print copying net from x to y.

Do you have any suggestions?

I have two ideas why it might not be working properly, but they are only suspicions nothing more.

  1. The sheets I am attempting to layout are doubly nested.
  2. There are multi-unit components in the sheets that have parts in other sheets. (They are annotated correctly though.)

Thanks for any responses you can provide. I hope filing a github issue is ok, as I tried to post a comment on your blog but the captcha kept breaking.

mmccoo commented 7 years ago

Hi Stephen

posting to github is fine. your blog comment did get to me, it just took some time for me to get to approving it.

If you're willing to send a test, I'm happy to look at it.

I'd like to make the script more robust.

Miles

On Sat, May 20, 2017 at 11:09 PM, Stephen Walker-Weinshenker < notifications@github.com> wrote:

I am attempting to use your replicate layout script to layout several duplicate hierarchal sheets. I am running the latest nightly release (April 7th) for macOS.

I am running into a problem where the script goes through all its initial setup but then does not actually replicate the layout of the parts. I have refreshed the screen as well as relaunched pcbnew entirely.

When I run the script, the last console line I get is J8 is in index 0. It never progresses to the point where it should print copying net from x to y.

Do you have any suggestions?

I have two ideas why it might not be working properly, but they are only suspicions nothing more.

  1. The sheets I am attempting to layout are doubly nested.
  2. There are multi-unit components in the sheets that have parts in other sheets. (They are annotated correctly though.)

Thanks for any responses you can provide. I hope filing a github issue is ok, as I tried to post a comment on your blog but the captcha kept breaking.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mmccoo/kicad_mmccoo/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBErNUkwt9pK_Qo0SroYajDPLOWJyUVks5r71aFgaJpZM4NhajS .

sww1235 commented 7 years ago

Hi Miles:

The KiCAD project I was attempting to use your script on lives at https://github.com/sww1235/edc-mux-board and any library files you may need are at https://github.com/sww1235/KiCAD-Libraries

The components I was using in the call to place_components were J8 and U7, each individually. I tried U7 first but then tried J8 as U7 is a multi-unit component.

Thanks for your help and responding so quickly.

mmccoo commented 7 years ago

I looked at it. Your design exposed several bugs in the replicator. I think I have to working on your data now.

trying pull and running again.

Thanks for reporting the problem and providing a testcase.

I'm curious what the design does, if you're at liberty to share that information. Miles

[image: Inline image 1]

On Sun, May 21, 2017 at 10:03 PM, Stephen Walker-Weinshenker < notifications@github.com> wrote:

Hi Miles:

The KiCAD project I was attempting to use your script on lives at https://github.com/sww1235/edc-mux-board and any library files you may need are at https://github.com/sww1235/KiCAD-Libraries

The components I was using in the call to place_components were J8 and U7, each individually. I tried U7 first but then tried J8 as U7 is a multi-unit component.

Thanks for your help and responding so quickly.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mmccoo/kicad_mmccoo/issues/1#issuecomment-302959555, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBErE6KWWBhEfB6GuMsKI83Ztt1P0I_ks5r8JiggaJpZM4NhajS .

sww1235 commented 7 years ago

I can certainly attempt to explain what it does :-). Essentially it is a 8 port USB hub, a power distribution board, and an audio/ push to talk signal routing board. It had a few instances of feature creep, especially when I decided that it should have USB C ports.

sww1235 commented 7 years ago

Hey Miles:

I had a very busy summer so I was not able to retest the updated script. I have not made any changes to the test files I gave you in the mean time.

When testing with the August 24th macOS beta, I get the error

execfile("/Users/Stephen/Desktop/replicatelayout.py")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/Stephen/Desktop/replicatelayout.py", line 141, in <module>
    SheetInstance.RegisterModulesAndNets(board)
  File "/Users/Stephen/Desktop/replicatelayout.py", line 89, in RegisterModulesAndNets
    common = SheetInstance.NetIsSheetInternal(net)
  File "/Users/Stephen/Desktop/replicatelayout.py", line 64, in NetIsSheetInternal
    for pad in net.Pads():
  File "/Applications/Kicad/kicad.app/Contents/Frameworks/python/site-packages/pcbnew.py", line 14224, in <lambda>
    __getattr__ = lambda self, name: _swig_getattr(self, NETINFO_ITEM, name)
  File "/Applications/Kicad/kicad.app/Contents/Frameworks/python/site-packages/pcbnew.py", line 83, in _swig_getattr
    raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
AttributeError: 'NETINFO_ITEM' object has no attribute 'Pads'

This error appears to happen before any actual work is being done by the script. From my inspection of the code it looks like the error is coming from the methods GetNetCanonical and NetIsSheetInternal.

Not certain if NETINFO_ITEM once had a reference to pads or not, but that functionality seems to ahve moved somewhere in pcbnew.BOARD_CONNECTED_ITEM.

Hope this helps. No rush

Duckle29 commented 7 years ago

Hey there. I just came across this issue, as kicad is giving me a an identical error as the one @sww1235 posted above.

If you are interested in the board I'm attempting to use your script on, then the board is this one: https://github.com/dumle29/TMC2130-smoothie With the libraries here: https://github.com/dumle29/kicad-libraries

Duckle29 commented 7 years ago

Asked some devs, and this is the commit that broke it. https://github.com/KiCad/kicad-source-mirror/commit/3cba1007eb36c1cef96ae44f66043870c3fb30a3

broke it a lot

mmccoo commented 6 years ago

I have tried running on both test cases and they work for me.

Too late for the two of you but perhaps helpful for future projects or someone else.

Thank you for taking the time to report the problems you found.