This repository has been archived by the owner on Sep 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BlockAssembly_20180303_01_KS.py
76 lines (65 loc) · 2.15 KB
/
BlockAssembly_20180303_01_KS.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import rhinoscriptsyntax as rs
import re
import urllib2
import time
start = time.time()
distanceX = [0.,40.,40.,0.,0.,-40.,-40.,0.]
distanceY = [40.,0.,0.,40.,-40.,0.,0.,-40.]
distanceZ = [28.284271,28.284271,-28.284271,-28.284271,28.284271,28.284271,-28.284271,-28.284271]
response = urllib2.urlopen("http://maxiemgeldhof.com/node/raw")
text = response.read()
response.close()
print(time.time() - start)
distanceX = [x*2 for x in distanceX]
distanceY = [x*2 for x in distanceY]
distanceZ = [x*2 for x in distanceZ]
arrNodes = []
arrFaces = []
text = re.sub(";", "\n", text)
for line in text.split():
id = int(re.sub(":.*", "", line))
line = re.sub("^[0-9]*:", "", line)
surrounding = []
for number in re.sub(",", " ", line).split():
surrounding.append(int(number))
arrNodes.append(id)
arrFaces.append(surrounding)
print(time.time() - start)
#______________________________________________
class Node:
x=None
y=None
z=None
id=None
surrounding = []
def __init__(self,surrounding, id):
self.surrounding = surrounding
self.id = id
def getCoord(self):
return self.x, self.y, self.z
def sharePos(self,x,y,z):
if self.x is None:
self.x = x
self.y = y
self.z = z
for index, node in enumerate(self.surrounding):
if node != 0:
#self.array = [0,0,0,0,0,0,0,0]
#self.array[index] += 1
self.move = [distanceX[index], distanceY[index], distanceZ[index]]
getObj(node).sharePos(self.x + self.move[0], self.y + self.move[1], self.z + self.move[2])
def getObj(id):
for node in nodes:
if node.id == id:
return node
def calcspots():
nodes[0].sharePos(0., 0., 0.)
nodes = [Node(surrounding, id) for surrounding, id in zip(arrFaces, arrNodes)]
calcspots()
print(time.time() - start)
idOutput = []
pointOutput = []
for node in nodes:
idOutput.append(node.id)
pointOutput.append(rs.AddPoint(node.x, node.y, node.z))
print(time.time() - start)