X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com Date: Wed, 24 Oct 2012 09:46:45 -0700 From: Colin D Bennett To: geda-user AT delorie DOT com Subject: [geda-user] pcb-shrink pads, Python script to scale SMT Pads (was: Re: [geda-user] Pin hole size) Message-ID: <20121024094645.3d8519a1@svelte> In-Reply-To: References: <20121023111430 DOT GY32696 AT fi DOT muni DOT cz> <3v1jl9x07b DOT ln2 AT skate DOT rswarbrick> <1351032683 DOT 2442 DOT 5 DOT camel AT AMD64X2 DOT fritz DOT box> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/4zjLx/xXRvKpH34qlwpgEz." X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator297.hostgator.com X-AntiAbuse: Original Domain - delorie.com X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - gibibit.com X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (svelte) [65.61.115.34]:21256 X-Source-Auth: colin AT gibibit DOT com X-Email-Count: 2 X-Source-Cap: c2t5bGVuO3NreWxlbjtnYXRvcjI5Ny5ob3N0Z2F0b3IuY29t Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk --MP_/4zjLx/xXRvKpH34qlwpgEz. Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline On Wed, 24 Oct 2012 11:15:38 +1100 Stephen Ecob wrote: > Simple, human readable file formats are, however, > one of the great strengths and advantages of gEDA. I personally > wouldn't hesitate to show beginners our file formats and how > easily they can be analysed and manipulated with text processing > tools - it's a feature of gEDA that I greatly value. Absolutely. Not only can you edit footprints by hand easily, once you learn the basic syntax, you can easily write scripts to generate or process them. For instance, see the attached script I wrote to scale all Pad[] entities in a footprint. For making custom solder paste stencil apertures, I generally use this by copying all Pads in the VIM editor, pasting them, and processing them through "pcb-shrink-pads --scale=0.85" or something, depending on size/shape of the pads, then adding the 'nopaste' flag to the original full-size pads. Another benefit of a readable text file format is that you can use version control tools side-by-side diff tools to easily compare changes made to footprint files. I rarely look at the .pcb layout files, actually, but I frequently work on footprint files in a text editor. Now, I do wish for many other features in pcb to make footprint editing easier. For instance, having to "explode" footprints into the component pads/pins to edit them, then "composite" them back together (losing a lot of information, like pin/pad 'square' flag, solder mask gap, pad name, etc.) is really a bummer. It would be a huge improvement if we could open and edit footprint files directly. Also, being able to add EVERY type of pcb entity to a footprint, and have custom layers like "keepout", "assembly drawing outline", "silk screen outline", etc. would be extremely helpful. Regards, Colin --MP_/4zjLx/xXRvKpH34qlwpgEz. Content-Type: application/octet-stream; name=pcb-shrink-pads Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=pcb-shrink-pads IyEvdXNyL2Jpbi9weXRob24KIyAtKi0gY29kaW5nOiB1dGYtOCAtKi0KIwojIFNocmluayBnRURB L3BjYiBwYWRzIGZyb20gYSBmb290cHJpbnQgYnkgYSBnaXZlbiBhbW91bnQuCiMgVGhlIHBhZCBp cyBzaHJ1bmsgYnkgYSBzcGVjaWZpZWQgZGlzdGFuY2UgZnJvbSBlYWNoIGVkZ2UuCiMKIyBUaGlz IGlzIHVzZWZ1bCBmb3IgY3JlYXRpbmcgc29sZGVyIHBhc3RlIHN0ZW5jaWwgZGVmaW5pdGlvbnMK IyB3aGljaCBhcmUgc21hbGxlciB0aGFuIHRoZSBTTVQgcGFkcy4KIwojIENvbGluIEQgQmVubmV0 dCA8Y29saW5AZ2liaWJpdC5jb20sIDIwMTItMDMtMjcuCgpmcm9tIHN5cyBpbXBvcnQgc3RkaW4K ZnJvbSBzeXMgaW1wb3J0IHN0ZG91dAppbXBvcnQgcmUKaW1wb3J0IG51bXB5IGFzIG5wCgoKIyMj I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IHVuaXQKICAgICsgciJccysoWy0rXT9cZCsoPzpcLlxkKik/KSht aWx8bW18XGIpIiAgICAgIyBUaGlja25lc3MgICg5KSBudW1iZXI7ICgxMCkgdW5pdAogICAgKyBy IlxzKyhbLStdP1xkKyg/OlwuXGQqKT8pKG1pbHxtbXxcYikiICAgICAjIENsZWFyYW5jZSAoPTIq Z2FwKSAgKDExKSBudW1iZXI7ICgxMikgdW5pdAogICAgKyByIlxzKyhbLStdP1xkKyg/OlwuXGQq KT8pKG1pbHxtbXxcYikiICAgICAjIE1hc2sgb3BlbmluZyAoPXRoaWNrbmVzcyArIDIqZ2FwKSAg KDEzKSBudW1iZXI7ICgxNCkgdW5pdAogICAgKyByJ1xzKyIoW14iXSopIicgICAgICAgICAgICAg ICAgICAgICAgICAgICAjIFBpbiBuYW1lICgxNSkKICAgICsgcidccysiKFteIl0qKSInICAgICAg ICAgICAgICAgICAgICAgICAgICAgIyBQaW4gbnVtYmVyICgxNikKICAgICsgcidccysiKFteIl0q KSInICAgICAgICAgICAgICAgICAgICAgICAgICAgIyBTeW1ib2xpYyBmbGFncyAoMTcpCiAgICAr IHInXHMqXF0nKSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgRW5kIFBhZFtdIGVu dGl0eQoKIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMj IyMjIyMjIyMjIyMjIyMjIyMjIwojIENsYXNzZXMKIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMj IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIwoKY2xhc3MgUGFkKG9i amVjdCk6CiAgICBkZWYgX19pbml0X18oc2VsZik6CiAgICAgICAgc2VsZi54MSA9IE5vbmUKICAg ICAgICBzZWxmLnkxID0gTm9uZQogICAgICAgIHNlbGYueDIgPSBOb25lCiAgICAgICAgc2VsZi55 MiA9IE5vbmUKICAgICAgICBzZWxmLncgPSBOb25lCiAgICAgICAgc2VsZi5jbHJnYXAgPSBOb25l CiAgICAgICAgc2VsZi5tYXNrZ2FwID0gTm9uZQogICAgICAgIHNlbGYubmFtZSA9IE5vbmUKICAg ICAgICBzZWxmLm51bWJlciA9IE5vbmUKICAgICAgICBzZWxmLmZsYWdzID0gTm9uZQoKICAgIGRl ZiBvdXRwdXQoc2VsZik6CiAgICAgICAgcyA9ICJQYWRbIgogICAgICAgIHMgKz0gZm9ybWF0X2xl bmd0aChzZWxmLngxKQogICAgICAgIHMgKz0gIiAiICsgZm9ybWF0X2xlbmd0aChzZWxmLnkxKQog ICAgICAgIHMgKz0gIiAiICsgZm9ybWF0X2xlbmd0aChzZWxmLngyKQogICAgICAgIHMgKz0gIiAi ICsgZm9ybWF0X2xlbmd0aChzZWxmLnkyKQogICAgICAgIHMgKz0gIiAiICsgZm9ybWF0X2xlbmd0 aChzZWxmLncpCiAgICAgICAgcyArPSAiICIgKyBmb3JtYXRfbGVuZ3RoKDIgKiBzZWxmLmNscmdh cCkKICAgICAgICBzICs9ICIgIiArIGZvcm1hdF9sZW5ndGgoc2VsZi53ICsgMiAqIHNlbGYubWFz a2dhcCkKICAgICAgICBzICs9ICcgIicgKyBzZWxmLm5hbWUgKyAnIicKICAgICAgICBzICs9ICcg IicgKyBzZWxmLm51bWJlciArICciJwogICAgICAgIHMgKz0gJyAiJyArIHNlbGYuZmxhZ3MgKyAn IicKICAgICAgICBzICs9ICJdIgogICAgICAgIHJldHVybiBzCgojIENyZWF0ZSBhIFBhZCBvYmpl Y3QgZnJvbSBhbiAncmUnIG1hdGNoIG9iamVjdC4KZGVmIHBhZF9mcm9tX21hdGNoKG0pOgogICAg cGFkID0gUGFkKCkKICAgIHBhZC54MSA9IGdldF9sZW5ndGgobS5ncm91cCgxKSwgbS5ncm91cCgy KSkKICAgIHBhZC55MSA9IGdldF9sZW5ndGgobS5ncm91cCgzKSwgbS5ncm91cCg0KSkKICAgIHBh ZC54MiA9IGdldF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