i’m trying to automate the setting of the values of the Galapagos Genepool component, but my val(see attached image + gh definition) has to be an integer… How can I convert float to decimal so that it is accepted by the GalapagosGeneListObject? Decimal(val) doesn’t work.
from decimal import Decimal : won’t work. there is no “decimal” library to import
from System import Decimal: will work. System is an available library to import.
Note: From within the ghpython editor, when you type “import” , the autocomplete will show you the “out of the box” available libraries. There are discussions on the forum that describe ways to import libraries that aren’t listed by the autocomplete.
ok, thanks.
do you maybe know why my value is being automatically rounded (see picture). should I define a context for the conversion from float to decimal?
without seeing the code/component setup/file…I might guess that you should set the “val” input type hint to “No Type Hint”.
Conversely, I would guess that if you set it to “float”, you might not need to have to do any casting in your code, (your original error).
to clarify, in this case, the reason to set it to “no type hint” is because you are explicitly describing what type of object your val is, (in this case, a decimal/float).
And…in most cases, just setting the type hint makes life a little easier.