I was trying to write a python script to extract a list of values expressed as string, my problem is that when I use the float() function, it changes the values as we can see in the pic
float()should work. Are you sure it’s not the GH panel that is truncating the decimals/doing scientific notation? Maybe try to print() the values inside the GHPython editor to see what they are?
Also, we would need the .jgw file to inspect further.
I think this might simply be the inherent floating point arithmetic (and more specifically displaying those), where you could use Decimal() to “see the exact value that’s stored in any particular Python float”:
Sorry to tell you that this way didn’t work, decimal.Decimal can’t be found
But I have found the solution:
import rhinoscriptsyntax as rs
import System.Convert as convert
def worldParam(file):
paramList =[]
with open(file, 'r', 0) as worldParamFile:
for line in worldParamFile:
paramList.append(convert.ToDecimal(line))
return paramList
a = worldParam(worldFile)
The trick was in calling a dotNet System.Convert and the result can be seen in the following pic
A quick remark from the side-line: passing anything through a panel will always convert that to a string. So: never-ever do that (unless you really want that result). \o/
Correction, there’s a 16 digits overall limitation.
It is reasonable though, if an object is 1 000 000 000 units of length then .0001 is of no relevance and if an object is 0.0001 units of length the 0.000100000000001 is of no relevance, nor is 100000.00 relevant to the latter.
Ironically this is coming from a naval architect who wishes to maintain constant 0.001 mm accuracy for ships.
I don’t know how to express to you that my problem now is that the component exports Boolean and not a number, not an integer and not a float, even when passing through a panel I don´t see a collection of Trues and False, but numbers.