-
Notifications
You must be signed in to change notification settings - Fork 2
/
openscad.py
30 lines (26 loc) · 888 Bytes
/
openscad.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import sys
class OpenscadPolyhedron:
def __init__(self):
self.points = []
self.triangles = []
def write(self, file=None):
if file == None:
file = sys.stdout
file.write("polyhedron (\n")
file.write(" points = [ // {0} points\n".format(len(self.points)))
n = 0
for point in self.points:
file.write("[")
file.write(",".join(map(str,point)))
file.write("], // {0}\n".format(n))
n+=1
file.write("],\n")
file.write(" triangles = [ // {0} triangles\n".format(len(self.triangles)))
n = 0
for triangle in self.triangles:
file.write("[")
file.write(",".join(map(str,triangle)))
file.write("], // {0}\n".format(n))
n+=1
file.write("]\n")
file.write(");\n")