forked from SDMrFeng/NestingForRhino6Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpointsReorder.py
More file actions
26 lines (25 loc) · 822 Bytes
/
Copy pathpointsReorder.py
File metadata and controls
26 lines (25 loc) · 822 Bytes
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
import rhinoscriptsyntax as rs
def PointsReorder(ptArr, op):
option = op
ordered = [0] * 5
# Read Op order
if option == 1:
# find if array need reorder
orig = 0
for i in range(0,4):
if round(ptArr[i][0]) <= round(ptArr[orig][0]) and round(ptArr[i][1]) <= round(ptArr[orig][1]):
orig = i
if orig == 0 or orig == 4:
return ptArr
else:
# start rotating sequence
for t in range(0,4):
# new index to assign
newIndex = (t + (4 - orig)) % 4
ordered[newIndex] = ptArr[t]
# concat first element back to last
temp = ordered[0]
ordered[4] = temp
return ordered
else:
return False