This program is growing using one list index.
but this time I have to create it based on two lists(Analysis point or Amount of solar radiation). Right?
Hi I dont think I understand the question clearly : what aspect do you need help with?
You can input both lists into your Python component.
If the lists are the same length so point 10 in list1 corresponds to radiation value 10 in list2 then you can use combined = zip(list1, list2) to get a new list of tuples of (point, radiation)
Graham
import Rhino.Geometry as rg
import random as rnd
class System():
def __init__(self, startIndex, radiationResult):
self.Indices = [startIndex]
self.radiation = [radiationResult]
print [radiationResult]
def AddNeighbour(self, testPts):
biggestIndex = -1
for index,Result in zip(self.Indices, self.radiation):
neighbourIndices = list(rg.RTree.Point3dClosestPoints(testPts, [testPts[index]], iGridSize + 0.1))
for neighbour in neighbourIndices[0]:
if neighbour > biggestIndex:
if neighbour not in self.Indices:
biggestIndex = neighbour
if biggestIndex > -1:
self.NewNeighbour = biggestIndex
def Update(self):
self.Indices.append(self.NewNeighbour)
###########################################
grid = testPts
if iRun:
if iReset or "system" not in globals():
system = System(iStartIndex, radiationResult)
else:
system.AddNeighbour(grid)
system.Update()
finalPts = []
if "system" in globals():
for index in system.Indices:
finalPts.append(grid[index])
oPts = finalPts
I use zip function!
but data have radiationResult list[0]
why?
This should do what you want. Just small modification:
Add new Input called iValues (list, float)
def AddNeighbour(self, pts):
biggestValue = -1
for index in self.Indices:
neighbourIndices = list(rg.RTree.Point3dClosestPoints(pts, [pts[index]], iGridSize + 0.1))
for neighbour in neighbourIndices[0]:
if iValues[neighbour] > biggestValue:
if neighbour not in self.Indices:
biggestValue = iValues[neighbour]
newIndex = neighbour
if newIndex > -1:
self.NewNeighbour = newIndex