Index: trunk/pcblib/parametric/screw =================================================================== --- trunk/pcblib/parametric/screw (nonexistent) +++ trunk/pcblib/parametric/screw (revision 891) @@ -0,0 +1,35 @@ +#!/bin/sh + +#@@example so(14) + +#@@purpose Generic screw. + +#@@desc Generate a "single pin" screw with optional head shapes +#@@params hole,head,shape,ring + +#@@param:hole hole diameter +#@@dim:hole + +#@@param:head head outmost diameter +#@@dim:head + +#@@param:ring copper ring outer diameter +#@@dim:ring +#@@optional:ring +#@@default:ring 80% of head diameter + + +#@@param:shape of the head; multiple values can be listed separated with colons, e.g. "shape=circle:hex" +#@@enum:shape:circle circle +#@@enum:shape:hex hexagon with straight line edges +#@@enum:shape:tx "torx": hexagon with arced edges +#@@enum:shape:xzn "triple square" +#@@enum:shape:ph philips slot (cross) +#@@enum:shape:slot a single straight line slot +#@@default:shape circle + + +#@@include common.awk + +awk -f `dirname $0`/common.awk -f `dirname $0`/screw.awk -v "args=$*" -v gen=`basename $0` + Property changes on: trunk/pcblib/parametric/screw ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/pcblib/parametric/screw.awk =================================================================== --- trunk/pcblib/parametric/screw.awk (nonexistent) +++ trunk/pcblib/parametric/screw.awk (revision 891) @@ -0,0 +1,87 @@ +function shp(r, edges, tx ,a,x,y,xl,yl,step,x1,y1,x2,y2,tx1,tx2,txs) +{ + step = 2*3.141592654/edges + if (tx == 1) { + tx1 = 0.7 + tx2 = 0.6 + txs = 5 + } + else if (tx == 2) { + tx1 = 0.85 + tx2 = 0.8 + txs = 5 + } + else if (tx == 3) { + tx1 = 0.2 + tx2 = 0.2 + txs = 3 + } + for(n = 0; n <= edges; n++) { + a += step + x = cos(a)*r + y = sin(a)*r + if (xl != "") { + if (tx) { + x1 = cos(a-(txs-1)*step/txs)*r*tx1 + y1 = sin(a-(txs-1)*step/txs)*r*tx1 + x2 = cos(a-step/txs)*r*tx1 + y2 = sin(a-step/txs)*r*tx1 + x3 = cos(a-step/2)*r*tx2 + y3 = sin(a-step/2)*r*tx2 + element_line(xl, yl, x1, y1) + element_line(x, y, x2, y2) + element_line(x3, y3, x1, y1) + element_line(x3, y3, x2, y2) + } + else + element_line(xl, yl, x, y) + } + xl = x + yl = y + } +} + +BEGIN { + set_arg(P, "?shape", "circle") + proc_args(P, "hole,head,shape,ring", "hole,head") + + element_begin("", "S1", "screw:" P["hole"] "," P["head"]"," P["shape"] ,0,0, 0, mil(-100)) + + hole = parse_dim(P["hole"]) + head = parse_dim(P["head"]) + + if (head < hole) + error("head diameter must be larger than hole diameter") + + ring = parse_dim(P["ring"]) + + if (ring == "") + ring = head*0.8 + + element_pin(0, 0, 1, "none", ring, "", "", hole) + + shape = ":" P["shape"] ":" + + if (shape ~ ":circle:") + element_arc(0, 0, head/2, head/2, 0, 360) + + if (shape ~ ":hex:") + shp(head/2, 6, 0) + + if (shape ~ ":tx:") + shp(head/2, 6, 1) + + if (shape ~ ":xzn:") + shp(head/2, 12, 2) + + if (shape ~ ":ph:") + shp(head*0.4, 4, 3) + + if (shape ~ ":slot:") + element_line(-head/2, 0, head/2, 0) + + dimension(-head/2, 0, head/2, 0, head*0.7) + dimension(-hole/2, 0, hole/2, 0, head*0.6) + + element_end() +}