Giter VIP home page Giter VIP logo

viastitching's Introduction

ViaStitching

Via Stitching action-plugin for use with KiCAD 6.0+.

Fill a selected copper area with a pattern of vias.

When to use this tool

Whenever you need to fill a copper area with vias to improve thermal or current conduction this tool is the answer (yet not the best one probably). The plugin is based on pre-existing areas so you have to define and select one before invoking the plugin.

Install

As any other KiCAD plugin - ViaStitching must be installed into one of the allowed path, my personal advice is to install it as a user plugin. To install it as user plugin on Windows systems (KiCAD 7.0) you should put plugins files into:

C:\Users<user_folder>\Documents\KiCad\7.0\scripting\plugins\viastitching

How it works

The workflow is pretty simple: select the area you want to fill, click on Tools->External Plugins->ViaStitching or click on AddNet icon toolbar icon: a dilaog like the one below should appear:

ViaStitching dialog

The vias you're going to create needs to be assigned a net usually this's the net of the target area for this reason the plugin pre-select this net for you; of course you're free to select another net if you like. The plugin dialog let you also specify the parameters for the via creation (via size and drill size), such values are taken from board configuration, you can change them but beware to use values that will not conflict with DRC rules; you can customize also: vertical and horizontal spacing between vias and edge clearance (insert 0 will disable check). When you're satisfied with your settings you have just to press Ok and the fillup will begin (I'm assuming Fill action is checked). If everything goes fine you'll get something like this:

viastitching result

After stitching is always a good practice to perform a DRC.

As you can see some implanted vias may still overlap with some other PCB elements (tracks, zone, pads, vias etc) at this development stage the removal of conflicting vias is up to the user with future releases the implant process will prevent vias to overlap with other elements.

The default action of the dialog is the Fill action (as you can notice from the radio-button on the bottom) but this plugin is not limited to this function only. Clear action works the in the opposite way: it removes from selected area any vias matching settings (i.e. same net, same size, same drill specified in dialog fields). Beware: Clear will not distinguish vias implanted by Fill from user ones until you check the specific checkbox, and will remove all of them if they match the values entered. If you check clear only plugin placed vias widget the plugin will inspect vias grouped on a specific group and remove only those matching: this can be used as an Undo feature.

TODO

Some features still to code:

  • Match user units (mm/inches).
  • Add clear area function.
  • Draw a better UI (if anyone is willing to contribute please read the following section).
  • Collision between new vias and underlying objects:
    • tracks,
    • zones,
    • pads,
    • footprint zones,
    • modules,
    • vias.
  • Different fillup patterns/modes (bounding box, centered spiral).
  • Avoid placing vias near area edges (define clearance).
  • History management (board commit).
  • Localization.
  • Support for multiple zones
  • Storage of stitching configuration for each individual zone as JSON string in a user layer.
  • Any request?

Coding notes

If you are willing to make any modification to the GUI (you're welcome) trough wxFormBuilder (viastitching.fbp file) remember to modify this line (around line 25 viastitching_gui.py):

self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )

In this way:

if sys.version_info[0] == 2:
 self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
else:
 self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )

