I’m trying to write a script that iterates through a list of numbers, adding them until they reach a maximum, and then printing the lists of values. I have a list of four numbers that can be used and a Target number for the max limit:
import Rhino.LengthValue as rl import Rhino.Geometry as rg import rhinoscriptsyntax as rs import System.Double import clr clr.AddReference("Grasshopper") from Grasshopper.Kernel.Data import GH_Path from Grasshopper import DataTree def listspecs(List): Value = 0 for n in List: Value += n MassValue[:] =  MassValue.append(Value) ListLength[:] =  ListLength.append(len(List)) def iterate(i, j, SizeList): for size in Sizes: listspecs(SizeList) if MassValue <= Target: SizeList.append(size) iterate(i, j, SizeList) else: j += 1 MasterSizeList.AddRange(SizeList, GH_Path(i,j)) def start(i, j, SizeList): for size in Sizes: #MassValue = size i += 1 #j += 1 SizeList.append(size) iterate(i, j, SizeList) MasterSizeList = DataTree[System.Double]() i = -1 ListLength =  MassValue =  SizeList =  j = 0 start(i, j, SizeList)
The results that I’m Expecting are lists like:
(0.337, 0.337), (0.337, 0.362),…(0.362, 0.412),…(0.412, 0.412).
What I’m trying to do in the script is start with a number, add a number, test if it’s less than the target (0.9) and if it is then add another number and if it isn’t print the list of values without the last number that makes it go over the Target. Any advice or hints as to why my script isn’t working?