← Back to team overview

kicad-developers team mailing list archive

Re: PadDrillStencilSilk.py (was Hello, first post, sharing python code)

 

Greg,

You are welcome to announce python scripts on the KiCad developers
mailing list.  Your best bet would be to post your code on either
launchpad or github and ask for help testing your code.  If other
developers find it useful and reasonably mature, then a decision by the
lead developers can be made as to whether or not to include in KiCad.
Thank you for your interest in contribution to KiCad.

Cheers,

Wayne

On 7/8/2017 11:22 AM, Greg Smith wrote:
> I'm seeking input on appropriate place to document progress on my python
> pads script. (Should I stop posting on the developer's list until it's
> much closer to deploy?) Here is the latest update from the comments in
> the code. I haven't posted it anywhere yet, but I'd be glad to share
> snippets of code if you're interested, just ask! My intent is to donate
> to the KiCAD project when I get it to conform to the style guidelines
> and fix some of the shortcomings (pad shapes, and front/back pads, in
> particular).
> 
> I also have decent references to drill sizes, and stencil rules of thumb
> (vs. aperture ratios, solder powder size/type).
> 
> If you are aware of other tools (including built-in KiCAD tools) that do
> the same tasks or similar, please let me know.
> 
> Greg S.
> 
> # PadDrillStencilSilk.py
> # Original Author: Greg Smith, June 2017
> #
> # ABOUT:
> #    This python script provides additional basic DRC checks to KiCAD
> #    and lists to make tweaking pads for stencil creation.
> #    It adds a menu item to "Tools" called Pads/Vias/Stencils.
> #
> # This is VERY beta. Not thoroughly tested. Not well commented.
> #
> # Not conforming to style guides (neither Python nor KiCAD style guides).
> # Inputs and outputs are in varying non-changable units (mils, inches,
> mm, nm)
> # Only tested on KiCAD 4.06, Windows 7.
> #
> # Install: place file in C:\Program
> Files\KiCad\share\kicad\scripting\plugins\PadDrillStencilSilk.py
> # in pcbnew, open scripting console (Tools > Scripting Console)
> # type "import PadDrillStencilSilk"
> #
> # THERE ARE BUGS:
> #
> # Only handles 2-layer boards, only through vias, and pads are not
> verified for shape.
> # Does not check pad drill DRC
> # Assumes all pads are on the front.
> # Does not mix via drill and pad drill checks.
> # Does not check annular ring size.
> #
> # Pad Info: Produces two lists: 
> #   1) detailed list of pads by footprint reference with paste/mask
> properties
> #   2) quantity of pads by size
> # Drill Info: Generates multiple lists:
> #   1) Hole quantity by specified pad drill sizes
> #   2) Quantity by closest larger standard drill size (future option to
> pick drill sets)
> #   3) Drill list
> #   4) Distance from each via to next closest via
> #   5) Checks via drill to via drill clearance
> #   6) Checks via drill to track clearance
> # Stencil Info:
> #   1) Lists quantity of apertures by aperture size
> #   2) Summary of aperture ratios by stencil thickness
> #   3) Checks AspectRatio and AreaRatio against a variety 
> #      of stencil thicknesses (2 mil-7 mil, all currently hardcoded)
> #
> # EXAMPLES:
> #
> # Pad Info: Produces two lists: 
> #   1) detailed list of pads by footprint reference with paste/mask
> properties
> #      Number of pads: 293
> #      
> #        ***** Pads By Footprint Reference, Alphabetical *****
> #      #    4(BT1.) X=113.665086 Y=147.423648 P=CIRC (2.64, 2.64) D=CIRC
> #             (2.64, 2.64) Layers=F.Cu,B.Cu,B.Mask,F.Mask lc=0.0000 c=0.1530
> #             Paste: spm=0.0000,0.0000 lspm=0.0000 lspmr=0.0000 | Mask :
> smm=0.0000 lsmm=0.0000
> #      ...
> #   2) quantity of pads by size
> #      ***** Quantity of Pads By Size *****
> #      Size: 0.900 0.900, Quantity 4
> #      Size: 0.875 1.250, Quantity 2
> #      Size: 0.800 1.200, Quantity 2
> #      Size: 0.900 1.700, Quantity 1
> #      Size: 0.300 0.800, Quantity 24
> #      ...
> #
> # Drill Info: Generates multiple lists:
> #   1) Hole quantity by specified pad drill sizes
> #      ***** Quantity of Pads By Specified Drill Size *****
> #      Size: 1.020mm, Quantity 2
> #      Size: 4.826mm, Quantity 6
> #      Size: 1.000mm, Quantity 54
> #      Size: 2.640mm, Quantity 2
> #      Size: 1.097mm, Quantity 8
> #      
> #   2) Hole quantity by closest larger standard drill size (future
> option to pick drill sets)     
> #      ***** Quantity of Pads By Standard Drill Size *****
> #      Size: 1.020mm (25.908 mils), Drill: 0.041 (59), Quantity 2
> #      Size: 4.826mm (122.580 mils), Drill: 0.191 (11), Quantity 6
> #      Size: 1.000mm (25.400 mils), Drill: 0.04 (60), Quantity 54
> #      Size: 2.640mm (67.056 mils), Drill: 0.104 (37), Quantity 2
> #      Size: 1.097mm (27.871 mils), Drill: 0.0465 (56), Quantity 8
> #
> #   3) Drill list
> #      ***** Drill Holes List (pad #, position (nm), Type, Drill, Drill
> Value, Via Width) *****
> #      0 (152661291, 138048648) 3 294000 294000 600000
> #      1 (113725000, 140800000) 3 294000 294000 600000
> #      ...
> #
> #   4) Distance from each via to next closest via
> #      ***** Distance to next closest via  ***** (looking only *forward*
> through the list)
> #      
> #      Minimum Via to Via = 20.000 mils (0.508 mm)
> #      0 3.692 mm
> #      1 1.205 mm
> #      ...
> #
> #   5) Checks via drill to via drill clearance
> #      ***** Vias too close to another via *****
> #      29
> #      44
> #      ...
> 
> #   6) Checks via drill to track clearance
> #      ***** Vias too close to track *****
> #      31 Via (/IOC_RB6) at (125934690, 138137006) is 306005 away from
> track (/IOC_RB5)
> #         ((126280790, 137531001) ; (125660499, 137531001)). Shoud be 508000
> #      23 Via (/GND) at (150540086, 141423648) is 307472 away from track
> (/RE2)
> #         ((149487558, 140816176) ; (152110941, 140816176)). Shoud be 508000
> #      ...
> #      
> # 
> # Stencil Info:
> #   1) Lists quantity of apertures by aperture size:
> #      (Aperture size in mm, triplets of stencil mil thickness, area
> ratio, aspect ratio)
> #      (qty 24)Aperture=0.225,0.725 (2.0 1.69 4.43) (3.0 1.13 2.95) (4.0
> 0.85 2.21)
> #         (5.0 0.68 1.77) (6.0 0.56 1.48) (7.0 0.48 1.27)
> #     Pads: [20, 45, 80, 98, 99, 100, 101, 109, 113, 121, 125, 140, 143,
> 165,
> #         205, 208, 209, 210, 233, 234, 238, 239, 241, 244]
> #         From: CONN_01X24
> #      ...
> #
> #   2) Summary of aperture ratios by stencil thickness
> #       ***** Aperture Ratio Ranges *****
> #       2.0 mil Aspect: 4.429 14.764Area  : 1.471 4.318
> #       3.0 mil Aspect: 2.953 9.843Area  : 0.981 2.879
> #       4.0 mil Aspect: 2.215 7.382Area  : 0.735 2.159
> #       5.0 mil Aspect: 1.772 5.906Area  : 0.588 1.727
> #       6.0 mil Aspect: 1.476 4.921Area  : 0.490 1.439
> #       7.0 mil Aspect: 1.265 4.218Area  : 0.420 1.234
> #
> #   3) Checks AspectRatio and AreaRatio against a variety 
> #      of stencil thicknesses (2 mil-7 mil, all currently hardcoded):
> #       ***** Failed Aperture Test *****
> #       Failed 5.0 mil thickness:
> #       Failed Area  : 0.445 0.225
> #       Failed Area  : 0.300 0.350
> #       Failed 6.0 mil thickness:
> #       Failed Area  : 0.555 0.245
> #       Failed Area  : 0.445 0.225
> #       Failed Area  : 0.300 0.350
> #       Failed Area  : 0.225 0.725
> #       Failed Aspect: 0.445 0.225
> #       Failed Aspect: 0.225 0.725
> #       Failed 7.0 mil thickness:
> #       Failed Area  : 0.555 0.245
> #       Failed Area  : 0.325 0.725
> #       Failed Area  : 0.445 0.225
> #       Failed Area  : 0.300 0.350
> #       Failed Area  : 0.225 0.725
> #       Failed Aspect: 0.555 0.245
> #       Failed Aspect: 0.445 0.225
> #       Failed Aspect: 0.225 0.725
> #
> #
> # Nevertheless, there are some examples of using python code to interact
> with KiCAD:
> #    Install Tools menu, replace if already existing (allows reloading
> python file after changes)
> #    Iterate over tracks, identify vias, get sizes of via copper, mask,
> and paste
> #    Identify which layers a pad is on.
> #    Generate basic interactive window.
> #    Display  multi-threaded wx.Gauge (progress bar)
> #    Get Paste (stencil) Aperture size calculated from pad properties.
> 
> # TODO list, aside from fixing the BUGS above.
> #   Support front and back layers.
> #Support more than just through drills (i.e. buried/blind vias)
> #   Label units and make consistent. Use KiCAD-provided "native unit"
> conversion
> #   Mask Info: Checks solder mask dam sizes.
> #   Silk Info: Checks silk screen character sizes.
> #
> 
> 
> On Sunday, June 18, 2017 8:29 AM, Greg Smith <ecomputerd@xxxxxxxxx> wrote:
> 
> 
> Hello!
> 
> This is my first post. I've read some of the material for KiCAD
> developers and some of the mailing list archives. I hope this is
> appropriate.
> 
> I've just started using KiCAD in the last month or so. I'm an
> experienced programmer, and I thought I'd try to add to the knowledge
> base here. I've developed some python code that is in VERY BETA state
> and seeking advice on how, when, and where to share it. Below are the
> comments at the top of the file.
> 
> Right now it might best be considered as some python examples of
> interacting with KiCAD.
> 
> How solid, tested, and guideline-conforming should the code be prior to
> sharing?
> 
> Any comments, questions, or advice welcome.
> 
> Greg S.
> 
> 
> # Original Author: Greg Smith, June 2017
> # This is VERY beta. Not thoroughly tested. Not well commented. Not
> optimized for memory or run time.
> # Not conforming to style guides (neither Python nor KiCAD style guides).
> # Inputs and outputs are in varying non-changable units (mils, inches,
> mm, nm)
> # Only tested on KiCAD 4.06, Windows 7.
> #
> # Install: place file in C:\Program
> Files\KiCad\share\kicad\scripting\plugins\PadDrillStencilSilk.py
> # in pcbnew, open scripting console (Tools > Scripting Console)
> # type "import PadDrillStencilSilk.py"
> # This python package provides additional basic DRC checks to KiCAD
> # It adds a menu item to "Tools" called Pads/Vias/Stencils.
> #
> # THERE ARE BUGS:
> # Only handles 2-layer boards, only through vias, and pads are not
> verified for shape.
> # Does not check pad drill DRC
> # Assumes all pads are on the front.
> # Does not mix via drill and pad drill checks.
> # Does not check annular ring size.
> #
> # Pad Info: quantity of pads by size, detailed list of pads and some
> python properties
> # Drill Info: Lists specified pad drill sizes, and closest larger
> standard drill size
> #             Checks via drill to via drill clearance, and via drill to
> track clearance
> #             Lists quantity by size
> # Stencil Info: Lists apertures, checks AspectRatio and
> # AreaRatio against a variety of stencil thicknesses (all currently
> hardcoded)
> #
> # Nevertheless, there are some examples of useing python code to
> interact with KiCAD:
> # Install Tools menu, replace if already existing (allows reloading
> python file after changes)
> # Iterate over tracks, identify vias, get sizes of via copper, mask, and
> paste
> # Identify which layers a pad is on.
> # Generate basic interactive window.
> # Get Paste (stencil) Aperture size calculated from pad properties.
> 
> # TODO list, aside from fixing the BUGS above.
> #    Mask Info: Checks mask sizes.
> #    Silk Info: Checks silk screen character sizes.
> 
> 
> 
> 
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
> 


References