This modification allows the code to work with Python 2 (that's the standard KiCAD/Python distribution AFAIK) as long as Python 3, please note that you need to import sys. Special thanks to NilujePerchut for this hint.

kicad-action-scripts - ViaStitching plugin similarity

Yes my plugin is pretty similar to this plugin but I'm using a radically different approach in coding. At the time I wrote the first release of my plugin unluckly jsreynaud plugin wasn't working but I bet he will fix it.

References

Some useful references that helped me coding this plugin:

  1. https://sourceforge.net/projects/wxformbuilder/
  2. https://wxpython.org/
  3. http://docs.kicad-pcb.org/doxygen-python/namespacepcbnew.html
  4. https://forum.kicad.info/c/external-plugins
  5. https://github.com/KiCad/kicad-source-mirror/blob/master/Documentation/development/pcbnew-plugins.md
  6. https://kicad.mmccoo.com/
  7. http://docs.kicad-pcb.org/5.1.4/en/pcbnew/pcbnew.html#kicad_scripting_reference

Tool I got inspired by:

Greetings

Hope someone find my work useful or at least inspiring to create something else/better. Special thanks to everyone that contributed to this project:

Last but not least, I would like to thank everyone who shared their knowledge of Python and KiCAD with me: Thanks!

Live long and prosper!

That's all folks.

By[t]e{s} Weirdgyn

viastitching's People

Contributors

danwood76 avatar giulio-borsoi avatar weirdgyn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar

viastitching's Issues

"No vias implanted" or Error

Trying to use this plugin, but not able to get it work.

When pressing 'Ok' button with Randomize ticked, I get the following traceback:

Traceback (most recent call last): File "C:\Users/tomjo/Documents/KiCad/7.0/scripting\plugins\viastitching-master\viastitching_dialog.py", line 456, in onProcessAction self.FillupArea() File "C:\Users/*my_name*/Documents/KiCad/7.0/scripting\plugins\viastitching-master\viastitching_dialog.py", line 363, in FillupArea p = pcbnew.VECTOR2I(xp, yp) File "C:\Program Files\KiCad\7.0\bin\Lib\site-packages\pcbnew.py", line 5003, in __init__ _pcbnew.VECTOR2I_swiginit(self, _pcbnew.new_VECTOR2I(*args)) TypeError: in method 'new_VECTOR2I', argument 1 of type 'int' Additional information: Wrong number or type of arguments for overloaded function 'new_VECTOR2I'. Possible C/C++ prototypes are: VECTOR2< int >::VECTOR2() VECTOR2< int >::VECTOR2(wxPoint const &) VECTOR2< int >::VECTOR2(wxSize const &) VECTOR2< int >::VECTOR2(int,int) VECTOR2< int >::VECTOR2(VECTOR2< int > const &)

When pressing 'Ok' button without Randomize ticked, I get "No vias implanted" and nothing happens beside the plugin dialogue box closing as if its done its job (Pic below). Looks like this, with the test copper pour area shown underneath. Tried varying via size and clearance to no avail. Sometimes I click the Ok button and nothing happens either...

image

Any hints would be great. Cheers

Not compatible with KiCAD 6.0

Will it be updated in the future?

image

Information:

Application: KiCad PCB 编辑器 (64-bit)
Version: (6.0.0-rc1-45-gbfad40bdcc), release build
Libraries:
wxWidgets 3.1.5
libcurl/7.78.0-DEV Schannel zlib/1.2.11
Platform: Windows 10 (build 22000), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
Date: Nov 17 2021 12:01:05
wxWidgets: 3.1.5 (wchar_t,wx containers)
Boost: 1.76.0
OCC: 7.5.0
Curl: 7.78.0-DEV
ngspice: 35
Compiler: Visual C++ 1929 without C++ ABI
Build settings:
KICAD_USE_OCC=ON
KICAD_SPICE=ON

Clearance

when set value in a Clearance box, it do nothing and it can't generate via.
image

Vias are placed so that DRC error is produced.

When selecting with other fill method then rectangle, vias are palced also to other layers (e.g. VCC)
Vias should only be placed, where the same net is and no short is produced.
In rectangle it works, on others not.

Execution time

So is is normal for the script to take hours to run on a 4 layer board?
I did run it with great effect on 2 layer boards and it was fine. but not it takes ages, i can see that some vias were placed both in layout and 3d model but kicad is frozen.
Also on a side note is there a way to tell the script not to put vias in certain areas so that i can later remove that zone and stitch with another net?

Via Stitching places 0 vias

I have a 4-layer board with 3 layers having ground pour and one layer having Vcc pour. I am trying to stitch ground vias and no matter what settings I try ViaStitching returns successfully but reports placing 0 vias. I have other boards where stitching works properly, so it must be something about the board settings for this board. I've tried various clearances and hold/via sizes but nothing changes the result.

Any suggestion what I should be looking for?

Running KiCad Application: KiCad PCB Editor x86_64 on x86_64

Version: 7.0.9-7.0.9~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: Linux Mint 21.2, 64 bit, Little endian, wxGTK, cinnamon, x11

Build Info:
Date: Nov 8 2023 19:01:25
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

Stitching seems to avoid all keepout zones

Hello!

I made a board with some keepout zones for footprints as I have some mechanical constraints. This had the side effect that it looks like it also keeps the stitching from adding vias to these areas.
image

Plugin not working using KiCad 7.0

Trying to place vias using this plugin and KiCad 7.0 does not work with the following error:

Traceback (most recent call last):
  File "/Users/frank/Documents/KiCad/7.0/scripting/plugins/viastitching-master/viastitching_dialog.py", line 418, in onProcessAction
    title_block.SetHorizJustify(pcbnew.GR_TEXT_HJUSTIFY_LEFT)
AttributeError: module 'pcbnew' has no attribute 'GR_TEXT_HJUSTIFY_LEFT'

KiCad version info:

Application: KiCad PCB Editor arm64 on arm64

Version: 7.0.1-0, release build

Libraries:
	wxWidgets 3.2.2
	FreeType 2.12.1
	HarfBuzz 5.3.1
	FontConfig 2.14.0
	libcurl/7.86.0 SecureTransport (LibreSSL/3.3.6) zlib/1.2.11 nghttp2/1.47.0

Platform: macOS Ventura Version 13.2.1 (Build 22D68), 64 bit, Little endian, wxMac

Build Info:
	Date: Mar 11 2023 12:11:29
	wxWidgets: 3.2.2 (wchar_t,wx containers)
	Boost: 1.80.0
	OCC: 7.6.3
	Curl: 7.77.0
	ngspice: 38
	Compiler: Clang 13.0.0 with C++ ABI 1002

Build settings:
	KICAD_SPICE=ON

Geting stuck

So after running the scrips of a few boards i found this pattern:
It works well only on simple 2 layer boards, if it has more then 2 layers or is fairly complex it gets stuck and computes for hours.

BUT also sometimes if the runtime is long enough it finds a pattern and layers it out visually and if you wit enough it will be auto saved or something and after you kill the task and reload the project it will still be there.

Also would using random help in these cases? is it a lighter script in terms of resources?

delete failed

"Clear only plugin placed vias" cannot be deleted after being selected, and can be deleted when deselected
image

win10
kicad6.0.7

Doesn't do anything: NotImplementedError: Wrong number or type of arguments for overloaded function 'new_VECTOR2I'.

Pressing the OK button results in nothing. No messages, no vias, nothing.

If I open the Python console and then hit OK, I'll get some errors in another window:

Traceback (most recent call last):
File "/home/jeremy/.local/share/kicad/6.0/scripting/plugins/viastitching-master/viastitching_dialog.py", line 456, in onProcessAction
self.FillupArea()
File "/home/jeremy/.local/share/kicad/6.0/scripting/plugins/viastitching-master/viastitching_dialog.py", line 363, in FillupArea
p = pcbnew.VECTOR2I(xp, yp)
File "/usr/lib/python3/dist-packages/pcbnew.py", line 5286, in init
this = _pcbnew.new_VECTOR2I(*args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_VECTOR2I'.
Possible C/C++ prototypes are:
VECTOR2< int >::VECTOR2()
VECTOR2< int >::VECTOR2(wxPoint const &)
VECTOR2< int >::VECTOR2(wxSize const &)
VECTOR2< int >::VECTOR2(int,int)
VECTOR2< int >::VECTOR2(VECTOR2< int > const &)

Traceback (most recent call last):
File "/home/jeremy/.local/share/kicad/6.0/scripting/plugins/viastitching-master/viastitching_dialog.py", line 456, in onProcessAction
self.FillupArea()
File "/home/jeremy/.local/share/kicad/6.0/scripting/plugins/viastitching-master/viastitching_dialog.py", line 363, in FillupArea
p = pcbnew.VECTOR2I(xp, yp)
File "/usr/lib/python3/dist-packages/pcbnew.py", line 5286, in init
this = _pcbnew.new_VECTOR2I(*args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_VECTOR2I'.
Possible C/C++ prototypes are:
VECTOR2< int >::VECTOR2()
VECTOR2< int >::VECTOR2(wxPoint const &)
VECTOR2< int >::VECTOR2(wxSize const &)
VECTOR2< int >::VECTOR2(int,int)
VECTOR2< int >::VECTOR2(VECTOR2< int > const &)

Traceback (most recent call last):
File "/home/jeremy/.local/share/kicad/6.0/scripting/plugins/viastitching-master/viastitching_dialog.py", line 456, in onProcessAction
self.FillupArea()
File "/home/jeremy/.local/share/kicad/6.0/scripting/plugins/viastitching-master/viastitching_dialog.py", line 363, in FillupArea
p = pcbnew.VECTOR2I(xp, yp)
File "/usr/lib/python3/dist-packages/pcbnew.py", line 5286, in init
this = _pcbnew.new_VECTOR2I(*args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_VECTOR2I'.
Possible C/C++ prototypes are:
VECTOR2< int >::VECTOR2()
VECTOR2< int >::VECTOR2(wxPoint const &)
VECTOR2< int >::VECTOR2(wxSize const &)
VECTOR2< int >::VECTOR2(int,int)
VECTOR2< int >::VECTOR2(VECTOR2< int > const &)

Input boxes small using KiCad 7.0

When using KiCad 7.0, the input boxes are unusably small:
Screenshot 2023-03-22 at 12 55 31

This is similar to the resolved KiCad issue #13866.

KiCad version info:

Application: KiCad PCB Editor arm64 on arm64

Version: 7.0.1-0, release build

Libraries:
	wxWidgets 3.2.2
	FreeType 2.12.1
	HarfBuzz 5.3.1
	FontConfig 2.14.0
	libcurl/7.86.0 SecureTransport (LibreSSL/3.3.6) zlib/1.2.11 nghttp2/1.47.0

Platform: macOS Ventura Version 13.2.1 (Build 22D68), 64 bit, Little endian, wxMac

Build Info:
	Date: Mar 11 2023 12:11:29
	wxWidgets: 3.2.2 (wchar_t,wx containers)
	Boost: 1.80.0
	OCC: 7.6.3
	Curl: 7.77.0
	ngspice: 38
	Compiler: Clang 13.0.0 with C++ ABI 1002

Build settings:
	KICAD_SPICE=ON

Undo last edit (CTRL + Z) doesn't remove vias added by this plugin

Hi,

Thanks for sharing this plugin, I am new to kicad and on the other cad programs, this is very easily done, but I could not find a way to do the via stitching on a zone until I found this plugin.

At first I was trying this plugin out and luckily I saved the board before running it because I was not able to remove the 5000+ vias added to the board with undo. So I closed it and re-open it and was back to the clean board and corrected the density problem, but it would be a good feature if undo would actually undo the via stitching also. Maybe a feature request, a workaround maybe would be if all the new vias are selected so a delete would remove them?

Thanks again.

KiCAD 7 Problems

I'm having some issues running this on kicad 7. Here is the traceback I'm getting.

Traceback (most recent call last):
  File "C:\Users/Kiran Shila/Documents/KiCad/7.0/scripting\plugins\viastitching\viastitching_dialog.py", line 453, in onProcessAction
    self.FillupArea()
  File "C:\Users/Kiran Shila/Documents/KiCad/7.0/scripting\plugins\viastitching\viastitching_dialog.py", line 365, in FillupArea
    if self.area.HitTestFilledArea(layer, p, 0):
  File "C:\Program Files\KiCad\7.0\bin\Lib\site-packages\pcbnew.py", line 13738, in HitTestFilledArea
    return _pcbnew.ZONE_HitTestFilledArea(self, aLayer, aRefPos, aAccuracy)
TypeError: in method 'ZONE_HitTestFilledArea', argument 3 of type 'VECTOR2I const &'
Additional information:
Wrong number or type of arguments for overloaded function 'ZONE_HitTestFilledArea'.
  Possible C/C++ prototypes are:
    ZONE::HitTestFilledArea(PCB_LAYER_ID,VECTOR2I const &,int) const
    ZONE::HitTestFilledArea(PCB_LAYER_ID,VECTOR2I const &) const

Any advise would be appreciated.

Not working in Kicad 6.0 on linux

I tried using the plugin after upgrading but after clicking "ok" nothing happens. I launched kicad using console to see what the output is and got the following:

  File "/home/dmytro/.local/share/kicad/6.0/scripting/plugins/viastitching-master/viastitching_dialog.py", line 307, in onProcessAction
    self.FillupArea()
  File "/home/dmytro/.local/share/kicad/6.0/scripting/plugins/viastitching-master/viastitching_dialog.py", line 278, in FillupArea
    if self.area.HitTestInsideZone(p):
  File "/usr/lib/python3/dist-packages/pcbnew.py", line 14913, in <lambda>
    __getattr__ = lambda self, name: _swig_getattr(self, ZONE, name)
  File "/usr/lib/python3/dist-packages/pcbnew.py", line 80, in _swig_getattr
    raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
AttributeError: 'ZONE' object has no attribute 'HitTestInsideZone'

Any idea what could be causing this and how to fix it?

Plugin not running

Good afternoon. Having selected the GND area, I launch the plugin, drive in the necessary parameters as in your photo, click OK and nothing happens. Please tell me what I'm doing wrong, thanks.

Exception on python action plugin code

Hi,

I got an error when trying to use this plugin on Kicad 6 on Windows 11. I've installed the plugin in the scripting\plugins folder.

image

This hapened to me when trying it in a new blank pcbnew window.

thanks for the plugin btw!

Error in KiCad 8

---------------------------
Exception on python action plugin code
---------------------------
Traceback (most recent call last):

  File "D:\Users/PC/Documents/KiCad/8.0/scripting\plugins\com_github_jsreynaud_kicad-action-scripts\ViaStitching\FillAreaAction.py", line 88, in Run
    fill.Run()

  File "D:\Users/PC/Documents/KiCad/8.0/scripting\plugins\com_github_jsreynaud_kicad-action-scripts\ViaStitching\FillArea.py", line 590, in Run
    board_edge.Deflate(int(b_clearance), int(12),  SHAPE_POLY_SET.ROUND_ALL_CORNERS)
                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

AttributeError: type object 'SHAPE_POLY_SET' has no attribute 'ROUND_ALL_CORNERS'

After starting the generation of the 'vias' I get this error message.

no vias implanted

For some reason, I do not have the fill option to check and regardless of the settings, no vias are implanted.
via1
via2

'wxPoint' and 'VECTOR2I' error

Hi, i am using the script in KiCAD 7 but i received below error.
.....\viastitching-master\viastitching_dialog.py", line 259, in CheckClearance
the_distance = norm(p2 - p1) # sqrt((p2.x - p1.x) ** 2 + (p2.y - p1.y) ** 2)
TypeError: unsupported operand type(s) for -: 'wxPoint' and 'VECTOR2I'

if yo can change viastitching_dialog .py as below, it is working
p1 = pcbnew.VECTOR2I(via.GetPosition())
corners = area.GetNumCorners()
# Calculate minimum distance from corners
# TODO: remove?
for i in range(corners):
corner = area.GetCornerPosition(i)
p2 = pcbnew.VECTOR2I(corner.getWxPoint())
the_distance = norm(p2 - p1) # sqrt((p2.x - p1.x) ** 2 + (p2.y - p1.y) ** 2)

        if the_distance < clearance:
            return False

Downloaded package hash does not match the repository record on KiCad8

When I tried to install this extension on KiCad 8.0.1, it failed to install and thrown this error message. It says the HASH of the downloaded package is not match the repository record. Besides, it warns me its not compatible with KiCad 8 when I tried to install it.
Translated screenshot is shown below.
0dd69be0-e223-470b-b951-91aea59266a2
Original screenshot is shown below.
屏幕截图 2024-03-28 195917

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.