first step to renew the repo

This commit is contained in:
easyw
2019-11-03 15:29:21 +01:00
parent 906781118d
commit 37e0a2a07f
42 changed files with 8432 additions and 659 deletions

View File

@ -0,0 +1,2 @@
from .fabrication_positions import generatePOS
generatePOS().register()

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,308 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="26"
width="26"
version="1.1"
viewBox="0 0 26 26"
id="svg2"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="fabricationPositions.svg"
inkscape:export-filename="/home/mau/.kicad_plugins/kicad-action-tools/FabricationPositions/fabricationPositions.png"
inkscape:export-xdpi="118.15385"
inkscape:export-ydpi="118.15385">
<metadata
id="metadata119">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1009"
id="namedview117"
showgrid="true"
inkscape:snap-to-guides="false"
inkscape:snap-grids="false"
inkscape:zoom="9.8333334"
inkscape:cx="-21.180697"
inkscape:cy="9.566445"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg2">
<inkscape:grid
type="xygrid"
id="grid3099"
empspacing="1"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true" />
</sodipodi:namedview>
<defs
id="defs4">
<filter
id="g"
color-interpolation-filters="sRGB">
<feGaussianBlur
stdDeviation="1.2065414"
id="feGaussianBlur7" />
</filter>
<filter
id="f"
color-interpolation-filters="sRGB">
<feGaussianBlur
stdDeviation="0.89955545"
id="feGaussianBlur10" />
</filter>
<linearGradient
id="h"
y2="94.103996"
gradientUnits="userSpaceOnUse"
x2="86.571999"
gradientTransform="matrix(0.41535,0,0,0.36675,-1.7202,-21.66944)"
y1="104"
x1="96">
<stop
stop-color="#888a85"
offset="0"
id="stop13" />
<stop
stop-color="#8c8e89"
offset=".0072"
id="stop15" />
<stop
stop-color="#abaca9"
offset=".0673"
id="stop17" />
<stop
stop-color="#c5c6c4"
offset=".1347"
id="stop19" />
<stop
stop-color="#dbdbda"
offset=".2115"
id="stop21" />
<stop
stop-color="#ebebeb"
offset=".3012"
id="stop23" />
<stop
stop-color="#f7f7f6"
offset=".4122"
id="stop25" />
<stop
stop-color="#fdfdfd"
offset=".5679"
id="stop27" />
<stop
stop-color="#fff"
offset="1"
id="stop29" />
</linearGradient>
<radialGradient
id="i"
gradientUnits="userSpaceOnUse"
cy="109.33"
cx="99.081001"
gradientTransform="matrix(0.40651,0,0,0.36008,-1.1546,-21.24267)"
r="139.56">
<stop
stop-color="#7a7d80"
offset="0"
id="stop32" />
<stop
stop-color="#c2c2c2"
offset=".12618"
id="stop34" />
<stop
stop-color="#fafafa"
offset=".23251"
id="stop36" />
<stop
stop-color="#fff"
offset=".27220"
id="stop38" />
<stop
stop-color="#fafafa"
offset=".53130"
id="stop40" />
<stop
stop-color="#ebecec"
offset=".84490"
id="stop42" />
<stop
stop-color="#e1e2e3"
offset="1"
id="stop44" />
</radialGradient>
<radialGradient
id="j"
gradientUnits="userSpaceOnUse"
cy="112.3"
cx="102"
gradientTransform="matrix(0.41535,0,0,0.36675,-1.7202,-21.66944)"
r="139.56">
<stop
stop-color="#00537d"
offset="0"
id="stop47" />
<stop
stop-color="#186389"
offset=".0151"
id="stop49" />
<stop
stop-color="#558ca8"
offset=".0558"
id="stop51" />
<stop
stop-color="#89afc3"
offset=".0964"
id="stop53" />
<stop
stop-color="#b3ccd8"
offset=".1357"
id="stop55" />
<stop
stop-color="#d4e2e9"
offset=".1737"
id="stop57" />
<stop
stop-color="#ecf2f5"
offset=".20990"
id="stop59" />
<stop
stop-color="#fafcfd"
offset=".24350"
id="stop61" />
<stop
stop-color="#fff"
offset=".27220"
id="stop63" />
</radialGradient>
</defs>
<g
transform="matrix(0,-2.848,2.44,0,-47.718,31.429)"
id="g73">
<rect
height="16"
width="16"
y="0"
x="0"
id="rect75"
style="fill-opacity:0" />
</g>
<g
id="g3114"
transform="matrix(0.62102756,0,0,0.47728223,30.575,21.588382)">
<rect
id="rect51"
x="10.679863"
y="-37.439487"
width="14.08869"
height="22.924355"
transform="matrix(0,-1,1,0,0,0)"
style="fill:#ffffff;stroke:#545454;stroke-width:0.97711289;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
id="path53"
d="m -37.947999,-20.191301 a 2.2240581,1.9589449 0 1 1 0.01376,3.917871"
inkscape:connector-curvature="0"
style="fill:none;stroke:#545454;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<g
id="g3983"
transform="translate(-38.934238,-31.273427)">
<rect
style="fill:#00c921;fill-opacity:1;stroke:#545454;stroke-width:0.93241322;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
transform="matrix(0,-1,1,0,0,0)"
height="4.0659709"
width="6.0590835"
y="4.5123401"
x="-8.5317764"
id="rect73" />
<rect
style="fill:#00c921;fill-opacity:1;stroke:#545454;stroke-width:0.93241322;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
transform="matrix(0,-1,1,0,0,0)"
height="4.0659709"
width="6.0590835"
y="11.451617"
x="-8.5076618"
id="rect73-5" />
<rect
style="fill:#00c921;fill-opacity:1;stroke:#545454;stroke-width:0.93241322;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
transform="matrix(0,-1,1,0,0,0)"
height="4.0659709"
width="6.0590835"
y="18.488895"
x="-8.5498009"
id="rect73-56" />
</g>
<g
id="g3983-1"
transform="translate(-38.880389,-15.182579)">
<rect
style="fill:#00c921;fill-opacity:1;stroke:#545454;stroke-width:0.93241322;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
transform="matrix(0,-1,1,0,0,0)"
height="4.0659709"
width="6.0590835"
y="4.5123401"
x="-8.5317764"
id="rect73-0" />
<rect
style="fill:#00c921;fill-opacity:1;stroke:#545454;stroke-width:0.93241322;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
transform="matrix(0,-1,1,0,0,0)"
height="4.0659709"
width="6.0590835"
y="11.451617"
x="-8.5076618"
id="rect73-5-4" />
<rect
style="fill:#00c921;fill-opacity:1;stroke:#545454;stroke-width:0.93241322;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
transform="matrix(0,-1,1,0,0,0)"
height="4.0659709"
width="6.0590835"
y="18.488895"
x="-8.5498009"
id="rect73-56-9" />
</g>
</g>
<path
style="opacity:0.9;fill:#1a1a1a;stroke:#1a1a1a;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none"
inkscape:connector-curvature="0"
d="M 23.586866,4.8640376 H 1.4326435"
id="path3429" />
<path
style="opacity:0.9;fill:#1a1a1a;stroke:#1a1a1a;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none"
inkscape:connector-curvature="0"
d="M 5.0093577,22.336199 V 2.0069966"
id="path3431" />
<path
style="stroke:#1a1a1a;stroke-width:0.69115704px;fill:#1a1a1a;opacity:0.9"
inkscape:connector-curvature="0"
d="M 24.335311,4.8146508 21.121519,2.0266169 v 5.7571524 z"
id="path3433" />
<path
style="stroke:#1a1a1a;stroke-width:0.69115704px;opacity:0.9"
inkscape:connector-curvature="0"
d="M 5.0744971,23.968314 7.8693327,20.762005 H 2.0978019 Z"
id="path3435" />
</svg>

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,302 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="26"
width="26"
version="1.1"
viewBox="0 0 26 26"
id="svg2"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="fabricationPositions.svg"
inkscape:export-filename="/home/mau/.kicad_plugins/kicad-action-tools/FabricationPositions/fabricationPositions.png"
inkscape:export-xdpi="118.15385"
inkscape:export-ydpi="118.15385">
<metadata
id="metadata119">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1009"
id="namedview117"
showgrid="true"
inkscape:snap-to-guides="false"
inkscape:snap-grids="false"
inkscape:zoom="30.961538"
inkscape:cx="12.967702"
inkscape:cy="13"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg2">
<inkscape:grid
type="xygrid"
id="grid3099"
empspacing="1"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true" />
</sodipodi:namedview>
<defs
id="defs4">
<filter
id="g"
color-interpolation-filters="sRGB">
<feGaussianBlur
stdDeviation="1.2065414"
id="feGaussianBlur7" />
</filter>
<filter
id="f"
color-interpolation-filters="sRGB">
<feGaussianBlur
stdDeviation="0.89955545"
id="feGaussianBlur10" />
</filter>
<linearGradient
id="h"
y2="94.103996"
gradientUnits="userSpaceOnUse"
x2="86.571999"
gradientTransform="matrix(0.41535,0,0,0.36675,-1.7202,-21.66944)"
y1="104"
x1="96">
<stop
stop-color="#888a85"
offset="0"
id="stop13" />
<stop
stop-color="#8c8e89"
offset=".0072"
id="stop15" />
<stop
stop-color="#abaca9"
offset=".0673"
id="stop17" />
<stop
stop-color="#c5c6c4"
offset=".1347"
id="stop19" />
<stop
stop-color="#dbdbda"
offset=".2115"
id="stop21" />
<stop
stop-color="#ebebeb"
offset=".3012"
id="stop23" />
<stop
stop-color="#f7f7f6"
offset=".4122"
id="stop25" />
<stop
stop-color="#fdfdfd"
offset=".5679"
id="stop27" />
<stop
stop-color="#fff"
offset="1"
id="stop29" />
</linearGradient>
<radialGradient
id="i"
gradientUnits="userSpaceOnUse"
cy="109.33"
cx="99.081001"
gradientTransform="matrix(0.40651,0,0,0.36008,-1.1546,-21.24267)"
r="139.56">
<stop
stop-color="#7a7d80"
offset="0"
id="stop32" />
<stop
stop-color="#c2c2c2"
offset=".12618"
id="stop34" />
<stop
stop-color="#fafafa"
offset=".23251"
id="stop36" />
<stop
stop-color="#fff"
offset=".27220"
id="stop38" />
<stop
stop-color="#fafafa"
offset=".53130"
id="stop40" />
<stop
stop-color="#ebecec"
offset=".84490"
id="stop42" />
<stop
stop-color="#e1e2e3"
offset="1"
id="stop44" />
</radialGradient>
<radialGradient
id="j"
gradientUnits="userSpaceOnUse"
cy="112.3"
cx="102"
gradientTransform="matrix(0.41535,0,0,0.36675,-1.7202,-21.66944)"
r="139.56">
<stop
stop-color="#00537d"
offset="0"
id="stop47" />
<stop
stop-color="#186389"
offset=".0151"
id="stop49" />
<stop
stop-color="#558ca8"
offset=".0558"
id="stop51" />
<stop
stop-color="#89afc3"
offset=".0964"
id="stop53" />
<stop
stop-color="#b3ccd8"
offset=".1357"
id="stop55" />
<stop
stop-color="#d4e2e9"
offset=".1737"
id="stop57" />
<stop
stop-color="#ecf2f5"
offset=".20990"
id="stop59" />
<stop
stop-color="#fafcfd"
offset=".24350"
id="stop61" />
<stop
stop-color="#fff"
offset=".27220"
id="stop63" />
</radialGradient>
</defs>
<g
transform="matrix(0,-2.848,2.44,0,-47.718,31.429)"
id="g73">
<rect
height="16"
width="16"
y="0"
x="0"
id="rect75"
style="fill-opacity:0" />
</g>
<g
id="g888"
transform="rotate(35,17.489961,12.636489)"
inkscape:export-xdpi="118.15385"
inkscape:export-ydpi="118.15385">
<rect
id="rect51"
x="18.048264"
y="-10.797076"
width="6.7242813"
height="14.236656"
transform="rotate(55)"
style="fill:#ffffff;stroke:#545454;stroke-width:0.5319708;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
id="path53"
d="M 21.994429,12.161141 A 0.93496958,1.3812014 55.000001 1 1 20.914881,10.634286"
inkscape:connector-curvature="0"
style="fill:none;stroke:#545454;stroke-width:0.54443127;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
id="rect73"
x="23.80514"
y="-8.92307"
width="2.8918929"
height="2.52508"
transform="rotate(55)"
style="fill:#da33e2;fill-opacity:1;stroke:#545454;stroke-width:0.50763494;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
id="rect73-5"
x="23.81665"
y="-4.6135879"
width="2.8918929"
height="2.52508"
transform="rotate(55)"
style="fill:#da33e2;fill-opacity:1;stroke:#545454;stroke-width:0.50763494;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
id="rect73-56"
x="23.796537"
y="-0.24324402"
width="2.8918929"
height="2.52508"
transform="rotate(55)"
style="fill:#da33e2;fill-opacity:1;stroke:#545454;stroke-width:0.50763494;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
id="rect73-0"
x="16.125263"
y="-8.8896284"
width="2.8918929"
height="2.52508"
transform="rotate(55)"
style="fill:#da33e2;fill-opacity:1;stroke:#545454;stroke-width:0.50763494;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
id="rect73-5-4"
x="16.136774"
y="-4.5801458"
width="2.8918929"
height="2.52508"
transform="rotate(55)"
style="fill:#da33e2;fill-opacity:1;stroke:#545454;stroke-width:0.50763494;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
id="rect73-56-9"
x="16.116661"
y="-0.20980217"
width="2.8918929"
height="2.52508"
transform="rotate(55)"
style="fill:#da33e2;fill-opacity:1;stroke:#545454;stroke-width:0.50763494;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
<path
style="opacity:0.9;fill:#1a1a1a;stroke:#1a1a1a;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none"
inkscape:connector-curvature="0"
d="M 23.586866,4.8640376 H 1.4326435"
id="path3429" />
<path
style="opacity:0.9;fill:#1a1a1a;stroke:#1a1a1a;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none"
inkscape:connector-curvature="0"
d="M 5.0093577,22.336199 V 2.0069966"
id="path3431" />
<path
style="stroke:#1a1a1a;stroke-width:0.69115704px;fill:#1a1a1a;opacity:0.9"
inkscape:connector-curvature="0"
d="M 24.335311,4.8146508 21.121519,2.0266169 v 5.7571524 z"
id="path3433" />
<path
style="stroke:#1a1a1a;stroke-width:0.69115704px;opacity:0.9"
inkscape:connector-curvature="0"
d="M 5.0744971,23.968314 7.8693327,20.762005 H 2.0978019 Z"
id="path3435" />
</svg>

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@ -0,0 +1,423 @@
# -*- coding: utf-8 -*-
#
# A script to generate POS file for kicad_pcb
# requirements: KiCAD pcbnew >= 4.0
# release "1.0.9"
# copyright Maurice easyw
#
# main script from https://forum.kicad.info/t/pcba-wants-all-parts-in-the-pos-file-not-just-smd/10045/6
#
___version___="1.2.0"
#wx.LogMessage("My message")
#mm_ius = 1000000.0
import sys, os
import pcbnew
import datetime
import wx
from pcbnew import *
import base64
from wx.lib.embeddedimage import PyEmbeddedImage
"""
execfile ("C:/kicad-wb-1602/msys64/home/userC/out3Dm/pack-x86_64/share/kicad/scripting/plugins/getpos.py")
"""
def generate_POS():
import os
mm_ius = 1000000.0
my_board = pcbnew.GetBoard()
fileName = pcbnew.GetBoard().GetFileName()
dirpath = os.path.abspath(os.path.expanduser(fileName))
path, fname = os.path.split(dirpath)
ext = os.path.splitext(os.path.basename(fileName))[1]
name = os.path.splitext(os.path.basename(fileName))[0]
#lsep=os.linesep
lsep='\n'
LogMsg1=lsep+"reading from:" + lsep + dirpath + lsep + lsep
out_filename_top_SMD=path+os.sep+name+"_POS_top_SMD.txt"
out_filename_bot_SMD=path+os.sep+name+"_POS_bot_SMD.txt"
out_filename_top_THD=path+os.sep+name+"_POS_top_THD.txt"
out_filename_bot_THD=path+os.sep+name+"_POS_bot_THD.txt"
out_filename_top_VIRTUAL=path+os.sep+name+"_POS_top_Virtual.txt"
out_filename_bot_VIRTUAL=path+os.sep+name+"_POS_bot_Virtual.txt"
out_filename_ALL=path+os.sep+name+"_POS_All.txt"
#out_filename=path+os.sep+name+"_POS.txt"
LogMsg1+="written to:" + lsep + out_filename_top_SMD + lsep
LogMsg1+= out_filename_bot_SMD + lsep
LogMsg1+= out_filename_top_THD + lsep
LogMsg1+= out_filename_bot_THD + lsep
LogMsg1+= out_filename_top_VIRTUAL + lsep
LogMsg1+= out_filename_bot_VIRTUAL + lsep
LogMsg1+= out_filename_ALL + lsep
# print (LogMsg)
#
# print ("### Module positions - created on %s ###" % datetime.datetime.now().strftime("%Y-%m-%d %H:%M"))
# print ("### Printed by get_pos v1")
# print ("## Unit = mm, Angle = deg.")
# print ("## Side : All")
# print ("# Ref Val Package PosX PosY Rot Side Type")
Header_1="### Module positions - created on " + datetime.datetime.now().strftime("%Y-%m-%d %H:%M")+lsep
Header_1+="### Printed by get_pos v1"+lsep
Header_1+="## Unit = mm, Angle = deg."+lsep
#LogMsg+="## Side : All"+lsep
Header_2="## Board Aux Origin: " + str(my_board.GetAuxOrigin())+lsep
Header_2+="{0:<10}".format("# Ref")+"{0:<20}".format("Val")+"{0:<20}".format("Package")+\
"{0:<11}".format("PosX")+"{0:<11}".format("PosY")+"{0:<8}".format(" Rot")+\
"{0:<10}".format(" Side")+" Type"+lsep
content_top_SMD=''
content_bot_SMD=''
content_top_THD=''
content_bot_THD=''
content_top_VIRTUAL=''
content_bot_VIRTUAL=''
content_ALL=''
SMD_pads = 0
TH_pads = 0
Virt_pads = 0
TH_top_cnt = 0
TH_bot_cnt = 0
SMD_top_cnt = 0
SMD_bot_cnt = 0
Virt_top_cnt = 0
Virt_bot_cnt = 0
bb = my_board.GetBoardEdgesBoundingBox()
pcb_height = bb.GetHeight() / mm_ius
pcb_width = bb.GetWidth() / mm_ius
#to add relative position to
#print ("Board Aux Origin: " + str(my_board.GetAuxOrigin()))
#'{0:<10} {1:<10} {2:<10}'.format(1.0, 2.2, 4.4))
for module in my_board.GetModules():
#print ("%s \"%s\" %s %1.3f %1.3f %1.3f %s" % ( module.GetReference(),
#Nchars = 20
# RefL = 10; ValL = 20
md=""
if module.GetAttributes() == 0: # PTH=0, SMD=1, Virtual = 2
md = "THD"
TH_pads+=module.GetPadCount()
elif module.GetAttributes() == 1:
md = "SMD"
SMD_pads+=module.GetPadCount()
else:
md = "VIRTUAL"
Virt_pads+=module.GetPadCount()
#Reference=str(module.GetReference()).ljust(Nchars/2)
#Value=str(module.GetValue()).ljust(Nchars)
#Package=str(module.GetFPID().GetLibItemName()).ljust(Nchars)
#X_POS=str(pcbnew.ToMM(module.GetPosition().x - my_board.GetAuxOrigin().x ))
#Y_POS=str(-1*pcbnew.ToMM(module.GetPosition().y - my_board.GetAuxOrigin().y))
#Rotation=str(module.GetOrientation()/10)
#Layer="top".ljust(Nchars) if module.GetLayer() == 0 else "bottom".ljust(Nchars)
#Type=md
Reference="{0:<10}".format(str(module.GetReference()))
Value = str(module.GetValue())
Value=(Value[:17] + '..') if len(Value) > 19 else Value
Value="{0:<20}".format(Value)
Package = str(module.GetFPID().GetLibItemName())
Package=(Package[:17] + '..') if len(Package) > 19 else Package
Package="{0:<20}".format(Package)
#Package="{0:<20}".format(str(module.GetFPID().GetLibItemName()))
X_POS='{0:.4f}'.format(pcbnew.ToMM(module.GetPosition().x - my_board.GetAuxOrigin().x ))
X_POS="{0:<11}".format(X_POS)
Y_POS='{0:.4f}'.format(-1*pcbnew.ToMM(module.GetPosition().y - my_board.GetAuxOrigin().y))
Y_POS="{0:<11}".format(Y_POS)
Rotation='{0:.1f}'.format((module.GetOrientation()/10))
Rotation="{0:>6}".format(Rotation)+' '
if module.GetLayer() == 0:
Layer=" top"
else:
Layer=" bottom"
#Side="## Side :"+Layer+lsep
Layer="{0:<10}".format(Layer)
Type=' '+md
content=Reference
content+=Value
content+=Package
content+=X_POS
content+=Y_POS
content+=Rotation
content+=Layer
content+=Type+lsep
if 'top' in Layer and 'SMD' in Type:
content_top_SMD+=content
SMD_top_cnt+=1
elif 'bot' in Layer and 'SMD' in Type:
content_bot_SMD+=content
SMD_bot_cnt+=1
elif 'top' in Layer and 'THD' in Type:
content_top_THD+=content
TH_top_cnt+=1
elif 'bot' in Layer and 'THD' in Type:
content_bot_THD+=content
TH_bot_cnt+=1
elif 'top' in Layer and 'VIRTUAL' in Type:
content_top_VIRTUAL+=content
Virt_top_cnt+=1
elif 'bot' in Layer and 'VIRTUAL' in Type:
content_bot_VIRTUAL+=content
Virt_bot_cnt+=1
content_ALL+=content
#print ("%s %s %s %1.4f %1.4f %1.4f %s %s" % ( str(module.GetReference()).ljust(Nchars),
# str(module.GetValue()).ljust(Nchars),
# str(module.GetFPID().GetLibItemName()).ljust(Nchars),
# pcbnew.ToMM(module.GetPosition().x - my_board.GetAuxOrigin().x ),
# -1*pcbnew.ToMM(module.GetPosition().y - my_board.GetAuxOrigin().y),
# module.GetOrientation()/10,
# "top".ljust(Nchars) if module.GetLayer() == 0 else "bottom".ljust(Nchars),
# md
# ))
#"top" if module.GetLayer() == 0 else "bottom"
#LogMsg+="## End"+lsep
Header=Header_1+"## Side : top"+lsep+Header_2
content=Header+content_top_SMD+"## End"+lsep
with open(out_filename_top_SMD,'w') as f_out:
f_out.write(content)
Header=Header_1+"## Side : bottom"+lsep+Header_2
content=Header+content_bot_SMD+"## End"+lsep
with open(out_filename_bot_SMD,'w') as f_out:
f_out.write(content)
Header=Header_1+"## Side : top"+lsep+Header_2
content=Header+content_top_THD+"## End"+lsep
with open(out_filename_top_THD,'w') as f_out:
f_out.write(content)
Header=Header_1+"## Side : bottom"+lsep+Header_2
content=Header+content_bot_THD+"## End"+lsep
with open(out_filename_bot_THD,'w') as f_out:
f_out.write(content)
Header=Header_1+"## Side : top"+lsep+Header_2
content=Header+content_top_VIRTUAL+"## End"+lsep
with open(out_filename_top_VIRTUAL,'w') as f_out:
f_out.write(content)
Header=Header_1+"## Side : bottom"+lsep+Header_2
content=Header+content_bot_VIRTUAL+"## End"+lsep
with open(out_filename_bot_VIRTUAL,'w') as f_out:
f_out.write(content)
Header=Header_1+"## Side : ALL"+lsep+Header_2
content=Header+content_ALL+"## End"+lsep
content = content + '## '+ str(SMD_pads) + ' SMD pads' +lsep
content = content + '## '+ str(TH_pads) + ' TH pads' +lsep
content = content + '## '+ str(Virt_pads) + ' Virtual pads' +lsep
content = content + '## '+ str( TH_top_cnt) + ' Top TH modules' + lsep
content = content + '## '+ str( TH_bot_cnt) + ' Bot TH modules' + lsep
content = content + '## '+ str( SMD_top_cnt) + ' Top SMD modules' + lsep
content = content + '## '+ str( SMD_bot_cnt) + ' Bot SMD modules' + lsep
content = content + '## '+ str( Virt_top_cnt) + ' Top Virtual modules' + lsep
content = content + '## '+ str( Virt_bot_cnt) + ' Bot Virtual modules' + lsep
with open(out_filename_ALL,'w') as f_out:
f_out.write(content)
#with open(out_filename,'w') as f_out:
# f_out.write(LogMsg)
#LogMsg=""
#f = open(out_filename,'w')
#f.write(LogMsg)
#f.close()
LogMsg1+= lsep + str(SMD_pads) + ' SMD pads' +lsep
LogMsg1+= str(TH_pads) + ' TH pads' +lsep
LogMsg1+= str(Virt_pads) + ' Virtual pads' +lsep
LogMsg1+= str( TH_top_cnt) + ' Top TH modules' + lsep
LogMsg1+= str( TH_bot_cnt) + ' Bot TH modules' + lsep
LogMsg1+= str( SMD_top_cnt) + ' Top SMD modules' + lsep
LogMsg1+= str( SMD_bot_cnt) + ' Bot SMD modules' + lsep
LogMsg1+= str( Virt_top_cnt) + ' Top Virtual modules' + lsep
LogMsg1+= str( Virt_bot_cnt) + ' Bot Virtual modules' + lsep
LogMsg1+= '{0:.3f}'.format( pcb_height ) + 'mm Pcb Height, ' + '{0:.3f}'.format( pcb_width ) + 'mm Pcb Width [based on Edge bounding box]' +lsep
return LogMsg1
#return LogMsg1+LogMsg
class generatePOS( pcbnew.ActionPlugin ):
"""
A script to generate POS file for kicad_pcb
requirements: KiCAD pcbnew >= 4.0
release "1.0.1"
"""
def defaults( self ):
"""
Method defaults must be redefined
self.name should be the menu label to use
self.category should be the category (not yet used)
self.description should be a comprehensive description
of the plugin
"""
self.name = "Generate Fabrication POS output\nversion "+___version___
self.category = "Fabrication Output"
self.description = "Generate POS output for SMD, THD, Virtual"
#self.SetIcon(PyEmbeddedImage(getPos_ico_b64_data).GetIcon())
self.icon_file_name = os.path.join(os.path.dirname(__file__), "./fabricationPositions.png")
self.show_toolbar_button = True
def Run( self ):
#wx.MessageDialog(self.frame,"ciao")
#subprocess.check_call(["C:\pathToYourProgram\yourProgram.exe", "your", "arguments", "comma", "separated"])
#http://stackoverflow.com/questions/1811691/running-an-outside-program-executable-in-python
class displayDialog(wx.Dialog):
"""
The default frame
http://stackoverflow.com/questions/3566603/how-do-i-make-wx-textctrl-multi-line-text-update-smoothly
"""
#----------------------------------------------------------------------
#def __init__(self):
# """Constructor"""
# wx.Frame.__init__(self, None, title="Display Frame", style=wx.DEFAULT_FRAME_STYLE, wx.ICON_INFORMATION)
# panel = wx.Panel(self)
def __init__(self, parent):
wx.Dialog.__init__(self, parent, id=-1, title="Generate POS output")#
#, style=wx.DEFAULT_DIALOG_STYLE, wx.ICON_INFORMATION)
#, style=wx.DEFAULT_DIALOG_STYLE, wx.ICON_INFORMATION)
#, pos=DefaultPosition, size=DefaultSize, style = wx.DEFAULT_FRAME_STYLE & (~wx.MAXIMIZE_BOX), name="fname")
#, wx.ICON_INFORMATION) #, title="Annular Check", style=wx.DEFAULT_FRAME_STYLE, wx.ICON_INFORMATION)
#
self.SetIcon(PyEmbeddedImage(getPos_ico_b64_data).GetIcon())
#wx.IconFromBitmap(wx.Bitmap("icon.ico", wx.BITMAP_TYPE_ANY)))
self.panel = wx.Panel(self)
self.title = wx.StaticText(self.panel, label="Generate POS debug:")
#self.result = wx.StaticText(self.panel, label="")
#self.result.SetForegroundColour('#FF0000')
self.button = wx.Button(self.panel, label="Close")
#self.lblname = wx.StaticText(self.panel, label="Your name:")
#self.editname = wx.TextCtrl(self.panel, size=(140, -1))
self.editname = wx.TextCtrl(self.panel, size = (600, 500), style = wx.TE_MULTILINE|wx.TE_READONLY)
# Set sizer for the frame, so we can change frame size to match widgets
self.windowSizer = wx.BoxSizer()
self.windowSizer.Add(self.panel, 1, wx.ALL | wx.EXPAND)
# Set sizer for the panel content
self.sizer = wx.GridBagSizer(5, 0)
self.sizer.Add(self.title, (0, 0))
#self.sizer.Add(self.result, (1, 0))
#self.sizer.Add(self.lblname, (1, 0))
self.sizer.Add(self.editname, (1, 0))
self.sizer.Add(self.button, (2, 0), (1, 2), flag=wx.EXPAND)
# Set simple sizer for a nice border
self.border = wx.BoxSizer()
self.border.Add(self.sizer, 1, wx.ALL | wx.EXPAND, 5)
# Use the sizers
self.panel.SetSizerAndFit(self.border)
self.SetSizerAndFit(self.windowSizer)
#self.result.SetLabel(msg)
# Set event handlers
#self.Show()
self.button.Bind(wx.EVT_BUTTON, self.OnClose)
self.Bind(wx.EVT_CLOSE,self.OnClose)
def OnClose(self,e):
#wx.LogMessage("c")
e.Skip()
#self.Close()
self.Destroy()
#def OnButton(self, e):
# self.result.SetLabel(self.editname.GetValue())
def setMsg(self, t_msg):
self.editname.SetValue(t_msg)
def f_mm(raw):
return repr(raw/mm_ius)
board = pcbnew.GetBoard()
#fileName = GetBoard().GetFileName()
fileName = pcbnew.GetBoard().GetFileName()
if len(fileName)==0:
wx.LogMessage("a board needs to be saved/loaded!")
else:
LogMsg=''
# msg="'get_pos.py'"+os.linesep
msg="Generate POS output: version = "+___version___+os.linesep
#msg+="Generate POS output"+os.linesep
#print (msg)
#LogMsg=msg+'\n\n'
print(msg)
LogMsg+=msg
reply=generate_POS()
LogMsg+=reply
frame = displayDialog(None)
#frame = wx.Frame(None)
frame.Center()
frame.setMsg(LogMsg)
frame.ShowModal()
frame.Destroy()
#frame = wx.wxFrame(None, 10110, 'T-Make', size=wx.wxSize(100,100),
# style=wx.wxSTAY_ON_TOP)
#frame.show()
generatePOS().register()
# "b64_data" is a variable containing your base64 encoded jpeg
getPos_ico_b64_data =\
"""
iVBORw0KGgoAAAANSUhEUgAAAEAAAAA/CAYAAABQHc7KAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAdDwAAHQ8Bjlx1kwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3Nj
YXBlLm9yZ5vuPBoAAAw+SURBVGiB7Zt7cFTVHcc/d+9uSAIhklgIpiQ0tjxSkCKIQ1CpCO3wUKCW0cF0Bqf/VFTG6tROS/8QZuxYwZGHgqD4SjNToFFDjJjGB4LkyUPk
FUhClETShCRssslu9u599I/Nvbm7e/eRENCZ8p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ru+NHjbwFtgBKtXx2RZwFBYNu2bfT09FBQUBB1FygIAqtWrWLt2rWx9m/ATIB5OHi9XlwuF9nZ2X2k
yLjdHjo7nTT/t5nyyrIru3a+9cyZM2c+AJxEcflgRI0Boijy9ttv09XVRWlpaVgSbDYb8+fPZ/v27TF3HhzJzd6g30uShMvlYvz48fh8Em63hytXOmhsaqSoqLAm/5//
WtPa2lpBmGkuGmKaBRwOB7t372bRokVUVlaGfJQkiiJTpkxhz5494df2MSB4T6+qKh6Ph+TkZETRRleXi/b2Nuov1Klv7Nr10b4Piv4GnAd6GYTxMIBpMDExkX379nHf
ffdx+vRpIzCKosjYsWMpLi4O+yosVpjX8fpY7+rqYsKECTidnbRebuHoseM9217ZuvX48RM7gO+IIdJHQkwEaPinw+TkZIqLi5k7dy4XL15E0zSGDx/O/v37o77ciITA
r1H7SXC73Xg8Hm65ZSyNTRcpeP+D8zu3v/Z8V1dXCQMMduEwYH8dM2YMpaWl3HXXXbS3t1NYWDjo9/Pmud1mswUQoCgKLpeLn06YQH3DBWXjxo3FpSWlm4FjQCdX8dTN
iDoLmE9X9PuMjAw++eQTampquPvuu43ywUAQBASbDVEUsdsdKKqKqCgomkB80k1aw7ffOv/8zNM72tvb/41/WetmiIwHawI0QK2pqWmrqKioj1Q5LS2NysrKq1ZC1TQ0
DXyyik9V8PlkXG43Bz8tbXzt1VcKgI/xr+x8DKHxYL3HGc73/58hAX9wawaq8e/lr3q8h+vIKu+H8q8xBf9mJvLfPm7gBm7gBgaJ/wGnp66JbeWfegAAAABJRU5ErkJg
gg==
"""
# execfile("round_tracks.py")

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B