Gene Pool component

Thanks Anders.

In one of the two examples I changed the first line from System to decimal and this is the error:

TypeError: 'IGH_Param' object does not support item assignment

With the original first line (from System import Decimal), this error shows:

  1. Error running script: ‘str’ value cannot be converted to System.Currency in method Void .ctor(System.Currency) [15:1]

GenePool_mrtn.gh (15.3 KB)

from System import Convert

if genePool and values:
    if values[0]:
        gp = ghenv.Component.Params.Input[0].Sources[0]
        if (
            gp.Decimals != decimals
            or Convert.ToSingle(gp.Maximum) != interval.Max
            or Convert.ToSingle(gp.Minimum) != interval.Min
            or gp.Count != len(values)
        ):
            gp.Decimals = decimals
            gp.Maximum = Convert.ToDecimal(interval.Max)
            gp.Minimum = Convert.ToDecimal(interval.Min)
            gp.Count = len(values)
            for i in range(gp.Count):
                gp.__setitem__(i, Convert.ToDecimal(values[i]))
            gp.ExpireSolution(True)

GenePool-Py3.gh (10.4 KB)

4 Likes

Thank you Mahdiyar this works perfectly now!

2 Likes