Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pub
libraries
Commits
6c76916f
Commit
6c76916f
authored
Oct 14, 2018
by
Neil Gershenfeld
Browse files
wip
parent
688dea00
Pipeline
#2621
passed with stage
in 1 second
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
python/pcb.py
View file @
6c76916f
...
...
@@ -41,27 +41,28 @@ import math,json,sys
#
# color(color,part)
# circle(x0, y0, r)
# cylinder(x0, y0, z0, z1, r)
# cone(x0, y0, z0, z1, r0)
# sphere(x0, y0, z0, r)
# torus(x0, y0, z0, r0, r1)
# rectangle(x0, x1, y0, y1)
# cube(x0, x1, y0, y1, z0, z1)
# right_triangle(x0, y0, h)
# triangle(x0, y0, x1, y1, x2, y2) (points in clockwise order)
# pyramid(x0, x1, y0, y1, z0, z1)
# circle(x,y,r)
# cylinder(x,y,z0,z1,r)
# cone(x,y,z0,z1,r)
# sphere(x,y,z,r)
# torus(x,y,z,r0,r1)
# rectangle(x0,x1,y0,y1)
# cube(x0,x1,y0,y1,z0,z1)
# line(x0,y0,x1,y1,z,width)
# right_triangle(x,y,h)
# triangle(x0,y0,x1,y1,x2,y2) (points in clockwise order)
# pyramid(x0,x1,y0,y1,z0,z1)
# function(Z_of_XY)
# functions(upper_Z_of_XY,lower_Z_of_XY)
# add(part1,
part2)
# subtract(part1,
part2)
# intersect(part1,
part2)
# add(part1,part2)
# subtract(part1,part2)
# intersect(part1,part2)
# move(part,dx,dy)
# translate(part,dx,dy,dz)
# rotate(part, angle)
# rotate_x(part,
angle)
# rotate_y(part,
angle)
# rotate_z(part,
angle)
# rotate_x(part,angle)
# rotate_y(part,angle)
# rotate_z(part,angle)
# rotate_90(part)
# rotate_180(part)
# rotate_270(part)
...
...
@@ -71,24 +72,24 @@ import math,json,sys
# reflect_xy(part)
# reflect_xz(part)
# reflect_yz(part)
# scale_x(part,
x0,
sx)
# scale_y(part,
y0,
sy)
# scale_z(part,
z0,
sz)
# scale_xy(part,
x0,
y0,
sxy)
# scale_xyz(part,
x0,
y0,
z0,
sxyz)
# coscale_x_y(part,
x0,
y0,
y1,
angle0,
angle1,
amplitude,
offset)
# coscale_x_z(part,
x0,
z0
,
z1,
angle0,
angle1,
amplitude,
offset)
# coscale_xy_z(part,
x0,
y0,
z0,
z1,
angle0,
angle1,
amplitude,
offset)
# taper_x_y(part,
x0,
y0,
y1,
s0,
s1)
# taper_x_z(part,
x0,
z0,
z1,
s0,
s1)
# taper_xy_z(part,
x0,
y0,
z0,
z1,
s0,
s1)
# shear_x_y(part,
y0,
y1,
dx0,
dx1)
# shear_x_z(part,
z0,
z1,
dx0,
dx1)
# scale_x(part,x0,sx)
# scale_y(part,y0,sy)
# scale_z(part,z0,sz)
# scale_xy(part,x0,y0,sxy)
# scale_xyz(part,x0,y0,z0,sxyz)
# coscale_x_y(part,x0,y0,y1,angle0,angle1,amplitude,offset)
# coscale_x_z(part,x0,z0 z1,angle0,angle1,amplitude,offset)
# coscale_xy_z(part,x0,y0,z0,z1,angle0,angle1,amplitude,offset)
# taper_x_y(part,x0,y0,y1,s0,s1)
# taper_x_z(part,x0,z0,z1,s0,s1)
# taper_xy_z(part,x0,y0,z0,z1,s0,s1)
# shear_x_y(part,y0,y1,dx0,dx1)
# shear_x_z(part,z0,z1,dx0,dx1)
true
=
"1"
false
=
"0"
def
color
(
color
,
part
):
def
color
(
color
,
part
):
part
=
'('
+
str
(
color
)
+
'*(('
+
part
+
')!=0))'
return
part
...
...
@@ -104,14 +105,14 @@ Brown = (45 << 16) + (82 << 8) + (145 << 0)
Navy
=
(
128
<<
16
)
+
(
0
<<
8
)
+
(
0
<<
0
)
Tan
=
(
60
<<
16
)
+
(
90
<<
8
)
+
(
125
<<
0
)
def
circle
(
x0
,
y0
,
r
):
def
circle
(
x0
,
y0
,
r
):
part
=
"(((X-(x0))*(X-(x0)) + (Y-(y0))*(Y-(y0))) <= (r*r))"
part
=
part
.
replace
(
'x0'
,
str
(
x0
))
part
=
part
.
replace
(
'y0'
,
str
(
y0
))
part
=
part
.
replace
(
'r'
,
str
(
r
))
return
part
def
cylinder
(
x0
,
y0
,
z0
,
z1
,
r
):
def
cylinder
(
x0
,
y0
,
z0
,
z1
,
r
):
part
=
"(((X-(x0))*(X-(x0)) + (Y-(y0))*(Y-(y0)) <= (r*r)) & (Z >= (z0)) & (Z <= (z1)))"
part
=
part
.
replace
(
'x0'
,
str
(
x0
))
part
=
part
.
replace
(
'y0'
,
str
(
y0
))
...
...
@@ -120,12 +121,12 @@ def cylinder(x0, y0, z0, z1, r):
part
=
part
.
replace
(
'r'
,
str
(
r
))
return
part
def
cone
(
x0
,
y0
,
z0
,
z1
,
r0
):
def
cone
(
x0
,
y0
,
z0
,
z1
,
r0
):
part
=
cylinder
(
x0
,
y0
,
z0
,
z1
,
r0
)
part
=
taper_xy_z
(
part
,
x0
,
y0
,
z0
,
z1
,
1.0
,
0.0
)
return
part
def
sphere
(
x0
,
y0
,
z0
,
r
):
def
sphere
(
x0
,
y0
,
z0
,
r
):
part
=
"(((X-(x0))*(X-(x0)) + (Y-(y0))*(Y-(y0)) + (Z-(z0))*(Z-(z0))) <= (r*r))"
part
=
part
.
replace
(
'x0'
,
str
(
x0
))
part
=
part
.
replace
(
'y0'
,
str
(
y0
))
...
...
@@ -133,7 +134,7 @@ def sphere(x0, y0, z0, r):
part
=
part
.
replace
(
'r'
,
str
(
r
))
return
part
def
torus
(
x0
,
y0
,
z0
,
r0
,
r1
):
def
torus
(
x0
,
y0
,
z0
,
r0
,
r1
):
part
=
"(((r0 - sqrt((X-(x0))*(X-(x0)) + (Y-(y0))*(Y-(y0))))*(r0 - sqrt((X-(x0))*(X-(x0)) + (Y-(y0))*(Y-(y0))) + (Z-(z0))*(Z-(z0))) <= (r1*r1))"
part
=
part
.
replace
(
'x0'
,
str
(
x0
))
part
=
part
.
replace
(
'y0'
,
str
(
y0
))
...
...
@@ -142,7 +143,7 @@ def torus(x0, y0, z0, r0, r1):
part
=
part
.
replace
(
'r1'
,
str
(
r1
))
return
part
def
rectangle
(
x0
,
x1
,
y0
,
y1
):
def
rectangle
(
x0
,
x1
,
y0
,
y1
):
part
=
"((X >= (x0)) & (X <= (x1)) & (Y >= (y0)) & (Y <= (y1)))"
part
=
part
.
replace
(
'x0'
,
str
(
x0
))
part
=
part
.
replace
(
'x1'
,
str
(
x1
))
...
...
@@ -150,7 +151,7 @@ def rectangle(x0, x1, y0, y1):
part
=
part
.
replace
(
'y1'
,
str
(
y1
))
return
part
def
cube
(
x0
,
x1
,
y0
,
y1
,
z0
,
z1
):
def
cube
(
x0
,
x1
,
y0
,
y1
,
z0
,
z1
):
part
=
"((X >= (x0)) & (X <= (x1)) & (Y >= (y0)) & (Y <= (y1)) & (Z >= (z0)) & (Z <= (z1)))"
part
=
part
.
replace
(
'x0'
,
str
(
x0
))
part
=
part
.
replace
(
'x1'
,
str
(
x1
))
...
...
@@ -160,14 +161,36 @@ def cube(x0, x1, y0, y1, z0, z1):
part
=
part
.
replace
(
'z1'
,
str
(
z1
))
return
part
def
right_triangle
(
x0
,
y0
,
l
):
def
line
(
x0
,
y0
,
x1
,
y1
,
z
,
width
):
dx
=
x1
-
x0
dy
=
y1
-
y0
l
=
math
.
sqrt
(
dx
*
dx
+
dy
*
dy
)
nx
=
dx
/
l
ny
=
dy
/
l
rx
=
-
ny
ry
=
nx
part
=
"((((X-(x0))*(nx)+(Y-(y0))*(ny)) >= 0) & (((X-(x0))*(nx)+(Y-(y0))*(ny)) <= l) & (((X-(x0))*(rx)+(Y-(y0))*(ry)) >= (-width/2)) & (((X-(x0))*(rx)+(Y-(y0))*(ry)) <= (width/2)) & (Z == z))"
part
=
part
.
replace
(
'x0'
,
str
(
x0
))
part
=
part
.
replace
(
'x1'
,
str
(
x1
))
part
=
part
.
replace
(
'y0'
,
str
(
y0
))
part
=
part
.
replace
(
'y1'
,
str
(
y1
))
part
=
part
.
replace
(
'nx'
,
str
(
nx
))
part
=
part
.
replace
(
'ny'
,
str
(
ny
))
part
=
part
.
replace
(
'rx'
,
str
(
rx
))
part
=
part
.
replace
(
'ry'
,
str
(
ry
))
part
=
part
.
replace
(
'l'
,
str
(
l
))
part
=
part
.
replace
(
'z'
,
str
(
z
))
part
=
part
.
replace
(
'width'
,
str
(
width
))
return
part
def
right_triangle
(
x0
,
y0
,
l
):
part
=
"((X > x0) & (X < x0 + l - (Y-y0)) & (Y > y0))"
part
=
part
.
replace
(
'x0'
,
str
(
x0
))
part
=
part
.
replace
(
'y0'
,
str
(
y0
))
part
=
part
.
replace
(
'l'
,
str
(
l
))
return
part
def
triangle
(
x0
,
y0
,
x1
,
y1
,
x2
,
y2
):
# points in clockwise order
def
triangle
(
x0
,
y0
,
x1
,
y1
,
x2
,
y2
):
# points in clockwise order
part
=
"(((((y1)-(y0))*(X-(x0))-((x1)-(x0))*(Y-(y0))) >= 0) & ((((y2)-(y1))*(X-(x1))-((x2)-(x1))*(Y-(y1))) >= 0) & ((((y0)-(y2))*(X-(x2))-((x0)-(x2))*(Y-(y2))) >= 0))"
part
=
part
.
replace
(
'x0'
,
str
(
x0
))
part
=
part
.
replace
(
'y0'
,
str
(
y0
))
...
...
@@ -177,7 +200,7 @@ def triangle(x0, y0, x1, y1, x2, y2): # points in clockwise order
part
=
part
.
replace
(
'y2'
,
str
(
y2
))
return
part
def
pyramid
(
x0
,
x1
,
y0
,
y1
,
z0
,
z1
):
def
pyramid
(
x0
,
x1
,
y0
,
y1
,
z0
,
z1
):
part
=
cube
(
x0
,
x1
,
y0
,
y1
,
z0
,
z1
)
part
=
taper_xy_z
(
part
,
(
x0
+
x1
)
/
2.
,
(
y0
+
y1
)
/
2.
,
z0
,
z1
,
1.0
,
0.0
)
return
part
...
...
@@ -190,19 +213,19 @@ def functions(upper_Z_of_XY,lower_Z_of_XY):
part
=
'(Z <= '
+
upper_Z_of_XY
+
') & (Z >= '
+
lower_Z_of_XY
+
')'
return
part
def
add
(
part1
,
part2
):
def
add
(
part1
,
part2
):
part
=
"part1 | part2"
part
=
part
.
replace
(
'part1'
,
part1
)
part
=
part
.
replace
(
'part2'
,
part2
)
return
part
def
subtract
(
part1
,
part2
):
def
subtract
(
part1
,
part2
):
part
=
"(part1) & ~(part2)"
part
=
part
.
replace
(
'part1'
,
part1
)
part
=
part
.
replace
(
'part2'
,
part2
)
return
part
def
intersect
(
part1
,
part2
):
def
intersect
(
part1
,
part2
):
part
=
"(part1) & (part2)"
part
=
part
.
replace
(
'part1'
,
part1
)
part
=
part
.
replace
(
'part2'
,
part2
)
...
...
@@ -219,7 +242,7 @@ def translate(part,dx,dy,dz):
part
=
part
.
replace
(
'Z'
,
'(Z-('
+
str
(
dz
)
+
'))'
)
return
part
def
rotate
(
part
,
angle
):
def
rotate
(
part
,
angle
):
angle
=
angle
*
math
.
pi
/
180
part
=
part
.
replace
(
'X'
,
'(math.cos(angle)*X+math.sin(angle)*y)'
)
part
=
part
.
replace
(
'Y'
,
'(-math.sin(angle)*X+math.cos(angle)*y)'
)
...
...
@@ -227,7 +250,7 @@ def rotate(part, angle):
part
=
part
.
replace
(
'angle'
,
str
(
angle
))
return
part
def
rotate_x
(
part
,
angle
):
def
rotate_x
(
part
,
angle
):
angle
=
angle
*
math
.
pi
/
180
part
=
part
.
replace
(
'Y'
,
'(math.cos(angle)*Y+math.sin(angle)*z)'
)
part
=
part
.
replace
(
'Z'
,
'(-math.sin(angle)*Y+math.cos(angle)*z)'
)
...
...
@@ -235,7 +258,7 @@ def rotate_x(part, angle):
part
=
part
.
replace
(
'angle'
,
str
(
angle
))
return
part
def
rotate_y
(
part
,
angle
):
def
rotate_y
(
part
,
angle
):
angle
=
angle
*
math
.
pi
/
180
part
=
part
.
replace
(
'X'
,
'(math.cos(angle)*X+math.sin(angle)*z)'
)
part
=
part
.
replace
(
'Z'
,
'(-math.sin(angle)*X+math.cos(angle)*z)'
)
...
...
@@ -243,7 +266,7 @@ def rotate_y(part, angle):
part
=
part
.
replace
(
'angle'
,
str
(
angle
))
return
part
def
rotate_z
(
part
,
angle
):
def
rotate_z
(
part
,
angle
):
angle
=
angle
*
math
.
pi
/
180
part
=
part
.
replace
(
'X'
,
'(math.cos(angle)*X+math.sin(angle)*y)'
)
part
=
part
.
replace
(
'Y'
,
'(-math.sin(angle)*X+math.cos(angle)*y)'
)
...
...
@@ -300,25 +323,25 @@ def reflect_yz(part):
part
=
part
.
replace
(
'temp'
,
'Z'
)
return
part
def
scale_x
(
part
,
x0
,
sx
):
def
scale_x
(
part
,
x0
,
sx
):
part
=
part
.
replace
(
'X'
,
'((x0) + (X-(x0))/(sx))'
)
part
=
part
.
replace
(
'x0'
,
str
(
x0
))
part
=
part
.
replace
(
'sx'
,
str
(
sx
))
return
part
def
scale_y
(
part
,
y0
,
sy
):
def
scale_y
(
part
,
y0
,
sy
):
part
=
part
.
replace
(
'Y'
,
'((y0) + (Y-(y0))/(sy))'
)
part
=
part
.
replace
(
'y0'
,
str
(
y0
))
part
=
part
.
replace
(
'sy'
,
str
(
sy
))
return
part
def
scale_z
(
part
,
z0
,
sz
):
def
scale_z
(
part
,
z0
,
sz
):
part
=
part
.
replace
(
'Z'
,
'((z0) + (Z-(z0))/(sz))'
)
part
=
part
.
replace
(
'z0'
,
str
(
z0
))
part
=
part
.
replace
(
'sz'
,
str
(
sz
))
return
part
def
scale_xy
(
part
,
x0
,
y0
,
sxy
):
def
scale_xy
(
part
,
x0
,
y0
,
sxy
):
part
=
part
.
replace
(
'X'
,
'((x0) + (X-(x0))/(sxy))'
)
part
=
part
.
replace
(
'Y'
,
'((y0) + (Y-(y0))/(sxy))'
)
part
=
part
.
replace
(
'x0'
,
str
(
x0
))
...
...
@@ -326,7 +349,7 @@ def scale_xy(part, x0, y0, sxy):
part
=
part
.
replace
(
'sxy'
,
str
(
sxy
))
return
part
def
scale_xyz
(
part
,
x0
,
y0
,
z0
,
sxyz
):
def
scale_xyz
(
part
,
x0
,
y0
,
z0
,
sxyz
):
part
=
part
.
replace
(
'X'
,
'((x0) + (X-(x0))/(sxyz))'
)
part
=
part
.
replace
(
'Y'
,
'((y0) + (Y-(y0))/(sxyz))'
)
part
=
part
.
replace
(
'Z'
,
'((z0) + (Z-(z0))/(sxyz))'
)
...
...
@@ -336,7 +359,7 @@ def scale_xyz(part, x0, y0, z0, sxyz):
part
=
part
.
replace
(
'sxyz'
,
str
(
sxyz
))
return
part
def
coscale_x_y
(
part
,
x0
,
y0
,
y1
,
angle0
,
angle1
,
amplitude
,
offset
):
def
coscale_x_y
(
part
,
x0
,
y0
,
y1
,
angle0
,
angle1
,
amplitude
,
offset
):
phase0
=
math
.
pi
*
angle0
/
180.
phase1
=
math
.
pi
*
angle1
/
180.
part
=
part
.
replace
(
'X'
,
'((x0) + (X-(x0))/((offset) + (amplitude)*math.cos((phase0) + ((phase1)-(phase0))*(Y-(y0))/((y1)-(y0)))))'
)
...
...
@@ -349,7 +372,7 @@ def coscale_x_y(part, x0, y0, y1, angle0, angle1, amplitude, offset):
part
=
part
.
replace
(
'offset'
,
str
(
offset
))
return
part
def
coscale_x_z
(
part
,
x0
,
z0
,
z1
,
angle0
,
angle1
,
amplitude
,
offset
):
def
coscale_x_z
(
part
,
x0
,
z0
,
z1
,
angle0
,
angle1
,
amplitude
,
offset
):
phase0
=
math
.
pi
*
angle0
/
180.
phase1
=
math
.
pi
*
angle1
/
180.
part
=
part
.
replace
(
'X'
,
'((x0) + (X-(x0))/((offset) + (amplitude)*math.cos((phase0) + ((phase1)-(phase0))*(Z-(z0))/((z1)-(z0)))))'
)
...
...
@@ -362,7 +385,7 @@ def coscale_x_z(part, x0, z0, z1, angle0, angle1, amplitude, offset):
part
=
part
.
replace
(
'offset'
,
str
(
offset
))
return
part
def
coscale_xy_z
(
part
,
x0
,
y0
,
z0
,
z1
,
angle0
,
angle1
,
amplitude
,
offset
):
def
coscale_xy_z
(
part
,
x0
,
y0
,
z0
,
z1
,
angle0
,
angle1
,
amplitude
,
offset
):
phase0
=
math
.
pi
*
angle0
/
180.
phase1
=
math
.
pi
*
angle1
/
180.
part
=
part
.
replace
(
'X'
,
'((x0) + (X-(x0))/((offset) + (amplitude)*math.cos((phase0) + ((phase1)-(phase0))*(Z-(z0))/((z1)-(z0)))))'
)
...
...
@@ -377,7 +400,7 @@ def coscale_xy_z(part, x0, y0, z0, z1, angle0, angle1, amplitude, offset):
part
=
part
.
replace
(
'offset'
,
str
(
offset
))
return
part
def
taper_x_y
(
part
,
x0
,
y0
,
y1
,
s0
,
s1
):
def
taper_x_y
(
part
,
x0
,
y0
,
y1
,
s0
,
s1
):
part
=
part
.
replace
(
'X'
,
'((x0) + (X-(x0))*((y1)-(y0))/((s1)*(Y-(y0)) + (s0)*((y1)-Y)))'
)
part
=
part
.
replace
(
'x0'
,
str
(
x0
))
part
=
part
.
replace
(
'y0'
,
str
(
y0
))
...
...
@@ -386,7 +409,7 @@ def taper_x_y(part, x0, y0, y1, s0, s1):
part
=
part
.
replace
(
's1'
,
str
(
s1
))
return
part
def
taper_x_z
(
part
,
x0
,
z0
,
z1
,
s0
,
s1
):
def
taper_x_z
(
part
,
x0
,
z0
,
z1
,
s0
,
s1
):
part
=
part
.
replace
(
'X'
,
'((x0) + (X-(x0))*((z1)-(z0))/((s1)*(Z-(z0)) + (s0)*((z1)-Z)))'
)
part
=
part
.
replace
(
'x0'
,
str
(
x0
))
part
=
part
.
replace
(
'z0'
,
str
(
z0
))
...
...
@@ -395,7 +418,7 @@ def taper_x_z(part, x0, z0, z1, s0, s1):
part
=
part
.
replace
(
's1'
,
str
(
s1
))
return
part
def
taper_xy_z
(
part
,
x0
,
y0
,
z0
,
z1
,
s0
,
s1
):
def
taper_xy_z
(
part
,
x0
,
y0
,
z0
,
z1
,
s0
,
s1
):
part
=
part
.
replace
(
'X'
,
'((x0) + (X-(x0))*((z1)-(z0))/((s1)*(Z-(z0)) + (s0)*((z1)-Z)))'
)
part
=
part
.
replace
(
'Y'
,
'((y0) + (Y-(y0))*((z1)-(z0))/((s1)*(Z-(z0)) + (s0)*((z1)-Z)))'
)
part
=
part
.
replace
(
'x0'
,
str
(
x0
))
...
...
@@ -406,7 +429,7 @@ def taper_xy_z(part, x0, y0, z0, z1, s0, s1):
part
=
part
.
replace
(
's1'
,
str
(
s1
))
return
part
def
shear_x_y
(
part
,
y0
,
y1
,
dx0
,
dx1
):
def
shear_x_y
(
part
,
y0
,
y1
,
dx0
,
dx1
):
part
=
part
.
replace
(
'X'
,
'(X - (dx0) - ((dx1)-(dx0))*(Y-(y0))/((y1)-(y0)))'
)
part
=
part
.
replace
(
'y0'
,
str
(
y0
))
part
=
part
.
replace
(
'y1'
,
str
(
y1
))
...
...
@@ -414,7 +437,7 @@ def shear_x_y(part, y0, y1, dx0, dx1):
part
=
part
.
replace
(
'dx1'
,
str
(
dx1
))
return
part
def
shear_x_z
(
part
,
z0
,
z1
,
dx0
,
dx1
):
def
shear_x_z
(
part
,
z0
,
z1
,
dx0
,
dx1
):
part
=
part
.
replace
(
'X'
,
'(X - (dx0) - ((dx1)-(dx0))*(Z-(z0))/((z1)-(z0)))'
)
part
=
part
.
replace
(
'z0'
,
str
(
z0
))
part
=
part
.
replace
(
'z1'
,
str
(
z1
))
...
...
@@ -422,7 +445,7 @@ def shear_x_z(part, z0, z1, dx0, dx1):
part
=
part
.
replace
(
'dx1'
,
str
(
dx1
))
return
part
def
coshear_x_z
(
part
,
z0
,
z1
,
angle0
,
angle1
,
amplitude
,
offset
):
def
coshear_x_z
(
part
,
z0
,
z1
,
angle0
,
angle1
,
amplitude
,
offset
):
phase0
=
math
.
pi
*
angle0
/
180.
phase1
=
math
.
pi
*
angle1
/
180.
part
=
part
.
replace
(
'X'
,
'(X - (offset) - (amplitude)*math.cos((phase0) + ((phase1)-(phase0))*(Z-(z0))/((z1)-(z0))))'
)
...
...
@@ -990,7 +1013,7 @@ class part:
pcb
=
pcb
.
add
(
translate
(
self
.
shape
,
0
,
0
,
z
))
return
pcb
def
wire
(
pcb
,
width
,
*
points
):
def
right
wire
(
pcb
,
width
,
*
points
):
for
i
in
range
(
1
,
len
(
points
)):
x0
=
points
[
i
-
1
].
x
y0
=
points
[
i
-
1
].
y
...
...
@@ -1008,6 +1031,22 @@ def wire(pcb,width,*points):
pcb
.
board
=
add
(
pcb
.
board
,
cube
(
x1
-
width
/
2
,
x1
+
width
/
2
,
y1
-
width
/
2
,
y0
+
width
/
2
,
z0
,
z0
))
return
pcb
def
wire
(
pcb
,
width
,
*
points
):
x0
=
points
[
0
].
x
y0
=
points
[
0
].
y
z0
=
points
[
0
].
z
pcb
.
board
=
add
(
pcb
.
board
,
cylinder
(
x0
,
y0
,
z0
,
z0
,
width
/
2
))
for
i
in
range
(
1
,
len
(
points
)):
x0
=
points
[
i
-
1
].
x
y0
=
points
[
i
-
1
].
y
z0
=
points
[
i
-
1
].
z
x1
=
points
[
i
].
x
y1
=
points
[
i
].
y
z1
=
points
[
i
].
z
pcb
.
board
=
add
(
pcb
.
board
,
line
(
x0
,
y0
,
x1
,
y1
,
z1
,
width
))
pcb
.
board
=
add
(
pcb
.
board
,
cylinder
(
x1
,
y1
,
z1
,
z1
,
width
/
2
))
return
pcb
#
# PCB library
#
...
...
@@ -4593,7 +4632,7 @@ class fab(part):
# define board
#
w
=
.
01
6
w
=
.
01
5
width
=
1
height
=
.
93
mask
=
.
004
...
...
@@ -4612,25 +4651,34 @@ pcb = J1.add(pcb,IC1.x+.05,IC1.pad[7].y-.22,z,angle=90)
pcb
=
wire
(
pcb
,
w
,
IC1
.
pad
[
8
],
point
(
J1
.
pad
[
1
].
x
,
IC1
.
pad
[
8
].
y
,
z
),
J1
.
pad
[
1
])
pcb
=
wire
(
pcb
,
w
,
IC1
.
pad
[
9
],
point
(
J1
.
pad
[
3
].
x
,
IC1
.
pad
[
9
].
y
,
z
),
J1
.
pad
[
3
])
pcb
=
wire
(
pcb
,
w
,
IC1
.
pad
[
7
],
point
(
IC1
.
pad
[
7
].
x
+
.
01
,
J1
.
y
-
.
02
,
z
),
point
(
IC1
.
pad
[
7
].
x
,
J1
.
y
+
.
02
,
z
),
point
(
IC1
.
pad
[
7
].
x
+
.
04
,
J1
.
y
-
.
02
,
z
),
point
(
J1
.
pad
[
4
].
x
,
J1
.
y
-
.
02
,
z
),
J1
.
pad
[
4
])
pcb
=
wire
(
pcb
,
w
,
IC1
.
pad
[
4
],
point
(
J1
.
pad
[
5
].
x
,
IC1
.
pad
[
4
].
y
,
z
),
J1
.
pad
[
5
])
pcb
=
wire
(
pcb
,
w
,
IC1
.
pad
[
14
],
point
(
J1
.
x
-
.
01
,
IC1
.
pad
[
14
].
y
,
z
),
point
(
J1
.
x
-
.
05
,
IC1
.
pad
[
14
].
y
-
.
04
,
z
),
point
(
J1
.
x
-
.
05
,
J1
.
y
+
.
02
,
z
),
point
(
J1
.
x
+
.
05
,
J1
.
y
+
.
02
,
z
),
point
(
J1
.
x
+
.
05
,
J1
.
pad
[
2
].
y
-
.
08
,
z
),
point
(
J1
.
pad
[
6
].
x
,
J1
.
pad
[
2
].
y
-
.
08
,
z
),
J1
.
pad
[
6
])
J2
=
header_FTDI
(
'J2 FTDI'
)
...
...
@@ -4638,30 +4686,38 @@ pcb = J2.add(pcb,x+width-.22,IC1.y-.0,z,angle=0)
pcb
=
wire
(
pcb
,
w
,
J1
.
pad
[
2
],
point
(
J2
.
x
,
J1
.
pad
[
2
].
y
,
z
),
point
(
J2
.
x
+
.
08
,
J1
.
pad
[
2
].
y
+
.
08
,
z
),
point
(
J2
.
x
+
.
08
,
J2
.
pad
[
3
].
y
,
z
),
J2
.
pad
[
3
])
pcb
=
wire
(
pcb
,
w
,
IC1
.
pad
[
13
],
point
(
IC1
.
pad
[
13
].
x
+
.
105
,
IC1
.
pad
[
13
].
y
,
z
),
point
(
IC1
.
pad
[
13
].
x
+
.
105
,
J2
.
pad
[
4
].
y
,
z
),
J2
.
pad
[
4
])
pcb
=
wire
(
pcb
,
w
,
IC1
.
pad
[
12
],
point
(
IC1
.
pad
[
12
].
x
+
.
07
,
J2
.
pad
[
5
].
y
,
z
),
point
(
IC1
.
pad
[
12
].
x
+
.
07
,
IC1
.
pad
[
12
].
y
,
z
),
point
(
IC1
.
pad
[
12
].
x
+
.
07
,
J2
.
pad
[
5
].
y
+
.
04
,
z
),
point
(
IC1
.
pad
[
12
].
x
+
.
11
,
J2
.
pad
[
5
].
y
,
z
),
J2
.
pad
[
5
])
XTAL1
=
XTAL_EFOBM
(
'XTAL1
\n
20 MHz'
)
pcb
=
XTAL1
.
add
(
pcb
,
IC1
.
pad
[
4
].
x
-
.
2
,
IC1
.
pad
[
13
].
y
+
.
00
8
,
z
,
angle
=-
90
)
pcb
=
XTAL1
.
add
(
pcb
,
IC1
.
pad
[
4
].
x
-
.
2
,
IC1
.
pad
[
13
].
y
+
.
00
3
,
z
,
angle
=-
90
)
pcb
=
wire
(
pcb
,
w
,
IC1
.
pad
[
2
],
point
(
XTAL1
.
x
+
.
12
,
IC1
.
pad
[
2
].
y
,
z
),
point
(
XTAL1
.
x
+
.
12
,
XTAL1
.
pad
[
1
].
y
,
z
),
XTAL1
.
pad
[
1
])
pcb
=
wire
(
pcb
,
w
,
J1
.
pad
[
6
],
point
(
J1
.
pad
[
6
].
x
,
J1
.
pad
[
6
].
y
-
.
08
,
z
),
point
(
XTAL1
.
x
-
.
04
,
J1
.
pad
[
6
].
y
-
.
08
,
z
),
point
(
XTAL1
.
x
-
.
12
,
J1
.
pad
[
6
].
y
,
z
),
point
(
XTAL1
.
x
-
.
12
,
XTAL1
.
pad
[
2
].
y
,
z
),
XTAL1
.
pad
[
2
])
...
...
@@ -4678,11 +4734,14 @@ pcb = wire(pcb,w,
pcb
=
wire
(
pcb
,
w
,
J2
.
pad
[
3
],
point
(
J2
.
pad
[
3
].
x
+
.
08
,
J2
.
pad
[
3
].
y
,
z
),
point
(
J2
.
pad
[
3
].
x
+
.
08
,
R1
.
y
+
.
06
,
z
),
point
(
R1
.
pad
[
1
].
x
,
R1
.
y
+
.
06
,
z
),
R1
.
pad
[
1
])
pcb
=
wire
(
pcb
,
w
,
R1
.
pad
[
2
],
point
(
J1
.
pad
[
5
].
x
,
R1
.
y
,
z
),
J1
.
pad
[
5
])
C1
=
C_1206
(
'C1
\n
1uF'
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment